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/// Errors raised by [`Dep::validate`].
4499///
4500/// Mirrors the per-axis error families the other `:versao`-carrying
4501/// typed surfaces expose
4502/// ([`crate::AplicacaoError::MembroVersaoEmpty`] /
4503/// [`crate::AplicacaoError::MembroVersaoInvalid`],
4504/// [`crate::SupervisorError::EmptyChildVersion`] /
4505/// [`crate::SupervisorError::ChildVersaoInvalid`]) so a future top-
4506/// level `CaixaError` (M4) sums these without reshaping the diagnostic.
4507#[derive(Debug, Error, PartialEq, Eq)]
4508pub enum DepError {
4509    #[error(
4510        ":deps entry has empty :nome (every dep must name a target caixa; \
4511         omit the entry instead of carrying an empty name)"
4512    )]
4513    NomeEmpty,
4514    #[error(
4515        ":deps entry :nome {nome:?} is not a valid DNS-1123 label: {reason} \
4516         (the value flows verbatim as the target caixa's `:nome`, the rendered \
4517         `lareira-<nome>` Helm chart name segment, the `LABEL_PROGRAM` label \
4518         value, and the resolver's checkout-directory leaf — each apiserver-side \
4519         schema rejects non-DNS-1123 names at admission time; use a lowercase \
4520         RFC 1123 label like `\"caixa-teia\"` or `\"pleme-mesh\"`, 1..=63 bytes, \
4521         pattern `^[a-z0-9]([-a-z0-9]*[a-z0-9])?$`)"
4522    )]
4523    NomeInvalid { nome: String, reason: String },
4524    #[error(
4525        ":deps entry {nome:?} has empty :versao (every dep must pin a semver \
4526         constraint that resolves through the lacre pipeline)"
4527    )]
4528    VersaoEmpty { nome: String },
4529    #[error(
4530        ":deps entry {nome:?} :versao {versao:?} is not a valid semver \
4531         requirement: {reason} (use Cargo-shaped forms like `\"^0.1\"`, \
4532         `\"~0.1.2\"`, `\"0.1.0\"`, or `\"*\"` — the same shape `:membros :versao` \
4533         and `:children :versao` carry; the lacre pipeline resolves all three \
4534         through the same parser)"
4535    )]
4536    VersaoInvalid {
4537        nome: String,
4538        versao: String,
4539        reason: String,
4540    },
4541    #[error(
4542        ":deps entry {nome:?} :fonte (:tipo git …) has empty :repo \
4543         (every git source must name a repo — use a `github:org/repo` \
4544         shorthand, an `https://…` URL, or an ssh-git URL; omit the \
4545         entire :fonte block to fall back to the default-host resolver \
4546         convention)"
4547    )]
4548    FonteRepoEmpty { nome: String },
4549    #[error(
4550        ":deps entry {nome:?} :fonte (:tipo git …) :repo {repo:?} has \
4551         invalid value-shape: {reason} (the value flows verbatim into the \
4552         caixa-resolver's `git clone <repo>` subprocess invocation; every \
4553         documented form carries a `:` separator and no whitespace / \
4554         control / non-ASCII bytes — use a `github:org/repo` shorthand, \
4555         an `https://host/path` / `ssh://[user@]host/path` / \
4556         `git://host/path` / `file:///path` URL, or the `git@host:path` \
4557         scp-style SSH form)"
4558    )]
4559    FonteRepoShape {
4560        nome: String,
4561        repo: String,
4562        reason: String,
4563    },
4564    #[error(
4565        ":deps entry {nome:?} :fonte (:tipo git …) has no pin set \
4566         (set exactly one of :tag, :rev, or :branch so the resolver \
4567         can pick a reproducible commit; omit the entire :fonte block \
4568         to fall back to the default-host resolver convention, which \
4569         resolves the latest tag matching :versao)"
4570    )]
4571    FontePinMissing { nome: String },
4572    #[error(
4573        ":deps entry {nome:?} :fonte (:tipo git …) has multiple pins \
4574         set ({pins}); exactly one of :tag, :rev, or :branch must be \
4575         set so the resolver's checkout target is unambiguous (the \
4576         resolver's silent precedence is :rev > :tag > :branch — if \
4577         you intended one specifically, drop the others)"
4578    )]
4579    FontePinAmbiguous { nome: String, pins: String },
4580    #[error(
4581        ":deps entry {nome:?} :fonte (:tipo git …) has empty {pin} \
4582         (a set pin must name a non-empty git ref; drop the {pin} key \
4583         entirely to fall through to another pin axis)"
4584    )]
4585    FontePinEmpty { nome: String, pin: String },
4586    #[error(
4587        ":deps entry {nome:?} :fonte (:tipo git …) {pin} {value:?} has invalid \
4588         value-shape: {reason} (the git porcelain enforces the same shape at \
4589         `git fetch` / `git checkout` time on every pin; use a leaf refname \
4590         like `\"v0.1.0\"` for `:tag` or `\"main\"` / `\"feature/foo\"` for \
4591         `:branch`, or a full 40/64 lowercase-hex commit OID for `:rev` — \
4592         drop any `refs/heads/` or `refs/tags/` prefix the caixa-resolver \
4593         prepends at clone time, and avoid abbreviated SHAs which are \
4594         ambiguous across repository history)"
4595    )]
4596    FontePinShape {
4597        nome: String,
4598        pin: String,
4599        value: String,
4600        reason: String,
4601    },
4602    #[error(
4603        ":deps entry {nome:?} :fonte (:tipo path …) has empty :caminho \
4604         (every path source must name a non-empty filesystem path; \
4605         omit the entire :fonte block to fall back to the default-host \
4606         resolver convention)"
4607    )]
4608    FonteCaminhoEmpty { nome: String },
4609    #[error(
4610        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} is \
4611         absolute (the lacre pipeline embeds the value verbatim in its \
4612         per-dep content-address `path:{caminho}` at \
4613         caixa-resolver/src/resolve.rs:189, so an absolute path makes the \
4614         BLAKE3 closure differ across machines — defeating the \
4615         reproducibility contract that's load-bearing for CSE; express \
4616         the path relative to the caixa.lisp location, e.g. \
4617         \"../caixa-teia\" for a sibling workspace dep)"
4618    )]
4619    FonteCaminhoAbsolute { nome: String, caminho: String },
4620    #[error(
4621        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
4622         with `~` (the leading-tilde is a shell-expansion convention, not a \
4623         POSIX path component — `Path::is_absolute` returns false on it, so \
4624         the b94fd83 absolute-path gate doesn't catch it, but the lacre \
4625         pipeline embeds the value verbatim in its per-dep content-address \
4626         `path:{caminho}` at caixa-resolver/src/resolve.rs:189 and the \
4627         caixa-resolver folds it through `Path::join` without `~`-expansion, \
4628         so the build looks for a literal `./{caminho}` subdirectory and \
4629         fails at resolve time far from the source caixa.lisp; even worse, a \
4630         future caixa-resolver pass that *does* expand `~` would silently \
4631         re-open the host-layout-leak the b94fd83 absolute gate closes — \
4632         Alice's `~` resolves to `/home/alice`, Bob's to `/home/bob`, two CI \
4633         runners with different `$HOME` layouts resolve to two distinct paths \
4634         for the byte-identical caixa, defeating the THEORY.md §V.2 render-\
4635         determinism contract; express the path relative to the caixa.lisp \
4636         location, e.g. \"../caixa-teia\" for a sibling workspace dep, or \
4637         spell out the full relative path explicitly if a workstation-rooted \
4638         dep is genuinely intended)"
4639    )]
4640    FonteCaminhoTildeExpansion { nome: String, caminho: String },
4641    #[error(
4642        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
4643         with `$` (the leading-`$` is a shell-variable-expansion convention, \
4644         not a POSIX path component — `Path::is_absolute` returns false on it \
4645         and the a5c248e tilde gate doesn't catch it, but the lacre pipeline \
4646         embeds the value verbatim in its per-dep content-address \
4647         `path:{caminho}` at caixa-resolver/src/resolve.rs:189 and the \
4648         caixa-resolver folds it through `Path::join` without `$`-expansion, \
4649         so the build looks for a literal `./{caminho}` subdirectory and \
4650         fails at resolve time far from the source caixa.lisp; even worse, a \
4651         future caixa-resolver pass that *does* expand `$VAR` (the canonical \
4652         shell-convention idiom that CI's `${{WORKSPACE}}` paste-idiom \
4653         invites) would silently re-open the host-layout-leak the b94fd83 \
4654         absolute gate closes — Alice's `$HOME` resolves to `/home/alice`, \
4655         Bob's to `/home/bob`, two CI runners with different `${{WORKSPACE}}` \
4656         layouts resolve to two distinct paths for the byte-identical caixa, \
4657         defeating the THEORY.md §V.2 render-determinism contract; express \
4658         the path relative to the caixa.lisp location, e.g. \"../caixa-teia\" \
4659         for a sibling workspace dep, or spell out the full relative path \
4660         explicitly if a workstation-rooted dep is genuinely intended)"
4661    )]
4662    FonteCaminhoVarExpansion { nome: String, caminho: String },
4663    #[error(
4664        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
4665         with a space (the leading ASCII space `0x20` is the orthogonal \
4666         paste-from-aligned-doc footgun that silently passes \
4667         `Path::is_absolute` and every prior leading-byte arm — \
4668         `\" ../caixa-teia\"` resolves via `Path::join` to a literal \
4669         `./ ../caixa-teia` subdirectory the resolver fails to find at \
4670         resolve time with a non-self-locating `No such file or directory` \
4671         error far from the source caixa.lisp; the lacre pipeline embeds \
4672         the value verbatim in its per-dep content-address `path:{caminho}` \
4673         at caixa-resolver/src/resolve.rs:189, so byte-divergent / \
4674         semantic-identical caixa values (` ../caixa-teia` vs \
4675         `../caixa-teia`) yield two distinct BLAKE3 closures across two \
4676         workstations whose authors differ only in paste-from-aligned- \
4677         caixa.lisp-doc whitespace habits — the most insidious failure \
4678         mode the typed slot can carry (no error surfaces; the divergence \
4679         is invisible until two machines compare lacres), defeating the \
4680         THEORY.md §V.2 render-determinism contract. The canonical \
4681         paste-from-aligned-`:deps`-block footgun (every `:fonte` form in \
4682         a multi-entry `:deps` block sits at the same column — an author \
4683         selecting `\"<sp><sp><sp>../caixa-teia\"` and pasting it from \
4684         the rendered alignment into a fresh entry preserves the leading \
4685         whitespace verbatim); peer `:fonte :repo` axis already rejects \
4686         leading whitespace via `is_git_repo_url`, `:fonte :tag` / \
4687         `:fonte :branch` via `is_git_ref_name`, `:descricao` via \
4688         `is_chart_description_shape`, `:licenca` via \
4689         `is_spdx_expression_shape`. Drop the leading space; express the \
4690         path as a bare relative single-token like \"../caixa-teia\")"
4691    )]
4692    FonteCaminhoLeadingWhitespace { nome: String, caminho: String },
4693    #[error(
4694        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
4695         with `-` (the canonical CLI-argument-injection footgun on the \
4696         `:caminho` axis — the lacre pipeline embeds the value verbatim in \
4697         its per-dep content-address `path:{caminho}` at \
4698         caixa-resolver/src/resolve.rs:189 and the caixa-resolver folds it \
4699         through `Path::join` looking for a literal `./{caminho}` \
4700         subdirectory. Every downstream subprocess that consumes the resolved \
4701         path — `git -C {caminho} <verb>`, `terraform -chdir={caminho}`, \
4702         `nix build --path {caminho}`, `find {caminho}`, `stat {caminho}`, \
4703         `cp -r {caminho} …`, `rm -rf {caminho}` — reinterprets a leading-`-` \
4704         value as a CLI flag rather than a positional path when the invocation \
4705         does not carry a `--` argument-list terminator between the flag block \
4706         and the path (the common case at every porcelain entry point). The \
4707         canonical footguns: `:caminho \"-rf\"` (bare short-flag paste), \
4708         `:caminho \"-C\"` (`git -C -C` config-injection paste), \
4709         `:caminho \"--upload-pack=cat /etc/passwd\"` (the canonical long-flag \
4710         CLI-arg-injection vector at every git porcelain entry point that \
4711         consumes a path or URL argument, peer with is_git_repo_url's \
4712         leading-`-` arm on the sibling `:fonte :repo` axis), \
4713         `:caminho \"--config=…\"` (`git -c foo=bar` config-override paste). \
4714         POSIX `std::path::Path` treats a leading `-` as a literal filename \
4715         byte so the resolver folds `\"-rf\"` through `Path::join` and looks \
4716         for a literal `./-rf` subdirectory that fails at resolve time with a \
4717         non-self-locating `No such file or directory` error far from the \
4718         source caixa.lisp — but on any downstream shell-out without `--` the \
4719         reinterpretation is silent and the failure mode is arbitrary-\
4720         argument-injection. Peer arms: `is_git_repo_url` (render.rs:2037) \
4721         rejects leading `-` on `:fonte :repo` for `git clone <repo>` CLI-\
4722         arg-injection; `is_git_ref_name` (render.rs:1381, 5a28454) rejects \
4723         leading `-` on `:fonte :tag` / `:branch` for `git checkout <ref>` \
4724         CLI-arg-injection; `is_dns_1123_label` rejects leading `-` on every \
4725         DNS-1123-shaped axis (top-level Caixa `:nome`, `:membros :caixa`, \
4726         `:children :caixa`, `:deps :nome`, cluster names); \
4727         `is_cargo_feature_name` rejects leading `-` on `:caracteristicas`; \
4728         the feira `init` / `add <nome>` positional gate (868c191) rejects \
4729         leading `-` on the CLI positional itself. Express the path as a bare \
4730         relative single-token like \"../caixa-teia\" — the sibling-workspace \
4731         directory name carries no leading-hyphen semantic, and `./` / `../` \
4732         prefixes structurally partition the leading-byte set to safe values.)"
4733    )]
4734    FonteCaminhoLeadingHyphen { nome: String, caminho: String },
4735    #[error(
4736        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains \
4737         ASCII control byte 0x{byte:02x} (POSIX paths reject NUL `0x00` outright — \
4738         every `std::fs` syscall routes the path through `CString::new` which \
4739         fails with `NulError` at resolve time; the lacre pipeline embeds the \
4740         value verbatim in its per-dep content-address `path:{caminho}` at \
4741         caixa-resolver/src/resolve.rs:189 so a control byte anywhere in the \
4742         value lands in the BLAKE3 closure and breaks the THEORY.md §V.2 render-\
4743         determinism contract — the canonical paste-from-multiline-doc \
4744         (`\\n`/`\\r`), paste-from-aligned-table (`\\t`), or paste-from-binary-\
4745         blob (`0x00`-DEL) footgun every peer single-token-shaped axis \
4746         (`:fonte :repo`, `:fonte :tag`/`:branch`, the Helm chart-string axes) \
4747         already gates against. Express the path as a relative single-line ASCII \
4748         string, e.g. \"../caixa-teia\" for a sibling workspace dep)"
4749    )]
4750    FonteCaminhoControlChar {
4751        nome: String,
4752        caminho: String,
4753        byte: u8,
4754    },
4755    #[error(
4756        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains `\\` \
4757         (POSIX `std::path::Path` treats `\\` as a literal byte inside a single path \
4758         component, so `..\\caixa-teia` is one directory named literally `..\\caixa-teia` — \
4759         not the parent's sibling — and the caixa-resolver folds the value through \
4760         `Path::join` looking for a literal `./{caminho}` subdirectory that fails at \
4761         resolve time with a non-self-locating `No such file or directory` error far \
4762         from the source caixa.lisp; Windows `std::path::Path` treats `\\` as a \
4763         primary path separator equal to `/`, so byte-identical caixa.lisp values \
4764         resolve to two distinct directories across runner OSes — the lacre pipeline \
4765         embeds the value verbatim in its per-dep content-address `path:{caminho}` at \
4766         caixa-resolver/src/resolve.rs:189, defeating the THEORY.md §V.2 render-\
4767         determinism contract via the cross-host-OS-separator divergence vector. The \
4768         canonical Windows-Explorer `Copy as path` / PowerShell `Get-Location` \
4769         paste-idiom footgun; peer `:fonte :tag` / `:fonte :branch` axis already \
4770         rejects `\\` via `is_git_ref_name` for the same Windows-path-leak reason, \
4771         and `:entrada :paths` rejects `\\` via `is_gateway_api_http_path`'s eleven-\
4772         byte RFC-3986-reserved set. Express the path with `/` as the separator, e.g. \
4773         \"../caixa-teia\" for a sibling workspace dep)"
4774    )]
4775    FonteCaminhoBackslash { nome: String, caminho: String },
4776    #[error(
4777        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4778         redirection metacharacter 0x{byte:02x} `{ch}` (every interactive shell — bash / \
4779         zsh / fish / nushell — lexes `<` and `>` as input / output redirection \
4780         operators, so `:caminho \"../caixa-teia>build.log\"` is the canonical \
4781         paste-from-shell-pipeline footgun where an author copies a `command > log` \
4782         tail without trimming the redirect; POSIX `std::path::Path` treats both bytes \
4783         as literal path-component bytes, so the resolver folds the value through \
4784         `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
4785         subdirectory and fails at resolve time with a non-self-locating `No such \
4786         file or directory` error far from the source caixa.lisp. The lacre pipeline \
4787         embeds the value verbatim in its per-dep content-address `path:{caminho}` at \
4788         caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure \
4789         and rides into every shell-spawned subprocess (the resolver's `git clone`, a \
4790         future `feira tofu` shell-out, a future operator-side `nix` spawn) as the \
4791         canonical CRLF-at-subprocess-argument / shell-metachar injection surface every \
4792         peer single-token-shaped typed slot already closes. The peer `:fonte :tag` / \
4793         `:fonte :branch` axis already rejects `<` / `>` via `is_git_ref_name`, and \
4794         `:entrada :paths` rejects them via `is_gateway_api_http_path`'s eleven-byte \
4795         RFC-3986-reserved set. Express the path as a bare relative single-token like \
4796         \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
4797         redirection semantic.",
4798        ch = *byte as char
4799    )]
4800    FonteCaminhoShellRedirection {
4801        nome: String,
4802        caminho: String,
4803        byte: u8,
4804    },
4805    #[error(
4806        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-pipe \
4807         metacharacter `|` (every interactive shell — bash / zsh / fish / nushell — lexes \
4808         `|` as the pipe operator that wires one command's stdout to the next command's \
4809         stdin, so `:caminho \"../caixa-teia | grep foo\"` is the canonical paste-from-\
4810         shell-history footgun where an author copies a `ls ../caixa-teia | grep` line \
4811         without trimming the pipeline tail, and `:caminho \"../foo||bar\"` is the \
4812         symmetric `cmd-a || cmd-b` short-circuit-OR paste shape; POSIX `std::path::Path` \
4813         treats `|` as a literal path-component byte, so the resolver folds the value \
4814         through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
4815         subdirectory and fails at resolve time with a non-self-locating `No such file or \
4816         directory` error far from the source caixa.lisp. The lacre pipeline embeds the \
4817         value verbatim in its per-dep content-address `path:{caminho}` at caixa-resolver/\
4818         src/resolve.rs:189, so the byte lands in the BLAKE3 closure and rides into every \
4819         shell-spawned subprocess (the resolver's `git clone`, a future `feira tofu` \
4820         shell-out, a future operator-side `nix` spawn) as the canonical CRLF-at-\
4821         subprocess-argument / shell-metachar injection surface every peer single-token-\
4822         shaped typed slot already closes. The peer `:entrada :paths` axis rejects `|` \
4823         via `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the \
4824         path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
4825         workspace directory name carries no shell-pipe semantic."
4826    )]
4827    FonteCaminhoShellPipe { nome: String, caminho: String },
4828    #[error(
4829        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4830         command-separator metacharacter `;` (every interactive shell — bash / zsh / fish \
4831         / nushell — lexes `;` as the sequential-command terminator that fires the next \
4832         command regardless of the prior command's exit status, so `:caminho \
4833         \"../caixa-teia; rm -rf build\"` is the canonical paste-from-shell-one-liner \
4834         footgun where an author copies a `cd path; do-thing` chain without trimming \
4835         the cleanup tail, and `:caminho \"../foo;;bar\"` is the symmetric POSIX `case` \
4836         arm `;;` terminator paste shape; POSIX `std::path::Path` treats `;` as a \
4837         literal path-component byte, so the resolver folds the value through \
4838         `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
4839         subdirectory and fails at resolve time with a non-self-locating `No such file \
4840         or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
4841         the value verbatim in its per-dep content-address `path:{caminho}` at \
4842         caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
4843         rides into every shell-spawned subprocess (the resolver's `git clone`, a \
4844         future `feira tofu` shell-out, a future operator-side `nix` spawn) as the \
4845         canonical shell-metachar injection surface every peer single-token-shaped \
4846         typed slot already closes. The peer `:entrada :paths` axis rejects `;` via \
4847         `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the \
4848         path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
4849         workspace directory name carries no shell-command-separator semantic."
4850    )]
4851    FonteCaminhoShellSemicolon { nome: String, caminho: String },
4852    #[error(
4853        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4854         background / list-AND metacharacter `&` (every interactive shell — bash / zsh \
4855         / fish / nushell — lexes `&` two ways: single `&` as the background-task \
4856         terminator detaching the prior command and returning control immediately to \
4857         the prompt, double `&&` as the logical-AND list operator firing the next \
4858         command only if the prior succeeded; POSIX `std::path::Path` treats it as a \
4859         literal byte. The canonical paste-from-shell-prompt footgun is a `cd path & \
4860         sleep 1` background-launch one-liner or a `cd path && make install` build-\
4861         chain idiom selected whole into the `:caminho` slot — the prior `;` arm at \
4862         05c358e closed the sequential-command-separator vector, this arm closes the \
4863         orthogonal background-task / logical-AND vector on the same paste-from-shell-\
4864         prompt class. The lacre pipeline embeds the value verbatim in its per-dep \
4865         content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the \
4866         byte lands in the BLAKE3 closure and rides into every shell-spawned \
4867         subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a \
4868         future operator-side `nix` spawn) as the canonical shell-metachar injection \
4869         surface every peer single-token-shaped typed slot already closes. The peer \
4870         `:entrada :paths` axis rejects `&` via `is_gateway_api_http_path`'s eleven-\
4871         byte RFC-3986-reserved set. Express the path as a bare relative single-token \
4872         like \"../caixa-teia\" — the sibling-workspace directory name carries no \
4873         shell-background / logical-AND semantic."
4874    )]
4875    FonteCaminhoShellBackground { nome: String, caminho: String },
4876    #[error(
4877        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4878         command-substitution metacharacter `` ` `` (every POSIX shell — sh / bash / zsh / \
4879         dash / ksh / fish / nushell — lexes the byte as the legacy command-substitution \
4880         wrapper that runs the enclosed command and substitutes its standard-output \
4881         verbatim into the surrounding word, so a backticked `whoami` expands to the \
4882         current user's name and a backticked `cat /etc/passwd` expands to the file's \
4883         contents — the canonical CWE-78 shell-command-injection vector; POSIX \
4884         `std::path::Path` treats the byte as a literal path-component byte. The canonical \
4885         paste-from-shell-prompt footgun is a `cd ../path/<backtick>whoami<backtick>` legacy substitution \
4886         one-liner or a `cd <backtick>pwd<backtick>/path` working-directory expansion idiom selected whole \
4887         into the `:caminho` slot — the prior `&` arm at e12e4f3 closed the shell-\
4888         background / logical-AND vector, this arm closes the orthogonal command-\
4889         substitution vector on the same paste-from-shell-prompt class (the modern `$()` \
4890         form is gated at leading position by the f4efe9c `FonteCaminhoVarExpansion` arm; \
4891         the legacy backtick form is the orthogonal axis). The lacre pipeline embeds the \
4892         value verbatim in its per-dep content-address `path:{caminho}` at \
4893         caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
4894         rides into every shell-spawned subprocess (the resolver's `git clone`, a future \
4895         `feira tofu` shell-out, a future operator-side `nix` spawn) as the canonical \
4896         shell-metachar injection surface every peer single-token-shaped typed slot \
4897         already closes. The peer `:entrada :paths` axis rejects the byte via \
4898         `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the path \
4899         as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
4900         directory name carries no shell-command-substitution semantic."
4901    )]
4902    FonteCaminhoShellCommandSubstitution { nome: String, caminho: String },
4903    #[error(
4904        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4905         glob / pathname-expansion metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — \
4906         sh / bash / zsh / dash / ksh / fish / nushell — lexes `*` and `?` as pathname-\
4907         expansion wildcards: `*` matches any sequence of characters in a path component \
4908         and `?` matches exactly one character, so a `:caminho \"../caixa-teia/*\"` is the \
4909         canonical paste-from-shell-listing footgun where an author copies a \
4910         `ls ../caixa-teia/*` listing without trimming the wildcard, and `:caminho \
4911         \"../foo?\"` is the symmetric single-char-wildcard paste shape; POSIX \
4912         `std::path::Path` treats both bytes as literal path-component bytes, so the \
4913         resolver folds the value through `Path::new(caminho).join(<file>)` looking for \
4914         a literal `./{caminho}` subdirectory and fails at resolve time with a non-self-\
4915         locating `No such file or directory` error far from the source caixa.lisp. The \
4916         lacre pipeline embeds the value verbatim in its per-dep content-address \
4917         `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in the \
4918         BLAKE3 closure and rides into every shell-spawned subprocess (the resolver's \
4919         `git clone`, a future `feira tofu` shell-out, a future operator-side `nix` \
4920         spawn) as the canonical shell-metachar / glob-expansion surface every peer \
4921         single-token-shaped typed slot already closes. The peer `:entrada :paths` axis \
4922         rejects `*` and `?` via `is_gateway_api_http_path`'s eleven-byte RFC-3986-\
4923         reserved set. Express the path as a bare relative single-token like \
4924         \"../caixa-teia\" — the sibling-workspace directory name carries no shell-glob \
4925         / pathname-expansion semantic.",
4926        ch = *byte as char
4927    )]
4928    FonteCaminhoShellGlob {
4929        nome: String,
4930        caminho: String,
4931        byte: u8,
4932    },
4933    #[error(
4934        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4935         subshell-grouping metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / \
4936         zsh / dash / ksh / fish / nushell — lexes `(` and `)` as the subshell-grouping \
4937         operator: `(<cmd>)` runs `<cmd>` in a child shell with a fresh environment scope \
4938         (the canonical `(cd <path> && <cmd>)` shell-history one-liner scopes a `cd` to one \
4939         subshell without disturbing the parent's working directory), and `$(<cmd>)` is the \
4940         modern Bourne command-substitution shape the leading-`$` `FonteCaminhoVarExpansion` \
4941         arm closes the leading byte of — together the two arms now structurally exclude the \
4942         entire `$(<cmd>)` substitution surface from the typed `:caminho` accepted set. \
4943         POSIX `std::path::Path` treats the byte as a literal path-component byte, so a \
4944         `:caminho \"../caixa-teia/$(date)/build\"` (the canonical paste-from-shell-history \
4945         modern-command-substitution footgun) or `:caminho \"../(cd foo && pwd)/caixa-teia\"` \
4946         (the symmetric subshell-grouping working-directory-probe paste idiom) silently passes \
4947         every prior arm and the resolver folds the value through `Path::new(caminho).join(\
4948         <file>)` looking for a literal subdirectory and fails at resolve time with a non-\
4949         self-locating `No such file or directory` error far from the source caixa.lisp. The \
4950         lacre pipeline embeds the value verbatim in its per-dep content-address `path:\
4951         {caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 \
4952         closure and rides into every shell-spawned subprocess (the resolver's `git clone`, a \
4953         future `feira tofu` shell-out, a future operator-side `nix` spawn) as the canonical \
4954         shell-metachar / subshell-grouping surface every peer single-token-shaped typed slot \
4955         already closes. The peer `:fonte :repo` axis (3b99147) closes the same byte under the \
4956         same shell-subshell-grouping / RFC-3986-sub-delims banner on `is_git_repo_url`, \
4957         together with the leading-`$` `FonteCaminhoVarExpansion` arm closing the leading byte \
4958         of every `$(<cmd>)` shape. Express the path as a bare relative single-token \
4959         like \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
4960         subshell-grouping semantic.",
4961        ch = *byte as char
4962    )]
4963    FonteCaminhoShellSubshellGrouping {
4964        nome: String,
4965        caminho: String,
4966        byte: u8,
4967    },
4968    #[error(
4969        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4970         brace-expansion / URI-Template placeholder metacharacter 0x{byte:02x} `{ch}` \
4971         (every POSIX-derived brace-expanding shell — bash / zsh / ksh / fish — lexes `{{` / \
4972         `}}` as the brace-expansion operator: `{{a,b,c}}` expands to the cross-product of \
4973         comma-separated members and `{{1..10}}` expands to the integer range — the \
4974         canonical `mkdir -p ../{{caixa-teia,caixa-helm,caixa-flux}}` / `cp file{{,.bak}}` \
4975         idiom every shell-history block carries; RFC 6570 reserves the matched pair for \
4976         URI Template placeholders (the canonical `https://{{host}}/{{org}}/{{repo}}` \
4977         substitution shape every OpenAPI / Swagger / Postman / GitHub Octokit client \
4978         library / Helm chart-URL fragment carries) and the Mustache / Handlebars / \
4979         Tera / Jinja2 / Go html/template doubled-brace substitution form every IaC \
4980         templating engine (Helm, Kustomize, Terraform's `${{var}}` cousin) emits. POSIX \
4981         `std::path::Path` treats the byte as a literal path-component byte, so a \
4982         `:caminho \"../{{caixa-teia,caixa-helm}}/build\"` (the canonical paste-from-\
4983         shell-history brace-expansion fan-across-siblings footgun) or `:caminho \"../{{{{org}}}}/\
4984         caixa-teia\"` (the symmetric paste-from-templated-doc URI-Template placeholder \
4985         idiom every README quick-start / OpenAPI spec / Helm chart `home:` field carries) \
4986         silently passes every prior arm and the resolver folds the value through \
4987         `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
4988         resolve time with a non-self-locating `No such file or directory` error far from \
4989         the source caixa.lisp. The lacre pipeline embeds the value verbatim in its \
4990         per-dep content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, \
4991         so the byte lands in the BLAKE3 closure and rides into every shell-spawned \
4992         subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a \
4993         future operator-side `nix` spawn) as the canonical shell-metachar / brace-\
4994         expansion / URI-Template-placeholder surface every peer single-token-shaped \
4995         typed slot already closes. The peer `:fonte :repo` axis (42d8f9d) closes the \
4996         same byte pair on `is_git_repo_url` under the same RFC-3986-'delims' / \
4997         RFC-6570-URI-Template / shell-brace-expansion banner. Express the path as a \
4998         bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
4999         directory name carries no shell-brace-expansion / URI-Template-placeholder \
5000         semantic; if two siblings actually need pinning, author two separate `:deps` \
5001         entries rather than one brace-expanded `:caminho` value.",
5002        ch = *byte as char
5003    )]
5004    FonteCaminhoShellBraceExpansion {
5005        nome: String,
5006        caminho: String,
5007        byte: u8,
5008    },
5009    #[error(
5010        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5011         bracket-expansion / POSIX glob-character-class / shell-`test`-builtin metacharacter \
5012         0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / nushell \
5013         — lexes the bracket pair as the glob character-class operator: `[abc]` matches one of \
5014         `a` / `b` / `c`, `[a-z]` matches any lowercase ASCII letter, `[^x]` negates — the \
5015         canonical `ls *.[ch]` C-source-file glob and `cd ../caixa-[a-z]*` lowercase-sibling \
5016         glob every shell-history block carries; the bracket pair additionally carries the \
5017         POSIX `test` / `[` builtin command (`[ -d ../caixa-teia ] && cd ...` every shell-\
5018         script conditional uses) and bash's `[[ ... ]]` extended-test grammar; beyond shell \
5019         the pair is the TOML inline-array delimiter (`features = [\"a\", \"b\"]` — the \
5020         canonical paste-from-Cargo-manifest cross-idiom-leak vector), the YAML flow-sequence \
5021         delimiter (`paths: [/a, /b]` — the canonical paste-from-values.yaml cross-idiom \
5022         leak), the JSON array delimiter, and the POSIX-ERE / PCRE bracket-expression anchor. \
5023         POSIX `std::path::Path` treats the byte as a literal path-component byte, so a \
5024         `:caminho \"../caixa-[a-z]/build\"` (the canonical paste-from-shell-history glob-\
5025         character-class fan-across-siblings footgun) or `:caminho \"../[caixa-teia]/build\"` \
5026         (the symmetric paste-from-TOML-array / paste-from-YAML-flow-sequence cross-idiom \
5027         leak) silently passes every prior arm and the resolver folds the value through \
5028         `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
5029         resolve time with a non-self-locating `No such file or directory` error far from \
5030         the source caixa.lisp. The lacre pipeline embeds the value verbatim in its per-dep \
5031         content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte \
5032         lands in the BLAKE3 closure and rides into every shell-spawned subprocess (the \
5033         resolver's `git clone`, a future `feira tofu` shell-out, a future operator-side \
5034         `nix` spawn) as the canonical shell-metachar / glob-character-class / TOML-array \
5035         surface every peer single-token-shaped typed slot already closes. Express the path \
5036         as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
5037         directory name carries no shell-bracket-expansion / glob-character-class / array-\
5038         literal semantic; if a family of sibling caixas actually needs pinning, author \
5039         separate `:deps` entries rather than one character-class-expanded `:caminho` value.",
5040        ch = *byte as char
5041    )]
5042    FonteCaminhoShellBracketExpansion {
5043        nome: String,
5044        caminho: String,
5045        byte: u8,
5046    },
5047    #[error(
5048        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5049         quote-grouping / cross-config-DSL string-literal-delimiter metacharacter \
5050         0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / \
5051         nushell — lexes `'` as the strong string-literal delimiter (`'…'` — no expansion) \
5052         and `\"` as the weak string-literal delimiter (`\"…\"` — variable- / command-\
5053         substitution-preserving); the canonical `cd '../caixa-teia'` shell-history idiom \
5054         every path-with-embedded-whitespace paste block carries and the symmetric \
5055         `git clone \"$REPO\"` weak-quoted CI-manifest shape both leak the pair verbatim. \
5056         Beyond shell the pair is the JSON string-literal delimiter (`\"key\": \"value\"` — \
5057         the canonical paste-from-JSON-config cross-idiom-leak vector), the YAML double- \
5058         and single-quoted flow-scalar delimiter (`path: \"../caixa-teia\"` — the canonical \
5059         paste-from-values.yaml / paste-from-K8s-YAML-manifest cross-idiom leak), the TOML \
5060         basic and literal string delimiter (`path = \"../caixa-teia\"` — the canonical \
5061         paste-from-Cargo-manifest cross-idiom leak), the tatara-lisp string-literal \
5062         delimiter itself (`(:caminho \"../caixa-teia\")` — the canonical \"I copied the \
5063         entire `:caminho \"...\"` slot rather than just the string body\" author-surface \
5064         footgun), and RFC 3986 §2.2's `gen-delims` / `sub-delims` grammar which excludes \
5065         both bytes from the `pchar = unreserved / pct-encoded / sub-delims / \":\" / \"@\"` \
5066         production. POSIX `std::path::Path` treats the byte as a literal path-component \
5067         byte, so a `:caminho \"'../caixa-teia'\"` (the canonical paste-from-shell-history \
5068         strong-quoted sibling-workspace path footgun) or `:caminho \"\\\"../caixa-teia\\\"\"` \
5069         (the symmetric weak-quoted paste-from-JSON / paste-from-YAML flow-scalar / paste-\
5070         from-TOML basic-string / paste-from-tatara-lisp string-literal cross-idiom-leak \
5071         shape) silently passes every prior arm and the resolver folds the value through \
5072         `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
5073         resolve time with a non-self-locating `No such file or directory` error far from \
5074         the source caixa.lisp. The lacre pipeline embeds the value verbatim in its per-dep \
5075         content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte \
5076         lands in the BLAKE3 closure and rides into every shell-spawned subprocess (the \
5077         resolver's `git clone`, a future `feira tofu` shell-out, a future operator-side \
5078         `nix` spawn) as the canonical shell-metachar / string-literal-delimiter surface \
5079         every peer single-token-shaped typed slot already closes. The peer `:fonte :repo` \
5080         axis closes both bytes under the same shell-quote-grouping / RFC-3986-sub-delims \
5081         banner (e7a109f `'` shell-single-quote + 4267d8b `\"` shell-double-quote on \
5082         `is_git_repo_url`). Express the path as a bare relative single-token like \
5083         \"../caixa-teia\" — the sibling-workspace directory name carries no shell-quote-\
5084         grouping / string-literal-delimiter semantic; strip the outer quote pair from the \
5085         paste (the tatara-lisp `:caminho \"...\"` slot already carries the string-literal \
5086         quoting on the outer syntactic layer, so an inner quote pair would nest and \
5087         desugar to a broken layer).",
5088        ch = *byte as char
5089    )]
5090    FonteCaminhoShellQuoteGrouping {
5091        nome: String,
5092        caminho: String,
5093        byte: u8,
5094    },
5095    #[error(
5096        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5097         comment / URL-fragment-identifier / YAML-comment cross-config-DSL metacharacter \
5098         0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / \
5099         nushell — lexes an unquoted `#` at the head of a word or after unquoted \
5100         whitespace as the comment-lead per POSIX.1-2017 §2.3 Token Recognition step 6, \
5101         discarding the byte and everything after it to the end of the physical line \
5102         before command parsing (`cd ../caixa-teia  # legacy sibling` — the canonical \
5103         paste-from-shell-history-with-trailing-annotation shape every operator-notebook \
5104         and CI-manifest carries); YAML 1.2 §6.6 makes `#` the comment-lead at any \
5105         position preceded by whitespace or at line-start (`path: ../caixa-teia  # pin` \
5106         — the canonical paste-from-values.yaml / paste-from-K8s-manifest cross-idiom-\
5107         leak); RFC 3986 §3.5 reserves `#` as the URL fragment-identifier delimiter (the \
5108         canonical paste-from-browser-address-bar `github.com/foo/bar#readme` / \
5109         `github.com/foo/bar#L42` permalink shape, and the symmetric Nix-flake-ref \
5110         cross-idiom leak `github:foo/bar#packageName` where `#` selects a flake \
5111         output); the same cross-config-DSL surface extends to HCL / Terraform / Nix \
5112         flake attributes / dotenv `.env` / gitconfig / .gitignore / ini / TOML where \
5113         `#` is likewise the comment-lead. POSIX `std::path::Path` treats the byte as a \
5114         literal path-component byte, so a `:caminho \"../caixa-teia # legacy sibling\"` \
5115         (the canonical paste-from-shell-history-with-trailing-annotation footgun), \
5116         `:caminho \"../caixa-teia  # pin\"` (the symmetric YAML flow-scalar paste-with-\
5117         trailing-comment shape), or `:caminho \"../caixa-teia#readme\"` (the URL \
5118         fragment paste-from-browser-address-bar shape) silently passes every prior arm \
5119         and the resolver folds the value through `Path::new(caminho).join(<file>)` \
5120         looking for a literal subdirectory named `../caixa-teia # legacy sibling` and \
5121         fails at resolve time with a non-self-locating `No such file or directory` \
5122         error far from the source caixa.lisp — while every downstream shell / YAML / \
5123         URL parser silently truncates the value at the `#` byte to `../caixa-teia`, so \
5124         a `feira tofu` shell-out and a `nix flake check` on an emitted YAML `path:` \
5125         scalar disagree with the resolver on which directory the value names. The \
5126         lacre pipeline embeds the value verbatim in its per-dep content-address \
5127         `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in \
5128         the BLAKE3 closure and rides into every shell-spawned subprocess (the \
5129         resolver's `git clone`, a future `feira tofu` shell-out, a future operator-\
5130         side `nix` spawn) as the canonical shell-metachar / comment-lead / URL-\
5131         fragment-delimiter surface every peer single-token-shaped typed slot already \
5132         closes. The peer `:fonte :repo` axis closes the byte under the same URL-\
5133         fragment-identifier banner (a68f818 `#` on `is_git_repo_url`). Express the \
5134         path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
5135         workspace directory name carries no shell-comment / URL-fragment / YAML-\
5136         comment semantic; move any trailing annotation to a tatara-lisp `;`-comment \
5137         on the surrounding form (`;; legacy sibling` above the `(:caminho ...)` slot) \
5138         and drop any `#fragment` tail entirely (fragment identifiers select \
5139         renderings, not directories, and `:caminho` names a directory).",
5140        ch = *byte as char
5141    )]
5142    FonteCaminhoShellComment {
5143        nome: String,
5144        caminho: String,
5145        byte: u8,
5146    },
5147    #[error(
5148        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains URL-\
5149         percent-encoding-escape / printf-format-specifier / bash-job-control-specifier \
5150         / YAML-directive-lead metacharacter 0x{byte:02x} `{ch}` (RFC 3986 §2.1 reserves \
5151         `%` as the URL percent-encoding-escape — `%HH` is the mandatory encoding \
5152         mechanism for every byte outside the `unreserved` alphanumeric / `-` / `.` / \
5153         `_` / `~` set, and `%` itself must be percent-encoded as `%25` to appear \
5154         literally inside a URL value. The canonical paste-from-browser-address-bar \
5155         percent-encoded-space footgun (an author copies `../caixa%20teia` out of a URL-\
5156         encoded README hyperlink / browser address bar / percent-encoded permalink \
5157         expecting `%20` to decode to a literal space at the filesystem layer) locks two \
5158         distinct BLAKE3 closures (`path:../caixa%20teia` vs `path:../caixa teia`) for \
5159         what the author intended as the byte-identical sibling-workspace dep. POSIX \
5160         `std::path::Path` treats the byte as a literal path-component byte, so \
5161         `Path::join` looks for a literal `./{caminho}` subdirectory and fails at \
5162         resolve time with a non-self-locating `No such file or directory` error far \
5163         from the source caixa.lisp — while every downstream URL parser / shell printf \
5164         builtin / YAML directive parser silently reinterprets the byte to a different \
5165         value than the resolver's `Path::join` sees. Beyond the URL-encoding hazard, \
5166         `%` is the C / POSIX printf format-directive lead-in (`%s`, `%d`, `%02x` — \
5167         wired into every POSIX shell's `printf` builtin, the canonical CWE-134 format-\
5168         string-injection vector); the bash / zsh / ksh job-control-specifier lead-in \
5169         (`%1` names \"job 1\", `%%` names \"the current job\", `%foo` names \"the most \
5170         recent job whose command started with `foo`\" — a future `kill %1` invocation \
5171         silently redirects the signal to a wrong target); the YAML 1.2 §6.8.1 \
5172         directive lead-in (`%YAML 1.2` / `%TAG` — the paste-from-top-of-doc YAML \
5173         directive block cross-idiom leak); and the Windows-shell env-var-reference \
5174         lead-in (`%PATH%` — the paste-from-`.bat` / paste-from-PowerShell-`%env:PATH%` \
5175         cross-idiom leak). The lacre pipeline embeds the value verbatim in its per-dep \
5176         content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the \
5177         byte lands in the BLAKE3 closure and rides into every shell-spawned subprocess \
5178         (the resolver's `git clone`, a future `feira tofu` shell-out, a future \
5179         operator-side `nix` spawn) as the canonical URL-percent-encoding-escape / \
5180         printf-format-specifier / job-control-specifier surface every peer single-\
5181         token-shaped typed slot already closes. The peer `:fonte :repo` axis closes \
5182         the byte under the same URL-percent-encoding-escape banner (a323db8 `%` on \
5183         `is_git_repo_url`). Express the path as a bare relative single-token like \
5184         \"../caixa-teia\" — the sibling-workspace directory name carries no URL-\
5185         percent-encoding-escape / format-specifier / job-control semantic; substitute \
5186         any `%20` percent-encoded-space with a literal space then reject the whole \
5187         value at the leading-whitespace / embedded-`?` arm on the same axis (a caixa \
5188         directory name never carries an embedded space in practice); drop any \
5189         `%2F`-encoded path separator in favor of a literal `/`; and drop any leading \
5190         `%YAML` / `%PATH%` cross-idiom-leak prefix entirely.",
5191        ch = *byte as char
5192    )]
5193    FonteCaminhoUrlPercentEncoding {
5194        nome: String,
5195        caminho: String,
5196        byte: u8,
5197    },
5198    #[error(
5199        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5200         variable-expansion / command-substitution / arithmetic-expansion / cross-config-\
5201         DSL-interpolation metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — sh / \
5202         bash / zsh / dash / ksh / busybox ash / fish / nushell — lexes `$` per \
5203         POSIX.1-2017 §2.6 as the variable-expansion `$<name>` / braced-form `${{<name>}}` \
5204         / command-substitution `$(<cmd>)` / arithmetic-expansion `$((<expr>))` operator; \
5205         Nix uses `${{var}}` as the string-interpolation lead, Make uses `$(var)` / `$@` \
5206         / `$<` for variables and automatic-variables, JavaScript / TypeScript template \
5207         literals use `${{expr}}` for interpolation, envsubst / Kubernetes / OpenShift \
5208         templates use `${{VAR}}` for env-var-reference, PHP uses `$_GET` / `$_ENV` for \
5209         superglobals, Perl uses `$foo` for scalars, SASS / SCSS uses `$primary-color` \
5210         for variables, and PostgreSQL / SQLite use `$1` / `$2` for bind parameters — \
5211         the byte is a first-class parser byte in nearly every config / templating / \
5212         build-system DSL the substrate's paste-idiom surface routinely crosses. POSIX \
5213         `std::path::Path` treats the byte as a literal path-component byte, so the \
5214         canonical paste-from-shell-one-liner `:caminho \"../foo$HOME/bar\"` / paste-\
5215         from-CI-manifest `:caminho \"../foo${{WORKSPACE}}/bar\"` / paste-from-shell-\
5216         prompt `:caminho \"../foo$(whoami)/bar\"` footguns silently pass every prior \
5217         cascade arm (`$` isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / \
5218         `?` / `(` / `)` / `{{` / `}}` / `[` / `]` / `'` / `\"` / `#` / `%`) and route \
5219         through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
5220         subdirectory that fails at resolve time with a non-self-locating `No such file \
5221         or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
5222         the value verbatim in its per-dep content-address `path:{caminho}` at \
5223         caixa-resolver/src/resolve.rs:189, so byte-identical caixa.lisp values differing \
5224         only in whether the author substituted `$HOME` / `${{WORKSPACE}}` at author \
5225         time lock to two distinct BLAKE3 closures across two workstations whose \
5226         downstream envsubst / Nix / Make / K8s-template layers differ in `$VAR` \
5227         recognition — defeating the THEORY.md §V.2 render-determinism contract on the \
5228         same axis every prior `:caminho` arm protects. Beyond the determinism vector, \
5229         `$` at any position in a value flowing verbatim into a shell-spawned subprocess \
5230         is the canonical CWE-78 shell-command-injection surface every peer single-\
5231         token-shaped typed slot already closes: peer `:fonte :repo` axis rejects `$` \
5232         under the shell-variable-expansion / URL-sub-delim banner via `is_git_repo_url` \
5233         (b9d187c), peer `:fonte :tag` / `:fonte :branch` axes reject `$` as part of \
5234         `is_git_ref_name`'s printable-ASCII-restricted grammar (`git check-ref-format` \
5235         rejects the byte outright), and peer `:entrada :paths` axis rejects `$` via \
5236         `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. The leading-`$` \
5237         position on the same axis routes through `FonteCaminhoVarExpansion` at the \
5238         f4efe9c leading-byte arm; this arm closes the last positional gap on the byte \
5239         so every position — leading and embedded — is structurally rejected. Substitute \
5240         the `$VAR` / `${{VAR}}` / `$(cmd)` template with the literal value at author \
5241         time, or express the path as a bare relative single-token like \
5242         \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
5243         variable-expansion / command-substitution / arithmetic-expansion semantic.",
5244        ch = *byte as char
5245    )]
5246    FonteCaminhoShellVariableExpansion {
5247        nome: String,
5248        caminho: String,
5249        byte: u8,
5250    },
5251    #[error(
5252        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5253         history-expansion / RFC-3986-sub-delims / bang-operator metacharacter 0x{byte:02x} \
5254         `{ch}` (every interactive POSIX shell with history enabled — bash / ksh / zsh's \
5255         `bashcompat` / csh / tcsh — lexes `!` as the history-expansion prefix per bash \
5256         reference §9.3: `!command` re-runs the most recent history entry beginning with \
5257         `command`, `!!` re-runs the prior command verbatim, `!$` substitutes the last \
5258         word of the prior command, `!:N` substitutes the Nth word of the prior command, \
5259         and the substitution fires at every history-expansion-enabled shell context — \
5260         `set -o histexpand` is bash's default for interactive sessions and the layer \
5261         every `feira tofu` / `git clone` / `nix flake check` subprocess-argument \
5262         invocation crosses when spawned under `bash -i`. Beyond shell history, RFC 3986 \
5263         §2.2 lists `!` in the `sub-delims` set (the URL grammar admits the byte inside \
5264         a path segment, but every WHATWG-conformant special-scheme URL parser percent-\
5265         encodes it inside a query component via the 'special-query percent-encode set' \
5266         the peer `is_git_repo_url` `*` / `(` / `)` / `'` arms close on); the byte is \
5267         also the C / C++ / Rust / JavaScript / Python bang-operator (logical-negation \
5268         prefix — the paste-from-source-code idiom where an author copies \
5269         `!path.exists()` out of a Rust snippet and the trailing punctuation crosses \
5270         the string-literal boundary); the canonical English-typography emphasis / \
5271         exclamation mark (the paste-from-prose enthusiasm-form idiom where an author \
5272         writes `:caminho \"../caixa-teia!\"` expecting the substrate to coerce it to a \
5273         kebab-case slug); and the Nix flake-ref attribute-selection operator surface. \
5274         POSIX `std::path::Path` treats `!` as a literal path-component byte, so the \
5275         canonical paste-from-shell-history footgun `:caminho \"../caixa-teia!sudo\"` \
5276         (an author copies a `cd ../caixa-teia && !sudo make install` one-liner from a \
5277         quick-start README and the trailing `!sudo` rides in verbatim as a history-\
5278         expansion reference), the symmetric `:caminho \"../foo!!/bar\"` (the `!!` \
5279         repeat-prior-command paste idiom), the English-typography `:caminho \
5280         \"../caixa-teia!\"` (paste-from-prose enthusiasm-form), and the last-word-\
5281         substitution `:caminho \"../foo!$\"` shape silently pass every prior cascade \
5282         arm (`!` isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / `?` / `(` \
5283         / `)` / `{{` / `}}` / `[` / `]` / `'` / `\"` / `#` / `%` / `$`) and route \
5284         through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
5285         subdirectory that fails at resolve time with a non-self-locating `No such file \
5286         or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
5287         the value verbatim in its per-dep content-address `path:{caminho}` at \
5288         caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
5289         rides into every shell-spawned subprocess (the resolver's `git clone`, a \
5290         future `feira tofu` shell-out, a future operator-side `nix flake check` spawn) \
5291         as the canonical shell-history-expansion / RFC-3986-sub-delims surface every \
5292         peer single-token-shaped typed slot already closes. The peer `:fonte :repo` \
5293         axis closes the byte under the same shell-history-expansion / RFC-3986-sub-\
5294         delims banner (7d53c68 `!` on `is_git_repo_url`). Express the path as a bare \
5295         relative single-token like \"../caixa-teia\" — the sibling-workspace directory \
5296         name carries no shell-history-expansion / bang-operator semantic; drop any \
5297         `!sudo` / `!!` / `!$` history-expansion trailing paste-from-shell-history \
5298         idiom; and drop any trailing English-typography exclamation mark that pasted \
5299         from prose.",
5300        ch = *byte as char
5301    )]
5302    FonteCaminhoShellHistoryExpansion {
5303        nome: String,
5304        caminho: String,
5305        byte: u8,
5306    },
5307    #[error(
5308        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5309         history-substitution / RFC-3986-'unwise' / regex-negation metacharacter 0x{byte:02x} \
5310         `{ch}` (POSIX bash's `set -o histexpand` mode — the default for every interactive \
5311         session and every `bash -i` subprocess-argument context `feira tofu` / `git clone` / \
5312         `nix flake check` cross — lexes `^old^new^` per bash reference §9.3 as the 'quick \
5313         substitution' history operator that rewrites the prior command's `old` string to \
5314         `new` and re-executes it verbatim, the canonical typo-correction one-liner idiom \
5315         (`git clone <bad-url>` → `^bad^good` typo-fix-and-rerun the paste-from-shell-\
5316         history author trims only the leading `git clone` prefix from). RFC 3986 §2 lists \
5317         `^` in the 'unwise' set every URL parser is required to percent-encode-or-refuse at \
5318         the wire boundary, and the WHATWG URL spec's 'fragment percent-encode set' maps \
5319         `^` → `%5E` at the query / fragment component transition, so `Path::join` on the \
5320         literal value diverges from every downstream `feira tofu` curl-invocation / \
5321         artifact-registry-fetch that percent-encodes the byte before the wire. `^` is also \
5322         the regex character-class negation prefix (`[^abc]`), the bitwise XOR operator in \
5323         C / C++ / Rust / Python / JavaScript / Nix / Go, the Windows `cmd.exe` escape \
5324         metacharacter, and the LaTeX / Markdown / BibTeX superscript operator. POSIX \
5325         `std::path::Path` treats `^` as a literal path-component byte, so \
5326         `:caminho \"../foo^bar/baz\"` (embedded quick-substitution), `:caminho \
5327         \"../foo^\"` (trailing history-substitution-open shape), or `:caminho \"../x^y\"` \
5328         (XOR-expression paste-from-source) silently pass every prior cascade arm (`^` \
5329         isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / `?` / `(` / `)` / `{{` \
5330         / `}}` / `[` / `]` / `'` / `\"` / `#` / `%` / `$` / `!`) and route through \
5331         `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` subdirectory \
5332         that fails at resolve time with a non-self-locating `No such file or directory` \
5333         error far from the source caixa.lisp. The lacre pipeline embeds the value verbatim \
5334         in its per-dep content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, \
5335         so the byte lands in the BLAKE3 closure and rides into every shell-spawned \
5336         subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a future \
5337         operator-side `nix flake check` spawn) as the canonical shell-history-substitution \
5338         / RFC-3986-unwise surface every peer single-token-shaped typed slot already closes. \
5339         The peer `:fonte :repo` axis closes the byte under the same shell-history-\
5340         substitution / RFC-3986-unwise banner (49e142f `^` on `is_git_repo_url`). Together \
5341         with the immediate-predecessor `!` arm (6a04767) this arm closes the full `set -o \
5342         histexpand` operator surface on the `:caminho` axis — the `!command` / `!!` / `!$` \
5343         prefix form via `!`, the `^old^new^` quick-substitution form via `^`. Express the \
5344         path as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
5345         directory name carries no shell-history-substitution / regex-negation / XOR-operator \
5346         semantic; drop any `^old^new` history-substitution paste-from-shell-history idiom; \
5347         drop any trailing `^` history-substitution-open fragment.",
5348        ch = *byte as char
5349    )]
5350    FonteCaminhoShellHistorySubstitution {
5351        nome: String,
5352        caminho: String,
5353        byte: u8,
5354    },
5355    #[error(
5356        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} has a trailing \
5357         `/` (the resolver's `Path::join` resolves `\"../caixa-teia\"` and \
5358         `\"../caixa-teia/\"` to the same directory, but the lacre pipeline embeds the \
5359         value verbatim in its per-dep content-address `path:{caminho}` at \
5360         caixa-resolver/src/resolve.rs:189, so two authors whose only difference is \
5361         shell tab-completion emit byte-divergent BLAKE3 closures for the same caixa — \
5362         defeating the THEORY.md §V.2 render-determinism contract via the trailing-\
5363         separator vector (the canonical paste-from-shell-tab-completion + paste-from-\
5364         `pwd`-with-`/`-suffix footgun, and the canonical Cargo-style `path = \
5365         \"../caixa-teia/\"` paste-from-Cargo-manifest cross-idiom leak). Drop the \
5366         trailing `/`; every `:caminho` value names a sibling-workspace directory \
5367         already, so the trailing separator carries no information. Use \
5368         `\"../caixa-teia\"` rather than `\"../caixa-teia/\"`)"
5369    )]
5370    FonteCaminhoTrailingSlash { nome: String, caminho: String },
5371    #[error(
5372        "{list} carries duplicate entry :nome {nome:?} — every dep list keys its \
5373         entries by caixa name (Cargo's [dependencies] / [dev-dependencies] tables \
5374         apply the same set-not-multiset discipline; one package per table), and \
5375         two entries naming the same caixa carry two version constraints / source \
5376         pins / feature sets for one identity. The caixa-resolver's lacre pipeline \
5377         consumes the list as a `HashMap`-keyed-by-`:nome` lookup: the second entry \
5378         silently overwrites the first at the resolver-side `concrete_versao` step, \
5379         and the dropped entry's pin / features never reach the closure — far from \
5380         the source caixa.lisp, with no field naming which `:deps` entry was the \
5381         silent loser. If two version constraints are genuinely needed (the rare \
5382         multi-version closure case the lacre pipeline doesn't yet support), the \
5383         author surface is two distinct caixa names (e.g. a `caixa-teia-v01` / \
5384         `caixa-teia-v02` aliased pair); within one list, one entry per caixa name."
5385    )]
5386    DuplicateNome { nome: String, list: &'static str },
5387    #[error(
5388        ":deps entry {nome:?} has empty :caracteristicas entry — every feature flag must \
5389         name a non-empty identifier on the target caixa (Cargo's [dependencies.<dep>.features] \
5390         applies the same per-entry non-empty discipline). An empty feature flag reaches the \
5391         caixa-resolver's lacre pipeline as a no-op feature enable, silently dropping the \
5392         author's intent far from the source caixa.lisp; drop the empty entry, or replace it \
5393         with the canonical kebab-case feature name the target caixa declares."
5394    )]
5395    CaracteristicaEmpty { nome: String },
5396    #[error(
5397        ":deps entry {nome:?} :caracteristicas entry {caracteristica:?} is not a valid Cargo \
5398         feature name: {reason} (the value flows verbatim into Cargo's \
5399         [dependencies.<dep>.features] list and Cargo's `restricted_names::validate_feature_name` \
5400         parser enforces the same shape at `cargo metadata` time; use a single-token \
5401         identifier like `\"http\"`, `\"derive\"`, or `\"runtime-tokio\"` — kebab-case ASCII \
5402         alphanumeric with `-`, `_`, `+`, or `.` as continuation characters, starting with \
5403         an ASCII alphanumeric or `_`)"
5404    )]
5405    CaracteristicaInvalid {
5406        nome: String,
5407        caracteristica: String,
5408        reason: String,
5409    },
5410    #[error(
5411        ":deps entry {nome:?} :caracteristicas carries duplicate feature {caracteristica:?} — \
5412         every feature-flag list keys its entries by name (Cargo's \
5413         [dependencies.<dep>.features] applies the same set-not-multiset discipline; one entry \
5414         per feature per dep), and two entries naming the same feature are a redundant \
5415         set-membership declaration for one identity (the feature-toggle slot is set-shaped; \
5416         enabling a feature twice has no additional semantic). The caixa-resolver's lacre \
5417         pipeline consumes the list as a set-shaped feature toggle — the resolver enables the \
5418         feature once regardless of declaration count, so the duplicate's pin / position never \
5419         reaches the closure with no field naming the silent loser. One entry per feature per \
5420         dep; if two distinct features are intended, name each verbatim."
5421    )]
5422    CaracteristicaDuplicate {
5423        nome: String,
5424        caracteristica: String,
5425    },
5426    #[error(
5427        "{list} entry :nome {nome:?} names the caixa itself — a caixa cannot depend \
5428         on itself (the lacre closure's dep-graph traversal is rooted at the caixa's \
5429         :nome, and a self-dep would be a one-node cycle the caixa-resolver either \
5430         rejects mid-traversal far from the source caixa.lisp or recurses on until \
5431         it exhausts its stack). Every :nome is globally-unique substrate identity, \
5432         so a :deps / :deps-dev entry whose :nome equals the parent caixa's :nome \
5433         *is* the parent itself, not a coincidentally-named peer. Drop the \
5434         self-referential dep entry — to reference code from this caixa, use \
5435         :bibliotecas / :exe / :servicos (the substrate-blessed shape for \
5436         referencing the caixa's own code surface) instead."
5437    )]
5438    DepIsSelf { nome: String, list: &'static str },
5439}
5440
5441// Fold the eleven `DepError::FonteCaminho<Variant> { nome: nome.to_string(),
5442// caminho: caminho.to_string() }` two-slot struct-variant wire-up sites at
5443// [`DepSource::validate_caminho`] onto one substrate primitive per typed
5444// variant — the paired `{ nome: String, caminho: String }` two-slot family
5445// on [`DepError`], sibling of the peer
5446// [`crate::supervisor::supervisor_caixa_only_ctors!`] (db09650, 3 variants
5447// on `{ caixa: String }`) on the `SupervisorError` envelope, the peer
5448// [`crate::aplicacao::contrato_empty_pair_ctors!`] (8580068, 4 variants on
5449// `{ de, para }`), [`crate::aplicacao::aplicacao_field_reason_ctors!`]
5450// (981060b, 7 variants on `{ <field>: String, reason: String }`),
5451// [`crate::aplicacao::contrato_target_ctors!`] (14b81d5, 2 variants on
5452// `{ de, para, wit, expected }`), and
5453// [`crate::aplicacao::contrato_pair_value_reason_ctors!`] (14e13f1, 3
5454// variants on `{ de, para, <field>: String, reason: String }`) on the
5455// `AplicacaoError` envelopes, the peer
5456// [`crate::layout::layout_violation_ctors!`] (131ca0d, 16 variants on
5457// `{ caixa, issue }`), [`crate::layout::layout_slot_kind_ctors!`]
5458// (0419438, 4 variants on `{ caixa, kind, slots }`),
5459// [`crate::LayoutError::missing_entry`] (1b09f9d, one variant on
5460// `{ kind, path }`), and [`crate::layout::layout_nome_only_ctors!`]
5461// (3fe3dd7, 6 variants on `<Variant>(String)`) on the `LayoutError`
5462// envelopes, the peer three [`crate::limits::limits_codec_value_*_ctors!`]
5463// codec-family macros (81c856c, 12 wire-ups) on the `LimitsError`
5464// envelope, and the peer [`crate::upgrade::upgrade_from_script_ctors!`]
5465// (8e67041, 3 variants on `{ from: String, script: PathBuf }`) on the
5466// `UpgradeError` envelope. First fold family on this `DepError` envelope.
5467//
5468// Each of the eleven wire-up sites on this shape (the leading-byte cascade
5469// closing the seven `FonteCaminho{Absolute, TildeExpansion, VarExpansion,
5470// LeadingWhitespace, LeadingHyphen}` arms; the orthogonal single-metachar
5471// cascade closing `FonteCaminhoBackslash` on `\`; the shell-lexer-metachar
5472// cascade closing `FonteCaminhoShell{Pipe, Semicolon, Background,
5473// CommandSubstitution}` on the four single-byte shell operators; and the
5474// trailing-`/` reproducibility arm closing `FonteCaminhoTrailingSlash`)
5475// opened the identical `DepError::FonteCaminho<Variant> { nome:
5476// nome.to_string(), caminho: caminho.to_string() }` four-line
5477// struct-literal against the same `(nome: &str, caminho: &str)` local pair
5478// — the exact "same block re-inlined at every consumer" shape the PRIME
5479// DIRECTIVE names as a bug, on the same altitude the peer `LayoutError` /
5480// `AplicacaoError` / `SupervisorError` / `LimitsError` / `UpgradeError`
5481// families each closed on their sibling envelopes. The eleven variants
5482// share one `{ nome: String, caminho: String }` shape, so the fold routes
5483// each wire-up site through one dispatch per typed variant.
5484//
5485// The macro below generates one `#[must_use]` inherent constructor per
5486// variant of shape `fn <ctor>(nome: &str, caminho: &str) -> Self`, so every
5487// wire-up site collapses onto one dispatch:
5488// `DepError::<ctor>(nome, caminho)`, byte-equal to the pre-lift
5489// struct-literal on the same `(&str, &str)` fixture. The uniform two-field
5490// construction (`nome.to_string()` / `caminho.to_string()`) is spelled
5491// once — inside the macro — rather than at every wire-up site.
5492//
5493// The twelve `FonteCaminho<Variant> { nome, caminho, byte }` three-field
5494// shapes at the per-byte-classification arms — the
5495// `FonteCaminho{ControlChar,ShellRedirection,ShellGlob,
5496// ShellSubshellGrouping,ShellBraceExpansion,ShellBracketExpansion,
5497// ShellQuoteGrouping,ShellComment,UrlPercentEncoding,
5498// ShellVariableExpansion,ShellHistoryExpansion,ShellHistorySubstitution}`
5499// cluster — carry an additional `byte: u8` naming the offending byte and
5500// so would break the uniform-two-field routing this macro promises. They
5501// instead fold onto the sibling three-field envelope through
5502// [`fonte_caminho_byte_ctors!`] (this-commit-lift, 12 variants on the
5503// `{ nome, caminho, byte }` shape), whose sole additional axis over this
5504// two-slot family is the `byte: u8` classification the arms carry. The
5505// remaining `FonteCaminhoEmpty` one-field `{ nome }` shape at the empty-
5506// first arm folds instead onto the peer [`dep_nome_only_ctors!`]
5507// (792aa92, 5 variants on `{ nome: String }`) sibling family of this
5508// envelope.
5509//
5510// Every future consumer that wants to construct one of these eleven
5511// variants outside the current in-crate [`DepSource::validate_caminho`]
5512// wire-up sites (a deferred `caixa-resolver` per-`:caminho` re-validator
5513// at lacre-resolve time re-checking the same value-shape axes the resolver
5514// consumes, a future `feira validate --deps` per-caixa admission verb
5515// re-checking the `:fonte :caminho` axis, a per-lacre overlay resolver
5516// rejecting a `:caminho` value against a cluster-local snapshot) now
5517// reaches each variant through one call rather than re-inlining the
5518// four-line struct-literal in lockstep with the eleven in-crate wire-up
5519// sites.
5520macro_rules! fonte_caminho_ctors {
5521    ($($ctor:ident => $variant:ident),* $(,)?) => {
5522        impl DepError {
5523            $(
5524                #[doc = concat!(
5525                    "Construct a [`DepError::",
5526                    stringify!($variant),
5527                    "`] naming the offending `:deps :nome` + `:fonte ",
5528                    "(:tipo path …) :caminho` pair. Folds the uniform ",
5529                    "`Self::",
5530                    stringify!($variant),
5531                    " { nome: nome.to_string(), caminho: caminho.to_string() }` ",
5532                    "two-slot struct-literal onto one substrate primitive so ",
5533                    "every [`DepSource::validate_caminho`] wire-up on this ",
5534                    "variant reads through one dispatch rather than the ",
5535                    "pre-lift four-line open-coded block."
5536                )]
5537                #[must_use]
5538                pub fn $ctor(nome: &str, caminho: &str) -> Self {
5539                    Self::$variant {
5540                        nome: nome.to_string(),
5541                        caminho: caminho.to_string(),
5542                    }
5543                }
5544            )*
5545        }
5546    };
5547}
5548
5549fonte_caminho_ctors! {
5550    fonte_caminho_absolute => FonteCaminhoAbsolute,
5551    fonte_caminho_tilde_expansion => FonteCaminhoTildeExpansion,
5552    fonte_caminho_var_expansion => FonteCaminhoVarExpansion,
5553    fonte_caminho_leading_whitespace => FonteCaminhoLeadingWhitespace,
5554    fonte_caminho_leading_hyphen => FonteCaminhoLeadingHyphen,
5555    fonte_caminho_backslash => FonteCaminhoBackslash,
5556    fonte_caminho_shell_pipe => FonteCaminhoShellPipe,
5557    fonte_caminho_shell_semicolon => FonteCaminhoShellSemicolon,
5558    fonte_caminho_shell_background => FonteCaminhoShellBackground,
5559    fonte_caminho_shell_command_substitution => FonteCaminhoShellCommandSubstitution,
5560    fonte_caminho_trailing_slash => FonteCaminhoTrailingSlash,
5561}
5562
5563// Fold the twelve `DepError::FonteCaminho<Variant> { nome: nome.to_string(),
5564// caminho: caminho.to_string(), byte: b }` three-slot struct-variant wire-up
5565// sites at [`DepSource::validate_caminho`] onto one substrate primitive per
5566// typed variant — the paired `{ nome: String, caminho: String, byte: u8 }`
5567// three-slot family on [`DepError`], strict sibling of the peer
5568// [`fonte_caminho_ctors!`] (f85f145, 11 variants on the two-slot
5569// `{ nome: String, caminho: String }` envelope) of this envelope. Extends
5570// that fold onto the `byte`-classifying arms whose additional `byte: u8`
5571// axis broke its uniform-two-field routing — the exact "future compounding
5572// work" the pre-lift `fonte_caminho_ctors!` prose named as deferred, closed
5573// here. Third fold family on this `DepError` envelope, sibling of the peer
5574// two-slot [`fonte_caminho_ctors!`] and one-slot [`dep_nome_only_ctors!`]
5575// (792aa92, 5 variants on the `{ nome: String }` envelope) families on the
5576// same enum.
5577//
5578// Each of the twelve wire-up sites on this shape (the control-byte arm
5579// closing `FonteCaminhoControlChar` on the sub-`0x20` / `0x7F` cluster; the
5580// shell-lexer-metachar cascade closing `FonteCaminhoShellRedirection` on
5581// `< >`, `FonteCaminhoShellGlob` on `* ?`, `FonteCaminhoShellSubshellGrouping`
5582// on `( )`, `FonteCaminhoShellBraceExpansion` on `{ }`,
5583// `FonteCaminhoShellBracketExpansion` on `[ ]`, and
5584// `FonteCaminhoShellQuoteGrouping` on `' "`; the single-metachar arms
5585// closing `FonteCaminhoShellComment` on `#`, `FonteCaminhoUrlPercentEncoding`
5586// on `%`, `FonteCaminhoShellVariableExpansion` on `$`,
5587// `FonteCaminhoShellHistoryExpansion` on `!`, and
5588// `FonteCaminhoShellHistorySubstitution` on `^`) opened the identical
5589// `DepError::FonteCaminho<Variant> { nome: nome.to_string(),
5590// caminho: caminho.to_string(), byte: b }` five-line struct-literal against
5591// the same `(nome: &str, caminho: &str, b: u8)` local triple — the exact
5592// "same block re-inlined at every consumer" shape the PRIME DIRECTIVE names
5593// as a bug, on the same altitude the peer two-slot `fonte_caminho_ctors!`
5594// closed on the sibling two-field envelope of this same enum. The twelve
5595// variants share one `{ nome: String, caminho: String, byte: u8 }` shape, so
5596// the fold routes each wire-up site through one dispatch per typed variant.
5597//
5598// The macro below generates one `#[must_use]` inherent constructor per
5599// variant of shape `fn <ctor>(nome: &str, caminho: &str, byte: u8) -> Self`,
5600// so every wire-up site collapses onto one dispatch:
5601// `DepError::<ctor>(nome, caminho, b)`, byte-equal to the pre-lift
5602// struct-literal on the same `(&str, &str, u8)` fixture. The uniform
5603// three-field construction (`nome.to_string()` / `caminho.to_string()` /
5604// `byte`) is spelled once — inside the macro — rather than at every wire-up
5605// site.
5606//
5607// Every future consumer that wants to construct one of these twelve
5608// variants outside the current in-crate [`DepSource::validate_caminho`]
5609// wire-up sites (a deferred `caixa-resolver` per-`:caminho` re-validator
5610// at lacre-resolve time re-checking the same value-shape axes the resolver
5611// consumes, a future `feira validate --deps` per-caixa admission verb
5612// re-checking the `:fonte :caminho` axis against the shell-metachar
5613// classification bytes this cluster catches, a per-lacre overlay resolver
5614// rejecting a `:caminho` value against a cluster-local snapshot) now
5615// reaches each variant through one call rather than re-inlining the
5616// five-line struct-literal in lockstep with the twelve in-crate wire-up
5617// sites.
5618macro_rules! fonte_caminho_byte_ctors {
5619    ($($ctor:ident => $variant:ident),* $(,)?) => {
5620        impl DepError {
5621            $(
5622                #[doc = concat!(
5623                    "Construct a [`DepError::",
5624                    stringify!($variant),
5625                    "`] naming the offending `:deps :nome` + `:fonte ",
5626                    "(:tipo path …) :caminho` pair + the offending `byte: u8` ",
5627                    "classification. Folds the uniform `Self::",
5628                    stringify!($variant),
5629                    " { nome: nome.to_string(), caminho: caminho.to_string(), ",
5630                    "byte }` three-slot struct-literal onto one substrate ",
5631                    "primitive so every [`DepSource::validate_caminho`] wire-up ",
5632                    "on this variant reads through one dispatch rather than ",
5633                    "the pre-lift five-line open-coded block."
5634                )]
5635                #[must_use]
5636                pub fn $ctor(nome: &str, caminho: &str, byte: u8) -> Self {
5637                    Self::$variant {
5638                        nome: nome.to_string(),
5639                        caminho: caminho.to_string(),
5640                        byte,
5641                    }
5642                }
5643            )*
5644        }
5645    };
5646}
5647
5648fonte_caminho_byte_ctors! {
5649    fonte_caminho_control_char => FonteCaminhoControlChar,
5650    fonte_caminho_shell_redirection => FonteCaminhoShellRedirection,
5651    fonte_caminho_shell_glob => FonteCaminhoShellGlob,
5652    fonte_caminho_shell_subshell_grouping => FonteCaminhoShellSubshellGrouping,
5653    fonte_caminho_shell_brace_expansion => FonteCaminhoShellBraceExpansion,
5654    fonte_caminho_shell_bracket_expansion => FonteCaminhoShellBracketExpansion,
5655    fonte_caminho_shell_quote_grouping => FonteCaminhoShellQuoteGrouping,
5656    fonte_caminho_shell_comment => FonteCaminhoShellComment,
5657    fonte_caminho_url_percent_encoding => FonteCaminhoUrlPercentEncoding,
5658    fonte_caminho_shell_variable_expansion => FonteCaminhoShellVariableExpansion,
5659    fonte_caminho_shell_history_expansion => FonteCaminhoShellHistoryExpansion,
5660    fonte_caminho_shell_history_substitution => FonteCaminhoShellHistorySubstitution,
5661}
5662
5663// Fold the five `DepError::<Variant> { nome: <owner>.clone_or_to_string() }`
5664// single-slot struct-variant wire-up sites scattered across
5665// [`Dep::validate`] / [`Dep::validate_caracteristicas`] /
5666// [`DepSource::validate`] / [`DepSource::validate_caminho`] onto one
5667// substrate primitive per typed variant — the paired `{ nome: String }`
5668// single-slot family on [`DepError`], sibling of the peer
5669// [`fonte_caminho_ctors!`] (f85f145, 11 variants on
5670// `{ nome: String, caminho: String }`) on the sibling two-slot envelope of
5671// the same enum, and of the peer
5672// [`crate::supervisor::supervisor_caixa_only_ctors!`] (db09650, 3 variants
5673// on `{ caixa: String }`) on the `SupervisorError` envelope's single-slot
5674// axis. Second fold family on this `DepError` envelope, and the first on
5675// the single-`{ nome }` shape.
5676//
5677// The five wire-up sites this fold closes each opened the identical
5678// `DepError::<Variant> { nome: <owner>.to_string_or_clone() }` three-line
5679// struct-literal against the same `nome: &str` (or `self.nome: &String`)
5680// local — the exact "same block re-inlined at every consumer" shape the
5681// PRIME DIRECTIVE names as a bug. The five variants share one
5682// `{ nome: String }` shape, so the fold routes each wire-up site through
5683// one dispatch per typed variant.
5684//
5685// The macro below generates one `#[must_use]` inherent constructor per
5686// variant of shape `fn <ctor>(nome: &str) -> Self`, so every wire-up site
5687// collapses onto one dispatch: `DepError::<ctor>(nome)`, byte-equal to the
5688// pre-lift struct-literal on the same `&str` fixture. The uniform
5689// one-field construction (`nome.to_string()`) is spelled once — inside
5690// the macro — rather than at every wire-up site. Callers that hold a
5691// `String` (`self.nome`) pass `&self.nome`, which auto-derefs to `&str`
5692// and lets the macro-owned `.to_string()` produce the fresh owning copy
5693// the enum variant needs; the semantics collapse onto the same
5694// `.clone()`-equivalent one this fold replaces at every site.
5695//
5696// The sibling `NomeEmpty` unit-variant (`enum DepError { NomeEmpty, … }`)
5697// on the same envelope stays on its pre-lift open-coded wire-up shape —
5698// it carries no `nome` field (the offending `:nome` value *is* the empty
5699// string this variant catches) so the uniform `fn(nome: &str) -> Self`
5700// signature this macro promises does not apply. Every future consumer
5701// that wants to construct one of these five variants outside the current
5702// in-crate wire-up sites (a deferred `caixa-resolver` per-`:versao` /
5703// `:caracteristicas` / `:fonte :repo` / `:fonte :pin` / `:fonte :caminho`
5704// re-validator at lacre-resolve time, a future `feira validate --deps`
5705// per-caixa admission verb, a per-lacre overlay resolver rejecting one of
5706// these empty-value shapes against a cluster-local snapshot) now reaches
5707// each variant through one call rather than re-inlining the three-line
5708// struct-literal in lockstep with the five in-crate wire-up sites.
5709macro_rules! dep_nome_only_ctors {
5710    ($($ctor:ident => $variant:ident),* $(,)?) => {
5711        impl DepError {
5712            $(
5713                #[doc = concat!(
5714                    "Construct a [`DepError::",
5715                    stringify!($variant),
5716                    "`] naming the offending `:deps :nome`. Folds the ",
5717                    "uniform `Self::",
5718                    stringify!($variant),
5719                    " { nome: nome.to_string() }` one-field ",
5720                    "struct-literal onto one substrate primitive so every ",
5721                    "in-crate wire-up on this variant reads through one ",
5722                    "dispatch rather than the pre-lift three-line ",
5723                    "open-coded block."
5724                )]
5725                #[must_use]
5726                pub fn $ctor(nome: &str) -> Self {
5727                    Self::$variant { nome: nome.to_string() }
5728                }
5729            )*
5730        }
5731    };
5732}
5733
5734dep_nome_only_ctors! {
5735    versao_empty => VersaoEmpty,
5736    fonte_repo_empty => FonteRepoEmpty,
5737    fonte_pin_missing => FontePinMissing,
5738    fonte_caminho_empty => FonteCaminhoEmpty,
5739    caracteristica_empty => CaracteristicaEmpty,
5740}
5741
5742// Fold the four `DepError::{DuplicateNome, DepIsSelf}` struct-variant
5743// wire-up sites at [`crate::manifest::Caixa::push_dep`] +
5744// [`crate::manifest::Caixa::validate_deps`] +
5745// [`validate_no_self_dep`] onto one substrate-primitive family per
5746// typed variant — the `DepError`-side siblings of the peer
5747// [`crate::supervisor::supervisor_caixa_only_ctors!`] macro (db09650)
5748// on the `SupervisorError { caixa: String }` one-slot envelope and of
5749// the peer [`dep_nome_only_ctors!`] macro (792aa92) on the
5750// `DepError { nome: String }` one-slot envelope. The two variants
5751// carry the same `{ nome: String, list: &'static str }` two-slot
5752// shape: the `nome` field names the offending dep the diagnostic
5753// points the author back at, and the `list` field carries the
5754// `":deps"` / `":deps-dev"` author-surface tag verbatim (via
5755// [`crate::dep::DepList::as_str`] on the [`push_dep`] /
5756// [`validate_deps`] arms, and via the paired
5757// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
5758// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `&'static str`
5759// canonicals on the [`validate_no_self_dep`] arm) so the author can
5760// grep their caixa.lisp for the offending list block in one edit.
5761//
5762// Each of the four wire-up sites opened the same struct-literal
5763// `DepError::<Variant> { nome: <name>.to_string(), list: <tag> }`
5764// two-line block — the exact "same block re-inlined at every
5765// consumer" shape the PRIME DIRECTIVE names as a bug, on the same
5766// altitude the peer `DepError` / `SupervisorError` /
5767// `AplicacaoError` / `LayoutError` / `LimitsError` ctor families
5768// already closed on their sibling envelopes. The two `#[must_use]`
5769// inherent constructors below fold each wire-up onto one dispatch:
5770// `DepError::duplicate_nome(<nome>, <list>)` and
5771// `DepError::dep_is_self(<nome>, <list>)`, byte-equal to the
5772// pre-lift struct-literal on the same scalar fixtures. The `list:
5773// &'static str` parameter (not `impl Into<String>`) preserves the
5774// exact wire tag every consumer already passes verbatim — no
5775// downstream diagnostic reshaping at the lift, matching the peer
5776// `DepList::as_str` / `DEP_AUTHOR_KEY_DEPS*` `&'static str`
5777// contract each wire-up site already keys off.
5778macro_rules! dep_nome_list_ctors {
5779    ($($ctor:ident => $variant:ident),* $(,)?) => {
5780        impl DepError {
5781            $(
5782                #[doc = concat!(
5783                    "Construct a [`DepError::",
5784                    stringify!($variant),
5785                    "`] naming the offending `:deps :nome` and the ",
5786                    "author-surface list tag (`:deps` vs. `:deps-dev`) ",
5787                    "the diagnostic points the author back at. Folds ",
5788                    "the uniform `Self::",
5789                    stringify!($variant),
5790                    " { nome: nome.to_string(), list }` two-field ",
5791                    "struct-literal onto one substrate primitive so ",
5792                    "every in-crate wire-up on this variant reads ",
5793                    "through one dispatch rather than the pre-lift ",
5794                    "open-coded struct-literal block."
5795                )]
5796                #[must_use]
5797                pub fn $ctor(nome: &str, list: &'static str) -> Self {
5798                    Self::$variant { nome: nome.to_string(), list }
5799                }
5800            )*
5801        }
5802    };
5803}
5804
5805dep_nome_list_ctors! {
5806    duplicate_nome => DuplicateNome,
5807    dep_is_self => DepIsSelf,
5808}
5809
5810// Fold the three `DepError::{VersaoInvalid, FonteRepoShape,
5811// CaracteristicaInvalid} { nome: <nome>.to_string(), <axis>:
5812// <value>.to_string(), reason }` struct-variant wire-up sites at
5813// [`Dep::validate`]'s `:versao` requirement-shape gate + [`DepSource::validate`]'s
5814// `:fonte (:tipo git …) :repo` value-shape gate + [`Dep::validate_caracteristicas`]'s
5815// per-entry `:caracteristicas` feature-name-shape gate onto one substrate-
5816// primitive family per typed variant — the `DepError`-side siblings of the
5817// peer [`dep_nome_only_ctors!`] (792aa92) on the one-slot `{ nome }`
5818// envelope, [`dep_nome_list_ctors!`] (6f5e0cd) on the two-slot `{ nome,
5819// list: &'static str }` envelope, [`fonte_caminho_ctors!`] (f85f145) on
5820// the two-slot `{ nome, caminho }` envelope, and
5821// [`fonte_caminho_byte_ctors!`] (0e35793) on the three-slot `{ nome,
5822// caminho, byte }` envelope. The three variants share the same
5823// `{ nome: String, <axis>: String, reason: String }` three-slot shape —
5824// the `nome` field names the offending dep the diagnostic points the
5825// author back at, the middle `<axis>: String` field carries the offending
5826// axis value verbatim (`:versao` requirement scalar on `VersaoInvalid`,
5827// `:repo` URL scalar on `FonteRepoShape`, `:caracteristicas` per-entry
5828// feature-name scalar on `CaracteristicaInvalid`), and the `reason: String`
5829// field carries the parser-shaped rejection sentence the paired
5830// [`crate::render::require_valid_versao_requirement`] /
5831// [`crate::render::is_git_repo_url`] /
5832// [`crate::render::is_cargo_feature_name`] predicate returned. The middle
5833// axis-field name differs across variants (`versao` / `repo` /
5834// `caracteristica`) so the ctor family below takes the axis field name as
5835// a macro parameter (`$axis:ident`) alongside the ctor + variant names,
5836// generating one `pub fn $ctor(nome: &str, $axis: &str, reason: String)
5837// -> Self` inherent constructor per typed variant that spells the uniform
5838// three-field construction (`nome.to_string()` / `<axis>.to_string()` /
5839// `reason` forwarded owned) exactly once. Peer of the sibling
5840// [`crate::aplicacao::aplicacao_field_reason_ctors!`] (981060b) macro
5841// family on the `AplicacaoError` envelope's mirror-symmetric
5842// `{ <field>: String, reason: String }` two-slot shape — same
5843// `<axis>: <value>.to_string()` + `reason` owned-forward payload shape,
5844// one `nome`-axis added at the per-dep-owned altitude the `DepError`
5845// envelope keys off (every `DepError` variant carries the offending
5846// `:deps :nome` verbatim so the author can grep their caixa.lisp for the
5847// offending block in one edit).
5848//
5849// The three wire-up sites this fold closes are:
5850// - [`DepSource::validate`]'s `:repo` value-shape arm
5851//   (`Err(DepError::FonteRepoShape { nome: nome.to_string(), repo:
5852//   repo.clone(), reason })` after [`crate::render::is_git_repo_url`]
5853//   rejects the offending URL);
5854// - [`Dep::validate`]'s `:versao` requirement-shape arm
5855//   (`|reason| DepError::VersaoInvalid { nome: self.nome.clone(), versao:
5856//   self.versao_requirement().to_string(), reason }` inside the
5857//   [`crate::render::require_valid_versao_requirement`] callback pair);
5858// - [`Dep::validate_caracteristicas`]'s per-entry feature-name-shape arm
5859//   (`Err(DepError::CaracteristicaInvalid { nome: self.nome.clone(),
5860//   caracteristica: c.clone(), reason })` after
5861//   [`crate::render::is_cargo_feature_name`] rejects the offending
5862//   feature-name).
5863//
5864// Each opened the identical five-line struct-literal against the same
5865// `(nome, <axis>, reason)` local triple — the exact "same block re-inlined
5866// at every consumer" shape the PRIME DIRECTIVE names as a bug, on the
5867// same altitude the peer four already-lifted `DepError` ctor families
5868// closed on their sibling shape-envelopes. The three variant / axis-field
5869// discriminators are the only things that vary between them; the rest of
5870// the struct-literal is a byte-for-byte re-inline.
5871//
5872// Every future consumer wanting to raise one of these three diagnostics
5873// (a deferred `caixa-resolver` per-`:deps` re-validator at lacre-resolve
5874// time re-checking each declared dep against the same requirement +
5875// git-URL + feature-name value-shape cascade, a future `feira validate
5876// --deps` per-caixa admission verb re-running the shape gates on demand,
5877// a per-lacre overlay resolver rejecting an author-supplied dep against a
5878// cluster-local snapshot) now reaches one dispatch rather than re-inlining
5879// the five-line struct-literal in lockstep with the three in-crate
5880// wire-up sites.
5881macro_rules! dep_nome_axis_reason_ctors {
5882    ($($ctor:ident => $variant:ident { $axis:ident }),* $(,)?) => {
5883        impl DepError {
5884            $(
5885                #[doc = concat!(
5886                    "Construct a [`DepError::",
5887                    stringify!($variant),
5888                    "`] naming the offending `:deps :nome`, the offending ",
5889                    "`:", stringify!($axis), "` axis value, and the ",
5890                    "parser-shaped rejection `reason`. Folds the uniform ",
5891                    "`Self::",
5892                    stringify!($variant),
5893                    " { nome: nome.to_string(), ",
5894                    stringify!($axis),
5895                    ": ",
5896                    stringify!($axis),
5897                    ".to_string(), reason }` three-field struct-literal ",
5898                    "onto one substrate primitive so every in-crate ",
5899                    "wire-up on this variant reads through one dispatch ",
5900                    "rather than the pre-lift five-line open-coded block. ",
5901                    "The `nome: &str` and `",
5902                    stringify!($axis),
5903                    ": &str` parameters accept `&str` literals and ",
5904                    "`&String` (via Deref coercion) so every existing ",
5905                    "wire-up threads through the ctor without a ",
5906                    "pre-conversion; the `reason: String` parameter takes ",
5907                    "an owned `String` (not `impl Into<String>`) matching ",
5908                    "the paired `crate::render::*` predicate's ",
5909                    "`Result<(), String>` return shape every wire-up ",
5910                    "already holds owned at the call site."
5911                )]
5912                #[must_use]
5913                pub fn $ctor(nome: &str, $axis: &str, reason: String) -> Self {
5914                    Self::$variant {
5915                        nome: nome.to_string(),
5916                        $axis: $axis.to_string(),
5917                        reason,
5918                    }
5919                }
5920            )*
5921        }
5922    };
5923}
5924
5925dep_nome_axis_reason_ctors! {
5926    versao_invalid => VersaoInvalid { versao },
5927    fonte_repo_shape => FonteRepoShape { repo },
5928    caracteristica_invalid => CaracteristicaInvalid { caracteristica },
5929}
5930
5931// Fold the three `DepError::{FontePinEmpty, FontePinAmbiguous,
5932// CaracteristicaDuplicate} { nome: <nome>.to_string(), <axis>:
5933// <value>.to_string() }` struct-variant wire-up sites at
5934// [`DepSource::validate`]'s per-`:fonte` git-pin single-pin-empty +
5935// multi-pin-ambiguous cascade and [`Dep::validate_caracteristicas`]'s
5936// per-entry set-not-multiset dedup closure onto one substrate-primitive
5937// family per typed variant — the missing two-slot rung on the
5938// `DepError`-side four-family ladder ([`dep_nome_only_ctors!`] (792aa92)
5939// one-slot `{ nome }` → this two-slot `{ nome, <axis>: String }` →
5940// [`dep_nome_list_ctors!`] (6f5e0cd) two-slot `{ nome, list: &'static
5941// str }` → [`dep_nome_axis_reason_ctors!`] (5621f8a) three-slot
5942// `{ nome, <axis>: String, reason: String }` → [`fonte_pin_shape`]
5943// (86e2a17) four-slot `{ nome, pin, value, reason }`), and mirror-
5944// symmetric sibling of the peer
5945// [`crate::aplicacao::aplicacao_field_reason_ctors!`] (981060b) two-slot
5946// `{ <field>: String, reason: String }` fold on the `AplicacaoError`
5947// envelope — same `<axis>: <value>.to_string()` owned-forward payload
5948// shape, `reason` axis removed and `nome`-axis added at the per-dep-
5949// owned altitude the `DepError` envelope keys off (every `DepError`
5950// variant carries the offending `:deps :nome` verbatim so the author
5951// can grep their caixa.lisp for the offending block in one edit). The
5952// three variants share the same `{ nome: String, <axis>: String }`
5953// two-slot shape: the `nome` field names the offending dep the
5954// diagnostic points the author back at, and the middle `<axis>:
5955// String` field carries the offending per-envelope axis value verbatim
5956// (`:fonte` per-pin author-surface tag on `FontePinEmpty`, the
5957// comma-joined multi-pin ambiguity report on `FontePinAmbiguous`, the
5958// duplicate `:caracteristicas` entry on `CaracteristicaDuplicate`).
5959// The middle axis-field name differs across variants (`pin` / `pins` /
5960// `caracteristica`) so the ctor family below takes the axis field name
5961// as a macro parameter (`$axis:ident`) alongside the ctor + variant
5962// names, generating one `pub fn $ctor(nome: &str, $axis: &str) ->
5963// Self` inherent constructor per typed variant that spells the
5964// uniform two-field construction (`nome.to_string()` /
5965// `<axis>.to_string()`) exactly once.
5966//
5967// The three wire-up sites this fold closes are:
5968// - [`DepSource::validate`]'s per-`:fonte` set-of-one empty-pin arm
5969//   (`return Err(DepError::FontePinEmpty { nome: nome.to_string(), pin:
5970//   pin.to_string() });` inside the `set.len() == 1` branch after the
5971//   `is_some_and(String::is_empty)` iterator);
5972// - [`DepSource::validate`]'s per-`:fonte` set-of-two-or-more
5973//   ambiguity arm (`return Err(DepError::FontePinAmbiguous { nome:
5974//   nome.to_string(), pins: set.join(", ") });` inside the `_` branch);
5975// - [`Dep::validate_caracteristicas`]'s per-entry
5976//   set-not-multiset-dedup closure (`|| DepError::CaracteristicaDuplicate
5977//   { nome: self.nome.clone(), caracteristica: c.clone() }` passed to
5978//   [`crate::render::insert_first_seen`]).
5979//
5980// Each opened the identical four-line struct-literal against the same
5981// `(nome, <axis>)` local pair — the exact "same block re-inlined at
5982// every consumer" shape the PRIME DIRECTIVE names as a bug, on the
5983// same altitude the peer four already-lifted `DepError` ctor families
5984// closed on their sibling shape-envelopes. The three variant / axis-
5985// field discriminators are the only things that vary between them;
5986// the rest of the struct-literal is a byte-for-byte re-inline.
5987//
5988// Every future consumer wanting to raise one of these three
5989// diagnostics (a deferred `caixa-resolver` per-`:deps` re-validator
5990// at lacre-resolve time re-checking each declared dep against the
5991// same `:fonte` set-of-one / set-of-many + `:caracteristicas`
5992// set-not-multiset cascade, a future `feira validate --deps` per-
5993// caixa admission verb re-running the shape gates on demand, a
5994// per-lacre overlay resolver rejecting an author-supplied dep against
5995// a cluster-local snapshot the M4 CR materializer projects) now
5996// reaches one dispatch rather than re-inlining the four-line struct-
5997// literal in lockstep with the three in-crate wire-up sites.
5998macro_rules! dep_nome_axis_ctors {
5999    ($($ctor:ident => $variant:ident { $axis:ident }),* $(,)?) => {
6000        impl DepError {
6001            $(
6002                #[doc = concat!(
6003                    "Construct a [`DepError::",
6004                    stringify!($variant),
6005                    "`] naming the offending `:deps :nome` and the ",
6006                    "offending `:", stringify!($axis), "` axis value. ",
6007                    "Folds the uniform `Self::",
6008                    stringify!($variant),
6009                    " { nome: nome.to_string(), ",
6010                    stringify!($axis),
6011                    ": ",
6012                    stringify!($axis),
6013                    ".to_string() }` two-field struct-literal onto one ",
6014                    "substrate primitive so every in-crate wire-up on ",
6015                    "this variant reads through one dispatch rather than ",
6016                    "the pre-lift four-line open-coded block. Both `nome: ",
6017                    "&str` and `",
6018                    stringify!($axis),
6019                    ": &str` parameters accept `&str` literals and ",
6020                    "`&String` (via Deref coercion) so every existing ",
6021                    "wire-up threads through the ctor without a pre-",
6022                    "conversion."
6023                )]
6024                #[must_use]
6025                pub fn $ctor(nome: &str, $axis: &str) -> Self {
6026                    Self::$variant {
6027                        nome: nome.to_string(),
6028                        $axis: $axis.to_string(),
6029                    }
6030                }
6031            )*
6032        }
6033    };
6034}
6035
6036dep_nome_axis_ctors! {
6037    fonte_pin_empty => FontePinEmpty { pin },
6038    fonte_pin_ambiguous => FontePinAmbiguous { pins },
6039    caracteristica_duplicate => CaracteristicaDuplicate { caracteristica },
6040}
6041
6042// Fold the two `DepError::FontePinShape { nome: nome.to_string(),
6043// pin: <pin>.to_string(), value: v.clone(), reason }` four-slot
6044// struct-variant wire-up sites at [`DepSource::validate`]'s
6045// per-`:fonte` git-pin value-shape gate onto one substrate primitive on
6046// the `DepError` envelope — the last open-coded ctor site remaining on
6047// the `:fonte (:tipo git …)` value-shape trajectory this envelope
6048// carries, and the single-variant sibling of the peer four already-
6049// lifted [`DepError`] ctor families ([`fonte_caminho_ctors!`] f85f145
6050// on the two-slot `{ nome, caminho }` envelope,
6051// [`fonte_caminho_byte_ctors!`] 0e35793 on the three-slot
6052// `{ nome, caminho, byte }` envelope, [`dep_nome_only_ctors!`] 792aa92
6053// on the one-slot `{ nome }` envelope, and [`dep_nome_list_ctors!`]
6054// 6f5e0cd on the two-slot `{ nome, list }` envelope). Peer of the
6055// sibling [`crate::aplicacao::contrato_pair_value_reason_ctors!`]
6056// (14e13f1) four-slot fold on the `AplicacaoError` envelope — same
6057// `{ …, value: String, reason: String }` payload shape, one axis
6058// removed at the `nome`-only-owner altitude the `DepError` envelope
6059// keys off (no `edge_pair()` de/para pair).
6060//
6061// The two wire-up sites this fold closes are the paired refname-pin
6062// arm (`|| DepError::FontePinShape { nome: nome.to_string(),
6063// pin: pin.to_string(), value: v.clone(), reason }` inside the
6064// `[(":tag", tag), (":branch", branch)]` iterator against
6065// [`crate::render::is_git_ref_name`]) and the hex-OID-pin arm
6066// (`|| DepError::FontePinShape { nome: nome.to_string(),
6067// pin: ":rev".to_string(), value: v.clone(), reason }` against
6068// [`crate::render::is_git_oid`]) — each opened the identical
6069// `DepError::FontePinShape { … }` six-line struct-literal against the
6070// same `(nome: &str, pin: &str, v: &String, reason: String)` local
6071// tuple, the exact "same block re-inlined at every consumer" shape
6072// the PRIME DIRECTIVE names as a bug. The `pin` axis discriminator is
6073// the only thing that varies between them (`":tag"`/`":branch"` on
6074// the refname arm, `":rev"` on the hex-OID arm); the rest of the
6075// struct-literal is a byte-for-byte re-inline. Refname/hex-OID both
6076// route through the same ctor because their `pin` field carries the
6077// author-surface tag verbatim (matching the `FontePinEmpty` /
6078// `FontePinAmbiguous` sibling variants' `pin: String` axis
6079// convention), so the offending author can grep their caixa.lisp for
6080// the offending `:tag "<value>"` / `:branch "<value>"` /
6081// `:rev "<value>"` literal in one edit.
6082//
6083// The single ctor below folds each wire-up onto one dispatch:
6084// `DepError::fonte_pin_shape(nome, pin, v, reason)`, byte-equal to
6085// the pre-lift struct-literal on the same `(&str, &str, &str,
6086// String)` fixture. The uniform four-field construction
6087// (`nome.to_string()` / `pin.to_string()` / `value.to_string()` /
6088// `reason` forwarded owned) is spelled once here rather than at every
6089// wire-up site. The `reason: String` field takes an owned `String`
6090// (not `impl Into<String>`) matching the two call sites' pre-existing
6091// `let Err(reason) = crate::render::is_git_ref_name(v)` /
6092// `let Err(reason) = crate::render::is_git_oid(v)` shape — both
6093// predicates return `Result<(), String>`, so the caller always holds
6094// an owned `String` at the wire-up site and threading it through the
6095// ctor without a `.into()` shim keeps the routing shape byte-equal to
6096// the pre-lift block. The `value: &str` parameter accepts both `&str`
6097// literals (unused today) and `&String` (from the caller-held
6098// `v: &String` on each arm, via Deref coercion), so every existing
6099// wire-up threads through the ctor without a pre-conversion.
6100//
6101// Every future consumer that wants to construct this variant outside
6102// the two in-crate [`DepSource::validate`] wire-up sites (a deferred
6103// `caixa-resolver` per-`:fonte` re-validator at lacre-resolve time
6104// re-checking the same value-shape axes the resolver consumes, a
6105// future `feira validate --deps` per-caixa admission verb re-checking
6106// the `:fonte :tag`/`:branch`/`:rev` axes, a per-lacre overlay
6107// resolver rejecting a git-pin value against a cluster-local
6108// snapshot) now reaches this variant through one call rather than
6109// re-inlining the six-line struct-literal in lockstep with the two
6110// in-crate wire-up sites.
6111impl DepError {
6112    /// Construct a [`DepError::FontePinShape`] naming the offending
6113    /// `:deps :nome`, the offending `:fonte (:tipo git …) :<pin>`
6114    /// axis tag, the offending value, and the parser-shaped `reason`.
6115    /// Folds the uniform
6116    /// `Self::FontePinShape { nome: nome.to_string(),
6117    /// pin: pin.to_string(), value: value.to_string(), reason }`
6118    /// four-field struct-literal onto one substrate primitive so
6119    /// every [`DepSource::validate`] wire-up on this variant reads
6120    /// through one dispatch rather than the pre-lift six-line
6121    /// open-coded block. The `nome` string threads verbatim from
6122    /// [`Dep::nome`] at the call site; the `pin` string carries the
6123    /// author-surface `:tag` / `:branch` / `:rev` tag verbatim; the
6124    /// `value` string carries the offending refname / hex-OID
6125    /// verbatim; and `reason` forwards the owned `String` returned
6126    /// by [`crate::render::is_git_ref_name`] /
6127    /// [`crate::render::is_git_oid`] without a `.into()` shim.
6128    #[must_use]
6129    pub fn fonte_pin_shape(nome: &str, pin: &str, value: &str, reason: String) -> Self {
6130        Self::FontePinShape {
6131            nome: nome.to_string(),
6132            pin: pin.to_string(),
6133            value: value.to_string(),
6134            reason,
6135        }
6136    }
6137
6138    /// Construct a [`DepError::NomeInvalid`] naming the offending
6139    /// `:deps :nome` byte-string and the parser-shaped rejection
6140    /// `reason` returned by [`crate::render::is_dns_1123_label`].
6141    ///
6142    /// Folds the uniform
6143    /// `Self::NomeInvalid { nome: nome.to_string(), reason }` two-field
6144    /// struct-literal onto one substrate primitive so every wire-up on
6145    /// this variant reads through one dispatch rather than the pre-lift
6146    /// four-line open-coded `DepError::NomeInvalid { nome:
6147    /// self.nome.clone(), reason }` block inside [`Dep::validate`]. The
6148    /// missing two-slot `{ nome, reason }` rung on the `DepError`-side
6149    /// ctor-family ladder (`{ nome }` one-slot →
6150    /// [`dep_nome_only_ctors!`] (792aa92); `{ nome, <axis>: String }`
6151    /// two-slot → [`dep_nome_axis_ctors!`] (7f7c950); `{ nome, list:
6152    /// &'static str }` two-slot → [`dep_nome_list_ctors!`] (6f5e0cd);
6153    /// `{ nome, <axis>: String, reason: String }` three-slot →
6154    /// [`dep_nome_axis_reason_ctors!`] (5621f8a); `{ nome, pin, value,
6155    /// reason }` four-slot → [`DepError::fonte_pin_shape`] (86e2a17))
6156    /// — the sole variant on the envelope carrying the
6157    /// `{ nome: String, reason: String }` two-slot shape without a
6158    /// middle axis, matching the peer
6159    /// [`crate::manifest::ManifestError::NomeInvalid`] +
6160    /// [`crate::aplicacao::AplicacaoError::MembroCaixaInvalid`] +
6161    /// [`crate::supervisor::SupervisorError::ChildCaixaInvalid`]
6162    /// four-axis DNS-1123 caixa-identifier diagnostic family the
6163    /// existing `nome_invalid_diagnostic_carries_offending_name` test
6164    /// pins on this envelope.
6165    ///
6166    /// The `nome: &str` parameter accepts `&str` literals and `&String`
6167    /// (via Deref coercion) so the sole in-crate wire-up threads through
6168    /// the ctor without a pre-conversion; the `reason: String`
6169    /// parameter takes an owned `String` (not `impl Into<String>`)
6170    /// matching the [`crate::render::is_dns_1123_label`] predicate's
6171    /// `Result<(), String>` return shape the sole wire-up site already
6172    /// holds owned at the call site, keeping the routing byte-equal to
6173    /// the pre-lift block. Same owned-`String`-forward `reason` payload
6174    /// discipline as the sibling three-slot family
6175    /// [`dep_nome_axis_reason_ctors!`] on `{ nome, <axis>, reason }`
6176    /// and the four-slot [`DepError::fonte_pin_shape`] on
6177    /// `{ nome, pin, value, reason }`.
6178    ///
6179    /// Every future consumer that raises the same diagnostic outside
6180    /// [`Dep::validate`] — a deferred `caixa-resolver` per-`:deps`
6181    /// re-validator at lacre-resolve time re-checking each declared
6182    /// dep's `:nome` against the same DNS-1123 predicate the apiserver-
6183    /// side schema uses (the `:nome` value flows verbatim as the target
6184    /// caixa's `:nome`, the rendered `lareira-<nome>` Helm chart name
6185    /// segment, the `LABEL_PROGRAM` label value, and the resolver's
6186    /// checkout-directory leaf), a future `feira validate --deps`
6187    /// per-caixa admission verb re-running the shape gate on demand, a
6188    /// per-lacre overlay resolver rejecting an author-supplied dep's
6189    /// `:nome` against a cluster-local snapshot the M4 CR materializer
6190    /// projects, a future authoring-surface widening the field into a
6191    /// `(String, Vec<Suggestion>)` pair carrying a
6192    /// "did-you-mean-<nearest-valid-label>" hint — now reaches this
6193    /// variant through one call rather than re-inlining the four-line
6194    /// struct-literal in lockstep with the one in-crate wire-up site.
6195    #[must_use]
6196    pub fn nome_invalid(nome: &str, reason: String) -> Self {
6197        Self::NomeInvalid {
6198            nome: nome.to_string(),
6199            reason,
6200        }
6201    }
6202}
6203
6204#[allow(clippy::trivially_copy_pass_by_ref)]
6205fn is_false(b: &bool) -> bool {
6206    !*b
6207}
6208
6209#[cfg(test)]
6210mod tests {
6211    use super::*;
6212
6213    #[test]
6214    fn registry_dep_is_minimal() {
6215        let d = Dep::simple("caixa-teia", "^0.1");
6216        assert_eq!(d.nome, "caixa-teia");
6217        assert_eq!(d.versao, "^0.1");
6218        assert!(d.fonte.is_none());
6219        assert!(!d.opcional());
6220        assert!(d.caracteristicas().is_empty());
6221    }
6222
6223    #[test]
6224    fn dep_string_scalar_accessor_pair_is_const_fn() {
6225        // Fail-before-pass-after pin on [`Dep::nome`] +
6226        // [`Dep::versao_requirement`]'s `const`-eval-surface posture.
6227        // Each accessor projects the per-`:deps` / per-`:deps-dev`
6228        // entry's [`String`] storage through the `pub const fn`
6229        // [`String::as_str`] (const-stable since Rust 1.87, well
6230        // within the workspace MSRV) — any future accidental
6231        // downgrade to non-`const` fails the corresponding
6232        // `<name>_via_const_fn` wrapper at caixa-core build time with
6233        // E0015 (`cannot call non-const method`), strictly stronger
6234        // than a runtime `assert!`. Sibling of the peer
6235        // per-M2/M3/universal-axis `String → &str` scalar-accessor
6236        // family pins on the sibling `const`-eval-surface passes
6237        // ([`crate::Caixa::nome`] / [`crate::Caixa::versao`] at the
6238        // top-level manifest, [`crate::CaixaVersion::as_str`] at the
6239        // typed-newtype wrapper, [`crate::aplicacao::Membro::nome`] /
6240        // [`crate::aplicacao::Membro::versao_requirement`] at the M3
6241        // membership axis, [`crate::aplicacao::Entrada::hostname`] /
6242        // [`crate::aplicacao::Entrada::destination`] at the M3
6243        // ingress axis, [`crate::supervisor::ChildSpec::nome`] /
6244        // [`crate::supervisor::ChildSpec::versao_requirement`] at the
6245        // M2 supervisor-tree axis,
6246        // [`crate::upgrade::UpgradeFromEntry::prior_versao`] at the
6247        // M2 upgrade axis, and the per-`:contratos`
6248        // [`crate::aplicacao::WitContract::source`] /
6249        // [`crate::aplicacao::WitContract::destination`] /
6250        // [`crate::aplicacao::WitContract::world_ref`] trio the
6251        // sibling pin at 279823b already anchors).
6252        const fn nome_via_const_fn(d: &Dep) -> &str {
6253            d.nome()
6254        }
6255        const fn versao_via_const_fn(d: &Dep) -> &str {
6256            d.versao_requirement()
6257        }
6258        for (nome, versao) in [
6259            ("caixa-teia", "^0.1"),
6260            ("caixa-mesh", "~0.2.3"),
6261            ("caixa-helm", "*"),
6262        ] {
6263            let d = Dep::simple(nome, versao);
6264            assert_eq!(nome_via_const_fn(&d), d.nome());
6265            assert_eq!(versao_via_const_fn(&d), d.versao_requirement());
6266            assert_eq!(d.nome(), nome);
6267            assert_eq!(d.versao_requirement(), versao);
6268        }
6269    }
6270
6271    #[test]
6272    fn dep_outer_accessor_family_is_const_fn() {
6273        // Fail-before-pass-after pin on [`Dep::fonte`] +
6274        // [`Dep::caracteristicas`]'s `const`-eval-surface posture.
6275        // Each accessor projects the per-`:deps` / per-`:deps-dev`
6276        // entry's composite / list storage through a `pub const fn`
6277        // stdlib method (`Option::<DepSource>::as_ref` /
6278        // `Vec::<String>::as_slice`, both const-stable since Rust
6279        // 1.83, well within the workspace MSRV). Any future
6280        // accidental downgrade to non-`const` fails the corresponding
6281        // `<name>_via_const_fn` wrapper at caixa-core build time with
6282        // E0015 (`cannot call non-const method`), strictly stronger
6283        // than a runtime `assert!` and side-stepping the destructor-
6284        // in-const restriction the `Dep` fixture's `String` /
6285        // `Option<DepSource>` / `Vec<String>` carriers rule out on the
6286        // direct-`const _: () = assert!(...)` residence.
6287        //
6288        // Peer of the sibling per-`Dep` scalar-accessor pair pin
6289        // [`dep_string_scalar_accessor_pair_is_const_fn`] on the same
6290        // outer per-dep-list-entry [`Dep`] altitude — this pin extends
6291        // the `const`-eval-surface discipline onto the composite-
6292        // reference and slice-return arms of the outer-`Dep` accessor
6293        // family, closing the four-slot outer surface (`:nome` +
6294        // `:versao` + `:fonte` + `:caracteristicas`) on the `const`-fn
6295        // posture. The `:opcional` `bool` arm already carries the
6296        // posture through [`Dep::opcional`]'s prior `pub const fn`
6297        // declaration, so this pin lands the last two unlifted
6298        // outer-`Dep` accessors and closes the family.
6299        const fn fonte_via_const_fn(d: &Dep) -> Option<&DepSource> {
6300            d.fonte()
6301        }
6302        const fn caracteristicas_via_const_fn(d: &Dep) -> &[String] {
6303            d.caracteristicas()
6304        }
6305        // `Dep::simple` — no `:fonte`, empty `:caracteristicas`.
6306        let empty = Dep::simple("caixa-teia", "^0.1");
6307        assert!(fonte_via_const_fn(&empty).is_none());
6308        assert_eq!(fonte_via_const_fn(&empty), empty.fonte());
6309        assert!(caracteristicas_via_const_fn(&empty).is_empty());
6310        assert_eq!(
6311            caracteristicas_via_const_fn(&empty),
6312            empty.caracteristicas()
6313        );
6314        // `Dep::git` — `:fonte` is `Some(Git{…})`, `:caracteristicas`
6315        // still empty.
6316        let git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
6317        assert!(fonte_via_const_fn(&git).is_some());
6318        assert_eq!(fonte_via_const_fn(&git), git.fonte());
6319        assert_eq!(caracteristicas_via_const_fn(&git), git.caracteristicas());
6320        // Populated `:caracteristicas` — exercise the non-empty
6321        // slice-view arm to pin the accessor's borrow shape against
6322        // both a `Vec::new()` empty backing buffer and a populated one.
6323        let mut with_features = Dep::simple("caixa-teia", "^0.1");
6324        with_features.caracteristicas = vec!["feat-a".into(), "feat-b".into()];
6325        assert_eq!(caracteristicas_via_const_fn(&with_features).len(), 2);
6326        assert_eq!(
6327            caracteristicas_via_const_fn(&with_features),
6328            with_features.caracteristicas()
6329        );
6330    }
6331
6332    #[test]
6333    fn git_dep_carries_tag() {
6334        let d = Dep::git("t", "*", "github:o/r", "v1");
6335        match d.fonte {
6336            Some(DepSource::Git {
6337                ref repo, ref tag, ..
6338            }) => {
6339                assert_eq!(repo, "github:o/r");
6340                assert_eq!(tag.as_deref(), Some("v1"));
6341            }
6342            _ => panic!("expected Git source"),
6343        }
6344    }
6345
6346    #[test]
6347    fn validate_accepts_simple_dep() {
6348        Dep::simple("caixa-teia", "^0.1").validate().unwrap();
6349    }
6350
6351    #[test]
6352    fn validate_rejects_empty_nome() {
6353        // The fail-before-pass-after pin for `:nome ""`: the empty-name
6354        // arm fires first so the per-entry parse-side diagnostic doesn't
6355        // emit a useless `nome: ""` reference.
6356        let mut d = Dep::simple("placeholder", "^0.1");
6357        d.nome = String::new();
6358        assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
6359    }
6360
6361    #[test]
6362    fn validate_rejects_empty_versao() {
6363        // `parse_requirement("")` returns `Ok(VersionReq::STAR)` (the
6364        // semver crate accepts the empty string as a wildcard match),
6365        // so the empty-`:versao` arm is structurally necessary even
6366        // with the parse arm in place — mirrors `MembroVersaoEmpty` /
6367        // `EmptyChildVersion` ordering on the other two `:versao` axes.
6368        let mut d = Dep::simple("caixa-teia", "ignored");
6369        d.versao = String::new();
6370        let err = d.validate().unwrap_err();
6371        assert!(
6372            matches!(err, DepError::VersaoEmpty { ref nome } if nome == "caixa-teia"),
6373            "got {err:?}"
6374        );
6375    }
6376
6377    // ── value-shape: DNS-1123 label on :deps :nome ────────────────────────
6378
6379    #[test]
6380    fn validate_rejects_nome_with_uppercase() {
6381        // The fail-before-pass-after pin: a non-empty but uppercase
6382        // `:nome` silently passed `validate()` on every pre-gate
6383        // codebase because the prior shape only refused the empty
6384        // string. The DNS-1123 violation surfaced far downstream at
6385        // lacre-resolve time when the *target* caixa's `:nome` failed
6386        // its own gate — far from the `:deps` entry, with a diagnostic
6387        // naming the target rather than the dep entry that referenced
6388        // it. Same fail-before-pass-after fixture pinned for
6389        // `:membros :caixa` (3f9d7a0), `:children :caixa` (31bfa43),
6390        // and Caixa `:nome` (6c992f8).
6391        let d = Dep::simple("Caixa-Teia", "^0.1");
6392        let err = d.validate().unwrap_err();
6393        assert!(
6394            matches!(
6395                err,
6396                DepError::NomeInvalid { ref nome, ref reason }
6397                    if nome == "Caixa-Teia" && reason.contains("uppercase")
6398            ),
6399            "got {err:?}"
6400        );
6401    }
6402
6403    #[test]
6404    fn validate_rejects_nome_with_underscore() {
6405        // RFC 1123 allows `[a-z0-9-]` only; underscore is the canonical
6406        // "I'm thinking of Go module names / Python identifiers" leak.
6407        // Same fixture pinned for the peer caixa-identifier axes.
6408        let d = Dep::simple("caixa_teia", "^0.1");
6409        let err = d.validate().unwrap_err();
6410        assert!(
6411            matches!(
6412                err,
6413                DepError::NomeInvalid { ref nome, ref reason }
6414                    if nome == "caixa_teia" && reason.contains('_')
6415            ),
6416            "got {err:?}"
6417        );
6418    }
6419
6420    #[test]
6421    fn validate_rejects_nome_with_dot() {
6422        // A `:deps :nome` is a single DNS-1123 *label*, not a
6423        // subdomain — dots are rejected. The `"caixa.teia"` shape is
6424        // the canonical "I confused the dep name with the FQDN /
6425        // namespace" footgun, distinct from the legitimate
6426        // `:fonte :repo "github:org/caixa-teia"` axis.
6427        let d = Dep::simple("caixa.teia", "^0.1");
6428        let err = d.validate().unwrap_err();
6429        assert!(
6430            matches!(
6431                err,
6432                DepError::NomeInvalid { ref nome, ref reason }
6433                    if nome == "caixa.teia" && reason.contains('.')
6434            ),
6435            "got {err:?}"
6436        );
6437    }
6438
6439    #[test]
6440    fn validate_rejects_nome_with_leading_hyphen() {
6441        // RFC 1123 requires alphanumeric at both label boundaries.
6442        // Pinned in parity with the peer DNS-1123 fixtures.
6443        let d = Dep::simple("-caixa-teia", "^0.1");
6444        let err = d.validate().unwrap_err();
6445        assert!(
6446            matches!(
6447                err,
6448                DepError::NomeInvalid { ref nome, ref reason }
6449                    if nome == "-caixa-teia" && reason.contains("alphanumeric")
6450            ),
6451            "got {err:?}"
6452        );
6453    }
6454
6455    #[test]
6456    fn validate_rejects_nome_with_trailing_hyphen() {
6457        let d = Dep::simple("caixa-teia-", "^0.1");
6458        let err = d.validate().unwrap_err();
6459        assert!(
6460            matches!(
6461                err,
6462                DepError::NomeInvalid { ref nome, ref reason }
6463                    if nome == "caixa-teia-" && reason.contains("alphanumeric")
6464            ),
6465            "got {err:?}"
6466        );
6467    }
6468
6469    #[test]
6470    fn validate_rejects_nome_with_slash() {
6471        // The canonical "I copied the GitHub repo path into `:nome`
6472        // instead of `:fonte :repo`" typo. A `/` in the name leaks the
6473        // lacre-side `:repositorio` shape (`pleme-io/caixa-teia`) into
6474        // the local-name slot. Same fixture pinned for `:membros
6475        // :caixa` (3f9d7a0).
6476        let d = Dep::simple("pleme-io/caixa-teia", "^0.1");
6477        let err = d.validate().unwrap_err();
6478        assert!(
6479            matches!(
6480                err,
6481                DepError::NomeInvalid { ref nome, ref reason }
6482                    if nome == "pleme-io/caixa-teia" && reason.contains('/')
6483            ),
6484            "got {err:?}"
6485        );
6486    }
6487
6488    #[test]
6489    fn validate_rejects_nome_too_long() {
6490        // 64-byte label — one over the RFC 1035 / RFC 1123 label cap.
6491        // Built from a valid character set so the length-bound
6492        // diagnostic surfaces before any per-character check (the
6493        // order pin parallel to the per-character predicates inside
6494        // [`crate::render::is_dns_1123_label`]).
6495        let long = "a".repeat(64);
6496        let d = Dep::simple(&long, "^0.1");
6497        let err = d.validate().unwrap_err();
6498        assert!(
6499            matches!(
6500                err,
6501                DepError::NomeInvalid { ref nome, ref reason }
6502                    if nome.len() == 64 && reason.contains("max length of 63")
6503            ),
6504            "got {err:?}"
6505        );
6506    }
6507
6508    #[test]
6509    fn validate_accepts_canonical_nome_labels() {
6510        // Positive-control sweep — every form the K8s apiserver
6511        // accepts as a DNS-1123 label must round-trip through
6512        // validate. Covers a hyphen-bearing label, a numeric-suffix
6513        // label, a leading-digit label, a single-character label, and
6514        // a 63-byte (exactly the cap) label — the same fixture set
6515        // the peer `:membros :caixa` / `:children :caixa` positive
6516        // controls pin.
6517        for nome in [
6518            "caixa-teia",
6519            "caixa-resolver2",
6520            "2nd-tier-cache",
6521            "x",
6522            "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0",
6523        ] {
6524            Dep::simple(nome, "^0.1")
6525                .validate()
6526                .unwrap_or_else(|e| panic!("canonical label {nome:?} must validate, got {e:?}"));
6527        }
6528    }
6529
6530    #[test]
6531    fn nome_empty_takes_precedence_over_nome_invalid() {
6532        // Ordering pin: `NomeEmpty` is the more self-locating
6533        // diagnostic on `""` and must lead — `is_dns_1123_label` is
6534        // only reached after the empty-check fires at the call site.
6535        // Mirrors `membro_caixa_empty_takes_precedence_over_invalid`
6536        // (3f9d7a0) on the peer caixa-identifier axis.
6537        let mut d = Dep::simple("placeholder", "^0.1");
6538        d.nome = String::new();
6539        assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
6540    }
6541
6542    #[test]
6543    fn nome_invalid_fires_before_versao_empty() {
6544        // Ordering pin: a malformed `:nome` fires before any `:versao`
6545        // axis check on the *same* entry — the per-entry shape gates
6546        // run top-to-bottom (nome empty → nome shape → versao empty →
6547        // versao parse → fonte shape), so a one-entry caixa.lisp with
6548        // both wrong sees the name-side diagnostic first (the name is
6549        // the self-locating axis — without a valid name, the parse
6550        // diagnostic can't quote `:nome "<bad>"`). Same ordering
6551        // discipline as `membro_caixa_invalid_fires_before_versao_check`
6552        // (3f9d7a0).
6553        let mut d = Dep::simple("Caixa-Teia", "^0.1");
6554        d.versao = String::new();
6555        let err = d.validate().unwrap_err();
6556        assert!(
6557            matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
6558            "got {err:?}"
6559        );
6560    }
6561
6562    #[test]
6563    fn nome_invalid_fires_before_versao_invalid() {
6564        // Ordering pin: a malformed `:nome` fires before the `:versao`
6565        // parse-side check on the *same* entry. Pin separately from
6566        // the empty-versao ordering so a future re-ordering surfaces
6567        // here, parallel to the b0c8389 / c4213a4 trajectory.
6568        let d = Dep::simple("Caixa-Teia", "^^0.1");
6569        let err = d.validate().unwrap_err();
6570        assert!(
6571            matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
6572            "got {err:?}"
6573        );
6574    }
6575
6576    #[test]
6577    fn nome_invalid_fires_before_fonte_invalid() {
6578        // Ordering pin: a malformed `:nome` fires before the `:fonte`
6579        // shape check on the *same* entry. The `:fonte` diagnostic
6580        // names the offending dep's `:nome` verbatim (via
6581        // `DepSource::validate(&self.nome)`), so a non-self-locating
6582        // name would taint the downstream diagnostic too — the gate
6583        // ordering keeps both diagnostics individually self-locating.
6584        let mut d = Dep::simple("Caixa-Teia", "^0.1");
6585        d.fonte = Some(DepSource::Git {
6586            repo: String::new(),
6587            tag: None,
6588            rev: None,
6589            branch: None,
6590        });
6591        let err = d.validate().unwrap_err();
6592        assert!(
6593            matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
6594            "got {err:?}"
6595        );
6596    }
6597
6598    #[test]
6599    fn nome_invalid_diagnostic_carries_offending_name() {
6600        // The diagnostic-shape pin: the error names the offending
6601        // `:nome` value verbatim so the author can grep their
6602        // caixa.lisp without re-running the build, and carries a
6603        // non-empty `reason` from `is_dns_1123_label` so the
6604        // predicate's own wording flows through to the diagnostic.
6605        // Same shape as `MembroCaixaInvalid` (3f9d7a0),
6606        // `ChildCaixaInvalid` (31bfa43), `ManifestError::NomeInvalid`
6607        // (6c992f8) — the four DNS-1123 caixa-identifier axes now
6608        // share a structurally-equivalent diagnostic family.
6609        let d = Dep::simple("Caixa_Teia", "^0.1");
6610        let err = d.validate().unwrap_err();
6611        let DepError::NomeInvalid { nome, reason } = err else {
6612            panic!("expected NomeInvalid, got other variant");
6613        };
6614        assert_eq!(nome, "Caixa_Teia");
6615        assert!(
6616            !reason.is_empty(),
6617            "NomeInvalid `reason` must carry the predicate's wording verbatim"
6618        );
6619    }
6620
6621    #[test]
6622    fn validate_rejects_invalid_versao_requirement() {
6623        // The fail-before-pass-after pin: a non-empty but malformed
6624        // requirement (`"^bad-version"`) silently passed every pre-gate
6625        // codebase because `:deps :versao` wasn't validated. The parse
6626        // failure surfaced far downstream at lacre-resolve time with a
6627        // `semver::Error` that didn't name which `:deps` entry carried
6628        // the typo. The new gate moves the check to caixa-build time
6629        // at the source caixa.lisp.
6630        let d = Dep::simple("caixa-teia", "^bad-version");
6631        let err = d.validate().unwrap_err();
6632        assert!(
6633            matches!(
6634                err,
6635                DepError::VersaoInvalid { ref nome, ref versao, .. }
6636                    if nome == "caixa-teia" && versao == "^bad-version"
6637            ),
6638            "got {err:?}"
6639        );
6640    }
6641
6642    #[test]
6643    fn validate_rejects_versao_with_double_caret_typo() {
6644        // `"^^0.1"` is the canonical doubled-caret typo — looks like a
6645        // Cargo-shaped requirement on first glance but fails the parser
6646        // because semver doesn't accept stacked operators. Pin this
6647        // adjacent-shape footgun explicitly so a future relaxation that
6648        // accepts "looks-canonical-but-isn't" forms surfaces here, in
6649        // parity with the `:membros` / `:children` fixtures.
6650        let d = Dep::simple("caixa-teia", "^^0.1");
6651        let err = d.validate().unwrap_err();
6652        assert!(
6653            matches!(
6654                err,
6655                DepError::VersaoInvalid { ref nome, ref versao, .. }
6656                    if nome == "caixa-teia" && versao == "^^0.1"
6657            ),
6658            "got {err:?}"
6659        );
6660    }
6661
6662    #[test]
6663    fn validate_rejects_versao_with_v_prefixed_tag() {
6664        // `"v0.1"` is the canonical "git-tag-shape leaking into the
6665        // semver requirement slot" typo — an author copies the
6666        // publish-side git-tag string verbatim into `:versao`, but
6667        // Cargo's semver parser rejects the leading `v`. Same fixture
6668        // pinned for `:membros :versao` (9888b13) and `:children
6669        // :versao` (b38ff3a). (Bare `x`-glob shorthands like `^0.1.x`
6670        // are *accepted* by the semver crate as an `*` wildcard on the
6671        // patch axis — they're a Cargo-side valid shape, not a typo.)
6672        let d = Dep::simple("caixa-teia", "v0.1");
6673        let err = d.validate().unwrap_err();
6674        assert!(
6675            matches!(
6676                err,
6677                DepError::VersaoInvalid { ref nome, ref versao, .. }
6678                    if nome == "caixa-teia" && versao == "v0.1"
6679            ),
6680            "got {err:?}"
6681        );
6682    }
6683
6684    #[test]
6685    fn validate_accepts_canonical_versao_forms() {
6686        // The five Cargo-shaped requirement forms `:membros :versao`
6687        // and `:children :versao` already accept via
6688        // `crate::parse_requirement` must pass the deps gate without
6689        // re-validating at the resolver layer. Pin every leg so a
6690        // future tightening of the canonical set surfaces here as a
6691        // test failure.
6692        for form in [
6693            "^0.1",      // caret — minor-range pin (the most common shape)
6694            "~0.1.2",    // tilde — patch-range pin
6695            "0.1.0",     // exact — single-version pin
6696            "*",         // wildcard — explicitly any-version
6697            ">=0.1, <2", // multi-range — comma-separated comparators
6698        ] {
6699            Dep::simple("caixa-teia", form)
6700                .validate()
6701                .unwrap_or_else(|e| panic!("canonical form {form:?} must validate, got {e:?}"));
6702        }
6703    }
6704
6705    #[test]
6706    fn versao_empty_takes_precedence_over_invalid() {
6707        // Order pin: the existing `VersaoEmpty` diagnostic (which
6708        // doesn't try to parse) fires before the new `VersaoInvalid`
6709        // parse-side diagnostic, so an empty `:versao` keeps its
6710        // narrower error message — `parse_requirement("")` would
6711        // otherwise return `Ok(STAR)` and silently pass, but the empty
6712        // arm catches it first.
6713        let mut d = Dep::simple("caixa-teia", "ignored");
6714        d.versao = String::new();
6715        let err = d.validate().unwrap_err();
6716        assert!(
6717            matches!(err, DepError::VersaoEmpty { ref nome } if nome == "caixa-teia"),
6718            "got {err:?}"
6719        );
6720    }
6721
6722    #[test]
6723    fn nome_empty_takes_precedence_over_versao_invalid() {
6724        // Order pin: even when `:versao` is malformed and would raise
6725        // its own diagnostic, `:nome ""` fires first because the
6726        // per-entry parse diagnostic needs a non-empty name to be
6727        // self-locating. Mirrors the
6728        // `membros_validation_runs_before_contratos_membership_check`
6729        // ordering on the typed-graph layer.
6730        let mut d = Dep::simple("placeholder", "^bad");
6731        d.nome = String::new();
6732        let err = d.validate().unwrap_err();
6733        assert_eq!(err, DepError::NomeEmpty);
6734    }
6735
6736    #[test]
6737    fn versao_invalid_diagnostic_carries_offending_versao() {
6738        // The diagnostic-shape pin: the error names the offending
6739        // `:versao` value verbatim so the author can grep their
6740        // caixa.lisp without re-running the build, and carries a
6741        // non-empty `reason` from `semver::VersionReq::parse` so the
6742        // parser's own wording flows through to the diagnostic.
6743        let d = Dep::simple("caixa-teia", "not-a-req");
6744        let err = d.validate().unwrap_err();
6745        let DepError::VersaoInvalid {
6746            nome,
6747            versao,
6748            reason,
6749        } = err
6750        else {
6751            panic!("expected VersaoInvalid, got other variant");
6752        };
6753        assert_eq!(nome, "caixa-teia");
6754        assert_eq!(versao, "not-a-req");
6755        assert!(
6756            !reason.is_empty(),
6757            "VersaoInvalid `reason` must carry the parser's wording verbatim"
6758        );
6759    }
6760
6761    // -- :fonte value-shape gate ------------------------------------------
6762
6763    fn dep_with_fonte(fonte: DepSource) -> Dep {
6764        let mut d = Dep::simple("caixa-teia", "^0.1");
6765        d.fonte = Some(fonte);
6766        d
6767    }
6768
6769    #[test]
6770    fn validate_accepts_git_fonte_with_tag() {
6771        // The positive-control pin on the canonical git source — exactly
6772        // one of :tag/:rev/:branch set, non-empty :repo. Mirrors the
6773        // shape every existing caixa-resolver integration test uses.
6774        let d = dep_with_fonte(DepSource::Git {
6775            repo: "github:pleme-io/caixa-teia".into(),
6776            tag: Some("v0.1.0".into()),
6777            rev: None,
6778            branch: None,
6779        });
6780        d.validate().unwrap();
6781    }
6782
6783    #[test]
6784    fn validate_accepts_git_fonte_with_rev() {
6785        // Each of the three pin axes is independently a valid single-pin
6786        // shape; pin the :rev arm so a future relaxation that only
6787        // accepts :tag surfaces here. The value is a full 40-hex SHA-1
6788        // OID — the canonical `git rev-parse HEAD` emission shape the
6789        // `crate::render::is_git_oid` value-shape gate now requires;
6790        // abbreviated OIDs are ambiguous across repo history and
6791        // rejected at this gate (pinned separately by
6792        // `validate_rejects_git_fonte_with_rev_abbreviated_prefix`).
6793        let d = dep_with_fonte(DepSource::Git {
6794            repo: "github:pleme-io/caixa-teia".into(),
6795            tag: None,
6796            rev: Some("c0ffee0123abcdef0123456789abcdef01234567".into()),
6797            branch: None,
6798        });
6799        d.validate().unwrap();
6800    }
6801
6802    #[test]
6803    fn validate_accepts_git_fonte_with_branch() {
6804        // The :branch arm is the third valid single-pin shape — pinned
6805        // separately so the gate-accepts-all-three-pin-axes contract is
6806        // a build-error to relax.
6807        let d = dep_with_fonte(DepSource::Git {
6808            repo: "github:pleme-io/caixa-teia".into(),
6809            tag: None,
6810            rev: None,
6811            branch: Some("main".into()),
6812        });
6813        d.validate().unwrap();
6814    }
6815
6816    #[test]
6817    fn validate_accepts_path_fonte() {
6818        // The positive-control pin on the path source — non-empty
6819        // :caminho, no pin axes (paths have no commit identity). Pinned
6820        // so a future "paths must also pin a rev" tightening surfaces
6821        // here as a structural decision, not a silent break.
6822        let d = dep_with_fonte(DepSource::Path {
6823            caminho: "../caixa-teia".into(),
6824        });
6825        d.validate().unwrap();
6826    }
6827
6828    #[test]
6829    fn validate_rejects_git_fonte_with_empty_repo() {
6830        // The fail-before-pass-after pin for `(:tipo git :repo "" :tag
6831        // "v1")`: the empty-repo shape silently passed every pre-gate
6832        // codebase because `:fonte` wasn't validated. The git-clone
6833        // failure surfaced far downstream at lacre-resolve time with no
6834        // field naming which `:deps` entry carried the typo. The new
6835        // gate moves the check to caixa-build time at the source
6836        // caixa.lisp.
6837        let d = dep_with_fonte(DepSource::Git {
6838            repo: String::new(),
6839            tag: Some("v0.1.0".into()),
6840            rev: None,
6841            branch: None,
6842        });
6843        let err = d.validate().unwrap_err();
6844        assert!(
6845            matches!(err, DepError::FonteRepoEmpty { ref nome } if nome == "caixa-teia"),
6846            "got {err:?}"
6847        );
6848    }
6849
6850    // -- :repo value-shape gate -------------------------------------------
6851    //
6852    // The `:fonte (:tipo git :repo …)` value flows verbatim into the
6853    // caixa-resolver's `git clone <repo>` subprocess. The pre-gate
6854    // codebase admitted any non-empty string; the new
6855    // [`crate::render::is_git_repo_url`] predicate gates the git-porcelain
6856    // URL intersection-floor at validate time, peer with the three pin
6857    // axes (`:tag` + `:branch` via `is_git_ref_name`, `:rev` via
6858    // `is_git_oid`). Every test in this section is a fail-before /
6859    // pass-after pin on a specific authoring footgun.
6860
6861    #[test]
6862    fn validate_rejects_git_fonte_with_repo_carrying_trailing_space() {
6863        // The canonical paste-from-doc footgun on `:repo` — an author
6864        // copies `"github:pleme-io/caixa-teia "` (trailing space) out of
6865        // a doc paragraph. Until this gate landed the empty-repo arm
6866        // passed (the string isn't empty), the resolver issued
6867        // `git clone 'github:pleme-io/caixa-teia '`, and the failure
6868        // surfaced at clone time with a quoting-confused error far from
6869        // the source caixa.lisp. Same paste-from-doc footgun the
6870        // `:tag "v0.1.0 "` gate (e70d213) closes on the peer refname
6871        // axis — now closed on the `:repo` URL axis too.
6872        let d = dep_with_fonte(DepSource::Git {
6873            repo: "github:pleme-io/caixa-teia ".into(),
6874            tag: Some("v0.1.0".into()),
6875            rev: None,
6876            branch: None,
6877        });
6878        let err = d.validate().unwrap_err();
6879        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6880            panic!("expected FonteRepoShape, got other variant");
6881        };
6882        assert_eq!(nome, "caixa-teia");
6883        assert_eq!(repo, "github:pleme-io/caixa-teia ");
6884        assert!(
6885            reason.contains("whitespace"),
6886            "reason must surface the whitespace arm, got {reason:?}"
6887        );
6888    }
6889
6890    #[test]
6891    fn validate_rejects_git_fonte_with_repo_starting_with_dash() {
6892        // The canonical CLI-argument-injection footgun at the `git clone`
6893        // subprocess boundary — `:repo "-upload-pack=evil"` makes git's
6894        // argv parser read the value as a CLI flag, escaping the
6895        // subprocess argument boundary. The `--` separator workaround
6896        // does not fix the typed slot's accepted set; the gate rejects
6897        // the shape upstream at validate time so the resolver never
6898        // invokes a `git clone -…` subprocess.
6899        let d = dep_with_fonte(DepSource::Git {
6900            repo: "-upload-pack=evil".into(),
6901            tag: Some("v0.1.0".into()),
6902            rev: None,
6903            branch: None,
6904        });
6905        let err = d.validate().unwrap_err();
6906        let DepError::FonteRepoShape { repo, reason, .. } = err else {
6907            panic!("expected FonteRepoShape, got other variant");
6908        };
6909        assert_eq!(repo, "-upload-pack=evil");
6910        assert!(
6911            reason.contains("must not start with `-`"),
6912            "reason must surface the leading-`-` arm, got {reason:?}"
6913        );
6914    }
6915
6916    #[test]
6917    fn validate_rejects_git_fonte_with_repo_carrying_embedded_newline() {
6918        // The canonical paste-from-multiline-doc footgun — a `:repo`
6919        // string with an embedded `\n` silently breaks git's URL parser
6920        // and is a class of CRLF-injection at the subprocess-argument
6921        // boundary. Caught by the control-char arm (0x0A < 0x20).
6922        let d = dep_with_fonte(DepSource::Git {
6923            repo: "github:pleme-io/caixa-teia\nrm -rf /".into(),
6924            tag: Some("v0.1.0".into()),
6925            rev: None,
6926            branch: None,
6927        });
6928        let err = d.validate().unwrap_err();
6929        let DepError::FonteRepoShape { reason, .. } = err else {
6930            panic!("expected FonteRepoShape, got other variant");
6931        };
6932        assert!(
6933            reason.contains("control character"),
6934            "reason must surface the control-char arm, got {reason:?}"
6935        );
6936    }
6937
6938    #[test]
6939    fn validate_rejects_git_fonte_with_repo_carrying_tab() {
6940        // Tab is the sibling whitespace footgun (the canonical
6941        // copy-from-aligned-table paste); pinned separately from the
6942        // space arm so a future relaxation that only catches one
6943        // surfaces here.
6944        let d = dep_with_fonte(DepSource::Git {
6945            repo: "github:pleme-io/caixa-teia\t".into(),
6946            tag: Some("v0.1.0".into()),
6947            rev: None,
6948            branch: None,
6949        });
6950        let err = d.validate().unwrap_err();
6951        assert!(
6952            matches!(
6953                err,
6954                DepError::FonteRepoShape { ref reason, .. }
6955                    if reason.contains("whitespace")
6956            ),
6957            "got {err:?}"
6958        );
6959    }
6960
6961    #[test]
6962    fn validate_rejects_git_fonte_with_repo_carrying_non_ascii() {
6963        // IDN hosts must be pre-encoded as Punycode (`xn--…`) — raw
6964        // non-ASCII silently breaks at git's URL parser and round-trips
6965        // inconsistently across NFC/NFD normalization on APFS /
6966        // case-folding filesystems. Same intersection-floor
6967        // [`is_git_ref_name`] enforces on the refname axes.
6968        let d = dep_with_fonte(DepSource::Git {
6969            repo: "https://github.com/pleme-io/café".into(),
6970            tag: Some("v0.1.0".into()),
6971            rev: None,
6972            branch: None,
6973        });
6974        let err = d.validate().unwrap_err();
6975        assert!(
6976            matches!(
6977                err,
6978                DepError::FonteRepoShape { ref reason, .. }
6979                    if reason.contains("non-ASCII")
6980            ),
6981            "got {err:?}"
6982        );
6983    }
6984
6985    #[test]
6986    fn validate_rejects_git_fonte_with_repo_carrying_fragment_anchor() {
6987        // The fail-before-pass-after pin for the canonical paste-from-
6988        // browser-address-bar footgun on `:repo`: an author copies a
6989        // GitHub permalink to a README anchor / line-permalink and
6990        // forgets to trim the `#fragment` tail. Until this arm landed
6991        // `:repo "https://github.com/pleme-io/caixa-teia#readme"`
6992        // silently passed every prior arm (no whitespace, no control
6993        // chars, no non-ASCII, contains a `:`, doesn't start with `-`
6994        // or `:`), libcurl's URL parser stripped the `#readme` tail
6995        // before opening the HTTPS transport, and the lacre embedded
6996        // the value verbatim in its per-dep BLAKE3 closure — two
6997        // authors whose values differ only in their fragment anchor
6998        // (`#readme` vs `#L42`) resolve to the byte-identical upstream
6999        // `git clone` but lock to two distinct lacres, defeating the
7000        // THEORY.md §V.2 render-determinism contract. Same value-shape
7001        // axis-floor every peer typed surface enforces; peer `:fonte
7002        // :tag` / `:fonte :branch` already reject the byte-class through
7003        // `is_git_ref_name`'s alphabet (refs are leaf identifiers, no
7004        // URL grammar admitted) and `:entrada :paths` rejects `#` as
7005        // part of `is_gateway_api_http_path`'s RFC-3986-reserved set.
7006        let d = dep_with_fonte(DepSource::Git {
7007            repo: "https://github.com/pleme-io/caixa-teia#readme".into(),
7008            tag: Some("v0.1.0".into()),
7009            rev: None,
7010            branch: None,
7011        });
7012        let err = d.validate().unwrap_err();
7013        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7014            panic!("expected FonteRepoShape, got other variant");
7015        };
7016        assert_eq!(nome, "caixa-teia");
7017        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia#readme");
7018        assert!(
7019            reason.contains("must not contain `#`"),
7020            "reason must surface the fragment-`#` arm, got {reason:?}"
7021        );
7022        assert!(
7023            reason.contains("fragment"),
7024            "reason must name the URL fragment grammar, got {reason:?}"
7025        );
7026    }
7027
7028    #[test]
7029    fn validate_rejects_git_fonte_with_repo_carrying_flake_ref_fragment() {
7030        // The symmetric paste-from-Nix-flake-ref footgun — an author
7031        // confuses the Nix flake-reference idiom (`github:foo/
7032        // bar#packageName`, where `#packageName` selects a flake
7033        // output) with the bare git `:repo` shape. The pleme-io
7034        // substrate authors compose flakes downstream of caixa
7035        // (caixa-flake renders a flake.nix), so the cross-idiom leak
7036        // is the canonical near-miss: the author writes the
7037        // flake-ref shape into a git `:repo` slot. Pinned separately
7038        // from the HTTPS-anchor arm so a future relaxation that
7039        // narrows to one URL scheme surfaces here.
7040        let d = dep_with_fonte(DepSource::Git {
7041            repo: "github:pleme-io/caixa-teia#caixa-teia".into(),
7042            tag: Some("v0.1.0".into()),
7043            rev: None,
7044            branch: None,
7045        });
7046        let err = d.validate().unwrap_err();
7047        let DepError::FonteRepoShape { reason, .. } = err else {
7048            panic!("expected FonteRepoShape, got other variant");
7049        };
7050        assert!(
7051            reason.contains("must not contain `#`"),
7052            "reason must surface the fragment-`#` arm, got {reason:?}"
7053        );
7054        assert!(
7055            reason.contains("Nix flake"),
7056            "reason must name the Nix-flake-ref cross-idiom footgun, got {reason:?}"
7057        );
7058    }
7059
7060    #[test]
7061    fn validate_rejects_git_fonte_with_repo_carrying_query_string() {
7062        // The fail-before-pass-after pin for the canonical paste-from-
7063        // browser-address-bar footgun on `:repo` (peer with the
7064        // a68f818 fragment-`#` arm on the same axis). An author
7065        // copies a GitHub tab deep-link out of the address bar and
7066        // forgets to trim the `?tab=…` query tail. Until this arm
7067        // landed `:repo "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file"`
7068        // silently passed every prior arm (no whitespace, no control
7069        // chars, no non-ASCII, no `#` fragment, contains a `:`,
7070        // doesn't start with `-` or `:`); GitHub silently ignored
7071        // the `?query` tail and served the same repo regardless;
7072        // the lacre embedded the value verbatim in its per-dep
7073        // BLAKE3 closure — two authors whose values differ only in
7074        // their query tail (`?tab=readme-ov-file` vs `?ref=main` vs
7075        // `?utm_source=twitter`) resolve to the byte-identical
7076        // upstream `git clone` but lock to two distinct lacres,
7077        // defeating the THEORY.md §V.2 render-determinism contract
7078        // on the same axis the `#` fragment arm closes. Same value-
7079        // shape axis-floor every peer typed surface enforces; peer
7080        // `:fonte :tag` / `:fonte :branch` already reject the byte-
7081        // class through `is_git_ref_name`'s alphabet (refspec glob
7082        // wildcards, caixa-core/src/render.rs:1426) and `:entrada
7083        // :paths` rejects `?` as the query separator in
7084        // `is_gateway_api_http_path` (caixa-core/src/render.rs:473).
7085        let d = dep_with_fonte(DepSource::Git {
7086            repo: "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file".into(),
7087            tag: Some("v0.1.0".into()),
7088            rev: None,
7089            branch: None,
7090        });
7091        let err = d.validate().unwrap_err();
7092        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7093            panic!("expected FonteRepoShape, got other variant");
7094        };
7095        assert_eq!(nome, "caixa-teia");
7096        assert_eq!(
7097            repo,
7098            "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file"
7099        );
7100        assert!(
7101            reason.contains("must not contain `?`"),
7102            "reason must surface the query-`?` arm, got {reason:?}"
7103        );
7104        assert!(
7105            reason.contains("query"),
7106            "reason must name the URL query grammar, got {reason:?}"
7107        );
7108    }
7109
7110    #[test]
7111    fn validate_rejects_git_fonte_with_repo_carrying_utm_tracker() {
7112        // The symmetric paste-from-social-share footgun — an author
7113        // copies a repo URL out of a Slack unfurl / Twitter share /
7114        // newsletter link / Discord embed and forgets to trim the
7115        // `?utm_source=…` / `?utm_medium=…` / `?utm_campaign=…`
7116        // campaign-tracker tail. Every major social-share / unfurl /
7117        // newsletter platform appends these UTM parameters; the
7118        // canonical near-miss on the `:repo` axis. Pinned separately
7119        // from the GitHub-tab-deep-link arm so a future relaxation
7120        // that narrows to one query-parameter class surfaces here.
7121        let d = dep_with_fonte(DepSource::Git {
7122            repo: "https://github.com/pleme-io/caixa-teia?utm_source=twitter&utm_campaign=launch"
7123                .into(),
7124            tag: Some("v0.1.0".into()),
7125            rev: None,
7126            branch: None,
7127        });
7128        let err = d.validate().unwrap_err();
7129        let DepError::FonteRepoShape { reason, .. } = err else {
7130            panic!("expected FonteRepoShape, got other variant");
7131        };
7132        assert!(
7133            reason.contains("must not contain `?`"),
7134            "reason must surface the query-`?` arm, got {reason:?}"
7135        );
7136        assert!(
7137            reason.contains("campaign-tracker"),
7138            "reason must name the campaign-tracker paste footgun, got {reason:?}"
7139        );
7140    }
7141
7142    #[test]
7143    fn fonte_repo_fragment_fires_before_query_when_fragment_first() {
7144        // Cascade pin: the fragment-`#` arm and the query-`?` arm are
7145        // both per-byte arms inside the same `for &b in s.as_bytes()`
7146        // loop, so the byte that appears first in the value's byte
7147        // order wins. A `:repo "https://github.com/p/x#readme?ref=main"`
7148        // (fragment before query — unusual URL-grammar but value-
7149        // disjoint at byte level) carries both `#` and `?`; the `#`
7150        // byte appears first, so the fragment-`#` arm fires, surfacing
7151        // the more self-locating diagnostic on the byte the author
7152        // pasted earliest in the URL. Mirrors the peer cascade
7153        // discipline `fonte_repo_control_char_fires_before_fragment`
7154        // pins on the prior `:repo` byte-class arm.
7155        let d = dep_with_fonte(DepSource::Git {
7156            repo: "https://github.com/pleme-io/caixa-teia#readme?ref=main".into(),
7157            tag: Some("v0.1.0".into()),
7158            rev: None,
7159            branch: None,
7160        });
7161        let err = d.validate().unwrap_err();
7162        let DepError::FonteRepoShape { reason, .. } = err else {
7163            panic!("expected FonteRepoShape, got other variant");
7164        };
7165        assert!(
7166            reason.contains("must not contain `#`"),
7167            "reason must surface the fragment-`#` arm (fires before query-`?` when \
7168             `#` byte appears first in value), got {reason:?}"
7169        );
7170    }
7171
7172    #[test]
7173    fn fonte_repo_control_char_fires_before_fragment() {
7174        // Cascade pin: the control-char arm structurally precedes the
7175        // fragment-`#` arm. A value like `"github:p/x\n#readme"` probes
7176        // positive on both arms (contains LF and `#`), but the narrower
7177        // POSIX-syscall-rejected / CRLF-injection-class diagnostic
7178        // (`control character`) wins so the author sees the more
7179        // self-locating arm first. Mirrors the peer cascade discipline
7180        // every prior `:repo` byte-class arm establishes.
7181        let d = dep_with_fonte(DepSource::Git {
7182            repo: "github:pleme-io/caixa-teia\n#readme".into(),
7183            tag: Some("v0.1.0".into()),
7184            rev: None,
7185            branch: None,
7186        });
7187        let err = d.validate().unwrap_err();
7188        let DepError::FonteRepoShape { reason, .. } = err else {
7189            panic!("expected FonteRepoShape, got other variant");
7190        };
7191        assert!(
7192            reason.contains("control character"),
7193            "reason must surface the control-char arm, got {reason:?}"
7194        );
7195    }
7196
7197    #[test]
7198    fn validate_rejects_git_fonte_with_repo_carrying_embedded_backslash() {
7199        // The fail-before-pass-after pin for the canonical Windows-
7200        // file-path-confusion footgun on `:repo` (peer with the 3a4e1d7
7201        // backslash arm on the sibling `:caminho` path-fonte axis).
7202        // An author pastes a Windows Explorer address-bar / PowerShell
7203        // `Get-Location` output into a `file://` URL slot, producing
7204        // `file:///C:\Users\me\caixa-teia`. Until this arm landed the
7205        // value silently passed every prior arm (no whitespace, no
7206        // control chars, no non-ASCII, no `#`, no `?`, doesn't start
7207        // with `-` or `:`); libcurl's URL parser silently translates
7208        // `\` → `/` on some platforms and refuses it on others, so
7209        // the byte rides verbatim into the lacre's per-dep content-
7210        // address but is silently rewritten / rejected at the wire —
7211        // two authors whose `:repo` values differ only in backslash-
7212        // vs-forward-slash (`file:///C:\path` vs `file:///C:/path`)
7213        // resolve to the byte-identical local clone but lock to two
7214        // distinct BLAKE3 closures, defeating the THEORY.md §V.2
7215        // render-determinism contract on the same axis the `#`
7216        // fragment and `?` query arms close. Same value-shape axis-
7217        // floor every peer typed surface enforces; the `:caminho`
7218        // 3a4e1d7 arm closes the same byte on the path-fonte axis.
7219        let d = dep_with_fonte(DepSource::Git {
7220            repo: "file:///C:\\Users\\me\\caixa-teia".into(),
7221            tag: Some("v0.1.0".into()),
7222            rev: None,
7223            branch: None,
7224        });
7225        let err = d.validate().unwrap_err();
7226        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7227            panic!("expected FonteRepoShape, got other variant");
7228        };
7229        assert_eq!(nome, "caixa-teia");
7230        assert_eq!(repo, "file:///C:\\Users\\me\\caixa-teia");
7231        assert!(
7232            reason.contains("must not contain `\\`"),
7233            "reason must surface the backslash-`\\` arm, got {reason:?}"
7234        );
7235        assert!(
7236            reason.contains("Windows"),
7237            "reason must name the Windows-path-confusion footgun, got {reason:?}"
7238        );
7239    }
7240
7241    #[test]
7242    fn validate_rejects_git_fonte_with_repo_carrying_mangled_https_backslashes() {
7243        // The symmetric Win32-shell-mangled-slashes footgun — an author
7244        // copies `https://github.com/foo/bar` into a Win32 shell that
7245        // rewrites every `/` to `\` (the canonical `cmd.exe` path-
7246        // separator-coercion bug), pastes the result into a `:repo`
7247        // slot, and produces `https:\\github.com\foo\bar`. Pinned
7248        // separately from the `file://` Explorer-paste arm so a future
7249        // relaxation that narrows to one URL scheme surfaces here.
7250        let d = dep_with_fonte(DepSource::Git {
7251            repo: "https:\\\\github.com\\pleme-io\\caixa-teia".into(),
7252            tag: Some("v0.1.0".into()),
7253            rev: None,
7254            branch: None,
7255        });
7256        let err = d.validate().unwrap_err();
7257        let DepError::FonteRepoShape { reason, .. } = err else {
7258            panic!("expected FonteRepoShape, got other variant");
7259        };
7260        assert!(
7261            reason.contains("must not contain `\\`"),
7262            "reason must surface the backslash-`\\` arm, got {reason:?}"
7263        );
7264        assert!(
7265            reason.contains("path separator") || reason.contains("path-segment separator"),
7266            "reason must name the URL path-segment separator grammar, got {reason:?}"
7267        );
7268    }
7269
7270    #[test]
7271    fn fonte_repo_fragment_fires_before_backslash_when_fragment_first() {
7272        // Cascade pin: the fragment-`#` arm and the backslash-`\` arm
7273        // are both per-byte arms inside the same `for &b in s.as_bytes()`
7274        // loop, so the byte that appears first in the value's byte order
7275        // wins. A `:repo "https://github.com/p/x#readme\\foo"` carries
7276        // both `#` and `\`; the `#` byte appears first, so the fragment-
7277        // `#` arm fires, surfacing the more self-locating diagnostic on
7278        // the byte the author pasted earliest in the URL. Mirrors the
7279        // peer cascade discipline `fonte_repo_fragment_fires_before_query_when_fragment_first`
7280        // pins on the prior `:repo` byte-class arm.
7281        let d = dep_with_fonte(DepSource::Git {
7282            repo: "https://github.com/pleme-io/caixa-teia#readme\\foo".into(),
7283            tag: Some("v0.1.0".into()),
7284            rev: None,
7285            branch: None,
7286        });
7287        let err = d.validate().unwrap_err();
7288        let DepError::FonteRepoShape { reason, .. } = err else {
7289            panic!("expected FonteRepoShape, got other variant");
7290        };
7291        assert!(
7292            reason.contains("must not contain `#`"),
7293            "reason must surface the fragment-`#` arm (fires before backslash-`\\` when \
7294             `#` byte appears first in value), got {reason:?}"
7295        );
7296    }
7297
7298    #[test]
7299    fn validate_rejects_git_fonte_with_repo_carrying_uri_template_placeholder() {
7300        // The fail-before-pass-after pin for the canonical URI Template
7301        // (RFC 6570) placeholder footgun on `:repo`. An author copies a
7302        // README quick-start snippet / OpenAPI `servers:` URL / Helm
7303        // chart `home:` template that carries unresolved
7304        // `{org}` / `{repo}` placeholders and pastes the raw template
7305        // into the `:repo` slot, expecting the substrate to resolve the
7306        // placeholder downstream. Until this arm landed the value
7307        // silently passed every prior arm (no whitespace, no control
7308        // chars, no non-ASCII, no `#`, no `?`, no `\`, doesn't start
7309        // with `-` or `:`); libcurl percent-encodes `{` / `}` to `%7B`
7310        // / `%7D` on the wire, so the byte rides verbatim into the
7311        // lacre's per-dep content-address but round-trips inconsistently
7312        // between the lacre's per-dep content-address and the
7313        // resolver's `git clone <repo>` invocation, defeating the
7314        // THEORY.md §V.2 render-determinism contract on the same axis
7315        // the `#` fragment, `?` query, and `\` backslash arms close;
7316        // every git porcelain entry-point additionally fetches a
7317        // nonexistent literal-`{placeholder}`-named path far from the
7318        // source caixa.lisp.
7319        let d = dep_with_fonte(DepSource::Git {
7320            repo: "https://github.com/{org}/caixa-teia".into(),
7321            tag: Some("v0.1.0".into()),
7322            rev: None,
7323            branch: None,
7324        });
7325        let err = d.validate().unwrap_err();
7326        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7327            panic!("expected FonteRepoShape, got other variant");
7328        };
7329        assert_eq!(nome, "caixa-teia");
7330        assert_eq!(repo, "https://github.com/{org}/caixa-teia");
7331        assert!(
7332            reason.contains("must not contain `{`"),
7333            "reason must surface the open-brace `{{` arm, got {reason:?}"
7334        );
7335        assert!(
7336            reason.contains("URI Template") || reason.contains("RFC 6570"),
7337            "reason must name the RFC 6570 URI Template grammar, got {reason:?}"
7338        );
7339    }
7340
7341    #[test]
7342    fn validate_rejects_git_fonte_with_repo_carrying_handlebars_doubled_brace() {
7343        // The symmetric Mustache / Handlebars doubled-brace
7344        // substitution-form footgun every CI / IaC templating engine
7345        // (Argo Workflows, Jinja2, Liquid, Vue / Angular interpolation,
7346        // GitHub Actions `${{ … }}` even though Actions uses `${{`) /
7347        // chart README quick-start snippet emits. Pinned separately
7348        // from the single-`{` `{org}` arm so a future relaxation that
7349        // narrows to one substitution-form surfaces here.
7350        let d = dep_with_fonte(DepSource::Git {
7351            repo: "https://github.com/{{org}}/caixa-teia".into(),
7352            tag: Some("v0.1.0".into()),
7353            rev: None,
7354            branch: None,
7355        });
7356        let err = d.validate().unwrap_err();
7357        let DepError::FonteRepoShape { reason, .. } = err else {
7358            panic!("expected FonteRepoShape, got other variant");
7359        };
7360        assert!(
7361            reason.contains("must not contain `{`"),
7362            "reason must surface the open-brace `{{` arm, got {reason:?}"
7363        );
7364    }
7365
7366    #[test]
7367    fn validate_rejects_git_fonte_with_repo_carrying_closing_brace_only() {
7368        // Asymmetric `}`-only shape — covers the closing-brace-by-
7369        // itself footgun (an author truncated `{org}/{repo}` mid-edit
7370        // and left a trailing `}` from the prior template fragment,
7371        // or pasted a value that included a closing brace from a
7372        // surrounding shell context). Pinned to ensure the predicate
7373        // refuses each brace independently rather than only when both
7374        // appear — a future regression that ANDs the two byte tests
7375        // surfaces here.
7376        let d = dep_with_fonte(DepSource::Git {
7377            repo: "https://github.com/pleme-io/caixa-teia}".into(),
7378            tag: Some("v0.1.0".into()),
7379            rev: None,
7380            branch: None,
7381        });
7382        let err = d.validate().unwrap_err();
7383        let DepError::FonteRepoShape { reason, .. } = err else {
7384            panic!("expected FonteRepoShape, got other variant");
7385        };
7386        assert!(
7387            reason.contains("must not contain `}`"),
7388            "reason must surface the close-brace `}}` arm, got {reason:?}"
7389        );
7390    }
7391
7392    #[test]
7393    fn fonte_repo_fragment_fires_before_template_placeholder_when_fragment_first() {
7394        // Cascade pin: the fragment-`#` arm and the template-`{` /
7395        // `}` arm are both per-byte arms inside the same
7396        // `for &b in s.as_bytes()` loop, so the byte that appears
7397        // first in the value's byte order wins. A `:repo
7398        // "https://github.com/p/x#readme{org}"` carries both `#` and
7399        // `{`; the `#` byte appears first, so the fragment-`#` arm
7400        // fires, surfacing the more self-locating diagnostic on the
7401        // byte the author pasted earliest in the URL. Mirrors the
7402        // peer cascade discipline `fonte_repo_fragment_fires_before_backslash_when_fragment_first`
7403        // pins on the prior `:repo` byte-class arm.
7404        let d = dep_with_fonte(DepSource::Git {
7405            repo: "https://github.com/pleme-io/caixa-teia#readme{org}".into(),
7406            tag: Some("v0.1.0".into()),
7407            rev: None,
7408            branch: None,
7409        });
7410        let err = d.validate().unwrap_err();
7411        let DepError::FonteRepoShape { reason, .. } = err else {
7412            panic!("expected FonteRepoShape, got other variant");
7413        };
7414        assert!(
7415            reason.contains("must not contain `#`"),
7416            "reason must surface the fragment-`#` arm (fires before template-`{{` when \
7417             `#` byte appears first in value), got {reason:?}"
7418        );
7419    }
7420
7421    #[test]
7422    fn validate_rejects_git_fonte_with_repo_carrying_output_redirection() {
7423        // The fail-before-pass-after pin for the canonical
7424        // shell-output-redirection footgun on `:repo`: an author
7425        // pastes a shell-pipeline tail (`git clone <repo> > build.log`
7426        // / `… >output.txt`) into the `:repo` slot without trimming
7427        // the redirect. Until this arm landed the value silently
7428        // passed every prior arm (no whitespace, no control chars,
7429        // no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, doesn't
7430        // start with `-` or `:`); RFC 3986 §2 lists `<` / `>` in the
7431        // 'delims' / 'unwise' set and the WHATWG URL spec's fragment
7432        // percent-encode set maps `>` → `%3E` on the wire, so the
7433        // byte rides verbatim into the lacre's per-dep BLAKE3 closure
7434        // but is silently rewritten or rejected at libcurl's URL-
7435        // parser layer — two authors whose values differ only in
7436        // their redirect tail (`>build.log` vs nothing) resolve to
7437        // the byte-identical upstream `git clone` but lock to two
7438        // distinct lacres, defeating the THEORY.md §V.2 render-
7439        // determinism contract. Peer with the `:caminho` axis's
7440        // `FonteCaminhoShellRedirection` arm (e457141) on the sibling
7441        // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
7442        // byte RFC-3986-reserved set on `:entrada :paths`.
7443        let d = dep_with_fonte(DepSource::Git {
7444            repo: "https://github.com/pleme-io/caixa-teia>build.log".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/pleme-io/caixa-teia>build.log");
7455        assert!(
7456            reason.contains("must not contain `>`"),
7457            "reason must surface the output-redirection `>` arm, got {reason:?}"
7458        );
7459        assert!(
7460            reason.contains("redirection") || reason.contains("'delims'"),
7461            "reason must name the shell-redirection / RFC-3986-unwise rationale, got {reason:?}"
7462        );
7463    }
7464
7465    #[test]
7466    fn validate_rejects_git_fonte_with_repo_carrying_input_redirection() {
7467        // The symmetric shell-input-redirection footgun — an author
7468        // pastes a shell-pipeline head (`git clone <input.url` /
7469        // `cat <README.md`) into the `:repo` slot. Pinned separately
7470        // from the `>`-output arm so a future relaxation that only
7471        // catches one of the two redirect bytes surfaces here. Peer
7472        // with the `:caminho` axis's `FonteCaminhoShellRedirection`
7473        // arm which closes both `<` and `>` under the same banner.
7474        let d = dep_with_fonte(DepSource::Git {
7475            repo: "https://github.com/pleme-io/caixa-teia<input.url".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 input-redirection `<` arm, got {reason:?}"
7487        );
7488        assert!(
7489            reason.contains("RFC 3986") || reason.contains("'unwise'"),
7490            "reason must name the RFC 3986 'unwise' grammar, got {reason:?}"
7491        );
7492    }
7493
7494    #[test]
7495    fn validate_rejects_git_fonte_with_repo_carrying_backtick_command_substitution() {
7496        // The fail-before-pass-after pin for the canonical
7497        // paste-from-shell-prompt-with-backticked-substitution footgun
7498        // on `:repo` (peer with the c4d62b3 backtick arm on the sibling
7499        // `:caminho` path-fonte axis). An author pastes a URL whose
7500        // segment carries a backticked command-substitution wrapper
7501        // (`` `whoami` ``, `` `git config user.name` ``, `` `pwd` ``)
7502        // from a doc / README quick-start snippet that expected the
7503        // substrate to substitute the value downstream. Until this arm
7504        // landed the value silently passed every prior arm (no
7505        // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
7506        // no `\`, no `{`/`}`, no `<`/`>`, doesn't start with `-` or
7507        // `:`); RFC 3986 §2 lists the backtick byte in the 'delims' /
7508        // 'unwise' set and the WHATWG URL spec's fragment percent-
7509        // encode set maps `` ` `` → `%60` on the wire, so the byte
7510        // rides verbatim into the lacre's per-dep BLAKE3 closure but
7511        // is silently rewritten or rejected at libcurl's URL-parser
7512        // layer — two authors whose values differ only in their
7513        // backtick wrapper (`` `whoami` `` vs nothing) resolve to the
7514        // byte-identical upstream `git clone` but lock to two distinct
7515        // lacres, defeating the THEORY.md §V.2 render-determinism
7516        // contract. Peer with the `:caminho` axis's
7517        // `FonteCaminhoShellCommandSubstitution` arm (c4d62b3) on the
7518        // sibling path-fonte axis, and `is_gateway_api_http_path`'s
7519        // eleven-byte RFC-3986-reserved set on `:entrada :paths`.
7520        let d = dep_with_fonte(DepSource::Git {
7521            repo: "https://github.com/pleme-io/`whoami`/caixa-teia".into(),
7522            tag: Some("v0.1.0".into()),
7523            rev: None,
7524            branch: None,
7525        });
7526        let err = d.validate().unwrap_err();
7527        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7528            panic!("expected FonteRepoShape, got other variant");
7529        };
7530        assert_eq!(nome, "caixa-teia");
7531        assert_eq!(repo, "https://github.com/pleme-io/`whoami`/caixa-teia");
7532        assert!(
7533            reason.contains("must not contain `` ` ``"),
7534            "reason must surface the backtick command-substitution arm, got {reason:?}"
7535        );
7536        assert!(
7537            reason.contains("command-substitution") || reason.contains("'unwise'"),
7538            "reason must name the shell-command-substitution / RFC-3986-unwise rationale, \
7539             got {reason:?}"
7540        );
7541    }
7542
7543    #[test]
7544    fn fonte_repo_fragment_fires_before_backtick_when_fragment_first() {
7545        // Cascade pin: the fragment-`#` arm and the backtick command-
7546        // substitution arm are both per-byte arms inside the same
7547        // `for &b in s.as_bytes()` loop, so the byte that appears first
7548        // in the value's byte order wins. A `:repo
7549        // "https://github.com/p/x#readme/`whoami`"` carries both `#`
7550        // and backtick; the `#` byte appears first, so the fragment-
7551        // `#` arm fires, surfacing the more self-locating diagnostic
7552        // on the byte the author pasted earliest in the URL. Mirrors
7553        // the peer cascade discipline
7554        // `fonte_repo_fragment_fires_before_shell_redirection_when_fragment_first`
7555        // pins on the prior `:repo` byte-class arm.
7556        let d = dep_with_fonte(DepSource::Git {
7557            repo: "https://github.com/pleme-io/caixa-teia#readme/`whoami`".into(),
7558            tag: Some("v0.1.0".into()),
7559            rev: None,
7560            branch: None,
7561        });
7562        let err = d.validate().unwrap_err();
7563        let DepError::FonteRepoShape { reason, .. } = err else {
7564            panic!("expected FonteRepoShape, got other variant");
7565        };
7566        assert!(
7567            reason.contains("must not contain `#`"),
7568            "reason must surface the fragment-`#` arm (fires before backtick when `#` byte \
7569             appears first in value), got {reason:?}"
7570        );
7571    }
7572
7573    #[test]
7574    fn fonte_repo_shell_redirection_fires_before_backtick_when_redirection_first() {
7575        // Cascade pin: the shell-redirection `<` / `>` arm and the
7576        // backtick command-substitution arm are both per-byte arms
7577        // inside the same `for &b in s.as_bytes()` loop, so the byte
7578        // that appears first in the value's byte order wins. A `:repo
7579        // "https://github.com/p/x>build.log/`whoami`"` carries both
7580        // `>` and backtick; the `>` byte appears first, so the
7581        // shell-redirection arm fires, surfacing the more self-
7582        // locating diagnostic on the byte the author pasted earliest
7583        // in the URL. Pins the natural-order cascade so a future
7584        // reorder of the per-byte arms surfaces here.
7585        let d = dep_with_fonte(DepSource::Git {
7586            repo: "https://github.com/pleme-io/caixa-teia>build.log/`whoami`".into(),
7587            tag: Some("v0.1.0".into()),
7588            rev: None,
7589            branch: None,
7590        });
7591        let err = d.validate().unwrap_err();
7592        let DepError::FonteRepoShape { reason, .. } = err else {
7593            panic!("expected FonteRepoShape, got other variant");
7594        };
7595        assert!(
7596            reason.contains("must not contain `>`"),
7597            "reason must surface the shell-redirection `>` arm (fires before backtick when \
7598             `>` byte appears first in value), got {reason:?}"
7599        );
7600    }
7601
7602    #[test]
7603    fn fonte_repo_fragment_fires_before_shell_redirection_when_fragment_first() {
7604        // Cascade pin: the fragment-`#` arm and the shell-redirection
7605        // `<` / `>` arm are both per-byte arms inside the same
7606        // `for &b in s.as_bytes()` loop, so the byte that appears
7607        // first in the value's byte order wins. A `:repo
7608        // "https://github.com/p/x#readme>build.log"` carries both
7609        // `#` and `>`; the `#` byte appears first, so the fragment-
7610        // `#` arm fires, surfacing the more self-locating diagnostic
7611        // on the byte the author pasted earliest in the URL. Mirrors
7612        // the peer cascade discipline
7613        // `fonte_repo_fragment_fires_before_template_placeholder_when_fragment_first`
7614        // pins on the prior `:repo` byte-class arm.
7615        let d = dep_with_fonte(DepSource::Git {
7616            repo: "https://github.com/pleme-io/caixa-teia#readme>build.log".into(),
7617            tag: Some("v0.1.0".into()),
7618            rev: None,
7619            branch: None,
7620        });
7621        let err = d.validate().unwrap_err();
7622        let DepError::FonteRepoShape { reason, .. } = err else {
7623            panic!("expected FonteRepoShape, got other variant");
7624        };
7625        assert!(
7626            reason.contains("must not contain `#`"),
7627            "reason must surface the fragment-`#` arm (fires before shell-redirection `>` when \
7628             `#` byte appears first in value), got {reason:?}"
7629        );
7630    }
7631
7632    #[test]
7633    fn validate_rejects_git_fonte_with_repo_carrying_shell_pipe() {
7634        // The fail-before-pass-after pin for the canonical
7635        // paste-from-shell-prompt-with-piped-pipeline footgun on
7636        // `:repo` (peer with the 124106f pipe arm on the sibling
7637        // `:caminho` path-fonte axis). An author pastes a shell
7638        // pipeline (`git clone <url> | tee build.log`,
7639        // `git ls-remote <url> | head`) into the `:repo` slot,
7640        // forgetting to trim the `| <consumer>` tail. Until this arm
7641        // landed the value silently passed every prior arm (no
7642        // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
7643        // no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, doesn't start
7644        // with `-` or `:`); RFC 3986 §2 lists the pipe byte in the
7645        // 'unwise' set and the WHATWG URL spec's fragment percent-
7646        // encode set maps `|` → `%7C` on the wire, so the byte rides
7647        // verbatim into the lacre's per-dep BLAKE3 closure but is
7648        // silently rewritten or rejected at libcurl's URL-parser
7649        // layer — two authors whose values differ only in their pipe
7650        // tail (`|tee build.log` vs nothing) resolve to the byte-
7651        // identical upstream `git clone` but lock to two distinct
7652        // lacres, defeating the THEORY.md §V.2 render-determinism
7653        // contract. Peer with the `:caminho` axis's
7654        // `FonteCaminhoShellPipe` arm (124106f) on the sibling path-
7655        // fonte axis, and `is_gateway_api_http_path`'s eleven-byte
7656        // RFC-3986-reserved set on `:entrada :paths`.
7657        let d = dep_with_fonte(DepSource::Git {
7658            repo: "https://github.com/pleme-io/caixa-teia|tee build.log".into(),
7659            tag: Some("v0.1.0".into()),
7660            rev: None,
7661            branch: None,
7662        });
7663        let err = d.validate().unwrap_err();
7664        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7665            panic!("expected FonteRepoShape, got other variant");
7666        };
7667        assert_eq!(nome, "caixa-teia");
7668        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia|tee build.log");
7669        assert!(
7670            reason.contains("must not contain `|`"),
7671            "reason must surface the shell-pipe arm, got {reason:?}"
7672        );
7673        assert!(
7674            reason.contains("pipe") || reason.contains("'unwise'"),
7675            "reason must name the shell-pipe / RFC-3986-unwise rationale, got {reason:?}"
7676        );
7677    }
7678
7679    #[test]
7680    fn fonte_repo_fragment_fires_before_pipe_when_fragment_first() {
7681        // Cascade pin: the fragment-`#` arm and the pipe arm are both
7682        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
7683        // so the byte that appears first in the value's byte order
7684        // wins. A `:repo "https://github.com/p/x#readme|tee"` carries
7685        // both `#` and `|`; the `#` byte appears first, so the
7686        // fragment-`#` arm fires, surfacing the more self-locating
7687        // diagnostic on the byte the author pasted earliest in the
7688        // URL. Mirrors the peer cascade discipline
7689        // `fonte_repo_fragment_fires_before_backtick_when_fragment_first`
7690        // pins on the prior `:repo` byte-class arm.
7691        let d = dep_with_fonte(DepSource::Git {
7692            repo: "https://github.com/pleme-io/caixa-teia#readme|tee".into(),
7693            tag: Some("v0.1.0".into()),
7694            rev: None,
7695            branch: None,
7696        });
7697        let err = d.validate().unwrap_err();
7698        let DepError::FonteRepoShape { reason, .. } = err else {
7699            panic!("expected FonteRepoShape, got other variant");
7700        };
7701        assert!(
7702            reason.contains("must not contain `#`"),
7703            "reason must surface the fragment-`#` arm (fires before pipe when `#` byte \
7704             appears first in value), got {reason:?}"
7705        );
7706    }
7707
7708    #[test]
7709    fn fonte_repo_backtick_fires_before_pipe_when_backtick_first() {
7710        // Cascade pin: the backtick arm and the pipe arm are both per-
7711        // byte arms inside the same `for &b in s.as_bytes()` loop, so
7712        // the byte that appears first in the value's byte order wins.
7713        // A `:repo "https://github.com/p/x/`whoami`|tee"` carries both
7714        // `` ` `` and `|`; the backtick byte appears first, so the
7715        // backtick arm fires, surfacing the more self-locating
7716        // diagnostic on the byte the author pasted earliest in the
7717        // URL. Pins the natural-order cascade so a future reorder of
7718        // the per-byte arms surfaces here.
7719        let d = dep_with_fonte(DepSource::Git {
7720            repo: "https://github.com/pleme-io/caixa-teia/`whoami`|tee".into(),
7721            tag: Some("v0.1.0".into()),
7722            rev: None,
7723            branch: None,
7724        });
7725        let err = d.validate().unwrap_err();
7726        let DepError::FonteRepoShape { reason, .. } = err else {
7727            panic!("expected FonteRepoShape, got other variant");
7728        };
7729        assert!(
7730            reason.contains("must not contain `` ` ``"),
7731            "reason must surface the backtick arm (fires before pipe when `` ` `` byte \
7732             appears first in value), got {reason:?}"
7733        );
7734    }
7735
7736    #[test]
7737    fn validate_rejects_git_fonte_with_repo_carrying_shell_command_separator() {
7738        // The fail-before-pass-after pin for the canonical
7739        // paste-from-shell-prompt-with-sequential-command-tail footgun
7740        // on `:repo` (peer with the 05c358e `;` arm on the sibling
7741        // `:caminho` path-fonte axis). An author pastes a shell
7742        // one-liner that chained a cleanup tail after the URL
7743        // (`git clone <url>; rm -rf build`, `git ls-remote <url>;
7744        // echo done`) into the `:repo` slot, forgetting to trim the
7745        // `; <cmd>` tail. Until this arm landed the value silently
7746        // passed every prior `is_git_repo_url` arm (no whitespace, no
7747        // control chars, no non-ASCII, no `#`, no `?`, no `\`, no
7748        // `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, doesn't start with
7749        // `-` or `:`); RFC 3986 §2 lists `;` in the 'sub-delims' /
7750        // reserved set and the WHATWG URL spec's fragment percent-
7751        // encode set maps `;` → `%3B` on the wire, so the byte rides
7752        // verbatim into the lacre's per-dep BLAKE3 closure but is
7753        // silently rewritten at libcurl's URL-parser layer — two
7754        // authors whose values differ only in their sequential-command
7755        // tail (`; rm -rf build` vs nothing) resolve to the byte-
7756        // identical upstream `git clone` but lock to two distinct
7757        // lacres, defeating the THEORY.md §V.2 render-determinism
7758        // contract. Peer with the `:caminho` axis's
7759        // `FonteCaminhoShellSemicolon` arm (05c358e) on the sibling
7760        // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
7761        // byte RFC-3986-reserved set on `:entrada :paths`.
7762        let d = dep_with_fonte(DepSource::Git {
7763            repo: "https://github.com/pleme-io/caixa-teia; rm -rf build".into(),
7764            tag: Some("v0.1.0".into()),
7765            rev: None,
7766            branch: None,
7767        });
7768        let err = d.validate().unwrap_err();
7769        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7770            panic!("expected FonteRepoShape, got other variant");
7771        };
7772        assert_eq!(nome, "caixa-teia");
7773        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia; rm -rf build");
7774        assert!(
7775            reason.contains("must not contain `;`"),
7776            "reason must surface the shell-command-separator arm, got {reason:?}"
7777        );
7778        assert!(
7779            reason.contains("sequential-command") || reason.contains("'sub-delims'"),
7780            "reason must name the shell-command-separator / RFC-3986-sub-delims \
7781             rationale, got {reason:?}"
7782        );
7783    }
7784
7785    #[test]
7786    fn fonte_repo_fragment_fires_before_semicolon_when_fragment_first() {
7787        // Cascade pin: the fragment-`#` arm and the semicolon arm are
7788        // both per-byte arms inside the same `for &b in s.as_bytes()`
7789        // loop, so the byte that appears first in the value's byte
7790        // order wins. A `:repo "https://github.com/p/x#readme; rm"`
7791        // carries both `#` and `;`; the `#` byte appears first, so the
7792        // fragment-`#` arm fires, surfacing the more self-locating
7793        // diagnostic on the byte the author pasted earliest in the URL.
7794        // Mirrors the peer cascade discipline
7795        // `fonte_repo_fragment_fires_before_pipe_when_fragment_first`
7796        // pins on the prior `:repo` byte-class arm.
7797        let d = dep_with_fonte(DepSource::Git {
7798            repo: "https://github.com/pleme-io/caixa-teia#readme; rm".into(),
7799            tag: Some("v0.1.0".into()),
7800            rev: None,
7801            branch: None,
7802        });
7803        let err = d.validate().unwrap_err();
7804        let DepError::FonteRepoShape { reason, .. } = err else {
7805            panic!("expected FonteRepoShape, got other variant");
7806        };
7807        assert!(
7808            reason.contains("must not contain `#`"),
7809            "reason must surface the fragment-`#` arm (fires before semicolon when `#` \
7810             byte appears first in value), got {reason:?}"
7811        );
7812    }
7813
7814    #[test]
7815    fn fonte_repo_pipe_fires_before_semicolon_when_pipe_first() {
7816        // Cascade pin: the pipe arm and the semicolon arm are both
7817        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
7818        // so the byte that appears first in the value's byte order
7819        // wins. A `:repo "https://github.com/p/x|tee; rm"` carries
7820        // both `|` and `;`; the `|` byte appears first, so the
7821        // pipe arm fires, surfacing the more self-locating diagnostic
7822        // on the byte the author pasted earliest in the URL. Pins the
7823        // natural-order cascade so a future reorder of the per-byte
7824        // arms surfaces here.
7825        let d = dep_with_fonte(DepSource::Git {
7826            repo: "https://github.com/pleme-io/caixa-teia|tee; rm".into(),
7827            tag: Some("v0.1.0".into()),
7828            rev: None,
7829            branch: None,
7830        });
7831        let err = d.validate().unwrap_err();
7832        let DepError::FonteRepoShape { reason, .. } = err else {
7833            panic!("expected FonteRepoShape, got other variant");
7834        };
7835        assert!(
7836            reason.contains("must not contain `|`"),
7837            "reason must surface the pipe arm (fires before semicolon when `|` byte \
7838             appears first in value), got {reason:?}"
7839        );
7840    }
7841
7842    #[test]
7843    fn validate_rejects_git_fonte_with_repo_carrying_shell_background() {
7844        // The fail-before-pass-after pin for the canonical
7845        // paste-from-shell-prompt-with-background-launch-tail footgun
7846        // on `:repo` (peer with the e12e4f3 `&` arm on the sibling
7847        // `:caminho` path-fonte axis). An author pastes a shell one-
7848        // liner that detached the clone into the background
7849        // (`git clone <url> & sleep 1`, `git clone <url> && cd …`)
7850        // into the `:repo` slot, forgetting to trim the `& <cmd>` /
7851        // `&& <cmd>` tail. Until this arm landed the value silently
7852        // passed every prior `is_git_repo_url` arm (no whitespace,
7853        // no control chars, no non-ASCII, no `#`, no `?`, no `\`,
7854        // no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no `;`,
7855        // doesn't start with `-` or `:`); RFC 3986 §2 lists `&` in
7856        // the 'sub-delims' / reserved set and the WHATWG URL spec's
7857        // fragment percent-encode set maps `&` → `%26` on the wire,
7858        // so the byte rides verbatim into the lacre's per-dep
7859        // BLAKE3 closure but is silently rewritten at libcurl's
7860        // URL-parser layer — two authors whose values differ only
7861        // in their background-launch tail (`& sleep 1` vs nothing)
7862        // resolve to the byte-identical upstream `git clone` but
7863        // lock to two distinct lacres, defeating the THEORY.md
7864        // §V.2 render-determinism contract. Peer with the
7865        // `:caminho` axis's `FonteCaminhoShellBackground` arm
7866        // (e12e4f3) on the sibling path-fonte axis, and
7867        // `is_gateway_api_http_path`'s eleven-byte RFC-3986-
7868        // reserved set on `:entrada :paths`.
7869        let d = dep_with_fonte(DepSource::Git {
7870            repo: "https://github.com/pleme-io/caixa-teia&sleep".into(),
7871            tag: Some("v0.1.0".into()),
7872            rev: None,
7873            branch: None,
7874        });
7875        let err = d.validate().unwrap_err();
7876        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7877            panic!("expected FonteRepoShape, got other variant");
7878        };
7879        assert_eq!(nome, "caixa-teia");
7880        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia&sleep");
7881        assert!(
7882            reason.contains("must not contain `&`"),
7883            "reason must surface the shell-background / logical-AND arm, got {reason:?}"
7884        );
7885        assert!(
7886            reason.contains("background-task") || reason.contains("'sub-delims'"),
7887            "reason must name the shell-background / RFC-3986-sub-delims rationale, \
7888             got {reason:?}"
7889        );
7890    }
7891
7892    #[test]
7893    fn validate_rejects_git_fonte_with_repo_carrying_logical_and() {
7894        // The fail-before-pass-after pin for the symmetric `&&`
7895        // logical-AND build-chain paste footgun: an author pastes
7896        // a `git clone <url> && cd <repo>` build-chain one-liner
7897        // and forgets to trim the `&& <cmd>` tail. The `&&` shape
7898        // is the same `&` byte twice in a row; the per-byte arm
7899        // fires on the first `&` it sees. Pinned separately from
7900        // the single-`&` background-launch shape so a future
7901        // diagnostic-surface change that special-cased the
7902        // doubled-byte form surfaces here.
7903        let d = dep_with_fonte(DepSource::Git {
7904            repo: "github:pleme-io/caixa-teia&&echo".into(),
7905            tag: Some("v0.1.0".into()),
7906            rev: None,
7907            branch: None,
7908        });
7909        let err = d.validate().unwrap_err();
7910        let DepError::FonteRepoShape { reason, .. } = err else {
7911            panic!("expected FonteRepoShape, got other variant");
7912        };
7913        assert!(
7914            reason.contains("must not contain `&`"),
7915            "reason must surface the shell-background / logical-AND arm on the doubled-`&&` \
7916             shape too, got {reason:?}"
7917        );
7918    }
7919
7920    #[test]
7921    fn fonte_repo_fragment_fires_before_background_when_fragment_first() {
7922        // Cascade pin: the fragment-`#` arm and the background-`&`
7923        // arm are both per-byte arms inside the same `for &b in
7924        // s.as_bytes()` loop, so the byte that appears first in the
7925        // value's byte order wins. A `:repo
7926        // "https://github.com/p/x#readme & sleep"` carries both `#`
7927        // and `&`; the `#` byte appears first, so the fragment-`#`
7928        // arm fires, surfacing the more self-locating diagnostic on
7929        // the byte the author pasted earliest in the URL. Mirrors
7930        // the peer cascade discipline
7931        // `fonte_repo_fragment_fires_before_semicolon_when_fragment_first`
7932        // on the prior `:repo` byte-class arm.
7933        let d = dep_with_fonte(DepSource::Git {
7934            repo: "https://github.com/pleme-io/caixa-teia#readme&sleep".into(),
7935            tag: Some("v0.1.0".into()),
7936            rev: None,
7937            branch: None,
7938        });
7939        let err = d.validate().unwrap_err();
7940        let DepError::FonteRepoShape { reason, .. } = err else {
7941            panic!("expected FonteRepoShape, got other variant");
7942        };
7943        assert!(
7944            reason.contains("must not contain `#`"),
7945            "reason must surface the fragment-`#` arm (fires before background-`&` when `#` \
7946             byte appears first in value), got {reason:?}"
7947        );
7948    }
7949
7950    #[test]
7951    fn fonte_repo_semicolon_fires_before_background_when_semicolon_first() {
7952        // Cascade pin: the semicolon arm and the background-`&` arm
7953        // are both per-byte arms inside the same `for &b in
7954        // s.as_bytes()` loop, so the byte that appears first in the
7955        // value's byte order wins. A `:repo
7956        // "https://github.com/p/x; rm & sleep"` carries both `;` and
7957        // `&`; the `;` byte appears first, so the semicolon arm
7958        // fires, surfacing the more self-locating diagnostic on the
7959        // byte the author pasted earliest in the URL. Pins the
7960        // natural-order cascade so a future reorder of the per-byte
7961        // arms surfaces here.
7962        let d = dep_with_fonte(DepSource::Git {
7963            repo: "https://github.com/pleme-io/caixa-teia;rm&sleep".into(),
7964            tag: Some("v0.1.0".into()),
7965            rev: None,
7966            branch: None,
7967        });
7968        let err = d.validate().unwrap_err();
7969        let DepError::FonteRepoShape { reason, .. } = err else {
7970            panic!("expected FonteRepoShape, got other variant");
7971        };
7972        assert!(
7973            reason.contains("must not contain `;`"),
7974            "reason must surface the semicolon arm (fires before background-`&` when `;` \
7975             byte appears first in value), got {reason:?}"
7976        );
7977    }
7978
7979    #[test]
7980    fn validate_rejects_git_fonte_with_repo_carrying_shell_variable_expansion() {
7981        // The fail-before-pass-after pin for the canonical
7982        // paste-from-shell-prompt-with-unsubstituted-variable footgun
7983        // on `:repo` (peer with the f4efe9c `$` arm on the sibling
7984        // `:caminho` path-fonte axis). An author pastes a shell one-
7985        // liner that referenced an environment variable
7986        // (`git clone https://github.com/$ORG/x`, `git clone
7987        // github:$USER/repo`) into the `:repo` slot, forgetting to
7988        // substitute the literal value at author time. Until this arm
7989        // landed the value silently passed every prior
7990        // `is_git_repo_url` arm (no whitespace, no control chars, no
7991        // non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no `<`/`>`,
7992        // no `` ` ``, no `|`, no `;`, no `&`, doesn't start with `-`
7993        // or `:`); RFC 3986 §2 lists `$` in the 'sub-delims' /
7994        // reserved set and the WHATWG URL spec's fragment percent-
7995        // encode set maps `$` → `%24` on the wire, so the byte rides
7996        // verbatim into the lacre's per-dep BLAKE3 closure but is
7997        // silently rewritten at libcurl's URL-parser layer — two
7998        // authors whose values differ only in their `$VAR` /
7999        // `${VAR}` / `$(cmd)` expansion tail resolve to the byte-
8000        // identical upstream `git clone` but lock to two distinct
8001        // lacres, defeating the THEORY.md §V.2 render-determinism
8002        // contract. Beyond determinism, the value is a structural
8003        // host-layout leak: two authors with the same `:repo` slot
8004        // but different `$ORG` / `$HOME` / `$WORKSPACE` resolve
8005        // different upstreams. Peer with the `:caminho` axis's
8006        // `FonteCaminhoVarExpansion` arm (f4efe9c) on the sibling
8007        // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
8008        // byte RFC-3986-reserved set on `:entrada :paths`.
8009        let d = dep_with_fonte(DepSource::Git {
8010            repo: "https://github.com/$ORG/caixa-teia".into(),
8011            tag: Some("v0.1.0".into()),
8012            rev: None,
8013            branch: None,
8014        });
8015        let err = d.validate().unwrap_err();
8016        let DepError::FonteRepoShape { nome, repo, reason } = err else {
8017            panic!("expected FonteRepoShape, got other variant");
8018        };
8019        assert_eq!(nome, "caixa-teia");
8020        assert_eq!(repo, "https://github.com/$ORG/caixa-teia");
8021        assert!(
8022            reason.contains("must not contain `$`"),
8023            "reason must surface the shell-variable-expansion arm, got {reason:?}"
8024        );
8025        assert!(
8026            reason.contains("variable-expansion") || reason.contains("'sub-delims'"),
8027            "reason must name the shell-variable-expansion / RFC-3986-sub-delims \
8028             rationale, got {reason:?}"
8029        );
8030    }
8031
8032    #[test]
8033    fn validate_rejects_git_fonte_with_repo_carrying_braced_variable_expansion() {
8034        // The fail-before-pass-after pin for the symmetric POSIX-
8035        // shell braced `${VAR}` expansion paste footgun: an author
8036        // pastes a CI-manifest line `git clone
8037        // https://github.com/${WORKSPACE}/x` (the canonical GitHub
8038        // Actions / GitLab CI / Drone shape) and forgets to
8039        // substitute the literal value. The `${...}` shape is the
8040        // same `$` byte at the leading position of the expansion;
8041        // the per-byte arm fires on the `$`. Pinned separately from
8042        // the bare-`$VAR` shape so a future diagnostic-surface
8043        // change that special-cased the braced form surfaces here.
8044        let d = dep_with_fonte(DepSource::Git {
8045            repo: "https://github.com/${WORKSPACE}/caixa-teia".into(),
8046            tag: Some("v0.1.0".into()),
8047            rev: None,
8048            branch: None,
8049        });
8050        let err = d.validate().unwrap_err();
8051        let DepError::FonteRepoShape { reason, .. } = err else {
8052            panic!("expected FonteRepoShape, got other variant");
8053        };
8054        assert!(
8055            reason.contains("must not contain `$`"),
8056            "reason must surface the shell-variable-expansion arm on the braced `${{...}}` \
8057             shape too, got {reason:?}"
8058        );
8059    }
8060
8061    #[test]
8062    fn fonte_repo_fragment_fires_before_var_expansion_when_fragment_first() {
8063        // Cascade pin: the fragment-`#` arm and the var-expansion-`$`
8064        // arm are both per-byte arms inside the same `for &b in
8065        // s.as_bytes()` loop, so the byte that appears first in the
8066        // value's byte order wins. A `:repo
8067        // "https://github.com/p/x#readme$HOME"` carries both `#` and
8068        // `$`; the `#` byte appears first, so the fragment-`#` arm
8069        // fires, surfacing the more self-locating diagnostic on the
8070        // byte the author pasted earliest in the URL. Mirrors the
8071        // peer cascade discipline
8072        // `fonte_repo_fragment_fires_before_background_when_fragment_first`
8073        // on the prior `:repo` byte-class arm.
8074        let d = dep_with_fonte(DepSource::Git {
8075            repo: "https://github.com/pleme-io/caixa-teia#readme$HOME".into(),
8076            tag: Some("v0.1.0".into()),
8077            rev: None,
8078            branch: None,
8079        });
8080        let err = d.validate().unwrap_err();
8081        let DepError::FonteRepoShape { reason, .. } = err else {
8082            panic!("expected FonteRepoShape, got other variant");
8083        };
8084        assert!(
8085            reason.contains("must not contain `#`"),
8086            "reason must surface the fragment-`#` arm (fires before var-expansion-`$` when \
8087             `#` byte appears first in value), got {reason:?}"
8088        );
8089    }
8090
8091    #[test]
8092    fn fonte_repo_background_fires_before_var_expansion_when_background_first() {
8093        // Cascade pin: the background-`&` arm and the
8094        // var-expansion-`$` arm are both per-byte arms inside the
8095        // same `for &b in s.as_bytes()` loop, so the byte that
8096        // appears first in the value's byte order wins. A `:repo
8097        // "https://github.com/p/x&sleep$HOME"` carries both `&` and
8098        // `$`; the `&` byte appears first, so the background arm
8099        // fires, surfacing the more self-locating diagnostic on the
8100        // byte the author pasted earliest in the URL. Pins the
8101        // natural-order cascade so a future reorder of the per-byte
8102        // arms surfaces here — `$` is the most recent byte-class arm,
8103        // so the cascade-pin sweep extends to cover every immediately
8104        // prior byte arm (`#`, `&`) firing first when ordered ahead
8105        // of `$` in the value.
8106        let d = dep_with_fonte(DepSource::Git {
8107            repo: "https://github.com/pleme-io/caixa-teia&sleep$HOME".into(),
8108            tag: Some("v0.1.0".into()),
8109            rev: None,
8110            branch: None,
8111        });
8112        let err = d.validate().unwrap_err();
8113        let DepError::FonteRepoShape { reason, .. } = err else {
8114            panic!("expected FonteRepoShape, got other variant");
8115        };
8116        assert!(
8117            reason.contains("must not contain `&`"),
8118            "reason must surface the background-`&` arm (fires before var-expansion-`$` when \
8119             `&` byte appears first in value), got {reason:?}"
8120        );
8121    }
8122
8123    #[test]
8124    fn validate_rejects_git_fonte_with_repo_carrying_shell_glob_wildcard() {
8125        // The fail-before-pass-after pin for the canonical
8126        // paste-from-shell-prompt glob footgun on `:repo` (peer with
8127        // the cf9034b `*` / `?` arm on the sibling `:caminho`
8128        // path-fonte axis). An author pastes a shell one-liner that
8129        // referenced a glob expansion (`ls
8130        // github.com/pleme-io/caixa-*`, `git clone
8131        // github:pleme-io/caixa-*`) into the `:repo` slot, forgetting
8132        // to substitute the literal repo name. Until this arm landed
8133        // the `*` byte silently passed every prior `is_git_repo_url`
8134        // arm (no whitespace, no control chars, no non-ASCII, no `#`,
8135        // no `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`,
8136        // no `;`, no `&`, no `$`, doesn't start with `-` or `:`); RFC
8137        // 3986 §2 lists `*` in the 'sub-delims' / reserved set and
8138        // the WHATWG URL spec's special-query percent-encode set maps
8139        // `*` → `%2A` on the wire, so the byte rides verbatim into
8140        // the lacre's per-dep BLAKE3 closure but is silently
8141        // rewritten at libcurl's URL-parser layer — two authors
8142        // whose values differ only in their asterisk presence
8143        // resolve to the byte-identical upstream `git clone` but
8144        // lock to two distinct lacres, defeating the THEORY.md §V.2
8145        // render-determinism contract. Peer with the `:caminho`
8146        // axis's `FonteCaminhoShellGlob` arm (cf9034b) on the
8147        // sibling path-fonte axis, and the `is_git_ref_name`
8148        // refspec-wildcard cascade on the `:fonte :tag` / `:branch`
8149        // axes.
8150        let d = dep_with_fonte(DepSource::Git {
8151            repo: "https://github.com/pleme-io/caixa-*".into(),
8152            tag: Some("v0.1.0".into()),
8153            rev: None,
8154            branch: None,
8155        });
8156        let err = d.validate().unwrap_err();
8157        let DepError::FonteRepoShape { nome, repo, reason } = err else {
8158            panic!("expected FonteRepoShape, got other variant");
8159        };
8160        assert_eq!(nome, "caixa-teia");
8161        assert_eq!(repo, "https://github.com/pleme-io/caixa-*");
8162        assert!(
8163            reason.contains("must not contain `*`"),
8164            "reason must surface the shell-glob arm, got {reason:?}"
8165        );
8166        assert!(
8167            reason.contains("pathname-expansion") || reason.contains("'sub-delims'"),
8168            "reason must name the shell-glob / pathname-expansion / \
8169             RFC-3986-sub-delims rationale, got {reason:?}"
8170        );
8171    }
8172
8173    #[test]
8174    fn validate_rejects_git_fonte_with_repo_carrying_recursive_shell_glob() {
8175        // The fail-before-pass-after pin for the symmetric bash
8176        // `globstar` recursive-glob paste footgun: an author pastes
8177        // a `ls github.com/pleme-io/**/x` (the canonical
8178        // `globstar`-shopt-enabled recursive-listing tail) into the
8179        // `:repo` slot. The `**` shape is two `*` bytes adjacent;
8180        // the per-byte arm fires on the first `*`. Pinned
8181        // separately from the single-`*` shape so a future
8182        // diagnostic-surface change that special-cased the
8183        // double-`*` form surfaces here.
8184        let d = dep_with_fonte(DepSource::Git {
8185            repo: "https://github.com/pleme-io/**/caixa-teia".into(),
8186            tag: Some("v0.1.0".into()),
8187            rev: None,
8188            branch: None,
8189        });
8190        let err = d.validate().unwrap_err();
8191        let DepError::FonteRepoShape { reason, .. } = err else {
8192            panic!("expected FonteRepoShape, got other variant");
8193        };
8194        assert!(
8195            reason.contains("must not contain `*`"),
8196            "reason must surface the shell-glob arm on the `**` recursive-glob shape too, \
8197             got {reason:?}"
8198        );
8199    }
8200
8201    #[test]
8202    fn fonte_repo_fragment_fires_before_glob_when_fragment_first() {
8203        // Cascade pin: the fragment-`#` arm and the glob-`*` arm are
8204        // both per-byte arms inside the same `for &b in s.as_bytes()`
8205        // loop, so the byte that appears first in the value's byte
8206        // order wins. A `:repo
8207        // "https://github.com/p/x#readme*tail"` carries both `#` and
8208        // `*`; the `#` byte appears first, so the fragment-`#` arm
8209        // fires, surfacing the more self-locating diagnostic on the
8210        // byte the author pasted earliest in the URL. Mirrors the
8211        // peer cascade discipline
8212        // `fonte_repo_fragment_fires_before_var_expansion_when_fragment_first`
8213        // on the prior `:repo` byte-class arm.
8214        let d = dep_with_fonte(DepSource::Git {
8215            repo: "https://github.com/pleme-io/caixa-teia#readme*tail".into(),
8216            tag: Some("v0.1.0".into()),
8217            rev: None,
8218            branch: None,
8219        });
8220        let err = d.validate().unwrap_err();
8221        let DepError::FonteRepoShape { reason, .. } = err else {
8222            panic!("expected FonteRepoShape, got other variant");
8223        };
8224        assert!(
8225            reason.contains("must not contain `#`"),
8226            "reason must surface the fragment-`#` arm (fires before glob-`*` when `#` byte \
8227             appears first in value), got {reason:?}"
8228        );
8229    }
8230
8231    #[test]
8232    fn fonte_repo_var_expansion_fires_before_glob_when_var_expansion_first() {
8233        // Cascade pin: the var-expansion-`$` arm and the glob-`*`
8234        // arm are both per-byte arms inside the same `for &b in
8235        // s.as_bytes()` loop, so the byte that appears first in the
8236        // value's byte order wins. A `:repo
8237        // "https://github.com/p/$ORG-*"` carries both `$` and `*`;
8238        // the `$` byte appears first, so the var-expansion arm
8239        // fires, surfacing the more self-locating diagnostic on the
8240        // byte the author pasted earliest in the URL. Pins the
8241        // natural-order cascade so a future reorder of the per-byte
8242        // arms surfaces here — `*` is the most recent byte-class
8243        // arm, so the cascade-pin sweep extends to cover the
8244        // immediately prior `$` byte arm firing first when ordered
8245        // ahead of `*` in the value.
8246        let d = dep_with_fonte(DepSource::Git {
8247            repo: "https://github.com/pleme-io/$ORG-caixa-*".into(),
8248            tag: Some("v0.1.0".into()),
8249            rev: None,
8250            branch: None,
8251        });
8252        let err = d.validate().unwrap_err();
8253        let DepError::FonteRepoShape { reason, .. } = err else {
8254            panic!("expected FonteRepoShape, got other variant");
8255        };
8256        assert!(
8257            reason.contains("must not contain `$`"),
8258            "reason must surface the var-expansion-`$` arm (fires before glob-`*` when `$` \
8259             byte appears first in value), got {reason:?}"
8260        );
8261    }
8262
8263    #[test]
8264    fn validate_rejects_git_fonte_with_repo_carrying_subshell_open_paren() {
8265        // The fail-before-pass-after pin for the canonical paste-from-
8266        // shell-prompt subshell-grouping footgun on `:repo`. An author
8267        // pastes a doc / README snippet carrying a regex-alternation
8268        // grouping shape (`https://github.com/(foo|bar)/repo`) or a
8269        // dynamic-config-substitution wrapper (`$(<cmd>)`) into the
8270        // `:repo` slot, forgetting to substitute one literal org name.
8271        // Until this arm landed the `(` byte silently passed every
8272        // prior `is_git_repo_url` arm (no whitespace, no control
8273        // chars, no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no
8274        // `<`/`>`, no `` ` ``, no `|`, no `;`, no `&`, no `$`, no
8275        // `*`, doesn't start with `-` or `:`); RFC 3986 §2 lists `(`
8276        // / `)` in the 'sub-delims' / reserved set, and the WHATWG
8277        // URL spec's special-query percent-encode set maps `(` →
8278        // `%28` and `)` → `%29` on the wire, so the byte rides
8279        // verbatim into the lacre's per-dep BLAKE3 closure but is
8280        // silently rewritten at libcurl's URL-parser layer —
8281        // defeating the THEORY.md §V.2 render-determinism contract on
8282        // the same axis the prior twelve byte-class arms close.
8283        let d = dep_with_fonte(DepSource::Git {
8284            repo: "https://github.com/(foo|bar)/caixa-teia".into(),
8285            tag: Some("v0.1.0".into()),
8286            rev: None,
8287            branch: None,
8288        });
8289        let err = d.validate().unwrap_err();
8290        let DepError::FonteRepoShape { nome, repo, reason } = err else {
8291            panic!("expected FonteRepoShape, got other variant");
8292        };
8293        assert_eq!(nome, "caixa-teia");
8294        assert_eq!(repo, "https://github.com/(foo|bar)/caixa-teia");
8295        assert!(
8296            reason.contains("must not contain `(`"),
8297            "reason must surface the subshell-open-paren arm, got {reason:?}"
8298        );
8299        assert!(
8300            reason.contains("subshell-grouping") || reason.contains("'sub-delims'"),
8301            "reason must name the shell-subshell-grouping / RFC-3986-sub-delims rationale, \
8302             got {reason:?}"
8303        );
8304    }
8305
8306    #[test]
8307    fn validate_rejects_git_fonte_with_repo_carrying_subshell_close_paren() {
8308        // The symmetric arm pin on the closing `)` byte: an author
8309        // pastes a `$(date)` command-substitution wrapper or a
8310        // regex-alternation `(foo|bar)` tail into the `:repo` slot.
8311        // Pinned separately from the opening `(` shape so a future
8312        // diagnostic-surface change that only checked one boundary
8313        // surfaces here. The `(` byte appears earlier in the
8314        // canonical regex / subshell wrapper so the per-byte loop
8315        // fires on `(` first; this test exercises a `:repo` value
8316        // carrying only the closing `)` byte (no opening paren) so
8317        // the `)` arm fires directly — pinning the byte-class arm
8318        // independent of order.
8319        let d = dep_with_fonte(DepSource::Git {
8320            repo: "github:pleme-io/caixa-teia)tail".into(),
8321            tag: Some("v0.1.0".into()),
8322            rev: None,
8323            branch: None,
8324        });
8325        let err = d.validate().unwrap_err();
8326        let DepError::FonteRepoShape { reason, .. } = err else {
8327            panic!("expected FonteRepoShape, got other variant");
8328        };
8329        assert!(
8330            reason.contains("must not contain `)`"),
8331            "reason must surface the subshell-close-paren arm on the bare `)` shape, \
8332             got {reason:?}"
8333        );
8334    }
8335
8336    #[test]
8337    fn fonte_repo_fragment_fires_before_subshell_when_fragment_first() {
8338        // Cascade pin: the fragment-`#` arm and the subshell-`(` arm
8339        // are both per-byte arms inside the same `for &b in
8340        // s.as_bytes()` loop, so the byte that appears first in the
8341        // value's byte order wins. A `:repo
8342        // "https://github.com/p/x#readme(tail)"` carries both `#` and
8343        // `(`; the `#` byte appears first, so the fragment-`#` arm
8344        // fires, surfacing the more self-locating diagnostic on the
8345        // byte the author pasted earliest in the URL. Mirrors the
8346        // peer cascade discipline
8347        // `fonte_repo_fragment_fires_before_glob_when_fragment_first`
8348        // on the prior `:repo` byte-class arm.
8349        let d = dep_with_fonte(DepSource::Git {
8350            repo: "https://github.com/pleme-io/caixa-teia#readme(tail)".into(),
8351            tag: Some("v0.1.0".into()),
8352            rev: None,
8353            branch: None,
8354        });
8355        let err = d.validate().unwrap_err();
8356        let DepError::FonteRepoShape { reason, .. } = err else {
8357            panic!("expected FonteRepoShape, got other variant");
8358        };
8359        assert!(
8360            reason.contains("must not contain `#`"),
8361            "reason must surface the fragment-`#` arm (fires before subshell-`(` when `#` \
8362             byte appears first in value), got {reason:?}"
8363        );
8364    }
8365
8366    #[test]
8367    fn fonte_repo_glob_fires_before_subshell_when_glob_first() {
8368        // Cascade pin: the glob-`*` arm (the immediate-predecessor
8369        // byte-class arm, 3902a9a) and the subshell-`(` arm are both
8370        // per-byte arms inside the same `for &b in s.as_bytes()`
8371        // loop, so the byte that appears first in the value's byte
8372        // order wins. A `:repo
8373        // "https://github.com/p/x-*-(date)"` carries both `*` and
8374        // `(`; the `*` byte appears first, so the glob arm fires,
8375        // surfacing the more self-locating diagnostic on the byte
8376        // the author pasted earliest in the URL. Pins the natural-
8377        // order cascade so a future reorder of the per-byte arms
8378        // surfaces here — `(` is the most recent byte-class arm,
8379        // so the cascade-pin sweep extends to cover the immediately
8380        // prior `*` byte arm firing first when ordered ahead of `(`
8381        // in the value.
8382        let d = dep_with_fonte(DepSource::Git {
8383            repo: "https://github.com/pleme-io/caixa-teia-*-(date)".into(),
8384            tag: Some("v0.1.0".into()),
8385            rev: None,
8386            branch: None,
8387        });
8388        let err = d.validate().unwrap_err();
8389        let DepError::FonteRepoShape { reason, .. } = err else {
8390            panic!("expected FonteRepoShape, got other variant");
8391        };
8392        assert!(
8393            reason.contains("must not contain `*`"),
8394            "reason must surface the glob-`*` arm (fires before subshell-`(` when `*` byte \
8395             appears first in value), got {reason:?}"
8396        );
8397    }
8398
8399    #[test]
8400    fn validate_rejects_git_fonte_with_repo_carrying_shell_double_quote() {
8401        // The fail-before-pass-after pin for the canonical paste-from-
8402        // doc-shell-quoting footgun on `:repo`. An author copies a
8403        // README quick-start snippet (`$ git clone "https://github.com/
8404        // foo/bar"`) and keeps the surrounding double-quote bytes when
8405        // pasting into the `:repo` slot — the doc wraps the URL in
8406        // double quotes so the shell doesn't re-lex metachars inside,
8407        // but the typed slot is itself a byte-level string parser, not
8408        // a shell context, so the quote bytes ride into the value
8409        // verbatim. Until this arm landed the `"` byte silently passed
8410        // every prior `is_git_repo_url` arm (no whitespace, no control
8411        // chars, no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no
8412        // `<`/`>`, no `` ` ``, no `|`, no `;`, no `&`, no `$`, no `*`,
8413        // no `(`/`)`, doesn't start with `-` or `:`); RFC 3986 §2 lists
8414        // `"` in the strict four-byte 'delims' subset (with `<`, `>`,
8415        // `` ` ``) every URL parser is required to refuse or percent-
8416        // encode, and the WHATWG URL spec's 'C0 control percent-encode
8417        // set' maps `"` → `%22` on the wire, so the byte rides verbatim
8418        // into the lacre's per-dep BLAKE3 closure but is silently
8419        // rewritten at libcurl's URL-parser layer, defeating the
8420        // THEORY.md §V.2 render-determinism contract.
8421        let d = dep_with_fonte(DepSource::Git {
8422            repo: "\"https://github.com/pleme-io/caixa-teia\"".into(),
8423            tag: Some("v0.1.0".into()),
8424            rev: None,
8425            branch: None,
8426        });
8427        let err = d.validate().unwrap_err();
8428        let DepError::FonteRepoShape { nome, repo, reason } = err else {
8429            panic!("expected FonteRepoShape, got other variant");
8430        };
8431        assert_eq!(nome, "caixa-teia");
8432        assert_eq!(repo, "\"https://github.com/pleme-io/caixa-teia\"");
8433        assert!(
8434            reason.contains("must not contain `\"`"),
8435            "reason must surface the shell-double-quote arm, got {reason:?}"
8436        );
8437        assert!(
8438            reason.contains("double-quote") || reason.contains("'delims'"),
8439            "reason must name the shell-double-quote / RFC-3986-delims rationale, \
8440             got {reason:?}"
8441        );
8442    }
8443
8444    #[test]
8445    fn validate_rejects_git_fonte_with_repo_carrying_stray_trailing_double_quote() {
8446        // The symmetric stray-quote tail pin: an author pastes only a
8447        // closing `"` from a shell-history line like `git clone
8448        // "https://github.com/foo/bar" && cd …` (the trim went too
8449        // far in one direction but not the other) into the `:repo`
8450        // slot. Pinned separately from the wrapped-quote shape so a
8451        // future diagnostic-surface change that only checked one
8452        // boundary (only leading, only trailing, only paired) surfaces
8453        // here — the per-byte arm fires anywhere `"` appears.
8454        let d = dep_with_fonte(DepSource::Git {
8455            repo: "github:pleme-io/caixa-teia\"".into(),
8456            tag: Some("v0.1.0".into()),
8457            rev: None,
8458            branch: None,
8459        });
8460        let err = d.validate().unwrap_err();
8461        let DepError::FonteRepoShape { reason, .. } = err else {
8462            panic!("expected FonteRepoShape, got other variant");
8463        };
8464        assert!(
8465            reason.contains("must not contain `\"`"),
8466            "reason must surface the shell-double-quote arm on the trailing-`\"` shape, \
8467             got {reason:?}"
8468        );
8469    }
8470
8471    #[test]
8472    fn fonte_repo_fragment_fires_before_double_quote_when_fragment_first() {
8473        // Cascade pin: the fragment-`#` arm and the double-quote arm
8474        // are both per-byte arms inside the same `for &b in
8475        // s.as_bytes()` loop, so the byte that appears first in the
8476        // value's byte order wins. A `:repo
8477        // "https://github.com/p/x#readme\"tail"` carries both `#` and
8478        // `"`; the `#` byte appears first, so the fragment-`#` arm
8479        // fires, surfacing the more self-locating diagnostic on the
8480        // byte the author pasted earliest in the URL.
8481        let d = dep_with_fonte(DepSource::Git {
8482            repo: "https://github.com/pleme-io/caixa-teia#readme\"tail".into(),
8483            tag: Some("v0.1.0".into()),
8484            rev: None,
8485            branch: None,
8486        });
8487        let err = d.validate().unwrap_err();
8488        let DepError::FonteRepoShape { reason, .. } = err else {
8489            panic!("expected FonteRepoShape, got other variant");
8490        };
8491        assert!(
8492            reason.contains("must not contain `#`"),
8493            "reason must surface the fragment-`#` arm (fires before double-quote when `#` \
8494             byte appears first in value), got {reason:?}"
8495        );
8496    }
8497
8498    #[test]
8499    fn fonte_repo_subshell_fires_before_double_quote_when_subshell_first() {
8500        // Cascade pin: the subshell-`(` arm (the immediate-predecessor
8501        // byte-class arm, 3b99147) and the double-quote arm are both
8502        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
8503        // so the byte that appears first in the value's byte order
8504        // wins. A `:repo "github:p/x(date)\"tail"` carries both `(`
8505        // and `"`; the `(` byte appears first, so the subshell arm
8506        // fires, surfacing the more self-locating diagnostic on the
8507        // byte the author pasted earliest in the URL. Pins the natural-
8508        // order cascade so a future reorder of the per-byte arms
8509        // surfaces here — `"` is the most recent byte-class arm, so
8510        // the cascade-pin sweep extends to cover the immediately prior
8511        // `(` byte arm firing first when ordered ahead of `"` in the
8512        // value.
8513        let d = dep_with_fonte(DepSource::Git {
8514            repo: "github:pleme-io/caixa-teia(date)\"tail".into(),
8515            tag: Some("v0.1.0".into()),
8516            rev: None,
8517            branch: None,
8518        });
8519        let err = d.validate().unwrap_err();
8520        let DepError::FonteRepoShape { reason, .. } = err else {
8521            panic!("expected FonteRepoShape, got other variant");
8522        };
8523        assert!(
8524            reason.contains("must not contain `(`"),
8525            "reason must surface the subshell-`(` arm (fires before double-quote when `(` \
8526             byte appears first in value), got {reason:?}"
8527        );
8528    }
8529
8530    #[test]
8531    fn validate_rejects_git_fonte_with_repo_carrying_shell_single_quote() {
8532        // The fail-before-pass-after pin for the canonical paste-from-
8533        // doc-strong-quoting footgun on `:repo`. An author copies a
8534        // security-conscious README quick-start snippet (`$ git clone
8535        // 'https://github.com/foo/bar'`) and keeps the surrounding
8536        // single-quote bytes when pasting into the `:repo` slot — the
8537        // doc strong-quotes the URL so the shell suppresses every form
8538        // of expansion on the bytes inside (no `$`, no backtick, no
8539        // glob, no word-splitting), but the typed slot is itself a
8540        // byte-level string parser, not a shell context, so the quote
8541        // bytes ride into the value verbatim. Until this arm landed the
8542        // `'` byte silently passed every prior `is_git_repo_url` arm
8543        // (no whitespace, no control chars, no non-ASCII, no `#`, no
8544        // `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no
8545        // `;`, no `&`, no `$`, no `*`, no `(`/`)`, no `"`, doesn't start
8546        // with `-` or `:`); RFC 3986 §2.2 lists `'` in the 'sub-delims'
8547        // set, peer with the `\"` 'delims' double-quote arm and the
8548        // partner ASCII shell-string-delimiter byte every byte-level
8549        // string parser sharing a value-shape with a shell argument
8550        // must refuse on a URL-shaped slot.
8551        let d = dep_with_fonte(DepSource::Git {
8552            repo: "'https://github.com/pleme-io/caixa-teia'".into(),
8553            tag: Some("v0.1.0".into()),
8554            rev: None,
8555            branch: None,
8556        });
8557        let err = d.validate().unwrap_err();
8558        let DepError::FonteRepoShape { nome, repo, reason } = err else {
8559            panic!("expected FonteRepoShape, got other variant");
8560        };
8561        assert_eq!(nome, "caixa-teia");
8562        assert_eq!(repo, "'https://github.com/pleme-io/caixa-teia'");
8563        assert!(
8564            reason.contains("must not contain `'`"),
8565            "reason must surface the shell-single-quote arm, got {reason:?}"
8566        );
8567        assert!(
8568            reason.contains("single-quote") || reason.contains("strong-quote"),
8569            "reason must name the shell-single-quote / strong-quote rationale, \
8570             got {reason:?}"
8571        );
8572    }
8573
8574    #[test]
8575    fn validate_rejects_git_fonte_with_repo_carrying_english_apostrophe() {
8576        // The symmetric English-typography pin: an author writes
8577        // `:repo "github:p/repo's-fork"` (the possessive-form paste-
8578        // from-prose idiom every README / commit-message / chat-thread
8579        // reference to a repo carries) expecting the substrate to
8580        // coerce it to a kebab-case slug — but the byte rides into the
8581        // lacre verbatim. Pinned separately from the wrapped-quote
8582        // shape so a future diagnostic-surface change that only checked
8583        // the boundary positions (only leading, only trailing, only
8584        // paired) surfaces here — the per-byte arm fires anywhere `'`
8585        // appears in the value.
8586        let d = dep_with_fonte(DepSource::Git {
8587            repo: "github:pleme-io/repo's-fork".into(),
8588            tag: Some("v0.1.0".into()),
8589            rev: None,
8590            branch: None,
8591        });
8592        let err = d.validate().unwrap_err();
8593        let DepError::FonteRepoShape { reason, .. } = err else {
8594            panic!("expected FonteRepoShape, got other variant");
8595        };
8596        assert!(
8597            reason.contains("must not contain `'`"),
8598            "reason must surface the shell-single-quote arm on the mid-string \
8599             apostrophe shape, got {reason:?}"
8600        );
8601    }
8602
8603    #[test]
8604    fn fonte_repo_fragment_fires_before_single_quote_when_fragment_first() {
8605        // Cascade pin: the fragment-`#` arm and the single-quote arm
8606        // are both per-byte arms inside the same `for &b in
8607        // s.as_bytes()` loop, so the byte that appears first in the
8608        // value's byte order wins. A `:repo
8609        // "https://github.com/p/x#readme'tail"` carries both `#` and
8610        // `'`; the `#` byte appears first, so the fragment-`#` arm
8611        // fires, surfacing the more self-locating diagnostic on the
8612        // byte the author pasted earliest in the URL.
8613        let d = dep_with_fonte(DepSource::Git {
8614            repo: "https://github.com/pleme-io/caixa-teia#readme'tail".into(),
8615            tag: Some("v0.1.0".into()),
8616            rev: None,
8617            branch: None,
8618        });
8619        let err = d.validate().unwrap_err();
8620        let DepError::FonteRepoShape { reason, .. } = err else {
8621            panic!("expected FonteRepoShape, got other variant");
8622        };
8623        assert!(
8624            reason.contains("must not contain `#`"),
8625            "reason must surface the fragment-`#` arm (fires before single-quote when `#` \
8626             byte appears first in value), got {reason:?}"
8627        );
8628    }
8629
8630    #[test]
8631    fn fonte_repo_double_quote_fires_before_single_quote_when_double_quote_first() {
8632        // Cascade pin: the double-quote-`"` arm (the immediate-predecessor
8633        // byte-class arm, 4267d8b) and the single-quote arm are both
8634        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
8635        // so the byte that appears first in the value's byte order
8636        // wins. A `:repo "github:p/x\"mid'tail"` carries both `"` and
8637        // `'`; the `"` byte appears first, so the double-quote arm
8638        // fires, surfacing the more self-locating diagnostic on the
8639        // byte the author pasted earliest in the URL. Pins the natural-
8640        // order cascade so a future reorder of the per-byte arms
8641        // surfaces here — `'` is the most recent byte-class arm, so
8642        // the cascade-pin sweep extends to cover the immediately prior
8643        // `"` byte arm firing first when ordered ahead of `'` in the
8644        // value.
8645        let d = dep_with_fonte(DepSource::Git {
8646            repo: "github:pleme-io/caixa-teia\"mid'tail".into(),
8647            tag: Some("v0.1.0".into()),
8648            rev: None,
8649            branch: None,
8650        });
8651        let err = d.validate().unwrap_err();
8652        let DepError::FonteRepoShape { reason, .. } = err else {
8653            panic!("expected FonteRepoShape, got other variant");
8654        };
8655        assert!(
8656            reason.contains("must not contain `\"`"),
8657            "reason must surface the double-quote arm (fires before single-quote when `\"` \
8658             byte appears first in value), got {reason:?}"
8659        );
8660    }
8661
8662    #[test]
8663    fn validate_rejects_git_fonte_with_repo_carrying_shell_history_expansion() {
8664        // The fail-before-pass-after pin for the canonical paste-from-
8665        // shell-history footgun on `:repo`. An author copies a `git
8666        // clone <url>!sudo make install` one-liner from a README's
8667        // quick-start snippet, intending the trailing `!sudo` as a
8668        // shell-history-expansion reference but the typed slot is itself
8669        // a byte-level string parser, not a shell context, so the byte
8670        // rides into the value verbatim. Until this arm landed the `!`
8671        // byte silently passed every prior `is_git_repo_url` arm (no
8672        // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
8673        // no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no `;`,
8674        // no `&`, no `$`, no `*`, no `(`/`)`, no `"`, no `'`, doesn't
8675        // start with `-` or `:`); bash with the default `histexpand`
8676        // mode rewrites `!command` to the most recent history entry
8677        // beginning with `command`, the canonical RCE-class injection
8678        // vector when the byte rides into a shell argument.
8679        let d = dep_with_fonte(DepSource::Git {
8680            repo: "https://github.com/pleme-io/caixa-teia!sudo".into(),
8681            tag: Some("v0.1.0".into()),
8682            rev: None,
8683            branch: None,
8684        });
8685        let err = d.validate().unwrap_err();
8686        let DepError::FonteRepoShape { nome, repo, reason } = err else {
8687            panic!("expected FonteRepoShape, got other variant");
8688        };
8689        assert_eq!(nome, "caixa-teia");
8690        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia!sudo");
8691        assert!(
8692            reason.contains("must not contain `!`"),
8693            "reason must surface the shell-history-expansion arm, got {reason:?}"
8694        );
8695        assert!(
8696            reason.contains("history-expansion") || reason.contains("bang"),
8697            "reason must name the shell-history-expansion / bang rationale, got {reason:?}"
8698        );
8699    }
8700
8701    #[test]
8702    fn validate_rejects_git_fonte_with_repo_carrying_double_bang_history_reference() {
8703        // The symmetric `!!` repeat-prior-command pin: an author paste-
8704        // trims a `git clone <url>` retry idiom from shell history that
8705        // expands to the previous command via `!!`. Pinned separately
8706        // from the wrapped `!command` shape so a future diagnostic-
8707        // surface change that only checked the leading or paired-bang
8708        // position 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/caixa-teia!!".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-history-expansion arm on the trailing-`!!` shape, \
8723             got {reason:?}"
8724        );
8725    }
8726
8727    #[test]
8728    fn fonte_repo_fragment_fires_before_bang_when_fragment_first() {
8729        // Cascade pin: the fragment-`#` arm and the bang arm are both
8730        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
8731        // so the byte that appears first in the value's byte order
8732        // wins. A `:repo "https://github.com/p/x#readme!tail"` carries
8733        // both `#` and `!`; the `#` byte appears first, so the
8734        // fragment-`#` arm fires, surfacing the more self-locating
8735        // diagnostic on the byte the author pasted earliest in the URL.
8736        let d = dep_with_fonte(DepSource::Git {
8737            repo: "https://github.com/pleme-io/caixa-teia#readme!tail".into(),
8738            tag: Some("v0.1.0".into()),
8739            rev: None,
8740            branch: None,
8741        });
8742        let err = d.validate().unwrap_err();
8743        let DepError::FonteRepoShape { reason, .. } = err else {
8744            panic!("expected FonteRepoShape, got other variant");
8745        };
8746        assert!(
8747            reason.contains("must not contain `#`"),
8748            "reason must surface the fragment-`#` arm (fires before bang when `#` byte \
8749             appears first in value), got {reason:?}"
8750        );
8751    }
8752
8753    #[test]
8754    fn fonte_repo_single_quote_fires_before_bang_when_single_quote_first() {
8755        // Cascade pin: the single-quote-`'` arm (the immediate-predecessor
8756        // byte-class arm, e7a109f) and the bang arm are both per-byte
8757        // arms inside the same `for &b in s.as_bytes()` loop, so the
8758        // byte that appears first in the value's byte order wins. A
8759        // `:repo "github:p/x'mid!tail"` carries both `'` and `!`; the
8760        // `'` byte appears first, so the single-quote arm fires,
8761        // surfacing the more self-locating diagnostic on the byte the
8762        // author pasted earliest in the URL. Pins the natural-order
8763        // cascade so a future reorder of the per-byte arms surfaces
8764        // here — `!` is the most recent byte-class arm, so the
8765        // cascade-pin sweep extends to cover the immediately prior `'`
8766        // byte arm firing first when ordered ahead of `!` in the value.
8767        let d = dep_with_fonte(DepSource::Git {
8768            repo: "github:pleme-io/caixa-teia'mid!tail".into(),
8769            tag: Some("v0.1.0".into()),
8770            rev: None,
8771            branch: None,
8772        });
8773        let err = d.validate().unwrap_err();
8774        let DepError::FonteRepoShape { reason, .. } = err else {
8775            panic!("expected FonteRepoShape, got other variant");
8776        };
8777        assert!(
8778            reason.contains("must not contain `'`"),
8779            "reason must surface the single-quote arm (fires before bang when `'` byte \
8780             appears first in value), got {reason:?}"
8781        );
8782    }
8783
8784    #[test]
8785    fn validate_rejects_git_fonte_with_repo_carrying_list_separator_comma() {
8786        // The fail-before-pass-after pin for the canonical
8787        // list-separator-belongs-to-list-grammar footgun on `:repo`.
8788        // An author copies a `git clone <a>, <b>, <c>` paste-from-CSV
8789        // one-liner from a multi-repo bootstrap doc, intending the
8790        // comma to separate multiple repo entries but the typed
8791        // `:repo` slot names *one* repo (the list-separator belongs
8792        // to the `:deps` list grammar, not to the value). Until this
8793        // arm landed the `,` byte silently passed every prior
8794        // `is_git_repo_url` arm (no whitespace, no control chars, no
8795        // non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no `<`/`>`,
8796        // no `` ` ``, no `|`, no `;`, no `&`, no `$`, no `*`, no
8797        // `(`/`)`, no `"`, no `'`, no `!`, doesn't start with `-` or
8798        // `:`); the byte rode into the lacre's per-dep content-
8799        // address and the resolver's `git clone <repo>` subprocess
8800        // invocation, where no host's repo registry resolved the
8801        // comma-bearing slug.
8802        let d = dep_with_fonte(DepSource::Git {
8803            repo: "github:pleme-io/caixa-teia,github:pleme-io/caixa-feira".into(),
8804            tag: Some("v0.1.0".into()),
8805            rev: None,
8806            branch: None,
8807        });
8808        let err = d.validate().unwrap_err();
8809        let DepError::FonteRepoShape { nome, repo, reason } = err else {
8810            panic!("expected FonteRepoShape, got other variant");
8811        };
8812        assert_eq!(nome, "caixa-teia");
8813        assert_eq!(
8814            repo,
8815            "github:pleme-io/caixa-teia,github:pleme-io/caixa-feira"
8816        );
8817        assert!(
8818            reason.contains("must not contain `,`"),
8819            "reason must surface the list-separator-comma arm, got {reason:?}"
8820        );
8821        assert!(
8822            reason.contains("list-separator") || reason.contains("sub-delims"),
8823            "reason must name the list-separator / RFC-3986-sub-delims rationale, \
8824             got {reason:?}"
8825        );
8826    }
8827
8828    #[test]
8829    fn validate_rejects_git_fonte_with_repo_carrying_trailing_comma() {
8830        // The symmetric trailing-`,` paste-from-prose pin: an author
8831        // writes `:repo "github:pleme-io/caixa-feira,"` (the trailing
8832        // comma every README-prose list-of-projects sentence carries,
8833        // mistakenly retained when the slug is pasted mid-sentence)
8834        // expecting the substrate to coerce it to a kebab-case slug.
8835        // Pinned separately from the wrapped mid-token shape so a
8836        // future diagnostic-surface change that only checked the
8837        // leading or paired-comma position surfaces here — the
8838        // per-byte arm fires anywhere `,` appears in the value.
8839        let d = dep_with_fonte(DepSource::Git {
8840            repo: "github:pleme-io/caixa-feira,".into(),
8841            tag: Some("v0.1.0".into()),
8842            rev: None,
8843            branch: None,
8844        });
8845        let err = d.validate().unwrap_err();
8846        let DepError::FonteRepoShape { reason, .. } = err else {
8847            panic!("expected FonteRepoShape, got other variant");
8848        };
8849        assert!(
8850            reason.contains("must not contain `,`"),
8851            "reason must surface the list-separator-comma arm on the trailing-`,` shape, \
8852             got {reason:?}"
8853        );
8854    }
8855
8856    #[test]
8857    fn fonte_repo_fragment_fires_before_comma_when_fragment_first() {
8858        // Cascade pin: the fragment-`#` arm and the comma arm are
8859        // both per-byte arms inside the same `for &b in s.as_bytes()`
8860        // loop, so the byte that appears first in the value's byte
8861        // order wins. A `:repo "https://github.com/p/x#readme,tail"`
8862        // carries both `#` and `,`; the `#` byte appears first, so
8863        // the fragment-`#` arm fires, surfacing the more self-
8864        // locating diagnostic on the byte the author pasted earliest
8865        // in the URL.
8866        let d = dep_with_fonte(DepSource::Git {
8867            repo: "https://github.com/pleme-io/caixa-teia#readme,tail".into(),
8868            tag: Some("v0.1.0".into()),
8869            rev: None,
8870            branch: None,
8871        });
8872        let err = d.validate().unwrap_err();
8873        let DepError::FonteRepoShape { reason, .. } = err else {
8874            panic!("expected FonteRepoShape, got other variant");
8875        };
8876        assert!(
8877            reason.contains("must not contain `#`"),
8878            "reason must surface the fragment-`#` arm (fires before comma when `#` byte \
8879             appears first in value), got {reason:?}"
8880        );
8881    }
8882
8883    #[test]
8884    fn fonte_repo_bang_fires_before_comma_when_bang_first() {
8885        // Cascade pin: the bang-`!` arm (the immediate-predecessor
8886        // byte-class arm, 7d53c68) and the comma arm are both
8887        // per-byte arms inside the same `for &b in s.as_bytes()`
8888        // loop, so the byte that appears first in the value's byte
8889        // order wins. A `:repo "github:p/x!mid,tail"` carries both
8890        // `!` and `,`; the `!` byte appears first, so the bang arm
8891        // fires, surfacing the more self-locating diagnostic on the
8892        // byte the author pasted earliest in the URL. Pins the
8893        // natural-order cascade so a future reorder of the per-byte
8894        // arms surfaces here — `,` is the most recent byte-class
8895        // arm, so the cascade-pin sweep extends to cover the
8896        // immediately prior `!` byte arm firing first when ordered
8897        // ahead of `,` in the value.
8898        let d = dep_with_fonte(DepSource::Git {
8899            repo: "github:pleme-io/caixa-teia!mid,tail".into(),
8900            tag: Some("v0.1.0".into()),
8901            rev: None,
8902            branch: None,
8903        });
8904        let err = d.validate().unwrap_err();
8905        let DepError::FonteRepoShape { reason, .. } = err else {
8906            panic!("expected FonteRepoShape, got other variant");
8907        };
8908        assert!(
8909            reason.contains("must not contain `!`"),
8910            "reason must surface the bang arm (fires before comma when `!` byte \
8911             appears first in value), got {reason:?}"
8912        );
8913    }
8914
8915    #[test]
8916    fn validate_rejects_git_fonte_with_repo_carrying_shell_env_var_assignment() {
8917        // The fail-before-pass-after pin for the canonical
8918        // shell-env-var-assignment-belongs-to-shell-grammar footgun
8919        // on `:repo`. An author copies
8920        // `GIT_TERMINAL_PROMPT=0 git clone <url>` (or
8921        // `GIT_SSL_NO_VERIFY=1 git clone <url>`, `HTTPS_PROXY=…
8922        // git clone <url>`, etc. — the canonical
8923        // git-troubleshooting README idiom for a one-shot env-var
8924        // scoped to the `git clone` invocation) from a shell-prompt
8925        // one-liner, intending the `KEY=VALUE` prefix as a shell-
8926        // grammar env-var assignment but the typed `:repo` slot is
8927        // a value parser, not a shell context, so the bytes ride
8928        // into the value verbatim. Until this arm landed the `=`
8929        // byte silently passed every prior `is_git_repo_url` arm
8930        // (no whitespace, no control chars, no non-ASCII, no `#`,
8931        // no `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no
8932        // `|`, no `;`, no `&`, no `$`, no `*`, no `(`/`)`, no `"`,
8933        // no `'`, no `!`, no `,`, doesn't start with `-` or `:`);
8934        // the byte rode into the lacre's per-dep content-address
8935        // and the resolver's `git clone <repo>` subprocess
8936        // invocation, where the upstream host's git porcelain
8937        // fetched a literal `GIT_TERMINAL_PROMPT=0 https://…`-shaped
8938        // path that no host's repo registry resolves.
8939        let d = dep_with_fonte(DepSource::Git {
8940            repo: "GIT_TERMINAL_PROMPT=0 https://github.com/pleme-io/caixa-teia".into(),
8941            tag: Some("v0.1.0".into()),
8942            rev: None,
8943            branch: None,
8944        });
8945        let err = d.validate().unwrap_err();
8946        let DepError::FonteRepoShape { nome, repo, reason } = err else {
8947            panic!("expected FonteRepoShape, got other variant");
8948        };
8949        assert_eq!(nome, "caixa-teia");
8950        assert_eq!(
8951            repo,
8952            "GIT_TERMINAL_PROMPT=0 https://github.com/pleme-io/caixa-teia"
8953        );
8954        // The `=` byte at position 19 of `GIT_TERMINAL_PROMPT=0 …`
8955        // appears before the ` ` byte at position 21, so the `=`
8956        // arm fires (not the whitespace arm) — both arms guard
8957        // the slot, but the per-byte for-loop scans left-to-right
8958        // and the first matching byte wins.
8959        assert!(
8960            reason.contains("must not contain `=`"),
8961            "reason must surface the equals-`=` arm on the env-var-assignment \
8962             paste shape, got {reason:?}"
8963        );
8964        assert!(
8965            reason.contains("env-var-assignment") || reason.contains("KEY=VALUE"),
8966            "reason must name the shell-env-var-assignment rationale, got {reason:?}"
8967        );
8968    }
8969
8970    #[test]
8971    fn validate_rejects_git_fonte_with_repo_carrying_gitconfig_url_key_prefix() {
8972        // The symmetric paste-from-gitconfig pin: an author copies
8973        // `url=https://github.com/p/x` from `git config --get-all
8974        // remote.origin.url` output, a `.gitconfig` `[remote
8975        // "origin"] url = https://…` ini-stanza paste, or a
8976        // `git config remote.origin.url <value>` doc snippet,
8977        // intending the `url=` prefix as the ini-key but the typed
8978        // `:repo` slot is a URL value parser, not a gitconfig
8979        // grammar. With no leading whitespace and no earlier-arm
8980        // bytes in the value, the `=` arm itself fires (rather
8981        // than cascading to the whitespace arm as in the env-var
8982        // paste shape). Pinned separately so a future diagnostic-
8983        // surface change that only checked the whitespace-leading
8984        // shape surfaces here — the per-byte arm fires anywhere
8985        // `=` appears in the value.
8986        let d = dep_with_fonte(DepSource::Git {
8987            repo: "url=https://github.com/pleme-io/caixa-feira".into(),
8988            tag: Some("v0.1.0".into()),
8989            rev: None,
8990            branch: None,
8991        });
8992        let err = d.validate().unwrap_err();
8993        let DepError::FonteRepoShape { reason, .. } = err else {
8994            panic!("expected FonteRepoShape, got other variant");
8995        };
8996        assert!(
8997            reason.contains("must not contain `=`"),
8998            "reason must surface the equals-`=` arm on the `url=…` gitconfig \
8999             paste shape, got {reason:?}"
9000        );
9001        assert!(
9002            reason.contains("key-value-separator") || reason.contains("sub-delims"),
9003            "reason must name the key-value-separator / RFC-3986-sub-delims \
9004             rationale, got {reason:?}"
9005        );
9006    }
9007
9008    #[test]
9009    fn fonte_repo_fragment_fires_before_equals_when_fragment_first() {
9010        // Cascade pin: the fragment-`#` arm and the `=` arm are
9011        // both 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 "https://github.com/p/x#readme=tail"`
9014        // carries both `#` and `=`; the `#` byte appears first, so
9015        // the fragment-`#` arm fires, surfacing the more self-
9016        // locating diagnostic on the byte the author pasted earliest
9017        // in the URL.
9018        let d = dep_with_fonte(DepSource::Git {
9019            repo: "https://github.com/pleme-io/caixa-teia#readme=tail".into(),
9020            tag: Some("v0.1.0".into()),
9021            rev: None,
9022            branch: None,
9023        });
9024        let err = d.validate().unwrap_err();
9025        let DepError::FonteRepoShape { reason, .. } = err else {
9026            panic!("expected FonteRepoShape, got other variant");
9027        };
9028        assert!(
9029            reason.contains("must not contain `#`"),
9030            "reason must surface the fragment-`#` arm (fires before equals when \
9031             `#` byte appears first in value), got {reason:?}"
9032        );
9033    }
9034
9035    #[test]
9036    fn fonte_repo_comma_fires_before_equals_when_comma_first() {
9037        // Cascade pin: the comma-`,` arm (the immediate-predecessor
9038        // byte-class arm, 775b80e) and the `=` arm are both per-byte
9039        // arms inside the same `for &b in s.as_bytes()` loop, so
9040        // the byte that appears first in the value's byte order
9041        // wins. A `:repo "github:p/x,mid=tail"` carries both `,`
9042        // and `=`; the `,` byte appears first, so the comma arm
9043        // fires, surfacing the more self-locating diagnostic on
9044        // the byte the author pasted earliest in the URL. Pins the
9045        // natural-order cascade so a future reorder of the per-byte
9046        // arms surfaces here — `=` is the most recent byte-class
9047        // arm, so the cascade-pin sweep extends to cover the
9048        // immediately prior `,` byte arm firing first when ordered
9049        // ahead of `=` in the value.
9050        let d = dep_with_fonte(DepSource::Git {
9051            repo: "github:pleme-io/caixa-teia,mid=tail".into(),
9052            tag: Some("v0.1.0".into()),
9053            rev: None,
9054            branch: None,
9055        });
9056        let err = d.validate().unwrap_err();
9057        let DepError::FonteRepoShape { reason, .. } = err else {
9058            panic!("expected FonteRepoShape, got other variant");
9059        };
9060        assert!(
9061            reason.contains("must not contain `,`"),
9062            "reason must surface the comma arm (fires before equals when `,` byte \
9063             appears first in value), got {reason:?}"
9064        );
9065    }
9066
9067    #[test]
9068    fn validate_rejects_git_fonte_with_repo_carrying_percent_encoded_space() {
9069        // The fail-before-pass-after pin for the canonical paste-from-
9070        // browser-address-bar percent-encoded-space footgun on `:repo`.
9071        // An author copies `https://github.com/p/x%20test` from a
9072        // browser address bar (or a percent-encoded README hyperlink,
9073        // or a `curl --data-urlencode` shell-pipeline output)
9074        // intending `%20` as the URL encoding of a literal space; the
9075        // typed `:repo` slot already rejects the literal space byte
9076        // (the whitespace arm at the top of `is_git_repo_url`), so an
9077        // author trying to express "I really meant a space" reaches
9078        // for percent-encoding. Until this arm landed the `%` byte
9079        // silently passed every prior `is_git_repo_url` arm and rode
9080        // verbatim into the lacre's per-dep content-address — but
9081        // libcurl re-percent-encodes `%` to `%25` on the wire (since
9082        // `%` is reserved as the escape-sequence lead-in), so the
9083        // wire request becomes `https://github.com/p/x%2520test`, a
9084        // path the lacre's content-address never names. The classic
9085        // render-determinism violation on the encoding-mechanism axis
9086        // itself.
9087        let d = dep_with_fonte(DepSource::Git {
9088            repo: "https://github.com/pleme-io/caixa-teia%20test".into(),
9089            tag: Some("v0.1.0".into()),
9090            rev: None,
9091            branch: None,
9092        });
9093        let err = d.validate().unwrap_err();
9094        let DepError::FonteRepoShape { nome, repo, reason } = err else {
9095            panic!("expected FonteRepoShape, got other variant");
9096        };
9097        assert_eq!(nome, "caixa-teia");
9098        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia%20test");
9099        assert!(
9100            reason.contains("must not contain `%`"),
9101            "reason must surface the percent-`%` arm on the percent-encoded-space \
9102             paste shape, got {reason:?}"
9103        );
9104        assert!(
9105            reason.contains("percent-encoding") || reason.contains("%25"),
9106            "reason must name the percent-encoding / `%25` re-encoding rationale, \
9107             got {reason:?}"
9108        );
9109    }
9110
9111    #[test]
9112    fn validate_rejects_git_fonte_with_repo_carrying_percent_encoded_slash() {
9113        // The symmetric over-encoded-path-separator pin: an author
9114        // writes `:repo "https://github.com/p%2Fx"` intending the
9115        // `%2F` as the URL encoding of `/` (the canonical
9116        // paste-from-OpenAPI-spec / paste-from-percent-encoded-template
9117        // footgun every API client library and OAuth redirect-URI
9118        // documentation surfaces — the `/` is the URL-path-separator
9119        // and some templates percent-encode it to escape interpretation
9120        // as a path separator). The GitHub Smart-HTTP transport
9121        // resolves the URL's path-segment grammar before the
9122        // percent-decoding pass, so the value identifies a different
9123        // resource on the wire than the literal-`/` form the lacre's
9124        // content-address must agree with — two authors whose `:repo`
9125        // values differ only in their `/` vs `%2F` presence lock to
9126        // two distinct BLAKE3 closures for the byte-identical upstream
9127        // `git clone`. Pinned separately so a future diagnostic
9128        // surface that only catches the `%20` shape surfaces here too.
9129        let d = dep_with_fonte(DepSource::Git {
9130            repo: "https://github.com/pleme-io%2Fcaixa-teia".into(),
9131            tag: Some("v0.1.0".into()),
9132            rev: None,
9133            branch: None,
9134        });
9135        let err = d.validate().unwrap_err();
9136        let DepError::FonteRepoShape { reason, .. } = err else {
9137            panic!("expected FonteRepoShape, got other variant");
9138        };
9139        assert!(
9140            reason.contains("must not contain `%`"),
9141            "reason must surface the percent-`%` arm on the over-encoded-path \
9142             shape, got {reason:?}"
9143        );
9144        assert!(
9145            reason.contains("render-determinism") || reason.contains("BLAKE3"),
9146            "reason must name the render-determinism / BLAKE3-closure rationale, \
9147             got {reason:?}"
9148        );
9149    }
9150
9151    #[test]
9152    fn fonte_repo_fragment_fires_before_percent_when_fragment_first() {
9153        // Cascade pin: the fragment-`#` arm and the `%` arm are both
9154        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
9155        // so the byte that appears first in the value's byte order
9156        // wins. A `:repo "https://github.com/p/x#sec%20tail"` carries
9157        // both `#` and `%`; the `#` byte appears first, so the
9158        // fragment-`#` arm fires, surfacing the more self-locating
9159        // diagnostic on the byte the author pasted earliest in the URL.
9160        let d = dep_with_fonte(DepSource::Git {
9161            repo: "https://github.com/pleme-io/caixa-teia#sec%20tail".into(),
9162            tag: Some("v0.1.0".into()),
9163            rev: None,
9164            branch: None,
9165        });
9166        let err = d.validate().unwrap_err();
9167        let DepError::FonteRepoShape { reason, .. } = err else {
9168            panic!("expected FonteRepoShape, got other variant");
9169        };
9170        assert!(
9171            reason.contains("must not contain `#`"),
9172            "reason must surface the fragment-`#` arm (fires before percent when \
9173             `#` byte appears first in value), got {reason:?}"
9174        );
9175    }
9176
9177    #[test]
9178    fn fonte_repo_equals_fires_before_percent_when_equals_first() {
9179        // Cascade pin: the equals-`=` arm (the immediate-predecessor
9180        // byte-class arm, acf99af) and the `%` arm are both per-byte
9181        // arms inside the same `for &b in s.as_bytes()` loop, so the
9182        // byte that appears first in the value's byte order wins.
9183        // A `:repo "github:p/x=mid%20tail"` carries both `=` and `%`;
9184        // the `=` byte appears first, so the equals arm fires,
9185        // surfacing the more self-locating diagnostic on the byte the
9186        // author pasted earliest in the URL. Pins the natural-order
9187        // cascade so a future reorder of the per-byte arms surfaces
9188        // here — `%` is the most recent byte-class arm, so the
9189        // cascade-pin sweep extends to cover the immediately prior
9190        // `=` byte arm firing first when ordered ahead of `%` in the
9191        // value.
9192        let d = dep_with_fonte(DepSource::Git {
9193            repo: "github:pleme-io/caixa-teia=mid%20tail".into(),
9194            tag: Some("v0.1.0".into()),
9195            rev: None,
9196            branch: None,
9197        });
9198        let err = d.validate().unwrap_err();
9199        let DepError::FonteRepoShape { reason, .. } = err else {
9200            panic!("expected FonteRepoShape, got other variant");
9201        };
9202        assert!(
9203            reason.contains("must not contain `=`"),
9204            "reason must surface the equals arm (fires before percent when `=` byte \
9205             appears first in value), got {reason:?}"
9206        );
9207    }
9208
9209    #[test]
9210    fn validate_rejects_git_fonte_with_repo_carrying_caret_history_substitution() {
9211        // The fail-before-pass-after pin for the canonical paste-from-
9212        // shell-history footgun on `:repo`. An author copies a
9213        // `git clone <url>` line from their terminal followed by a
9214        // bash / ksh / zsh `^typo^fix^` quick-edit-and-rerun shell-
9215        // history shorthand (the `^old^new^` form re-runs the prior
9216        // history entry with the first `old` substituted by `new`,
9217        // bash's default behavior on interactive sessions with
9218        // `set -o histexpand`), forgetting to trim the trailing
9219        // `^...^...` shell-history fragment from the URL value. The
9220        // `^` byte sits in the RFC 3986 §2 'unwise' set (peer with
9221        // `{`, `}`, `|`, `\\` — the strictest of the §2 reserved
9222        // classes), the WHATWG URL spec's 'fragment percent-encode
9223        // set' maps `^` → `%5E` on the wire, so the byte rides
9224        // verbatim into the lacre's per-dep content-address but
9225        // libcurl re-encodes it to `%5E` at `git clone` time — the
9226        // classic render-determinism violation on the same axis the
9227        // peer `%`, `=`, `,`, `!`, `'`, `"`, `(`, `)`, `*`, `$`,
9228        // `&`, `;`, `|`, backtick, `<`, `>`, `{`, `}`, `\\`, `?`,
9229        // `#` arms close.
9230        let d = dep_with_fonte(DepSource::Git {
9231            repo: "https://github.com/pleme-io/caixa-teia^typo^fix".into(),
9232            tag: Some("v0.1.0".into()),
9233            rev: None,
9234            branch: None,
9235        });
9236        let err = d.validate().unwrap_err();
9237        let DepError::FonteRepoShape { nome, repo, reason } = err else {
9238            panic!("expected FonteRepoShape, got other variant");
9239        };
9240        assert_eq!(nome, "caixa-teia");
9241        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia^typo^fix");
9242        assert!(
9243            reason.contains("must not contain `^`"),
9244            "reason must surface the caret-`^` arm on the paste-from-shell-history \
9245             shape, got {reason:?}"
9246        );
9247        assert!(
9248            reason.contains("history-substitution") || reason.contains("%5E"),
9249            "reason must name the shell-history-substitution / `%5E` wire-encoding \
9250             rationale, got {reason:?}"
9251        );
9252    }
9253
9254    #[test]
9255    fn validate_rejects_git_fonte_with_repo_carrying_caret_regex_anchor() {
9256        // The symmetric paste-from-doc-grep-pipeline footgun: an
9257        // author writes `:repo "github:p/^archived"` after copying a
9258        // `grep '^archived'` regex-anchor / negation idiom from a
9259        // doc / README quick-listing snippet, expecting the substrate
9260        // to coerce it to a literal repo name. The byte rides
9261        // verbatim into the lacre's per-dep content-address and
9262        // diverges from the byte-identical literal `archived` form
9263        // every other author authored — the canonical render-
9264        // determinism violation pin on the second footgun shape the
9265        // caret-`^` arm closes.
9266        let d = dep_with_fonte(DepSource::Git {
9267            repo: "github:pleme-io/^archived".into(),
9268            tag: Some("v0.1.0".into()),
9269            rev: None,
9270            branch: None,
9271        });
9272        let err = d.validate().unwrap_err();
9273        let DepError::FonteRepoShape { reason, .. } = err else {
9274            panic!("expected FonteRepoShape, got other variant");
9275        };
9276        assert!(
9277            reason.contains("must not contain `^`"),
9278            "reason must surface the caret-`^` arm on the regex-anchor shape, \
9279             got {reason:?}"
9280        );
9281        assert!(
9282            reason.contains("render-determinism") || reason.contains("BLAKE3"),
9283            "reason must name the render-determinism / BLAKE3-closure rationale, \
9284             got {reason:?}"
9285        );
9286    }
9287
9288    #[test]
9289    fn fonte_repo_percent_fires_before_caret_when_percent_first() {
9290        // Cascade pin: the `%` arm (the immediate-predecessor byte-
9291        // class arm, a323db8) and the `^` arm are both per-byte arms
9292        // inside the same `for &b in s.as_bytes()` loop, so the byte
9293        // that appears first in the value's byte order wins. A
9294        // `:repo "https://github.com/p/x%20mid^tail"` carries both
9295        // `%` and `^`; the `%` byte appears first, so the percent
9296        // arm fires, surfacing the more self-locating diagnostic on
9297        // the byte the author pasted earliest in the URL. Pins the
9298        // natural-order cascade so a future reorder of the per-byte
9299        // arms surfaces here — `^` is the most recent byte-class arm,
9300        // so the cascade-pin sweep extends to cover the immediately
9301        // prior `%` byte arm firing first when ordered ahead of `^`
9302        // in the value.
9303        let d = dep_with_fonte(DepSource::Git {
9304            repo: "https://github.com/pleme-io/caixa-teia%20mid^tail".into(),
9305            tag: Some("v0.1.0".into()),
9306            rev: None,
9307            branch: None,
9308        });
9309        let err = d.validate().unwrap_err();
9310        let DepError::FonteRepoShape { reason, .. } = err else {
9311            panic!("expected FonteRepoShape, got other variant");
9312        };
9313        assert!(
9314            reason.contains("must not contain `%`"),
9315            "reason must surface the percent arm (fires before caret when `%` byte \
9316             appears first in value), got {reason:?}"
9317        );
9318    }
9319
9320    #[test]
9321    fn validate_rejects_git_fonte_with_repo_missing_colon_separator() {
9322        // The "I dropped the scheme" footgun — `:repo "pleme-io/caixa-teia"`
9323        // (no `github:` prefix, no scheme). Every documented form
9324        // carries a `:` (`github:`, `https://`, `ssh://`, `git://`,
9325        // `file://`, or `git@host:path`); a bare `org/repo` is
9326        // ambiguous (`git clone` reads as a relative filesystem path
9327        // rather than the GitHub-shorthand expansion the author
9328        // probably intended) and the gate rejects the shape upstream.
9329        let d = dep_with_fonte(DepSource::Git {
9330            repo: "pleme-io/caixa-teia".into(),
9331            tag: Some("v0.1.0".into()),
9332            rev: None,
9333            branch: None,
9334        });
9335        let err = d.validate().unwrap_err();
9336        let DepError::FonteRepoShape { reason, .. } = err else {
9337            panic!("expected FonteRepoShape, got other variant");
9338        };
9339        assert!(
9340            reason.contains("must contain a `:`"),
9341            "reason must surface the missing-`:` arm, got {reason:?}"
9342        );
9343        assert!(
9344            reason.contains("github:"),
9345            "reason must name the canonical `github:` shorthand prefix, got {reason:?}"
9346        );
9347    }
9348
9349    #[test]
9350    fn validate_rejects_git_fonte_with_repo_leading_colon() {
9351        // The "empty scheme" footgun — `:repo ":foo"` has a zero-length
9352        // scheme that no git porcelain entry-point accepts. Pinned
9353        // separately from the missing-`:` arm because a value with a
9354        // leading `:` does technically contain a `:` separator; the
9355        // shape gate rejects on a dedicated arm so the diagnostic
9356        // names the specific footgun.
9357        let d = dep_with_fonte(DepSource::Git {
9358            repo: ":pleme-io/caixa-teia".into(),
9359            tag: Some("v0.1.0".into()),
9360            rev: None,
9361            branch: None,
9362        });
9363        let err = d.validate().unwrap_err();
9364        let DepError::FonteRepoShape { reason, .. } = err else {
9365            panic!("expected FonteRepoShape, got other variant");
9366        };
9367        assert!(
9368            reason.contains("must not start with `:`"),
9369            "reason must surface the leading-`:` arm, got {reason:?}"
9370        );
9371    }
9372
9373    #[test]
9374    fn validate_rejects_git_fonte_with_repo_too_long() {
9375        // The cap arm — a `:repo` value longer than
9376        // [`crate::render::GIT_REPO_URL_MAX_LEN`] (2048) bytes is
9377        // structurally untenable on every realistic landing site (the
9378        // resolver's `git clone` invocation, the future M4 CR
9379        // materializer's per-dep `repo:` axis); a value of that length
9380        // is almost certainly a paste-from-binary slug.
9381        let too_long = format!(
9382            "github:pleme-io/{}",
9383            "x".repeat(crate::render::GIT_REPO_URL_MAX_LEN)
9384        );
9385        let d = dep_with_fonte(DepSource::Git {
9386            repo: too_long.clone(),
9387            tag: Some("v0.1.0".into()),
9388            rev: None,
9389            branch: None,
9390        });
9391        let err = d.validate().unwrap_err();
9392        let DepError::FonteRepoShape { reason, .. } = err else {
9393            panic!("expected FonteRepoShape, got other variant");
9394        };
9395        assert!(
9396            reason.contains("2048"),
9397            "reason must name the cap, got {reason:?}"
9398        );
9399    }
9400
9401    #[test]
9402    fn validate_accepts_canonical_git_fonte_repo_shapes() {
9403        // The positive-control sweep: every documented author shape on
9404        // the `:fonte :repo` axis ([`crate::DepSource::Git`] doc comment)
9405        // must pass the value-shape gate. Pinned so a future tightening
9406        // (e.g. forbidding `http://` in favor of `https://`-only) surfaces
9407        // here as a structural decision. Each form is exercised with the
9408        // same canonical `:tag` pin so only the `:repo` axis varies.
9409        for repo in [
9410            // The pleme-io registry-shorthand convention — `github:org/repo`.
9411            "github:pleme-io/caixa-teia",
9412            // Other host-aliased shorthands (the resolver's pluggable
9413            // host-prefix table).
9414            "gitlab:pleme-io/caixa-teia",
9415            "codeberg:pleme-io/caixa-teia",
9416            "sourcehut:~pleme-io/caixa-teia",
9417            // Full HTTPS URL with and without `.git` suffix.
9418            "https://github.com/pleme-io/caixa-teia",
9419            "https://github.com/pleme-io/caixa-teia.git",
9420            // HTTP (rare; dev / mirror).
9421            "http://example.com/pleme-io/caixa-teia.git",
9422            // SSH URL.
9423            "ssh://git@github.com/pleme-io/caixa-teia.git",
9424            "ssh://git@git.example.com:2222/pleme-io/caixa-teia.git",
9425            // Scp-style SSH — the canonical `git@host:path` short form.
9426            "git@github.com:pleme-io/caixa-teia.git",
9427            "git@git.example.com:team/private.git",
9428            // Anonymous git protocol.
9429            "git://git.example.com/pleme-io/caixa-teia.git",
9430            // Local file URL (dev path).
9431            "file:///tmp/caixa-teia",
9432        ] {
9433            let d = dep_with_fonte(DepSource::Git {
9434                repo: repo.into(),
9435                tag: Some("v0.1.0".into()),
9436                rev: None,
9437                branch: None,
9438            });
9439            d.validate()
9440                .unwrap_or_else(|e| panic!("canonical repo {repo:?} must validate, got {e:?}"));
9441        }
9442    }
9443
9444    #[test]
9445    fn fonte_repo_empty_takes_precedence_over_shape() {
9446        // Order pin: the existing `FonteRepoEmpty` diagnostic (narrower
9447        // diagnostic; doesn't try to parse the URL shape) fires before
9448        // the new `FonteRepoShape` per-axis gate, so an empty `:repo`
9449        // keeps its narrower error message. Mirrors
9450        // `fonte_repo_empty_fires_before_pin_missing` (already pinned)
9451        // on the ordering layer.
9452        let d = dep_with_fonte(DepSource::Git {
9453            repo: String::new(),
9454            tag: Some("v0.1.0".into()),
9455            rev: None,
9456            branch: None,
9457        });
9458        let err = d.validate().unwrap_err();
9459        assert!(
9460            matches!(err, DepError::FonteRepoEmpty { .. }),
9461            "got {err:?}"
9462        );
9463    }
9464
9465    #[test]
9466    fn fonte_repo_shape_fires_before_pin_missing() {
9467        // Order pin: a malformed `:repo` value on a dep with no pin set
9468        // surfaces the `:repo` shape diagnostic (the more self-locating
9469        // axis — the `:repo` is the load-bearing identity of the source;
9470        // a missing pin is downstream from "do we even know the repo")
9471        // rather than collapsing onto the pin-missing diagnostic. The
9472        // shape gate runs inline before the pin enumeration in
9473        // `DepSource::validate`.
9474        let d = dep_with_fonte(DepSource::Git {
9475            repo: "pleme-io/caixa-teia".into(), // missing `:` separator
9476            tag: None,
9477            rev: None,
9478            branch: None,
9479        });
9480        let err = d.validate().unwrap_err();
9481        assert!(
9482            matches!(err, DepError::FonteRepoShape { .. }),
9483            "got {err:?}"
9484        );
9485    }
9486
9487    #[test]
9488    fn fonte_repo_shape_diagnostic_carries_offending_repo_verbatim() {
9489        // The diagnostic-shape pin: the error names the offending
9490        // `:repo` value verbatim plus a non-empty parser-shaped `reason`
9491        // so the author can grep their caixa.lisp without re-running
9492        // the build. Mirrors the diagnostic-shape sweep on every prior
9493        // value-shape gate (3f9d7a0, 6cbb900, c7d05ec, e70d213, be07fd5).
9494        let d = dep_with_fonte(DepSource::Git {
9495            repo: "pleme-io/caixa-teia".into(),
9496            tag: Some("v0.1.0".into()),
9497            rev: None,
9498            branch: None,
9499        });
9500        let err = d.validate().unwrap_err();
9501        let DepError::FonteRepoShape { nome, repo, reason } = err else {
9502            panic!("expected FonteRepoShape, got other variant");
9503        };
9504        assert_eq!(nome, "caixa-teia");
9505        assert_eq!(repo, "pleme-io/caixa-teia");
9506        assert!(
9507            !reason.is_empty(),
9508            "FonteRepoShape `reason` must carry the predicate's wording verbatim"
9509        );
9510    }
9511
9512    #[test]
9513    fn validate_rejects_git_fonte_with_no_pin() {
9514        // The fail-before-pass-after pin for the canonical
9515        // `(:tipo git :repo "github:pleme-io/x")` shape with no
9516        // :tag/:rev/:branch — until this gate landed the resolver's
9517        // ResolveError::MissingPin surfaced at fetch time, far from the
9518        // source caixa.lisp. The new gate moves the check to validate
9519        // time and names the offending dep.
9520        let d = dep_with_fonte(DepSource::Git {
9521            repo: "github:pleme-io/caixa-teia".into(),
9522            tag: None,
9523            rev: None,
9524            branch: None,
9525        });
9526        let err = d.validate().unwrap_err();
9527        assert!(
9528            matches!(err, DepError::FontePinMissing { ref nome } if nome == "caixa-teia"),
9529            "got {err:?}"
9530        );
9531    }
9532
9533    #[test]
9534    fn validate_rejects_git_fonte_with_ambiguous_tag_and_branch() {
9535        // The canonical "pin drift" footgun: an author writes
9536        // `:tag "v1"` and later adds `:branch "main"` without removing
9537        // the :tag, and the resolver silently picks :tag (precedence
9538        // :rev > :tag > :branch). The :branch was dropped with no
9539        // diagnostic. The gate now rejects multi-pin shapes so the
9540        // author makes the precedence explicit at the source.
9541        let d = dep_with_fonte(DepSource::Git {
9542            repo: "github:pleme-io/caixa-teia".into(),
9543            tag: Some("v0.1.0".into()),
9544            rev: None,
9545            branch: Some("main".into()),
9546        });
9547        let err = d.validate().unwrap_err();
9548        let DepError::FontePinAmbiguous { nome, pins } = err else {
9549            panic!("expected FontePinAmbiguous");
9550        };
9551        assert_eq!(nome, "caixa-teia");
9552        assert!(pins.contains(":tag"));
9553        assert!(pins.contains(":branch"));
9554        assert!(!pins.contains(":rev"));
9555    }
9556
9557    #[test]
9558    fn validate_rejects_git_fonte_with_ambiguous_tag_and_rev() {
9559        // Sibling arm of the pin-drift footgun: :tag + :rev set
9560        // simultaneously. Pinned separately so a future relaxation
9561        // that only catches the (:tag, :branch) pair surfaces here.
9562        let d = dep_with_fonte(DepSource::Git {
9563            repo: "github:pleme-io/caixa-teia".into(),
9564            tag: Some("v0.1.0".into()),
9565            rev: Some("c0ffee".into()),
9566            branch: None,
9567        });
9568        let err = d.validate().unwrap_err();
9569        let DepError::FontePinAmbiguous { nome, pins } = err else {
9570            panic!("expected FontePinAmbiguous");
9571        };
9572        assert_eq!(nome, "caixa-teia");
9573        assert!(pins.contains(":tag"));
9574        assert!(pins.contains(":rev"));
9575    }
9576
9577    #[test]
9578    fn validate_rejects_git_fonte_with_all_three_pins() {
9579        // The maximal ambiguity case — every pin axis set. Pinned so a
9580        // future relaxation that only catches pairs surfaces here. The
9581        // diagnostic must enumerate every offending axis so the author
9582        // sees the full set, not just the first match.
9583        let d = dep_with_fonte(DepSource::Git {
9584            repo: "github:pleme-io/caixa-teia".into(),
9585            tag: Some("v0.1.0".into()),
9586            rev: Some("c0ffee".into()),
9587            branch: Some("main".into()),
9588        });
9589        let err = d.validate().unwrap_err();
9590        let DepError::FontePinAmbiguous { nome, pins } = err else {
9591            panic!("expected FontePinAmbiguous");
9592        };
9593        assert_eq!(nome, "caixa-teia");
9594        assert!(pins.contains(":tag"));
9595        assert!(pins.contains(":rev"));
9596        assert!(pins.contains(":branch"));
9597    }
9598
9599    #[test]
9600    fn validate_rejects_git_fonte_with_empty_tag_pin() {
9601        // The empty-pin arm: exactly one pin axis is `Some(_)`, but its
9602        // inner string is empty. Distinct from FontePinMissing (where
9603        // every axis is None) — pinned separately so a future
9604        // tightening collapsing them surfaces here as a structural
9605        // decision.
9606        let d = dep_with_fonte(DepSource::Git {
9607            repo: "github:pleme-io/caixa-teia".into(),
9608            tag: Some(String::new()),
9609            rev: None,
9610            branch: None,
9611        });
9612        let err = d.validate().unwrap_err();
9613        let DepError::FontePinEmpty { nome, pin } = err else {
9614            panic!("expected FontePinEmpty");
9615        };
9616        assert_eq!(nome, "caixa-teia");
9617        assert_eq!(pin, ":tag");
9618    }
9619
9620    #[test]
9621    fn validate_rejects_git_fonte_with_empty_rev_pin() {
9622        // Sibling arm — the empty-pin diagnostic names which axis
9623        // carries the empty value, so the author's grep target is
9624        // unambiguous.
9625        let d = dep_with_fonte(DepSource::Git {
9626            repo: "github:pleme-io/caixa-teia".into(),
9627            tag: None,
9628            rev: Some(String::new()),
9629            branch: None,
9630        });
9631        let err = d.validate().unwrap_err();
9632        let DepError::FontePinEmpty { nome, pin } = err else {
9633            panic!("expected FontePinEmpty");
9634        };
9635        assert_eq!(nome, "caixa-teia");
9636        assert_eq!(pin, ":rev");
9637    }
9638
9639    #[test]
9640    fn validate_rejects_path_fonte_with_empty_caminho() {
9641        // The fail-before-pass-after pin for `(:tipo path :caminho "")`:
9642        // until this gate landed the resolver's
9643        // ResolveError::MissingPath surfaced with `path: PathBuf("")` at
9644        // fetch time — not actionable. The new gate moves the check to
9645        // validate time and names the offending dep.
9646        let d = dep_with_fonte(DepSource::Path {
9647            caminho: String::new(),
9648        });
9649        let err = d.validate().unwrap_err();
9650        assert!(
9651            matches!(err, DepError::FonteCaminhoEmpty { ref nome } if nome == "caixa-teia"),
9652            "got {err:?}"
9653        );
9654    }
9655
9656    #[test]
9657    fn validate_rejects_path_fonte_with_absolute_caminho() {
9658        // The fail-before-pass-after pin for the absolute-`:caminho`
9659        // shape: `(:tipo path :caminho "/home/me/work/caixa-teia")`.
9660        // Until this gate landed an absolute `:caminho` silently
9661        // passed validate; the lacre pipeline embedded the
9662        // host-specific filesystem path verbatim in its
9663        // content-address (`conteudo: format!("path:{caminho}")`,
9664        // caixa-resolver/src/resolve.rs:189), so the BLAKE3 closure
9665        // differed per machine — the build succeeded but two CI
9666        // runners with different `${HOME}` layouts emitted two
9667        // distinct lacres for the byte-identical caixa, silently
9668        // breaking the THEORY.md §V.2 render-determinism contract
9669        // far from the source caixa.lisp. The new gate moves the
9670        // check to validate time and names the offending dep +
9671        // caminho verbatim.
9672        let d = dep_with_fonte(DepSource::Path {
9673            caminho: "/home/me/work/caixa-teia".into(),
9674        });
9675        let err = d.validate().unwrap_err();
9676        let DepError::FonteCaminhoAbsolute { nome, caminho } = err else {
9677            panic!("expected FonteCaminhoAbsolute, got other variant");
9678        };
9679        assert_eq!(nome, "caixa-teia");
9680        assert_eq!(caminho, "/home/me/work/caixa-teia");
9681    }
9682
9683    #[test]
9684    fn validate_accepts_path_fonte_with_parent_escape_caminho() {
9685        // The canonical sibling-workspace dep form
9686        // (`:caminho "../caixa-teia"`) remains accepted. The
9687        // absolute-path gate above is specifically narrower than the
9688        // shared [`crate::render::is_sandboxed_relative_path`]
9689        // predicate (which additionally forbids `..` traversal): a
9690        // local-path dep's canonical author surface is the in-tree
9691        // sibling-workspace path, so a full sandboxed-relative-path
9692        // lift would structurally reject every legitimate path-fonte
9693        // dep. Pinned so a future tightening to the full predicate
9694        // surfaces here as a structural decision, not a silent break.
9695        let d = dep_with_fonte(DepSource::Path {
9696            caminho: "../caixa-teia".into(),
9697        });
9698        d.validate().unwrap();
9699    }
9700
9701    #[test]
9702    fn validate_accepts_path_fonte_with_deeply_nested_relative_caminho() {
9703        // A multi-segment relative `:caminho`
9704        // (`"vendor/forks/caixa-teia"`) remains accepted — the
9705        // absolute-path gate brackets the host-layout-leaking shape
9706        // at the leading-`/` boundary only; every relative shape past
9707        // the empty arm continues to pass. Pinned alongside the
9708        // `..`-traversal positive control so a future tightening
9709        // surfaces the full set of legitimate relative forms here
9710        // rather than at a downstream consumer.
9711        let d = dep_with_fonte(DepSource::Path {
9712            caminho: "vendor/forks/caixa-teia".into(),
9713        });
9714        d.validate().unwrap();
9715    }
9716
9717    #[test]
9718    fn validate_rejects_path_fonte_with_tilde_prefix_caminho() {
9719        // The fail-before-pass-after pin for the tilde-expansion
9720        // `:caminho` shape: `(:tipo path :caminho "~/work/caixa-teia")`.
9721        // Until this gate landed the b94fd83 absolute arm let `~/foo`
9722        // through (`Path::is_absolute` returns false on a leading `~`
9723        // — the tilde is a shell-expansion convention, not a POSIX
9724        // path component), so the lacre embedded the value verbatim
9725        // and the resolver folded it through `Path::join` without
9726        // expansion, looking for a literal `./~/work/caixa-teia`
9727        // subdirectory and failing at resolve time with a
9728        // `No such file or directory` error far from the source
9729        // caixa.lisp. The new gate moves the check to validate time
9730        // and names the offending dep + caminho verbatim.
9731        let d = dep_with_fonte(DepSource::Path {
9732            caminho: "~/work/caixa-teia".into(),
9733        });
9734        let err = d.validate().unwrap_err();
9735        let DepError::FonteCaminhoTildeExpansion { nome, caminho } = err else {
9736            panic!("expected FonteCaminhoTildeExpansion, got {err:?}");
9737        };
9738        assert_eq!(nome, "caixa-teia");
9739        assert_eq!(caminho, "~/work/caixa-teia");
9740    }
9741
9742    #[test]
9743    fn validate_rejects_path_fonte_with_bare_tilde_caminho() {
9744        // The bare `~` form (canonical "I meant `$HOME` and forgot
9745        // the rest"): both the leading-tilde arm catches it and the
9746        // canonical-user-tilde shell idiom (`~alice/dev/caixa-teia`)
9747        // sweeps through the same arm. Pinned both to ensure the
9748        // gate doesn't narrow to `~/` only.
9749        for s in ["~", "~alice/dev/caixa-teia", "~/", "~root/work"] {
9750            let d = dep_with_fonte(DepSource::Path { caminho: s.into() });
9751            let err = d.validate().unwrap_err();
9752            assert!(
9753                matches!(err, DepError::FonteCaminhoTildeExpansion { .. }),
9754                "{s:?} → {err:?}",
9755            );
9756        }
9757    }
9758
9759    #[test]
9760    fn validate_accepts_path_fonte_with_mid_path_tilde_caminho() {
9761        // The leading-`~` is the canonical shell-expansion footgun —
9762        // a tilde mid-path (`"../foo~bar/caixa-teia"` — the canonical
9763        // backup-file-suffix idiom) is a legitimate POSIX path byte
9764        // with no shell-expansion semantic at the leading position.
9765        // Pinned so the gate doesn't widen to a full no-tilde-anywhere
9766        // sweep that would break every legitimate-shape backup-file
9767        // path.
9768        let d = dep_with_fonte(DepSource::Path {
9769            caminho: "../foo~bar/caixa-teia".into(),
9770        });
9771        d.validate().unwrap();
9772    }
9773
9774    #[test]
9775    fn fonte_caminho_empty_fires_before_tilde_expansion() {
9776        // Cascade pin: the empty arm structurally precedes the
9777        // tilde arm (the bytes `""` and `"~"` don't overlap), but the
9778        // pin establishes the precedence at the diagnostic-shape
9779        // level should a future codec round-trip ever produce a
9780        // probe-as-both value. Mirrors the peer
9781        // `fonte_repo_empty_fires_before_pin_missing` cascade
9782        // discipline.
9783        let d = dep_with_fonte(DepSource::Path {
9784            caminho: String::new(),
9785        });
9786        let err = d.validate().unwrap_err();
9787        assert!(
9788            matches!(err, DepError::FonteCaminhoEmpty { .. }),
9789            "got {err:?}",
9790        );
9791    }
9792
9793    #[test]
9794    fn fonte_caminho_tilde_diagnostic_carries_offending_dep_and_caminho() {
9795        // Diagnostic-shape pin (peer with
9796        // `validate_rejects_path_fonte_with_absolute_caminho`'s
9797        // payload assertion): the error's Display surfaces both the
9798        // offending `:nome` and the offending `:caminho` verbatim
9799        // so a `feira lint` run can render the diagnostic without
9800        // re-parsing.
9801        let d = dep_with_fonte(DepSource::Path {
9802            caminho: "~alice/dev/caixa-teia".into(),
9803        });
9804        let rendered = d.validate().unwrap_err().to_string();
9805        assert!(
9806            rendered.contains("caixa-teia"),
9807            "diagnostic must name the offending dep: {rendered}",
9808        );
9809        assert!(
9810            rendered.contains("~alice/dev/caixa-teia"),
9811            "diagnostic must quote the offending caminho: {rendered}",
9812        );
9813        assert!(
9814            rendered.contains('~'),
9815            "diagnostic must reference the tilde footgun: {rendered}",
9816        );
9817    }
9818
9819    #[test]
9820    fn validate_rejects_path_fonte_with_dollar_prefix_caminho() {
9821        // The fail-before-pass-after pin for the shell-variable-
9822        // expansion `:caminho` shape: `(:tipo path :caminho
9823        // "$HOME/work/caixa-teia")`. Until this gate landed the
9824        // b94fd83 absolute arm + the a5c248e tilde arm both let
9825        // `$HOME/foo` through (`Path::is_absolute` returns false on
9826        // a leading `$` — the `$` is a shell convention, not a POSIX
9827        // path component; `starts_with('~')` returns false too), so
9828        // the lacre embedded the value verbatim and the resolver
9829        // folded it through `Path::join` without `$`-expansion,
9830        // looking for a literal `./$HOME/work/caixa-teia`
9831        // subdirectory and failing at resolve time with a
9832        // `No such file or directory` error far from the source
9833        // caixa.lisp. The new gate moves the check to validate time
9834        // and names the offending dep + caminho verbatim.
9835        let d = dep_with_fonte(DepSource::Path {
9836            caminho: "$HOME/work/caixa-teia".into(),
9837        });
9838        let err = d.validate().unwrap_err();
9839        let DepError::FonteCaminhoVarExpansion { nome, caminho } = err else {
9840            panic!("expected FonteCaminhoVarExpansion, got {err:?}");
9841        };
9842        assert_eq!(nome, "caixa-teia");
9843        assert_eq!(caminho, "$HOME/work/caixa-teia");
9844    }
9845
9846    #[test]
9847    fn validate_rejects_path_fonte_with_dollar_brace_prefix_caminho() {
9848        // Sweep over every leading-`$` shape: the `${VAR}`-braced
9849        // form (canonical "paste-from-CI-manifest" footgun every
9850        // GitHub Actions / GitLab CI / Drone manifest carries on
9851        // `${WORKSPACE}`), the XDG idiom (`$XDG_CONFIG_HOME/caixa`,
9852        // canonical "I'm referencing a per-user config dir"),
9853        // and the bare `$` (canonical "I meant `$HOME` and forgot
9854        // the rest"). All shapes route through the same gate's
9855        // byte check. Pinned so the gate doesn't narrow to a
9856        // single shape (e.g. `$HOME/` only).
9857        for s in [
9858            "${HOME}/work/caixa-teia",
9859            "${WORKSPACE}/caixa-teia",
9860            "$XDG_CONFIG_HOME/caixa",
9861            "$",
9862        ] {
9863            let d = dep_with_fonte(DepSource::Path { caminho: s.into() });
9864            let err = d.validate().unwrap_err();
9865            assert!(
9866                matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
9867                "{s:?} → {err:?}",
9868            );
9869        }
9870    }
9871
9872    #[test]
9873    fn validate_rejects_path_fonte_with_mid_path_dollar_caminho() {
9874        // The `$` byte is the canonical shell-variable-expansion /
9875        // command-substitution / arithmetic-expansion sentinel and
9876        // is rejected at *every* position on the `:caminho` axis: the
9877        // leading arm surfaces `FonteCaminhoVarExpansion`, the
9878        // embedded arm surfaces `FonteCaminhoShellVariableExpansion`
9879        // (6620f39). Pinned so a future arm doesn't narrow the gate
9880        // back to the leading position and re-open the paste-from-
9881        // shell-one-liner `"../foo$HOME/bar"` / paste-from-CI-
9882        // manifest `"../foo${WORKSPACE}/bar"` / paste-from-shell-
9883        // prompt `"../foo$(whoami)/bar"` cross-idiom-leak surface on
9884        // the lacre content-address (`path:{caminho}`,
9885        // caixa-resolver/src/resolve.rs:189).
9886        let d = dep_with_fonte(DepSource::Path {
9887            caminho: "../foo$bar/caixa-teia".into(),
9888        });
9889        let err = d.validate().unwrap_err();
9890        assert!(
9891            matches!(
9892                err,
9893                DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
9894            ),
9895            "got {err:?}",
9896        );
9897    }
9898
9899    #[test]
9900    fn fonte_caminho_tilde_fires_before_var_expansion() {
9901        // Cascade pin: the tilde arm structurally precedes the var
9902        // arm (the bytes `~` and `$` don't overlap at the leading
9903        // position), but the pin establishes the precedence at the
9904        // diagnostic-shape level should a future codec round-trip
9905        // ever produce a probe-as-both value. Mirrors the peer
9906        // `fonte_caminho_empty_fires_before_tilde_expansion` cascade
9907        // discipline on the immediate-predecessor arm.
9908        let d = dep_with_fonte(DepSource::Path {
9909            caminho: "~/work/caixa-teia".into(),
9910        });
9911        let err = d.validate().unwrap_err();
9912        assert!(
9913            matches!(err, DepError::FonteCaminhoTildeExpansion { .. }),
9914            "got {err:?}",
9915        );
9916    }
9917
9918    #[test]
9919    fn fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho() {
9920        // Diagnostic-shape pin (peer with
9921        // `fonte_caminho_tilde_diagnostic_carries_offending_dep_and_caminho`'s
9922        // payload assertion on the immediate-predecessor arm): the
9923        // error's Display surfaces both the offending `:nome` and
9924        // the offending `:caminho` verbatim plus the `$` footgun
9925        // character itself so a `feira lint` run can render the
9926        // diagnostic without re-parsing.
9927        let d = dep_with_fonte(DepSource::Path {
9928            caminho: "${WORKSPACE}/caixa-teia".into(),
9929        });
9930        let rendered = d.validate().unwrap_err().to_string();
9931        assert!(
9932            rendered.contains("caixa-teia"),
9933            "diagnostic must name the offending dep: {rendered}",
9934        );
9935        assert!(
9936            rendered.contains("${WORKSPACE}/caixa-teia"),
9937            "diagnostic must quote the offending caminho: {rendered}",
9938        );
9939        assert!(
9940            rendered.contains('$'),
9941            "diagnostic must reference the dollar footgun: {rendered}",
9942        );
9943    }
9944
9945    #[test]
9946    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_nul() {
9947        // The fail-before-pass-after pin for the load-bearing NUL byte:
9948        // POSIX paths cannot contain `0x00` (every `std::fs` syscall
9949        // routes the path through `CString::new` which fails with
9950        // `NulError`); until this gate landed a `:caminho
9951        // "../caixa\0teia"` silently passed validate, the lacre
9952        // pipeline embedded the value verbatim, and the failure
9953        // surfaced at the resolver's `Path::join` → `CString::new`
9954        // boundary with a non-self-locating `NulError` far from the
9955        // source caixa.lisp. The new gate moves the check to validate
9956        // time and names the offending dep + caminho + offending byte
9957        // verbatim.
9958        let d = dep_with_fonte(DepSource::Path {
9959            caminho: "../caixa\0teia".into(),
9960        });
9961        let err = d.validate().unwrap_err();
9962        let DepError::FonteCaminhoControlChar {
9963            nome,
9964            caminho,
9965            byte,
9966        } = err
9967        else {
9968            panic!("expected FonteCaminhoControlChar, got {err:?}");
9969        };
9970        assert_eq!(nome, "caixa-teia");
9971        assert_eq!(caminho, "../caixa\0teia");
9972        assert_eq!(byte, 0x00);
9973    }
9974
9975    #[test]
9976    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_newline() {
9977        // The canonical paste-from-multiline-doc footgun on `:caminho`
9978        // — author copies `"../caixa-teia\n"` (trailing newline) out
9979        // of a multi-line code-fence or, worse, a `:caminho
9980        // "../caixa-teia\nrm -rf /"` value (CRLF-at-subprocess-argument
9981        // injection sibling on the path axis the `is_git_repo_url`
9982        // control-char arm already closes on `:repo`). Pinned
9983        // separately from the NUL arm so a future relaxation that
9984        // catches one but not the other surfaces here.
9985        let d = dep_with_fonte(DepSource::Path {
9986            caminho: "../caixa-teia\n".into(),
9987        });
9988        let err = d.validate().unwrap_err();
9989        let DepError::FonteCaminhoControlChar { byte, .. } = err else {
9990            panic!("expected FonteCaminhoControlChar, got {err:?}");
9991        };
9992        assert_eq!(byte, 0x0A);
9993    }
9994
9995    #[test]
9996    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_carriage_return() {
9997        // The CRLF sibling of the LF arm — Windows-line-ending
9998        // paste-from-multiline-doc on a `\r\n`-terminated buffer
9999        // leaves a stray `\r` mid-string after the LF strip. Pinned
10000        // separately from the LF arm so a future relaxation that
10001        // only catches LF surfaces here.
10002        let d = dep_with_fonte(DepSource::Path {
10003            caminho: "../caixa-teia\r".into(),
10004        });
10005        let err = d.validate().unwrap_err();
10006        let DepError::FonteCaminhoControlChar { byte, .. } = err else {
10007            panic!("expected FonteCaminhoControlChar, got {err:?}");
10008        };
10009        assert_eq!(byte, 0x0D);
10010    }
10011
10012    #[test]
10013    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_tab() {
10014        // The canonical paste-from-aligned-table footgun — a `\t`
10015        // mid-`:caminho` is invisible in most editors but rides
10016        // through the lacre's content-address verbatim, so two
10017        // paste-from-distinct-tables (one editor strips tabs, one
10018        // preserves them) yield divergent lacres for the byte-
10019        // identical-looking caixa. Pinned separately from the
10020        // whitespace-shaped LF/CR arms so a future relaxation that
10021        // narrows to line-terminator-only surfaces here.
10022        let d = dep_with_fonte(DepSource::Path {
10023            caminho: "../caixa\tteia".into(),
10024        });
10025        let err = d.validate().unwrap_err();
10026        let DepError::FonteCaminhoControlChar { byte, .. } = err else {
10027            panic!("expected FonteCaminhoControlChar, got {err:?}");
10028        };
10029        assert_eq!(byte, 0x09);
10030    }
10031
10032    #[test]
10033    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_del() {
10034        // The DEL byte (`0x7F`) closes the upper-end paste-from-
10035        // binary-blob footgun — the gate's contract is `b < 0x20 ||
10036        // b == 0x7F`, matching the `is_git_repo_url` /
10037        // `is_git_ref_name` predicates' control-char arms. Pinned
10038        // separately from the lower-range arms so a future narrowing
10039        // to `< 0x20` only surfaces here.
10040        let d = dep_with_fonte(DepSource::Path {
10041            caminho: "../caixa\x7fteia".into(),
10042        });
10043        let err = d.validate().unwrap_err();
10044        let DepError::FonteCaminhoControlChar { byte, .. } = err else {
10045            panic!("expected FonteCaminhoControlChar, got {err:?}");
10046        };
10047        assert_eq!(byte, 0x7F);
10048    }
10049
10050    #[test]
10051    fn validate_accepts_path_fonte_with_caminho_carrying_high_bit_utf8() {
10052        // The control-byte arm targets `0x00..=0x1F` + `0x7F` only —
10053        // high-bit / non-ASCII UTF-8 bytes are not gated. POSIX paths
10054        // are opaque byte sequences and UTF-8 multi-byte sequences
10055        // are a legitimate filename shape (the `café-teia/foo` idiom).
10056        // Pinned so the gate doesn't widen to a full ASCII-only sweep
10057        // that would break every legitimate-shape UTF-8 path.
10058        let d = dep_with_fonte(DepSource::Path {
10059            caminho: "../café-teia/foo".into(),
10060        });
10061        d.validate().unwrap();
10062    }
10063
10064    #[test]
10065    fn fonte_caminho_var_fires_before_control_char() {
10066        // Cascade pin: the var-expansion arm structurally precedes the
10067        // control-char arm. A value like `"$\n"` probes positive on
10068        // both arms (`starts_with('$')` and contains LF), but the
10069        // narrower leading-byte diagnostic (`FonteCaminhoVarExpansion`)
10070        // wins so the author sees the more self-locating shell-
10071        // expansion arm first. Mirrors the
10072        // `fonte_caminho_tilde_fires_before_var_expansion` cascade
10073        // discipline on the immediate-predecessor arm.
10074        let d = dep_with_fonte(DepSource::Path {
10075            caminho: "$HOME\n".into(),
10076        });
10077        let err = d.validate().unwrap_err();
10078        assert!(
10079            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
10080            "got {err:?}",
10081        );
10082    }
10083
10084    #[test]
10085    fn validate_rejects_path_fonte_with_leading_space_caminho() {
10086        // The fail-before-pass-after pin for the leading ASCII space
10087        // `:caminho` shape: `(:tipo path :caminho " ../caixa-teia")`.
10088        // Until this gate landed the b94fd83 absolute arm + the a5c248e
10089        // tilde arm + the f4efe9c var arm + the d624c8d control-byte arm
10090        // all let `" ../caixa-teia"` through: `Path::is_absolute` returns
10091        // false on a leading space (the leading byte is `0x20`, not `0x2F`),
10092        // `starts_with('~')` / `starts_with('$')` return false, and `0x20`
10093        // is not in the `0x00..=0x1F` plus `0x7F` control-byte set (the
10094        // four ASCII whitespace bytes `0x09` tab, `0x0A` LF, `0x0D` CR
10095        // are caught, but the most common whitespace `0x20` space is
10096        // not). The lacre embedded the value verbatim and the resolver
10097        // folded it through `Path::join` looking for a literal `./ ../
10098        // caixa-teia` subdirectory and failing at resolve time with a
10099        // non-self-locating `No such file or directory` error far from
10100        // the source caixa.lisp. The new gate moves the check to
10101        // validate time and names the offending dep + caminho verbatim.
10102        let d = dep_with_fonte(DepSource::Path {
10103            caminho: " ../caixa-teia".into(),
10104        });
10105        let err = d.validate().unwrap_err();
10106        let DepError::FonteCaminhoLeadingWhitespace { nome, caminho } = err else {
10107            panic!("expected FonteCaminhoLeadingWhitespace, got {err:?}");
10108        };
10109        assert_eq!(nome, "caixa-teia");
10110        assert_eq!(caminho, " ../caixa-teia");
10111    }
10112
10113    #[test]
10114    fn validate_rejects_path_fonte_with_multiple_leading_spaces_caminho() {
10115        // The aligned-doc paste footgun sweep: more than one leading
10116        // space (`"   ../caixa-teia"` — the canonical "I selected the
10117        // aligned column from a four-`:fonte`-entry `:deps` block"
10118        // paste) routes through the same gate's `starts_with(' ')`
10119        // byte check. Pinned so the gate doesn't narrow to a
10120        // single-space prefix.
10121        let d = dep_with_fonte(DepSource::Path {
10122            caminho: "   ../caixa-teia".into(),
10123        });
10124        let err = d.validate().unwrap_err();
10125        assert!(
10126            matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
10127            "got {err:?}",
10128        );
10129    }
10130
10131    #[test]
10132    fn validate_accepts_path_fonte_with_mid_path_space_caminho() {
10133        // The leading-space is the canonical paste-from-aligned-doc
10134        // footgun — a space mid-path (`"../my dir/caixa-teia"` — the
10135        // canonical "I have a directory with a space in its name"
10136        // idiom; ASCII `0x20` is a valid POSIX filename byte) is a
10137        // legitimate path with no whitespace-leak semantic at the
10138        // non-leading position. Pinned so the gate doesn't widen to a
10139        // full no-space-anywhere sweep that would break every
10140        // legitimate-shape space-in-filename path.
10141        let d = dep_with_fonte(DepSource::Path {
10142            caminho: "../my dir/caixa-teia".into(),
10143        });
10144        d.validate().unwrap();
10145    }
10146
10147    #[test]
10148    fn fonte_caminho_var_fires_before_leading_whitespace() {
10149        // Cascade pin: the var-expansion arm structurally precedes the
10150        // leading-whitespace arm. A value like `"$ "` would probe positive
10151        // on var (`starts_with('$')`) but the leading-byte arms walk
10152        // left-to-right so the var arm fires on the leading `$` before
10153        // the leading-whitespace arm probes. Mirrors the
10154        // `fonte_caminho_tilde_fires_before_var_expansion` cascade
10155        // discipline on the immediate-predecessor arms.
10156        let d = dep_with_fonte(DepSource::Path {
10157            caminho: "$VAR".into(),
10158        });
10159        let err = d.validate().unwrap_err();
10160        assert!(
10161            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
10162            "got {err:?}",
10163        );
10164    }
10165
10166    #[test]
10167    fn fonte_caminho_leading_whitespace_fires_before_control_char() {
10168        // Cascade pin: the leading-whitespace arm structurally precedes
10169        // the control-char arm. A value like `" ../foo\n"` probes
10170        // positive on both (starts with space AND contains LF), but
10171        // the narrower leading-byte diagnostic
10172        // (`FonteCaminhoLeadingWhitespace`) wins so the author sees the
10173        // more self-locating paste-from-aligned-doc arm first. Mirrors
10174        // the `fonte_caminho_var_fires_before_control_char` cascade
10175        // discipline on the immediate-predecessor arm.
10176        let d = dep_with_fonte(DepSource::Path {
10177            caminho: " ../foo\n".into(),
10178        });
10179        let err = d.validate().unwrap_err();
10180        assert!(
10181            matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
10182            "got {err:?}",
10183        );
10184    }
10185
10186    #[test]
10187    fn fonte_caminho_leading_whitespace_diagnostic_carries_offending_dep_and_caminho() {
10188        // Diagnostic-shape pin (peer with
10189        // `fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho`'s
10190        // payload assertion on the immediate-predecessor arm): the
10191        // error's Display surfaces both the offending `:nome` and the
10192        // offending `:caminho` verbatim, so a `feira lint` run can
10193        // render the diagnostic without re-parsing and the author can
10194        // grep their caixa.lisp for `:caminho "<value>"` and fix it in
10195        // one edit.
10196        let d = dep_with_fonte(DepSource::Path {
10197            caminho: " ../caixa-teia".into(),
10198        });
10199        let rendered = d.validate().unwrap_err().to_string();
10200        assert!(
10201            rendered.contains("caixa-teia"),
10202            "diagnostic must name the offending dep: {rendered}",
10203        );
10204        assert!(
10205            rendered.contains(" ../caixa-teia"),
10206            "diagnostic must quote the offending caminho: {rendered}",
10207        );
10208        assert!(
10209            rendered.contains("space"),
10210            "diagnostic must name the space footgun: {rendered}",
10211        );
10212    }
10213
10214    #[test]
10215    fn fonte_caminho_absolute_fires_before_control_char() {
10216        // Cascade pin on the sibling leading-byte arm: a leading `/`
10217        // value with embedded control byte (`"/etc/passwd\n"`) routes
10218        // through `FonteCaminhoAbsolute` not `FonteCaminhoControlChar`
10219        // — the host-layout-leak diagnostic is the load-bearing axis,
10220        // the control byte is the secondary observation. Same precedence
10221        // logic on every prior leading-byte arm.
10222        let d = dep_with_fonte(DepSource::Path {
10223            caminho: "/etc/passwd\n".into(),
10224        });
10225        let err = d.validate().unwrap_err();
10226        assert!(
10227            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10228            "got {err:?}",
10229        );
10230    }
10231
10232    #[test]
10233    fn validate_rejects_path_fonte_with_leading_hyphen_caminho() {
10234        // The fail-before-pass-after pin for the leading-`-` CLI-arg-
10235        // injection `:caminho` shape sweep. Until this gate landed
10236        // every prior leading-byte arm passed a leading-`-` value
10237        // through: `Path::is_absolute` returns false on `-` (the
10238        // leading byte is `0x2D`, not `0x2F`), `starts_with('~')` /
10239        // `starts_with('$')` / `starts_with(' ')` all return false,
10240        // and `0x2D` sits outside the control-byte set. The lacre
10241        // embedded the value verbatim and the resolver folded it
10242        // through `Path::join` looking for a literal `./-rf` /
10243        // `./-C` / `./--upload-pack=…` subdirectory; the failure at
10244        // `Path::join` time is non-self-locating but harmless, while
10245        // the failure at every downstream `git -C {caminho}` /
10246        // `terraform -chdir={caminho}` / `find {caminho}` shell-out
10247        // is arbitrary-CLI-arg-injection because none of those
10248        // porcelains carry a `--` argument-list terminator between
10249        // the flag block and the path argument. The new arm moves the
10250        // rejection to `Caixa::from_lisp` boundary time and names
10251        // the offending dep + caminho verbatim.
10252        //
10253        // Sweep spans the canonical CLI-arg-injection shapes matching
10254        // the peer sweep on the sibling `is_git_ref_name` /
10255        // `is_git_repo_url` axes: short-flag `-rf` (the `rm -rf` /
10256        // `find -rf` reinterpretation vector), `-C` (the `git -C`
10257        // change-directory-config-injection paste), long-flag
10258        // `--upload-pack=cat /etc/passwd` (the canonical
10259        // arbitrary-command-execution vector on every git porcelain
10260        // entry point), git-config-injection `--config=core.merge=ours`,
10261        // and the degenerate single-byte `-` value.
10262        for caminho in [
10263            "-rf",
10264            "-C",
10265            "--upload-pack=cat /etc/passwd",
10266            "--config=core.merge=ours",
10267            "-",
10268        ] {
10269            let d = dep_with_fonte(DepSource::Path {
10270                caminho: caminho.into(),
10271            });
10272            let err = d.validate().unwrap_err();
10273            let DepError::FonteCaminhoLeadingHyphen { nome, caminho: got } = err else {
10274                panic!("expected FonteCaminhoLeadingHyphen for {caminho:?}, got {err:?}");
10275            };
10276            assert_eq!(nome, "caixa-teia");
10277            assert_eq!(got, caminho);
10278        }
10279    }
10280
10281    #[test]
10282    fn validate_accepts_path_fonte_with_mid_path_hyphen_caminho() {
10283        // The leading-`-` is the canonical CLI-arg-injection footgun
10284        // — a `-` anywhere else in the path (`"../caixa-teia"` — the
10285        // canonical kebab-separator-between-alphanumeric-segments
10286        // shape every DNS-1123-shaped caixa name carries; `"../-hidden"`
10287        // — a mid-path segment starting with `-`, still a legitimate
10288        // POSIX filename byte at that non-leading position because the
10289        // subprocess reads the whole `{caminho}` value as one positional
10290        // argument, so only the very first byte of the composite path
10291        // string is at the CLI-arg-injection boundary) is a legitimate
10292        // path with no CLI-flag-reinterpretation semantic at the non-
10293        // leading position of the top-level value. Pinned so the gate
10294        // doesn't widen to a full no-`-`-anywhere sweep that would
10295        // break every legitimate-shape kebab-in-filename path (i.e.
10296        // essentially every sibling-workspace caixa dep).
10297        for caminho in [
10298            "../caixa-teia",
10299            "../caixa-teia/-hidden",
10300            "./my-lib",
10301            "../foo-bar/baz",
10302        ] {
10303            let d = dep_with_fonte(DepSource::Path {
10304                caminho: caminho.into(),
10305            });
10306            d.validate()
10307                .unwrap_or_else(|e| panic!("mid-path `-` caminho {caminho:?} must pass: {e:?}"));
10308        }
10309    }
10310
10311    #[test]
10312    fn fonte_caminho_leading_whitespace_fires_before_leading_hyphen() {
10313        // Cascade pin: the leading-whitespace arm structurally precedes
10314        // the leading-hyphen arm. A value like `" -rf"` probes positive
10315        // on both (leading space AND, one byte in, a `-` — though the
10316        // leading-hyphen arm probes only the very first byte so it
10317        // wouldn't fire on this value; the pin instead documents the
10318        // arm order on the more common "leading space then a hyphen"
10319        // paste-from-aligned-doc paste-flag-shell-one-liner idiom).
10320        // The narrower leading-space diagnostic (the paste-from-aligned-
10321        // doc footgun) wins so the author sees the more self-locating
10322        // whitespace arm first. Mirrors the
10323        // `fonte_caminho_var_fires_before_leading_whitespace` cascade
10324        // discipline on the immediate-predecessor arm.
10325        let d = dep_with_fonte(DepSource::Path {
10326            caminho: " -rf".into(),
10327        });
10328        let err = d.validate().unwrap_err();
10329        assert!(
10330            matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
10331            "got {err:?}",
10332        );
10333    }
10334
10335    #[test]
10336    fn fonte_caminho_leading_hyphen_fires_before_control_char() {
10337        // Cascade pin: the leading-hyphen arm structurally precedes
10338        // the control-char arm. A value like `"-rf\n"` probes positive
10339        // on both (starts with `-` AND contains LF), but the narrower
10340        // leading-byte diagnostic (`FonteCaminhoLeadingHyphen`) wins so
10341        // the author sees the more self-locating CLI-arg-injection arm
10342        // first. Mirrors the
10343        // `fonte_caminho_leading_whitespace_fires_before_control_char`
10344        // cascade discipline on the immediate-predecessor arm.
10345        let d = dep_with_fonte(DepSource::Path {
10346            caminho: "-rf\n".into(),
10347        });
10348        let err = d.validate().unwrap_err();
10349        assert!(
10350            matches!(err, DepError::FonteCaminhoLeadingHyphen { .. }),
10351            "got {err:?}",
10352        );
10353    }
10354
10355    #[test]
10356    fn fonte_caminho_leading_hyphen_diagnostic_carries_offending_dep_and_caminho() {
10357        // Diagnostic-shape pin (peer with
10358        // `fonte_caminho_leading_whitespace_diagnostic_carries_offending_dep_and_caminho`'s
10359        // payload assertion on the immediate-predecessor arm): the
10360        // error's Display surfaces both the offending `:nome` and the
10361        // offending `:caminho` verbatim plus the CLI-argument-injection
10362        // vocabulary, so a `feira lint` run can render the diagnostic
10363        // without re-parsing and the author can grep their caixa.lisp
10364        // for `:caminho "<value>"` and fix it in one edit.
10365        let d = dep_with_fonte(DepSource::Path {
10366            caminho: "--upload-pack=cat /etc/passwd".into(),
10367        });
10368        let rendered = d.validate().unwrap_err().to_string();
10369        assert!(
10370            rendered.contains("caixa-teia"),
10371            "diagnostic must name the offending dep: {rendered}",
10372        );
10373        assert!(
10374            rendered.contains("--upload-pack=cat /etc/passwd"),
10375            "diagnostic must quote the offending caminho: {rendered}",
10376        );
10377        assert!(
10378            rendered.contains("CLI-argument-injection"),
10379            "diagnostic must name the CLI-argument-injection vector: {rendered}",
10380        );
10381        assert!(
10382            rendered.contains("`-`"),
10383            "diagnostic must name the offending byte: {rendered}",
10384        );
10385    }
10386
10387    #[test]
10388    fn fonte_caminho_control_diagnostic_carries_offending_dep_caminho_byte() {
10389        // Diagnostic-shape pin (peer with
10390        // `fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho`'s
10391        // payload assertion on the immediate-predecessor arm): the
10392        // error's Display surfaces the offending `:nome`, the
10393        // offending `:caminho` verbatim, and the offending byte in
10394        // hex form (`0x09` for tab) so a `feira lint` run can render
10395        // the diagnostic without re-parsing.
10396        let d = dep_with_fonte(DepSource::Path {
10397            caminho: "../caixa\tteia".into(),
10398        });
10399        let rendered = d.validate().unwrap_err().to_string();
10400        assert!(
10401            rendered.contains("caixa-teia"),
10402            "diagnostic must name the offending dep: {rendered}",
10403        );
10404        assert!(
10405            rendered.contains("../caixa\tteia"),
10406            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10407        );
10408        assert!(
10409            rendered.contains("0x09"),
10410            "diagnostic must name the offending byte in hex: {rendered:?}",
10411        );
10412    }
10413
10414    #[test]
10415    fn validate_rejects_path_fonte_with_caminho_carrying_backslash() {
10416        // The fail-before-pass-after pin for the canonical Windows-
10417        // path-separator paste footgun: an author who pastes a path
10418        // from Windows-Explorer's `Copy as path`, PowerShell's
10419        // `Get-Location`, or any CMD/Cygwin/MSYS shell prompt
10420        // produces `..\caixa-teia`-shape values that silently passed
10421        // every prior arm (`Path::is_absolute("..\\caixa-teia")` is
10422        // false; `\` is neither a leading-byte sentinel nor a
10423        // control byte). On POSIX resolvers the value rides through
10424        // `Path::join` as a literal directory name and fails at
10425        // resolve time with `No such file or directory`; on Windows
10426        // resolvers the value resolves to the parent's sibling — two
10427        // distinct directories for the byte-identical caixa.lisp.
10428        // The new arm moves the rejection to validate time and names
10429        // the offending dep + caminho verbatim.
10430        let d = dep_with_fonte(DepSource::Path {
10431            caminho: "..\\caixa-teia".into(),
10432        });
10433        let err = d.validate().unwrap_err();
10434        let DepError::FonteCaminhoBackslash { nome, caminho } = err else {
10435            panic!("expected FonteCaminhoBackslash, got {err:?}");
10436        };
10437        assert_eq!(nome, "caixa-teia");
10438        assert_eq!(caminho, "..\\caixa-teia");
10439    }
10440
10441    #[test]
10442    fn validate_rejects_path_fonte_with_caminho_carrying_windows_drive_letter() {
10443        // The Windows drive-letter paste shape (`C:\work\caixa-teia`
10444        // out of Explorer / `cd`-and-`pwd`-on-Windows). On POSIX
10445        // hosts `Path::is_absolute("C:\\work\\caixa-teia")` returns
10446        // false (POSIX absolute paths start with `/`, drive letters
10447        // are not a POSIX concept), so the b94fd83 absolute arm
10448        // doesn't fire; the value contains `\` bytes that this arm
10449        // now catches with the more self-locating Windows-path-
10450        // separator diagnostic. Pinned separately from the bare
10451        // `..\caixa-teia` shape so a future arm that targets only
10452        // leading-`..\` doesn't regress the drive-letter coverage.
10453        let d = dep_with_fonte(DepSource::Path {
10454            caminho: "C:\\work\\caixa-teia".into(),
10455        });
10456        let err = d.validate().unwrap_err();
10457        assert!(
10458            matches!(err, DepError::FonteCaminhoBackslash { .. }),
10459            "got {err:?}",
10460        );
10461    }
10462
10463    #[test]
10464    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_backslash() {
10465        // The trailing-`\` shape (`..\caixa-teia\` — the canonical
10466        // PowerShell tab-completion-on-a-directory append). Pinned
10467        // separately from the embedded-`\` shape so the gate's
10468        // contract is "any `\` anywhere", not "any `\` not at end".
10469        let d = dep_with_fonte(DepSource::Path {
10470            caminho: "..\\caixa-teia\\".into(),
10471        });
10472        let err = d.validate().unwrap_err();
10473        assert!(
10474            matches!(err, DepError::FonteCaminhoBackslash { .. }),
10475            "got {err:?}",
10476        );
10477    }
10478
10479    #[test]
10480    fn validate_accepts_path_fonte_with_caminho_carrying_legitimate_forward_slash() {
10481        // The positive-control pin: the gate targets `\` only,
10482        // never `/`. The canonical relative POSIX path
10483        // (`../caixa-teia/foo/bar`) must continue to validate cleanly
10484        // so legitimate nested-directory deps aren't broken. Pinned
10485        // so the gate doesn't accidentally widen to a "no path
10486        // separators at all" sweep.
10487        let d = dep_with_fonte(DepSource::Path {
10488            caminho: "../caixa-teia/foo/bar".into(),
10489        });
10490        d.validate().unwrap();
10491    }
10492
10493    #[test]
10494    fn fonte_caminho_control_char_fires_before_backslash() {
10495        // Cascade pin: the control-char arm structurally precedes the
10496        // backslash arm. A value like `"..\caixa\0teia"` probes
10497        // positive on both (`\` byte + NUL byte), but the control-
10498        // char diagnostic wins so the author sees the more self-
10499        // locating POSIX-syscall-rejected-byte diagnostic first
10500        // (NUL outright breaks `CString::new` at every `std::fs`
10501        // syscall boundary; the `\` divergence is the cross-OS-
10502        // separator axis). Mirrors the
10503        // `fonte_caminho_var_fires_before_control_char` cascade
10504        // discipline on the immediate-predecessor arm.
10505        let d = dep_with_fonte(DepSource::Path {
10506            caminho: "..\\caixa\0teia".into(),
10507        });
10508        let err = d.validate().unwrap_err();
10509        assert!(
10510            matches!(err, DepError::FonteCaminhoControlChar { .. }),
10511            "got {err:?}",
10512        );
10513    }
10514
10515    #[test]
10516    fn fonte_caminho_absolute_fires_before_backslash() {
10517        // Cascade pin on the load-bearing leading-byte arm: a leading
10518        // `/` value with embedded `\` (`/etc/passwd\foo`) routes
10519        // through `FonteCaminhoAbsolute` not `FonteCaminhoBackslash`
10520        // — the host-layout-leak diagnostic is the load-bearing
10521        // axis, the `\` byte is the secondary observation. Same
10522        // precedence logic as every prior leading-byte arm.
10523        let d = dep_with_fonte(DepSource::Path {
10524            caminho: "/etc/passwd\\foo".into(),
10525        });
10526        let err = d.validate().unwrap_err();
10527        assert!(
10528            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10529            "got {err:?}",
10530        );
10531    }
10532
10533    #[test]
10534    fn fonte_caminho_var_fires_before_backslash() {
10535        // Cascade pin on the var-expansion arm: a leading-`$` value
10536        // with embedded `\` (`$WORKSPACE\caixa-teia` — the canonical
10537        // PowerShell-env-var paste-from-CI-manifest footgun) routes
10538        // through `FonteCaminhoVarExpansion` not `FonteCaminhoBackslash`.
10539        // The shell-expansion diagnostic is the more self-locating
10540        // axis since both the leading `$` and the embedded `\`
10541        // are Windows-shell artifacts but the `$` is the root-cause
10542        // surface (an author who removes the `$` is likely to leave
10543        // the `\` too).
10544        let d = dep_with_fonte(DepSource::Path {
10545            caminho: "$WORKSPACE\\caixa-teia".into(),
10546        });
10547        let err = d.validate().unwrap_err();
10548        assert!(
10549            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
10550            "got {err:?}",
10551        );
10552    }
10553
10554    #[test]
10555    fn fonte_caminho_backslash_diagnostic_carries_offending_dep_and_caminho() {
10556        // Diagnostic-shape pin (peer with the prior
10557        // `fonte_caminho_*_diagnostic_carries_*` payload assertions
10558        // on every preceding arm): the error's Display surfaces the
10559        // offending `:nome` and the offending `:caminho` verbatim
10560        // so a `feira lint` run can render the diagnostic without
10561        // re-parsing.
10562        let d = dep_with_fonte(DepSource::Path {
10563            caminho: "..\\caixa-teia".into(),
10564        });
10565        let rendered = d.validate().unwrap_err().to_string();
10566        assert!(
10567            rendered.contains("caixa-teia"),
10568            "diagnostic must name the offending dep: {rendered}",
10569        );
10570        assert!(
10571            rendered.contains("..\\caixa-teia"),
10572            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10573        );
10574        assert!(
10575            rendered.contains('\\'),
10576            "diagnostic must reference the backslash footgun: {rendered:?}",
10577        );
10578    }
10579
10580    #[test]
10581    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_slash() {
10582        // The fail-before-pass-after pin for the canonical trailing-`/`
10583        // paste footgun: an author who shell-tab-completes a sibling
10584        // directory (every interactive shell — bash/zsh/fish/nushell —
10585        // appends `/` on tab-completing a directory) produces
10586        // `"../caixa-teia/"`-shape values that silently passed every
10587        // prior arm (the leading byte is `.`, no control bytes, no
10588        // backslash). `Path::join` resolves both shapes to the same
10589        // directory at the resolver, but the lacre embeds the value
10590        // verbatim and the BLAKE3 closures diverge across two
10591        // workstations whose authors differ only in tab-completion
10592        // habits.
10593        let d = dep_with_fonte(DepSource::Path {
10594            caminho: "../caixa-teia/".into(),
10595        });
10596        let err = d.validate().unwrap_err();
10597        let DepError::FonteCaminhoTrailingSlash { nome, caminho } = err else {
10598            panic!("expected FonteCaminhoTrailingSlash, got {err:?}");
10599        };
10600        assert_eq!(nome, "caixa-teia");
10601        assert_eq!(caminho, "../caixa-teia/");
10602    }
10603
10604    #[test]
10605    fn validate_rejects_path_fonte_with_caminho_carrying_bare_dot_slash() {
10606        // The `"./"` shape (the canonical "I meant the caixa.lisp's own
10607        // directory and tab-completed it" footgun). Pinned separately
10608        // from the canonical `"../caixa-teia/"` shape so the gate's
10609        // contract is "any trailing `/`", not "trailing `/` after a leaf
10610        // name".
10611        let d = dep_with_fonte(DepSource::Path {
10612            caminho: "./".into(),
10613        });
10614        let err = d.validate().unwrap_err();
10615        assert!(
10616            matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
10617            "got {err:?}",
10618        );
10619    }
10620
10621    #[test]
10622    fn validate_rejects_path_fonte_with_caminho_carrying_consecutive_trailing_slashes() {
10623        // The `"foo//"` shape (the canonical "I pasted from a CI manifest
10624        // that double-templated `${VAR}/` over an already-`/`-suffixed
10625        // path" footgun). The gate fires on the last byte being `/`
10626        // regardless of how many `/` precede it; the arm contract is
10627        // "the value ends with `/`", structurally.
10628        let d = dep_with_fonte(DepSource::Path {
10629            caminho: "../caixa-teia//".into(),
10630        });
10631        let err = d.validate().unwrap_err();
10632        assert!(
10633            matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
10634            "got {err:?}",
10635        );
10636    }
10637
10638    #[test]
10639    fn validate_rejects_path_fonte_with_caminho_carrying_dotdot_trailing_slash() {
10640        // The `"../"` shape (the canonical "I want the parent" tab-
10641        // completion footgun on a bare `..` path). Pinned separately so
10642        // the gate doesn't accidentally narrow to "trailing `/` only on
10643        // multi-segment paths".
10644        let d = dep_with_fonte(DepSource::Path {
10645            caminho: "../".into(),
10646        });
10647        let err = d.validate().unwrap_err();
10648        assert!(
10649            matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
10650            "got {err:?}",
10651        );
10652    }
10653
10654    #[test]
10655    fn validate_accepts_path_fonte_with_caminho_carrying_internal_slashes() {
10656        // The positive-control pin: the gate targets the trailing byte
10657        // only, never internal `/` separators. The canonical nested
10658        // relative POSIX path (`"../caixa-teia/foo/bar"`) must continue
10659        // to validate cleanly so legitimate deeply-nested deps aren't
10660        // broken. Pinned so the gate doesn't accidentally widen to a
10661        // "no `/` separators anywhere" sweep that would defeat the
10662        // entire path-fonte author surface.
10663        let d = dep_with_fonte(DepSource::Path {
10664            caminho: "../caixa-teia/foo/bar".into(),
10665        });
10666        d.validate().unwrap();
10667    }
10668
10669    #[test]
10670    fn validate_accepts_path_fonte_with_caminho_carrying_bare_dot() {
10671        // The positive-control pin on the degenerate single-`.` shape
10672        // (the canonical "the caixa.lisp's own directory" idiom). The
10673        // gate fires on the trailing byte being `/`, not on the path
10674        // being short, so `"."` (one byte, not `/`) must continue to
10675        // validate cleanly.
10676        let d = dep_with_fonte(DepSource::Path {
10677            caminho: ".".into(),
10678        });
10679        d.validate().unwrap();
10680    }
10681
10682    #[test]
10683    fn fonte_caminho_control_char_fires_before_trailing_slash() {
10684        // Cascade pin: the control-char arm structurally precedes the
10685        // trailing-slash arm. A value like `"../foo\n/"` ends in `/`
10686        // but the embedded LF (`0x0A`) is the load-bearing diagnostic
10687        // (control bytes are the paste-from-multiline-doc footgun the
10688        // d624c8d arm already closes). Mirrors the
10689        // `fonte_caminho_control_char_fires_before_backslash` cascade
10690        // discipline on the immediate-predecessor arm.
10691        let d = dep_with_fonte(DepSource::Path {
10692            caminho: "../foo\n/".into(),
10693        });
10694        let err = d.validate().unwrap_err();
10695        assert!(
10696            matches!(err, DepError::FonteCaminhoControlChar { .. }),
10697            "got {err:?}",
10698        );
10699    }
10700
10701    #[test]
10702    fn fonte_caminho_backslash_fires_before_trailing_slash() {
10703        // Cascade pin on the backslash arm: a value like `"..\foo/"`
10704        // ends in `/` but the embedded `\` is the load-bearing
10705        // diagnostic (the cross-host-OS-separator divergence vector
10706        // the 3a4e1d7 arm closes). Same precedence logic as the prior
10707        // narrower-diagnostic-first cascade.
10708        let d = dep_with_fonte(DepSource::Path {
10709            caminho: "..\\caixa-teia/".into(),
10710        });
10711        let err = d.validate().unwrap_err();
10712        assert!(
10713            matches!(err, DepError::FonteCaminhoBackslash { .. }),
10714            "got {err:?}",
10715        );
10716    }
10717
10718    #[test]
10719    fn fonte_caminho_absolute_fires_before_trailing_slash() {
10720        // Cascade pin on the load-bearing leading-byte arm: a leading
10721        // `/` value with a trailing `/` (`"/etc/passwd/"`) routes
10722        // through `FonteCaminhoAbsolute` not `FonteCaminhoTrailingSlash`
10723        // — the host-layout-leak diagnostic is the load-bearing axis,
10724        // the trailing `/` is the secondary observation. Same
10725        // precedence logic as every prior leading-byte arm.
10726        let d = dep_with_fonte(DepSource::Path {
10727            caminho: "/etc/passwd/".into(),
10728        });
10729        let err = d.validate().unwrap_err();
10730        assert!(
10731            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10732            "got {err:?}",
10733        );
10734    }
10735
10736    #[test]
10737    fn fonte_caminho_trailing_slash_diagnostic_carries_offending_dep_and_caminho() {
10738        // Diagnostic-shape pin (peer with the prior
10739        // `fonte_caminho_*_diagnostic_carries_*` payload assertions on
10740        // every preceding arm): the error's Display surfaces the
10741        // offending `:nome` and the offending `:caminho` verbatim so a
10742        // `feira lint` run can render the diagnostic without re-parsing.
10743        let d = dep_with_fonte(DepSource::Path {
10744            caminho: "../caixa-teia/".into(),
10745        });
10746        let rendered = d.validate().unwrap_err().to_string();
10747        assert!(
10748            rendered.contains("caixa-teia"),
10749            "diagnostic must name the offending dep: {rendered}",
10750        );
10751        assert!(
10752            rendered.contains("../caixa-teia/"),
10753            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10754        );
10755        assert!(
10756            rendered.contains("trailing"),
10757            "diagnostic must reference the trailing-slash footgun: {rendered:?}",
10758        );
10759    }
10760
10761    // -- :caminho shell-redirection metacharacter arm -----------------------
10762
10763    #[test]
10764    fn validate_rejects_path_fonte_with_caminho_carrying_gt_redirection() {
10765        // The fail-before-pass-after pin for the canonical output-redirection
10766        // paste footgun: an author copies a shell pipeline tail
10767        // (`"../caixa-teia>build.log"` — the canonical "I selected the whole
10768        // line including the `> build.log` redirect" idiom) and silently
10769        // passed every prior arm (`Path::is_absolute` false on `..`, no
10770        // control bytes, no backslash, doesn't end in `/`). The lacre
10771        // embedded the value verbatim, the resolver folded it through
10772        // `Path::join` looking for a literal `./../caixa-teia>build.log`
10773        // subdirectory, and the failure surfaced at resolve time with a
10774        // non-self-locating `No such file or directory` error. The new arm
10775        // moves the rejection to validate time and names the offending dep
10776        // + caminho + byte verbatim.
10777        let d = dep_with_fonte(DepSource::Path {
10778            caminho: "../caixa-teia>build.log".into(),
10779        });
10780        let err = d.validate().unwrap_err();
10781        let DepError::FonteCaminhoShellRedirection {
10782            nome,
10783            caminho,
10784            byte,
10785        } = err
10786        else {
10787            panic!("expected FonteCaminhoShellRedirection, got {err:?}");
10788        };
10789        assert_eq!(nome, "caixa-teia");
10790        assert_eq!(caminho, "../caixa-teia>build.log");
10791        assert_eq!(byte, b'>');
10792    }
10793
10794    #[test]
10795    fn validate_rejects_path_fonte_with_caminho_carrying_lt_redirection() {
10796        // The symmetric input-redirection paste shape
10797        // (`"../caixa-teia<input.lisp"` — the canonical "I copied a
10798        // `command < input.lisp` line from a tatara-lisp REPL log"
10799        // idiom). Pinned separately from the `>` shape so the gate's
10800        // contract is "any `<` or `>` anywhere", not single-byte coverage.
10801        let d = dep_with_fonte(DepSource::Path {
10802            caminho: "../caixa-teia<input.lisp".into(),
10803        });
10804        let err = d.validate().unwrap_err();
10805        let DepError::FonteCaminhoShellRedirection { byte, .. } = err else {
10806            panic!("expected FonteCaminhoShellRedirection, got {err:?}");
10807        };
10808        assert_eq!(byte, b'<');
10809    }
10810
10811    #[test]
10812    fn validate_rejects_path_fonte_with_caminho_carrying_leading_gt_redirection() {
10813        // Leading-position `>` shape (`">../caixa-teia"` — the degenerate
10814        // "I forgot the source side of the redirect" idiom). Pinned
10815        // separately from the embedded-byte shapes so the gate covers
10816        // every position, not only mid-path.
10817        let d = dep_with_fonte(DepSource::Path {
10818            caminho: ">../caixa-teia".into(),
10819        });
10820        let err = d.validate().unwrap_err();
10821        assert!(
10822            matches!(
10823                err,
10824                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
10825            ),
10826            "got {err:?}",
10827        );
10828    }
10829
10830    #[test]
10831    fn validate_rejects_path_fonte_with_caminho_carrying_double_gt_append() {
10832        // The bash append-redirection shape (`"../caixa-teia>>build.log"` —
10833        // the canonical "I copied a `>>` append redirect" idiom). The arm
10834        // fires on the first `>` encountered; pinned so a future arm that
10835        // tries to distinguish `>` from `>>` doesn't break the broader
10836        // contract.
10837        let d = dep_with_fonte(DepSource::Path {
10838            caminho: "../caixa-teia>>build.log".into(),
10839        });
10840        let err = d.validate().unwrap_err();
10841        assert!(
10842            matches!(
10843                err,
10844                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
10845            ),
10846            "got {err:?}",
10847        );
10848    }
10849
10850    #[test]
10851    fn validate_accepts_path_fonte_with_caminho_carrying_no_redirection() {
10852        // The positive-control pin: the gate targets only `<` / `>`,
10853        // never adjacent printable ASCII or POSIX-valid bytes. The
10854        // canonical relative POSIX path (`"../caixa-teia"`) and a
10855        // nested deeply-pathed variant (`"../caixa-teia/foo/bar"`) must
10856        // continue to validate cleanly so the gate doesn't widen to a
10857        // "no printable punctuation anywhere" sweep that would defeat
10858        // the entire path-fonte author surface.
10859        let d = dep_with_fonte(DepSource::Path {
10860            caminho: "../caixa-teia/foo/bar".into(),
10861        });
10862        d.validate().unwrap();
10863    }
10864
10865    #[test]
10866    fn fonte_caminho_backslash_fires_before_shell_redirection() {
10867        // Cascade pin on the immediate-predecessor arm: a value carrying
10868        // both `\` and `<` / `>` (`"..\caixa-teia>build.log"` — the
10869        // canonical "I pasted a Windows-shell command with output
10870        // redirect" footgun) routes through `FonteCaminhoBackslash` not
10871        // `FonteCaminhoShellRedirection`. The cross-host-OS-separator
10872        // divergence is the load-bearing axis (an author who removes
10873        // the `\` is the root-cause edit; the `>` falls away in the
10874        // same edit since it's downstream of the Windows-shell
10875        // convention).
10876        let d = dep_with_fonte(DepSource::Path {
10877            caminho: "..\\caixa-teia>build.log".into(),
10878        });
10879        let err = d.validate().unwrap_err();
10880        assert!(
10881            matches!(err, DepError::FonteCaminhoBackslash { .. }),
10882            "got {err:?}",
10883        );
10884    }
10885
10886    #[test]
10887    fn fonte_caminho_control_char_fires_before_shell_redirection() {
10888        // Cascade pin on the embedded-control-byte arm: a value carrying
10889        // both a control byte and `<` / `>` (`"../foo\n>bar"` — the
10890        // canonical paste-from-multiline-doc footgun where a newline
10891        // landed mid-caminho) routes through `FonteCaminhoControlChar`
10892        // not `FonteCaminhoShellRedirection`. The POSIX-syscall-
10893        // rejected-byte / NUL-`CString::new`-fail diagnostic is the
10894        // load-bearing axis on every value that probes positive for
10895        // both — mirrors the cascade discipline on every prior arm.
10896        let d = dep_with_fonte(DepSource::Path {
10897            caminho: "../foo\n>bar".into(),
10898        });
10899        let err = d.validate().unwrap_err();
10900        assert!(
10901            matches!(err, DepError::FonteCaminhoControlChar { .. }),
10902            "got {err:?}",
10903        );
10904    }
10905
10906    #[test]
10907    fn fonte_caminho_absolute_fires_before_shell_redirection() {
10908        // Cascade pin on the load-bearing leading-byte arm: a leading
10909        // `/` value with embedded `<` / `>` (`"/etc/passwd>out"`)
10910        // routes through `FonteCaminhoAbsolute` not
10911        // `FonteCaminhoShellRedirection` — the host-layout-leak
10912        // diagnostic is the load-bearing axis, the `>` byte is the
10913        // secondary observation. Same precedence logic as every prior
10914        // leading-byte arm.
10915        let d = dep_with_fonte(DepSource::Path {
10916            caminho: "/etc/passwd>out".into(),
10917        });
10918        let err = d.validate().unwrap_err();
10919        assert!(
10920            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10921            "got {err:?}",
10922        );
10923    }
10924
10925    #[test]
10926    fn fonte_caminho_shell_redirection_fires_before_trailing_slash() {
10927        // Cascade pin on the immediate-successor arm: a value carrying
10928        // both `<` / `>` and a trailing `/` (`"../foo></"` — the
10929        // canonical "I tab-completed a path that already had a
10930        // redirect" footgun) routes through `FonteCaminhoShellRedirection`
10931        // not `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
10932        // the more semantic-locating axis (an author who removes the
10933        // `<` / `>` typically also drops the trailing separator since
10934        // both are paste-from-shell artifacts).
10935        let d = dep_with_fonte(DepSource::Path {
10936            caminho: "../foo></".into(),
10937        });
10938        let err = d.validate().unwrap_err();
10939        assert!(
10940            matches!(
10941                err,
10942                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
10943            ),
10944            "got {err:?}",
10945        );
10946    }
10947
10948    #[test]
10949    fn fonte_caminho_shell_redirection_diagnostic_carries_offending_dep_caminho_byte() {
10950        // Diagnostic-shape pin (peer with
10951        // `fonte_caminho_control_diagnostic_carries_offending_dep_caminho_byte`'s
10952        // payload assertion on the closest peer arm that also carries a
10953        // `byte` field): the error's Display surfaces the offending
10954        // `:nome`, the offending `:caminho` verbatim, and the offending
10955        // byte in hex (`0x3c` for `<`, `0x3e` for `>`) so a `feira lint`
10956        // run can render the diagnostic without re-parsing.
10957        let d = dep_with_fonte(DepSource::Path {
10958            caminho: "../caixa-teia>build.log".into(),
10959        });
10960        let rendered = d.validate().unwrap_err().to_string();
10961        assert!(
10962            rendered.contains("caixa-teia"),
10963            "diagnostic must name the offending dep: {rendered}",
10964        );
10965        assert!(
10966            rendered.contains("../caixa-teia>build.log"),
10967            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10968        );
10969        assert!(
10970            rendered.contains("0x3e"),
10971            "diagnostic must name the offending byte in hex: {rendered:?}",
10972        );
10973        assert!(
10974            rendered.contains("redirection"),
10975            "diagnostic must name the shell-redirection footgun: {rendered:?}",
10976        );
10977    }
10978
10979    // -- :caminho shell-pipe metacharacter arm ----------------------------
10980
10981    #[test]
10982    fn validate_rejects_path_fonte_with_caminho_carrying_pipe() {
10983        // The fail-before-pass-after pin for the canonical shell-pipe
10984        // paste footgun: an author copies a shell-history line
10985        // (`"../caixa-teia | grep foo"` — the canonical "I selected
10986        // the whole `ls dir | grep` line out of zsh history") and
10987        // silently passed every prior arm (`Path::is_absolute` false
10988        // on `..`, no control bytes, no backslash, no `<` / `>`,
10989        // doesn't end in `/`). The lacre embedded the value verbatim,
10990        // the resolver folded it through `Path::join` looking for a
10991        // literal `./../caixa-teia | grep foo` subdirectory, and the
10992        // failure surfaced at resolve time with a non-self-locating
10993        // `No such file or directory` error. The new arm moves the
10994        // rejection to validate time and names the offending dep +
10995        // caminho verbatim.
10996        let d = dep_with_fonte(DepSource::Path {
10997            caminho: "../caixa-teia | grep foo".into(),
10998        });
10999        let err = d.validate().unwrap_err();
11000        let DepError::FonteCaminhoShellPipe { nome, caminho } = err else {
11001            panic!("expected FonteCaminhoShellPipe, got {err:?}");
11002        };
11003        assert_eq!(nome, "caixa-teia");
11004        assert_eq!(caminho, "../caixa-teia | grep foo");
11005    }
11006
11007    #[test]
11008    fn validate_rejects_path_fonte_with_caminho_carrying_leading_pipe() {
11009        // Leading-position `|` shape (`"|../caixa-teia"` — the
11010        // degenerate "I forgot the source side of the pipe" idiom).
11011        // Pinned separately from the embedded-byte shape so the gate
11012        // covers every position, not only mid-path.
11013        let d = dep_with_fonte(DepSource::Path {
11014            caminho: "|../caixa-teia".into(),
11015        });
11016        let err = d.validate().unwrap_err();
11017        assert!(
11018            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11019            "got {err:?}",
11020        );
11021    }
11022
11023    #[test]
11024    fn validate_rejects_path_fonte_with_caminho_carrying_double_pipe_or() {
11025        // The bash short-circuit-OR shape (`"../caixa-teia||fallback"`
11026        // — the canonical "I copied a `cmd-a || cmd-b` fallback line"
11027        // idiom). The arm fires on the first `|` encountered; pinned
11028        // so a future arm that tries to distinguish `|` from `||`
11029        // doesn't break the broader contract.
11030        let d = dep_with_fonte(DepSource::Path {
11031            caminho: "../caixa-teia||fallback".into(),
11032        });
11033        let err = d.validate().unwrap_err();
11034        assert!(
11035            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11036            "got {err:?}",
11037        );
11038    }
11039
11040    #[test]
11041    fn validate_accepts_path_fonte_with_caminho_carrying_no_pipe() {
11042        // The positive-control pin: the gate targets only `|`, never
11043        // adjacent printable ASCII or POSIX-valid bytes. The canonical
11044        // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
11045        // pathed variant with adjacent printable punctuation
11046        // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
11047        // cleanly so the gate doesn't widen to a "no printable
11048        // punctuation anywhere" sweep that would defeat the entire
11049        // path-fonte author surface.
11050        let d = dep_with_fonte(DepSource::Path {
11051            caminho: "../caixa-teia/sub-dir.v2".into(),
11052        });
11053        d.validate().unwrap();
11054    }
11055
11056    #[test]
11057    fn fonte_caminho_shell_redirection_fires_before_shell_pipe() {
11058        // Cascade pin on the immediate-predecessor arm: a value carrying
11059        // both `<` / `>` and `|` (`"../caixa-teia<input|tee"` — the
11060        // canonical "I pasted a `cmd < input | tee` pipeline tail"
11061        // footgun) routes through `FonteCaminhoShellRedirection` not
11062        // `FonteCaminhoShellPipe`. The input/output redirection
11063        // metachar carries the more self-locating `byte: u8` payload
11064        // (it names which of `<` or `>` triggered), so the prior arm
11065        // wins on every probe-as-both value — same cascade discipline
11066        // every prior `:caminho` arm establishes.
11067        let d = dep_with_fonte(DepSource::Path {
11068            caminho: "../caixa-teia<input|tee".into(),
11069        });
11070        let err = d.validate().unwrap_err();
11071        assert!(
11072            matches!(
11073                err,
11074                DepError::FonteCaminhoShellRedirection { byte: b'<', .. }
11075            ),
11076            "got {err:?}",
11077        );
11078    }
11079
11080    #[test]
11081    fn fonte_caminho_backslash_fires_before_shell_pipe() {
11082        // Cascade pin on the upstream backslash arm: a value carrying
11083        // both `\` and `|` (`"..\caixa-teia|tee"` — the canonical
11084        // "I pasted a Windows-shell command with pipe to tee"
11085        // footgun) routes through `FonteCaminhoBackslash` not
11086        // `FonteCaminhoShellPipe`. The cross-host-OS-separator
11087        // divergence is the load-bearing axis on every probe-as-both
11088        // value (an author who removes the `\` is the root-cause edit;
11089        // the `|` falls away in the same edit since it's downstream of
11090        // the Windows-shell convention).
11091        let d = dep_with_fonte(DepSource::Path {
11092            caminho: "..\\caixa-teia|tee".into(),
11093        });
11094        let err = d.validate().unwrap_err();
11095        assert!(
11096            matches!(err, DepError::FonteCaminhoBackslash { .. }),
11097            "got {err:?}",
11098        );
11099    }
11100
11101    #[test]
11102    fn fonte_caminho_control_char_fires_before_shell_pipe() {
11103        // Cascade pin on the embedded-control-byte arm: a value
11104        // carrying both a control byte and `|` (`"../foo\n|bar"` —
11105        // the canonical paste-from-multiline-doc footgun where a
11106        // newline landed mid-caminho) routes through
11107        // `FonteCaminhoControlChar` not `FonteCaminhoShellPipe`. The
11108        // POSIX-syscall-rejected-byte / NUL-`CString::new`-fail
11109        // diagnostic is the load-bearing axis on every value that
11110        // probes positive for both — mirrors the cascade discipline
11111        // on every prior arm.
11112        let d = dep_with_fonte(DepSource::Path {
11113            caminho: "../foo\n|bar".into(),
11114        });
11115        let err = d.validate().unwrap_err();
11116        assert!(
11117            matches!(err, DepError::FonteCaminhoControlChar { .. }),
11118            "got {err:?}",
11119        );
11120    }
11121
11122    #[test]
11123    fn fonte_caminho_absolute_fires_before_shell_pipe() {
11124        // Cascade pin on the load-bearing leading-byte arm: a leading
11125        // `/` value with embedded `|` (`"/etc/passwd|tee"`) routes
11126        // through `FonteCaminhoAbsolute` not `FonteCaminhoShellPipe`
11127        // — the host-layout-leak diagnostic is the load-bearing axis,
11128        // the `|` byte is the secondary observation. Same precedence
11129        // logic as every prior leading-byte arm.
11130        let d = dep_with_fonte(DepSource::Path {
11131            caminho: "/etc/passwd|tee".into(),
11132        });
11133        let err = d.validate().unwrap_err();
11134        assert!(
11135            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11136            "got {err:?}",
11137        );
11138    }
11139
11140    #[test]
11141    fn fonte_caminho_shell_pipe_fires_before_trailing_slash() {
11142        // Cascade pin on the immediate-successor arm: a value carrying
11143        // both `|` and a trailing `/` (`"../foo|tee/"` — the canonical
11144        // "I tab-completed a path that already had a pipeline tail"
11145        // footgun) routes through `FonteCaminhoShellPipe` not
11146        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
11147        // the more semantic-locating axis (an author who removes the
11148        // `|` typically also drops the trailing separator since both
11149        // are paste-from-shell artifacts).
11150        let d = dep_with_fonte(DepSource::Path {
11151            caminho: "../foo|tee/".into(),
11152        });
11153        let err = d.validate().unwrap_err();
11154        assert!(
11155            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11156            "got {err:?}",
11157        );
11158    }
11159
11160    #[test]
11161    fn fonte_caminho_shell_pipe_diagnostic_carries_offending_dep_and_caminho() {
11162        // Diagnostic-shape pin (peer with
11163        // `fonte_caminho_backslash_diagnostic_carries_offending_dep_and_caminho`
11164        // on the closest single-byte peer arm): the error's Display
11165        // surfaces the offending `:nome` and the offending `:caminho`
11166        // verbatim, and names the shell-pipe footgun explicitly so a
11167        // `feira lint` run can render the diagnostic without
11168        // re-parsing.
11169        let d = dep_with_fonte(DepSource::Path {
11170            caminho: "../caixa-teia | grep foo".into(),
11171        });
11172        let rendered = d.validate().unwrap_err().to_string();
11173        assert!(
11174            rendered.contains("caixa-teia"),
11175            "diagnostic must name the offending dep: {rendered}",
11176        );
11177        assert!(
11178            rendered.contains("../caixa-teia | grep foo"),
11179            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11180        );
11181        assert!(
11182            rendered.contains('|'),
11183            "diagnostic must reference the pipe footgun: {rendered:?}",
11184        );
11185        assert!(
11186            rendered.contains("pipe"),
11187            "diagnostic must name the shell-pipe footgun: {rendered:?}",
11188        );
11189    }
11190
11191    // -- :caminho shell-command-separator metacharacter arm ---------------
11192
11193    #[test]
11194    fn validate_rejects_path_fonte_with_caminho_carrying_semicolon() {
11195        // The fail-before-pass-after pin for the canonical shell-command-
11196        // separator paste footgun: an author copies a shell one-liner
11197        // (`"../caixa-teia; rm -rf build"` — the canonical "I selected the
11198        // whole `cd path; do-thing` chain out of a shell-history block")
11199        // and silently passed every prior arm (`Path::is_absolute` false
11200        // on `..`, no control bytes, no backslash, no `<` / `>`, no `|`,
11201        // doesn't end in `/`). The lacre embedded the value verbatim, the
11202        // resolver folded it through `Path::join` looking for a literal
11203        // `./../caixa-teia; rm -rf build` subdirectory, and the failure
11204        // surfaced at resolve time with a non-self-locating `No such file
11205        // or directory` error. The new arm moves the rejection to validate
11206        // time and names the offending dep + caminho verbatim.
11207        let d = dep_with_fonte(DepSource::Path {
11208            caminho: "../caixa-teia; rm -rf build".into(),
11209        });
11210        let err = d.validate().unwrap_err();
11211        let DepError::FonteCaminhoShellSemicolon { nome, caminho } = err else {
11212            panic!("expected FonteCaminhoShellSemicolon, got {err:?}");
11213        };
11214        assert_eq!(nome, "caixa-teia");
11215        assert_eq!(caminho, "../caixa-teia; rm -rf build");
11216    }
11217
11218    #[test]
11219    fn validate_rejects_path_fonte_with_caminho_carrying_leading_semicolon() {
11220        // Leading-position `;` shape (`";../caixa-teia"` — the degenerate
11221        // "I forgot the prior command side of the separator" idiom).
11222        // Pinned separately from the embedded-byte shape so the gate
11223        // covers every position, not only mid-path.
11224        let d = dep_with_fonte(DepSource::Path {
11225            caminho: ";../caixa-teia".into(),
11226        });
11227        let err = d.validate().unwrap_err();
11228        assert!(
11229            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11230            "got {err:?}",
11231        );
11232    }
11233
11234    #[test]
11235    fn validate_rejects_path_fonte_with_caminho_carrying_double_semicolon() {
11236        // The POSIX `case` arm `;;` terminator shape
11237        // (`"../caixa-teia;;next"` — the canonical "I copied a `case`
11238        // arm tail" idiom). The arm fires on the first `;` encountered;
11239        // pinned so a future arm that tries to distinguish `;` from `;;`
11240        // doesn't break the broader contract.
11241        let d = dep_with_fonte(DepSource::Path {
11242            caminho: "../caixa-teia;;next".into(),
11243        });
11244        let err = d.validate().unwrap_err();
11245        assert!(
11246            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11247            "got {err:?}",
11248        );
11249    }
11250
11251    #[test]
11252    fn validate_accepts_path_fonte_with_caminho_carrying_no_semicolon() {
11253        // The positive-control pin: the gate targets only `;`, never
11254        // adjacent printable ASCII or POSIX-valid bytes. The canonical
11255        // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
11256        // pathed variant with adjacent printable punctuation
11257        // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
11258        // cleanly so the gate doesn't widen to a "no printable
11259        // punctuation anywhere" sweep that would defeat the entire
11260        // path-fonte author surface.
11261        let d = dep_with_fonte(DepSource::Path {
11262            caminho: "../caixa-teia/sub-dir.v2".into(),
11263        });
11264        d.validate().unwrap();
11265    }
11266
11267    #[test]
11268    fn fonte_caminho_shell_pipe_fires_before_shell_semicolon() {
11269        // Cascade pin on the immediate-predecessor arm: a value carrying
11270        // both `|` and `;` (`"../caixa-teia | tee; rm"` — the canonical
11271        // "I pasted a `cmd | tee; cleanup` chain" footgun) routes through
11272        // `FonteCaminhoShellPipe` not `FonteCaminhoShellSemicolon`. The
11273        // pipeline-tail paste is the load-bearing root-cause edit on
11274        // every probe-as-both value (an author who removes the `|`
11275        // typically also drops the trailing `; cleanup` since both are
11276        // the same paste-from-shell-history artifact) — same cascade
11277        // discipline every prior `:caminho` arm establishes.
11278        let d = dep_with_fonte(DepSource::Path {
11279            caminho: "../caixa-teia | tee; rm".into(),
11280        });
11281        let err = d.validate().unwrap_err();
11282        assert!(
11283            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11284            "got {err:?}",
11285        );
11286    }
11287
11288    #[test]
11289    fn fonte_caminho_shell_redirection_fires_before_shell_semicolon() {
11290        // Cascade pin on the upstream shell-redirection arm: a value
11291        // carrying both `<` / `>` and `;` (`"../caixa-teia>log; rm"` —
11292        // the canonical "I pasted a `cmd > log; cleanup` chain"
11293        // footgun) routes through `FonteCaminhoShellRedirection` not
11294        // `FonteCaminhoShellSemicolon`. The input/output redirection
11295        // metachar carries the more self-locating `byte: u8` payload
11296        // (it names which of `<` or `>` triggered), so the prior arm
11297        // wins on every probe-as-both value.
11298        let d = dep_with_fonte(DepSource::Path {
11299            caminho: "../caixa-teia>log; rm".into(),
11300        });
11301        let err = d.validate().unwrap_err();
11302        assert!(
11303            matches!(
11304                err,
11305                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11306            ),
11307            "got {err:?}",
11308        );
11309    }
11310
11311    #[test]
11312    fn fonte_caminho_backslash_fires_before_shell_semicolon() {
11313        // Cascade pin on the upstream backslash arm: a value carrying
11314        // both `\` and `;` (`"..\caixa-teia;rm"` — the canonical "I
11315        // pasted a Windows-shell `cd ..\path; cleanup` chain") routes
11316        // through `FonteCaminhoBackslash` not `FonteCaminhoShellSemicolon`.
11317        // The cross-host-OS-separator divergence is the load-bearing axis
11318        // on every probe-as-both value (an author who removes the `\` is
11319        // the root-cause edit; the `;` falls away in the same edit since
11320        // it's downstream of the Windows-shell convention).
11321        let d = dep_with_fonte(DepSource::Path {
11322            caminho: "..\\caixa-teia;rm".into(),
11323        });
11324        let err = d.validate().unwrap_err();
11325        assert!(
11326            matches!(err, DepError::FonteCaminhoBackslash { .. }),
11327            "got {err:?}",
11328        );
11329    }
11330
11331    #[test]
11332    fn fonte_caminho_control_char_fires_before_shell_semicolon() {
11333        // Cascade pin on the embedded-control-byte arm: a value carrying
11334        // both a control byte and `;` (`"../foo\n;bar"` — the canonical
11335        // paste-from-multiline-doc footgun where a newline landed mid-
11336        // caminho) routes through `FonteCaminhoControlChar` not
11337        // `FonteCaminhoShellSemicolon`. The POSIX-syscall-rejected-byte
11338        // / NUL-`CString::new`-fail diagnostic is the load-bearing axis
11339        // on every value that probes positive for both — mirrors the
11340        // cascade discipline on every prior arm.
11341        let d = dep_with_fonte(DepSource::Path {
11342            caminho: "../foo\n;bar".into(),
11343        });
11344        let err = d.validate().unwrap_err();
11345        assert!(
11346            matches!(err, DepError::FonteCaminhoControlChar { .. }),
11347            "got {err:?}",
11348        );
11349    }
11350
11351    #[test]
11352    fn fonte_caminho_absolute_fires_before_shell_semicolon() {
11353        // Cascade pin on the load-bearing leading-byte arm: a leading
11354        // `/` value with embedded `;` (`"/etc/passwd;rm"`) routes
11355        // through `FonteCaminhoAbsolute` not `FonteCaminhoShellSemicolon`
11356        // — the host-layout-leak diagnostic is the load-bearing axis,
11357        // the `;` byte is the secondary observation. Same precedence
11358        // logic as every prior leading-byte arm.
11359        let d = dep_with_fonte(DepSource::Path {
11360            caminho: "/etc/passwd;rm".into(),
11361        });
11362        let err = d.validate().unwrap_err();
11363        assert!(
11364            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11365            "got {err:?}",
11366        );
11367    }
11368
11369    #[test]
11370    fn fonte_caminho_shell_semicolon_fires_before_trailing_slash() {
11371        // Cascade pin on the immediate-successor arm: a value carrying
11372        // both `;` and a trailing `/` (`"../foo;rm/"` — the canonical
11373        // "I tab-completed a path that already had a `; cleanup` tail"
11374        // footgun) routes through `FonteCaminhoShellSemicolon` not
11375        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
11376        // the more semantic-locating axis (an author who removes the
11377        // `;` typically also drops the trailing separator since both
11378        // are paste-from-shell artifacts).
11379        let d = dep_with_fonte(DepSource::Path {
11380            caminho: "../foo;rm/".into(),
11381        });
11382        let err = d.validate().unwrap_err();
11383        assert!(
11384            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11385            "got {err:?}",
11386        );
11387    }
11388
11389    #[test]
11390    fn fonte_caminho_shell_semicolon_diagnostic_carries_offending_dep_and_caminho() {
11391        // Diagnostic-shape pin (peer with
11392        // `fonte_caminho_shell_pipe_diagnostic_carries_offending_dep_and_caminho`
11393        // on the closest single-byte peer arm): the error's Display
11394        // surfaces the offending `:nome` and the offending `:caminho`
11395        // verbatim, and names the shell-command-separator footgun
11396        // explicitly so a `feira lint` run can render the diagnostic
11397        // without re-parsing.
11398        let d = dep_with_fonte(DepSource::Path {
11399            caminho: "../caixa-teia; rm -rf build".into(),
11400        });
11401        let rendered = d.validate().unwrap_err().to_string();
11402        assert!(
11403            rendered.contains("caixa-teia"),
11404            "diagnostic must name the offending dep: {rendered}",
11405        );
11406        assert!(
11407            rendered.contains("../caixa-teia; rm -rf build"),
11408            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11409        );
11410        assert!(
11411            rendered.contains(';'),
11412            "diagnostic must reference the semicolon footgun: {rendered:?}",
11413        );
11414        assert!(
11415            rendered.contains("command-separator"),
11416            "diagnostic must name the shell-command-separator footgun: {rendered:?}",
11417        );
11418    }
11419
11420    #[test]
11421    fn validate_rejects_path_fonte_with_caminho_carrying_ampersand() {
11422        // The fail-before-pass-after pin for the canonical shell-
11423        // background-task paste footgun: an author copies a shell one-
11424        // liner (`"../caixa-teia & sleep 1"` — the canonical "I selected
11425        // the whole `cd path & sleep 1` background-launch out of a
11426        // shell-history block") and silently passed every prior arm
11427        // (`Path::is_absolute` false on `..`, no control bytes, no
11428        // backslash, no `<` / `>`, no `|`, no `;`, doesn't end in `/`).
11429        // The lacre embedded the value verbatim, the resolver folded it
11430        // through `Path::join` looking for a literal `./../caixa-teia &
11431        // sleep 1` subdirectory, and the failure surfaced at resolve
11432        // time with a non-self-locating `No such file or directory`
11433        // error. The new arm moves the rejection to validate time and
11434        // names the offending dep + caminho verbatim.
11435        let d = dep_with_fonte(DepSource::Path {
11436            caminho: "../caixa-teia & sleep 1".into(),
11437        });
11438        let err = d.validate().unwrap_err();
11439        let DepError::FonteCaminhoShellBackground { nome, caminho } = err else {
11440            panic!("expected FonteCaminhoShellBackground, got {err:?}");
11441        };
11442        assert_eq!(nome, "caixa-teia");
11443        assert_eq!(caminho, "../caixa-teia & sleep 1");
11444    }
11445
11446    #[test]
11447    fn validate_rejects_path_fonte_with_caminho_carrying_leading_ampersand() {
11448        // Leading-position `&` shape (`"&../caixa-teia"` — the
11449        // degenerate "I forgot the prior command side of the
11450        // background terminator" idiom). Pinned separately from the
11451        // embedded-byte shape so the gate covers every position, not
11452        // only mid-path.
11453        let d = dep_with_fonte(DepSource::Path {
11454            caminho: "&../caixa-teia".into(),
11455        });
11456        let err = d.validate().unwrap_err();
11457        assert!(
11458            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11459            "got {err:?}",
11460        );
11461    }
11462
11463    #[test]
11464    fn validate_rejects_path_fonte_with_caminho_carrying_double_ampersand() {
11465        // The logical-AND `&&` shape (`"../caixa-teia && make"` — the
11466        // canonical "I copied a `cd path && make` build chain" idiom
11467        // every Makefile / shell-script wraps). The arm fires on the
11468        // first `&` encountered; pinned so a future arm that tries to
11469        // distinguish `&` from `&&` doesn't break the broader contract.
11470        let d = dep_with_fonte(DepSource::Path {
11471            caminho: "../caixa-teia && make".into(),
11472        });
11473        let err = d.validate().unwrap_err();
11474        assert!(
11475            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11476            "got {err:?}",
11477        );
11478    }
11479
11480    #[test]
11481    fn validate_accepts_path_fonte_with_caminho_carrying_no_ampersand() {
11482        // The positive-control pin: the gate targets only `&`, never
11483        // adjacent printable ASCII or POSIX-valid bytes. The canonical
11484        // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
11485        // pathed variant with adjacent printable punctuation
11486        // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
11487        // cleanly so the gate doesn't widen to a "no printable
11488        // punctuation anywhere" sweep that would defeat the entire
11489        // path-fonte author surface.
11490        let d = dep_with_fonte(DepSource::Path {
11491            caminho: "../caixa-teia/sub-dir.v2".into(),
11492        });
11493        d.validate().unwrap();
11494    }
11495
11496    #[test]
11497    fn fonte_caminho_shell_semicolon_fires_before_shell_background() {
11498        // Cascade pin on the immediate-predecessor arm: a value carrying
11499        // both `;` and `&` (`"../caixa-teia; rm & sleep"` — the
11500        // canonical "I pasted a `cmd; cleanup & sleep` chain" footgun)
11501        // routes through `FonteCaminhoShellSemicolon` not
11502        // `FonteCaminhoShellBackground`. The sequential-command-
11503        // separator paste is the more common shell-history paste idiom
11504        // on every probe-as-both value (an author who removes the `;`
11505        // typically also drops the trailing `& sleep` since both are
11506        // paste-from-shell-history artifacts) — same cascade discipline
11507        // every prior `:caminho` arm establishes.
11508        let d = dep_with_fonte(DepSource::Path {
11509            caminho: "../caixa-teia; rm & sleep".into(),
11510        });
11511        let err = d.validate().unwrap_err();
11512        assert!(
11513            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11514            "got {err:?}",
11515        );
11516    }
11517
11518    #[test]
11519    fn fonte_caminho_shell_pipe_fires_before_shell_background() {
11520        // Cascade pin on the upstream shell-pipe arm: a value carrying
11521        // both `|` and `&` (`"../caixa-teia | tee & sleep"` — the
11522        // canonical "I pasted a `cmd | tee & sleep` background-pipeline
11523        // chain" footgun) routes through `FonteCaminhoShellPipe` not
11524        // `FonteCaminhoShellBackground`. The pipeline-tail paste is the
11525        // load-bearing root-cause edit on every probe-as-both value.
11526        let d = dep_with_fonte(DepSource::Path {
11527            caminho: "../caixa-teia | tee & sleep".into(),
11528        });
11529        let err = d.validate().unwrap_err();
11530        assert!(
11531            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11532            "got {err:?}",
11533        );
11534    }
11535
11536    #[test]
11537    fn fonte_caminho_shell_redirection_fires_before_shell_background() {
11538        // Cascade pin on the upstream shell-redirection arm: a value
11539        // carrying both `>` and `&` (`"../caixa-teia>log & sleep"` —
11540        // the canonical "I pasted a `cmd > log & sleep` background-
11541        // redirect chain" footgun) routes through
11542        // `FonteCaminhoShellRedirection` not
11543        // `FonteCaminhoShellBackground`. The input/output redirection
11544        // metachar carries the more self-locating `byte: u8` payload
11545        // (it names which of `<` or `>` triggered), so the prior arm
11546        // wins on every probe-as-both value.
11547        let d = dep_with_fonte(DepSource::Path {
11548            caminho: "../caixa-teia>log & sleep".into(),
11549        });
11550        let err = d.validate().unwrap_err();
11551        assert!(
11552            matches!(
11553                err,
11554                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11555            ),
11556            "got {err:?}",
11557        );
11558    }
11559
11560    #[test]
11561    fn fonte_caminho_backslash_fires_before_shell_background() {
11562        // Cascade pin on the upstream backslash arm: a value carrying
11563        // both `\` and `&` (`"..\caixa-teia & sleep"` — the canonical
11564        // "I pasted a Windows-shell `cd ..\path & sleep` background-
11565        // launch chain") routes through `FonteCaminhoBackslash` not
11566        // `FonteCaminhoShellBackground`. The cross-host-OS-separator
11567        // divergence is the load-bearing axis on every probe-as-both
11568        // value (an author who removes the `\` is the root-cause edit;
11569        // the `&` falls away in the same edit since it's downstream of
11570        // the Windows-shell convention).
11571        let d = dep_with_fonte(DepSource::Path {
11572            caminho: "..\\caixa-teia & sleep".into(),
11573        });
11574        let err = d.validate().unwrap_err();
11575        assert!(
11576            matches!(err, DepError::FonteCaminhoBackslash { .. }),
11577            "got {err:?}",
11578        );
11579    }
11580
11581    #[test]
11582    fn fonte_caminho_control_char_fires_before_shell_background() {
11583        // Cascade pin on the embedded-control-byte arm: a value
11584        // carrying both a control byte and `&` (`"../foo\n&sleep"` —
11585        // the canonical paste-from-multiline-doc footgun where a
11586        // newline landed mid-caminho) routes through
11587        // `FonteCaminhoControlChar` not `FonteCaminhoShellBackground`.
11588        // The POSIX-syscall-rejected-byte / NUL-`CString::new`-fail
11589        // diagnostic is the load-bearing axis on every value that
11590        // probes positive for both — mirrors the cascade discipline on
11591        // every prior arm.
11592        let d = dep_with_fonte(DepSource::Path {
11593            caminho: "../foo\n&sleep".into(),
11594        });
11595        let err = d.validate().unwrap_err();
11596        assert!(
11597            matches!(err, DepError::FonteCaminhoControlChar { .. }),
11598            "got {err:?}",
11599        );
11600    }
11601
11602    #[test]
11603    fn fonte_caminho_absolute_fires_before_shell_background() {
11604        // Cascade pin on the load-bearing leading-byte arm: a leading
11605        // `/` value with embedded `&` (`"/etc/passwd & sleep"`) routes
11606        // through `FonteCaminhoAbsolute` not
11607        // `FonteCaminhoShellBackground` — the host-layout-leak
11608        // diagnostic is the load-bearing axis, the `&` byte is the
11609        // secondary observation. Same precedence logic as every prior
11610        // leading-byte arm.
11611        let d = dep_with_fonte(DepSource::Path {
11612            caminho: "/etc/passwd & sleep".into(),
11613        });
11614        let err = d.validate().unwrap_err();
11615        assert!(
11616            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11617            "got {err:?}",
11618        );
11619    }
11620
11621    #[test]
11622    fn fonte_caminho_shell_background_fires_before_trailing_slash() {
11623        // Cascade pin on the immediate-successor arm: a value carrying
11624        // both `&` and a trailing `/` (`"../foo&sleep/"` — the
11625        // canonical "I tab-completed a path that already had a `&
11626        // sleep` background-launch tail" footgun) routes through
11627        // `FonteCaminhoShellBackground` not `FonteCaminhoTrailingSlash`.
11628        // The embedded shell-metachar is the more semantic-locating
11629        // axis (an author who removes the `&` typically also drops
11630        // the trailing separator since both are paste-from-shell
11631        // artifacts).
11632        let d = dep_with_fonte(DepSource::Path {
11633            caminho: "../foo&sleep/".into(),
11634        });
11635        let err = d.validate().unwrap_err();
11636        assert!(
11637            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11638            "got {err:?}",
11639        );
11640    }
11641
11642    #[test]
11643    fn fonte_caminho_shell_background_diagnostic_carries_offending_dep_and_caminho() {
11644        // Diagnostic-shape pin (peer with
11645        // `fonte_caminho_shell_semicolon_diagnostic_carries_offending_dep_and_caminho`
11646        // on the closest single-byte peer arm): the error's Display
11647        // surfaces the offending `:nome` and the offending `:caminho`
11648        // verbatim, and names the shell-background / logical-AND
11649        // footgun explicitly so a `feira lint` run can render the
11650        // diagnostic without re-parsing.
11651        let d = dep_with_fonte(DepSource::Path {
11652            caminho: "../caixa-teia & sleep 1".into(),
11653        });
11654        let rendered = d.validate().unwrap_err().to_string();
11655        assert!(
11656            rendered.contains("caixa-teia"),
11657            "diagnostic must name the offending dep: {rendered}",
11658        );
11659        assert!(
11660            rendered.contains("../caixa-teia & sleep 1"),
11661            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11662        );
11663        assert!(
11664            rendered.contains('&'),
11665            "diagnostic must reference the ampersand footgun: {rendered:?}",
11666        );
11667        assert!(
11668            rendered.contains("background") || rendered.contains("list-AND"),
11669            "diagnostic must name the shell-background / logical-AND footgun: {rendered:?}",
11670        );
11671    }
11672
11673    #[test]
11674    fn validate_rejects_path_fonte_with_caminho_carrying_backtick() {
11675        // The fail-before-pass-after pin for the canonical shell-
11676        // command-substitution paste footgun: an author copies a
11677        // POSIX legacy backticked one-liner (`"../caixa-teia/`whoami`"`
11678        // — the canonical "I pasted a path that included a `pwd`
11679        // / `whoami` / `date` legacy command-substitution expansion
11680        // out of a shell-history block") and silently passed every
11681        // prior arm (`Path::is_absolute` false on `..`, no control
11682        // bytes, no `\`, no `<` / `>`, no `|`, no `;`, no `&`, doesn't
11683        // end in `/`). The lacre embedded the value verbatim, the
11684        // resolver folded it through `Path::join` looking for a
11685        // literal `./../caixa-teia/`whoami`` subdirectory, and the
11686        // failure surfaced at resolve time with a non-self-locating
11687        // `No such file or directory` error. The new arm moves the
11688        // rejection to validate time and names the offending dep +
11689        // caminho verbatim.
11690        let d = dep_with_fonte(DepSource::Path {
11691            caminho: "../caixa-teia/`whoami`".into(),
11692        });
11693        let err = d.validate().unwrap_err();
11694        let DepError::FonteCaminhoShellCommandSubstitution { nome, caminho } = err else {
11695            panic!("expected FonteCaminhoShellCommandSubstitution, got {err:?}");
11696        };
11697        assert_eq!(nome, "caixa-teia");
11698        assert_eq!(caminho, "../caixa-teia/`whoami`");
11699    }
11700
11701    #[test]
11702    fn validate_rejects_path_fonte_with_caminho_carrying_leading_backtick() {
11703        // Leading-position backtick shape (``"`pwd`/caixa-teia"`` —
11704        // the canonical `<backtick>pwd<backtick>/path` working-
11705        // directory expansion shape every shell-side path-composition
11706        // idiom carries). Pinned separately from the embedded-byte
11707        // shape so the gate covers every position, not only mid-path.
11708        let d = dep_with_fonte(DepSource::Path {
11709            caminho: "`pwd`/caixa-teia".into(),
11710        });
11711        let err = d.validate().unwrap_err();
11712        assert!(
11713            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11714            "got {err:?}",
11715        );
11716    }
11717
11718    #[test]
11719    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_backtick() {
11720        // Trailing-position backtick shape (`"../caixa-teia`"` — the
11721        // degenerate "I selected an unbalanced backtick out of a
11722        // shell-history block" idiom that probes for the cascade's
11723        // last-byte handling). The trailing-`/` arm fires only on
11724        // last-byte `/`; an unbalanced trailing backtick must route
11725        // through this arm regardless of position.
11726        let d = dep_with_fonte(DepSource::Path {
11727            caminho: "../caixa-teia`".into(),
11728        });
11729        let err = d.validate().unwrap_err();
11730        assert!(
11731            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11732            "got {err:?}",
11733        );
11734    }
11735
11736    #[test]
11737    fn validate_rejects_path_fonte_with_caminho_carrying_balanced_backtick_pair() {
11738        // The canonical balanced-pair shape (``"../<backtick>cat
11739        // /etc/passwd<backtick>"`` — the canonical CWE-78 shell-
11740        // command-injection paste idiom every shell-side hardening
11741        // guide enumerates first). The arm fires on the first
11742        // backtick encountered; pinned so a future arm that tries to
11743        // distinguish the opening from the closing byte doesn't break
11744        // the broader contract.
11745        let d = dep_with_fonte(DepSource::Path {
11746            caminho: "../`cat /etc/passwd`".into(),
11747        });
11748        let err = d.validate().unwrap_err();
11749        assert!(
11750            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11751            "got {err:?}",
11752        );
11753    }
11754
11755    #[test]
11756    fn validate_accepts_path_fonte_with_caminho_carrying_no_backtick() {
11757        // The positive-control pin: the gate targets only the
11758        // backtick byte, never adjacent printable ASCII or POSIX-
11759        // valid bytes. The canonical relative POSIX path
11760        // (`"../caixa-teia"`) and a nested deeply-pathed variant with
11761        // adjacent printable punctuation
11762        // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
11763        // cleanly so the gate doesn't widen to a "no printable
11764        // punctuation anywhere" sweep that would defeat the entire
11765        // path-fonte author surface.
11766        let d = dep_with_fonte(DepSource::Path {
11767            caminho: "../caixa-teia/sub-dir.v2".into(),
11768        });
11769        d.validate().unwrap();
11770    }
11771
11772    #[test]
11773    fn fonte_caminho_shell_background_fires_before_shell_command_substitution() {
11774        // Cascade pin on the immediate-predecessor arm: a value
11775        // carrying both `&` and a backtick (``"../caixa-teia &
11776        // <backtick>sleep 1<backtick>"`` — the canonical "I pasted a
11777        // `cmd & <backtick>sleep N<backtick>` background-launch +
11778        // command-substitution chain" footgun) routes through
11779        // `FonteCaminhoShellBackground` not
11780        // `FonteCaminhoShellCommandSubstitution`. The background-
11781        // launch tail is the more common shell-history paste idiom
11782        // on every probe-as-both value — same cascade discipline
11783        // every prior `:caminho` arm establishes.
11784        let d = dep_with_fonte(DepSource::Path {
11785            caminho: "../caixa-teia & `sleep 1`".into(),
11786        });
11787        let err = d.validate().unwrap_err();
11788        assert!(
11789            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11790            "got {err:?}",
11791        );
11792    }
11793
11794    #[test]
11795    fn fonte_caminho_shell_semicolon_fires_before_shell_command_substitution() {
11796        // Cascade pin on the upstream shell-semicolon arm: a value
11797        // carrying both `;` and a backtick (``"../caixa-teia;
11798        // <backtick>whoami<backtick>"`` — the canonical "I pasted a
11799        // `cmd; <backtick>follow-up<backtick>` sequential-chain
11800        // footgun) routes through `FonteCaminhoShellSemicolon` not
11801        // `FonteCaminhoShellCommandSubstitution`. The sequential-
11802        // command-separator paste is the load-bearing root-cause
11803        // edit on every probe-as-both value.
11804        let d = dep_with_fonte(DepSource::Path {
11805            caminho: "../caixa-teia; `whoami`".into(),
11806        });
11807        let err = d.validate().unwrap_err();
11808        assert!(
11809            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11810            "got {err:?}",
11811        );
11812    }
11813
11814    #[test]
11815    fn fonte_caminho_shell_pipe_fires_before_shell_command_substitution() {
11816        // Cascade pin on the upstream shell-pipe arm: a value
11817        // carrying both `|` and a backtick (``"../caixa-teia |
11818        // <backtick>tee log<backtick>"`` — the canonical pipeline-to-
11819        // command-substitution paste idiom) routes through
11820        // `FonteCaminhoShellPipe` not
11821        // `FonteCaminhoShellCommandSubstitution`. The pipeline-tail
11822        // paste is the load-bearing root-cause edit on every
11823        // probe-as-both value.
11824        let d = dep_with_fonte(DepSource::Path {
11825            caminho: "../caixa-teia | `tee log`".into(),
11826        });
11827        let err = d.validate().unwrap_err();
11828        assert!(
11829            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11830            "got {err:?}",
11831        );
11832    }
11833
11834    #[test]
11835    fn fonte_caminho_shell_redirection_fires_before_shell_command_substitution() {
11836        // Cascade pin on the upstream shell-redirection arm: a value
11837        // carrying both `>` and a backtick (``"../caixa-teia>log
11838        // <backtick>date<backtick>"`` — the canonical "I pasted a
11839        // `cmd > log <backtick>date<backtick>` redirect-plus-
11840        // substitution chain" footgun) routes through
11841        // `FonteCaminhoShellRedirection` not
11842        // `FonteCaminhoShellCommandSubstitution`. The input/output
11843        // redirection metachar carries the more self-locating `byte`
11844        // payload (it names which of `<` or `>` triggered), so the
11845        // prior arm wins on every probe-as-both value.
11846        let d = dep_with_fonte(DepSource::Path {
11847            caminho: "../caixa-teia>log `date`".into(),
11848        });
11849        let err = d.validate().unwrap_err();
11850        assert!(
11851            matches!(
11852                err,
11853                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11854            ),
11855            "got {err:?}",
11856        );
11857    }
11858
11859    #[test]
11860    fn fonte_caminho_backslash_fires_before_shell_command_substitution() {
11861        // Cascade pin on the upstream backslash arm: a value
11862        // carrying both `\` and a backtick (``"..\caixa-teia
11863        // <backtick>whoami<backtick>"`` — the canonical "I pasted a
11864        // Windows-shell `cd ..\path <backtick>whoami<backtick>`
11865        // chain") routes through `FonteCaminhoBackslash` not
11866        // `FonteCaminhoShellCommandSubstitution`. The cross-host-OS-
11867        // separator divergence is the load-bearing axis on every
11868        // probe-as-both value (an author who removes the `\` is the
11869        // root-cause edit; the backtick falls away in the same edit
11870        // since it's downstream of the Windows-shell convention).
11871        let d = dep_with_fonte(DepSource::Path {
11872            caminho: "..\\caixa-teia `whoami`".into(),
11873        });
11874        let err = d.validate().unwrap_err();
11875        assert!(
11876            matches!(err, DepError::FonteCaminhoBackslash { .. }),
11877            "got {err:?}",
11878        );
11879    }
11880
11881    #[test]
11882    fn fonte_caminho_control_char_fires_before_shell_command_substitution() {
11883        // Cascade pin on the embedded-control-byte arm: a value
11884        // carrying both a control byte and a backtick (`"../foo\n
11885        // `whoami`"` — the canonical paste-from-multiline-doc
11886        // footgun where a newline landed mid-caminho between two
11887        // paste fragments) routes through `FonteCaminhoControlChar`
11888        // not `FonteCaminhoShellCommandSubstitution`. The POSIX-
11889        // syscall-rejected-byte / NUL-`CString::new`-fail diagnostic
11890        // is the load-bearing axis on every value that probes
11891        // positive for both — mirrors the cascade discipline on
11892        // every prior arm.
11893        let d = dep_with_fonte(DepSource::Path {
11894            caminho: "../foo\n`whoami`".into(),
11895        });
11896        let err = d.validate().unwrap_err();
11897        assert!(
11898            matches!(err, DepError::FonteCaminhoControlChar { .. }),
11899            "got {err:?}",
11900        );
11901    }
11902
11903    #[test]
11904    fn fonte_caminho_absolute_fires_before_shell_command_substitution() {
11905        // Cascade pin on the load-bearing leading-byte arm: a
11906        // leading `/` value with embedded backtick (``"/etc/passwd
11907        // <backtick>whoami<backtick>"``) routes through
11908        // `FonteCaminhoAbsolute` not
11909        // `FonteCaminhoShellCommandSubstitution` — the host-layout-
11910        // leak diagnostic is the load-bearing axis, the backtick
11911        // byte is the secondary observation. Same precedence logic
11912        // as every prior leading-byte arm.
11913        let d = dep_with_fonte(DepSource::Path {
11914            caminho: "/etc/passwd `whoami`".into(),
11915        });
11916        let err = d.validate().unwrap_err();
11917        assert!(
11918            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11919            "got {err:?}",
11920        );
11921    }
11922
11923    #[test]
11924    fn fonte_caminho_shell_command_substitution_fires_before_trailing_slash() {
11925        // Cascade pin on the immediate-successor arm: a value
11926        // carrying both a backtick and a trailing `/`
11927        // (``"../`whoami`/"`` — the canonical "I tab-completed a
11928        // path that already had a backticked `whoami` substitution
11929        // tail" footgun) routes through
11930        // `FonteCaminhoShellCommandSubstitution` not
11931        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
11932        // is the more semantic-locating axis (an author who removes
11933        // the backtick typically also drops the trailing separator
11934        // since both are paste-from-shell artifacts).
11935        let d = dep_with_fonte(DepSource::Path {
11936            caminho: "../`whoami`/".into(),
11937        });
11938        let err = d.validate().unwrap_err();
11939        assert!(
11940            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11941            "got {err:?}",
11942        );
11943    }
11944
11945    #[test]
11946    fn fonte_caminho_shell_command_substitution_diagnostic_carries_offending_dep_and_caminho() {
11947        // Diagnostic-shape pin (peer with
11948        // `fonte_caminho_shell_background_diagnostic_carries_offending_dep_and_caminho`
11949        // on the closest single-byte peer arm): the error's Display
11950        // surfaces the offending `:nome` and the offending `:caminho`
11951        // verbatim, and names the shell-command-substitution footgun
11952        // explicitly so a `feira lint` run can render the diagnostic
11953        // without re-parsing.
11954        let d = dep_with_fonte(DepSource::Path {
11955            caminho: "../caixa-teia/`whoami`".into(),
11956        });
11957        let rendered = d.validate().unwrap_err().to_string();
11958        assert!(
11959            rendered.contains("caixa-teia"),
11960            "diagnostic must name the offending dep: {rendered}",
11961        );
11962        assert!(
11963            rendered.contains("../caixa-teia/`whoami`"),
11964            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11965        );
11966        assert!(
11967            rendered.contains('`'),
11968            "diagnostic must reference the backtick footgun: {rendered:?}",
11969        );
11970        assert!(
11971            rendered.contains("command-substitution"),
11972            "diagnostic must name the shell-command-substitution footgun: {rendered:?}",
11973        );
11974    }
11975
11976    #[test]
11977    fn validate_rejects_path_fonte_with_caminho_carrying_star_glob() {
11978        // The fail-before-pass-after pin for the canonical pathname-
11979        // expansion paste footgun: an author copies an `ls
11980        // ../caixa-teia/*` shell-listing tail into the `:caminho`
11981        // slot and silently passes every prior arm
11982        // (`Path::is_absolute` false on `..`, no control bytes, no
11983        // `\`, no `<` / `>`, no `|`, no `;`, no `&`, no backtick,
11984        // doesn't end in `/`). The lacre embedded the value
11985        // verbatim, the resolver folded it through `Path::join`
11986        // looking for a literal `./../caixa-teia/*` subdirectory,
11987        // and the failure surfaced at resolve time with a non-self-
11988        // locating `No such file or directory` error. The new arm
11989        // moves the rejection to validate time and names the
11990        // offending dep + caminho + byte verbatim.
11991        let d = dep_with_fonte(DepSource::Path {
11992            caminho: "../caixa-teia/*".into(),
11993        });
11994        let err = d.validate().unwrap_err();
11995        let DepError::FonteCaminhoShellGlob {
11996            nome,
11997            caminho,
11998            byte,
11999        } = err
12000        else {
12001            panic!("expected FonteCaminhoShellGlob, got {err:?}");
12002        };
12003        assert_eq!(nome, "caixa-teia");
12004        assert_eq!(caminho, "../caixa-teia/*");
12005        assert_eq!(byte, b'*');
12006    }
12007
12008    #[test]
12009    fn validate_rejects_path_fonte_with_caminho_carrying_question_glob() {
12010        // The symmetric single-char-wildcard paste shape
12011        // (`"../foo?"` — the canonical "I copied a `rm foo?` line
12012        // out of shell history" idiom). Pinned separately from the
12013        // `*` shape so the gate's contract is "any `*` or `?`
12014        // anywhere", not single-byte coverage.
12015        let d = dep_with_fonte(DepSource::Path {
12016            caminho: "../foo?".into(),
12017        });
12018        let err = d.validate().unwrap_err();
12019        let DepError::FonteCaminhoShellGlob { byte, .. } = err else {
12020            panic!("expected FonteCaminhoShellGlob, got {err:?}");
12021        };
12022        assert_eq!(byte, b'?');
12023    }
12024
12025    #[test]
12026    fn validate_rejects_path_fonte_with_caminho_carrying_leading_star_glob() {
12027        // Leading-position `*` shape (`"*/caixa-teia"` — the
12028        // degenerate "I selected only the wildcard prefix out of a
12029        // shell-glob expression" idiom). Pinned separately from the
12030        // embedded-byte shapes so the gate covers every position,
12031        // not only mid-path.
12032        let d = dep_with_fonte(DepSource::Path {
12033            caminho: "*/caixa-teia".into(),
12034        });
12035        let err = d.validate().unwrap_err();
12036        assert!(
12037            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12038            "got {err:?}",
12039        );
12040    }
12041
12042    #[test]
12043    fn validate_rejects_path_fonte_with_caminho_carrying_double_star_recursive_glob() {
12044        // The bash/zsh `globstar` recursive-glob shape
12045        // (`"../caixa-teia/**/foo"` — the canonical "I copied a
12046        // `find ../caixa-teia/**/foo` recursive expansion" idiom).
12047        // The arm fires on the first `*` encountered; pinned so a
12048        // future arm that tries to distinguish single `*` from
12049        // double `**` doesn't break the broader contract.
12050        let d = dep_with_fonte(DepSource::Path {
12051            caminho: "../caixa-teia/**/foo".into(),
12052        });
12053        let err = d.validate().unwrap_err();
12054        assert!(
12055            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12056            "got {err:?}",
12057        );
12058    }
12059
12060    #[test]
12061    fn validate_rejects_path_fonte_with_caminho_carrying_dotted_extension_glob() {
12062        // The canonical extension-glob shape (`"../caixa-teia/*.lisp"`
12063        // — the "I selected `*.lisp` to mean every Lisp source file
12064        // in the dep root" footgun the prior arms structurally
12065        // cannot catch since `.` is a POSIX-valid path-component
12066        // byte). Pinned so the gate's contract covers the most
12067        // idiomatic glob-paste shape every author meets first.
12068        let d = dep_with_fonte(DepSource::Path {
12069            caminho: "../caixa-teia/*.lisp".into(),
12070        });
12071        let err = d.validate().unwrap_err();
12072        assert!(
12073            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12074            "got {err:?}",
12075        );
12076    }
12077
12078    #[test]
12079    fn validate_accepts_path_fonte_with_caminho_carrying_no_glob() {
12080        // The positive-control pin: the gate targets only `*` /
12081        // `?`, never adjacent printable ASCII or POSIX-valid bytes.
12082        // The canonical relative POSIX path (`"../caixa-teia"`) and
12083        // a nested deeply-pathed variant with adjacent printable
12084        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
12085        // to validate cleanly so the gate doesn't widen to a "no
12086        // printable punctuation anywhere" sweep that would defeat
12087        // the entire path-fonte author surface.
12088        let d = dep_with_fonte(DepSource::Path {
12089            caminho: "../caixa-teia/sub-dir.v2".into(),
12090        });
12091        d.validate().unwrap();
12092    }
12093
12094    #[test]
12095    fn fonte_caminho_shell_command_substitution_fires_before_shell_glob() {
12096        // Cascade pin on the immediate-predecessor arm: a value
12097        // carrying both a backtick and `*` (``"../`whoami`/*"`` —
12098        // the canonical "I pasted a `cd <backtick>whoami<backtick>/*`
12099        // command-substitution + glob chain") routes through
12100        // `FonteCaminhoShellCommandSubstitution` not
12101        // `FonteCaminhoShellGlob`. The CWE-78 shell-command-
12102        // injection vector is the load-bearing root-cause edit on
12103        // every probe-as-both value — same cascade discipline every
12104        // prior `:caminho` arm establishes.
12105        let d = dep_with_fonte(DepSource::Path {
12106            caminho: "../`whoami`/*".into(),
12107        });
12108        let err = d.validate().unwrap_err();
12109        assert!(
12110            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
12111            "got {err:?}",
12112        );
12113    }
12114
12115    #[test]
12116    fn fonte_caminho_shell_background_fires_before_shell_glob() {
12117        // Cascade pin on the upstream shell-background arm: a value
12118        // carrying both `&` and `*` (`"../caixa-teia & ls /*"` — the
12119        // canonical "I pasted a `cmd & ls /*` background + glob
12120        // chain" footgun) routes through `FonteCaminhoShellBackground`
12121        // not `FonteCaminhoShellGlob`. The background-launch tail is
12122        // the load-bearing root-cause edit on every probe-as-both
12123        // value.
12124        let d = dep_with_fonte(DepSource::Path {
12125            caminho: "../caixa-teia & ls /*".into(),
12126        });
12127        let err = d.validate().unwrap_err();
12128        assert!(
12129            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
12130            "got {err:?}",
12131        );
12132    }
12133
12134    #[test]
12135    fn fonte_caminho_shell_semicolon_fires_before_shell_glob() {
12136        // Cascade pin on the upstream shell-semicolon arm: a value
12137        // carrying both `;` and `*` (`"../caixa-teia; rm *"` — the
12138        // canonical sequential-cleanup + glob paste idiom) routes
12139        // through `FonteCaminhoShellSemicolon` not
12140        // `FonteCaminhoShellGlob`. The sequential-command-separator
12141        // paste is the load-bearing root-cause edit on every
12142        // probe-as-both value.
12143        let d = dep_with_fonte(DepSource::Path {
12144            caminho: "../caixa-teia; rm *".into(),
12145        });
12146        let err = d.validate().unwrap_err();
12147        assert!(
12148            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
12149            "got {err:?}",
12150        );
12151    }
12152
12153    #[test]
12154    fn fonte_caminho_shell_pipe_fires_before_shell_glob() {
12155        // Cascade pin on the upstream shell-pipe arm: a value
12156        // carrying both `|` and `*` (`"../caixa-teia | ls *"` — the
12157        // canonical pipeline-to-glob paste idiom) routes through
12158        // `FonteCaminhoShellPipe` not `FonteCaminhoShellGlob`. The
12159        // pipeline-tail paste is the load-bearing root-cause edit
12160        // on every probe-as-both value.
12161        let d = dep_with_fonte(DepSource::Path {
12162            caminho: "../caixa-teia | ls *".into(),
12163        });
12164        let err = d.validate().unwrap_err();
12165        assert!(
12166            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
12167            "got {err:?}",
12168        );
12169    }
12170
12171    #[test]
12172    fn fonte_caminho_shell_redirection_fires_before_shell_glob() {
12173        // Cascade pin on the upstream shell-redirection arm: a value
12174        // carrying both `>` and `*` (`"../caixa-teia>log *"` — the
12175        // canonical "I pasted a `cmd > log *` redirect-plus-glob
12176        // chain" footgun) routes through
12177        // `FonteCaminhoShellRedirection` not `FonteCaminhoShellGlob`.
12178        // The input/output redirection metachar carries the more
12179        // self-locating `byte` payload (it names which of `<` or `>`
12180        // triggered), so the prior arm wins on every probe-as-both
12181        // value.
12182        let d = dep_with_fonte(DepSource::Path {
12183            caminho: "../caixa-teia>log *".into(),
12184        });
12185        let err = d.validate().unwrap_err();
12186        assert!(
12187            matches!(
12188                err,
12189                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
12190            ),
12191            "got {err:?}",
12192        );
12193    }
12194
12195    #[test]
12196    fn fonte_caminho_backslash_fires_before_shell_glob() {
12197        // Cascade pin on the upstream backslash arm: a value
12198        // carrying both `\` and `*` (`"..\caixa-teia\*"` — the
12199        // canonical "I pasted a Windows-shell `cd ..\path\*` glob
12200        // expression" footgun) routes through
12201        // `FonteCaminhoBackslash` not `FonteCaminhoShellGlob`. The
12202        // cross-host-OS-separator divergence is the load-bearing
12203        // axis on every probe-as-both value (an author who removes
12204        // the `\` is the root-cause edit; the `*` falls away in the
12205        // same edit since it's downstream of the Windows-shell
12206        // convention).
12207        let d = dep_with_fonte(DepSource::Path {
12208            caminho: "..\\caixa-teia\\*".into(),
12209        });
12210        let err = d.validate().unwrap_err();
12211        assert!(
12212            matches!(err, DepError::FonteCaminhoBackslash { .. }),
12213            "got {err:?}",
12214        );
12215    }
12216
12217    #[test]
12218    fn fonte_caminho_control_char_fires_before_shell_glob() {
12219        // Cascade pin on the embedded-control-byte arm: a value
12220        // carrying both a control byte and `*` (`"../foo\n*"` — the
12221        // canonical paste-from-multiline-doc footgun where a
12222        // newline landed mid-caminho between two paste fragments)
12223        // routes through `FonteCaminhoControlChar` not
12224        // `FonteCaminhoShellGlob`. The POSIX-syscall-rejected-byte /
12225        // NUL-`CString::new`-fail diagnostic is the load-bearing
12226        // axis on every value that probes positive for both —
12227        // mirrors the cascade discipline on every prior arm.
12228        let d = dep_with_fonte(DepSource::Path {
12229            caminho: "../foo\n*".into(),
12230        });
12231        let err = d.validate().unwrap_err();
12232        assert!(
12233            matches!(err, DepError::FonteCaminhoControlChar { .. }),
12234            "got {err:?}",
12235        );
12236    }
12237
12238    #[test]
12239    fn fonte_caminho_absolute_fires_before_shell_glob() {
12240        // Cascade pin on the load-bearing leading-byte arm: a
12241        // leading `/` value with embedded `*` (`"/etc/*"`) routes
12242        // through `FonteCaminhoAbsolute` not `FonteCaminhoShellGlob`
12243        // — the host-layout-leak diagnostic is the load-bearing
12244        // axis, the glob byte is the secondary observation. Same
12245        // precedence logic as every prior leading-byte arm.
12246        let d = dep_with_fonte(DepSource::Path {
12247            caminho: "/etc/*".into(),
12248        });
12249        let err = d.validate().unwrap_err();
12250        assert!(
12251            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
12252            "got {err:?}",
12253        );
12254    }
12255
12256    #[test]
12257    fn fonte_caminho_shell_glob_fires_before_trailing_slash() {
12258        // Cascade pin on the immediate-successor arm: a value
12259        // carrying both `*` and a trailing `/` (`"../foo*/"` — the
12260        // canonical "I tab-completed a path that already had a
12261        // glob-expansion tail" footgun) routes through
12262        // `FonteCaminhoShellGlob` not `FonteCaminhoTrailingSlash`.
12263        // The embedded shell-metachar is the more semantic-locating
12264        // axis (an author who removes the `*` typically also drops
12265        // the trailing separator since both are paste-from-shell
12266        // artifacts).
12267        let d = dep_with_fonte(DepSource::Path {
12268            caminho: "../foo*/".into(),
12269        });
12270        let err = d.validate().unwrap_err();
12271        assert!(
12272            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12273            "got {err:?}",
12274        );
12275    }
12276
12277    #[test]
12278    fn fonte_caminho_shell_glob_diagnostic_carries_offending_dep_caminho_and_byte() {
12279        // Diagnostic-shape pin (peer with
12280        // `fonte_caminho_shell_redirection_diagnostic_*` on the
12281        // closest two-byte peer arm): the error's Display surfaces
12282        // the offending `:nome`, the offending `:caminho` verbatim,
12283        // the offending byte's hex / character form, and names the
12284        // shell-glob / pathname-expansion footgun explicitly so a
12285        // `feira lint` run can render the diagnostic without
12286        // re-parsing.
12287        let d = dep_with_fonte(DepSource::Path {
12288            caminho: "../caixa-teia/*.lisp".into(),
12289        });
12290        let rendered = d.validate().unwrap_err().to_string();
12291        assert!(
12292            rendered.contains("caixa-teia"),
12293            "diagnostic must name the offending dep: {rendered}",
12294        );
12295        assert!(
12296            rendered.contains("../caixa-teia/*.lisp"),
12297            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
12298        );
12299        assert!(
12300            rendered.contains("0x2a"),
12301            "diagnostic must surface the offending byte hex: {rendered:?}",
12302        );
12303        assert!(
12304            rendered.contains("glob"),
12305            "diagnostic must name the shell-glob footgun: {rendered:?}",
12306        );
12307        assert!(
12308            rendered.contains("pathname-expansion"),
12309            "diagnostic must reference the POSIX pathname-expansion vocabulary: {rendered:?}",
12310        );
12311    }
12312
12313    #[test]
12314    fn validate_rejects_path_fonte_with_caminho_carrying_modern_command_substitution() {
12315        // The fail-before-pass-after pin for the canonical modern-Bourne
12316        // command-substitution paste footgun: an author copies a
12317        // `cd ../caixa-teia/$(date)/build` shell-history one-liner whose
12318        // `$(<cmd>)` expansion would land the current date as a
12319        // subdirectory name and silently passed every prior arm
12320        // (`Path::is_absolute` false on `..`, no control bytes, no `\`,
12321        // no `<` / `>`, no `|`, no `;`, no `&`, no backtick, no `*` /
12322        // `?`, doesn't end in `/`; the leading-`$` f4efe9c
12323        // `FonteCaminhoVarExpansion` arm doesn't fire because the `$`
12324        // sits mid-path). The lacre embedded the value verbatim, the
12325        // resolver folded it through `Path::join` looking for a literal
12326        // `./../caixa-teia/$(date)/build` subdirectory, and the failure
12327        // surfaced at resolve time with a non-self-locating `No such
12328        // file or directory` error. The new arm moves the rejection to
12329        // validate time and names the offending dep + caminho + byte
12330        // verbatim. The arm fires on the first `(` encountered (the
12331        // opening byte of `$(date)`).
12332        let d = dep_with_fonte(DepSource::Path {
12333            caminho: "../caixa-teia/$(date)/build".into(),
12334        });
12335        let err = d.validate().unwrap_err();
12336        let DepError::FonteCaminhoShellSubshellGrouping {
12337            nome,
12338            caminho,
12339            byte,
12340        } = err
12341        else {
12342            panic!("expected FonteCaminhoShellSubshellGrouping, got {err:?}");
12343        };
12344        assert_eq!(nome, "caixa-teia");
12345        assert_eq!(caminho, "../caixa-teia/$(date)/build");
12346        assert_eq!(byte, b'(');
12347    }
12348
12349    #[test]
12350    fn validate_rejects_path_fonte_with_caminho_carrying_close_paren() {
12351        // The symmetric close-paren paste shape (`"../caixa-teia)"` —
12352        // the degenerate "I selected an unbalanced closing paren out of
12353        // a shell-history block" idiom that probes for the cascade's
12354        // last-byte handling on a value carrying only the closing byte).
12355        // Pinned separately from the open-paren shape so the gate's
12356        // contract is "any `(` or `)` anywhere", not single-byte
12357        // coverage. Mirrors the peer `validate_rejects_path_fonte_with_\
12358        // caminho_carrying_question_glob` shape on the immediate-
12359        // predecessor `FonteCaminhoShellGlob` arm.
12360        let d = dep_with_fonte(DepSource::Path {
12361            caminho: "../caixa-teia)".into(),
12362        });
12363        let err = d.validate().unwrap_err();
12364        let DepError::FonteCaminhoShellSubshellGrouping { byte, .. } = err else {
12365            panic!("expected FonteCaminhoShellSubshellGrouping, got {err:?}");
12366        };
12367        assert_eq!(byte, b')');
12368    }
12369
12370    #[test]
12371    fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_paren() {
12372        // Leading-position `(` shape (`"(cd foo)/caixa-teia"` — the
12373        // canonical "I selected a `(cd foo)` subshell-grouping prefix
12374        // out of a `(cd foo) && cmd` shell-history one-liner" idiom).
12375        // Pinned separately from the embedded-byte shape so the gate
12376        // covers every position, not only mid-path.
12377        let d = dep_with_fonte(DepSource::Path {
12378            caminho: "(cd foo)/caixa-teia".into(),
12379        });
12380        let err = d.validate().unwrap_err();
12381        assert!(
12382            matches!(
12383                err,
12384                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
12385            ),
12386            "got {err:?}",
12387        );
12388    }
12389
12390    #[test]
12391    fn validate_rejects_path_fonte_with_caminho_carrying_balanced_subshell_grouping_pair() {
12392        // The canonical balanced-pair shape (`"../(pwd)/caixa-teia"`
12393        // — the canonical "I copied a `(pwd)` working-directory-probe
12394        // subshell-grouping idiom every shell-history block carries"
12395        // footgun). The value carries no other cascade-preceding
12396        // shell metachar (`&` / `;` / `|` / `<` / `>` / backtick /
12397        // `*` / `?`) so the arm fires on the first `(` encountered;
12398        // pinned so a future arm that tries to distinguish the
12399        // opening from the closing byte doesn't break the broader
12400        // contract. Mirrors the peer
12401        // `validate_rejects_path_fonte_with_caminho_carrying_balanced_\
12402        // backtick_pair` shape on the upstream `FonteCaminhoShell\
12403        // CommandSubstitution` arm.
12404        let d = dep_with_fonte(DepSource::Path {
12405            caminho: "../(pwd)/caixa-teia".into(),
12406        });
12407        let err = d.validate().unwrap_err();
12408        assert!(
12409            matches!(
12410                err,
12411                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
12412            ),
12413            "got {err:?}",
12414        );
12415    }
12416
12417    #[test]
12418    fn validate_accepts_path_fonte_with_caminho_carrying_no_subshell_grouping() {
12419        // The positive-control pin: the gate targets only `(` / `)`,
12420        // never adjacent printable ASCII or POSIX-valid bytes. The
12421        // canonical relative POSIX path (`"../caixa-teia"`) and a
12422        // nested deeply-pathed variant with adjacent printable
12423        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue to
12424        // validate cleanly so the gate doesn't widen to a "no printable
12425        // punctuation anywhere" sweep that would defeat the entire
12426        // path-fonte author surface.
12427        let d = dep_with_fonte(DepSource::Path {
12428            caminho: "../caixa-teia/sub-dir.v2".into(),
12429        });
12430        d.validate().unwrap();
12431    }
12432
12433    #[test]
12434    fn fonte_caminho_shell_glob_fires_before_shell_subshell_grouping() {
12435        // Cascade pin on the immediate-predecessor arm: a value
12436        // carrying both `*` and `(` (`"../caixa-teia/*(date)"` — the
12437        // canonical "I pasted a glob expansion followed by a
12438        // subshell-grouping tail" footgun) routes through
12439        // `FonteCaminhoShellGlob` not
12440        // `FonteCaminhoShellSubshellGrouping`. The pathname-expansion
12441        // shape is the more common shell-history paste idiom on every
12442        // probe-as-both value — same cascade discipline every prior
12443        // `:caminho` arm establishes.
12444        let d = dep_with_fonte(DepSource::Path {
12445            caminho: "../caixa-teia/*(date)".into(),
12446        });
12447        let err = d.validate().unwrap_err();
12448        assert!(
12449            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12450            "got {err:?}",
12451        );
12452    }
12453
12454    #[test]
12455    fn fonte_caminho_shell_command_substitution_fires_before_shell_subshell_grouping() {
12456        // Cascade pin on the upstream shell-command-substitution arm: a
12457        // value carrying both a backtick and `(` (``"../`whoami`/$(date)"``
12458        // — the canonical "I pasted a legacy-backtick + modern-paren
12459        // command-substitution chain" footgun) routes through
12460        // `FonteCaminhoShellCommandSubstitution` not
12461        // `FonteCaminhoShellSubshellGrouping`. The CWE-78 shell-
12462        // command-injection vector is the load-bearing root-cause edit
12463        // on every probe-as-both value.
12464        let d = dep_with_fonte(DepSource::Path {
12465            caminho: "../`whoami`/$(date)".into(),
12466        });
12467        let err = d.validate().unwrap_err();
12468        assert!(
12469            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
12470            "got {err:?}",
12471        );
12472    }
12473
12474    #[test]
12475    fn fonte_caminho_shell_background_fires_before_shell_subshell_grouping() {
12476        // Cascade pin on the upstream shell-background arm: a value
12477        // carrying both `&` and `(` (`"../caixa-teia & (cd foo)"` —
12478        // the canonical "I pasted a `cmd & (cd foo)` background-launch
12479        // + subshell-grouping chain" footgun) routes through
12480        // `FonteCaminhoShellBackground` not
12481        // `FonteCaminhoShellSubshellGrouping`. The background-launch
12482        // tail is the load-bearing root-cause edit on every probe-as-
12483        // both value.
12484        let d = dep_with_fonte(DepSource::Path {
12485            caminho: "../caixa-teia & (cd foo)".into(),
12486        });
12487        let err = d.validate().unwrap_err();
12488        assert!(
12489            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
12490            "got {err:?}",
12491        );
12492    }
12493
12494    #[test]
12495    fn fonte_caminho_shell_semicolon_fires_before_shell_subshell_grouping() {
12496        // Cascade pin on the upstream shell-semicolon arm: a value
12497        // carrying both `;` and `(` (`"../caixa-teia; (cd foo)"` —
12498        // the canonical sequential-cleanup + subshell-grouping paste
12499        // idiom) routes through `FonteCaminhoShellSemicolon` not
12500        // `FonteCaminhoShellSubshellGrouping`. The sequential-command-
12501        // separator paste is the load-bearing root-cause edit on
12502        // every probe-as-both value.
12503        let d = dep_with_fonte(DepSource::Path {
12504            caminho: "../caixa-teia; (cd foo)".into(),
12505        });
12506        let err = d.validate().unwrap_err();
12507        assert!(
12508            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
12509            "got {err:?}",
12510        );
12511    }
12512
12513    #[test]
12514    fn fonte_caminho_shell_pipe_fires_before_shell_subshell_grouping() {
12515        // Cascade pin on the upstream shell-pipe arm: a value carrying
12516        // both `|` and `(` (`"../caixa-teia | (tee log)"` — the
12517        // canonical pipeline-to-subshell-grouping paste idiom) routes
12518        // through `FonteCaminhoShellPipe` not
12519        // `FonteCaminhoShellSubshellGrouping`. The pipeline-tail paste
12520        // is the load-bearing root-cause edit on every probe-as-both
12521        // value.
12522        let d = dep_with_fonte(DepSource::Path {
12523            caminho: "../caixa-teia | (tee log)".into(),
12524        });
12525        let err = d.validate().unwrap_err();
12526        assert!(
12527            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
12528            "got {err:?}",
12529        );
12530    }
12531
12532    #[test]
12533    fn fonte_caminho_shell_redirection_fires_before_shell_subshell_grouping() {
12534        // Cascade pin on the upstream shell-redirection arm: a value
12535        // carrying both `>` and `(` (`"../caixa-teia>log (cd foo)"` —
12536        // the canonical "I pasted a `cmd > log (cd foo)` redirect-
12537        // plus-subshell-grouping chain" footgun) routes through
12538        // `FonteCaminhoShellRedirection` not
12539        // `FonteCaminhoShellSubshellGrouping`. The input/output
12540        // redirection metachar carries the more self-locating `byte`
12541        // payload (it names which of `<` or `>` triggered), so the
12542        // prior arm wins on every probe-as-both value.
12543        let d = dep_with_fonte(DepSource::Path {
12544            caminho: "../caixa-teia>log (cd foo)".into(),
12545        });
12546        let err = d.validate().unwrap_err();
12547        assert!(
12548            matches!(
12549                err,
12550                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
12551            ),
12552            "got {err:?}",
12553        );
12554    }
12555
12556    #[test]
12557    fn fonte_caminho_backslash_fires_before_shell_subshell_grouping() {
12558        // Cascade pin on the upstream backslash arm: a value carrying
12559        // both `\` and `(` (`"..\caixa-teia\(cd foo)"` — the canonical
12560        // "I pasted a Windows-shell `cd ..\path\(cmd)` chain") routes
12561        // through `FonteCaminhoBackslash` not
12562        // `FonteCaminhoShellSubshellGrouping`. The cross-host-OS-
12563        // separator divergence is the load-bearing axis on every
12564        // probe-as-both value (an author who removes the `\` is the
12565        // root-cause edit; the `(` falls away in the same edit since
12566        // it's downstream of the Windows-shell convention).
12567        let d = dep_with_fonte(DepSource::Path {
12568            caminho: "..\\caixa-teia\\(cd foo)".into(),
12569        });
12570        let err = d.validate().unwrap_err();
12571        assert!(
12572            matches!(err, DepError::FonteCaminhoBackslash { .. }),
12573            "got {err:?}",
12574        );
12575    }
12576
12577    #[test]
12578    fn fonte_caminho_control_char_fires_before_shell_subshell_grouping() {
12579        // Cascade pin on the embedded-control-byte arm: a value
12580        // carrying both a control byte and `(` (`"../foo\n(cd bar)"` —
12581        // the canonical paste-from-multiline-doc footgun where a
12582        // newline landed mid-caminho between two paste fragments)
12583        // routes through `FonteCaminhoControlChar` not
12584        // `FonteCaminhoShellSubshellGrouping`. The POSIX-syscall-
12585        // rejected-byte / NUL-`CString::new`-fail diagnostic is the
12586        // load-bearing axis on every value that probes positive for
12587        // both — mirrors the cascade discipline on every prior arm.
12588        let d = dep_with_fonte(DepSource::Path {
12589            caminho: "../foo\n(cd bar)".into(),
12590        });
12591        let err = d.validate().unwrap_err();
12592        assert!(
12593            matches!(err, DepError::FonteCaminhoControlChar { .. }),
12594            "got {err:?}",
12595        );
12596    }
12597
12598    #[test]
12599    fn fonte_caminho_absolute_fires_before_shell_subshell_grouping() {
12600        // Cascade pin on the load-bearing leading-byte arm: a leading
12601        // `/` value with embedded `(` (`"/etc/(cd foo)"`) routes
12602        // through `FonteCaminhoAbsolute` not
12603        // `FonteCaminhoShellSubshellGrouping` — the host-layout-leak
12604        // diagnostic is the load-bearing axis, the subshell-grouping
12605        // byte is the secondary observation. Same precedence logic as
12606        // every prior leading-byte arm.
12607        let d = dep_with_fonte(DepSource::Path {
12608            caminho: "/etc/(cd foo)".into(),
12609        });
12610        let err = d.validate().unwrap_err();
12611        assert!(
12612            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
12613            "got {err:?}",
12614        );
12615    }
12616
12617    #[test]
12618    fn fonte_caminho_var_expansion_fires_before_shell_subshell_grouping() {
12619        // Cascade pin on the upstream leading-`$` var-expansion arm: a
12620        // value carrying both a leading `$` and a `(` (`"$(date)/\
12621        // caixa-teia"` — the canonical "I pasted a `$(date)` modern-
12622        // command-substitution at the head of a sibling-workspace
12623        // path" footgun) routes through `FonteCaminhoVarExpansion` not
12624        // `FonteCaminhoShellSubshellGrouping`. The leading-byte
12625        // shell-variable-expansion is the more self-locating diagnostic
12626        // on values that probe as both — same load-bearing-leading-
12627        // byte cascade discipline every prior `:caminho` arm
12628        // establishes. Closing both halves of `$(<cmd>)` structurally
12629        // (leading `$` here, trailing `)` on the new arm) excludes the
12630        // entire modern Bourne command-substitution surface from the
12631        // typed `:caminho` accepted set; the cascade preserves the
12632        // narrower leading-byte diagnostic on values that probe both
12633        // halves at the canonical leading position.
12634        let d = dep_with_fonte(DepSource::Path {
12635            caminho: "$(date)/caixa-teia".into(),
12636        });
12637        let err = d.validate().unwrap_err();
12638        assert!(
12639            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
12640            "got {err:?}",
12641        );
12642    }
12643
12644    #[test]
12645    fn fonte_caminho_shell_subshell_grouping_fires_before_trailing_slash() {
12646        // Cascade pin on the immediate-successor arm: a value carrying
12647        // both `(` and a trailing `/` (`"../(cd foo)/"` — the canonical
12648        // "I tab-completed a path that already had a subshell-grouping
12649        // expansion tail" footgun) routes through
12650        // `FonteCaminhoShellSubshellGrouping` not
12651        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
12652        // the more semantic-locating axis (an author who removes the
12653        // `(` typically also drops the trailing separator since both
12654        // are paste-from-shell artifacts).
12655        let d = dep_with_fonte(DepSource::Path {
12656            caminho: "../(cd foo)/".into(),
12657        });
12658        let err = d.validate().unwrap_err();
12659        assert!(
12660            matches!(
12661                err,
12662                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
12663            ),
12664            "got {err:?}",
12665        );
12666    }
12667
12668    #[test]
12669    fn fonte_caminho_shell_subshell_grouping_diagnostic_carries_offending_dep_caminho_and_byte() {
12670        // Diagnostic-shape pin (peer with
12671        // `fonte_caminho_shell_glob_diagnostic_carries_offending_dep_caminho_and_byte`
12672        // on the closest two-byte peer arm): the error's Display
12673        // surfaces the offending `:nome`, the offending `:caminho`
12674        // verbatim, the offending byte's hex / character form, and
12675        // names the shell-subshell-grouping footgun explicitly so a
12676        // `feira lint` run can render the diagnostic without re-
12677        // parsing.
12678        let d = dep_with_fonte(DepSource::Path {
12679            caminho: "../caixa-teia/$(date)/build".into(),
12680        });
12681        let rendered = d.validate().unwrap_err().to_string();
12682        assert!(
12683            rendered.contains("caixa-teia"),
12684            "diagnostic must name the offending dep: {rendered}",
12685        );
12686        assert!(
12687            rendered.contains("../caixa-teia/$(date)/build"),
12688            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
12689        );
12690        assert!(
12691            rendered.contains("0x28"),
12692            "diagnostic must surface the offending byte hex: {rendered:?}",
12693        );
12694        assert!(
12695            rendered.contains("subshell-grouping"),
12696            "diagnostic must name the shell-subshell-grouping footgun: {rendered:?}",
12697        );
12698        assert!(
12699            rendered.contains("command-substitution"),
12700            "diagnostic must reference the `$(<cmd>)` command-substitution vocabulary: \
12701             {rendered:?}",
12702        );
12703    }
12704
12705    // ── shell-brace-expansion / URI-Template-placeholder arm ───────────
12706    //
12707    // Peer with the prior `FonteCaminhoShellSubshellGrouping` (`(` /
12708    // `)`) byte-pair arm: the same per-byte cascade with the same
12709    // self-locating `byte: u8` diagnostic on the orthogonal `{` /
12710    // `}` brace-expansion / URI-Template placeholder axis. The peer
12711    // [`crate::render::is_git_repo_url`] (42d8f9d) closes the same
12712    // byte pair on the sibling `:fonte :repo` axis under the same
12713    // banner.
12714
12715    #[test]
12716    fn validate_rejects_path_fonte_with_caminho_carrying_brace_expansion_fan_across_siblings() {
12717        // The fail-before-pass-after pin for the canonical paste-from-
12718        // shell-history brace-expansion footgun: an author copies a
12719        // `cd ../{caixa-teia,caixa-helm}/build` shell-history one-
12720        // liner whose `{a,b}` brace expansion fans across two siblings
12721        // and silently passed every prior arm (`Path::is_absolute`
12722        // false on `..`, no control bytes, no `\`, no `<` / `>`, no
12723        // `|`, no `;`, no `&`, no backtick, no `*` / `?`, no `(` /
12724        // `)`, doesn't end in `/`; the leading-`$` f4efe9c
12725        // `FonteCaminhoVarExpansion` arm doesn't fire because the
12726        // value starts with `..` not `$`). The lacre embedded the
12727        // value verbatim, the resolver folded it through `Path::join`
12728        // looking for a literal `./../{caixa-teia,caixa-helm}/build`
12729        // subdirectory, and the failure surfaced at resolve time with
12730        // a non-self-locating `No such file or directory` error. The
12731        // new arm moves the rejection to validate time and names the
12732        // offending dep + caminho + byte verbatim. The arm fires on
12733        // the first `{` encountered.
12734        let d = dep_with_fonte(DepSource::Path {
12735            caminho: "../{caixa-teia,caixa-helm}/build".into(),
12736        });
12737        let err = d.validate().unwrap_err();
12738        let DepError::FonteCaminhoShellBraceExpansion {
12739            nome,
12740            caminho,
12741            byte,
12742        } = err
12743        else {
12744            panic!("expected FonteCaminhoShellBraceExpansion, got {err:?}");
12745        };
12746        assert_eq!(nome, "caixa-teia");
12747        assert_eq!(caminho, "../{caixa-teia,caixa-helm}/build");
12748        assert_eq!(byte, b'{');
12749    }
12750
12751    #[test]
12752    fn validate_rejects_path_fonte_with_caminho_carrying_close_brace() {
12753        // The symmetric close-brace paste shape (`"../caixa-teia}"` —
12754        // the degenerate "I selected an unbalanced closing brace out
12755        // of a shell-history block" idiom that probes for the
12756        // cascade's last-byte handling on a value carrying only the
12757        // closing byte). Pinned separately from the open-brace shape
12758        // so the gate's contract is "any `{` or `}` anywhere", not
12759        // single-byte coverage. Mirrors the peer
12760        // `validate_rejects_path_fonte_with_caminho_carrying_close_paren`
12761        // shape on the immediate-predecessor `FonteCaminhoShellSubshellGrouping`
12762        // arm.
12763        let d = dep_with_fonte(DepSource::Path {
12764            caminho: "../caixa-teia}".into(),
12765        });
12766        let err = d.validate().unwrap_err();
12767        let DepError::FonteCaminhoShellBraceExpansion { byte, .. } = err else {
12768            panic!("expected FonteCaminhoShellBraceExpansion, got {err:?}");
12769        };
12770        assert_eq!(byte, b'}');
12771    }
12772
12773    #[test]
12774    fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_brace() {
12775        // Leading-position `{` shape (`"{caixa-teia,caixa-helm}/build"`
12776        // — the canonical "I selected a `{a,b}` brace-expansion prefix
12777        // out of a shell-history one-liner" idiom). Pinned separately
12778        // from the embedded-byte shape so the gate covers every
12779        // position, not only mid-path.
12780        let d = dep_with_fonte(DepSource::Path {
12781            caminho: "{caixa-teia,caixa-helm}/build".into(),
12782        });
12783        let err = d.validate().unwrap_err();
12784        assert!(
12785            matches!(
12786                err,
12787                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
12788            ),
12789            "got {err:?}",
12790        );
12791    }
12792
12793    #[test]
12794    fn validate_rejects_path_fonte_with_caminho_carrying_uri_template_placeholder() {
12795        // The canonical URI-Template / Mustache / Helm doubled-brace
12796        // placeholder shape (`"../{{org}}/caixa-teia"` — the canonical
12797        // "I copied a `https://github.com/{{org}}/caixa-teia` README
12798        // quick-start / OpenAPI spec / Helm chart `home:` template
12799        // and forgot to substitute the placeholder" footgun). The arm
12800        // fires on the first `{` encountered; pinned so the gate's
12801        // coverage extends from the bare-brace shell-history shape to
12802        // the doubled-brace URI-Template / templating-engine shape.
12803        // Mirrors the peer 42d8f9d `is_git_repo_url` arm on the
12804        // sibling `:fonte :repo` axis.
12805        let d = dep_with_fonte(DepSource::Path {
12806            caminho: "../{{org}}/caixa-teia".into(),
12807        });
12808        let err = d.validate().unwrap_err();
12809        assert!(
12810            matches!(
12811                err,
12812                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
12813            ),
12814            "got {err:?}",
12815        );
12816    }
12817
12818    #[test]
12819    fn validate_rejects_path_fonte_with_caminho_carrying_brace_range_expansion() {
12820        // The canonical bash brace-range-expansion shape (`"../caixa-
12821        // v{1..10}"` — the `{1..10}` sequence expansion every bash /
12822        // zsh `for i in {1..10}; do …; done` idiom uses, the symmetric
12823        // sequence-range form to the `{a,b,c}` comma-separated form).
12824        // The arm fires on the first `{` encountered; pinned so the
12825        // gate's coverage extends from the comma-separated form to
12826        // the integer-range form.
12827        let d = dep_with_fonte(DepSource::Path {
12828            caminho: "../caixa-v{1..10}".into(),
12829        });
12830        let err = d.validate().unwrap_err();
12831        assert!(
12832            matches!(
12833                err,
12834                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
12835            ),
12836            "got {err:?}",
12837        );
12838    }
12839
12840    #[test]
12841    fn validate_accepts_path_fonte_with_caminho_carrying_no_brace_expansion() {
12842        // The positive-control pin: the gate targets only `{` / `}`,
12843        // never adjacent printable ASCII or POSIX-valid bytes. The
12844        // canonical relative POSIX path (`"../caixa-teia"`) and a
12845        // nested deeply-pathed variant with adjacent printable
12846        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue to
12847        // validate cleanly so the gate doesn't widen to a "no
12848        // printable punctuation anywhere" sweep that would defeat
12849        // the entire path-fonte author surface. Peer with
12850        // `validate_accepts_path_fonte_with_caminho_carrying_no_subshell_grouping`
12851        // on the immediate-predecessor arm.
12852        let d = dep_with_fonte(DepSource::Path {
12853            caminho: "../caixa-teia/sub-dir.v2".into(),
12854        });
12855        d.validate().unwrap();
12856    }
12857
12858    #[test]
12859    fn fonte_caminho_shell_subshell_grouping_fires_before_shell_brace_expansion() {
12860        // Cascade pin on the immediate-predecessor arm: a value
12861        // carrying both `(` and `{` (`"../(cd foo)/{a,b}"` — the
12862        // canonical "I pasted a subshell-grouping followed by a
12863        // brace-expansion tail" footgun) routes through
12864        // `FonteCaminhoShellSubshellGrouping` not
12865        // `FonteCaminhoShellBraceExpansion`. The subshell-grouping
12866        // shape is the more semantic-locating axis on every probe-
12867        // as-both value because it closes both halves of the modern
12868        // Bourne `$(<cmd>)` command-substitution surface — same
12869        // cascade discipline every prior `:caminho` arm establishes.
12870        let d = dep_with_fonte(DepSource::Path {
12871            caminho: "../(cd foo)/{a,b}".into(),
12872        });
12873        let err = d.validate().unwrap_err();
12874        assert!(
12875            matches!(
12876                err,
12877                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
12878            ),
12879            "got {err:?}",
12880        );
12881    }
12882
12883    #[test]
12884    fn fonte_caminho_shell_glob_fires_before_shell_brace_expansion() {
12885        // Cascade pin on the upstream shell-glob arm: a value carrying
12886        // both `*` and `{` (`"../caixa-teia/*{a,b}"` — the canonical
12887        // "I pasted a glob expansion followed by a brace-expansion
12888        // tail" footgun) routes through `FonteCaminhoShellGlob` not
12889        // `FonteCaminhoShellBraceExpansion`. The pathname-expansion
12890        // shape is the load-bearing root-cause edit on every
12891        // probe-as-both value.
12892        let d = dep_with_fonte(DepSource::Path {
12893            caminho: "../caixa-teia/*{a,b}".into(),
12894        });
12895        let err = d.validate().unwrap_err();
12896        assert!(
12897            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12898            "got {err:?}",
12899        );
12900    }
12901
12902    #[test]
12903    fn fonte_caminho_shell_command_substitution_fires_before_shell_brace_expansion() {
12904        // Cascade pin on the upstream shell-command-substitution arm:
12905        // a value carrying both a backtick and `{` (``"../`whoami`/{a,b}"``
12906        // — the canonical "I pasted a legacy-backtick command-
12907        // substitution followed by a brace-expansion fan-out" footgun)
12908        // routes through `FonteCaminhoShellCommandSubstitution` not
12909        // `FonteCaminhoShellBraceExpansion`. The CWE-78 shell-
12910        // command-injection vector is the load-bearing root-cause
12911        // edit on every probe-as-both value.
12912        let d = dep_with_fonte(DepSource::Path {
12913            caminho: "../`whoami`/{a,b}".into(),
12914        });
12915        let err = d.validate().unwrap_err();
12916        assert!(
12917            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
12918            "got {err:?}",
12919        );
12920    }
12921
12922    #[test]
12923    fn fonte_caminho_shell_background_fires_before_shell_brace_expansion() {
12924        // Cascade pin on the upstream shell-background arm: a value
12925        // carrying both `&` and `{` (`"../caixa-teia & {a,b}"` — the
12926        // canonical "I pasted a `cmd & {fork-fan}` background-launch
12927        // + brace-expansion chain" footgun) routes through
12928        // `FonteCaminhoShellBackground` not
12929        // `FonteCaminhoShellBraceExpansion`. The background-launch
12930        // tail is the load-bearing root-cause edit on every
12931        // probe-as-both value.
12932        let d = dep_with_fonte(DepSource::Path {
12933            caminho: "../caixa-teia & {a,b}".into(),
12934        });
12935        let err = d.validate().unwrap_err();
12936        assert!(
12937            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
12938            "got {err:?}",
12939        );
12940    }
12941
12942    #[test]
12943    fn fonte_caminho_shell_semicolon_fires_before_shell_brace_expansion() {
12944        // Cascade pin on the upstream shell-semicolon arm: a value
12945        // carrying both `;` and `{` (`"../caixa-teia; {a,b}"` — the
12946        // canonical sequential-cleanup + brace-expansion paste
12947        // idiom) routes through `FonteCaminhoShellSemicolon` not
12948        // `FonteCaminhoShellBraceExpansion`. The sequential-command-
12949        // separator paste is the load-bearing root-cause edit on
12950        // every probe-as-both value.
12951        let d = dep_with_fonte(DepSource::Path {
12952            caminho: "../caixa-teia; {a,b}".into(),
12953        });
12954        let err = d.validate().unwrap_err();
12955        assert!(
12956            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
12957            "got {err:?}",
12958        );
12959    }
12960
12961    #[test]
12962    fn fonte_caminho_shell_pipe_fires_before_shell_brace_expansion() {
12963        // Cascade pin on the upstream shell-pipe arm: a value
12964        // carrying both `|` and `{` (`"../caixa-teia | {tee,cat}"`
12965        // — the canonical pipeline-to-brace-expansion paste idiom)
12966        // routes through `FonteCaminhoShellPipe` not
12967        // `FonteCaminhoShellBraceExpansion`. The pipeline-tail paste
12968        // is the load-bearing root-cause edit on every probe-as-
12969        // both value.
12970        let d = dep_with_fonte(DepSource::Path {
12971            caminho: "../caixa-teia | {tee,cat}".into(),
12972        });
12973        let err = d.validate().unwrap_err();
12974        assert!(
12975            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
12976            "got {err:?}",
12977        );
12978    }
12979
12980    #[test]
12981    fn fonte_caminho_shell_redirection_fires_before_shell_brace_expansion() {
12982        // Cascade pin on the upstream shell-redirection arm: a value
12983        // carrying both `>` and `{` (`"../caixa-teia>log {a,b}"` —
12984        // the canonical "I pasted a `cmd > log {a,b}` redirect-
12985        // plus-brace-expansion chain" footgun) routes through
12986        // `FonteCaminhoShellRedirection` not
12987        // `FonteCaminhoShellBraceExpansion`. The input/output
12988        // redirection metachar carries the more self-locating
12989        // `byte` payload, so the prior arm wins on every probe-
12990        // as-both value.
12991        let d = dep_with_fonte(DepSource::Path {
12992            caminho: "../caixa-teia>log {a,b}".into(),
12993        });
12994        let err = d.validate().unwrap_err();
12995        assert!(
12996            matches!(
12997                err,
12998                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
12999            ),
13000            "got {err:?}",
13001        );
13002    }
13003
13004    #[test]
13005    fn fonte_caminho_backslash_fires_before_shell_brace_expansion() {
13006        // Cascade pin on the upstream backslash arm: a value
13007        // carrying both `\` and `{` (`"..\caixa-teia\{a,b}"` — the
13008        // canonical "I pasted a Windows-shell `cd ..\path\{a,b}`
13009        // chain") routes through `FonteCaminhoBackslash` not
13010        // `FonteCaminhoShellBraceExpansion`. The cross-host-OS-
13011        // separator divergence is the load-bearing axis on every
13012        // probe-as-both value.
13013        let d = dep_with_fonte(DepSource::Path {
13014            caminho: "..\\caixa-teia\\{a,b}".into(),
13015        });
13016        let err = d.validate().unwrap_err();
13017        assert!(
13018            matches!(err, DepError::FonteCaminhoBackslash { .. }),
13019            "got {err:?}",
13020        );
13021    }
13022
13023    #[test]
13024    fn fonte_caminho_control_char_fires_before_shell_brace_expansion() {
13025        // Cascade pin on the embedded-control-byte arm: a value
13026        // carrying both a control byte and `{` (`"../foo\n{a,b}"` —
13027        // the canonical paste-from-multiline-doc footgun where a
13028        // newline landed mid-caminho between two paste fragments)
13029        // routes through `FonteCaminhoControlChar` not
13030        // `FonteCaminhoShellBraceExpansion`. The POSIX-syscall-
13031        // rejected-byte / NUL-`CString::new`-fail diagnostic is the
13032        // load-bearing axis on every value that probes positive for
13033        // both — mirrors the cascade discipline on every prior arm.
13034        let d = dep_with_fonte(DepSource::Path {
13035            caminho: "../foo\n{a,b}".into(),
13036        });
13037        let err = d.validate().unwrap_err();
13038        assert!(
13039            matches!(err, DepError::FonteCaminhoControlChar { .. }),
13040            "got {err:?}",
13041        );
13042    }
13043
13044    #[test]
13045    fn fonte_caminho_absolute_fires_before_shell_brace_expansion() {
13046        // Cascade pin on the load-bearing leading-byte arm: a
13047        // leading `/` value with embedded `{` (`"/etc/{a,b}"`)
13048        // routes through `FonteCaminhoAbsolute` not
13049        // `FonteCaminhoShellBraceExpansion` — the host-layout-leak
13050        // diagnostic is the load-bearing axis, the brace-expansion
13051        // byte is the secondary observation. Same precedence logic
13052        // as every prior leading-byte arm.
13053        let d = dep_with_fonte(DepSource::Path {
13054            caminho: "/etc/{a,b}".into(),
13055        });
13056        let err = d.validate().unwrap_err();
13057        assert!(
13058            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
13059            "got {err:?}",
13060        );
13061    }
13062
13063    #[test]
13064    fn fonte_caminho_var_expansion_fires_before_shell_brace_expansion() {
13065        // Cascade pin on the upstream leading-`$` var-expansion
13066        // arm: a value carrying both a leading `$` and a `{`
13067        // (`"${ORG}/caixa-teia"` — the canonical "I pasted a
13068        // `${ORG}` shell-variable + curly-brace expansion at the
13069        // head of a sibling-workspace path" footgun) routes through
13070        // `FonteCaminhoVarExpansion` not
13071        // `FonteCaminhoShellBraceExpansion`. The leading-byte
13072        // shell-variable-expansion is the more self-locating
13073        // diagnostic on values that probe as both — same
13074        // load-bearing-leading-byte cascade discipline every prior
13075        // `:caminho` arm establishes.
13076        let d = dep_with_fonte(DepSource::Path {
13077            caminho: "${ORG}/caixa-teia".into(),
13078        });
13079        let err = d.validate().unwrap_err();
13080        assert!(
13081            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
13082            "got {err:?}",
13083        );
13084    }
13085
13086    #[test]
13087    fn fonte_caminho_shell_brace_expansion_fires_before_trailing_slash() {
13088        // Cascade pin on the immediate-successor arm: a value
13089        // carrying both `{` and a trailing `/`
13090        // (`"../{caixa-teia,caixa-helm}/"` — the canonical "I
13091        // tab-completed a path that already had a brace-expansion
13092        // expansion tail" footgun) routes through
13093        // `FonteCaminhoShellBraceExpansion` not
13094        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
13095        // is the more semantic-locating axis (an author who removes
13096        // the `{` typically also drops the trailing separator since
13097        // both are paste-from-shell artifacts).
13098        let d = dep_with_fonte(DepSource::Path {
13099            caminho: "../{caixa-teia,caixa-helm}/".into(),
13100        });
13101        let err = d.validate().unwrap_err();
13102        assert!(
13103            matches!(
13104                err,
13105                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
13106            ),
13107            "got {err:?}",
13108        );
13109    }
13110
13111    #[test]
13112    fn fonte_caminho_shell_brace_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
13113        // Diagnostic-shape pin (peer with
13114        // `fonte_caminho_shell_subshell_grouping_diagnostic_carries_offending_dep_caminho_and_byte`
13115        // on the closest two-byte peer arm): the error's Display
13116        // surfaces the offending `:nome`, the offending `:caminho`
13117        // verbatim, the offending byte's hex / character form, and
13118        // names the shell-brace-expansion / URI-Template footgun
13119        // explicitly so a `feira lint` run can render the diagnostic
13120        // without re-parsing.
13121        let d = dep_with_fonte(DepSource::Path {
13122            caminho: "../{caixa-teia,caixa-helm}/build".into(),
13123        });
13124        let rendered = d.validate().unwrap_err().to_string();
13125        assert!(
13126            rendered.contains("caixa-teia"),
13127            "diagnostic must name the offending dep: {rendered}",
13128        );
13129        assert!(
13130            rendered.contains("../{caixa-teia,caixa-helm}/build"),
13131            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
13132        );
13133        assert!(
13134            rendered.contains("0x7b"),
13135            "diagnostic must surface the offending byte hex: {rendered:?}",
13136        );
13137        assert!(
13138            rendered.contains("brace-expansion"),
13139            "diagnostic must name the shell-brace-expansion footgun: {rendered:?}",
13140        );
13141        assert!(
13142            rendered.contains("URI Template"),
13143            "diagnostic must reference the RFC-6570 URI-Template-placeholder vocabulary: \
13144             {rendered:?}",
13145        );
13146    }
13147
13148    #[test]
13149    fn validate_rejects_path_fonte_with_caminho_carrying_bracket_glob_character_class() {
13150        // The canonical paste-from-shell-history bracket-glob /
13151        // character-class footgun: an author copies a
13152        // `cd ../caixa-[a-z]/build` shell-history one-liner whose
13153        // `[a-z]` POSIX glob character-class matches every lowercase-
13154        // ASCII-suffix sibling caixa directory and silently passed
13155        // every prior arm (`Path::is_absolute` false on `..`, no
13156        // control bytes, no `\`, no `<` / `>`, no `|`, no `;`, no
13157        // `&`, no backtick, no `*` / `?`, no `(` / `)`, no `{` /
13158        // `}`, doesn't end in `/`; the leading-`$` f4efe9c
13159        // `FonteCaminhoVarExpansion` arm doesn't fire because the
13160        // value starts with `..` not `$`). The lacre embedded the
13161        // value verbatim, the resolver folded it through
13162        // `Path::join` looking for a literal `./../caixa-[a-z]/
13163        // build` subdirectory, and the failure surfaced at resolve
13164        // time with a non-self-locating `No such file or directory`
13165        // error. The new arm moves the rejection to validate time
13166        // and names the offending dep + caminho + byte verbatim.
13167        // The arm fires on the first `[` encountered.
13168        let d = dep_with_fonte(DepSource::Path {
13169            caminho: "../caixa-[a-z]/build".into(),
13170        });
13171        let err = d.validate().unwrap_err();
13172        let DepError::FonteCaminhoShellBracketExpansion {
13173            nome,
13174            caminho,
13175            byte,
13176        } = err
13177        else {
13178            panic!("expected FonteCaminhoShellBracketExpansion, got {err:?}");
13179        };
13180        assert_eq!(nome, "caixa-teia");
13181        assert_eq!(caminho, "../caixa-[a-z]/build");
13182        assert_eq!(byte, b'[');
13183    }
13184
13185    #[test]
13186    fn validate_rejects_path_fonte_with_caminho_carrying_close_bracket() {
13187        // The symmetric close-bracket paste shape (`"../caixa-teia]"`
13188        // — the degenerate "I selected an unbalanced closing bracket
13189        // out of a glob character-class block" idiom that probes for
13190        // the cascade's last-byte handling on a value carrying only
13191        // the closing byte). Pinned separately from the open-bracket
13192        // shape so the gate's contract is "any `[` or `]` anywhere",
13193        // not single-byte coverage. Mirrors the peer
13194        // `validate_rejects_path_fonte_with_caminho_carrying_close_brace`
13195        // shape on the immediate-predecessor
13196        // `FonteCaminhoShellBraceExpansion` arm.
13197        let d = dep_with_fonte(DepSource::Path {
13198            caminho: "../caixa-teia]".into(),
13199        });
13200        let err = d.validate().unwrap_err();
13201        let DepError::FonteCaminhoShellBracketExpansion { byte, .. } = err else {
13202            panic!("expected FonteCaminhoShellBracketExpansion, got {err:?}");
13203        };
13204        assert_eq!(byte, b']');
13205    }
13206
13207    #[test]
13208    fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_bracket() {
13209        // Leading-position `[` shape (`"[caixa-teia]/build"` — the
13210        // canonical "I selected a `[caixa-teia]` TOML-table-header /
13211        // glob-character-class prefix out of an aligned config /
13212        // shell-history one-liner" idiom). Pinned separately from
13213        // the embedded-byte shape so the gate covers every position,
13214        // not only mid-path.
13215        let d = dep_with_fonte(DepSource::Path {
13216            caminho: "[caixa-teia]/build".into(),
13217        });
13218        let err = d.validate().unwrap_err();
13219        assert!(
13220            matches!(
13221                err,
13222                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
13223            ),
13224            "got {err:?}",
13225        );
13226    }
13227
13228    #[test]
13229    fn validate_rejects_path_fonte_with_caminho_carrying_toml_inline_array() {
13230        // The canonical TOML inline-array / YAML flow-sequence
13231        // paste shape (`"../[\"a\", \"b\"]/caixa-teia"` — the
13232        // canonical "I copied a `features = [\"a\", \"b\"]` TOML
13233        // inline-array out of a sibling-Cargo manifest" cross-idiom
13234        // leak; the symmetric YAML flow-sequence form `paths: [/a,
13235        // /b]` paste-from-values.yaml shape carries the same
13236        // bracket pair). The arm fires on the first `[` encountered;
13237        // pinned so the gate's coverage extends from the bare-
13238        // bracket glob-character-class shape to the TOML / YAML /
13239        // JSON array-literal shape.
13240        let d = dep_with_fonte(DepSource::Path {
13241            caminho: "../[\"a\", \"b\"]/caixa-teia".into(),
13242        });
13243        let err = d.validate().unwrap_err();
13244        assert!(
13245            matches!(
13246                err,
13247                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
13248            ),
13249            "got {err:?}",
13250        );
13251    }
13252
13253    #[test]
13254    fn validate_rejects_path_fonte_with_caminho_carrying_shell_test_builtin() {
13255        // The canonical POSIX `test` / `[` builtin command paste
13256        // shape (`"../[ -d caixa-teia ]"` — the `[ <expr> ]` shell-
13257        // script conditional every paste-from-shell-script idiom
13258        // carries; bash's `[[ <expr> ]]` extended-test grammar
13259        // would surface the same byte pair). The arm fires on the
13260        // first `[` encountered; pinned so the gate's coverage
13261        // extends from the embedded-glob-character-class shape to
13262        // the leading-`test`-builtin / extended-test form.
13263        let d = dep_with_fonte(DepSource::Path {
13264            caminho: "../[ -d caixa-teia ]".into(),
13265        });
13266        let err = d.validate().unwrap_err();
13267        assert!(
13268            matches!(
13269                err,
13270                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
13271            ),
13272            "got {err:?}",
13273        );
13274    }
13275
13276    #[test]
13277    fn validate_accepts_path_fonte_with_caminho_carrying_no_bracket_expansion() {
13278        // The positive-control pin: the gate targets only `[` /
13279        // `]`, never adjacent printable ASCII or POSIX-valid bytes.
13280        // The canonical relative POSIX path (`"../caixa-teia"`) and
13281        // a nested deeply-pathed variant with adjacent printable
13282        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
13283        // to validate cleanly so the gate doesn't widen to a "no
13284        // printable punctuation anywhere" sweep that would defeat
13285        // the entire path-fonte author surface. Peer with
13286        // `validate_accepts_path_fonte_with_caminho_carrying_no_brace_expansion`
13287        // on the immediate-predecessor arm.
13288        let d = dep_with_fonte(DepSource::Path {
13289            caminho: "../caixa-teia/sub-dir.v2".into(),
13290        });
13291        d.validate().unwrap();
13292    }
13293
13294    #[test]
13295    fn fonte_caminho_shell_brace_expansion_fires_before_shell_bracket_expansion() {
13296        // Cascade pin on the immediate-predecessor arm: a value
13297        // carrying both `{` and `[` (`"../{a,b}[ch]"` — the
13298        // canonical "I pasted a brace-expansion fan followed by a
13299        // glob-character-class tail" footgun) routes through
13300        // `FonteCaminhoShellBraceExpansion` not
13301        // `FonteCaminhoShellBracketExpansion`. The brace-expansion
13302        // fan is the load-bearing root-cause edit on every
13303        // probe-as-both value because the bracket-class tail
13304        // typically rides on a prior brace-expansion expansion;
13305        // same cascade discipline every prior `:caminho` arm
13306        // establishes.
13307        let d = dep_with_fonte(DepSource::Path {
13308            caminho: "../{a,b}[ch]".into(),
13309        });
13310        let err = d.validate().unwrap_err();
13311        assert!(
13312            matches!(
13313                err,
13314                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
13315            ),
13316            "got {err:?}",
13317        );
13318    }
13319
13320    #[test]
13321    fn fonte_caminho_shell_subshell_grouping_fires_before_shell_bracket_expansion() {
13322        // Cascade pin on the upstream shell-subshell-grouping arm:
13323        // a value carrying both `(` and `[` (`"../(cd foo)/[ch]"` —
13324        // the canonical "I pasted a subshell-grouping followed by
13325        // a glob-character-class tail" footgun) routes through
13326        // `FonteCaminhoShellSubshellGrouping` not
13327        // `FonteCaminhoShellBracketExpansion`. The modern Bourne
13328        // `$(<cmd>)` command-substitution boundary is the load-
13329        // bearing axis on every probe-as-both value.
13330        let d = dep_with_fonte(DepSource::Path {
13331            caminho: "../(cd foo)/[ch]".into(),
13332        });
13333        let err = d.validate().unwrap_err();
13334        assert!(
13335            matches!(
13336                err,
13337                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
13338            ),
13339            "got {err:?}",
13340        );
13341    }
13342
13343    #[test]
13344    fn fonte_caminho_shell_glob_fires_before_shell_bracket_expansion() {
13345        // Cascade pin on the upstream shell-glob arm: a value
13346        // carrying both `*` and `[` (`"../caixa-teia/*[ch]"` — the
13347        // canonical "I pasted a `*.[ch]` C-source-file glob whose
13348        // unbounded `*` precedes the bracket character-class"
13349        // footgun) routes through `FonteCaminhoShellGlob` not
13350        // `FonteCaminhoShellBracketExpansion`. The unbounded
13351        // pathname-expansion sentinel is the load-bearing root-
13352        // cause edit on every probe-as-both value — the unbounded
13353        // `*` carries the more aggressive expansion vector than
13354        // the bounded `[ch]` class, so the prior arm wins.
13355        let d = dep_with_fonte(DepSource::Path {
13356            caminho: "../caixa-teia/*[ch]".into(),
13357        });
13358        let err = d.validate().unwrap_err();
13359        assert!(
13360            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
13361            "got {err:?}",
13362        );
13363    }
13364
13365    #[test]
13366    fn fonte_caminho_shell_command_substitution_fires_before_shell_bracket_expansion() {
13367        // Cascade pin on the upstream shell-command-substitution
13368        // arm: a value carrying both a backtick and `[`
13369        // (``"../`whoami`/[ch]"`` — the canonical "I pasted a
13370        // legacy-backtick command-substitution followed by a
13371        // glob-character-class tail" footgun) routes through
13372        // `FonteCaminhoShellCommandSubstitution` not
13373        // `FonteCaminhoShellBracketExpansion`. The CWE-78 shell-
13374        // command-injection vector is the load-bearing root-cause
13375        // edit on every probe-as-both value.
13376        let d = dep_with_fonte(DepSource::Path {
13377            caminho: "../`whoami`/[ch]".into(),
13378        });
13379        let err = d.validate().unwrap_err();
13380        assert!(
13381            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
13382            "got {err:?}",
13383        );
13384    }
13385
13386    #[test]
13387    fn fonte_caminho_shell_background_fires_before_shell_bracket_expansion() {
13388        // Cascade pin on the upstream shell-background arm: a
13389        // value carrying both `&` and `[` (`"../caixa-teia & [ch]"`
13390        // — the canonical "I pasted a `cmd & [glob]` background-
13391        // launch + bracket-class chain" footgun) routes through
13392        // `FonteCaminhoShellBackground` not
13393        // `FonteCaminhoShellBracketExpansion`. The background-
13394        // launch tail is the load-bearing root-cause edit on
13395        // every probe-as-both value.
13396        let d = dep_with_fonte(DepSource::Path {
13397            caminho: "../caixa-teia & [ch]".into(),
13398        });
13399        let err = d.validate().unwrap_err();
13400        assert!(
13401            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
13402            "got {err:?}",
13403        );
13404    }
13405
13406    #[test]
13407    fn fonte_caminho_shell_semicolon_fires_before_shell_bracket_expansion() {
13408        // Cascade pin on the upstream shell-semicolon arm: a value
13409        // carrying both `;` and `[` (`"../caixa-teia; [ch]"` — the
13410        // canonical sequential-cleanup + bracket-class paste
13411        // idiom) routes through `FonteCaminhoShellSemicolon` not
13412        // `FonteCaminhoShellBracketExpansion`. The sequential-
13413        // command-separator paste is the load-bearing root-cause
13414        // edit on every probe-as-both value.
13415        let d = dep_with_fonte(DepSource::Path {
13416            caminho: "../caixa-teia; [ch]".into(),
13417        });
13418        let err = d.validate().unwrap_err();
13419        assert!(
13420            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
13421            "got {err:?}",
13422        );
13423    }
13424
13425    #[test]
13426    fn fonte_caminho_shell_pipe_fires_before_shell_bracket_expansion() {
13427        // Cascade pin on the upstream shell-pipe arm: a value
13428        // carrying both `|` and `[` (`"../caixa-teia | [tee]"` —
13429        // the canonical pipeline-to-bracket-class paste idiom)
13430        // routes through `FonteCaminhoShellPipe` not
13431        // `FonteCaminhoShellBracketExpansion`. The pipeline-tail
13432        // paste is the load-bearing root-cause edit on every
13433        // probe-as-both value.
13434        let d = dep_with_fonte(DepSource::Path {
13435            caminho: "../caixa-teia | [tee]".into(),
13436        });
13437        let err = d.validate().unwrap_err();
13438        assert!(
13439            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
13440            "got {err:?}",
13441        );
13442    }
13443
13444    #[test]
13445    fn fonte_caminho_shell_redirection_fires_before_shell_bracket_expansion() {
13446        // Cascade pin on the upstream shell-redirection arm: a
13447        // value carrying both `>` and `[` (`"../caixa-teia>log
13448        // [ch]"` — the canonical "I pasted a `cmd > log [glob]`
13449        // redirect-plus-bracket chain" footgun) routes through
13450        // `FonteCaminhoShellRedirection` not
13451        // `FonteCaminhoShellBracketExpansion`. The input/output
13452        // redirection metachar carries the more self-locating
13453        // `byte` payload, so the prior arm wins on every
13454        // probe-as-both value.
13455        let d = dep_with_fonte(DepSource::Path {
13456            caminho: "../caixa-teia>log [ch]".into(),
13457        });
13458        let err = d.validate().unwrap_err();
13459        assert!(
13460            matches!(
13461                err,
13462                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
13463            ),
13464            "got {err:?}",
13465        );
13466    }
13467
13468    #[test]
13469    fn fonte_caminho_backslash_fires_before_shell_bracket_expansion() {
13470        // Cascade pin on the upstream backslash arm: a value
13471        // carrying both `\` and `[` (`"..\caixa-teia\[ch]"` — the
13472        // canonical "I pasted a Windows-shell `cd ..\path\[glob]`
13473        // chain") routes through `FonteCaminhoBackslash` not
13474        // `FonteCaminhoShellBracketExpansion`. The cross-host-OS-
13475        // separator divergence is the load-bearing axis on every
13476        // probe-as-both value.
13477        let d = dep_with_fonte(DepSource::Path {
13478            caminho: "..\\caixa-teia\\[ch]".into(),
13479        });
13480        let err = d.validate().unwrap_err();
13481        assert!(
13482            matches!(err, DepError::FonteCaminhoBackslash { .. }),
13483            "got {err:?}",
13484        );
13485    }
13486
13487    #[test]
13488    fn fonte_caminho_control_char_fires_before_shell_bracket_expansion() {
13489        // Cascade pin on the embedded-control-byte arm: a value
13490        // carrying both a control byte and `[` (`"../foo\n[ch]"` —
13491        // the canonical paste-from-multiline-doc footgun where a
13492        // newline landed mid-caminho between two paste fragments)
13493        // routes through `FonteCaminhoControlChar` not
13494        // `FonteCaminhoShellBracketExpansion`. The POSIX-syscall-
13495        // rejected-byte / NUL-`CString::new`-fail diagnostic is
13496        // the load-bearing axis on every value that probes
13497        // positive for both — mirrors the cascade discipline on
13498        // every prior arm.
13499        let d = dep_with_fonte(DepSource::Path {
13500            caminho: "../foo\n[ch]".into(),
13501        });
13502        let err = d.validate().unwrap_err();
13503        assert!(
13504            matches!(err, DepError::FonteCaminhoControlChar { .. }),
13505            "got {err:?}",
13506        );
13507    }
13508
13509    #[test]
13510    fn fonte_caminho_absolute_fires_before_shell_bracket_expansion() {
13511        // Cascade pin on the load-bearing leading-byte arm: a
13512        // leading `/` value with embedded `[` (`"/etc/[ch]"`)
13513        // routes through `FonteCaminhoAbsolute` not
13514        // `FonteCaminhoShellBracketExpansion` — the host-layout-
13515        // leak diagnostic is the load-bearing axis, the bracket-
13516        // expansion byte is the secondary observation. Same
13517        // precedence logic as every prior leading-byte arm.
13518        let d = dep_with_fonte(DepSource::Path {
13519            caminho: "/etc/[ch]".into(),
13520        });
13521        let err = d.validate().unwrap_err();
13522        assert!(
13523            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
13524            "got {err:?}",
13525        );
13526    }
13527
13528    #[test]
13529    fn fonte_caminho_var_expansion_fires_before_shell_bracket_expansion() {
13530        // Cascade pin on the upstream leading-`$` var-expansion
13531        // arm: a value carrying both a leading `$` and a `[`
13532        // (`"$DIR/[ch]"` — the canonical "I pasted a `$DIR` shell-
13533        // variable + bracket-class at the head of a sibling-
13534        // workspace path" footgun) routes through
13535        // `FonteCaminhoVarExpansion` not
13536        // `FonteCaminhoShellBracketExpansion`. The leading-byte
13537        // shell-variable-expansion is the more self-locating
13538        // diagnostic on values that probe as both — same
13539        // load-bearing-leading-byte cascade discipline every
13540        // prior `:caminho` arm establishes.
13541        let d = dep_with_fonte(DepSource::Path {
13542            caminho: "$DIR/[ch]".into(),
13543        });
13544        let err = d.validate().unwrap_err();
13545        assert!(
13546            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
13547            "got {err:?}",
13548        );
13549    }
13550
13551    #[test]
13552    fn fonte_caminho_shell_bracket_expansion_fires_before_trailing_slash() {
13553        // Cascade pin on the immediate-successor arm: a value
13554        // carrying both `[` and a trailing `/` (`"../[a-z]/"` —
13555        // the canonical "I tab-completed a path that already had
13556        // a bracket-glob-character-class expansion tail" footgun)
13557        // routes through `FonteCaminhoShellBracketExpansion` not
13558        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
13559        // is the more semantic-locating axis (an author who
13560        // removes the `[` typically also drops the trailing
13561        // separator since both are paste-from-shell artifacts).
13562        let d = dep_with_fonte(DepSource::Path {
13563            caminho: "../[a-z]/".into(),
13564        });
13565        let err = d.validate().unwrap_err();
13566        assert!(
13567            matches!(
13568                err,
13569                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
13570            ),
13571            "got {err:?}",
13572        );
13573    }
13574
13575    #[test]
13576    fn fonte_caminho_shell_bracket_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
13577        // Diagnostic-shape pin (peer with
13578        // `fonte_caminho_shell_brace_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
13579        // on the closest two-byte peer arm): the error's Display
13580        // surfaces the offending `:nome`, the offending `:caminho`
13581        // verbatim, the offending byte's hex / character form, and
13582        // names the shell-bracket-expansion / glob-character-class
13583        // footgun explicitly so a `feira lint` run can render the
13584        // diagnostic without re-parsing.
13585        let d = dep_with_fonte(DepSource::Path {
13586            caminho: "../caixa-[a-z]/build".into(),
13587        });
13588        let rendered = d.validate().unwrap_err().to_string();
13589        assert!(
13590            rendered.contains("caixa-teia"),
13591            "diagnostic must name the offending dep: {rendered}",
13592        );
13593        assert!(
13594            rendered.contains("../caixa-[a-z]/build"),
13595            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
13596        );
13597        assert!(
13598            rendered.contains("0x5b"),
13599            "diagnostic must surface the offending byte hex: {rendered:?}",
13600        );
13601        assert!(
13602            rendered.contains("bracket-expansion"),
13603            "diagnostic must name the shell-bracket-expansion footgun: {rendered:?}",
13604        );
13605        assert!(
13606            rendered.contains("glob-character-class"),
13607            "diagnostic must reference the POSIX glob-character-class vocabulary: \
13608             {rendered:?}",
13609        );
13610    }
13611
13612    #[test]
13613    fn validate_rejects_path_fonte_with_caminho_carrying_single_quote_grouping() {
13614        // The canonical paste-from-shell-history strong-quoted
13615        // sibling-workspace-path footgun: an author copies a
13616        // `cd '../caixa-teia'` shell-history one-liner whose strong-
13617        // quoting preserved the path across a whitespace paste
13618        // boundary and silently passed every prior arm
13619        // (`Path::is_absolute` false on `'..`, no control bytes, no
13620        // `\`, no `<` / `>`, no `|`, no `;`, no `&`, no backtick, no
13621        // `*` / `?`, no `(` / `)`, no `{` / `}`, no `[` / `]`,
13622        // doesn't end in `/`; the leading-`$` f4efe9c
13623        // `FonteCaminhoVarExpansion` arm doesn't fire because the
13624        // value starts with `'` not `$`). The lacre embedded the
13625        // value verbatim, the resolver folded it through
13626        // `Path::join` looking for a literal `./'../caixa-teia'`
13627        // subdirectory, and the failure surfaced at resolve time
13628        // with a non-self-locating `No such file or directory`
13629        // error. The new arm moves the rejection to validate time
13630        // and names the offending dep + caminho + byte verbatim.
13631        // The arm fires on the first `'` encountered.
13632        let d = dep_with_fonte(DepSource::Path {
13633            caminho: "'../caixa-teia'".into(),
13634        });
13635        let err = d.validate().unwrap_err();
13636        let DepError::FonteCaminhoShellQuoteGrouping {
13637            nome,
13638            caminho,
13639            byte,
13640        } = err
13641        else {
13642            panic!("expected FonteCaminhoShellQuoteGrouping, got {err:?}");
13643        };
13644        assert_eq!(nome, "caixa-teia");
13645        assert_eq!(caminho, "'../caixa-teia'");
13646        assert_eq!(byte, b'\'');
13647    }
13648
13649    #[test]
13650    fn validate_rejects_path_fonte_with_caminho_carrying_double_quote_grouping() {
13651        // The symmetric weak-quoted paste shape (`"\"../caixa-teia\""`
13652        // — the canonical paste-from-JSON-config / paste-from-YAML-
13653        // flow-scalar / paste-from-TOML-basic-string / paste-from-
13654        // tatara-lisp-string-literal cross-idiom leak). Pinned
13655        // separately from the single-quote shape so the gate's
13656        // contract is "any `'` or `\"` anywhere", not single-byte
13657        // coverage. Mirrors the peer
13658        // `validate_rejects_path_fonte_with_caminho_carrying_close_bracket`
13659        // shape on the immediate-predecessor
13660        // `FonteCaminhoShellBracketExpansion` arm.
13661        let d = dep_with_fonte(DepSource::Path {
13662            caminho: "\"../caixa-teia\"".into(),
13663        });
13664        let err = d.validate().unwrap_err();
13665        let DepError::FonteCaminhoShellQuoteGrouping { byte, .. } = err else {
13666            panic!("expected FonteCaminhoShellQuoteGrouping, got {err:?}");
13667        };
13668        assert_eq!(byte, b'"');
13669    }
13670
13671    #[test]
13672    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_double_quote() {
13673        // Embedded-position `"` shape (`"../\"caixa-teia\""` — the
13674        // canonical "I pasted a JSON key-value pair fragment into
13675        // the middle of the path" idiom). Pinned separately from
13676        // the leading-byte shape so the gate covers every position,
13677        // not only leading.
13678        let d = dep_with_fonte(DepSource::Path {
13679            caminho: "../\"caixa-teia\"".into(),
13680        });
13681        let err = d.validate().unwrap_err();
13682        assert!(
13683            matches!(
13684                err,
13685                DepError::FonteCaminhoShellQuoteGrouping { byte: b'"', .. },
13686            ),
13687            "got {err:?}",
13688        );
13689    }
13690
13691    #[test]
13692    fn validate_rejects_path_fonte_with_caminho_carrying_yaml_flow_scalar_paste() {
13693        // The canonical YAML double-quoted flow-scalar cross-idiom
13694        // leak shape (`"path: \"../caixa-teia\""` — the "I copied a
13695        // `path: \"...\"` YAML flow-scalar entry out of an aligned
13696        // values.yaml / K8s manifest and dropped it verbatim into
13697        // the `:caminho` slot including the `path: ` key prefix"
13698        // paste-idiom). The arm fires on the first `"` encountered;
13699        // pinned so the gate's coverage extends from the bare-quote
13700        // paste shape to the aligned-YAML-manifest cross-idiom-leak
13701        // shape.
13702        let d = dep_with_fonte(DepSource::Path {
13703            caminho: "path: \"../caixa-teia\"".into(),
13704        });
13705        let err = d.validate().unwrap_err();
13706        assert!(
13707            matches!(
13708                err,
13709                DepError::FonteCaminhoShellQuoteGrouping { byte: b'"', .. },
13710            ),
13711            "got {err:?}",
13712        );
13713    }
13714
13715    #[test]
13716    fn validate_accepts_path_fonte_with_caminho_carrying_no_quote_grouping() {
13717        // The positive-control pin: the gate targets only `'` /
13718        // `"`, never adjacent printable ASCII or POSIX-valid bytes.
13719        // The canonical relative POSIX path (`"../caixa-teia"`) and
13720        // a nested deeply-pathed variant with adjacent printable
13721        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
13722        // to validate cleanly so the gate doesn't widen to a "no
13723        // printable punctuation anywhere" sweep that would defeat
13724        // the entire path-fonte author surface. Peer with
13725        // `validate_accepts_path_fonte_with_caminho_carrying_no_bracket_expansion`
13726        // on the immediate-predecessor arm.
13727        let d = dep_with_fonte(DepSource::Path {
13728            caminho: "../caixa-teia/sub-dir.v2".into(),
13729        });
13730        d.validate().unwrap();
13731    }
13732
13733    #[test]
13734    fn fonte_caminho_shell_bracket_expansion_fires_before_shell_quote_grouping() {
13735        // Cascade pin on the immediate-predecessor arm: a value
13736        // carrying both `[` and `'` (`"../[a-z]'x'"` — the canonical
13737        // "I pasted a glob-character-class followed by a strong-
13738        // quoted literal tail" footgun) routes through
13739        // `FonteCaminhoShellBracketExpansion` not
13740        // `FonteCaminhoShellQuoteGrouping`. The glob-character-class
13741        // expansion is the load-bearing root-cause edit on every
13742        // probe-as-both value; same cascade discipline every prior
13743        // `:caminho` arm establishes.
13744        let d = dep_with_fonte(DepSource::Path {
13745            caminho: "../[a-z]'x'".into(),
13746        });
13747        let err = d.validate().unwrap_err();
13748        assert!(
13749            matches!(
13750                err,
13751                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
13752            ),
13753            "got {err:?}",
13754        );
13755    }
13756
13757    #[test]
13758    fn fonte_caminho_shell_brace_expansion_fires_before_shell_quote_grouping() {
13759        // Cascade pin on the upstream shell-brace-expansion arm: a
13760        // value carrying both `{` and `'` (`"../{a,b}'x'"` — the
13761        // canonical "I pasted a brace-expansion fan followed by a
13762        // strong-quoted literal tail" footgun) routes through
13763        // `FonteCaminhoShellBraceExpansion` not
13764        // `FonteCaminhoShellQuoteGrouping`. The brace-expansion fan
13765        // is the load-bearing root-cause edit on every probe-as-
13766        // both value.
13767        let d = dep_with_fonte(DepSource::Path {
13768            caminho: "../{a,b}'x'".into(),
13769        });
13770        let err = d.validate().unwrap_err();
13771        assert!(
13772            matches!(
13773                err,
13774                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
13775            ),
13776            "got {err:?}",
13777        );
13778    }
13779
13780    #[test]
13781    fn fonte_caminho_shell_subshell_grouping_fires_before_shell_quote_grouping() {
13782        // Cascade pin on the upstream shell-subshell-grouping arm:
13783        // a value carrying both `(` and `'` (`"../(cd foo)/'x'"` —
13784        // the canonical "I pasted a subshell-grouping followed by
13785        // a strong-quoted literal tail" footgun) routes through
13786        // `FonteCaminhoShellSubshellGrouping` not
13787        // `FonteCaminhoShellQuoteGrouping`. The modern Bourne
13788        // `$(<cmd>)` command-substitution boundary is the load-
13789        // bearing axis on every probe-as-both value.
13790        let d = dep_with_fonte(DepSource::Path {
13791            caminho: "../(cd foo)/'x'".into(),
13792        });
13793        let err = d.validate().unwrap_err();
13794        assert!(
13795            matches!(
13796                err,
13797                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
13798            ),
13799            "got {err:?}",
13800        );
13801    }
13802
13803    #[test]
13804    fn fonte_caminho_shell_glob_fires_before_shell_quote_grouping() {
13805        // Cascade pin on the upstream shell-glob arm: a value
13806        // carrying both `*` and `'` (`"../caixa-teia/*'x'"` — the
13807        // canonical "I pasted a `*` unbounded pathname-expansion
13808        // followed by a strong-quoted literal tail" footgun) routes
13809        // through `FonteCaminhoShellGlob` not
13810        // `FonteCaminhoShellQuoteGrouping`. The unbounded pathname-
13811        // expansion sentinel is the load-bearing root-cause edit
13812        // on every probe-as-both value.
13813        let d = dep_with_fonte(DepSource::Path {
13814            caminho: "../caixa-teia/*'x'".into(),
13815        });
13816        let err = d.validate().unwrap_err();
13817        assert!(
13818            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
13819            "got {err:?}",
13820        );
13821    }
13822
13823    #[test]
13824    fn fonte_caminho_shell_command_substitution_fires_before_shell_quote_grouping() {
13825        // Cascade pin on the upstream shell-command-substitution
13826        // arm: a value carrying both a backtick and `'`
13827        // (``"../`whoami`/'x'"`` — the canonical "I pasted a
13828        // legacy-backtick command-substitution followed by a
13829        // strong-quoted literal tail" footgun) routes through
13830        // `FonteCaminhoShellCommandSubstitution` not
13831        // `FonteCaminhoShellQuoteGrouping`. The CWE-78 shell-
13832        // command-injection vector is the load-bearing root-cause
13833        // edit on every probe-as-both value.
13834        let d = dep_with_fonte(DepSource::Path {
13835            caminho: "../`whoami`/'x'".into(),
13836        });
13837        let err = d.validate().unwrap_err();
13838        assert!(
13839            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
13840            "got {err:?}",
13841        );
13842    }
13843
13844    #[test]
13845    fn fonte_caminho_shell_background_fires_before_shell_quote_grouping() {
13846        // Cascade pin on the upstream shell-background arm: a value
13847        // carrying both `&` and `'` (`"../caixa-teia & 'x'"` — the
13848        // canonical "I pasted a `cmd & 'literal'` background-launch
13849        // + quote chain" footgun) routes through
13850        // `FonteCaminhoShellBackground` not
13851        // `FonteCaminhoShellQuoteGrouping`. The background-launch
13852        // tail is the load-bearing root-cause edit on every
13853        // probe-as-both value.
13854        let d = dep_with_fonte(DepSource::Path {
13855            caminho: "../caixa-teia & 'x'".into(),
13856        });
13857        let err = d.validate().unwrap_err();
13858        assert!(
13859            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
13860            "got {err:?}",
13861        );
13862    }
13863
13864    #[test]
13865    fn fonte_caminho_shell_semicolon_fires_before_shell_quote_grouping() {
13866        // Cascade pin on the upstream shell-semicolon arm: a value
13867        // carrying both `;` and `'` (`"../caixa-teia; 'x'"` — the
13868        // canonical sequential-cleanup + quote paste idiom) routes
13869        // through `FonteCaminhoShellSemicolon` not
13870        // `FonteCaminhoShellQuoteGrouping`. The sequential-command-
13871        // separator paste is the load-bearing root-cause edit on
13872        // every probe-as-both value.
13873        let d = dep_with_fonte(DepSource::Path {
13874            caminho: "../caixa-teia; 'x'".into(),
13875        });
13876        let err = d.validate().unwrap_err();
13877        assert!(
13878            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
13879            "got {err:?}",
13880        );
13881    }
13882
13883    #[test]
13884    fn fonte_caminho_shell_pipe_fires_before_shell_quote_grouping() {
13885        // Cascade pin on the upstream shell-pipe arm: a value
13886        // carrying both `|` and `'` (`"../caixa-teia | 'x'"` — the
13887        // canonical pipeline-to-quoted-literal paste idiom) routes
13888        // through `FonteCaminhoShellPipe` not
13889        // `FonteCaminhoShellQuoteGrouping`. The pipeline-tail paste
13890        // is the load-bearing root-cause edit on every probe-as-
13891        // both value.
13892        let d = dep_with_fonte(DepSource::Path {
13893            caminho: "../caixa-teia | 'x'".into(),
13894        });
13895        let err = d.validate().unwrap_err();
13896        assert!(
13897            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
13898            "got {err:?}",
13899        );
13900    }
13901
13902    #[test]
13903    fn fonte_caminho_shell_redirection_fires_before_shell_quote_grouping() {
13904        // Cascade pin on the upstream shell-redirection arm: a
13905        // value carrying both `>` and `'` (`"../caixa-teia>log 'x'"`
13906        // — the canonical "I pasted a `cmd > log 'literal'`
13907        // redirect-plus-quote chain" footgun) routes through
13908        // `FonteCaminhoShellRedirection` not
13909        // `FonteCaminhoShellQuoteGrouping`. The input/output
13910        // redirection metachar carries the more self-locating
13911        // `byte` payload, so the prior arm wins on every probe-as-
13912        // both value.
13913        let d = dep_with_fonte(DepSource::Path {
13914            caminho: "../caixa-teia>log 'x'".into(),
13915        });
13916        let err = d.validate().unwrap_err();
13917        assert!(
13918            matches!(
13919                err,
13920                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
13921            ),
13922            "got {err:?}",
13923        );
13924    }
13925
13926    #[test]
13927    fn fonte_caminho_backslash_fires_before_shell_quote_grouping() {
13928        // Cascade pin on the upstream backslash arm: a value
13929        // carrying both `\` and `'` (`"..\caixa-teia\'x'"` — the
13930        // canonical "I pasted a Windows-shell `cd ..\path\'literal'`
13931        // chain" footgun) routes through `FonteCaminhoBackslash`
13932        // not `FonteCaminhoShellQuoteGrouping`. The cross-host-OS-
13933        // separator divergence is the load-bearing axis on every
13934        // probe-as-both value.
13935        let d = dep_with_fonte(DepSource::Path {
13936            caminho: "..\\caixa-teia\\'x'".into(),
13937        });
13938        let err = d.validate().unwrap_err();
13939        assert!(
13940            matches!(err, DepError::FonteCaminhoBackslash { .. }),
13941            "got {err:?}",
13942        );
13943    }
13944
13945    #[test]
13946    fn fonte_caminho_control_char_fires_before_shell_quote_grouping() {
13947        // Cascade pin on the embedded-control-byte arm: a value
13948        // carrying both a control byte and `'` (`"../foo\n'x'"` —
13949        // the canonical paste-from-multiline-doc footgun where a
13950        // newline landed mid-caminho between two paste fragments)
13951        // routes through `FonteCaminhoControlChar` not
13952        // `FonteCaminhoShellQuoteGrouping`. The POSIX-syscall-
13953        // rejected-byte / NUL-`CString::new`-fail diagnostic is
13954        // the load-bearing axis on every value that probes
13955        // positive for both — mirrors the cascade discipline on
13956        // every prior arm.
13957        let d = dep_with_fonte(DepSource::Path {
13958            caminho: "../foo\n'x'".into(),
13959        });
13960        let err = d.validate().unwrap_err();
13961        assert!(
13962            matches!(err, DepError::FonteCaminhoControlChar { .. }),
13963            "got {err:?}",
13964        );
13965    }
13966
13967    #[test]
13968    fn fonte_caminho_absolute_fires_before_shell_quote_grouping() {
13969        // Cascade pin on the load-bearing leading-byte arm: a
13970        // leading `/` value with embedded `'` (`"/etc/'x'"`) routes
13971        // through `FonteCaminhoAbsolute` not
13972        // `FonteCaminhoShellQuoteGrouping` — the host-layout-leak
13973        // diagnostic is the load-bearing axis, the quote byte is
13974        // the secondary observation. Same precedence logic as every
13975        // prior leading-byte arm.
13976        let d = dep_with_fonte(DepSource::Path {
13977            caminho: "/etc/'x'".into(),
13978        });
13979        let err = d.validate().unwrap_err();
13980        assert!(
13981            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
13982            "got {err:?}",
13983        );
13984    }
13985
13986    #[test]
13987    fn fonte_caminho_var_expansion_fires_before_shell_quote_grouping() {
13988        // Cascade pin on the upstream leading-`$` var-expansion
13989        // arm: a value carrying both a leading `$` and a `'`
13990        // (`"$DIR/'x'"` — the canonical "I pasted a `$DIR` shell-
13991        // variable + quoted literal at the head of a sibling-
13992        // workspace path" footgun) routes through
13993        // `FonteCaminhoVarExpansion` not
13994        // `FonteCaminhoShellQuoteGrouping`. The leading-byte
13995        // shell-variable-expansion is the more self-locating
13996        // diagnostic on values that probe as both — same
13997        // load-bearing-leading-byte cascade discipline every
13998        // prior `:caminho` arm establishes.
13999        let d = dep_with_fonte(DepSource::Path {
14000            caminho: "$DIR/'x'".into(),
14001        });
14002        let err = d.validate().unwrap_err();
14003        assert!(
14004            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
14005            "got {err:?}",
14006        );
14007    }
14008
14009    #[test]
14010    fn fonte_caminho_shell_quote_grouping_fires_before_trailing_slash() {
14011        // Cascade pin on the immediate-successor arm: a value
14012        // carrying both `'` and a trailing `/` (`"../'caixa-teia'/"`
14013        // — the canonical "I tab-completed a path whose strong-
14014        // quoted body already carried the quoting from a shell-
14015        // history paste" footgun) routes through
14016        // `FonteCaminhoShellQuoteGrouping` not
14017        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
14018        // is the more semantic-locating axis (an author who removes
14019        // the `'` typically also drops the trailing separator since
14020        // both are paste-from-shell artifacts).
14021        let d = dep_with_fonte(DepSource::Path {
14022            caminho: "../'caixa-teia'/".into(),
14023        });
14024        let err = d.validate().unwrap_err();
14025        assert!(
14026            matches!(
14027                err,
14028                DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
14029            ),
14030            "got {err:?}",
14031        );
14032    }
14033
14034    #[test]
14035    fn fonte_caminho_shell_quote_grouping_diagnostic_carries_offending_dep_caminho_and_byte() {
14036        // Diagnostic-shape pin (peer with
14037        // `fonte_caminho_shell_bracket_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
14038        // on the closest two-byte peer arm): the error's Display
14039        // surfaces the offending `:nome`, the offending `:caminho`
14040        // verbatim, the offending byte's hex / character form, and
14041        // names the shell-quote-grouping / cross-config-DSL-string-
14042        // literal-delimiter footgun explicitly so a `feira lint`
14043        // run can render the diagnostic without re-parsing.
14044        let d = dep_with_fonte(DepSource::Path {
14045            caminho: "'../caixa-teia'".into(),
14046        });
14047        let rendered = d.validate().unwrap_err().to_string();
14048        assert!(
14049            rendered.contains("caixa-teia"),
14050            "diagnostic must name the offending dep: {rendered}",
14051        );
14052        assert!(
14053            rendered.contains("'../caixa-teia'"),
14054            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
14055        );
14056        assert!(
14057            rendered.contains("0x27"),
14058            "diagnostic must surface the offending byte hex: {rendered:?}",
14059        );
14060        assert!(
14061            rendered.contains("quote-grouping"),
14062            "diagnostic must name the shell-quote-grouping footgun: {rendered:?}",
14063        );
14064        assert!(
14065            rendered.contains("string-literal"),
14066            "diagnostic must reference the cross-config-DSL string-literal-delimiter \
14067             vocabulary: {rendered:?}",
14068        );
14069    }
14070
14071    #[test]
14072    fn validate_rejects_path_fonte_with_caminho_carrying_shell_comment_lead() {
14073        // The canonical paste-from-shell-history-with-trailing-
14074        // annotation footgun: an author pastes a `cd ../caixa-teia
14075        // # legacy sibling` shell-history one-liner whose unquoted `#`
14076        // comment-lead separates the path from an inline annotation.
14077        // The POSIX shell trims the annotation to `../caixa-teia`
14078        // (POSIX.1-2017 §2.3 Token Recognition step 6), but
14079        // `Path::is_absolute` returns false on `..`, `#` is neither
14080        // a leading-byte sentinel nor a control byte nor `\` nor
14081        // `<` / `>` nor `|` nor `;` nor `&` nor backtick nor `*` /
14082        // `?` nor `(` / `)` nor `{` / `}` nor `[` / `]` nor `'` /
14083        // `"`, and the value's last byte isn't `/` — so the value
14084        // silently passed every prior arm. The resolver folded the
14085        // value through `Path::join` looking for a literal
14086        // `./../caixa-teia # legacy sibling` subdirectory and the
14087        // failure surfaced at resolve time with a non-self-locating
14088        // `No such file or directory` error. The new arm moves the
14089        // rejection to validate time and names the offending dep +
14090        // caminho + byte verbatim.
14091        let d = dep_with_fonte(DepSource::Path {
14092            caminho: "../caixa-teia # legacy sibling".into(),
14093        });
14094        let err = d.validate().unwrap_err();
14095        let DepError::FonteCaminhoShellComment {
14096            nome,
14097            caminho,
14098            byte,
14099        } = err
14100        else {
14101            panic!("expected FonteCaminhoShellComment, got {err:?}");
14102        };
14103        assert_eq!(nome, "caixa-teia");
14104        assert_eq!(caminho, "../caixa-teia # legacy sibling");
14105        assert_eq!(byte, b'#');
14106    }
14107
14108    #[test]
14109    fn validate_rejects_path_fonte_with_caminho_carrying_yaml_comment_paste() {
14110        // The symmetric YAML flow-scalar / values.yaml / K8s-manifest
14111        // cross-idiom-leak shape (`"../caixa-teia  # pin"` — the
14112        // canonical "I copied a `path: ../caixa-teia  # pin` YAML
14113        // scalar-plus-comment entry out of an aligned values.yaml and
14114        // dropped it verbatim into the `:caminho` slot" paste-idiom).
14115        // Pinned separately from the shell-history shape so the
14116        // gate's coverage extends from the single-space `#` shape to
14117        // the YAML-canonical double-space `  #` shape. YAML 1.2 §6.6
14118        // requires the `#` to be preceded by whitespace to lex as a
14119        // comment (bare `foo#bar` is a single scalar); the double-
14120        // space paste from an aligned manifest is the canonical
14121        // shape.
14122        let d = dep_with_fonte(DepSource::Path {
14123            caminho: "../caixa-teia  # pin".into(),
14124        });
14125        let err = d.validate().unwrap_err();
14126        assert!(
14127            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
14128            "got {err:?}",
14129        );
14130    }
14131
14132    #[test]
14133    fn validate_rejects_path_fonte_with_caminho_carrying_url_fragment_anchor() {
14134        // The URL-fragment-identifier paste shape
14135        // (`"../caixa-teia#readme"` — the canonical
14136        // paste-from-browser-address-bar permalink shape where the
14137        // browser preserved the `#anchor` tail on the copy). Pinned
14138        // separately from the whitespace-separated shell / YAML
14139        // comment shapes so the gate covers the unpadded RFC 3986
14140        // §3.5 fragment-delimiter position too, not only positions
14141        // preceded by unquoted whitespace. Peer with the immediate-
14142        // sibling `is_git_repo_url` arm on the `:fonte :repo` axis
14143        // (a68f818) which closes the same byte under the same URL-
14144        // fragment-identifier banner.
14145        let d = dep_with_fonte(DepSource::Path {
14146            caminho: "../caixa-teia#readme".into(),
14147        });
14148        let err = d.validate().unwrap_err();
14149        assert!(
14150            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
14151            "got {err:?}",
14152        );
14153    }
14154
14155    #[test]
14156    fn validate_rejects_path_fonte_with_caminho_carrying_leading_shell_comment() {
14157        // Leading-position `#` shape (`"#../caixa-teia"` — the
14158        // "I copied a shell-comment-out entry from a commented-out
14159        // dep row" footgun). Pinned separately from the embedded
14160        // shapes so the gate covers every position, not only
14161        // whitespace-preceded / mid-value.
14162        let d = dep_with_fonte(DepSource::Path {
14163            caminho: "#../caixa-teia".into(),
14164        });
14165        let err = d.validate().unwrap_err();
14166        assert!(
14167            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
14168            "got {err:?}",
14169        );
14170    }
14171
14172    #[test]
14173    fn validate_accepts_path_fonte_with_caminho_carrying_no_shell_comment() {
14174        // The positive-control pin: the gate targets only `#`,
14175        // never adjacent printable ASCII or POSIX-valid bytes. The
14176        // canonical relative POSIX path (`"../caixa-teia"`) and a
14177        // nested deeply-pathed variant with adjacent printable
14178        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
14179        // to validate cleanly so the gate doesn't widen to a "no
14180        // printable punctuation anywhere" sweep that would defeat
14181        // the entire path-fonte author surface. Peer with
14182        // `validate_accepts_path_fonte_with_caminho_carrying_no_quote_grouping`
14183        // on the immediate-predecessor arm.
14184        let d = dep_with_fonte(DepSource::Path {
14185            caminho: "../caixa-teia/sub-dir.v2".into(),
14186        });
14187        d.validate().unwrap();
14188    }
14189
14190    #[test]
14191    fn fonte_caminho_shell_quote_grouping_fires_before_shell_comment() {
14192        // Cascade pin on the immediate-predecessor arm: a value
14193        // carrying both `'` and `#` (`"../'x'#pin"` — the canonical
14194        // "I pasted a strong-quoted literal followed by a URL-
14195        // fragment permalink tail" footgun) routes through
14196        // `FonteCaminhoShellQuoteGrouping` not
14197        // `FonteCaminhoShellComment`. The shell-string-literal-
14198        // delimiter is the load-bearing root-cause edit on every
14199        // probe-as-both value; same cascade discipline every prior
14200        // `:caminho` arm establishes.
14201        let d = dep_with_fonte(DepSource::Path {
14202            caminho: "../'x'#pin".into(),
14203        });
14204        let err = d.validate().unwrap_err();
14205        assert!(
14206            matches!(
14207                err,
14208                DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
14209            ),
14210            "got {err:?}",
14211        );
14212    }
14213
14214    #[test]
14215    fn fonte_caminho_shell_bracket_expansion_fires_before_shell_comment() {
14216        // Cascade pin on the upstream shell-bracket-expansion arm:
14217        // a value carrying both `[` and `#` (`"../[a-z]#pin"` — the
14218        // canonical "I pasted a glob-character-class followed by a
14219        // URL-fragment tail" footgun) routes through
14220        // `FonteCaminhoShellBracketExpansion` not
14221        // `FonteCaminhoShellComment`. The glob-character-class
14222        // expansion is the load-bearing root-cause edit on every
14223        // probe-as-both value.
14224        let d = dep_with_fonte(DepSource::Path {
14225            caminho: "../[a-z]#pin".into(),
14226        });
14227        let err = d.validate().unwrap_err();
14228        assert!(
14229            matches!(
14230                err,
14231                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
14232            ),
14233            "got {err:?}",
14234        );
14235    }
14236
14237    #[test]
14238    fn fonte_caminho_shell_brace_expansion_fires_before_shell_comment() {
14239        // Cascade pin on the upstream shell-brace-expansion arm: a
14240        // value carrying both `{` and `#` (`"../{a,b}#pin"` — the
14241        // canonical "I pasted a brace-expansion fan followed by a
14242        // URL-fragment tail" footgun) routes through
14243        // `FonteCaminhoShellBraceExpansion` not
14244        // `FonteCaminhoShellComment`. The brace-expansion fan is the
14245        // load-bearing root-cause edit on every probe-as-both value.
14246        let d = dep_with_fonte(DepSource::Path {
14247            caminho: "../{a,b}#pin".into(),
14248        });
14249        let err = d.validate().unwrap_err();
14250        assert!(
14251            matches!(
14252                err,
14253                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
14254            ),
14255            "got {err:?}",
14256        );
14257    }
14258
14259    #[test]
14260    fn fonte_caminho_shell_subshell_grouping_fires_before_shell_comment() {
14261        // Cascade pin on the upstream shell-subshell-grouping arm:
14262        // a value carrying both `(` and `#` (`"../(cd foo)#pin"` —
14263        // the canonical "I pasted a subshell-grouping followed by a
14264        // URL-fragment tail" footgun) routes through
14265        // `FonteCaminhoShellSubshellGrouping` not
14266        // `FonteCaminhoShellComment`. The modern Bourne `$(<cmd>)`
14267        // command-substitution boundary is the load-bearing axis on
14268        // every probe-as-both value.
14269        let d = dep_with_fonte(DepSource::Path {
14270            caminho: "../(cd foo)#pin".into(),
14271        });
14272        let err = d.validate().unwrap_err();
14273        assert!(
14274            matches!(
14275                err,
14276                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
14277            ),
14278            "got {err:?}",
14279        );
14280    }
14281
14282    #[test]
14283    fn fonte_caminho_shell_glob_fires_before_shell_comment() {
14284        // Cascade pin on the upstream shell-glob arm: a value
14285        // carrying both `*` and `#` (`"../caixa-teia/*#pin"` — the
14286        // canonical "I pasted a `*` unbounded pathname-expansion
14287        // followed by a URL-fragment tail" footgun) routes through
14288        // `FonteCaminhoShellGlob` not `FonteCaminhoShellComment`.
14289        // The unbounded pathname-expansion sentinel is the load-
14290        // bearing root-cause edit on every probe-as-both value.
14291        let d = dep_with_fonte(DepSource::Path {
14292            caminho: "../caixa-teia/*#pin".into(),
14293        });
14294        let err = d.validate().unwrap_err();
14295        assert!(
14296            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
14297            "got {err:?}",
14298        );
14299    }
14300
14301    #[test]
14302    fn fonte_caminho_shell_command_substitution_fires_before_shell_comment() {
14303        // Cascade pin on the upstream shell-command-substitution
14304        // arm: a value carrying both a backtick and `#`
14305        // (``"../`whoami`#pin"`` — the canonical "I pasted a
14306        // legacy-backtick command-substitution followed by a URL-
14307        // fragment tail" footgun) routes through
14308        // `FonteCaminhoShellCommandSubstitution` not
14309        // `FonteCaminhoShellComment`. The CWE-78 shell-command-
14310        // injection vector is the load-bearing root-cause edit on
14311        // every probe-as-both value.
14312        let d = dep_with_fonte(DepSource::Path {
14313            caminho: "../`whoami`#pin".into(),
14314        });
14315        let err = d.validate().unwrap_err();
14316        assert!(
14317            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
14318            "got {err:?}",
14319        );
14320    }
14321
14322    #[test]
14323    fn fonte_caminho_shell_background_fires_before_shell_comment() {
14324        // Cascade pin on the upstream shell-background arm: a value
14325        // carrying both `&` and `#` (`"../caixa-teia&pin#tail"` —
14326        // the canonical "I pasted a `cmd &` background-launch
14327        // followed by a URL-fragment tail" footgun) routes through
14328        // `FonteCaminhoShellBackground` not
14329        // `FonteCaminhoShellComment`. The background-launch tail is
14330        // the load-bearing root-cause edit on every probe-as-both
14331        // value.
14332        let d = dep_with_fonte(DepSource::Path {
14333            caminho: "../caixa-teia&pin#tail".into(),
14334        });
14335        let err = d.validate().unwrap_err();
14336        assert!(
14337            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
14338            "got {err:?}",
14339        );
14340    }
14341
14342    #[test]
14343    fn fonte_caminho_shell_semicolon_fires_before_shell_comment() {
14344        // Cascade pin on the upstream shell-semicolon arm: a value
14345        // carrying both `;` and `#` (`"../caixa-teia;pin#tail"` —
14346        // the canonical sequential-cleanup + URL-fragment paste
14347        // idiom) routes through `FonteCaminhoShellSemicolon` not
14348        // `FonteCaminhoShellComment`. The sequential-command-
14349        // separator paste is the load-bearing root-cause edit on
14350        // every probe-as-both value.
14351        let d = dep_with_fonte(DepSource::Path {
14352            caminho: "../caixa-teia;pin#tail".into(),
14353        });
14354        let err = d.validate().unwrap_err();
14355        assert!(
14356            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
14357            "got {err:?}",
14358        );
14359    }
14360
14361    #[test]
14362    fn fonte_caminho_shell_pipe_fires_before_shell_comment() {
14363        // Cascade pin on the upstream shell-pipe arm: a value
14364        // carrying both `|` and `#` (`"../caixa-teia|pin#tail"` —
14365        // the canonical pipeline-to-URL-fragment paste idiom) routes
14366        // through `FonteCaminhoShellPipe` not
14367        // `FonteCaminhoShellComment`. The pipeline-tail paste is
14368        // the load-bearing root-cause edit on every probe-as-both
14369        // value.
14370        let d = dep_with_fonte(DepSource::Path {
14371            caminho: "../caixa-teia|pin#tail".into(),
14372        });
14373        let err = d.validate().unwrap_err();
14374        assert!(
14375            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
14376            "got {err:?}",
14377        );
14378    }
14379
14380    #[test]
14381    fn fonte_caminho_shell_redirection_fires_before_shell_comment() {
14382        // Cascade pin on the upstream shell-redirection arm: a
14383        // value carrying both `>` and `#` (`"../caixa-teia>log#pin"`
14384        // — the canonical "I pasted a `cmd > log` redirect followed
14385        // by a URL-fragment tail" footgun) routes through
14386        // `FonteCaminhoShellRedirection` not
14387        // `FonteCaminhoShellComment`. The input/output redirection
14388        // metachar carries the more self-locating `byte` payload,
14389        // so the prior arm wins on every probe-as-both value.
14390        let d = dep_with_fonte(DepSource::Path {
14391            caminho: "../caixa-teia>log#pin".into(),
14392        });
14393        let err = d.validate().unwrap_err();
14394        assert!(
14395            matches!(
14396                err,
14397                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
14398            ),
14399            "got {err:?}",
14400        );
14401    }
14402
14403    #[test]
14404    fn fonte_caminho_backslash_fires_before_shell_comment() {
14405        // Cascade pin on the upstream backslash arm: a value
14406        // carrying both `\` and `#` (`"..\caixa-teia#pin"` — the
14407        // canonical "I pasted a Windows-shell path followed by a
14408        // URL-fragment tail" footgun) routes through
14409        // `FonteCaminhoBackslash` not `FonteCaminhoShellComment`.
14410        // The cross-host-OS-separator divergence is the load-
14411        // bearing axis on every probe-as-both value.
14412        let d = dep_with_fonte(DepSource::Path {
14413            caminho: "..\\caixa-teia#pin".into(),
14414        });
14415        let err = d.validate().unwrap_err();
14416        assert!(
14417            matches!(err, DepError::FonteCaminhoBackslash { .. }),
14418            "got {err:?}",
14419        );
14420    }
14421
14422    #[test]
14423    fn fonte_caminho_control_char_fires_before_shell_comment() {
14424        // Cascade pin on the embedded-control-byte arm: a value
14425        // carrying both a control byte and `#` (`"../foo\n#pin"` —
14426        // the canonical paste-from-multiline-doc footgun where a
14427        // newline landed mid-caminho between the path and an
14428        // annotation) routes through `FonteCaminhoControlChar` not
14429        // `FonteCaminhoShellComment`. The POSIX-syscall-rejected-
14430        // byte diagnostic is the load-bearing axis on every value
14431        // that probes positive for both — mirrors the cascade
14432        // discipline on every prior arm.
14433        let d = dep_with_fonte(DepSource::Path {
14434            caminho: "../foo\n#pin".into(),
14435        });
14436        let err = d.validate().unwrap_err();
14437        assert!(
14438            matches!(err, DepError::FonteCaminhoControlChar { .. }),
14439            "got {err:?}",
14440        );
14441    }
14442
14443    #[test]
14444    fn fonte_caminho_absolute_fires_before_shell_comment() {
14445        // Cascade pin on the load-bearing leading-byte arm: a
14446        // leading `/` value with embedded `#` (`"/etc/foo#pin"`)
14447        // routes through `FonteCaminhoAbsolute` not
14448        // `FonteCaminhoShellComment` — the host-layout-leak
14449        // diagnostic is the load-bearing axis, the fragment byte is
14450        // the secondary observation. Same precedence logic as every
14451        // prior leading-byte arm.
14452        let d = dep_with_fonte(DepSource::Path {
14453            caminho: "/etc/foo#pin".into(),
14454        });
14455        let err = d.validate().unwrap_err();
14456        assert!(
14457            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
14458            "got {err:?}",
14459        );
14460    }
14461
14462    #[test]
14463    fn fonte_caminho_var_expansion_fires_before_shell_comment() {
14464        // Cascade pin on the upstream leading-`$` var-expansion
14465        // arm: a value carrying both a leading `$` and a `#`
14466        // (`"$DIR/foo#pin"` — the canonical "I pasted a `$DIR`
14467        // shell-variable at the head of a sibling-workspace path
14468        // followed by a URL-fragment tail" footgun) routes through
14469        // `FonteCaminhoVarExpansion` not `FonteCaminhoShellComment`.
14470        // The leading-byte shell-variable-expansion is the more
14471        // self-locating diagnostic on values that probe as both.
14472        let d = dep_with_fonte(DepSource::Path {
14473            caminho: "$DIR/foo#pin".into(),
14474        });
14475        let err = d.validate().unwrap_err();
14476        assert!(
14477            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
14478            "got {err:?}",
14479        );
14480    }
14481
14482    #[test]
14483    fn fonte_caminho_shell_comment_fires_before_trailing_slash() {
14484        // Cascade pin on the immediate-successor arm: a value
14485        // carrying both `#` and a trailing `/`
14486        // (`"../caixa-teia#pin/"` — the canonical "I tab-completed
14487        // a URL-fragment-carrying path" footgun) routes through
14488        // `FonteCaminhoShellComment` not
14489        // `FonteCaminhoTrailingSlash`. The embedded fragment /
14490        // comment-lead byte is the more semantic-locating axis (an
14491        // author who removes the `#pin` fragment typically also
14492        // drops the trailing separator since both are paste-from-
14493        // URL / paste-from-shell-tab-completion artifacts).
14494        let d = dep_with_fonte(DepSource::Path {
14495            caminho: "../caixa-teia#pin/".into(),
14496        });
14497        let err = d.validate().unwrap_err();
14498        assert!(
14499            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. },),
14500            "got {err:?}",
14501        );
14502    }
14503
14504    #[test]
14505    fn fonte_caminho_shell_comment_diagnostic_carries_offending_dep_caminho_and_byte() {
14506        // Diagnostic-shape pin (peer with
14507        // `fonte_caminho_shell_quote_grouping_diagnostic_carries_offending_dep_caminho_and_byte`
14508        // on the immediate-predecessor arm): the error's Display
14509        // surfaces the offending `:nome`, the offending `:caminho`
14510        // verbatim, the offending byte's hex / character form, and
14511        // names the shell-comment / URL-fragment-identifier /
14512        // YAML-comment cross-config-DSL footgun explicitly so a
14513        // `feira lint` run can render the diagnostic without
14514        // re-parsing.
14515        let d = dep_with_fonte(DepSource::Path {
14516            caminho: "../caixa-teia#readme".into(),
14517        });
14518        let rendered = d.validate().unwrap_err().to_string();
14519        assert!(
14520            rendered.contains("caixa-teia"),
14521            "diagnostic must name the offending dep: {rendered}",
14522        );
14523        assert!(
14524            rendered.contains("../caixa-teia#readme"),
14525            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
14526        );
14527        assert!(
14528            rendered.contains("0x23"),
14529            "diagnostic must surface the offending byte hex: {rendered:?}",
14530        );
14531        assert!(
14532            rendered.contains("shell-comment") || rendered.contains("comment-lead"),
14533            "diagnostic must name the shell-comment footgun: {rendered:?}",
14534        );
14535        assert!(
14536            rendered.contains("fragment") || rendered.contains("URL-fragment"),
14537            "diagnostic must reference the URL-fragment-identifier vocabulary: \
14538             {rendered:?}",
14539        );
14540    }
14541
14542    #[test]
14543    fn validate_rejects_path_fonte_with_caminho_carrying_url_percent_encoded_space() {
14544        // The canonical paste-from-browser-address-bar percent-
14545        // encoded-space footgun: an author copies `../caixa%20teia`
14546        // out of a URL-encoded README hyperlink / browser address
14547        // bar / percent-encoded permalink expecting `%20` to decode
14548        // to a literal space at the filesystem layer. POSIX
14549        // `std::path::Path` treats `%` as a literal path-component
14550        // byte, so `Path::join` looks for a literal
14551        // `./../caixa%20teia` subdirectory. `Path::is_absolute`
14552        // returns false on `..`, `%` is neither a leading-byte
14553        // sentinel nor a control byte nor `\` nor `<` / `>` nor
14554        // `|` nor `;` nor `&` nor backtick nor `*` / `?` nor `(` /
14555        // `)` nor `{` / `}` nor `[` / `]` nor `'` / `"` nor `#`,
14556        // and the value's last byte isn't `/` — so the value
14557        // silently passed every prior arm. The new arm moves the
14558        // rejection to validate time and names the offending dep +
14559        // caminho + byte verbatim.
14560        let d = dep_with_fonte(DepSource::Path {
14561            caminho: "../caixa%20teia".into(),
14562        });
14563        let err = d.validate().unwrap_err();
14564        let DepError::FonteCaminhoUrlPercentEncoding {
14565            nome,
14566            caminho,
14567            byte,
14568        } = err
14569        else {
14570            panic!("expected FonteCaminhoUrlPercentEncoding, got {err:?}");
14571        };
14572        assert_eq!(nome, "caixa-teia");
14573        assert_eq!(caminho, "../caixa%20teia");
14574        assert_eq!(byte, b'%');
14575    }
14576
14577    #[test]
14578    fn validate_rejects_path_fonte_with_caminho_carrying_url_percent_encoded_slash() {
14579        // The over-encoded path-separator shape (`"../caixa%2Fteia"`
14580        // intending the `%2F` as the URL encoding of `/`) locks a
14581        // `path:../caixa%2Fteia` BLAKE3 closure that diverges from
14582        // the byte-identical `path:../caixa/teia` form. Pinned
14583        // separately from the space-encoded shape so the gate's
14584        // coverage extends past the single canonical `%20` example
14585        // to any two-hex-digit percent-encoded sequence.
14586        let d = dep_with_fonte(DepSource::Path {
14587            caminho: "../caixa%2Fteia".into(),
14588        });
14589        let err = d.validate().unwrap_err();
14590        assert!(
14591            matches!(
14592                err,
14593                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
14594            ),
14595            "got {err:?}",
14596        );
14597    }
14598
14599    #[test]
14600    fn validate_rejects_path_fonte_with_caminho_carrying_lone_percent() {
14601        // The lone-`%` malformed-escape shape (`"../caixa-teia%foo"`
14602        // where `%` isn't followed by two hex digits) — every
14603        // WHATWG-conformant URL parser rejects the value at parse
14604        // time per RFC 3986 §2.1, but the byte would silently ride
14605        // into the lacre before the resolver subprocess crosses the
14606        // URL-parser boundary. Pinned separately from the well-
14607        // formed `%HH` shapes so the gate covers every percent-
14608        // occurrence, not only strictly-conformant escapes.
14609        let d = dep_with_fonte(DepSource::Path {
14610            caminho: "../caixa-teia%foo".into(),
14611        });
14612        let err = d.validate().unwrap_err();
14613        assert!(
14614            matches!(
14615                err,
14616                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
14617            ),
14618            "got {err:?}",
14619        );
14620    }
14621
14622    #[test]
14623    fn validate_rejects_path_fonte_with_caminho_carrying_leading_yaml_directive() {
14624        // The YAML-directive-lead paste shape (`"%YAML/../caixa-teia"`
14625        // — the canonical paste-from-top-of-doc YAML directive
14626        // block cross-idiom leak per YAML 1.2 §6.8.1). Pinned
14627        // separately from embedded shapes so the gate covers the
14628        // leading-position `%` too, not only mid-value occurrences.
14629        let d = dep_with_fonte(DepSource::Path {
14630            caminho: "%YAML/../caixa-teia".into(),
14631        });
14632        let err = d.validate().unwrap_err();
14633        assert!(
14634            matches!(
14635                err,
14636                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
14637            ),
14638            "got {err:?}",
14639        );
14640    }
14641
14642    #[test]
14643    fn validate_rejects_path_fonte_with_caminho_carrying_printf_format_specifier() {
14644        // The printf-format-specifier paste shape
14645        // (`"../caixa-%s-teia"` — the canonical paste-from-shell-
14646        // diagnostic-one-liner `printf "path=%s\n" ...` idiom, CWE-
14647        // 134 format-string-injection vector). Pinned separately
14648        // from the URL-encoding shapes so the gate's rationale
14649        // extends past the RFC 3986 axis to the C / POSIX printf
14650        // format-directive-lead axis.
14651        let d = dep_with_fonte(DepSource::Path {
14652            caminho: "../caixa-%s-teia".into(),
14653        });
14654        let err = d.validate().unwrap_err();
14655        assert!(
14656            matches!(
14657                err,
14658                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
14659            ),
14660            "got {err:?}",
14661        );
14662    }
14663
14664    #[test]
14665    fn validate_accepts_path_fonte_with_caminho_carrying_no_percent() {
14666        // The positive-control pin: the gate targets only `%`,
14667        // never adjacent printable ASCII or POSIX-valid bytes. The
14668        // canonical relative POSIX path (`"../caixa-teia"`) and a
14669        // nested deeply-pathed variant with adjacent printable
14670        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
14671        // to validate cleanly so the gate doesn't widen to a "no
14672        // printable punctuation anywhere" sweep that would defeat
14673        // the entire path-fonte author surface. Peer with
14674        // `validate_accepts_path_fonte_with_caminho_carrying_no_shell_comment`
14675        // on the immediate-predecessor arm.
14676        let d = dep_with_fonte(DepSource::Path {
14677            caminho: "../caixa-teia/sub-dir.v2".into(),
14678        });
14679        d.validate().unwrap();
14680    }
14681
14682    #[test]
14683    fn fonte_caminho_shell_comment_fires_before_url_percent_encoding() {
14684        // Cascade pin on the immediate-predecessor arm: a value
14685        // carrying both `#` and `%` (`"../caixa-teia#pin%20"` — the
14686        // canonical "I pasted a URL-fragment permalink followed by a
14687        // percent-encoded space tail" footgun) routes through
14688        // `FonteCaminhoShellComment` not
14689        // `FonteCaminhoUrlPercentEncoding`. The URL-fragment-
14690        // identifier is the load-bearing downstream-truncation edit
14691        // on every probe-as-both value; same cascade discipline
14692        // every prior `:caminho` arm establishes.
14693        let d = dep_with_fonte(DepSource::Path {
14694            caminho: "../caixa-teia#pin%20".into(),
14695        });
14696        let err = d.validate().unwrap_err();
14697        assert!(
14698            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
14699            "got {err:?}",
14700        );
14701    }
14702
14703    #[test]
14704    fn fonte_caminho_shell_quote_grouping_fires_before_url_percent_encoding() {
14705        // Cascade pin on the upstream shell-quote-grouping arm: a
14706        // value carrying both `'` and `%` (`"../'x'%20teia"` — the
14707        // canonical "I pasted a strong-quoted literal followed by
14708        // a percent-encoded space" footgun) routes through
14709        // `FonteCaminhoShellQuoteGrouping` not
14710        // `FonteCaminhoUrlPercentEncoding`. The shell-string-
14711        // literal-delimiter is the load-bearing root-cause edit on
14712        // every probe-as-both value.
14713        let d = dep_with_fonte(DepSource::Path {
14714            caminho: "../'x'%20teia".into(),
14715        });
14716        let err = d.validate().unwrap_err();
14717        assert!(
14718            matches!(
14719                err,
14720                DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
14721            ),
14722            "got {err:?}",
14723        );
14724    }
14725
14726    #[test]
14727    fn fonte_caminho_backslash_fires_before_url_percent_encoding() {
14728        // Cascade pin on the upstream backslash arm: a value
14729        // carrying both `\` and `%` (`"..\\caixa%20teia"` — the
14730        // canonical "I pasted a Windows-shell path followed by a
14731        // percent-encoded space" footgun) routes through
14732        // `FonteCaminhoBackslash` not
14733        // `FonteCaminhoUrlPercentEncoding`. The cross-host-OS-
14734        // separator divergence is the load-bearing root-cause edit
14735        // on every probe-as-both value.
14736        let d = dep_with_fonte(DepSource::Path {
14737            caminho: "..\\caixa%20teia".into(),
14738        });
14739        let err = d.validate().unwrap_err();
14740        assert!(
14741            matches!(err, DepError::FonteCaminhoBackslash { .. }),
14742            "got {err:?}",
14743        );
14744    }
14745
14746    #[test]
14747    fn fonte_caminho_control_char_fires_before_url_percent_encoding() {
14748        // Cascade pin on the upstream control-char arm: a value
14749        // carrying both a NUL byte and `%` (`"../caixa\0%20teia"` —
14750        // the canonical "I pasted a paste-from-binary-blob path
14751        // followed by a percent-encoded space" footgun) routes
14752        // through `FonteCaminhoControlChar` not
14753        // `FonteCaminhoUrlPercentEncoding`. The POSIX-syscall-
14754        // rejected byte is the load-bearing root-cause edit on
14755        // every probe-as-both value.
14756        let d = dep_with_fonte(DepSource::Path {
14757            caminho: "../caixa\0%20teia".into(),
14758        });
14759        let err = d.validate().unwrap_err();
14760        assert!(
14761            matches!(err, DepError::FonteCaminhoControlChar { byte: 0x00, .. },),
14762            "got {err:?}",
14763        );
14764    }
14765
14766    #[test]
14767    fn fonte_caminho_absolute_fires_before_url_percent_encoding() {
14768        // Cascade pin on the upstream absolute-path arm: a value
14769        // that's both absolute and carries `%` (`"/etc/passwd%20"`
14770        // — the canonical "I pasted an absolute path with a
14771        // percent-encoded space tail" footgun) routes through
14772        // `FonteCaminhoAbsolute` not
14773        // `FonteCaminhoUrlPercentEncoding`. The host-layout-leak is
14774        // the load-bearing root-cause edit on every probe-as-both
14775        // value.
14776        let d = dep_with_fonte(DepSource::Path {
14777            caminho: "/etc/passwd%20".into(),
14778        });
14779        let err = d.validate().unwrap_err();
14780        assert!(
14781            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
14782            "got {err:?}",
14783        );
14784    }
14785
14786    #[test]
14787    fn fonte_caminho_var_expansion_fires_before_url_percent_encoding() {
14788        // Cascade pin on the upstream var-expansion arm: a value
14789        // starting with `$` and carrying `%` (`"$HOME/caixa%20teia"`
14790        // — the canonical "I pasted a `$HOME`-rooted path with a
14791        // percent-encoded space" footgun) routes through
14792        // `FonteCaminhoVarExpansion` not
14793        // `FonteCaminhoUrlPercentEncoding`. The shell-variable-
14794        // expansion is the load-bearing root-cause edit on every
14795        // probe-as-both value.
14796        let d = dep_with_fonte(DepSource::Path {
14797            caminho: "$HOME/caixa%20teia".into(),
14798        });
14799        let err = d.validate().unwrap_err();
14800        assert!(
14801            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
14802            "got {err:?}",
14803        );
14804    }
14805
14806    #[test]
14807    fn fonte_caminho_url_percent_encoding_fires_before_trailing_slash() {
14808        // Cascade pin on the immediate-successor arm: a value
14809        // carrying both `%` and a trailing `/`
14810        // (`"../caixa%20teia/"` — the canonical "I tab-completed a
14811        // percent-encoded-space-carrying path" footgun) routes
14812        // through `FonteCaminhoUrlPercentEncoding` not
14813        // `FonteCaminhoTrailingSlash`. The embedded percent-
14814        // encoding-escape byte is the more semantic-locating axis
14815        // (an author who decodes the `%20` to a literal space is
14816        // likely to also tab-strip the trailing separator since
14817        // both are paste-from-URL / paste-from-shell-tab-completion
14818        // artifacts).
14819        let d = dep_with_fonte(DepSource::Path {
14820            caminho: "../caixa%20teia/".into(),
14821        });
14822        let err = d.validate().unwrap_err();
14823        assert!(
14824            matches!(
14825                err,
14826                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
14827            ),
14828            "got {err:?}",
14829        );
14830    }
14831
14832    #[test]
14833    fn fonte_caminho_url_percent_encoding_diagnostic_carries_offending_dep_caminho_and_byte() {
14834        // Diagnostic-shape pin (peer with
14835        // `fonte_caminho_shell_comment_diagnostic_carries_offending_dep_caminho_and_byte`
14836        // on the immediate-predecessor arm): the error's Display
14837        // surfaces the offending `:nome`, the offending `:caminho`
14838        // verbatim, the offending byte's hex / character form, and
14839        // names the URL-percent-encoding-escape / printf-format-
14840        // specifier footgun explicitly so a `feira lint` run can
14841        // render the diagnostic without re-parsing.
14842        let d = dep_with_fonte(DepSource::Path {
14843            caminho: "../caixa%20teia".into(),
14844        });
14845        let rendered = d.validate().unwrap_err().to_string();
14846        assert!(
14847            rendered.contains("caixa-teia"),
14848            "diagnostic must name the offending dep: {rendered}",
14849        );
14850        assert!(
14851            rendered.contains("../caixa%20teia"),
14852            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
14853        );
14854        assert!(
14855            rendered.contains("0x25"),
14856            "diagnostic must surface the offending byte hex: {rendered:?}",
14857        );
14858        assert!(
14859            rendered.contains("percent-encoding") || rendered.contains("percent-encoded"),
14860            "diagnostic must name the URL-percent-encoding-escape footgun: {rendered:?}",
14861        );
14862        assert!(
14863            rendered.contains("printf") || rendered.contains("format-specifier"),
14864            "diagnostic must reference the printf-format-specifier vocabulary: \
14865             {rendered:?}",
14866        );
14867    }
14868
14869    #[test]
14870    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_var_expansion() {
14871        // The canonical embedded-`$` shell-variable-expansion paste
14872        // shape (`"../foo$HOME/bar"` — an author copies a partially-
14873        // substituted shell one-liner where the leading segment is a
14874        // literal `../foo` while the mid segment carries the un-
14875        // substituted `$HOME` template). The leading-`$` position is
14876        // already gated by the f4efe9c leading-byte arm which routes
14877        // through `FonteCaminhoVarExpansion`; this arm closes the
14878        // last positional gap on `$` — every position on the axis is
14879        // structurally rejected.
14880        let d = dep_with_fonte(DepSource::Path {
14881            caminho: "../foo$HOME/bar".into(),
14882        });
14883        let err = d.validate().unwrap_err();
14884        let DepError::FonteCaminhoShellVariableExpansion {
14885            nome,
14886            caminho,
14887            byte,
14888        } = err
14889        else {
14890            panic!("expected FonteCaminhoShellVariableExpansion, got {err:?}");
14891        };
14892        assert_eq!(nome, "caixa-teia");
14893        assert_eq!(caminho, "../foo$HOME/bar");
14894        assert_eq!(byte, b'$');
14895    }
14896
14897    #[test]
14898    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_braced_var_expansion() {
14899        // The symmetric braced-CI-manifest paste shape
14900        // (`"../foo${WORKSPACE}/bar"` — the canonical paste-from-
14901        // GitHub-Actions-workflow / paste-from-`.gitlab-ci.yml`
14902        // footgun). Pinned separately from the bare-`$VAR` shape so
14903        // the gate covers both POSIX shell §2.6 Parameter Expansion
14904        // syntactic forms, not only the unbraced variant. The
14905        // embedded `{` byte in `${...}` is also caught by the 598b770
14906        // shell-brace-expansion arm but that arm fires earlier in
14907        // the cascade — the `$` arm's coverage extends to `${...}`
14908        // structurally, so the diagnostic asserted here is the
14909        // brace-expansion one (which is a valid outcome; the point
14910        // of the pin is that the value never survives validation).
14911        let d = dep_with_fonte(DepSource::Path {
14912            caminho: "../foo${WORKSPACE}/bar".into(),
14913        });
14914        let err = d.validate().unwrap_err();
14915        assert!(
14916            matches!(
14917                err,
14918                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. }
14919                    | DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
14920            ),
14921            "got {err:?}",
14922        );
14923    }
14924
14925    #[test]
14926    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_command_substitution() {
14927        // The paste-from-shell-prompt command-substitution idiom
14928        // (`"../foo$(whoami)/bar"`). Pinned separately from the bare-
14929        // `$VAR` shape so the gate's rationale extends to POSIX shell
14930        // §2.6.3 Command Substitution (the modern `$(<cmd>)` form; the
14931        // legacy `` `<cmd>` `` form is already closed by the c370458
14932        // backtick arm). The embedded `(` byte in `$(...)` is also
14933        // caught structurally by the 0633c91 shell-subshell-grouping
14934        // arm which fires earlier in the cascade — the diagnostic
14935        // asserted here is either outcome, since both structurally
14936        // reject the value; the point of the pin is that the value
14937        // never survives validation.
14938        let d = dep_with_fonte(DepSource::Path {
14939            caminho: "../foo$(whoami)/bar".into(),
14940        });
14941        let err = d.validate().unwrap_err();
14942        assert!(
14943            matches!(
14944                err,
14945                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. }
14946                    | DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
14947            ),
14948            "got {err:?}",
14949        );
14950    }
14951
14952    #[test]
14953    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_positional_parameter() {
14954        // The paste-from-`Makefile` / paste-from-SQL-migration bare-
14955        // `$1` positional-parameter shape (`"../foo$1/bar"` — a Make
14956        // automatic-variable `$1` or a PostgreSQL bind-parameter `$1`
14957        // idiom copied into a caminho template). None of the prior
14958        // shell-metachar arms cover this shape (`1` is a bare digit;
14959        // no `(` / `{` / letter follows the `$`), so the arm is the
14960        // sole gate on the shape.
14961        let d = dep_with_fonte(DepSource::Path {
14962            caminho: "../foo$1/bar".into(),
14963        });
14964        let err = d.validate().unwrap_err();
14965        assert!(
14966            matches!(
14967                err,
14968                DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
14969            ),
14970            "got {err:?}",
14971        );
14972    }
14973
14974    #[test]
14975    fn validate_accepts_path_fonte_with_caminho_carrying_no_dollar() {
14976        // The positive-control pin (peer with
14977        // `validate_accepts_path_fonte_with_caminho_carrying_no_percent`
14978        // on the immediate-predecessor arm): the gate targets only
14979        // `$`, never adjacent printable ASCII or POSIX-valid bytes.
14980        // A relative POSIX path carrying dashes / dots / slashes /
14981        // digits (`"../caixa-teia/sub-dir.v2"`) must continue to
14982        // validate cleanly so the gate doesn't widen to a "no
14983        // printable punctuation anywhere" sweep that would defeat
14984        // the entire path-fonte author surface.
14985        let d = dep_with_fonte(DepSource::Path {
14986            caminho: "../caixa-teia/sub-dir.v2".into(),
14987        });
14988        d.validate().unwrap();
14989    }
14990
14991    #[test]
14992    fn fonte_caminho_var_expansion_fires_before_shell_variable_expansion() {
14993        // Cascade pin on the leading-`$` sibling arm at line 540: a
14994        // value starting with `$` and carrying an embedded `$` too
14995        // (`"$HOME/foo$WORKSPACE/bar"` — the canonical "I pasted a
14996        // fully-templated CI path with two un-substituted variables")
14997        // routes through `FonteCaminhoVarExpansion` not
14998        // `FonteCaminhoShellVariableExpansion`. The leading-byte
14999        // host-layout-leak is the load-bearing self-locating axis
15000        // (the leading position dominates the semantic-locating
15001        // rationale on every probe-as-both value); the embedded
15002        // arm's positional-agnostic sweep catches only values whose
15003        // leading byte doesn't route through the earlier leading-
15004        // byte arms.
15005        let d = dep_with_fonte(DepSource::Path {
15006            caminho: "$HOME/foo$WORKSPACE/bar".into(),
15007        });
15008        let err = d.validate().unwrap_err();
15009        assert!(
15010            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
15011            "got {err:?}",
15012        );
15013    }
15014
15015    #[test]
15016    fn fonte_caminho_url_percent_encoding_fires_before_shell_variable_expansion() {
15017        // Cascade pin on the immediate-predecessor arm: a value
15018        // carrying both `%` and embedded `$` (`"../foo%20$HOME/bar"`
15019        // — the canonical "I pasted a percent-encoded space adjacent
15020        // to a `$HOME` template") routes through
15021        // `FonteCaminhoUrlPercentEncoding` not
15022        // `FonteCaminhoShellVariableExpansion`. The URL-percent-
15023        // encoding-escape byte is the more semantic-locating axis
15024        // (the paste-from-browser-address-bar shape is the load-
15025        // bearing self-locating edit); same cascade discipline every
15026        // prior `:caminho` arm establishes.
15027        let d = dep_with_fonte(DepSource::Path {
15028            caminho: "../foo%20$HOME/bar".into(),
15029        });
15030        let err = d.validate().unwrap_err();
15031        assert!(
15032            matches!(
15033                err,
15034                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
15035            ),
15036            "got {err:?}",
15037        );
15038    }
15039
15040    #[test]
15041    fn fonte_caminho_shell_variable_expansion_fires_before_trailing_slash() {
15042        // Cascade pin on the immediate-successor arm: a value
15043        // carrying both embedded `$` and a trailing `/`
15044        // (`"../foo$HOME/bar/"` — the canonical "I tab-completed a
15045        // `$HOME`-template-carrying path") routes through
15046        // `FonteCaminhoShellVariableExpansion` not
15047        // `FonteCaminhoTrailingSlash`. The embedded shell-variable-
15048        // expansion byte is the more semantic-locating axis on
15049        // probe-as-both values (an author who substitutes the
15050        // `$HOME` template with a literal value is likely to also
15051        // tab-strip the trailing separator).
15052        let d = dep_with_fonte(DepSource::Path {
15053            caminho: "../foo$HOME/bar/".into(),
15054        });
15055        let err = d.validate().unwrap_err();
15056        assert!(
15057            matches!(
15058                err,
15059                DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
15060            ),
15061            "got {err:?}",
15062        );
15063    }
15064
15065    #[test]
15066    fn fonte_caminho_shell_variable_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
15067        // Diagnostic-shape pin (peer with
15068        // `fonte_caminho_url_percent_encoding_diagnostic_carries_offending_dep_caminho_and_byte`
15069        // on the immediate-predecessor arm): the error's Display
15070        // surfaces the offending `:nome`, the offending `:caminho`
15071        // verbatim, the offending byte's hex / character form, and
15072        // names the shell-variable-expansion / command-substitution
15073        // footgun explicitly so a `feira lint` run can render the
15074        // diagnostic without re-parsing.
15075        let d = dep_with_fonte(DepSource::Path {
15076            caminho: "../foo$HOME/bar".into(),
15077        });
15078        let rendered = d.validate().unwrap_err().to_string();
15079        assert!(
15080            rendered.contains("caixa-teia"),
15081            "diagnostic must name the offending dep: {rendered}",
15082        );
15083        assert!(
15084            rendered.contains("../foo$HOME/bar"),
15085            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
15086        );
15087        assert!(
15088            rendered.contains("0x24"),
15089            "diagnostic must surface the offending byte hex: {rendered:?}",
15090        );
15091        assert!(
15092            rendered.contains("variable-expansion") || rendered.contains("variable expansion"),
15093            "diagnostic must name the shell-variable-expansion footgun: {rendered:?}",
15094        );
15095        assert!(
15096            rendered.contains("command-substitution") || rendered.contains("command substitution"),
15097            "diagnostic must reference the command-substitution vocabulary: {rendered:?}",
15098        );
15099    }
15100
15101    #[test]
15102    fn validate_rejects_path_fonte_with_caminho_carrying_shell_history_expansion() {
15103        // The fail-before-pass-after pin for the canonical paste-from-
15104        // shell-history footgun on `:caminho`. An author copies a `cd
15105        // ../caixa-teia && !sudo make install` one-liner from a quick-
15106        // start README, intending the trailing `!sudo` as a shell-
15107        // history-expansion reference but the typed slot is itself a
15108        // byte-level string parser, not a shell context, so the byte
15109        // rides into the value verbatim. Until this arm landed the `!`
15110        // byte silently passed every prior `:caminho` cascade arm
15111        // (`!` isn't `\` / `<` / `>` / `|` / `;` / `&` / backtick /
15112        // `*` / `?` / `(` / `)` / `{` / `}` / `[` / `]` / `'` / `"` /
15113        // `#` / `%` / `$`); bash with the default `histexpand` mode
15114        // rewrites `!command` to the most recent history entry
15115        // beginning with `command`, the canonical RCE-class injection
15116        // vector when the byte rides into a shell argument executed
15117        // under `bash -i` (the operator-notebook interactive shell).
15118        let d = dep_with_fonte(DepSource::Path {
15119            caminho: "../caixa-teia!sudo".into(),
15120        });
15121        let err = d.validate().unwrap_err();
15122        let DepError::FonteCaminhoShellHistoryExpansion {
15123            nome,
15124            caminho,
15125            byte,
15126        } = err
15127        else {
15128            panic!("expected FonteCaminhoShellHistoryExpansion, got {err:?}");
15129        };
15130        assert_eq!(nome, "caixa-teia");
15131        assert_eq!(caminho, "../caixa-teia!sudo");
15132        assert_eq!(byte, b'!');
15133    }
15134
15135    #[test]
15136    fn validate_rejects_path_fonte_with_caminho_carrying_double_bang_history_reference() {
15137        // The symmetric `!!` repeat-prior-command paste idiom (peer with
15138        // `validate_rejects_git_fonte_with_repo_carrying_double_bang_history_reference`
15139        // on `is_git_repo_url`). Pinned separately from the wrapped
15140        // `!command` shape so a future diagnostic-surface change that
15141        // only checked the leading or paired-bang position surfaces
15142        // here — the per-byte arm fires anywhere `!` appears in the
15143        // value, including at consecutive positions in the middle.
15144        let d = dep_with_fonte(DepSource::Path {
15145            caminho: "../foo!!/bar".into(),
15146        });
15147        let err = d.validate().unwrap_err();
15148        assert!(
15149            matches!(
15150                err,
15151                DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
15152            ),
15153            "got {err:?}",
15154        );
15155    }
15156
15157    #[test]
15158    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_enthusiasm_bang() {
15159        // The English-typography enthusiasm-form paste-from-prose
15160        // idiom: an author writes `:caminho "../caixa-teia!"`
15161        // expecting the substrate to coerce it to a kebab-case slug.
15162        // Pinned separately from the `!<word>` shell-history shape so
15163        // the gate's rationale extends to the paste-from-prose surface
15164        // (the same rationale the peer `is_git_repo_url` bang arm at
15165        // 7d53c68 covers). None of the prior shell-metachar arms cover
15166        // this shape (no `!<word>` reference and no `!!` repeat), so
15167        // the arm is the sole gate on the shape.
15168        let d = dep_with_fonte(DepSource::Path {
15169            caminho: "../caixa-teia!".into(),
15170        });
15171        let err = d.validate().unwrap_err();
15172        assert!(
15173            matches!(
15174                err,
15175                DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
15176            ),
15177            "got {err:?}",
15178        );
15179    }
15180
15181    #[test]
15182    fn validate_accepts_path_fonte_with_caminho_carrying_no_bang() {
15183        // The positive-control pin (peer with
15184        // `validate_accepts_path_fonte_with_caminho_carrying_no_dollar`
15185        // on the immediate-predecessor arm): the gate targets only
15186        // `!`, never adjacent printable ASCII or POSIX-valid bytes.
15187        // A relative POSIX path carrying dashes / dots / slashes /
15188        // digits (`"../caixa-teia/sub-dir.v2"`) must continue to
15189        // validate cleanly so the gate doesn't widen to a "no
15190        // printable punctuation anywhere" sweep that would defeat
15191        // the entire path-fonte author surface.
15192        let d = dep_with_fonte(DepSource::Path {
15193            caminho: "../caixa-teia/sub-dir.v2".into(),
15194        });
15195        d.validate().unwrap();
15196    }
15197
15198    #[test]
15199    fn fonte_caminho_shell_variable_expansion_fires_before_shell_history_expansion() {
15200        // Cascade pin on the immediate-predecessor arm: a value
15201        // carrying both embedded `$` and `!` (`"../foo$HOME/bar!sudo"`
15202        // — the canonical "I pasted a `$HOME`-templated path adjacent
15203        // to a trailing `!sudo` history-expansion") routes through
15204        // `FonteCaminhoShellVariableExpansion` not
15205        // `FonteCaminhoShellHistoryExpansion`. The shell-variable-
15206        // expansion byte is the more semantic-locating axis on
15207        // probe-as-both values (the paste-from-CI-manifest-with-`$VAR`-
15208        // template shape is the load-bearing self-locating edit);
15209        // same cascade discipline every prior `:caminho` arm
15210        // establishes.
15211        let d = dep_with_fonte(DepSource::Path {
15212            caminho: "../foo$HOME/bar!sudo".into(),
15213        });
15214        let err = d.validate().unwrap_err();
15215        assert!(
15216            matches!(
15217                err,
15218                DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
15219            ),
15220            "got {err:?}",
15221        );
15222    }
15223
15224    #[test]
15225    fn fonte_caminho_shell_history_expansion_fires_before_trailing_slash() {
15226        // Cascade pin on the immediate-successor arm: a value carrying
15227        // both embedded `!` and a trailing `/` (`"../caixa-teia!sudo/"`
15228        // — the canonical "I tab-completed a `!sudo`-carrying path")
15229        // routes through `FonteCaminhoShellHistoryExpansion` not
15230        // `FonteCaminhoTrailingSlash`. The embedded shell-history-
15231        // expansion byte is the more semantic-locating axis on probe-
15232        // as-both values (an author who removes the `!sudo` history
15233        // reference is likely to also tab-strip the trailing separator).
15234        let d = dep_with_fonte(DepSource::Path {
15235            caminho: "../caixa-teia!sudo/".into(),
15236        });
15237        let err = d.validate().unwrap_err();
15238        assert!(
15239            matches!(
15240                err,
15241                DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
15242            ),
15243            "got {err:?}",
15244        );
15245    }
15246
15247    #[test]
15248    fn fonte_caminho_shell_history_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
15249        // Diagnostic-shape pin (peer with
15250        // `fonte_caminho_shell_variable_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
15251        // on the immediate-predecessor arm): the error's Display
15252        // surfaces the offending `:nome`, the offending `:caminho`
15253        // verbatim, the offending byte's hex / character form, and
15254        // names the shell-history-expansion / bang-operator footgun
15255        // explicitly so a `feira lint` run can render the diagnostic
15256        // without re-parsing.
15257        let d = dep_with_fonte(DepSource::Path {
15258            caminho: "../caixa-teia!sudo".into(),
15259        });
15260        let rendered = d.validate().unwrap_err().to_string();
15261        assert!(
15262            rendered.contains("caixa-teia"),
15263            "diagnostic must name the offending dep: {rendered}",
15264        );
15265        assert!(
15266            rendered.contains("../caixa-teia!sudo"),
15267            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
15268        );
15269        assert!(
15270            rendered.contains("0x21"),
15271            "diagnostic must surface the offending byte hex: {rendered:?}",
15272        );
15273        assert!(
15274            rendered.contains("history-expansion") || rendered.contains("history expansion"),
15275            "diagnostic must name the shell-history-expansion footgun: {rendered:?}",
15276        );
15277        assert!(
15278            rendered.contains("bang"),
15279            "diagnostic must reference the bang-operator vocabulary: {rendered:?}",
15280        );
15281    }
15282
15283    #[test]
15284    fn validate_rejects_path_fonte_with_caminho_carrying_shell_history_substitution() {
15285        // The fail-before-pass-after pin for the canonical paste-from-
15286        // shell-history-quick-substitution footgun on `:caminho`. An
15287        // author copies a `git clone <bad-url>` line from their terminal,
15288        // corrects it via bash's `^bad^good` quick-substitution history
15289        // operator (bash reference §9.3, `set -o histexpand` mode's
15290        // default for interactive sessions), and pastes the trailing
15291        // `^bad^good` substitution fragment into a `:caminho` value
15292        // without trimming the leading `git clone` prefix — the byte
15293        // rides into the manifest verbatim. Until this arm landed the
15294        // `^` byte silently passed every prior `:caminho` cascade arm
15295        // (`^` isn't `\` / `<` / `>` / `|` / `;` / `&` / backtick / `*`
15296        // / `?` / `(` / `)` / `{` / `}` / `[` / `]` / `'` / `"` / `#` /
15297        // `%` / `$` / `!`); bash with the default `histexpand` mode
15298        // rewrites the prior command's `bad` string to `good` and re-
15299        // executes it, the paired-operator half of the `set -o
15300        // histexpand` feature the peer `!` arm already closes the prefix
15301        // half of. The peer `is_git_repo_url` axis rejects the byte at
15302        // 49e142f under the same shell-history-substitution / RFC-3986-
15303        // unwise banner.
15304        let d = dep_with_fonte(DepSource::Path {
15305            caminho: "../foo^bad^good".into(),
15306        });
15307        let err = d.validate().unwrap_err();
15308        let DepError::FonteCaminhoShellHistorySubstitution {
15309            nome,
15310            caminho,
15311            byte,
15312        } = err
15313        else {
15314            panic!("expected FonteCaminhoShellHistorySubstitution, got {err:?}");
15315        };
15316        assert_eq!(nome, "caixa-teia");
15317        assert_eq!(caminho, "../foo^bad^good");
15318        assert_eq!(byte, b'^');
15319    }
15320
15321    #[test]
15322    fn validate_rejects_path_fonte_with_caminho_carrying_regex_negation_anchor() {
15323        // The symmetric paste-from-doc-grep-pipeline footgun (peer with
15324        // `validate_rejects_git_fonte_with_repo_carrying_caret_regex_anchor`
15325        // on `is_git_repo_url`). An author copies a `grep '^archived'`
15326        // regex-anchor / negation idiom from a doc snippet and the byte
15327        // rides in verbatim. Pinned separately from the `^old^new^`
15328        // quick-substitution shape so a future diagnostic-surface change
15329        // that only checked the paired-caret history-substitution
15330        // position surfaces here — the per-byte arm fires anywhere `^`
15331        // appears in the value, including at a solitary leading-of-
15332        // segment position.
15333        let d = dep_with_fonte(DepSource::Path {
15334            caminho: "../foo/^archived".into(),
15335        });
15336        let err = d.validate().unwrap_err();
15337        assert!(
15338            matches!(
15339                err,
15340                DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
15341            ),
15342            "got {err:?}",
15343        );
15344    }
15345
15346    #[test]
15347    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_history_substitution_open() {
15348        // The trailing-`^` history-substitution-open shape — an author
15349        // starts typing a `^bad^good` quick-substitution but pastes only
15350        // the leading `^` sentinel before context-switching (a bash-
15351        // reference §9.3 valid histexpand prefix on its own — even a
15352        // solitary `^` on the prior command's whole re-execution shape).
15353        // Pinned separately from the `^old^new^` full-form and the leading-
15354        // of-segment `^archived` regex-anchor shape so the gate's
15355        // rationale extends to the paste-from-shell-history-with-only-
15356        // the-first-byte-selected surface. None of the prior shell-
15357        // metachar arms cover this shape.
15358        let d = dep_with_fonte(DepSource::Path {
15359            caminho: "../caixa-teia^".into(),
15360        });
15361        let err = d.validate().unwrap_err();
15362        assert!(
15363            matches!(
15364                err,
15365                DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
15366            ),
15367            "got {err:?}",
15368        );
15369    }
15370
15371    #[test]
15372    fn validate_accepts_path_fonte_with_caminho_carrying_no_caret() {
15373        // The positive-control pin (peer with
15374        // `validate_accepts_path_fonte_with_caminho_carrying_no_bang`
15375        // on the immediate-predecessor arm): the gate targets only
15376        // `^`, never adjacent printable ASCII or POSIX-valid bytes.
15377        // A relative POSIX path carrying dashes / dots / slashes /
15378        // digits / underscore (`"../caixa-teia/sub_v2.rc"`) must
15379        // continue to validate cleanly so the gate doesn't widen to
15380        // a "no printable punctuation anywhere" sweep that would
15381        // defeat the entire path-fonte author surface.
15382        let d = dep_with_fonte(DepSource::Path {
15383            caminho: "../caixa-teia/sub_v2.rc".into(),
15384        });
15385        d.validate().unwrap();
15386    }
15387
15388    #[test]
15389    fn fonte_caminho_shell_history_expansion_fires_before_shell_history_substitution() {
15390        // Cascade pin on the immediate-predecessor arm: a value carrying
15391        // both embedded `!` and `^` (`"../foo!sudo^bad^good"` — the
15392        // canonical "I pasted a `!sudo` history-reference next to a
15393        // `^bad^good` quick-substitution") routes through
15394        // `FonteCaminhoShellHistoryExpansion` not
15395        // `FonteCaminhoShellHistorySubstitution`. The `!` prefix form is
15396        // the more semantic-locating axis on probe-as-both values (an
15397        // author who removes the `!sudo` reference is likely to also
15398        // strip the paired `^` substitution fragment); same cascade
15399        // discipline every prior `:caminho` arm establishes.
15400        let d = dep_with_fonte(DepSource::Path {
15401            caminho: "../foo!sudo^bad^good".into(),
15402        });
15403        let err = d.validate().unwrap_err();
15404        assert!(
15405            matches!(
15406                err,
15407                DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
15408            ),
15409            "got {err:?}",
15410        );
15411    }
15412
15413    #[test]
15414    fn fonte_caminho_shell_history_substitution_fires_before_trailing_slash() {
15415        // Cascade pin on the immediate-successor arm: a value carrying
15416        // both embedded `^` and a trailing `/` (`"../foo^bad^good/"` —
15417        // the canonical "I tab-completed a `^bad^good`-carrying path")
15418        // routes through `FonteCaminhoShellHistorySubstitution` not
15419        // `FonteCaminhoTrailingSlash`. The embedded shell-history-
15420        // substitution byte is the more semantic-locating axis on probe-
15421        // as-both values (an author who removes the `^bad^good`
15422        // substitution fragment is likely to also tab-strip the trailing
15423        // separator).
15424        let d = dep_with_fonte(DepSource::Path {
15425            caminho: "../foo^bad^good/".into(),
15426        });
15427        let err = d.validate().unwrap_err();
15428        assert!(
15429            matches!(
15430                err,
15431                DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
15432            ),
15433            "got {err:?}",
15434        );
15435    }
15436
15437    #[test]
15438    fn fonte_caminho_shell_history_substitution_diagnostic_carries_offending_dep_caminho_and_byte()
15439    {
15440        // Diagnostic-shape pin (peer with
15441        // `fonte_caminho_shell_history_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
15442        // on the immediate-predecessor arm): the error's Display
15443        // surfaces the offending `:nome`, the offending `:caminho`
15444        // verbatim, the offending byte's hex form, and names the
15445        // shell-history-substitution / RFC-3986-'unwise' / regex-
15446        // negation footgun explicitly so a `feira lint` run can render
15447        // the diagnostic without re-parsing.
15448        let d = dep_with_fonte(DepSource::Path {
15449            caminho: "../foo^bad^good".into(),
15450        });
15451        let rendered = d.validate().unwrap_err().to_string();
15452        assert!(
15453            rendered.contains("caixa-teia"),
15454            "diagnostic must name the offending dep: {rendered}",
15455        );
15456        assert!(
15457            rendered.contains("../foo^bad^good"),
15458            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
15459        );
15460        assert!(
15461            rendered.contains("0x5e") || rendered.contains("0x5E"),
15462            "diagnostic must surface the offending byte hex: {rendered:?}",
15463        );
15464        assert!(
15465            rendered.contains("history-substitution") || rendered.contains("history substitution"),
15466            "diagnostic must name the shell-history-substitution footgun: {rendered:?}",
15467        );
15468        assert!(
15469            rendered.contains("unwise"),
15470            "diagnostic must reference the RFC-3986 'unwise' set vocabulary: {rendered:?}",
15471        );
15472    }
15473
15474    #[test]
15475    fn fonte_repo_empty_fires_before_pin_missing() {
15476        // Order pin: empty `:repo` is the more self-locating diagnostic
15477        // (every git source needs a repo; the pin discussion is
15478        // secondary), so it fires before the pin-missing arm even when
15479        // both are violated. Mirrors the
15480        // `nome_empty_takes_precedence_over_versao_invalid` ordering
15481        // discipline on the per-entry layer.
15482        let d = dep_with_fonte(DepSource::Git {
15483            repo: String::new(),
15484            tag: None,
15485            rev: None,
15486            branch: None,
15487        });
15488        let err = d.validate().unwrap_err();
15489        assert!(
15490            matches!(err, DepError::FonteRepoEmpty { .. }),
15491            "got {err:?}"
15492        );
15493    }
15494
15495    #[test]
15496    fn fonte_pin_missing_fires_before_pin_empty() {
15497        // Order pin: a fully-None pin set is structurally distinct from
15498        // a Some(empty) pin — the first surfaces as FontePinMissing
15499        // (no axis chosen), the second as FontePinEmpty (axis chosen
15500        // but value blank). Pin the disjoint relationship so a future
15501        // unification collapses to one variant only as a structural
15502        // decision.
15503        let d = dep_with_fonte(DepSource::Git {
15504            repo: "github:pleme-io/caixa-teia".into(),
15505            tag: None,
15506            rev: None,
15507            branch: None,
15508        });
15509        assert!(matches!(
15510            d.validate().unwrap_err(),
15511            DepError::FontePinMissing { .. }
15512        ));
15513    }
15514
15515    #[test]
15516    fn nome_empty_takes_precedence_over_fonte_invalid() {
15517        // Order pin: a per-entry diagnostic without a non-empty :nome
15518        // can't be self-locating, so :nome "" fires first even when
15519        // :fonte is also malformed. Mirrors
15520        // `nome_empty_takes_precedence_over_versao_invalid` on the
15521        // adjacent axis.
15522        let mut d = dep_with_fonte(DepSource::Git {
15523            repo: String::new(),
15524            tag: None,
15525            rev: None,
15526            branch: None,
15527        });
15528        d.nome = String::new();
15529        assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
15530    }
15531
15532    #[test]
15533    fn versao_invalid_takes_precedence_over_fonte_invalid() {
15534        // Order pin: the :versao parse-side diagnostic is narrower than
15535        // the :fonte shape diagnostic — a malformed :versao always names
15536        // the parser's reason, which is more actionable than the
15537        // :fonte gate's "the pins are wrong" wording. Pin the ordering
15538        // so a re-ordering surfaces here.
15539        let mut d = dep_with_fonte(DepSource::Git {
15540            repo: String::new(),
15541            tag: None,
15542            rev: None,
15543            branch: None,
15544        });
15545        d.versao = "v0.1".into();
15546        let err = d.validate().unwrap_err();
15547        assert!(
15548            matches!(err, DepError::VersaoInvalid { ref nome, .. } if nome == "caixa-teia"),
15549            "got {err:?}"
15550        );
15551    }
15552
15553    #[test]
15554    fn fonte_invalid_diagnostic_carries_offending_nome() {
15555        // The diagnostic-shape pin: every :fonte error variant names
15556        // the offending dep's :nome verbatim, so the author can grep
15557        // caixa.lisp for the `:nome "<n>"` block and fix it in one
15558        // edit. Cover all seven variants so a future variant addition
15559        // forces a parallel diagnostic-shape decision.
15560        for (case, fonte) in [
15561            (
15562                "repo-empty",
15563                DepSource::Git {
15564                    repo: String::new(),
15565                    tag: Some("v1".into()),
15566                    rev: None,
15567                    branch: None,
15568                },
15569            ),
15570            (
15571                "repo-shape",
15572                DepSource::Git {
15573                    repo: "github:p/x ".into(),
15574                    tag: Some("v1".into()),
15575                    rev: None,
15576                    branch: None,
15577                },
15578            ),
15579            (
15580                "pin-missing",
15581                DepSource::Git {
15582                    repo: "github:p/x".into(),
15583                    tag: None,
15584                    rev: None,
15585                    branch: None,
15586                },
15587            ),
15588            (
15589                "pin-ambiguous",
15590                DepSource::Git {
15591                    repo: "github:p/x".into(),
15592                    tag: Some("v1".into()),
15593                    rev: None,
15594                    branch: Some("main".into()),
15595                },
15596            ),
15597            (
15598                "pin-empty",
15599                DepSource::Git {
15600                    repo: "github:p/x".into(),
15601                    tag: Some(String::new()),
15602                    rev: None,
15603                    branch: None,
15604                },
15605            ),
15606            (
15607                "caminho-empty",
15608                DepSource::Path {
15609                    caminho: String::new(),
15610                },
15611            ),
15612            (
15613                "caminho-absolute",
15614                DepSource::Path {
15615                    caminho: "/home/me/work/caixa-teia".into(),
15616                },
15617            ),
15618        ] {
15619            let d = dep_with_fonte(fonte);
15620            let msg = d
15621                .validate()
15622                .expect_err(&format!("{case}: expected fonte error"))
15623                .to_string();
15624            assert!(
15625                msg.contains("\"caixa-teia\""),
15626                "{case}: diagnostic must quote the offending :nome verbatim, got {msg:?}"
15627            );
15628        }
15629    }
15630
15631    // -- :tag / :branch value-shape gate ----------------------------------
15632
15633    #[test]
15634    fn validate_rejects_git_fonte_with_tag_carrying_trailing_space() {
15635        // The canonical paste-from-doc footgun on `:tag` — author
15636        // copies `"v0.1.0 "` (trailing space) out of a release-notes
15637        // paragraph. Until this gate landed the empty-pin arm passed
15638        // (the string isn't empty), the resolver issued
15639        // `git fetch <remote> tag 'v0.1.0 '`, and the failure
15640        // surfaced at clone time with a quoting-confused git error
15641        // far from the source caixa.lisp. The new gate moves the
15642        // check to caixa-build time and names the offending dep +
15643        // pin + value verbatim.
15644        let d = dep_with_fonte(DepSource::Git {
15645            repo: "github:pleme-io/caixa-teia".into(),
15646            tag: Some("v0.1.0 ".into()),
15647            rev: None,
15648            branch: None,
15649        });
15650        let err = d.validate().unwrap_err();
15651        let DepError::FontePinShape {
15652            nome,
15653            pin,
15654            value,
15655            reason,
15656        } = err
15657        else {
15658            panic!("expected FontePinShape, got other variant");
15659        };
15660        assert_eq!(nome, "caixa-teia");
15661        assert_eq!(pin, ":tag");
15662        assert_eq!(value, "v0.1.0 ");
15663        assert!(
15664            reason.contains("whitespace"),
15665            "reason must surface the whitespace arm, got {reason:?}"
15666        );
15667    }
15668
15669    #[test]
15670    fn validate_rejects_git_fonte_with_tag_carrying_lock_suffix() {
15671        // The `.lock` suffix is git's atomic-rename guard for
15672        // in-flight ref updates — a refname ending in `.lock` is
15673        // unwritable on disk. Pinned separately from the whitespace
15674        // arm so a future relaxation that admits one but not the
15675        // other surfaces here.
15676        let d = dep_with_fonte(DepSource::Git {
15677            repo: "github:pleme-io/caixa-teia".into(),
15678            tag: Some("v0.1.0.lock".into()),
15679            rev: None,
15680            branch: None,
15681        });
15682        let err = d.validate().unwrap_err();
15683        let DepError::FontePinShape {
15684            pin, value, reason, ..
15685        } = err
15686        else {
15687            panic!("expected FontePinShape, got other variant");
15688        };
15689        assert_eq!(pin, ":tag");
15690        assert_eq!(value, "v0.1.0.lock");
15691        assert!(
15692            reason.contains(".lock"),
15693            "reason must surface the .lock arm, got {reason:?}"
15694        );
15695    }
15696
15697    #[test]
15698    fn validate_rejects_git_fonte_with_branch_carrying_embedded_space() {
15699        // The canonical "branch name with spaces" footgun (`feature
15700        // foo`, `release branch`) — git's refname parser rejects raw
15701        // whitespace, and the failure surfaces at `git checkout
15702        // 'feature foo'` time with a quoting-confused error far from
15703        // the source caixa.lisp. Pinned on the `:branch` axis so the
15704        // gate-applies-to-both-:tag-and-:branch contract is a build-
15705        // error to relax.
15706        let d = dep_with_fonte(DepSource::Git {
15707            repo: "github:pleme-io/caixa-teia".into(),
15708            tag: None,
15709            rev: None,
15710            branch: Some("feature/foo bar".into()),
15711        });
15712        let err = d.validate().unwrap_err();
15713        let DepError::FontePinShape {
15714            pin, value, reason, ..
15715        } = err
15716        else {
15717            panic!("expected FontePinShape, got other variant");
15718        };
15719        assert_eq!(pin, ":branch");
15720        assert_eq!(value, "feature/foo bar");
15721        assert!(
15722            reason.contains("whitespace"),
15723            "reason must surface the whitespace arm, got {reason:?}"
15724        );
15725    }
15726
15727    #[test]
15728    fn validate_rejects_git_fonte_with_branch_carrying_qualified_prefix() {
15729        // The `refs/heads/main` shape — the canonical "I copied the
15730        // fully-qualified ref out of `git show-ref` instead of the
15731        // leaf" footgun. The caixa-resolver prepends `refs/heads/`
15732        // at clone time, so this resolves to a literal ref named
15733        // `refs/heads/refs/heads/main` on disk; the silent double-
15734        // prefix is the load-bearing reason to gate at validate.
15735        // The diagnostic must enumerate the leaf the author probably
15736        // meant (`"main"`) so the fix is one edit.
15737        let d = dep_with_fonte(DepSource::Git {
15738            repo: "github:pleme-io/caixa-teia".into(),
15739            tag: None,
15740            rev: None,
15741            branch: Some("refs/heads/main".into()),
15742        });
15743        let err = d.validate().unwrap_err();
15744        let DepError::FontePinShape {
15745            pin, value, reason, ..
15746        } = err
15747        else {
15748            panic!("expected FontePinShape, got other variant");
15749        };
15750        assert_eq!(pin, ":branch");
15751        assert_eq!(value, "refs/heads/main");
15752        assert!(
15753            reason.contains("fully-qualified"),
15754            "reason must surface the qualified-prefix arm, got {reason:?}"
15755        );
15756        assert!(
15757            reason.contains("\"main\""),
15758            "reason must quote the leaf the author probably meant, got {reason:?}"
15759        );
15760    }
15761
15762    #[test]
15763    fn validate_rejects_git_fonte_with_tag_carrying_qualified_prefix() {
15764        // Sibling arm of the qualified-prefix gate on the `:tag`
15765        // axis (`refs/tags/v0.1.0` — same `git show-ref` output-leak
15766        // footgun). Pinned separately so a future relaxation that
15767        // only catches the `:branch` arm surfaces here.
15768        let d = dep_with_fonte(DepSource::Git {
15769            repo: "github:pleme-io/caixa-teia".into(),
15770            tag: Some("refs/tags/v0.1.0".into()),
15771            rev: None,
15772            branch: None,
15773        });
15774        let err = d.validate().unwrap_err();
15775        let DepError::FontePinShape {
15776            pin, value, reason, ..
15777        } = err
15778        else {
15779            panic!("expected FontePinShape, got other variant");
15780        };
15781        assert_eq!(pin, ":tag");
15782        assert_eq!(value, "refs/tags/v0.1.0");
15783        assert!(
15784            reason.contains("fully-qualified"),
15785            "reason must surface the qualified-prefix arm, got {reason:?}"
15786        );
15787        assert!(
15788            reason.contains("\"v0.1.0\""),
15789            "reason must quote the leaf the author probably meant, got {reason:?}"
15790        );
15791    }
15792
15793    #[test]
15794    fn validate_rejects_git_fonte_with_branch_named_at() {
15795        // The bare `@` is git's alias for `HEAD`; a `:branch "@"` is
15796        // unsourceable. Pinned so a future relaxation that admits
15797        // any single-character refname surfaces here.
15798        let d = dep_with_fonte(DepSource::Git {
15799            repo: "github:pleme-io/caixa-teia".into(),
15800            tag: None,
15801            rev: None,
15802            branch: Some("@".into()),
15803        });
15804        let err = d.validate().unwrap_err();
15805        let DepError::FontePinShape { pin, value, .. } = err else {
15806            panic!("expected FontePinShape, got other variant");
15807        };
15808        assert_eq!(pin, ":branch");
15809        assert_eq!(value, "@");
15810    }
15811
15812    #[test]
15813    fn validate_rejects_git_fonte_with_tag_carrying_double_dot() {
15814        // Git's `<rev1>..<rev2>` range grammar reserves `..` —
15815        // a `:tag "../escape"` (path-traversal-shaped slug) silently
15816        // passes parse and surfaces as a refname-parse error or, on
15817        // older git, a literal `../escape` checkout that escapes the
15818        // refs/ directory tree. Pinned separately from the
15819        // qualified-prefix arm so a future relaxation that catches
15820        // one but not the other surfaces here.
15821        let d = dep_with_fonte(DepSource::Git {
15822            repo: "github:pleme-io/caixa-teia".into(),
15823            tag: Some("../escape".into()),
15824            rev: None,
15825            branch: None,
15826        });
15827        let err = d.validate().unwrap_err();
15828        let DepError::FontePinShape { pin, value, .. } = err else {
15829            panic!("expected FontePinShape, got other variant");
15830        };
15831        assert_eq!(pin, ":tag");
15832        assert_eq!(value, "../escape");
15833    }
15834
15835    #[test]
15836    fn validate_accepts_git_fonte_with_hierarchical_branch() {
15837        // The positive-control pin: hierarchical refnames with one or
15838        // more `/` separators (the `feature/foo` / `user/jdoe/feat`
15839        // canonical idiom) round-trip through the gate. Pinned
15840        // separately from the leaf-`"main"` positive control so a
15841        // future tightening that rejects all multi-component refnames
15842        // surfaces here.
15843        let d = dep_with_fonte(DepSource::Git {
15844            repo: "github:pleme-io/caixa-teia".into(),
15845            tag: None,
15846            rev: None,
15847            branch: Some("feature/checkout-rewrite".into()),
15848        });
15849        d.validate().unwrap();
15850    }
15851
15852    #[test]
15853    fn validate_accepts_git_fonte_with_prerelease_tag() {
15854        // The positive-control pin: semver pre-release shape
15855        // (`v0.1.0-alpha.1`) — the in-component dot is allowed
15856        // (only consecutive `..` and trailing `.` are rejected), the
15857        // mid-component hyphen is allowed. Pinned separately from
15858        // the bare-`"v0.1.0"` positive control so a future tightening
15859        // that rejects pre-release tags surfaces here.
15860        let d = dep_with_fonte(DepSource::Git {
15861            repo: "github:pleme-io/caixa-teia".into(),
15862            tag: Some("v0.1.0-alpha.1".into()),
15863            rev: None,
15864            branch: None,
15865        });
15866        d.validate().unwrap();
15867    }
15868
15869    #[test]
15870    fn validate_rejects_git_fonte_with_rev_carrying_refname_unfriendly_value() {
15871        // The `:rev` axis is routed through `crate::render::is_git_oid`
15872        // (a SHA's character set is `[0-9a-f]`, not a refname's), so a
15873        // value with refname-shape punctuation (here, a `:` mid-string
15874        // — would be a refname violation under `is_git_ref_name` too)
15875        // is rejected at the OID-shape gate. The two predicates
15876        // partition the `:fonte` pin axes structurally: an `:rev` value
15877        // that's a valid refname (`:rev "main"`, `:rev "v0.1.0"`) is
15878        // *still* rejected here because every refname character outside
15879        // `[0-9a-f]` fails the OID gate. Same shape as
15880        // `fonte_pin_shape_diagnostic_carries_offending_nome_pin_value`
15881        // on the refname-shaped axes — the diagnostic names the
15882        // offending dep + pin + value verbatim. The flip-from-accept
15883        // case the prior `:tag`/`:branch` gate left as a "future axis"
15884        // (e70d213) — now landed.
15885        let d = dep_with_fonte(DepSource::Git {
15886            repo: "github:pleme-io/caixa-teia".into(),
15887            tag: None,
15888            rev: Some("c0ffee:notarefname".into()),
15889            branch: None,
15890        });
15891        let err = d.validate().unwrap_err();
15892        let DepError::FontePinShape {
15893            nome,
15894            pin,
15895            value,
15896            reason,
15897        } = err
15898        else {
15899            panic!("expected FontePinShape, got other variant");
15900        };
15901        assert_eq!(nome, "caixa-teia");
15902        assert_eq!(pin, ":rev");
15903        assert_eq!(value, "c0ffee:notarefname");
15904        assert!(
15905            !reason.is_empty(),
15906            "FontePinShape `reason` must carry the predicate's wording verbatim"
15907        );
15908    }
15909
15910    #[test]
15911    fn validate_accepts_git_fonte_with_rev_full_sha1() {
15912        // The positive-control pin on the SHA-1 OID width: exactly 40
15913        // lowercase hex characters — the canonical `git rev-parse HEAD`
15914        // emission on a SHA-1-hashed repository (the default on every
15915        // pre-2.42 git and the canonical pleme-io substrate hash).
15916        // Pinned separately from the SHA-256 positive control so a
15917        // future tightening that only admits one width surfaces here.
15918        let d = dep_with_fonte(DepSource::Git {
15919            repo: "github:pleme-io/caixa-teia".into(),
15920            tag: None,
15921            rev: Some("0123456789abcdef0123456789abcdef01234567".into()),
15922            branch: None,
15923        });
15924        d.validate().unwrap();
15925    }
15926
15927    #[test]
15928    fn validate_accepts_git_fonte_with_rev_full_sha256() {
15929        // The positive-control pin on the SHA-256 OID width: exactly
15930        // 64 lowercase hex characters — `git`'s
15931        // `extensions.objectFormat = sha256` emission (GA since Git
15932        // 2.42 / Oct 2023). The substrate admits either canonical
15933        // width so an `:rev` authored against a SHA-256-hashed
15934        // upstream round-trips through the gate without per-repo
15935        // configuration. Pinned separately from the SHA-1 positive
15936        // control so a future tightening that drops one width surfaces
15937        // here as a structural decision.
15938        let d = dep_with_fonte(DepSource::Git {
15939            repo: "github:pleme-io/caixa-teia".into(),
15940            tag: None,
15941            rev: Some("0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef".into()),
15942            branch: None,
15943        });
15944        d.validate().unwrap();
15945    }
15946
15947    #[test]
15948    fn validate_rejects_git_fonte_with_rev_abbreviated_prefix() {
15949        // The canonical `git log --short` / `git rev-parse --short HEAD`
15950        // paste-from-release-notes footgun: a 7-char prefix (git's
15951        // default `core.abbrev`) silently passes string emptiness
15952        // checks and resolves to one commit today, but becomes ambiguous
15953        // tomorrow as the repo grows. Until this gate landed the empty-
15954        // pin arm passed (the string isn't empty) and the resolver
15955        // accepted the prefix through git's separate prefix-lookup pass
15956        // — defeating the reproducibility contract `:rev` carries vs.
15957        // `:tag` / `:branch`. The new gate moves the check to caixa-
15958        // build time and names the offending dep + pin + value verbatim.
15959        let d = dep_with_fonte(DepSource::Git {
15960            repo: "github:pleme-io/caixa-teia".into(),
15961            tag: None,
15962            rev: Some("c0ffee0".into()),
15963            branch: None,
15964        });
15965        let err = d.validate().unwrap_err();
15966        let DepError::FontePinShape {
15967            pin, value, reason, ..
15968        } = err
15969        else {
15970            panic!("expected FontePinShape, got other variant");
15971        };
15972        assert_eq!(pin, ":rev");
15973        assert_eq!(value, "c0ffee0");
15974        assert!(
15975            reason.contains("abbreviated") || reason.contains("ambiguous"),
15976            "reason must surface the abbreviation arm, got {reason:?}"
15977        );
15978    }
15979
15980    #[test]
15981    fn validate_rejects_git_fonte_with_rev_uppercase_hex() {
15982        // The canonical "I pasted the SHA in uppercase" footgun: `git
15983        // porcelain` emits OIDs lowercase exclusively, so an uppercase-
15984        // bearing `:rev` round-trips inconsistently across the
15985        // resolver's `git fetch <remote> <:rev>` ↔ `git rev-parse HEAD`
15986        // equality-check pipeline and fails the lacre's content-
15987        // addressing probe with a confusing case-only diff. Pinned
15988        // separately from the non-hex arm so a future relaxation that
15989        // admits one but not the other surfaces here.
15990        let d = dep_with_fonte(DepSource::Git {
15991            repo: "github:pleme-io/caixa-teia".into(),
15992            tag: None,
15993            rev: Some("DEADBEEFCAFEBABE0123456789ABCDEF01234567".into()),
15994            branch: None,
15995        });
15996        let err = d.validate().unwrap_err();
15997        let DepError::FontePinShape {
15998            pin, value, reason, ..
15999        } = err
16000        else {
16001            panic!("expected FontePinShape, got other variant");
16002        };
16003        assert_eq!(pin, ":rev");
16004        assert_eq!(value, "DEADBEEFCAFEBABE0123456789ABCDEF01234567");
16005        assert!(
16006            reason.contains("uppercase"),
16007            "reason must surface the uppercase arm, got {reason:?}"
16008        );
16009    }
16010
16011    #[test]
16012    fn validate_rejects_git_fonte_with_rev_refname_value() {
16013        // The cross-axis mis-slot footgun: `:rev "main"` — the author
16014        // conflated `:rev` (hex commit ID, immutable) and `:branch`
16015        // (mutable ref pointing at whatever HEAD is today). Until this
16016        // gate landed the resolver silently dispatched on the value
16017        // shape ("`main` doesn't look like a SHA, fall back to
16018        // refname"), defeating the `:rev` reproducibility contract.
16019        // The new gate rejects every non-hex value on the `:rev` axis,
16020        // so the `:rev`/`:branch` boundary is structurally enforced —
16021        // a refname in the `:rev` slot is a build error, not a
16022        // resolver-time silent reinterpretation.
16023        let d = dep_with_fonte(DepSource::Git {
16024            repo: "github:pleme-io/caixa-teia".into(),
16025            tag: None,
16026            rev: Some("main".into()),
16027            branch: None,
16028        });
16029        let err = d.validate().unwrap_err();
16030        let DepError::FontePinShape {
16031            pin, value, reason, ..
16032        } = err
16033        else {
16034            panic!("expected FontePinShape, got other variant");
16035        };
16036        assert_eq!(pin, ":rev");
16037        assert_eq!(value, "main");
16038        // 4 chars `main` fails the length arm before the character arm,
16039        // so the diagnostic surfaces the abbreviation wording (same
16040        // path the `c0ffee0` 7-char fixture lands on); the structural
16041        // assertion is just that the `:rev "main"` value is rejected.
16042        assert!(
16043            !reason.is_empty(),
16044            "FontePinShape reason must be non-empty for refname-shaped :rev"
16045        );
16046    }
16047
16048    #[test]
16049    fn validate_rejects_git_fonte_with_rev_tag_shaped_value() {
16050        // Sibling cross-axis mis-slot: `:rev "v0.1.0"` — the author
16051        // conflated `:rev` and `:tag`. Pinned separately from the
16052        // `:rev "main"` (`:branch` mis-slot) arm so a future relaxation
16053        // that catches one but not the other surfaces here. The
16054        // length arm fires first (6 chars ≠ 40 ≠ 64); the structural
16055        // assertion is just that the cross-axis mis-slot is a build
16056        // error, regardless of which sub-arm surfaces the diagnostic
16057        // (`is_git_oid` rejects at the first violation; longer
16058        // tag-shape values would hit the non-hex arm instead).
16059        let d = dep_with_fonte(DepSource::Git {
16060            repo: "github:pleme-io/caixa-teia".into(),
16061            tag: None,
16062            rev: Some("v0.1.0".into()),
16063            branch: None,
16064        });
16065        let err = d.validate().unwrap_err();
16066        let DepError::FontePinShape {
16067            pin, value, reason, ..
16068        } = err
16069        else {
16070            panic!("expected FontePinShape, got other variant");
16071        };
16072        assert_eq!(pin, ":rev");
16073        assert_eq!(value, "v0.1.0");
16074        assert!(
16075            !reason.is_empty(),
16076            "FontePinShape reason must be non-empty for tag-shaped :rev"
16077        );
16078    }
16079
16080    #[test]
16081    fn validate_rejects_git_fonte_with_rev_too_long() {
16082        // Boundary case on the upper end: 41 hex chars — one past the
16083        // SHA-1 width, well below the SHA-256 width. Pin so a future
16084        // relaxation that admits "long enough to be a SHA" without
16085        // matching either canonical width surfaces here. The diagnostic
16086        // names the offending length verbatim so the author's grep
16087        // target is unambiguous (either trim one char or paste the
16088        // full SHA-256).
16089        let too_long: String = "0".repeat(41);
16090        let d = dep_with_fonte(DepSource::Git {
16091            repo: "github:pleme-io/caixa-teia".into(),
16092            tag: None,
16093            rev: Some(too_long.clone()),
16094            branch: None,
16095        });
16096        let err = d.validate().unwrap_err();
16097        let DepError::FontePinShape {
16098            pin, value, reason, ..
16099        } = err
16100        else {
16101            panic!("expected FontePinShape, got other variant");
16102        };
16103        assert_eq!(pin, ":rev");
16104        assert_eq!(value, too_long);
16105        assert!(
16106            reason.contains("41"),
16107            "reason must surface the offending length verbatim, got {reason:?}"
16108        );
16109    }
16110
16111    #[test]
16112    fn validate_rejects_git_fonte_with_rev_carrying_whitespace() {
16113        // The canonical paste-from-doc footgun on `:rev` — author
16114        // copies `"deadbeefcafe…0123 "` (trailing space) out of a
16115        // commit-message paragraph. Until this gate landed the empty-
16116        // pin arm passed (the string isn't empty), the resolver issued
16117        // `git fetch <remote> 'deadbeef… '` and the failure surfaced at
16118        // clone time with a quoting-confused git error far from the
16119        // source caixa.lisp. The new gate moves the check to caixa-
16120        // build time. Length is 41 (40 hex + space) so the length arm
16121        // fires first — pinned separately from the pure-length arm to
16122        // ensure the diagnostic surfaces *some* parser wording, not
16123        // silently pass through.
16124        let with_space = "0123456789abcdef0123456789abcdef01234567 ".to_string();
16125        let d = dep_with_fonte(DepSource::Git {
16126            repo: "github:pleme-io/caixa-teia".into(),
16127            tag: None,
16128            rev: Some(with_space.clone()),
16129            branch: None,
16130        });
16131        let err = d.validate().unwrap_err();
16132        let DepError::FontePinShape {
16133            pin, value, reason, ..
16134        } = err
16135        else {
16136            panic!("expected FontePinShape, got other variant");
16137        };
16138        assert_eq!(pin, ":rev");
16139        assert_eq!(value, with_space);
16140        assert!(
16141            !reason.is_empty(),
16142            "FontePinShape reason must be non-empty for whitespace-bearing :rev"
16143        );
16144    }
16145
16146    #[test]
16147    fn fonte_pin_shape_diagnostic_carries_offending_nome_pin_value_for_rev() {
16148        // Diagnostic-shape pin on the `:rev` axis: every FontePinShape
16149        // variant on this axis names the offending dep's `:nome` + the
16150        // `:rev` axis + the offending value verbatim, so the author's
16151        // grep target is the literal `:rev "<value>"` block in
16152        // caixa.lisp. Sibling of the `fonte_pin_shape_diagnostic_
16153        // carries_offending_nome_pin_value` test on the refname-shaped
16154        // (`:tag` / `:branch`) axes.
16155        let d = dep_with_fonte(DepSource::Git {
16156            repo: "github:p/x".into(),
16157            tag: None,
16158            rev: Some("not-a-sha".into()),
16159            branch: None,
16160        });
16161        let msg = d
16162            .validate()
16163            .expect_err(":rev: expected FontePinShape")
16164            .to_string();
16165        assert!(
16166            msg.contains("\"caixa-teia\""),
16167            ":rev: diagnostic must quote the offending :nome verbatim, got {msg:?}"
16168        );
16169        assert!(
16170            msg.contains(":rev"),
16171            ":rev: diagnostic must name the offending pin axis, got {msg:?}"
16172        );
16173        assert!(
16174            msg.contains("not-a-sha"),
16175            ":rev: diagnostic must quote the offending value verbatim, got {msg:?}"
16176        );
16177    }
16178
16179    #[test]
16180    fn fonte_pin_empty_fires_before_pin_shape() {
16181        // Order pin: a `Some("")` `:tag` is the more self-locating
16182        // diagnostic (the author chose an axis but left it blank;
16183        // grep is unambiguous), so it fires before the shape gate
16184        // even when both arms would match. Pinned so a future
16185        // reordering surfaces here. Mirrors the
16186        // `fonte_repo_empty_fires_before_pin_missing` ordering
16187        // discipline on the peer per-axis arms.
16188        let d = dep_with_fonte(DepSource::Git {
16189            repo: "github:pleme-io/caixa-teia".into(),
16190            tag: Some(String::new()),
16191            rev: None,
16192            branch: None,
16193        });
16194        assert!(matches!(
16195            d.validate().unwrap_err(),
16196            DepError::FontePinEmpty { ref pin, .. } if pin == ":tag"
16197        ));
16198    }
16199
16200    #[test]
16201    fn fonte_pin_shape_fires_after_repo_empty() {
16202        // Order pin: `:repo ""` is the more self-locating axis
16203        // (every git source needs a repo; the per-pin shape gate is
16204        // secondary), so the repo-empty arm fires before the
16205        // per-pin shape arm even when both are violated. Pinned so
16206        // a future reordering surfaces here. Mirrors
16207        // `fonte_repo_empty_fires_before_pin_missing` on the
16208        // adjacent axis pair.
16209        let d = dep_with_fonte(DepSource::Git {
16210            repo: String::new(),
16211            tag: Some("v0.1.0 ".into()),
16212            rev: None,
16213            branch: None,
16214        });
16215        assert!(matches!(
16216            d.validate().unwrap_err(),
16217            DepError::FonteRepoEmpty { .. }
16218        ));
16219    }
16220
16221    #[test]
16222    fn fonte_pin_shape_diagnostic_carries_offending_nome_pin_value() {
16223        // Diagnostic-shape pin across both refname-shaped axes
16224        // (`:tag` + `:branch`): every `FontePinShape` variant names
16225        // the offending dep's `:nome` + the offending pin axis + the
16226        // offending value verbatim, so the author's grep target is
16227        // unambiguous (the literal `:tag "<value>"` / `:branch
16228        // "<value>"` lands in caixa.lisp with quotes). Cover both
16229        // pin axes so a future variant addition forces a parallel
16230        // diagnostic-shape decision.
16231        for (pin_label, fonte) in [
16232            (
16233                ":tag",
16234                DepSource::Git {
16235                    repo: "github:p/x".into(),
16236                    tag: Some("v0.1.0~1".into()),
16237                    rev: None,
16238                    branch: None,
16239                },
16240            ),
16241            (
16242                ":branch",
16243                DepSource::Git {
16244                    repo: "github:p/x".into(),
16245                    tag: None,
16246                    rev: None,
16247                    branch: Some("feature/foo*".into()),
16248                },
16249            ),
16250        ] {
16251            let d = dep_with_fonte(fonte);
16252            let msg = d
16253                .validate()
16254                .expect_err(&format!("{pin_label}: expected FontePinShape"))
16255                .to_string();
16256            assert!(
16257                msg.contains("\"caixa-teia\""),
16258                "{pin_label}: diagnostic must quote the offending :nome verbatim, got {msg:?}"
16259            );
16260            assert!(
16261                msg.contains(pin_label),
16262                "{pin_label}: diagnostic must name the offending pin axis, got {msg:?}"
16263            );
16264        }
16265    }
16266
16267    #[test]
16268    fn git_source_json_round_trip() {
16269        let src = DepSource::Git {
16270            repo: "github:pleme-io/caixa-teia".into(),
16271            tag: Some("v0.1.0".into()),
16272            rev: None,
16273            branch: None,
16274        };
16275        let s = serde_json::to_string(&src).unwrap();
16276        assert!(s.contains(&format!(
16277            r#""{tipo}":"{git}""#,
16278            tipo = crate::render::DEP_SOURCE_KEY_TIPO,
16279            git = crate::render::DEP_SOURCE_TIPO_GIT,
16280        )));
16281        assert!(s.contains(r#""repo":"github:pleme-io/caixa-teia""#));
16282        assert!(s.contains(r#""tag":"v0.1.0""#));
16283        assert!(!s.contains("rev"));
16284        assert!(!s.contains("branch"));
16285        let round: DepSource = serde_json::from_str(&s).unwrap();
16286        assert_eq!(round, src);
16287    }
16288
16289    // ── DEP_SOURCE_{KEY_TIPO,TIPO_GIT,TIPO_PATH} drift-detection ────────
16290    //
16291    // The `#[serde(tag = "tipo", rename_all = "lowercase")]` derive
16292    // attribute on [`DepSource`] pins three load-bearing byte-sequences
16293    // that flow into every serialized `Dep.fonte` block: the outer
16294    // discriminator-key `"tipo"` the `tag = "tipo"` attribute names, and
16295    // the two admitted variant-tag values `"git"` / `"path"` the
16296    // `rename_all = "lowercase"` attribute pins as the discriminator's
16297    // closed-set arms. The three pin tests below round-trip a
16298    // fully-populated variant of each arm through
16299    // [`serde_json::to_value`] and assert each canonical byte-sequence
16300    // appears at its axis — pins a hypothetical future
16301    // `tag = "type"` / `tag = "source_type"` typo, a `rename_all`
16302    // rebrand (`"UPPERCASE"` / `"snake_case"` / `"kebab-case"`), or a
16303    // Rust-side variant rename (`Git` → `Repository`, `Path` → `Local`)
16304    // at build time rather than at fetch time when the resolver's
16305    // `Dep.fonte` dispatch silently fails to match on the drifted
16306    // discriminator. Same "serialize-and-check" discipline the peer
16307    // `M2_LIMITS_KEY_*`, `M2_BEHAVIOR_KEY_ON_*`, `SUPERVISOR_KEY_*`,
16308    // and `MEMBRO_KEY_*` drift-detection pins carry — extended here
16309    // to the last `#[serde(tag = ..., rename_all = ...)]` discriminator
16310    // family in caixa-core lacking a lifted peer.
16311
16312    #[test]
16313    fn dep_source_git_serde_keys_match_lifted_dep_source_key_consts() {
16314        // Fail-before-pass-after: a future `tag = "type"` at the derive
16315        // attribute would serialize under `"type":"git"`, and this test
16316        // would trip because `"tipo"` no longer appears at the emitted
16317        // discriminator key. A future `rename_all = "kebab-case"` /
16318        // `"snake_case"` (both no-ops on `Git` since it lacks internal
16319        // word boundaries) is caught by the sibling
16320        // `dep_source_path_serde_keys_match_lifted_dep_source_key_consts`
16321        // pin below (Path has no internal boundary either but the pair
16322        // catches any per-arm inconsistency). A future variant rename
16323        // `Git` → `Repository` would emit `"tipo":"repository"` and
16324        // trip this pin.
16325        let src = DepSource::Git {
16326            repo: "github:pleme-io/caixa-teia".into(),
16327            tag: Some("v0.1.0".into()),
16328            rev: None,
16329            branch: None,
16330        };
16331        let json = serde_json::to_value(&src).unwrap();
16332        let obj = json.as_object().expect("Git serializes as a JSON object");
16333        assert_eq!(
16334            obj.get(crate::render::DEP_SOURCE_KEY_TIPO)
16335                .and_then(serde_json::Value::as_str),
16336            Some(crate::render::DEP_SOURCE_TIPO_GIT),
16337            "DepSource::Git must serialize the tipo discriminator at DEP_SOURCE_KEY_TIPO \
16338             with value DEP_SOURCE_TIPO_GIT — attribute drift or variant rename \
16339             detected in {json}"
16340        );
16341    }
16342
16343    #[test]
16344    fn dep_source_path_serde_keys_match_lifted_dep_source_key_consts() {
16345        // Fail-before-pass-after: a future variant rename `Path` →
16346        // `Local` / `Filesystem` would emit `"tipo":"local"` and trip
16347        // this pin. A per-consumer disambiguation as the `defcaixa`
16348        // macro stabilizes ("caminho" → "path" for English-uniformity)
16349        // is scoped to the inner field key, not the discriminator; this
16350        // pin is orthogonal to that and catches only the outer
16351        // discriminator drift.
16352        let src = DepSource::Path {
16353            caminho: "../caixa-teia".into(),
16354        };
16355        let json = serde_json::to_value(&src).unwrap();
16356        let obj = json.as_object().expect("Path serializes as a JSON object");
16357        assert_eq!(
16358            obj.get(crate::render::DEP_SOURCE_KEY_TIPO)
16359                .and_then(serde_json::Value::as_str),
16360            Some(crate::render::DEP_SOURCE_TIPO_PATH),
16361            "DepSource::Path must serialize the tipo discriminator at DEP_SOURCE_KEY_TIPO \
16362             with value DEP_SOURCE_TIPO_PATH — attribute drift or variant rename \
16363             detected in {json}"
16364        );
16365    }
16366
16367    #[test]
16368    fn dep_source_key_consts_are_pairwise_distinct() {
16369        // Cross-axis collapse detector: a hypothetical future edit that
16370        // accidentally set two of the three consts to the same byte
16371        // (`DEP_SOURCE_TIPO_GIT = "path"` typo matching a peer arm) would
16372        // pass every per-arm serialize pin above but silently collapse
16373        // the discriminator's closed-set arms onto one another; this pin
16374        // catches the collapse at build time.
16375        assert_ne!(
16376            crate::render::DEP_SOURCE_KEY_TIPO,
16377            crate::render::DEP_SOURCE_TIPO_GIT,
16378        );
16379        assert_ne!(
16380            crate::render::DEP_SOURCE_KEY_TIPO,
16381            crate::render::DEP_SOURCE_TIPO_PATH,
16382        );
16383        assert_ne!(
16384            crate::render::DEP_SOURCE_TIPO_GIT,
16385            crate::render::DEP_SOURCE_TIPO_PATH,
16386        );
16387    }
16388
16389    #[test]
16390    fn dep_source_tipo_variant_consts_are_ascii_lowercase_shape() {
16391        // Shape pin against `rename_all` drift: the two variant-tag
16392        // consts must be ASCII-lowercase-only to match the
16393        // `rename_all = "lowercase"` attribute the derive uses; a future
16394        // rebrand to `"UPPERCASE"` / `"PascalCase"` at the attribute
16395        // would emit `"GIT"` / `"Git"` instead and trip this pin.
16396        for (label, s) in [
16397            ("DEP_SOURCE_TIPO_GIT", crate::render::DEP_SOURCE_TIPO_GIT),
16398            ("DEP_SOURCE_TIPO_PATH", crate::render::DEP_SOURCE_TIPO_PATH),
16399        ] {
16400            assert!(!s.is_empty(), "{label} must not be empty");
16401            assert!(
16402                s.bytes().all(|b| b.is_ascii_lowercase()),
16403                "{label} must be ASCII-lowercase-only (matching \
16404                 rename_all = \"lowercase\"), got {s:?}",
16405            );
16406        }
16407    }
16408
16409    // ── per-entry :caracteristicas set-not-multiset gate ────────────
16410    //
16411    // Every Vec-keyed-by-name authoring surface on the typed Caixa
16412    // surface that identifies its entries by a name field now uniformly
16413    // closes the set-not-multiset discipline at build time (cite
16414    // `validate_caracteristicas`'s peer-axis enumeration). The
16415    // `:caracteristicas` axis is per-`Dep`: the feature-toggle slot is
16416    // set-shaped (a feature is either enabled or not — there is no
16417    // `feature × 2` semantic), so two entries naming the same feature
16418    // are a redundant declaration the caixa-resolver's lacre pipeline
16419    // would silently dedup at resolve time. The empty-feature arm
16420    // closes the parallel "operationally-meaningless value" axis on
16421    // the same slot. Same linear-walk + `HashSet` + first-collision
16422    // shape every peer set gate uses; same empty-first cascade every
16423    // peer per-entry shape + duplicate gate uses (the empty-feature
16424    // axis is the more-actionable defect since two `""` entries would
16425    // both report `caracteristica: ""` under a duplicate-first
16426    // ordering, with no way to distinguish the offending site).
16427
16428    fn dep_with_features(features: &[&str]) -> Dep {
16429        Dep {
16430            nome: "caixa-teia".into(),
16431            versao: "^0.1".into(),
16432            fonte: None,
16433            opcional: false,
16434            caracteristicas: features.iter().map(|s| (*s).into()).collect(),
16435        }
16436    }
16437
16438    #[test]
16439    fn validate_rejects_empty_caracteristica() {
16440        // Fail-before-pass-after pin: every pre-gate codebase accepted
16441        // `(:caracteristicas (""))` cleanly (the `Vec<String>` field
16442        // imposed no per-entry shape contract), the dep validated, and
16443        // the empty feature would have reached the future caixa-resolver
16444        // lacre pipeline as a no-op feature enable — silently dropping
16445        // the author's intent far from the source `caixa.lisp`. The new
16446        // gate surfaces the structural defect at the typed-validate
16447        // surface with a self-locating diagnostic naming the offending
16448        // dep's `:nome`.
16449        let d = dep_with_features(&[""]);
16450        assert!(
16451            matches!(d.validate().unwrap_err(), DepError::CaracteristicaEmpty { ref nome } if nome == "caixa-teia"),
16452            "expected CaracteristicaEmpty, got {:?}",
16453            d.validate(),
16454        );
16455    }
16456
16457    #[test]
16458    fn validate_rejects_duplicate_caracteristica() {
16459        // Fail-before-pass-after pin on the set-not-multiset arm: the
16460        // feature-toggle slot is set-shaped, so `(:caracteristicas
16461        // ("http" "http"))` is a redundant declaration the lacre
16462        // pipeline dedupes silently at resolve time. The diagnostic
16463        // names the offending dep + the colliding feature verbatim so
16464        // the author can grep their caixa.lisp for `:caracteristicas`
16465        // and fix it in one edit. First-collision determinism is
16466        // pinned separately below.
16467        let d = dep_with_features(&["http", "http"]);
16468        assert!(
16469            matches!(
16470                d.validate().unwrap_err(),
16471                DepError::CaracteristicaDuplicate { ref nome, ref caracteristica }
16472                    if nome == "caixa-teia" && caracteristica == "http"
16473            ),
16474            "expected CaracteristicaDuplicate, got {:?}",
16475            d.validate(),
16476        );
16477    }
16478
16479    #[test]
16480    fn validate_accepts_distinct_caracteristicas() {
16481        // The canonical authoring shape — every feature distinct — must
16482        // remain a clean pass (positive control sweep). Covers the
16483        // canonical kebab-case feature names a target caixa typically
16484        // declares.
16485        dep_with_features(&["http", "json", "tls"])
16486            .validate()
16487            .unwrap();
16488    }
16489
16490    #[test]
16491    fn validate_accepts_single_caracteristica() {
16492        // Single-element list is the minimum non-empty shape; passes
16493        // the gate as the identity of the duplicate check (no second
16494        // entry to collide with).
16495        dep_with_features(&["http"]).validate().unwrap();
16496    }
16497
16498    #[test]
16499    fn validate_accepts_empty_caracteristicas_list() {
16500        // The bare-dep authoring shape (`Dep::simple` / `Dep::git`)
16501        // produces `caracteristicas: Vec::new()`; the empty list is
16502        // the gate's empty-set identity and passes vacuously. Pin
16503        // this so a future tightening that requires ≥1 feature
16504        // surfaces here as a test failure rather than a silent
16505        // contract narrowing.
16506        Dep::simple("caixa-teia", "^0.1").validate().unwrap();
16507        assert!(dep_with_features(&[]).validate().is_ok());
16508    }
16509
16510    #[test]
16511    fn validate_caracteristica_empty_fires_before_duplicate() {
16512        // Empty-first cascade: an entry with an empty feature *and*
16513        // duplicate entries surfaces the empty diagnostic first. The
16514        // empty-feature axis is the more-actionable defect since
16515        // `caracteristica: ""` is unambiguous; under duplicate-first
16516        // ordering the diagnostic could report the empty string from
16517        // either of two empty entries with no way to distinguish.
16518        // Mirrors the peer empty-before-duplicate ordering
16519        // discipline every per-entry shape + duplicate gate establishes
16520        // (`SupervisorSpec::validate`'s `EmptyChildName` arm before
16521        // `DuplicateChildCaixa`, `validate_membros`'s
16522        // `MembroCaixaEmpty` arm before `MembroDuplicate`).
16523        let d = dep_with_features(&["", "http", "http"]);
16524        assert!(matches!(
16525            d.validate().unwrap_err(),
16526            DepError::CaracteristicaEmpty { .. }
16527        ));
16528    }
16529
16530    #[test]
16531    fn validate_caracteristica_duplicate_first_collision_determinism() {
16532        // Three matching entries: the second occurrence surfaces the
16533        // diagnostic (the second is the first *collision* — the first
16534        // entry is the establishing one, not a duplicate). Mirrors
16535        // every peer first-collision posture
16536        // (`SupervisorError::DuplicateChildCaixa` reports the second
16537        // collision, `AplicacaoError::MembroDuplicate` reports the
16538        // second, `DepError::DuplicateNome` reports the second).
16539        // Pinning this so a future shortcut that flips to last-
16540        // collision (or non-deterministic) surfaces here.
16541        let d = dep_with_features(&["http", "http", "http"]);
16542        assert!(matches!(
16543            d.validate().unwrap_err(),
16544            DepError::CaracteristicaDuplicate { ref caracteristica, .. } if caracteristica == "http"
16545        ));
16546    }
16547
16548    #[test]
16549    fn validate_per_entry_shape_fires_before_caracteristicas() {
16550        // Per-entry shape precedence: a dep with a malformed `:nome`
16551        // (uppercase) AND duplicate `:caracteristicas` surfaces the
16552        // narrower `NomeInvalid` diagnostic first, not the set-gate
16553        // diagnostic. The `:nome` is the self-locating axis (every
16554        // diagnostic from the caracteristicas gate quotes the
16555        // offending dep's `:nome` to anchor the grep target —
16556        // surfacing the malformed name first keeps that anchor
16557        // valid). Same precedence shape every peer per-entry-shape
16558        // arm establishes against its peer set-gate
16559        // (`validate_deps_per_entry_validate_fires_before_duplicate_in_deps`
16560        // on the cross-entry `:nome` axis).
16561        let d = Dep {
16562            nome: "Caixa-Teia".into(), // uppercase — DNS-1123 violation
16563            versao: "^0.1".into(),
16564            fonte: None,
16565            opcional: false,
16566            caracteristicas: vec!["http".into(), "http".into()],
16567        };
16568        assert!(matches!(
16569            d.validate().unwrap_err(),
16570            DepError::NomeInvalid { .. }
16571        ));
16572    }
16573
16574    // ── per-entry :caracteristicas value-shape gate ──────────────────
16575    //
16576    // Until this gate landed `:caracteristicas` only refused the empty
16577    // string and cross-entry duplicates: a non-empty distinct but
16578    // structurally invalid feature name silently passed validate and the
16579    // failure surfaced at `cargo metadata` time as Cargo's
16580    // `restricted_names::validate_feature_name` parser rejection, far from
16581    // the source `caixa.lisp` with no field naming which `:deps` entry's
16582    // `:caracteristicas` carried the typo. The lifted predicate makes the
16583    // Cargo-feature-name-grammar intersection-floor a substrate-level
16584    // invariant at validate time. Same trajectory as the eight peer
16585    // value-shape predicates each typed surface downstream of a structured
16586    // grammar already follows.
16587
16588    #[test]
16589    fn validate_rejects_caracteristica_with_leading_plus() {
16590        // Fail-before-pass-after pin on the canonical Cargo
16591        // `+<feature>` activation-form-in-feature-name-slot footgun.
16592        // Cargo's `[dependencies.<dep>.features]` list grammar accepts
16593        // `+optional-feature` as an enablement of a previously-disabled
16594        // feature; pasting that activation form into `:caracteristicas`
16595        // (which names the feature itself) silently passed pre-gate and
16596        // failed at `cargo metadata` parse time.
16597        let d = dep_with_features(&["+http"]);
16598        let err = d.validate().unwrap_err();
16599        assert!(
16600            matches!(
16601                err,
16602                DepError::CaracteristicaInvalid { ref nome, ref caracteristica, .. }
16603                    if nome == "caixa-teia" && caracteristica == "+http"
16604            ),
16605            "expected CaracteristicaInvalid, got {err:?}"
16606        );
16607    }
16608
16609    #[test]
16610    fn validate_rejects_caracteristica_with_leading_hyphen() {
16611        // Fail-before-pass-after pin on the leading-hyphen footgun. `-`
16612        // is a legitimate continuation character (kebab-case feature
16613        // names like `runtime-tokio` pass) but Cargo rejects it at the
16614        // start; the structural defect — and its CLI-argument-injection
16615        // adjacency at any downstream Cargo subprocess invocation — is
16616        // closed at validate time, not at `cargo metadata` time.
16617        let d = dep_with_features(&["-json"]);
16618        let err = d.validate().unwrap_err();
16619        assert!(
16620            matches!(
16621                err,
16622                DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "-json"
16623            ),
16624            "expected CaracteristicaInvalid, got {err:?}"
16625        );
16626    }
16627
16628    #[test]
16629    fn validate_rejects_caracteristica_with_leading_dot() {
16630        // Fail-before-pass-after pin on the leading-dot footgun. `.` is
16631        // a legitimate continuation character (version-suffix shapes
16632        // like `feat.v2` pass) but the leading-dot form is the
16633        // canonical dotted-version-suffix-as-feature-name confusion.
16634        let d = dep_with_features(&[".feat"]);
16635        let err = d.validate().unwrap_err();
16636        assert!(matches!(
16637            err,
16638            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == ".feat"
16639        ));
16640    }
16641
16642    #[test]
16643    fn validate_rejects_caracteristica_with_whitespace() {
16644        // Fail-before-pass-after pin on the embedded-whitespace footgun:
16645        // a feature name with a space inside is structurally a multi-
16646        // token blob (the canonical paste-from-doc footgun, or an
16647        // accidental `"http server"` where the author meant
16648        // `"http-server"`).
16649        let d = dep_with_features(&["http feature"]);
16650        let err = d.validate().unwrap_err();
16651        assert!(matches!(
16652            err,
16653            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http feature"
16654        ));
16655    }
16656
16657    #[test]
16658    fn validate_rejects_caracteristica_with_comma() {
16659        // Fail-before-pass-after pin on the embedded-comma footgun:
16660        // the list-separator-belongs-to-the-list-grammar
16661        // miscomprehension where the author writes
16662        // `:caracteristicas ("http,json")` intending two features but
16663        // the `Vec<String>` field consumes the bare token as one entry.
16664        let d = dep_with_features(&["http,json"]);
16665        let err = d.validate().unwrap_err();
16666        assert!(matches!(
16667            err,
16668            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http,json"
16669        ));
16670    }
16671
16672    #[test]
16673    fn validate_rejects_caracteristica_with_slash() {
16674        // Fail-before-pass-after pin on the embedded-slash footgun:
16675        // Cargo's `dep/feat` namespaced-dep syntax applies inside
16676        // `[dependencies.<dep>.features]` list entries that already
16677        // name the parent dep (so the syntax says "enable feature
16678        // `feat` on a transitive dep `dep`"); `:caracteristicas` is
16679        // per-dep already (a sibling slot on the `Dep` itself), so the
16680        // segment separator within an entry must be `-`, `_`, `+`,
16681        // or `.`. The diagnostic remediation points at the canonical
16682        // Cargo namespaced-dep discipline.
16683        let d = dep_with_features(&["http/json"]);
16684        let err = d.validate().unwrap_err();
16685        assert!(matches!(
16686            err,
16687            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http/json"
16688        ));
16689    }
16690
16691    #[test]
16692    fn validate_rejects_caracteristica_with_non_ascii() {
16693        // Fail-before-pass-after pin on the un-percent-encoded non-ASCII
16694        // byte footgun: NFC-vs-NFD normalization across filesystems
16695        // silently rewrites the feature-key, breaking the lacre's
16696        // content-addressing invariant. Pinned at a canonical
16697        // smart-quote-paste shape (`café`) where the raw `é` byte is the
16698        // documented APFS round-trip break.
16699        let d = dep_with_features(&["caf\u{e9}"]);
16700        let err = d.validate().unwrap_err();
16701        assert!(matches!(
16702            err,
16703            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "caf\u{e9}"
16704        ));
16705    }
16706
16707    #[test]
16708    fn validate_rejects_caracteristica_with_control_character() {
16709        // Fail-before-pass-after pin on the embedded-control-character
16710        // footgun: a CR/LF or any 0x00..0x1F / 0x7F byte landing in a
16711        // feature name is the canonical paste-from-multiline-doc
16712        // footgun the predicate's reason wording specifically calls out.
16713        let d = dep_with_features(&["http\njson"]);
16714        let err = d.validate().unwrap_err();
16715        assert!(matches!(err, DepError::CaracteristicaInvalid { .. }));
16716    }
16717
16718    #[test]
16719    fn validate_accepts_canonical_caracteristicas_shapes() {
16720        // Positive control sweep: every canonical Cargo feature name
16721        // shape the pleme-io ecosystem uses must still pass. Mirrors
16722        // the substrate-side `cargo_feature_name_accepts_canonical_forms`
16723        // sweep — drift between either landing site and the predicate's
16724        // accepted set is a build error visible at this pair of tests,
16725        // not a per-renderer "this passed validate but failed at
16726        // cargo metadata time" surprise on the next acceptance.
16727        for s in [
16728            "http",
16729            "json",
16730            "derive",
16731            "serde_json",
16732            "runtime-tokio",
16733            "tokio.full",
16734            "v0.1",
16735            "http+json",
16736            "_internal",
16737            "__private",
16738            "default",
16739            "rt-multi-thread",
16740            "feat.v2",
16741        ] {
16742            let d = dep_with_features(&[s]);
16743            d.validate().unwrap_or_else(|e| {
16744                panic!("canonical Cargo feature name {s:?} must pass validate: {e:?}")
16745            });
16746        }
16747    }
16748
16749    #[test]
16750    fn validate_caracteristica_empty_fires_before_invalid() {
16751        // Cascade precedence pin: an entry list with both an empty
16752        // feature AND an invalid-shape feature surfaces the
16753        // `CaracteristicaEmpty` arm first (the empty value carries no
16754        // self-locating data — `caracteristica: ""` is the diagnostic
16755        // with no way to anchor a grep target — so closing the empty
16756        // axis first preserves the per-entry-shape diagnostic's
16757        // self-locating discipline). Same empty-first cascade every
16758        // peer per-entry shape gate establishes
16759        // (`SupervisorSpec::validate`'s `EmptyChildName` before
16760        // `ChildCaixaInvalid`, `validate_membros`'s `MembroCaixaEmpty`
16761        // before `MembroCaixaInvalid`).
16762        let d = dep_with_features(&["", "+http"]);
16763        assert!(matches!(
16764            d.validate().unwrap_err(),
16765            DepError::CaracteristicaEmpty { .. }
16766        ));
16767    }
16768
16769    #[test]
16770    fn validate_caracteristica_invalid_fires_before_duplicate() {
16771        // Per-entry-shape precedence pin: an entry list with the same
16772        // invalid feature shape declared twice surfaces the
16773        // `CaracteristicaInvalid` diagnostic on the first entry, not
16774        // the `CaracteristicaDuplicate` on the second collision. The
16775        // per-entry shape gate fires before the cross-entry set gate
16776        // — same precedence shape every peer two-arm-plus-set gate
16777        // establishes (`SupervisorSpec::validate`'s
16778        // `ChildCaixaInvalid` before `DuplicateChildCaixa`,
16779        // `validate_membros`'s `MembroCaixaInvalid` before
16780        // `MembroDuplicate`, `Dep::validate`'s `NomeInvalid` before
16781        // cross-list `DuplicateNome`).
16782        let d = dep_with_features(&["+http", "+http"]);
16783        assert!(matches!(
16784            d.validate().unwrap_err(),
16785            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "+http"
16786        ));
16787    }
16788
16789    #[test]
16790    fn validate_rejects_caracteristica_at_65_byte_boundary() {
16791        // Boundary pin on the 64-byte cap — both the boundary-accepting
16792        // case and the boundary-exceeding case in one place, so a
16793        // future cap shift surfaces both arms simultaneously, mirroring
16794        // the peer `cargo_feature_name_rejects_at_65_byte_boundary`
16795        // predicate-level pin at the dep-axis landing site.
16796        let max_ok = "a".repeat(64);
16797        dep_with_features(&[&max_ok])
16798            .validate()
16799            .unwrap_or_else(|e| panic!("64-byte feature name must pass: {e:?}"));
16800        let too_long = "a".repeat(65);
16801        let d = dep_with_features(&[&too_long]);
16802        assert!(matches!(
16803            d.validate().unwrap_err(),
16804            DepError::CaracteristicaInvalid { .. }
16805        ));
16806    }
16807
16808    // ── self-dep cross-slot gate ─────────────────────────────────────
16809
16810    #[test]
16811    fn validate_no_self_dep_rejects_self_in_deps() {
16812        // A caixa whose `:deps` lists its own `:nome` is a one-node
16813        // cycle in the lacre closure's dep-graph traversal — rejected,
16814        // naming the parent and the offending list tag.
16815        let deps = vec![
16816            Dep::simple("caixa-teia", "^0.1"),
16817            Dep::simple("orquestra", "^0.1"),
16818        ];
16819        let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
16820        assert!(
16821            matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS),
16822            "got {err:?}"
16823        );
16824    }
16825
16826    #[test]
16827    fn validate_no_self_dep_rejects_self_in_deps_dev() {
16828        // Same gate on the `:deps-dev` axis — neither dep list is a
16829        // second-class citizen on the self-edge invariant.
16830        let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
16831        let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
16832        assert!(
16833            matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
16834            "got {err:?}"
16835        );
16836    }
16837
16838    #[test]
16839    fn validate_no_self_dep_deps_fires_before_deps_dev() {
16840        // Walk order pin: a caixa that self-references on both lists
16841        // surfaces the `:deps` arm first — the load-bearing axis the
16842        // lacre closure resolves at every build. Mirrors the canonical
16843        // [`Caixa::validate_deps`] cascade (`:deps` → `:deps-dev`).
16844        let deps = vec![Dep::simple("orquestra", "^0.1")];
16845        let deps_dev = vec![Dep::simple("orquestra", "^0.2")];
16846        let err = validate_no_self_dep(&deps, &deps_dev, "orquestra").unwrap_err();
16847        assert!(
16848            matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS),
16849            "got {err:?}"
16850        );
16851    }
16852
16853    #[test]
16854    fn validate_no_self_dep_accepts_distinct_names() {
16855        // Positive control: every dep names a distinct caixa. The
16856        // canonical author surface — peer of
16857        // [`validate_no_self_supervision_accepts_distinct_children`].
16858        let deps = vec![
16859            Dep::simple("caixa-teia", "^0.1"),
16860            Dep::simple("caixa-arch", "^0.1"),
16861        ];
16862        let deps_dev = vec![Dep::simple("caixa-test", "^0.1")];
16863        validate_no_self_dep(&deps, &deps_dev, "orquestra").unwrap();
16864    }
16865
16866    #[test]
16867    fn validate_no_self_dep_empty_lists_pass() {
16868        // A caixa with no declared deps has nothing to self-reference —
16869        // the gate is vacuously satisfied. Peer of
16870        // [`validate_no_self_supervision_empty_children_is_ok`].
16871        validate_no_self_dep(&[], &[], "orquestra").unwrap();
16872    }
16873
16874    #[test]
16875    fn validate_no_self_dep_diagnostic_carries_offending_list_and_nome() {
16876        // Diagnostic-shape pin (peer with
16877        // [`validate_no_self_supervision`]'s diagnostic): the error's
16878        // Display surfaces both the offending list tag and the
16879        // parent's `:nome` verbatim, so the author can grep their
16880        // caixa.lisp for the offending block in one edit. Names
16881        // `:bibliotecas` / `:exe` / `:servicos` as the corrective
16882        // surface — every legitimate "I want to use code from this
16883        // caixa" intent routes through one of those three slots.
16884        let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
16885        let rendered = validate_no_self_dep(&[], &deps_dev, "orquestra")
16886            .unwrap_err()
16887            .to_string();
16888        assert!(
16889            rendered.contains(crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
16890            "diagnostic must name the offending list tag: {rendered}",
16891        );
16892        assert!(
16893            rendered.contains("orquestra"),
16894            "diagnostic must quote the parent caixa name: {rendered}",
16895        );
16896        assert!(
16897            rendered.contains(":bibliotecas"),
16898            "diagnostic must point at the corrective code-surface slot: {rendered}",
16899        );
16900    }
16901
16902    #[test]
16903    fn validate_no_self_dep_accepts_coincidental_substring_match() {
16904        // Identity is exact-string equality, not substring — a dep
16905        // named `"orquestra-helper"` is a distinct caixa even when the
16906        // parent is `"orquestra"`. Pin the exact-match discipline so a
16907        // future relaxation that uses `contains` surfaces here, peer
16908        // with the supervision-tree and Aplicacao-membership gates
16909        // which all use exact-string equality on the typed identity.
16910        let deps = vec![Dep::simple("orquestra-helper", "^0.1")];
16911        validate_no_self_dep(&deps, &[], "orquestra").unwrap();
16912    }
16913
16914    // ── drift-detection: DEP_AUTHOR_KEY_{DEPS,DEPS_DEV} pin ─────────────
16915
16916    #[test]
16917    fn dep_author_key_consts_pin_canonical_kebab_case_labels() {
16918        // Scalar-value pin: the two author-facing kebab-case labels the
16919        // `(defcaixa … :deps ((…)) :deps-dev ((…)))` surface admits on
16920        // the two-list dep-graph slot axis, one arm per typed slot.
16921        // Mirrors the peer scalar-value pin the sibling
16922        // [`crate::M2_AUTHOR_KEY_LIMITS`] /
16923        // [`crate::M2_AUTHOR_KEY_BEHAVIOR`] /
16924        // [`crate::M2_AUTHOR_KEY_UPGRADE_FROM`] (f49c8b0) M2 top-level
16925        // author-labels, [`crate::M3_AUTHOR_KEY_MEMBROS`] etc.
16926        // (882f498) M3 top-level author-labels, and
16927        // [`crate::SUPERVISOR_AUTHOR_KEY_ESTRATEGIA`] etc. (be40492)
16928        // Supervisor top-level author-labels carry, so every kind-scoped
16929        // typed-slot-family axis routes through one canonical per-arm
16930        // declaration.
16931        //
16932        // A future rebrand (`:deps` → `:dependencies` matching Cargo's
16933        // verbatim key, `:deps-dev` → `:dev-dependencies` matching the
16934        // same, `:deps` / `:deps-dev` → `:runtime-deps` / `:dev-deps`
16935        // for symmetry) lands as an edit to exactly one const, and
16936        // every consumer that reaches for the label picks it up at
16937        // build time rather than at runtime as a downstream mismatch on
16938        // a `DepError::DuplicateNome { list: … }` diagnostic far from
16939        // the rename's commit.
16940        assert_eq!(crate::render::DEP_AUTHOR_KEY_DEPS, ":deps");
16941        assert_eq!(crate::render::DEP_AUTHOR_KEY_DEPS_DEV, ":deps-dev");
16942    }
16943
16944    #[test]
16945    fn dep_author_key_consts_are_pairwise_distinct() {
16946        // Distinct-labels pin: the two `:deps` / `:deps-dev` labels
16947        // must not collapse onto one byte-string. A future copy-paste
16948        // slip that renamed both consts to the same value (or a rebrand
16949        // that dropped the `-dev` suffix from one but not the other)
16950        // would leave every `DepError::DuplicateNome { list: … }`
16951        // diagnostic naming an unattributable list — the linter would
16952        // route the author to the wrong caixa.lisp block, or the
16953        // cross-list precedence gate
16954        // (`validate_deps_duplicate_in_deps_fires_before_duplicate_in_deps_dev`)
16955        // would surface a `:deps`-tagged diagnostic on a `:deps-dev`
16956        // duplicate. Peer of the sibling
16957        // `m2_author_key_consts_are_pairwise_distinct`-shape gates the
16958        // other top-level kind-scoped slot-family axes carry
16959        // (implicitly held by their different byte-values today).
16960        assert_ne!(
16961            crate::render::DEP_AUTHOR_KEY_DEPS,
16962            crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
16963            "DEP_AUTHOR_KEY_{{DEPS,DEPS_DEV}} consts must be pairwise-distinct \
16964             so a `DepError::DuplicateNome {{ list: … }}` diagnostic \
16965             self-locates the offending block in the author's caixa.lisp",
16966        );
16967    }
16968
16969    #[test]
16970    fn validate_no_self_dep_routes_through_lifted_dep_author_key_consts() {
16971        // Production-through-const pin: the two per-arm list tags
16972        // [`validate_no_self_dep`] threads onto the `list:` field of a
16973        // returned [`DepError::DepIsSelf`] route through the lifted
16974        // [`crate::DEP_AUTHOR_KEY_DEPS`] /
16975        // [`crate::DEP_AUTHOR_KEY_DEPS_DEV`] consts. A future drift at
16976        // the walker (a rename that reaches one arm but not the const,
16977        // or vice versa) surfaces here at build time rather than at
16978        // runtime as a `feira lint` diagnostic naming the wrong list
16979        // tag. Mirror of the peer
16980        // [`crate::Caixa::declared_servico_slots`] production tagger
16981        // pin (f49c8b0) on the sibling M2 top-level slot axis, extended
16982        // onto the two-list dep-graph gate.
16983        let deps = vec![Dep::simple("orquestra", "^0.1")];
16984        let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
16985        let DepError::DepIsSelf { list, .. } = err else {
16986            panic!("expected DepIsSelf from :deps walk");
16987        };
16988        assert_eq!(list, crate::render::DEP_AUTHOR_KEY_DEPS);
16989
16990        let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
16991        let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
16992        let DepError::DepIsSelf { list, .. } = err else {
16993            panic!("expected DepIsSelf from :deps-dev walk");
16994        };
16995        assert_eq!(list, crate::render::DEP_AUTHOR_KEY_DEPS_DEV);
16996    }
16997
16998    // ── Dep::nome accessor pins ───────────────────────────────────────
16999    //
17000    // Three coherence pins on the lifted `Dep::nome` accessor: byte-equal
17001    // projection over the plain-shorthand / explicit-git / explicit-path
17002    // fixture triad the [`Dep`] docstring lists (so the accessor's
17003    // accept-set is exercised across every author-surface `:fonte`
17004    // shape); by-borrow pointer identity so the projection stays
17005    // zero-copy at every consumer site; and validate-composition through
17006    // the [`validate_no_self_dep`] cross-slot gate reading its
17007    // parent-name equality check through the lifted accessor rather than
17008    // the raw field.
17009
17010    #[test]
17011    fn dep_nome_returns_declared_nome_across_fonte_shapes() {
17012        // Plain-shorthand form (`:fonte None`).
17013        assert_eq!(Dep::simple("caixa-teia", "^0.1").nome(), "caixa-teia");
17014        // Explicit git-source form with a tag pin — same accessor path.
17015        assert_eq!(
17016            Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0").nome(),
17017            "caixa-teia",
17018        );
17019        // Explicit path-source form.
17020        assert_eq!(
17021            Dep {
17022                nome: "caixa-teia".to_string(),
17023                versao: "0.1.0".to_string(),
17024                fonte: Some(DepSource::Path {
17025                    caminho: "../caixa-teia".to_string(),
17026                }),
17027                opcional: false,
17028                caracteristicas: Vec::new(),
17029            }
17030            .nome(),
17031            "caixa-teia",
17032        );
17033        // The empty-string `:nome` sentinel (which [`Dep::validate`]
17034        // refuses through the [`DepError::NomeEmpty`] arm) still round-
17035        // trips as an empty `&str` through the accessor — the accessor is
17036        // a projection, not a gate; the gate is [`Dep::validate`].
17037        assert_eq!(Dep::simple("", "^0.1").nome(), "");
17038    }
17039
17040    #[test]
17041    fn dep_nome_is_by_borrow_pointer_identity() {
17042        // Zero-copy pin: the accessor must borrow into the field's own
17043        // storage, not clone. If a future rewrite regresses to
17044        // `self.nome.clone().leak()` or an owned-buffer shape, the two
17045        // pointers diverge and this pin fails at build time.
17046        let d = Dep::simple("caixa-teia", "^0.1");
17047        assert!(std::ptr::eq(d.nome().as_ptr(), d.nome.as_ptr()));
17048    }
17049
17050    // ── Dep::versao_requirement accessor pins ─────────────────────────
17051    //
17052    // Three coherence pins on the lifted `Dep::versao_requirement`
17053    // accessor: byte-equal projection over the plain-shorthand /
17054    // explicit-git / explicit-path fixture triad the [`Dep`] docstring
17055    // lists plus the empty-sentinel that round-trips as `""` (the accessor
17056    // is a projection, not a gate; the gate is [`Dep::validate`]); by-
17057    // borrow pointer identity so the projection stays zero-copy at every
17058    // consumer site; and validate-composition through the
17059    // [`crate::render::require_valid_versao_requirement`] cascade reading
17060    // its requirement-shape check through the lifted accessor rather than
17061    // the raw field.
17062    #[test]
17063    fn dep_versao_requirement_returns_declared_versao_across_fonte_shapes() {
17064        // Plain-shorthand form (`:fonte None`).
17065        assert_eq!(
17066            Dep::simple("caixa-teia", "^0.1").versao_requirement(),
17067            "^0.1",
17068        );
17069        // Explicit git-source form with a tag pin — same accessor path.
17070        assert_eq!(
17071            Dep::git(
17072                "caixa-teia",
17073                "~0.1.2",
17074                "github:pleme-io/caixa-teia",
17075                "v0.1.0"
17076            )
17077            .versao_requirement(),
17078            "~0.1.2",
17079        );
17080        // Explicit path-source form.
17081        assert_eq!(
17082            Dep {
17083                nome: "caixa-teia".to_string(),
17084                versao: "0.1.0".to_string(),
17085                fonte: Some(DepSource::Path {
17086                    caminho: "../caixa-teia".to_string(),
17087                }),
17088                opcional: false,
17089                caracteristicas: Vec::new(),
17090            }
17091            .versao_requirement(),
17092            "0.1.0",
17093        );
17094        // The wildcard requirement (`"*"`) — the shorthand
17095        // `parse_requirement` accepts as `VersionReq::STAR` — round-trips
17096        // verbatim through the accessor as `"*"`, same byte-shape the
17097        // author wrote.
17098        assert_eq!(Dep::simple("caixa-teia", "*").versao_requirement(), "*");
17099        // The empty-string `:versao` sentinel (which [`Dep::validate`]
17100        // refuses through the [`DepError::VersaoEmpty`] arm) still round-
17101        // trips as an empty `&str` through the accessor — the accessor is
17102        // a projection, not a gate; the gate is [`Dep::validate`]. Peer
17103        // of the sibling [`Dep::nome`] empty-sentinel round-trip pin.
17104        assert_eq!(Dep::simple("caixa-teia", "").versao_requirement(), "");
17105    }
17106
17107    #[test]
17108    fn dep_versao_requirement_is_by_borrow_pointer_identity() {
17109        // Zero-copy pin: the accessor must borrow into the field's own
17110        // storage, not clone. If a future rewrite regresses to
17111        // `self.versao.clone().leak()` or an owned-buffer shape, the two
17112        // pointers diverge and this pin fails at build time. Peer of the
17113        // sibling [`Dep::nome`] pointer-identity pin — same by-borrow
17114        // discipline extended onto the requirement-carrying axis.
17115        let d = Dep::simple("caixa-teia", "^0.1");
17116        assert!(std::ptr::eq(
17117            d.versao_requirement().as_ptr(),
17118            d.versao.as_ptr(),
17119        ));
17120    }
17121
17122    #[test]
17123    fn dep_validate_reads_requirement_through_accessor() {
17124        // Composition pin: the [`Dep::validate`]
17125        // [`crate::render::require_valid_versao_requirement`] cascade
17126        // consumes the requirement string through the lifted accessor —
17127        // both the requirement-gate input and the
17128        // [`DepError::VersaoInvalid`] error-body carrier route through
17129        // `self.versao_requirement()`. A valid requirement passes
17130        // (positive control); a malformed-but-non-empty requirement fails
17131        // and the diagnostic quotes the offending byte-string verbatim
17132        // (same shape the accessor projects), so a future regression that
17133        // detoured the requirement carrier through a different byte-
17134        // string (say the parsed `VersionReq`'s `Display`, or a
17135        // normalized rewrite) would surface here at build time. The
17136        // empty-`:versao` arm fires the [`DepError::VersaoEmpty`] variant
17137        // ahead of the parse arm, pinning the empty-first cascade the
17138        // accessor's `""` sentinel round-trip acknowledges.
17139        Dep::simple("caixa-teia", "^0.1").validate().unwrap();
17140        let err = Dep::simple("caixa-teia", "v0.1").validate().unwrap_err();
17141        assert!(
17142            matches!(
17143                &err,
17144                DepError::VersaoInvalid {
17145                    nome,
17146                    versao,
17147                    ..
17148                } if nome == "caixa-teia" && versao == "v0.1",
17149            ),
17150            "expected VersaoInvalid quoting the accessor-projected requirement, got {err:?}",
17151        );
17152        let err = Dep::simple("caixa-teia", "").validate().unwrap_err();
17153        assert!(
17154            matches!(
17155                &err,
17156                DepError::VersaoEmpty { nome } if nome == "caixa-teia",
17157            ),
17158            "expected VersaoEmpty from the empty-first arm, got {err:?}",
17159        );
17160    }
17161
17162    // ── Dep::fonte accessor pins ──────────────────────────────────────
17163    //
17164    // Three coherence pins on the lifted `Dep::fonte` accessor: byte-
17165    // equal projection over the plain-shorthand (`:fonte None`) /
17166    // explicit-git-tag / explicit-path fixture triad the [`Dep`]
17167    // docstring lists (so the accessor's accept-set is exercised across
17168    // every author-surface `:fonte` shape and both `DepSource` variants);
17169    // pointer identity so the borrowed reference points into the field's
17170    // own `Option<DepSource>` storage (not a cloned side-buffer); and
17171    // validate-composition through the [`Dep::validate`] gate reading
17172    // its per-`:fonte` [`DepSource::validate`] delegation through the
17173    // lifted accessor rather than the raw `if let Some(ref fonte) =
17174    // self.fonte` bracket.
17175
17176    #[test]
17177    fn dep_fonte_returns_declared_source_across_shapes() {
17178        // Plain-shorthand form — `:fonte` omitted, accessor projects
17179        // the `None` partition the resolver-side default-fill treats
17180        // as "resolve through `github:<default-org>/<nome>`".
17181        assert!(Dep::simple("caixa-teia", "^0.1").fonte().is_none());
17182        // Explicit git-source form with a tag pin — same accessor path.
17183        let git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
17184        match git.fonte() {
17185            Some(DepSource::Git {
17186                repo,
17187                tag,
17188                rev,
17189                branch,
17190            }) => {
17191                assert_eq!(repo, "github:pleme-io/caixa-teia");
17192                assert_eq!(tag.as_deref(), Some("v0.1.0"));
17193                assert!(rev.is_none());
17194                assert!(branch.is_none());
17195            }
17196            other => panic!("expected explicit git :fonte, got {other:?}"),
17197        }
17198        // Explicit path-source form — the dev-only local-filesystem
17199        // arm the [`Dep`] docstring's third fixture carries.
17200        let path = Dep {
17201            nome: "caixa-teia".to_string(),
17202            versao: "0.1.0".to_string(),
17203            fonte: Some(DepSource::Path {
17204                caminho: "../caixa-teia".to_string(),
17205            }),
17206            opcional: false,
17207            caracteristicas: Vec::new(),
17208        };
17209        match path.fonte() {
17210            Some(DepSource::Path { caminho }) => {
17211                assert_eq!(caminho, "../caixa-teia");
17212            }
17213            other => panic!("expected explicit path :fonte, got {other:?}"),
17214        }
17215    }
17216
17217    #[test]
17218    fn dep_fonte_is_by_borrow_pointer_identity() {
17219        // Zero-copy pin: the accessor must borrow into the field's own
17220        // `Option<DepSource>` storage, not clone into a side buffer. If
17221        // a future rewrite regresses to `self.fonte.clone()` or an
17222        // owned-buffer shape, the two pointers diverge and this pin
17223        // fails at build time. Peer of the sibling per-`Dep` [`Dep::nome`]
17224        // (eba2cde) / [`Dep::versao_requirement`] (05529b1) pointer-
17225        // identity pins — same by-borrow discipline extended onto the
17226        // outer-`Dep` `Option<&Composite>` composite-reference axis.
17227        let d = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
17228        let accessed = d.fonte().expect("git :fonte present") as *const DepSource;
17229        let raw = d.fonte.as_ref().expect("git :fonte present") as *const DepSource;
17230        assert!(std::ptr::eq(accessed, raw));
17231    }
17232
17233    #[test]
17234    fn dep_validate_reads_fonte_through_accessor() {
17235        // Composition pin: [`Dep::validate`]'s per-`:fonte`
17236        // [`DepSource::validate`] delegation consumes the typed slot
17237        // through the lifted accessor — an author-omitted `:fonte`
17238        // still passes the outer gate (positive control), an explicit
17239        // well-formed git source with exactly one pin passes, and a
17240        // malformed git source (empty `:repo`) surfaces the
17241        // [`DepError::FonteRepoEmpty`] variant quoting the offending
17242        // dep's `:nome` verbatim so a future regression that detoured
17243        // the `:fonte` delegation through a different path (say a
17244        // per-scope override projector) would surface here at build
17245        // time. Peer of the sibling
17246        // `dep_validate_reads_requirement_through_accessor` composition
17247        // pin on the `:versao` axis.
17248        // Positive control 1: no `:fonte` at all.
17249        Dep::simple("caixa-teia", "^0.1").validate().unwrap();
17250        // Positive control 2: well-formed git source.
17251        Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0")
17252            .validate()
17253            .unwrap();
17254        // Negative control: empty `:repo` — the accessor still returns
17255        // `Some(&DepSource::Git { repo: "", … })` and the delegated
17256        // `DepSource::validate` gate raises the typed carrier.
17257        let bad = Dep {
17258            nome: "caixa-teia".to_string(),
17259            versao: "^0.1".to_string(),
17260            fonte: Some(DepSource::Git {
17261                repo: String::new(),
17262                tag: Some("v0.1.0".to_string()),
17263                rev: None,
17264                branch: None,
17265            }),
17266            opcional: false,
17267            caracteristicas: Vec::new(),
17268        };
17269        let err = bad.validate().unwrap_err();
17270        assert!(
17271            matches!(
17272                &err,
17273                DepError::FonteRepoEmpty { nome } if nome == "caixa-teia",
17274            ),
17275            "expected FonteRepoEmpty from the accessor-routed :fonte gate, got {err:?}",
17276        );
17277    }
17278
17279    #[test]
17280    fn validate_no_self_dep_reads_parent_equality_through_accessor() {
17281        // Composition pin: the cross-slot [`validate_no_self_dep`] gate
17282        // rejects a `:deps` entry whose `:nome` equals the parent caixa's
17283        // own `:nome` through the lifted accessor rather than the raw
17284        // field. Fails-before-passes-after: with the accessor lifted the
17285        // gate reads its equality check through `dep.nome() ==
17286        // parent_nome` on both the `:deps` and `:deps-dev` traversals, so
17287        // the diagnostic still names the offending list tag as expected.
17288        let deps = vec![Dep::simple("orquestra", "^0.1")];
17289        let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
17290        assert!(matches!(
17291            err,
17292            DepError::DepIsSelf {
17293                ref nome,
17294                list,
17295            } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS,
17296        ));
17297        let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
17298        let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
17299        assert!(matches!(
17300            err,
17301            DepError::DepIsSelf {
17302                ref nome,
17303                list,
17304            } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
17305        ));
17306        // A non-matching `:nome` passes through the accessor gate.
17307        let deps = vec![Dep::simple("caixa-teia", "^0.1")];
17308        validate_no_self_dep(&deps, &[], "orquestra").unwrap();
17309    }
17310
17311    // ── Dep::caracteristicas accessor pins ────────────────────────────
17312    //
17313    // Three coherence pins on the lifted `Dep::caracteristicas` accessor:
17314    // byte-equal projection over the default-empty / single-entry /
17315    // multi-entry fixture triad (so the accessor's accept-set is
17316    // exercised across every author-surface `:caracteristicas` shape,
17317    // matching the peer sibling family's fixture-triad discipline); by-
17318    // borrow pointer identity so the projection stays zero-copy at every
17319    // consumer site; and validate-composition through the
17320    // [`Dep::validate_caracteristicas`] gate reading its per-entry
17321    // linear walk through the lifted accessor rather than the raw
17322    // `for c in &self.caracteristicas` bracket.
17323
17324    #[test]
17325    fn dep_caracteristicas_returns_declared_features_across_shapes() {
17326        // Default-empty form — the [`Dep::simple`] constructor's
17327        // `Vec::new()` fill; the accessor projects the empty slice
17328        // verbatim (no `None` collapse).
17329        assert!(
17330            Dep::simple("caixa-teia", "^0.1")
17331                .caracteristicas()
17332                .is_empty(),
17333        );
17334        // Single-entry form — the canonical Cargo-shaped one-feature
17335        // enable ([`crate::render::is_cargo_feature_name`] accepts the
17336        // `"http"` byte-string as a valid feature name).
17337        let one = Dep {
17338            nome: "caixa-teia".to_string(),
17339            versao: "^0.1".to_string(),
17340            fonte: None,
17341            opcional: false,
17342            caracteristicas: vec!["http".to_string()],
17343        };
17344        assert_eq!(one.caracteristicas(), &["http".to_string()]);
17345        // Multi-entry form — the substrate's set-shaped multi-feature
17346        // enable, exercising the accessor over a length-two slice with
17347        // no duplicate collapse.
17348        let two = Dep {
17349            nome: "caixa-teia".to_string(),
17350            versao: "^0.1".to_string(),
17351            fonte: None,
17352            opcional: false,
17353            caracteristicas: vec!["http".to_string(), "json".to_string()],
17354        };
17355        assert_eq!(
17356            two.caracteristicas(),
17357            &["http".to_string(), "json".to_string()],
17358        );
17359    }
17360
17361    #[test]
17362    fn dep_caracteristicas_is_by_borrow_pointer_identity() {
17363        // Zero-copy pin: the accessor must borrow into the field's own
17364        // `Vec<String>` storage, not clone into a side buffer. If a
17365        // future rewrite regresses to `self.caracteristicas.clone()` or
17366        // an owned-buffer shape, the two pointers diverge and this pin
17367        // fails at build time. Peer of the sibling per-`Dep`
17368        // [`Dep::nome`] (eba2cde) / [`Dep::versao_requirement`] (05529b1)
17369        // / [`Dep::fonte`] (d65d1bf) pointer-identity pins — same by-
17370        // borrow discipline extended onto the outer-`Dep` `&[String]`
17371        // slice-projection axis.
17372        let d = Dep {
17373            nome: "caixa-teia".to_string(),
17374            versao: "^0.1".to_string(),
17375            fonte: None,
17376            opcional: false,
17377            caracteristicas: vec!["http".to_string(), "json".to_string()],
17378        };
17379        assert!(std::ptr::eq(
17380            d.caracteristicas().as_ptr(),
17381            d.caracteristicas.as_ptr(),
17382        ));
17383    }
17384
17385    #[test]
17386    fn dep_validate_reads_caracteristicas_through_accessor() {
17387        // Composition pin: [`Dep::validate_caracteristicas`]'s per-entry
17388        // linear walk consumes the feature-toggle list through the
17389        // lifted accessor — a well-formed `:caracteristicas` set passes
17390        // (positive control), an empty-string entry surfaces the
17391        // [`DepError::CaracteristicaEmpty`] variant quoting the offending
17392        // `Dep::nome`, and a within-list duplicate surfaces the
17393        // [`DepError::CaracteristicaDuplicate`] variant so a future
17394        // regression that detoured the walk through a different byte-
17395        // string list (say a per-scope override projector) would surface
17396        // here at build time. Peer of the sibling
17397        // `dep_validate_reads_fonte_through_accessor` /
17398        // `dep_validate_reads_requirement_through_accessor` composition
17399        // pins on the `:fonte` / `:versao` axes.
17400        // Positive control: two distinct well-formed feature names pass.
17401        Dep {
17402            nome: "caixa-teia".to_string(),
17403            versao: "^0.1".to_string(),
17404            fonte: None,
17405            opcional: false,
17406            caracteristicas: vec!["http".to_string(), "json".to_string()],
17407        }
17408        .validate()
17409        .unwrap();
17410        // Negative control 1: empty-string feature-name entry — the
17411        // accessor still returns `&[""]` and the walk raises the typed
17412        // empty-first carrier.
17413        let err = Dep {
17414            nome: "caixa-teia".to_string(),
17415            versao: "^0.1".to_string(),
17416            fonte: None,
17417            opcional: false,
17418            caracteristicas: vec![String::new()],
17419        }
17420        .validate()
17421        .unwrap_err();
17422        assert!(
17423            matches!(
17424                &err,
17425                DepError::CaracteristicaEmpty { nome } if nome == "caixa-teia",
17426            ),
17427            "expected CaracteristicaEmpty from the accessor-routed walk, got {err:?}",
17428        );
17429        // Negative control 2: within-list duplicate — the accessor's
17430        // slice view carries both entries, and the walk's dedup arm
17431        // raises the typed duplicate carrier quoting the offending
17432        // feature name verbatim.
17433        let err = Dep {
17434            nome: "caixa-teia".to_string(),
17435            versao: "^0.1".to_string(),
17436            fonte: None,
17437            opcional: false,
17438            caracteristicas: vec!["http".to_string(), "http".to_string()],
17439        }
17440        .validate()
17441        .unwrap_err();
17442        assert!(
17443            matches!(
17444                &err,
17445                DepError::CaracteristicaDuplicate {
17446                    nome,
17447                    caracteristica,
17448                } if nome == "caixa-teia" && caracteristica == "http",
17449            ),
17450            "expected CaracteristicaDuplicate from the accessor-routed dedup, got {err:?}",
17451        );
17452    }
17453
17454    // ── Dep::opcional accessor pins ───────────────────────────────────
17455    //
17456    // Two coherence pins on the lifted `Dep::opcional` accessor: byte-
17457    // equal projection over the default-`false` / explicit-`true`
17458    // fixture pair across the plain-shorthand (`:fonte None`) / explicit-
17459    // git-tag / explicit-path fixture triad the [`Dep`] docstring lists,
17460    // exercising the accessor's accept-set over every author-surface
17461    // `:fonte` shape × every author-surface `:opcional` shape; and by-
17462    // `Copy` idempotency so the projection stays value-return (no
17463    // silent detour to a fresh `&bool` borrow that would introduce a
17464    // lifetime on the return type the plain-`Copy`-scalar axis's `bool`
17465    // shape elides). No composition pin — `:opcional` does not
17466    // participate in [`Dep::validate`] (an opcional dep with any bool
17467    // value is validate-accepted; the missing-source arm is a resolver-
17468    // side runtime dispatch, not a build-time refusal), so the axis
17469    // reduces to the value-shape + `Copy` pin pair the peer
17470    // [`crate::Caixa::max_restarts`] / [`crate::Caixa::estrategia`]
17471    // outer-`Option<Copy>` accessor pins already carry.
17472
17473    #[test]
17474    fn dep_opcional_returns_declared_opcional_across_fonte_shapes() {
17475        // Default-`false` form via the [`Dep::simple`] constructor —
17476        // the accessor projects the `false` bit the default-fill sets.
17477        assert!(!Dep::simple("caixa-teia", "^0.1").opcional());
17478        // Default-`false` form via the [`Dep::git`] constructor — same
17479        // default fill; the accessor projects `false` regardless of the
17480        // `:fonte` arm.
17481        assert!(!Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0").opcional(),);
17482        // Explicit-`true` form × plain-shorthand `:fonte` — the
17483        // canonical author-surface "this dep may be missing" shape.
17484        let plain_true = Dep {
17485            nome: "caixa-teia".to_string(),
17486            versao: "^0.1".to_string(),
17487            fonte: None,
17488            opcional: true,
17489            caracteristicas: Vec::new(),
17490        };
17491        assert!(plain_true.opcional());
17492        // Explicit-`true` form × explicit git-source — the accessor
17493        // projects the bit verbatim regardless of the `:fonte` arm.
17494        let git_true = Dep {
17495            nome: "caixa-teia".to_string(),
17496            versao: "^0.1".to_string(),
17497            fonte: Some(DepSource::Git {
17498                repo: "github:pleme-io/caixa-teia".to_string(),
17499                tag: Some("v0.1.0".to_string()),
17500                rev: None,
17501                branch: None,
17502            }),
17503            opcional: true,
17504            caracteristicas: Vec::new(),
17505        };
17506        assert!(git_true.opcional());
17507        // Explicit-`true` form × explicit path-source — the dev-only
17508        // local-filesystem arm the [`Dep`] docstring's third fixture
17509        // carries.
17510        let path_true = Dep {
17511            nome: "caixa-teia".to_string(),
17512            versao: "0.1.0".to_string(),
17513            fonte: Some(DepSource::Path {
17514                caminho: "../caixa-teia".to_string(),
17515            }),
17516            opcional: true,
17517            caracteristicas: Vec::new(),
17518        };
17519        assert!(path_true.opcional());
17520    }
17521
17522    #[test]
17523    fn dep_opcional_projects_bool_by_copy() {
17524        // The by-`Copy` pin: [`Dep::opcional`] returns `bool` by value
17525        // (`bool: Copy`) — the accessor does not borrow `&self` past
17526        // the call (no lifetime on the return type), and calling the
17527        // accessor twice on the same [`Dep`] must yield discriminant-
17528        // equal values (idempotent, no side effects on `&self`). Peer
17529        // of the sibling outer-`Caixa` `Option<Copy>` by-`Copy`
17530        // `max_restarts_projects_option_by_copy` (eba5211) /
17531        // `estrategia_projects_option_by_copy` (ed04d3c) pins on the
17532        // outer-`Caixa` altitude — extended here to the outer-`Dep`
17533        // altitude's plain-`Copy` `bool` axis. The `Copy` discipline
17534        // replaces the pointer-equality claim the sibling per-`Dep`
17535        // by-borrow pins (`dep_nome_is_by_borrow_pointer_identity`
17536        // eba2cde, `dep_versao_requirement_is_by_borrow_pointer_identity`
17537        // 05529b1, `dep_fonte_is_by_borrow_pointer_identity` d65d1bf,
17538        // `dep_caracteristicas_is_by_borrow_pointer_identity` 9197944)
17539        // carry (a fresh `Copy` of a `Copy` discriminant is definitionally
17540        // the same discriminant, so the axis reduces to discriminant
17541        // equality).
17542        //
17543        // Pins against a future silent detour that returned a fresh
17544        // `&bool` reference (which would type-check but silently
17545        // introduce a borrow of `&self` past the call, collapsing the
17546        // load-bearing "no lifetime on the return type" `Copy`
17547        // projection the plain-`Copy`-scalar axis's `bool` shape
17548        // carries) or a stale-read side effect that flipped the outer
17549        // discriminant on successive calls.
17550        for opcional in [false, true] {
17551            let d = Dep {
17552                nome: "caixa-teia".to_string(),
17553                versao: "^0.1".to_string(),
17554                fonte: None,
17555                opcional,
17556                caracteristicas: Vec::new(),
17557            };
17558            let first = d.opcional();
17559            let second = d.opcional();
17560            assert_eq!(
17561                first, second,
17562                "Dep::opcional must be idempotent — two successive calls \
17563                 on the same &self must return the same bool",
17564            );
17565            assert_eq!(
17566                first, opcional,
17567                "Dep::opcional must return :opcional verbatim by Copy — \
17568                 got {first}, expected {opcional}",
17569            );
17570            assert_eq!(
17571                d.opcional(),
17572                d.opcional,
17573                "Dep::opcional accessor and self.opcional field access \
17574                 must byte-equal — a bit-flip drift would silently split \
17575                 the paired resolver-side drop-vs-error dispatch from \
17576                 the storage-side default-fill the [`Dep::simple`] / \
17577                 [`Dep::git`] constructor pair carries",
17578            );
17579        }
17580    }
17581
17582    // ── DepSource::sole_pin — sole-set git-pin accessor ─────────────────
17583
17584    #[test]
17585    fn sole_pin_returns_none_for_path_source() {
17586        // A path source carries no git-ref, so `sole_pin()` returns
17587        // `None` structurally — the sibling arm every git-fetching
17588        // consumer partitions off before reaching for a git-ref. Pins
17589        // the Path-arm branch of the accessor against a future silent
17590        // detour that treats a `Self::Path` as an unpinned-git source
17591        // and returns the wrong "no pin" signal (e.g. the empty string,
17592        // or a hard-coded `Some("HEAD")` matching the caixa-crd
17593        // path-arm `git_ref` fill).
17594        let s = DepSource::Path {
17595            caminho: "../local-caixa".to_string(),
17596        };
17597        assert_eq!(s.sole_pin(), None);
17598    }
17599
17600    #[test]
17601    fn sole_pin_returns_none_for_unpinned_git_source() {
17602        // The [`DepSource::default_github`] shorthand shape carries no
17603        // pin — every `tag`/`rev`/`branch` is `None`, and `sole_pin()`
17604        // returns `None`. This is the shape caixa-resolver's `fetch_dep`
17605        // materializes when the author omits `:fonte` entirely, then
17606        // hands to `fetch_git` which raises `ResolveError::MissingPin`
17607        // on the `None` arm — the accessor's return matches the arm
17608        // the resolver's diagnostic keys off.
17609        let s = DepSource::default_github("pleme-io", "caixa-teia");
17610        assert_eq!(s.sole_pin(), None);
17611    }
17612
17613    #[test]
17614    fn sole_pin_returns_rev_when_only_rev_is_set() {
17615        let s = DepSource::Git {
17616            repo: "github:o/x".into(),
17617            tag: None,
17618            rev: Some("deadbeefcafebabe1234567890abcdef12345678".into()),
17619            branch: None,
17620        };
17621        assert_eq!(
17622            s.sole_pin(),
17623            Some("deadbeefcafebabe1234567890abcdef12345678")
17624        );
17625    }
17626
17627    #[test]
17628    fn sole_pin_returns_tag_when_only_tag_is_set() {
17629        let s = DepSource::Git {
17630            repo: "github:o/x".into(),
17631            tag: Some("v0.1.0".into()),
17632            rev: None,
17633            branch: None,
17634        };
17635        assert_eq!(s.sole_pin(), Some("v0.1.0"));
17636    }
17637
17638    #[test]
17639    fn sole_pin_returns_branch_when_only_branch_is_set() {
17640        let s = DepSource::Git {
17641            repo: "github:o/x".into(),
17642            tag: None,
17643            rev: None,
17644            branch: Some("main".into()),
17645        };
17646        assert_eq!(s.sole_pin(), Some("main"));
17647    }
17648
17649    #[test]
17650    fn sole_pin_precedence_rev_beats_tag_and_branch() {
17651        // Precedence: rev > tag > branch. Validate() rejects
17652        // multiple-pin shapes, but the accessor's precedence is defined
17653        // for pre-validate consumers (the resolver's `MissingPin`
17654        // diagnostic path, the caixa-crd round-trip's default `"main"`
17655        // fallback) and as defense-in-depth if the gate is ever
17656        // bypassed. Pins the same precedence caixa-resolver's
17657        // `fetch_git` and caixa-crd's `dep_into_ref` already apply
17658        // inline.
17659        let s = DepSource::Git {
17660            repo: "github:o/x".into(),
17661            tag: Some("v1".into()),
17662            rev: Some("deadbeefcafebabe1234567890abcdef12345678".into()),
17663            branch: Some("main".into()),
17664        };
17665        assert_eq!(
17666            s.sole_pin(),
17667            Some("deadbeefcafebabe1234567890abcdef12345678")
17668        );
17669    }
17670
17671    #[test]
17672    fn sole_pin_precedence_tag_beats_branch_when_no_rev() {
17673        let s = DepSource::Git {
17674            repo: "github:o/x".into(),
17675            tag: Some("v1".into()),
17676            rev: None,
17677            branch: Some("main".into()),
17678        };
17679        assert_eq!(s.sole_pin(), Some("v1"));
17680    }
17681
17682    #[test]
17683    fn sole_pin_byte_equals_inline_rev_or_tag_or_branch_cascade() {
17684        // Fail-before-pass-after byte-parity pin: the substrate accessor
17685        // must return byte-identical to the inline
17686        // `rev.as_deref().or(tag.as_deref()).or(branch.as_deref())`
17687        // cascade both caixa-resolver's `fetch_git` and caixa-crd's
17688        // `dep_into_ref` open-coded pre-lift. Trips at caixa-core build
17689        // time if the accessor's precedence silently drifts from the
17690        // consumer-side cascade — the exact drift this lift converges
17691        // to one substrate primitive to close structurally.
17692        //
17693        // Iterates through the 2^3 = 8 combinations of (tag, rev,
17694        // branch) each-either-`None`-or-`Some`, so every arm of the
17695        // precedence cascade lands under the pin. `validate()` refuses
17696        // the 4 multi-pin combinations, but the accessor's return is
17697        // defined on all 8.
17698        let vals = [Some("R".to_string()), None];
17699        for tag in &vals {
17700            for rev in &vals {
17701                for branch in &vals {
17702                    let s = DepSource::Git {
17703                        repo: "github:o/x".into(),
17704                        tag: tag.clone(),
17705                        rev: rev.clone(),
17706                        branch: branch.clone(),
17707                    };
17708                    // The exact inline cascade the two pre-lift
17709                    // consumer sites hand-rolled, byte-for-byte.
17710                    let expected = rev.as_deref().or(tag.as_deref()).or(branch.as_deref());
17711                    assert_eq!(
17712                        s.sole_pin(),
17713                        expected,
17714                        "sole_pin() must byte-equal \
17715                         rev.or(tag).or(branch) for \
17716                         (tag={tag:?}, rev={rev:?}, branch={branch:?}) — \
17717                         a drift would silently split caixa-resolver's \
17718                         fetch_git checkout target from caixa-crd's \
17719                         dep_into_ref git_ref fill",
17720                    );
17721                }
17722            }
17723        }
17724    }
17725
17726    // Fail-before-pass-after pins on the eleven
17727    // [`fonte_caminho_ctors!`]-generated `DepError::fonte_caminho_*`
17728    // constructors folded from the [`DepSource::validate_caminho`]
17729    // wire-up sites. Each pins the generated ctor's output to the
17730    // pre-lift struct-literal on the same `(&str, &str)` fixture, so
17731    // any wrapper-side lowercase / trim / re-order / silent-field-swap
17732    // regression on the two-field `{ nome: nome.to_string(), caminho:
17733    // caminho.to_string() }` construction surfaces here rather than at
17734    // a downstream diagnostic-shape mismatch. Peer of the sibling
17735    // `empty_child_version_ctor_matches_struct_literal_wrap` /
17736    // `contrato_endpoint_empty_ctor_matches_struct_literal_wrap` /
17737    // `entrada_host_invalid_ctor_matches_struct_literal_wrap` /
17738    // `nome_only_ctor_routes_caixa_through_nome_accessor` equivalence
17739    // pins on the peer `SupervisorError` / `AplicacaoError` /
17740    // `LayoutError` / `LimitsError` / `UpgradeError` envelopes.
17741
17742    #[test]
17743    fn fonte_caminho_absolute_ctor_matches_struct_literal_wrap() {
17744        assert_eq!(
17745            DepError::fonte_caminho_absolute("caixa-teia", "/home/me/work/caixa-teia"),
17746            DepError::FonteCaminhoAbsolute {
17747                nome: "caixa-teia".to_string(),
17748                caminho: "/home/me/work/caixa-teia".to_string(),
17749            },
17750            "generated fonte_caminho_absolute ctor must produce byte-equal \
17751             DepError to the open-coded struct-literal wrap on the same \
17752             (&str, &str) fixture",
17753        );
17754    }
17755
17756    #[test]
17757    fn fonte_caminho_tilde_expansion_ctor_matches_struct_literal_wrap() {
17758        assert_eq!(
17759            DepError::fonte_caminho_tilde_expansion("caixa-teia", "~/work/caixa-teia"),
17760            DepError::FonteCaminhoTildeExpansion {
17761                nome: "caixa-teia".to_string(),
17762                caminho: "~/work/caixa-teia".to_string(),
17763            },
17764        );
17765    }
17766
17767    #[test]
17768    fn fonte_caminho_var_expansion_ctor_matches_struct_literal_wrap() {
17769        assert_eq!(
17770            DepError::fonte_caminho_var_expansion("caixa-teia", "$HOME/work/caixa-teia"),
17771            DepError::FonteCaminhoVarExpansion {
17772                nome: "caixa-teia".to_string(),
17773                caminho: "$HOME/work/caixa-teia".to_string(),
17774            },
17775        );
17776    }
17777
17778    #[test]
17779    fn fonte_caminho_leading_whitespace_ctor_matches_struct_literal_wrap() {
17780        assert_eq!(
17781            DepError::fonte_caminho_leading_whitespace("caixa-teia", " ../caixa-teia"),
17782            DepError::FonteCaminhoLeadingWhitespace {
17783                nome: "caixa-teia".to_string(),
17784                caminho: " ../caixa-teia".to_string(),
17785            },
17786        );
17787    }
17788
17789    #[test]
17790    fn fonte_caminho_leading_hyphen_ctor_matches_struct_literal_wrap() {
17791        assert_eq!(
17792            DepError::fonte_caminho_leading_hyphen("caixa-teia", "-rf"),
17793            DepError::FonteCaminhoLeadingHyphen {
17794                nome: "caixa-teia".to_string(),
17795                caminho: "-rf".to_string(),
17796            },
17797        );
17798    }
17799
17800    #[test]
17801    fn fonte_caminho_backslash_ctor_matches_struct_literal_wrap() {
17802        assert_eq!(
17803            DepError::fonte_caminho_backslash("caixa-teia", "..\\caixa-teia"),
17804            DepError::FonteCaminhoBackslash {
17805                nome: "caixa-teia".to_string(),
17806                caminho: "..\\caixa-teia".to_string(),
17807            },
17808        );
17809    }
17810
17811    #[test]
17812    fn fonte_caminho_shell_pipe_ctor_matches_struct_literal_wrap() {
17813        assert_eq!(
17814            DepError::fonte_caminho_shell_pipe("caixa-teia", "../caixa-teia|evil"),
17815            DepError::FonteCaminhoShellPipe {
17816                nome: "caixa-teia".to_string(),
17817                caminho: "../caixa-teia|evil".to_string(),
17818            },
17819        );
17820    }
17821
17822    #[test]
17823    fn fonte_caminho_shell_semicolon_ctor_matches_struct_literal_wrap() {
17824        assert_eq!(
17825            DepError::fonte_caminho_shell_semicolon("caixa-teia", "../caixa-teia;evil"),
17826            DepError::FonteCaminhoShellSemicolon {
17827                nome: "caixa-teia".to_string(),
17828                caminho: "../caixa-teia;evil".to_string(),
17829            },
17830        );
17831    }
17832
17833    #[test]
17834    fn fonte_caminho_shell_background_ctor_matches_struct_literal_wrap() {
17835        assert_eq!(
17836            DepError::fonte_caminho_shell_background("caixa-teia", "../caixa-teia&"),
17837            DepError::FonteCaminhoShellBackground {
17838                nome: "caixa-teia".to_string(),
17839                caminho: "../caixa-teia&".to_string(),
17840            },
17841        );
17842    }
17843
17844    #[test]
17845    fn fonte_caminho_shell_command_substitution_ctor_matches_struct_literal_wrap() {
17846        assert_eq!(
17847            DepError::fonte_caminho_shell_command_substitution(
17848                "caixa-teia",
17849                "../caixa-teia`whoami`",
17850            ),
17851            DepError::FonteCaminhoShellCommandSubstitution {
17852                nome: "caixa-teia".to_string(),
17853                caminho: "../caixa-teia`whoami`".to_string(),
17854            },
17855        );
17856    }
17857
17858    #[test]
17859    fn fonte_caminho_trailing_slash_ctor_matches_struct_literal_wrap() {
17860        assert_eq!(
17861            DepError::fonte_caminho_trailing_slash("caixa-teia", "../caixa-teia/"),
17862            DepError::FonteCaminhoTrailingSlash {
17863                nome: "caixa-teia".to_string(),
17864                caminho: "../caixa-teia/".to_string(),
17865            },
17866        );
17867    }
17868
17869    #[test]
17870    fn fonte_caminho_ctors_route_nome_and_caminho_through_to_string() {
17871        // Cross-axis pin: sweep the two constructor input axes
17872        // (`nome: &str`, `caminho: &str`) through a non-default fixture
17873        // pair against every generated arm in the
17874        // [`fonte_caminho_ctors!`] macro, so any wrapper-side lowercase
17875        // / trim / truncate / re-order on the two-field
17876        // `{ nome, caminho }` construction — or a silent field swap
17877        // between the two axes at codegen time — surfaces here rather
17878        // than at a downstream diagnostic-shape mismatch. Peer of the
17879        // sibling `supervisor_caixa_only_ctors_route_caixa_through_
17880        // to_string` cross-axis routing pin on the peer
17881        // `SupervisorError` envelope, extended here onto the
17882        // `DepError` `{ nome: String, caminho: String }` envelope so
17883        // every substrate-primitive ctor family in caixa-core
17884        // guarantees each `&str`-field construction routes the
17885        // caller's `&str` verbatim through `.to_string()`.
17886        let nome = "sibling-teia";
17887        let caminho = "../workspace/sibling";
17888        let cases: [(DepError, DepError); 11] = [
17889            (
17890                DepError::fonte_caminho_absolute(nome, caminho),
17891                DepError::FonteCaminhoAbsolute {
17892                    nome: nome.to_string(),
17893                    caminho: caminho.to_string(),
17894                },
17895            ),
17896            (
17897                DepError::fonte_caminho_tilde_expansion(nome, caminho),
17898                DepError::FonteCaminhoTildeExpansion {
17899                    nome: nome.to_string(),
17900                    caminho: caminho.to_string(),
17901                },
17902            ),
17903            (
17904                DepError::fonte_caminho_var_expansion(nome, caminho),
17905                DepError::FonteCaminhoVarExpansion {
17906                    nome: nome.to_string(),
17907                    caminho: caminho.to_string(),
17908                },
17909            ),
17910            (
17911                DepError::fonte_caminho_leading_whitespace(nome, caminho),
17912                DepError::FonteCaminhoLeadingWhitespace {
17913                    nome: nome.to_string(),
17914                    caminho: caminho.to_string(),
17915                },
17916            ),
17917            (
17918                DepError::fonte_caminho_leading_hyphen(nome, caminho),
17919                DepError::FonteCaminhoLeadingHyphen {
17920                    nome: nome.to_string(),
17921                    caminho: caminho.to_string(),
17922                },
17923            ),
17924            (
17925                DepError::fonte_caminho_backslash(nome, caminho),
17926                DepError::FonteCaminhoBackslash {
17927                    nome: nome.to_string(),
17928                    caminho: caminho.to_string(),
17929                },
17930            ),
17931            (
17932                DepError::fonte_caminho_shell_pipe(nome, caminho),
17933                DepError::FonteCaminhoShellPipe {
17934                    nome: nome.to_string(),
17935                    caminho: caminho.to_string(),
17936                },
17937            ),
17938            (
17939                DepError::fonte_caminho_shell_semicolon(nome, caminho),
17940                DepError::FonteCaminhoShellSemicolon {
17941                    nome: nome.to_string(),
17942                    caminho: caminho.to_string(),
17943                },
17944            ),
17945            (
17946                DepError::fonte_caminho_shell_background(nome, caminho),
17947                DepError::FonteCaminhoShellBackground {
17948                    nome: nome.to_string(),
17949                    caminho: caminho.to_string(),
17950                },
17951            ),
17952            (
17953                DepError::fonte_caminho_shell_command_substitution(nome, caminho),
17954                DepError::FonteCaminhoShellCommandSubstitution {
17955                    nome: nome.to_string(),
17956                    caminho: caminho.to_string(),
17957                },
17958            ),
17959            (
17960                DepError::fonte_caminho_trailing_slash(nome, caminho),
17961                DepError::FonteCaminhoTrailingSlash {
17962                    nome: nome.to_string(),
17963                    caminho: caminho.to_string(),
17964                },
17965            ),
17966        ];
17967        for (via_ctor, via_struct_literal) in cases {
17968            assert_eq!(
17969                via_ctor, via_struct_literal,
17970                "fonte_caminho_ctors!-generated ctor must route (nome, caminho) \
17971                 through `.to_string()` in declared field order — a field-swap or \
17972                 silent-conversion regression surfaces here rather than at a \
17973                 downstream diagnostic-shape mismatch",
17974            );
17975        }
17976    }
17977
17978    // ── `dep_nome_only_ctors!` — the paired `{ nome: String }` single-slot
17979    //    envelope on `DepError`, sibling of the peer `fonte_caminho_ctors!`
17980    //    (f85f145) on the `{ nome, caminho }` two-slot envelope of the same
17981    //    enum, and of `supervisor_caixa_only_ctors!` (db09650) on the peer
17982    //    `SupervisorError` envelope's `{ caixa: String }` single-slot axis.
17983
17984    #[test]
17985    fn versao_empty_ctor_matches_struct_literal_wrap() {
17986        assert_eq!(
17987            DepError::versao_empty("caixa-teia"),
17988            DepError::VersaoEmpty {
17989                nome: "caixa-teia".to_string(),
17990            },
17991        );
17992    }
17993
17994    #[test]
17995    fn fonte_repo_empty_ctor_matches_struct_literal_wrap() {
17996        assert_eq!(
17997            DepError::fonte_repo_empty("caixa-teia"),
17998            DepError::FonteRepoEmpty {
17999                nome: "caixa-teia".to_string(),
18000            },
18001        );
18002    }
18003
18004    #[test]
18005    fn fonte_pin_missing_ctor_matches_struct_literal_wrap() {
18006        assert_eq!(
18007            DepError::fonte_pin_missing("caixa-teia"),
18008            DepError::FontePinMissing {
18009                nome: "caixa-teia".to_string(),
18010            },
18011        );
18012    }
18013
18014    #[test]
18015    fn fonte_caminho_empty_ctor_matches_struct_literal_wrap() {
18016        assert_eq!(
18017            DepError::fonte_caminho_empty("caixa-teia"),
18018            DepError::FonteCaminhoEmpty {
18019                nome: "caixa-teia".to_string(),
18020            },
18021        );
18022    }
18023
18024    #[test]
18025    fn caracteristica_empty_ctor_matches_struct_literal_wrap() {
18026        assert_eq!(
18027            DepError::caracteristica_empty("caixa-teia"),
18028            DepError::CaracteristicaEmpty {
18029                nome: "caixa-teia".to_string(),
18030            },
18031        );
18032    }
18033
18034    #[test]
18035    fn dep_nome_only_ctors_route_nome_through_to_string() {
18036        // Cross-axis routing pin: sweep the single constructor input
18037        // axis (`nome: &str`) through a non-default fixture against
18038        // every generated arm in the [`dep_nome_only_ctors!`] macro, so
18039        // any wrapper-side lowercase / trim / truncate at codegen time
18040        // — or a silent field re-name away from the canonical `nome`
18041        // axis on any one variant — surfaces here rather than at a
18042        // downstream diagnostic-shape mismatch. Peer of the sibling
18043        // `fonte_caminho_ctors_route_nome_and_caminho_through_
18044        // to_string` cross-axis routing pin on the same envelope's
18045        // two-slot family (f85f145) and of the peer
18046        // `supervisor_caixa_only_ctors_route_caixa_through_to_string`
18047        // pin on the `SupervisorError` single-slot family (db09650).
18048        let nome = "sibling-teia";
18049        let cases: [(DepError, DepError); 5] = [
18050            (
18051                DepError::versao_empty(nome),
18052                DepError::VersaoEmpty {
18053                    nome: nome.to_string(),
18054                },
18055            ),
18056            (
18057                DepError::fonte_repo_empty(nome),
18058                DepError::FonteRepoEmpty {
18059                    nome: nome.to_string(),
18060                },
18061            ),
18062            (
18063                DepError::fonte_pin_missing(nome),
18064                DepError::FontePinMissing {
18065                    nome: nome.to_string(),
18066                },
18067            ),
18068            (
18069                DepError::fonte_caminho_empty(nome),
18070                DepError::FonteCaminhoEmpty {
18071                    nome: nome.to_string(),
18072                },
18073            ),
18074            (
18075                DepError::caracteristica_empty(nome),
18076                DepError::CaracteristicaEmpty {
18077                    nome: nome.to_string(),
18078                },
18079            ),
18080        ];
18081        for (via_ctor, via_struct_literal) in cases {
18082            assert_eq!(
18083                via_ctor, via_struct_literal,
18084                "dep_nome_only_ctors!-generated ctor must route `nome` \
18085                 through `.to_string()` onto the canonical `nome` field \
18086                 — a field-rename or silent-conversion regression surfaces \
18087                 here rather than at a downstream diagnostic-shape mismatch",
18088            );
18089        }
18090    }
18091
18092    // ── `dep_nome_list_ctors!` — the paired `{ nome: String, list:
18093    //    &'static str }` two-slot envelope on `DepError`, strict
18094    //    sibling of the peer `dep_nome_only_ctors!` (792aa92) on the
18095    //    same envelope's `{ nome: String }` one-slot shape and of the
18096    //    peer `supervisor_caixa_only_ctors!` (db09650) on the
18097    //    `SupervisorError` envelope's `{ caixa: String }` one-slot axis.
18098
18099    #[test]
18100    fn duplicate_nome_ctor_matches_struct_literal_wrap() {
18101        assert_eq!(
18102            DepError::duplicate_nome("caixa-teia", crate::render::DEP_AUTHOR_KEY_DEPS),
18103            DepError::DuplicateNome {
18104                nome: "caixa-teia".to_string(),
18105                list: crate::render::DEP_AUTHOR_KEY_DEPS,
18106            },
18107            "generated duplicate_nome ctor must produce byte-equal \
18108             `DepError::DuplicateNome` to the pre-lift struct-literal \
18109             wrap on the same scalar fixtures",
18110        );
18111    }
18112
18113    #[test]
18114    fn dep_is_self_ctor_matches_struct_literal_wrap() {
18115        assert_eq!(
18116            DepError::dep_is_self("orquestra", crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
18117            DepError::DepIsSelf {
18118                nome: "orquestra".to_string(),
18119                list: crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
18120            },
18121            "generated dep_is_self ctor must produce byte-equal \
18122             `DepError::DepIsSelf` to the pre-lift struct-literal \
18123             wrap on the same scalar fixtures",
18124        );
18125    }
18126
18127    #[test]
18128    fn dep_nome_list_ctors_route_nome_and_list_through_uniformly() {
18129        // Cross-axis routing pin: sweep the two constructor input axes
18130        // (`nome: &str`, `list: &'static str`) through non-default
18131        // fixtures against every generated arm in the
18132        // [`dep_nome_list_ctors!`] macro, so any wrapper-side
18133        // lowercase / trim / truncate at codegen time — or a silent
18134        // field re-name away from the canonical `nome` / `list` axes
18135        // on any one variant, or a `list` axis silently rerouted
18136        // through `.to_string()` instead of passed as `&'static str`
18137        // verbatim — surfaces here rather than at a downstream
18138        // diagnostic-shape mismatch. Peer of the sibling
18139        // `dep_nome_only_ctors_route_nome_through_to_string` pin
18140        // (792aa92) on the same envelope's one-slot family, and of the
18141        // peer
18142        // `supervisor_child_reason_ctors_route_reason_through_into_uniformly`
18143        // pin (d2ef2ec) on the sibling `SupervisorError` envelope's
18144        // two-slot `{ caixa: String, reason: String }` shape.
18145        let nome = "sibling-teia";
18146        let cases: [(DepError, DepError); 4] = [
18147            (
18148                DepError::duplicate_nome(nome, crate::render::DEP_AUTHOR_KEY_DEPS),
18149                DepError::DuplicateNome {
18150                    nome: nome.to_string(),
18151                    list: crate::render::DEP_AUTHOR_KEY_DEPS,
18152                },
18153            ),
18154            (
18155                DepError::duplicate_nome(nome, crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
18156                DepError::DuplicateNome {
18157                    nome: nome.to_string(),
18158                    list: crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
18159                },
18160            ),
18161            (
18162                DepError::dep_is_self(nome, crate::render::DEP_AUTHOR_KEY_DEPS),
18163                DepError::DepIsSelf {
18164                    nome: nome.to_string(),
18165                    list: crate::render::DEP_AUTHOR_KEY_DEPS,
18166                },
18167            ),
18168            (
18169                DepError::dep_is_self(nome, crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
18170                DepError::DepIsSelf {
18171                    nome: nome.to_string(),
18172                    list: crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
18173                },
18174            ),
18175        ];
18176        for (via_ctor, via_struct_literal) in cases {
18177            assert_eq!(
18178                via_ctor, via_struct_literal,
18179                "dep_nome_list_ctors!-generated ctor must route `nome` \
18180                 through `.to_string()` onto the canonical `nome` field \
18181                 and pass `list` verbatim onto the canonical `&'static str` \
18182                 `list` field — a field-rename, silent-conversion, or \
18183                 axis-swap regression surfaces here rather than at a \
18184                 downstream diagnostic-shape mismatch",
18185            );
18186        }
18187    }
18188
18189    // ── `fonte_pin_shape` — the paired `{ nome: String, pin: String,
18190    //    value: String, reason: String }` four-slot envelope on
18191    //    `DepError`, sibling of the peer `dep_nome_only_ctors!` (792aa92),
18192    //    `dep_nome_list_ctors!` (6f5e0cd), `fonte_caminho_ctors!` (f85f145),
18193    //    and `fonte_caminho_byte_ctors!` (0e35793) folds on the same
18194    //    envelope, and of the peer `contrato_pair_value_reason_ctors!`
18195    //    (14e13f1) four-slot fold on the sibling `AplicacaoError`
18196    //    envelope. Single-variant lift closing the last open-coded ctor
18197    //    site on the `:fonte (:tipo git …)` value-shape trajectory.
18198
18199    #[test]
18200    fn fonte_pin_shape_ctor_matches_struct_literal_wrap() {
18201        // Pre-lift equivalence pin on the [`DepError::fonte_pin_shape`]
18202        // ctor: sweep both wire-up-shape arms (the refname-pin arm
18203        // routing `":tag"` / `":branch"` value through
18204        // [`crate::render::is_git_ref_name`], and the hex-OID-pin arm
18205        // routing `":rev"` through [`crate::render::is_git_oid`]) and
18206        // assert byte-equal `PartialEq` against the pre-lift
18207        // struct-literal, so any wrapper-side field-rename /
18208        // silent-conversion regression surfaces here rather than at a
18209        // downstream diagnostic-shape mismatch. Peer of the sibling
18210        // per-envelope byte-equal ctor pins
18211        // ([`fonte_pin_missing_ctor_matches_struct_literal_wrap`],
18212        // [`duplicate_nome_ctor_matches_struct_literal_wrap`],
18213        // [`dep_is_self_ctor_matches_struct_literal_wrap`]).
18214        assert_eq!(
18215            DepError::fonte_pin_shape(
18216                "caixa-teia",
18217                ":tag",
18218                "v0.1.0 ",
18219                "trailing whitespace".to_string(),
18220            ),
18221            DepError::FontePinShape {
18222                nome: "caixa-teia".to_string(),
18223                pin: ":tag".to_string(),
18224                value: "v0.1.0 ".to_string(),
18225                reason: "trailing whitespace".to_string(),
18226            },
18227            "fonte_pin_shape ctor must produce byte-equal \
18228             `DepError::FontePinShape` to the pre-lift struct-literal \
18229             wrap on a refname-pin (`:tag` / `:branch`) fixture",
18230        );
18231        assert_eq!(
18232            DepError::fonte_pin_shape(
18233                "caixa-teia",
18234                ":rev",
18235                "DEADBEEF",
18236                "abbreviated OID rejected".to_string(),
18237            ),
18238            DepError::FontePinShape {
18239                nome: "caixa-teia".to_string(),
18240                pin: ":rev".to_string(),
18241                value: "DEADBEEF".to_string(),
18242                reason: "abbreviated OID rejected".to_string(),
18243            },
18244            "fonte_pin_shape ctor must produce byte-equal \
18245             `DepError::FontePinShape` to the pre-lift struct-literal \
18246             wrap on a hex-OID-pin (`:rev`) fixture",
18247        );
18248    }
18249
18250    #[test]
18251    fn fonte_pin_shape_ctor_routes_all_four_axes_through_to_string() {
18252        // Cross-axis routing pin: sweep every one of the four
18253        // constructor input axes (`nome: &str`, `pin: &str`,
18254        // `value: &str`, `reason: String`) through non-default
18255        // fixtures against the [`DepError::fonte_pin_shape`] ctor, so
18256        // any wrapper-side lowercase / trim / truncate at codegen time
18257        // — or a silent field re-name / axis-swap on any one of the
18258        // four fields, or a `reason` axis silently routed through
18259        // `.to_string()` instead of forwarded owned — surfaces here
18260        // rather than at a downstream diagnostic-shape mismatch. Peer
18261        // of the sibling
18262        // `dep_nome_only_ctors_route_nome_through_to_string` pin
18263        // (792aa92) and
18264        // `dep_nome_list_ctors_route_nome_and_list_through_uniformly`
18265        // pin (6f5e0cd) on the same envelope's one- and two-slot
18266        // families. Distinct-per-axis fixtures rule out any two-axis
18267        // swap (`nome` ↔ `pin`, `pin` ↔ `value`, `value` ↔ `reason`,
18268        // etc.) that would still pass a same-fixture-per-axis pin.
18269        let nome = "sibling-teia";
18270        let pin = ":branch";
18271        let value = "feature/bar";
18272        let reason = "embedded space".to_string();
18273        let via_ctor = DepError::fonte_pin_shape(nome, pin, value, reason.clone());
18274        let via_struct_literal = DepError::FontePinShape {
18275            nome: nome.to_string(),
18276            pin: pin.to_string(),
18277            value: value.to_string(),
18278            reason: reason.clone(),
18279        };
18280        assert_eq!(
18281            via_ctor, via_struct_literal,
18282            "fonte_pin_shape ctor must route `nome` / `pin` / `value` \
18283             through `.to_string()` onto their canonical fields and \
18284             forward `reason` owned onto the canonical `reason` field \
18285             — a field-rename, silent-conversion, or axis-swap \
18286             regression surfaces here rather than at a downstream \
18287             diagnostic-shape mismatch",
18288        );
18289        let DepError::FontePinShape {
18290            nome: n,
18291            pin: p,
18292            value: v,
18293            reason: r,
18294        } = via_ctor
18295        else {
18296            panic!("fonte_pin_shape ctor produced non-FontePinShape variant")
18297        };
18298        assert_eq!(n, nome);
18299        assert_eq!(p, pin);
18300        assert_eq!(v, value);
18301        assert_eq!(r, reason);
18302    }
18303
18304    // ── `fonte_caminho_byte_ctors!` — the paired `{ nome: String,
18305    //    caminho: String, byte: u8 }` three-slot envelope on `DepError`,
18306    //    strict sibling of the peer `fonte_caminho_ctors!` (f85f145) on
18307    //    the same envelope's `{ nome: String, caminho: String }` two-slot
18308    //    shape, and of the peer `dep_nome_only_ctors!` (792aa92) on the
18309    //    same envelope's `{ nome: String }` one-slot shape.
18310
18311    #[test]
18312    fn fonte_caminho_control_char_ctor_matches_struct_literal_wrap() {
18313        assert_eq!(
18314            DepError::fonte_caminho_control_char("caixa-teia", "../caixa-teia\x00foo", 0x00),
18315            DepError::FonteCaminhoControlChar {
18316                nome: "caixa-teia".to_string(),
18317                caminho: "../caixa-teia\x00foo".to_string(),
18318                byte: 0x00,
18319            },
18320        );
18321    }
18322
18323    #[test]
18324    fn fonte_caminho_shell_redirection_ctor_matches_struct_literal_wrap() {
18325        assert_eq!(
18326            DepError::fonte_caminho_shell_redirection("caixa-teia", "../caixa-teia>log", b'>'),
18327            DepError::FonteCaminhoShellRedirection {
18328                nome: "caixa-teia".to_string(),
18329                caminho: "../caixa-teia>log".to_string(),
18330                byte: b'>',
18331            },
18332        );
18333    }
18334
18335    #[test]
18336    #[allow(
18337        clippy::too_many_lines,
18338        reason = "cross-axis routing pin sweeps twelve typed variants, one per \
18339                  byte-classification arm on the {nome,caminho,byte} envelope; \
18340                  the linear per-variant repetition is exactly what the sweep \
18341                  is pinning — a helper macro would hide the shape the fold is \
18342                  keying on"
18343    )]
18344    fn fonte_caminho_byte_ctors_route_nome_caminho_and_byte_through_to_string() {
18345        // Cross-axis routing pin: sweep the three constructor input axes
18346        // (`nome: &str`, `caminho: &str`, `byte: u8`) through a
18347        // non-default fixture triple against every generated arm in the
18348        // [`fonte_caminho_byte_ctors!`] macro, so any wrapper-side
18349        // lowercase / trim / truncate on the two `&str` axes — a silent
18350        // field swap between `nome` and `caminho`, or a silent
18351        // re-classification of the offending byte — surfaces here rather
18352        // than at a downstream diagnostic-shape mismatch. Peer of the
18353        // sibling `fonte_caminho_ctors_route_nome_and_caminho_through_
18354        // to_string` cross-axis routing pin on the same envelope's
18355        // two-slot family (f85f145) and of the sibling
18356        // `dep_nome_only_ctors_route_nome_through_to_string` pin on the
18357        // same envelope's one-slot family (792aa92), extended here onto
18358        // the `{ nome: String, caminho: String, byte: u8 }` three-slot
18359        // envelope so every substrate-primitive ctor family in
18360        // caixa-core's `DepError` envelope guarantees each field routes
18361        // the caller's value verbatim through `.to_string()` (or byte-
18362        // identity for `byte: u8`) in declared field order.
18363        let nome = "sibling-teia";
18364        let caminho = "../workspace/sibling";
18365        let byte = 0x2A_u8;
18366        let cases: [(DepError, DepError); 12] = [
18367            (
18368                DepError::fonte_caminho_control_char(nome, caminho, byte),
18369                DepError::FonteCaminhoControlChar {
18370                    nome: nome.to_string(),
18371                    caminho: caminho.to_string(),
18372                    byte,
18373                },
18374            ),
18375            (
18376                DepError::fonte_caminho_shell_redirection(nome, caminho, byte),
18377                DepError::FonteCaminhoShellRedirection {
18378                    nome: nome.to_string(),
18379                    caminho: caminho.to_string(),
18380                    byte,
18381                },
18382            ),
18383            (
18384                DepError::fonte_caminho_shell_glob(nome, caminho, byte),
18385                DepError::FonteCaminhoShellGlob {
18386                    nome: nome.to_string(),
18387                    caminho: caminho.to_string(),
18388                    byte,
18389                },
18390            ),
18391            (
18392                DepError::fonte_caminho_shell_subshell_grouping(nome, caminho, byte),
18393                DepError::FonteCaminhoShellSubshellGrouping {
18394                    nome: nome.to_string(),
18395                    caminho: caminho.to_string(),
18396                    byte,
18397                },
18398            ),
18399            (
18400                DepError::fonte_caminho_shell_brace_expansion(nome, caminho, byte),
18401                DepError::FonteCaminhoShellBraceExpansion {
18402                    nome: nome.to_string(),
18403                    caminho: caminho.to_string(),
18404                    byte,
18405                },
18406            ),
18407            (
18408                DepError::fonte_caminho_shell_bracket_expansion(nome, caminho, byte),
18409                DepError::FonteCaminhoShellBracketExpansion {
18410                    nome: nome.to_string(),
18411                    caminho: caminho.to_string(),
18412                    byte,
18413                },
18414            ),
18415            (
18416                DepError::fonte_caminho_shell_quote_grouping(nome, caminho, byte),
18417                DepError::FonteCaminhoShellQuoteGrouping {
18418                    nome: nome.to_string(),
18419                    caminho: caminho.to_string(),
18420                    byte,
18421                },
18422            ),
18423            (
18424                DepError::fonte_caminho_shell_comment(nome, caminho, byte),
18425                DepError::FonteCaminhoShellComment {
18426                    nome: nome.to_string(),
18427                    caminho: caminho.to_string(),
18428                    byte,
18429                },
18430            ),
18431            (
18432                DepError::fonte_caminho_url_percent_encoding(nome, caminho, byte),
18433                DepError::FonteCaminhoUrlPercentEncoding {
18434                    nome: nome.to_string(),
18435                    caminho: caminho.to_string(),
18436                    byte,
18437                },
18438            ),
18439            (
18440                DepError::fonte_caminho_shell_variable_expansion(nome, caminho, byte),
18441                DepError::FonteCaminhoShellVariableExpansion {
18442                    nome: nome.to_string(),
18443                    caminho: caminho.to_string(),
18444                    byte,
18445                },
18446            ),
18447            (
18448                DepError::fonte_caminho_shell_history_expansion(nome, caminho, byte),
18449                DepError::FonteCaminhoShellHistoryExpansion {
18450                    nome: nome.to_string(),
18451                    caminho: caminho.to_string(),
18452                    byte,
18453                },
18454            ),
18455            (
18456                DepError::fonte_caminho_shell_history_substitution(nome, caminho, byte),
18457                DepError::FonteCaminhoShellHistorySubstitution {
18458                    nome: nome.to_string(),
18459                    caminho: caminho.to_string(),
18460                    byte,
18461                },
18462            ),
18463        ];
18464        for (via_ctor, via_struct_literal) in cases {
18465            assert_eq!(
18466                via_ctor, via_struct_literal,
18467                "fonte_caminho_byte_ctors!-generated ctor must route \
18468                 (nome, caminho, byte) through `.to_string()` / byte-\
18469                 identity in declared field order — a field-swap or \
18470                 silent-conversion regression surfaces here rather than \
18471                 at a downstream diagnostic-shape mismatch",
18472            );
18473        }
18474    }
18475
18476    #[test]
18477    fn dep_list_as_ref_str_routes_through_as_str_accessor() {
18478        // Fail-before-pass-after byte-parity pin on the lifted
18479        // `impl AsRef<str> for DepList` — asserts the standard-
18480        // library trait impl and the substrate-primitive
18481        // [`super::DepList::as_str`] `pub const fn` accessor resolve
18482        // to the same `&str` per instance across the two-arm closed
18483        // set, so any future silent detour that routes the impl
18484        // through a divergent projection (a per-arm inline
18485        // `match self { DepList::Prod => ":deps", … }` re-inlining
18486        // that opens a compile-time link to the un-lifted arm-literal,
18487        // a swap onto a second projection axis) trips at caixa-core
18488        // test time under `PartialEq` rather than at a downstream
18489        // `impl AsRef<str>`-bound consumer's silent split. Sweeps
18490        // every one of the two arms [`super::DepList::ALL`] carries
18491        // so no arm's projection is covered only by the sibling
18492        // `Display` path. Peer of the sibling
18493        // `caixa_dialeto_as_ref_str_routes_through_as_str_accessor`
18494        // (1723611) on the top-level dialect-classification closed-
18495        // set typed enum, and the peer
18496        // `rate_limit_unit_as_ref_str_routes_through_as_suffix_accessor`
18497        // (d8136db) pin on the M3 `:politicas :rate-limit` closed-set
18498        // typed enum — the pins together close the substrate
18499        // primitive's `AsRef<str>` projection axis onto the seventh
18500        // (and last unlifted) closed-set typed enum on the caixa
18501        // surface.
18502        for &list in super::DepList::ALL {
18503            assert_eq!(
18504                <super::DepList as AsRef<str>>::as_ref(&list),
18505                list.as_str(),
18506                "AsRef<str> impl on DepList::{list:?} must byte-equal \
18507                 DepList::as_str on the same instance — divergence \
18508                 signals a silent detour off the substrate-primitive \
18509                 accessor"
18510            );
18511        }
18512    }
18513
18514    #[test]
18515    fn dep_list_as_ref_str_routes_through_display_via_shared_accessor() {
18516        // Fail-before-pass-after byte-parity pin on the three-path
18517        // convergence discipline the [`super::DepList`] two-list
18518        // dep-graph closed-set typed enum now carries on the `&str`-
18519        // projection axis: `<DepList as AsRef<str>>::as_ref(&v)` (the
18520        // newly lifted impl), `format!("{v}")` (the pre-existing
18521        // [`fmt::Display`] impl), and `v.as_str()` (the substrate-
18522        // primitive `pub const fn` accessor both trait impls delegate
18523        // through) must resolve to the same byte-string on every
18524        // instance across the two-arm closed set. Refuses any future
18525        // divergence between the two trait impls (a stray
18526        // [`fmt::Display::fmt`] rewrite that hand-rolls the arms
18527        // rather than delegating through the shared accessor; a
18528        // hypothetical `AsRef<str>` rewrite that inlines a per-arm
18529        // literal cascade) that would silently split the two
18530        // projection paths of the same closed-set typed enum. Mirrors
18531        // the sibling three-path-convergence discipline the peer
18532        // [`crate::CaixaDialeto`] typed enum carries
18533        // (`caixa_dialeto_as_ref_str_routes_through_display_via_shared_accessor`,
18534        // 1723611), the peer [`crate::aplicacao::RateLimitUnit`] triple
18535        // (`rate_limit_unit_as_ref_str_routes_through_display_via_shared_accessor`,
18536        // d8136db), the peer [`crate::CaixaKind`] triple
18537        // (`caixa_kind_as_ref_str_routes_through_display_via_shared_accessor`,
18538        // cd2091f), and the [`crate::CaixaVersion`] typed newtype
18539        // triple (`caixa_version_as_ref_str_routes_through_display_via_shared_accessor`,
18540        // 16d5c7e).
18541        for &list in super::DepList::ALL {
18542            let via_as_ref: &str = <super::DepList as AsRef<str>>::as_ref(&list);
18543            let via_display: String = format!("{list}");
18544            let via_accessor: &str = list.as_str();
18545            assert_eq!(via_as_ref, via_accessor);
18546            assert_eq!(via_display, via_accessor);
18547            assert_eq!(via_as_ref, via_display.as_str());
18548        }
18549    }
18550
18551    #[test]
18552    fn dep_list_try_from_str_routes_through_from_wire_accessor() {
18553        // Fail-before-pass-after byte-parity pin on the newly lifted
18554        // `impl TryFrom<&str> for DepList` — asserts the standard-
18555        // library trait impl and the substrate-primitive
18556        // [`super::DepList::from_wire`] `Option<Self>` accessor resolve
18557        // to the same two-arm accept-set across every arm the
18558        // exhaustive [`super::DepList::ALL`] slice enumerates. Peer of
18559        // the sibling
18560        // `restart_strategy_try_from_str_routes_through_from_wire_accessor`
18561        // (5b828ed), `caixa_kind_try_from_str_routes_through_from_wire_accessor`,
18562        // and the 12 other substrate-wide trait-idiomatic reverse-
18563        // projection routes-through pins — closes the campaign's
18564        // completeness gap on the two-list dep-graph closed-set enum.
18565        for &list in super::DepList::ALL {
18566            let wire = list.as_str();
18567            assert_eq!(
18568                <super::DepList as TryFrom<&str>>::try_from(wire),
18569                Ok(list),
18570                "TryFrom<&str> impl on DepList must round-trip \
18571                 DepList::{list:?}.as_str() = {wire:?} back to \
18572                 Ok(DepList::{list:?}) — divergence from \
18573                 DepList::from_wire signals a silent detour off the \
18574                 substrate-primitive accessor"
18575            );
18576            assert_eq!(
18577                <super::DepList as TryFrom<&str>>::try_from(wire).ok(),
18578                super::DepList::from_wire(wire),
18579                "TryFrom<&str> ok()-projection on {wire:?} must byte-equal \
18580                 DepList::from_wire on the same input"
18581            );
18582        }
18583    }
18584
18585    #[test]
18586    fn dep_list_try_from_str_rejects_unknown_byte_strings() {
18587        // Rejection witness on the `impl TryFrom<&str> for DepList` —
18588        // sweeps candidate byte-strings outside the two-arm accept-set
18589        // the sibling [`super::DepList::as_str`] emits (`:deps` /
18590        // `:deps-dev`) and asserts every one lands on `Err(())`, so a
18591        // future accidental widening of the trait impl's accept-set (a
18592        // stray case-fold path, a silent inclusion of a rebrand alias
18593        // like `":packages"`, an English rebrand `":dev-deps"` in
18594        // reverse arm-order that would silently swap the two arms) trips
18595        // at caixa-core test time. Peer of the sibling
18596        // `restart_strategy_try_from_str_rejects_unknown_byte_strings`
18597        // (5b828ed) rejection witness.
18598        let rejected: &[&str] = &[
18599            "",
18600            " ",
18601            "\t",
18602            "\n",
18603            ":deps ",
18604            " :deps",
18605            ":DEPS",
18606            ":Deps",
18607            ":Deps-Dev",
18608            ":deps_dev",
18609            ":deps-development",
18610            ":dev-deps",
18611            ":packages",
18612            ":packages-dev",
18613            "deps",
18614            "deps-dev",
18615            "Prod",
18616            "Dev",
18617            "prod",
18618            "dev",
18619            "\":deps\"",
18620            "\":deps-dev\"",
18621            ":deps\n",
18622            ":deps-dev\n",
18623        ];
18624        for &input in rejected {
18625            assert_eq!(
18626                <super::DepList as TryFrom<&str>>::try_from(input),
18627                Err(()),
18628                "TryFrom<&str> impl on DepList must reject unknown \
18629                 byte-string {input:?} — divergence from \
18630                 DepList::from_wire on the same input signals a silent \
18631                 accept-set widening past the two lifted \
18632                 crate::render::DEP_AUTHOR_KEY_DEPS* wire constants"
18633            );
18634            assert_eq!(
18635                <super::DepList as TryFrom<&str>>::try_from(input).ok(),
18636                super::DepList::from_wire(input),
18637                "TryFrom<&str> ok()-projection on {input:?} must byte-equal \
18638                 DepList::from_wire on the same input — divergence signals \
18639                 the two reverse-projection paths have drifted onto \
18640                 different accept-sets"
18641            );
18642        }
18643    }
18644
18645    #[test]
18646    fn dep_list_from_into_static_str_routes_through_as_str_accessor() {
18647        // Fail-before-pass-after byte-parity pin on the newly lifted
18648        // `impl From<DepList> for &'static str` — asserts the standard-
18649        // library trait impl and the substrate-primitive
18650        // [`super::DepList::as_str`] `pub const fn` accessor resolve to
18651        // the same two-arm emit-set across every arm the exhaustive
18652        // [`super::DepList::ALL`] slice enumerates. Materializes the
18653        // `<&'static str as From<DepList>>::from` output in a
18654        // `const`-shape binding to make the `'static` lifetime promise
18655        // a build-time invariant — a future accidental downgrade of
18656        // either arm to a non-`&'static str` (a `String::leak()`-
18657        // produced return, a `Box::leak`-cast) trips at caixa-core
18658        // build time rather than at a downstream `'static`-bound
18659        // consumer. Peer of the sibling
18660        // `restart_strategy_from_into_static_str_routes_through_as_str_accessor`
18661        // (523157d) and the 13 other substrate-wide forward-projection
18662        // routes-through pins.
18663        const PROD: &str = super::DepList::Prod.as_str();
18664        const DEV: &str = super::DepList::Dev.as_str();
18665        for &list in super::DepList::ALL {
18666            let via_trait: &'static str = <&'static str as From<super::DepList>>::from(list);
18667            let via_method: &'static str = list.as_str();
18668            assert_eq!(
18669                via_trait, via_method,
18670                "From<DepList> for &'static str impl must round-trip \
18671                 DepList::{list:?} to the same lifted \
18672                 crate::render::DEP_AUTHOR_KEY_DEPS* const \
18673                 DepList::as_str returns — divergence signals a silent \
18674                 detour off the substrate-primitive accessor"
18675            );
18676            let via_into: &'static str = list.into();
18677            assert_eq!(
18678                via_into, via_method,
18679                "Into<&'static str>::into on DepList::{list:?} must \
18680                 byte-equal DepList::as_str on the same input — the \
18681                 blanket-derived Into shape must resolve to the same \
18682                 as_str dispatch as the explicit From impl"
18683            );
18684        }
18685        assert_eq!(
18686            [PROD, DEV],
18687            [
18688                crate::render::DEP_AUTHOR_KEY_DEPS,
18689                crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
18690            ],
18691            "const-context DepList::as_str must resolve to the two lifted \
18692             DEP_AUTHOR_KEY_DEPS* consts — a future accidental downgrade \
18693             of either arm to a non-const or non-static byte-string breaks \
18694             the `&'static str`-lifetime promise the paired \
18695             From<DepList> for &'static str impl carries by construction"
18696        );
18697    }
18698
18699    #[test]
18700    fn dep_list_from_into_static_str_and_as_str_partition_the_emit_set() {
18701        // Cross-axis partition pin: the paired trait-idiomatic
18702        // `From<DepList> for &'static str` forward projection and the
18703        // method-named [`super::DepList::as_str`] forward projection
18704        // must resolve identically on every arm, locking the two paths
18705        // together so any future detour trips at caixa-core test time.
18706        // Then a round-trip witness: every arm's forward `From` output
18707        // re-parses through the paired trait-idiomatic reverse
18708        // `TryFrom<&str>` back to the original variant, closing the
18709        // two-way `DepList ↔ &'static str` round-trip on the trait-
18710        // idiomatic axis pair, mirroring the pre-existing method-named
18711        // `as_str` + `from_wire` round-trip. Peer of the sibling
18712        // `restart_strategy_from_into_static_str_and_as_str_partition_the_emit_set`
18713        // (523157d).
18714        for &list in super::DepList::ALL {
18715            let via_trait: &'static str = <&'static str as From<super::DepList>>::from(list);
18716            let via_method: &'static str = list.as_str();
18717            assert_eq!(
18718                via_trait, via_method,
18719                "From<DepList> for &'static str and DepList::as_str must \
18720                 resolve identically on DepList::{list:?} — divergence \
18721                 signals the two forward-projection paths have drifted \
18722                 onto different emit-sets"
18723            );
18724        }
18725        for &list in super::DepList::ALL {
18726            let emitted: &'static str = list.into();
18727            let re_parsed: Result<super::DepList, ()> =
18728                <super::DepList as TryFrom<&str>>::try_from(emitted);
18729            assert_eq!(
18730                re_parsed,
18731                Ok(list),
18732                "trait-idiomatic axis pair must round-trip \
18733                 DepList::{list:?} through `.into::<&'static str>()` and \
18734                 back through `TryFrom<&str>` — a break signals the \
18735                 forward-emit and reverse-parse axes have drifted onto \
18736                 different vocabularies"
18737            );
18738        }
18739    }
18740
18741    #[test]
18742    fn dep_list_from_borrowed_into_static_str_routes_through_as_str_accessor() {
18743        // Fail-before-pass-after byte-parity pin on the newly lifted
18744        // `impl From<&DepList> for &'static str` — asserts the borrowed-
18745        // input standard-library trait impl and the substrate-primitive
18746        // [`super::DepList::as_str`] `pub const fn` accessor resolve to
18747        // the same two-arm emit-set across every arm the exhaustive
18748        // [`super::DepList::ALL`] slice enumerates. Rust's `From` trait
18749        // does not auto-derive the borrowed-input sibling from a paired
18750        // owned-input impl (no `impl<T, U> From<&T> for U where T: Copy,
18751        // U: From<T>` blanket in `core`), so the borrowed-input axis is
18752        // a distinct trait-idiomatic surface that a `.iter().map(Into::into)`
18753        // shape over [`super::DepList::ALL`] (whose iterator yields
18754        // `&DepList`, not `DepList`) reaches through this impl and no
18755        // other — the paired owned-input [`From<DepList>`] impl requires
18756        // an explicit `.copied()` / dereference before the trait fires.
18757        // Materializes the `<&'static str as From<&DepList>>::from`
18758        // output in a `const`-shape binding to make the `'static`
18759        // lifetime promise a build-time invariant.
18760        const PROD: &str = super::DepList::Prod.as_str();
18761        const DEV: &str = super::DepList::Dev.as_str();
18762        for list in super::DepList::ALL {
18763            let via_trait: &'static str = <&'static str as From<&super::DepList>>::from(list);
18764            let via_method: &'static str = list.as_str();
18765            assert_eq!(
18766                via_trait, via_method,
18767                "From<&DepList> for &'static str impl must round-trip \
18768                 &DepList::{list:?} to the same lifted \
18769                 crate::render::DEP_AUTHOR_KEY_DEPS* const \
18770                 DepList::as_str returns — divergence signals a silent \
18771                 detour off the substrate-primitive accessor"
18772            );
18773            let via_into: &'static str = list.into();
18774            assert_eq!(
18775                via_into, via_method,
18776                "Into<&'static str>::into on &DepList::{list:?} must \
18777                 byte-equal DepList::as_str on the same input — the \
18778                 blanket-derived Into shape must resolve to the same \
18779                 as_str dispatch as the explicit From impl"
18780            );
18781        }
18782        assert_eq!(
18783            [PROD, DEV],
18784            [
18785                crate::render::DEP_AUTHOR_KEY_DEPS,
18786                crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
18787            ],
18788            "const-context DepList::as_str must resolve to the two lifted \
18789             DEP_AUTHOR_KEY_DEPS* consts — the borrowed-input \
18790             From<&DepList> for &'static str impl inherits its `'static` \
18791             lifetime promise from the same accessor the owned-input \
18792             sibling routes through"
18793        );
18794    }
18795
18796    #[test]
18797    fn dep_list_from_owned_and_borrowed_into_static_str_agree_on_every_arm() {
18798        // Cross-axis partition pin: the paired trait-idiomatic
18799        // owned-input `From<DepList> for &'static str` (523157d
18800        // campaign-shape) and borrowed-input `From<&DepList> for
18801        // &'static str` (this lift) forward projections must resolve
18802        // identically on every arm, locking the two input-shape paths
18803        // together so any future detour trips at caixa-core test time.
18804        // Then a witness that a `.iter().map(Into::into)` pipe over
18805        // [`super::DepList::ALL`] (whose iterator yields `&DepList`)
18806        // materializes the two-arm accept-set through the borrowed-
18807        // input axis alone — the exact shape a future M4 admission-
18808        // webhook rejection body composer, a future substrate-wide
18809        // per-arm diagnostic column, or a
18810        // `HashMap::<&'static str, DepList>::from_iter(DepList::ALL.iter()
18811        //     .map(|l| (l.into(), *l)))`-style per-list lookup reaches
18812        // through — closing the two-way owned/borrowed input-shape
18813        // symmetry on the forward-projection trait-idiomatic axis.
18814        for &list in super::DepList::ALL {
18815            let owned: &'static str = <&'static str as From<super::DepList>>::from(list);
18816            let borrowed: &'static str = <&'static str as From<&super::DepList>>::from(&list);
18817            assert_eq!(
18818                owned, borrowed,
18819                "From<DepList> and From<&DepList> for &'static str must \
18820                 resolve identically on DepList::{list:?} — divergence \
18821                 signals the owned-input and borrowed-input forward-\
18822                 projection paths have drifted onto different emit-sets"
18823            );
18824        }
18825        let via_iter: Vec<&'static str> = super::DepList::ALL.iter().map(Into::into).collect();
18826        let via_method: Vec<&'static str> =
18827            super::DepList::ALL.iter().map(|l| l.as_str()).collect();
18828        assert_eq!(
18829            via_iter, via_method,
18830            "`.iter().map(Into::into)` over DepList::ALL must byte-equal \
18831             `.iter().map(|l| l.as_str())` on every arm — the borrowed-\
18832             input `From<&DepList> for &'static str` axis is what makes \
18833             the `.iter().map(Into::into)` shape route through the \
18834             substrate-primitive `DepList::as_str` accessor rather than \
18835             through a per-call-site `.copied()` / dereference detour"
18836        );
18837    }
18838
18839    #[test]
18840    fn dep_list_from_into_owned_string_routes_through_as_str_accessor() {
18841        // Fail-before-pass-after byte-parity pin on the newly lifted
18842        // `impl From<DepList> for String` — asserts the owned-`String`
18843        // -returning standard-library trait impl and the substrate-
18844        // primitive [`super::DepList::as_str`] `pub const fn` accessor
18845        // resolve to the same two-arm emit-set across every arm the
18846        // exhaustive [`super::DepList::ALL`] slice enumerates. Rust's
18847        // standard library does not carry a blanket
18848        // `impl<T: AsRef<str>> From<T> for String` (nor an
18849        // `impl<T: fmt::Display> From<T> for String`), so the
18850        // owned-`String` forward-projection axis is a distinct trait-
18851        // idiomatic surface that a `let key: String = list.into();`-
18852        // shaped call site reaches through this impl and no other — the
18853        // paired sibling `From<DepList> for &'static str` impl forces
18854        // every owned-`String` call site through an explicit
18855        // `.to_owned()` / `String::from` restatement. Peer of the
18856        // first-mover
18857        // [`crate::supervisor::tests::restart_strategy_from_into_owned_string_routes_through_as_str_accessor`]
18858        // (7baa18a), the second-peer
18859        // [`crate::supervisor::tests::restart_policy_from_into_owned_string_routes_through_as_str_accessor`]
18860        // (7851725), the third-peer
18861        // [`crate::kind::tests::caixa_kind_from_into_owned_string_routes_through_as_str_accessor`]
18862        // (231a18c), and the fourth-peer
18863        // [`crate::dialeto::tests::caixa_dialeto_from_into_owned_string_routes_through_as_str_accessor`]
18864        // (88942cd) — extends the trait-idiomatic owned-`String`
18865        // forward-projection axis onto the fifth closed-set fieldless
18866        // typed enum on the caixa surface (the two-list dep-graph axis).
18867        for &variant in super::DepList::ALL {
18868            let via_trait: String = <String as From<super::DepList>>::from(variant);
18869            let via_method: &'static str = variant.as_str();
18870            assert_eq!(
18871                via_trait.as_str(),
18872                via_method,
18873                "From<DepList> for String impl must round-trip \
18874                 DepList::{variant:?} to the same lifted \
18875                 crate::render::DEP_AUTHOR_KEY_DEPS* const \
18876                 DepList::as_str returns — divergence signals a silent \
18877                 detour off the substrate-primitive accessor"
18878            );
18879            let via_into: String = variant.into();
18880            assert_eq!(
18881                via_into.as_str(),
18882                via_method,
18883                "Into<String>::into on DepList::{variant:?} must \
18884                 byte-equal DepList::as_str on the same input — the \
18885                 blanket-derived Into shape must resolve to the same \
18886                 as_str dispatch as the explicit From impl"
18887            );
18888        }
18889    }
18890
18891    #[test]
18892    fn dep_list_from_into_owned_string_and_static_str_agree_on_every_arm() {
18893        // Cross-axis partition pin: the paired trait-idiomatic
18894        // owned-`String` `From<DepList> for String` (this lift) and
18895        // owned-`&'static str` `From<DepList> for &'static str`
18896        // (523157d campaign-shape) forward projections must resolve
18897        // identically on every arm, locking the two return-type-shape
18898        // paths together so any future detour trips at caixa-core test
18899        // time. Also byte-parity witness against the sibling
18900        // [`ToString::to_string`] surface routed through
18901        // [`std::fmt::Display`] — the three owned-heap-string paths
18902        // (`.into::<String>()`, `String::from`, `.to_string()`) must
18903        // resolve identically on every arm so a future consumer that
18904        // picks any of the three lands on the same two-arm lifted
18905        // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
18906        // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] accept-set.
18907        // Then a `.iter().copied().map(String::from)` pipe witness
18908        // over [`super::DepList::ALL`] that materializes the two-arm
18909        // accept-set through the owned-`String` axis alone — the exact
18910        // shape a future M4 admission-webhook rejection body composer
18911        // or a
18912        // `HashMap::<String, DepList>::from_iter(
18913        //     DepList::ALL.iter().copied().map(|l| (l.into(), l)))`-
18914        // style owned-key per-list lookup reaches through — closing the
18915        // owned-`String` forward-projection axis's iterator-pipe shape.
18916        // Then a direct round-trip witness through the paired
18917        // trait-idiomatic reverse [`TryFrom<&str>`] axis on the
18918        // owned-`String`'s [`String::as_str`] borrow that closes the
18919        // two-way `Self → String → Self` round-trip on the trait-
18920        // idiomatic owned-`String` forward + reverse axis pair.
18921        //
18922        // Unlike the peer [`crate::CaixaKind`] axis pair (whose forward
18923        // `From` emit lands on the lowercase Portuguese `as_str`
18924        // diagnostic vocabulary while the reverse `TryFrom<&str>`
18925        // parses the `PascalCase` `wire_name` author-surface vocabulary,
18926        // forcing the round-trip through an intermediate
18927        // [`crate::CaixaKind::wire_name`] hop), [`super::DepList`]'s
18928        // [`super::DepList::as_str`] emit and [`super::DepList::from_wire`]
18929        // parse resolve through the same lifted
18930        // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
18931        // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] consts by
18932        // construction (there is no wire/diagnostic axis split on this
18933        // enum), so the owned-`String` forward axis and the reverse
18934        // axis compose directly — matching the peer
18935        // [`crate::supervisor::RestartStrategy`] /
18936        // [`crate::supervisor::RestartPolicy`] /
18937        // [`crate::CaixaDialeto`] owned-`String` axis pairs.
18938        for &list in super::DepList::ALL {
18939            let owned_string: String = <String as From<super::DepList>>::from(list);
18940            let owned_static: &'static str = <&'static str as From<super::DepList>>::from(list);
18941            assert_eq!(
18942                owned_string.as_str(),
18943                owned_static,
18944                "From<DepList> for String and From<DepList> for \
18945                 &'static str must resolve identically on \
18946                 DepList::{list:?} — divergence signals the owned-\
18947                 `String` and owned-`&'static str` forward-projection \
18948                 return-type-shape paths have drifted onto different \
18949                 emit-sets"
18950            );
18951            let via_to_string: String = list.to_string();
18952            assert_eq!(
18953                owned_string, via_to_string,
18954                "From<DepList> for String must byte-equal \
18955                 DepList::to_string on DepList::{list:?} — divergence \
18956                 signals the trait-idiomatic owned-`String` forward-\
18957                 projection axis and the ToString-through-Display axis \
18958                 have drifted onto different emit-sets"
18959            );
18960        }
18961        let via_iter: Vec<String> = super::DepList::ALL
18962            .iter()
18963            .copied()
18964            .map(String::from)
18965            .collect();
18966        let via_method: Vec<String> = super::DepList::ALL
18967            .iter()
18968            .map(|l| l.as_str().to_owned())
18969            .collect();
18970        assert_eq!(
18971            via_iter, via_method,
18972            "`.iter().copied().map(String::from)` over DepList::ALL must \
18973             byte-equal `.iter().map(|l| l.as_str().to_owned())` on \
18974             every arm — the owned-`String` `From<DepList> for String` \
18975             axis is what makes the `String::from` composition route \
18976             through the substrate-primitive `DepList::as_str` accessor \
18977             rather than through a per-call-site `.to_owned()` / \
18978             `String::from(list.as_str())` detour"
18979        );
18980        for &variant in super::DepList::ALL {
18981            let emitted: String = variant.into();
18982            let re_parsed: Result<super::DepList, ()> =
18983                <super::DepList as TryFrom<&str>>::try_from(emitted.as_str());
18984            assert_eq!(
18985                re_parsed,
18986                Ok(variant),
18987                "trait-idiomatic owned-`String` forward-projection + \
18988                 reverse-projection axis pair must round-trip \
18989                 DepList::{variant:?} through `.into::<String>()` and \
18990                 back through `TryFrom<&str>` on the owned-`String`'s \
18991                 String::as_str borrow — a break signals the owned-\
18992                 `String` forward-emit and reverse-parse axes have \
18993                 drifted onto different vocabularies (unlike the peer \
18994                 CaixaKind axis pair, DepList's forward emit and \
18995                 reverse parse share the same lifted \
18996                 DEP_AUTHOR_KEY_DEPS* consts by construction, so the \
18997                 round-trip composes directly)"
18998            );
18999        }
19000    }
19001
19002    #[test]
19003    fn dep_list_from_into_borrowed_owned_string_routes_through_as_str_accessor() {
19004        // Fail-before-pass-after byte-parity pin on the newly lifted
19005        // `impl From<&DepList> for String` — asserts the borrowed-input
19006        // owned-`String`-returning standard-library trait impl and the
19007        // substrate-primitive [`super::DepList::as_str`] `pub const fn`
19008        // accessor resolve to the same two-arm emit-set across every
19009        // arm the exhaustive [`super::DepList::ALL`] slice enumerates.
19010        // Rust's standard library does not carry a blanket
19011        // `impl<T: AsRef<str>> From<&T> for String` (nor an
19012        // `impl<T: fmt::Display> From<&T> for String`), so the
19013        // borrowed-input owned-`String` forward-projection axis is a
19014        // distinct trait-idiomatic surface that a
19015        // `let key: String = (&list).into();`-shaped call site reaches
19016        // through this impl and no other — the paired sibling
19017        // `From<DepList> for String` impl forces every borrowed-input
19018        // call site through an explicit `Copy` deref
19019        // (`String::from(*list)`) or an `.as_str().to_owned()` /
19020        // `.to_string()` detour. Peer of the first-mover
19021        // [`crate::supervisor::tests::restart_strategy_from_into_borrowed_owned_string_routes_through_as_str_accessor`]
19022        // (579385f) and the second-peer
19023        // [`crate::supervisor::tests::restart_policy_from_into_borrowed_owned_string_routes_through_as_str_accessor`]
19024        // (8465740) — extends the trait-idiomatic borrowed-input owned-
19025        // `String` forward-projection axis off the M2 OTP-shape sibling
19026        // axis pair onto the first non-M2 closed-set fieldless typed
19027        // enum peer (the two-list dep-graph axis).
19028        for &variant in super::DepList::ALL {
19029            let via_trait: String = <String as From<&super::DepList>>::from(&variant);
19030            let via_method: &'static str = variant.as_str();
19031            assert_eq!(
19032                via_trait.as_str(),
19033                via_method,
19034                "From<&DepList> for String impl must round-trip \
19035                 &DepList::{variant:?} to the same lifted \
19036                 crate::render::DEP_AUTHOR_KEY_DEPS* const \
19037                 DepList::as_str returns — divergence signals a silent \
19038                 detour off the substrate-primitive accessor"
19039            );
19040            let via_into: String = (&variant).into();
19041            assert_eq!(
19042                via_into.as_str(),
19043                via_method,
19044                "Into<String>::into on &DepList::{variant:?} must \
19045                 byte-equal DepList::as_str on the same input — the \
19046                 blanket-derived Into shape must resolve to the same \
19047                 as_str dispatch as the explicit From impl"
19048            );
19049        }
19050    }
19051
19052    #[test]
19053    fn dep_list_from_into_borrowed_owned_string_agrees_with_paired_axes_on_every_arm() {
19054        // Cross-axis partition pin: the newly lifted trait-idiomatic
19055        // borrowed-input owned-`String` `From<&DepList> for String`
19056        // (this lift), the paired owned-input owned-`String`
19057        // `From<DepList> for String` (32b0ee8), the paired borrowed-
19058        // input owned-`&'static str` `From<&DepList> for &'static str`
19059        // (64aa742), and the paired owned-input owned-`&'static str`
19060        // `From<DepList> for &'static str` (3455cbf) — every corner of
19061        // the `{Self, &Self} × {&'static str, String}` 2×2 trait-
19062        // idiomatic projection family — must resolve identically on
19063        // every arm, locking the four return-shape × input-shape paths
19064        // together so any future detour trips at caixa-core test time.
19065        // Also byte-parity witness against the sibling
19066        // [`ToString::to_string`] surface routed through
19067        // [`std::fmt::Display`] and a direct round-trip witness through
19068        // the paired trait-idiomatic reverse [`TryFrom<&str>`] axis on
19069        // the owned-`String`'s [`String::as_str`] borrow that closes
19070        // the two-way `&Self → String → Self` round-trip on the trait-
19071        // idiomatic borrowed-input owned-`String` forward + reverse
19072        // axis pair. Peer of the first-mover
19073        // [`crate::supervisor::tests::restart_strategy_from_into_borrowed_owned_string_agrees_with_paired_axes_on_every_arm`]
19074        // (579385f) and the second-peer
19075        // [`crate::supervisor::tests::restart_policy_from_into_borrowed_owned_string_agrees_with_paired_axes_on_every_arm`]
19076        // (8465740) — closes the whole `{Self, &Self} × {&'static str,
19077        // String}` 2×2 projection corner on the third substrate-wide
19078        // closed-set fieldless typed enum peer (the two-list dep-graph
19079        // axis, first outside the M2 OTP-shape sibling pair).
19080        //
19081        // Unlike the peer [`crate::CaixaKind`] axis pair (whose forward
19082        // `From` emit lands on the lowercase Portuguese `as_str`
19083        // diagnostic vocabulary while the reverse `TryFrom<&str>`
19084        // parses the `PascalCase` `wire_name` author-surface vocabulary,
19085        // forcing the round-trip through an intermediate
19086        // [`crate::CaixaKind::wire_name`] hop), [`super::DepList`]'s
19087        // [`super::DepList::as_str`] emit and
19088        // [`super::DepList::from_wire`] parse resolve through the same
19089        // lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19090        // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] consts by
19091        // construction (there is no wire/diagnostic axis split on this
19092        // enum), so the borrowed-input owned-`String` forward axis and
19093        // the reverse axis compose directly — matching the peer
19094        // [`crate::supervisor::RestartStrategy`] /
19095        // [`crate::supervisor::RestartPolicy`] borrowed-input owned-
19096        // `String` axis pairs.
19097        for &list in super::DepList::ALL {
19098            let borrowed_string: String = <String as From<&super::DepList>>::from(&list);
19099            let owned_string: String = <String as From<super::DepList>>::from(list);
19100            let borrowed_static: &'static str =
19101                <&'static str as From<&super::DepList>>::from(&list);
19102            let owned_static: &'static str = <&'static str as From<super::DepList>>::from(list);
19103            assert_eq!(
19104                borrowed_string, owned_string,
19105                "From<&DepList> for String and From<DepList> for String \
19106                 must resolve identically on DepList::{list:?} — \
19107                 divergence signals the borrowed-input and owned-input \
19108                 owned-`String` forward-projection input-shape paths \
19109                 have drifted onto different emit-sets"
19110            );
19111            assert_eq!(
19112                borrowed_string.as_str(),
19113                borrowed_static,
19114                "From<&DepList> for String and From<&DepList> for \
19115                 &'static str must resolve identically on \
19116                 DepList::{list:?} — divergence signals the borrowed-\
19117                 input `&'static str` and owned-`String` return-shape \
19118                 paths have drifted onto different emit-sets"
19119            );
19120            assert_eq!(
19121                borrowed_string.as_str(),
19122                owned_static,
19123                "From<&DepList> for String and From<DepList> for \
19124                 &'static str must resolve identically on \
19125                 DepList::{list:?} — divergence signals a break in the \
19126                 diagonal corner of the {{Self, &Self}} × {{&'static \
19127                 str, String}} 2×2 trait-idiomatic projection family"
19128            );
19129            let via_to_string: String = list.to_string();
19130            assert_eq!(
19131                borrowed_string, via_to_string,
19132                "From<&DepList> for String must byte-equal \
19133                 DepList::to_string on DepList::{list:?} — divergence \
19134                 signals the trait-idiomatic borrowed-input owned-\
19135                 `String` forward-projection axis and the ToString-\
19136                 through-Display axis have drifted onto different \
19137                 emit-sets"
19138            );
19139        }
19140        let via_iter: Vec<String> = super::DepList::ALL.iter().map(String::from).collect();
19141        let via_method: Vec<String> = super::DepList::ALL
19142            .iter()
19143            .map(|l| l.as_str().to_owned())
19144            .collect();
19145        assert_eq!(
19146            via_iter, via_method,
19147            "`.iter().map(String::from)` over DepList::ALL — a call \
19148             site whose iteration axis holds `&DepList` by construction \
19149             — must byte-equal `.iter().map(|l| l.as_str().to_owned())` \
19150             on every arm — the borrowed-input owned-`String` \
19151             `From<&DepList> for String` axis is what makes the \
19152             `String::from` composition route through the substrate-\
19153             primitive `DepList::as_str` accessor without a spurious \
19154             `Copy` deref (which would only be reachable through the \
19155             owned-input `From<DepList> for String` axis by first \
19156             calling `.copied()` on the iterator)"
19157        );
19158        for &variant in super::DepList::ALL {
19159            let emitted: String = (&variant).into();
19160            let re_parsed: Result<super::DepList, ()> =
19161                <super::DepList as TryFrom<&str>>::try_from(emitted.as_str());
19162            assert_eq!(
19163                re_parsed,
19164                Ok(variant),
19165                "trait-idiomatic borrowed-input owned-`String` \
19166                 forward-projection + reverse-projection axis pair must \
19167                 round-trip &DepList::{variant:?} through \
19168                 `.into::<String>()` on the borrowed-input surface and \
19169                 back through `TryFrom<&str>` on the owned-`String`'s \
19170                 String::as_str borrow — a break signals the \
19171                 borrowed-input owned-`String` forward-emit and \
19172                 reverse-parse axes have drifted onto different \
19173                 vocabularies (unlike the peer CaixaKind axis pair, \
19174                 DepList's forward emit and reverse parse share the \
19175                 same lifted DEP_AUTHOR_KEY_DEPS* consts by \
19176                 construction, so the round-trip composes directly)"
19177            );
19178        }
19179    }
19180
19181    #[test]
19182    fn dep_list_from_into_static_cow_str_routes_through_as_str_accessor() {
19183        // Fail-before-pass-after byte-parity pin on the newly lifted
19184        // `impl From<DepList> for std::borrow::Cow<'static, str>` —
19185        // asserts the standard-library trait impl and the substrate-
19186        // primitive [`super::DepList::as_str`] `pub const fn`
19187        // accessor resolve to the same two-arm emit-set across every
19188        // arm the exhaustive [`super::DepList::ALL`] slice
19189        // enumerates. Rust's standard library does not carry a
19190        // blanket `impl<T: AsRef<str>> From<T> for Cow<'static, str>`
19191        // (nor an `impl<T: fmt::Display> From<T> for
19192        // Cow<'static, str>`), so the `Cow<'static, str>` forward-
19193        // projection axis is a distinct trait-idiomatic surface that
19194        // a `let key: Cow<'static, str> = list.into();`-shaped call
19195        // site reaches through this impl and no other — the paired
19196        // sibling `From<DepList> for &'static str` and
19197        // `From<DepList> for String` impls force every
19198        // `Cow<'static, str>`-parameterized call site through a
19199        // `Cow::Borrowed(list.as_str())` /
19200        // `Cow::Owned(list.to_string())` composition whose type
19201        // bounds have no compile-time link back to the substrate
19202        // primitive.
19203        //
19204        // Also asserts the projection lands on the zero-alloc
19205        // [`std::borrow::Cow::Borrowed`] arm (not the
19206        // [`std::borrow::Cow::Owned`] arm) — the substrate-primitive
19207        // [`super::DepList::as_str`] accessor's `&'static str`
19208        // return lifetime by construction (each match arm resolves
19209        // to one of the two lifted
19210        // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19211        // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const
19212        // &str` values) makes the borrowed arm the type-correct
19213        // projection with no runtime allocation. Any future silent
19214        // detour that routes the impl through the owned arm trips
19215        // at caixa-core test time under the
19216        // [`std::borrow::Cow::Borrowed`] discriminator witness
19217        // rather than at a downstream `Cow<'static, str>`-bound
19218        // consumer's silent allocation.
19219        //
19220        // First-mover on the outside-M3 substrate-wide tier of the
19221        // substrate-wide trait-idiomatic
19222        // [`std::borrow::Cow<'static, str>`] forward-projection
19223        // campaign — extends the axis off the paired
19224        // [`crate::CaixaKind`] top-level opener (99c1735 + d45c409),
19225        // the paired M2 OTP-shape
19226        // [`crate::supervisor::RestartStrategy`] (7dd28b3 + 9b3e4b3)
19227        // and [`crate::supervisor::RestartPolicy`] (0612398 +
19228        // ee577fd), and the paired M3-mesh-shape
19229        // [`crate::aplicacao::WitShape`] (8634dec + 25690ef),
19230        // [`crate::aplicacao::PlacementStrategy`] (eee504d +
19231        // afdf0f4), and [`crate::aplicacao::RateLimitUnit`] (1d59925)
19232        // peers onto the first outside-M3 caixa-core peer (the two-
19233        // list dep-graph axis), opening the outside-M3 caixa-core
19234        // tier of the substrate-wide Cow<'static, str> forward-
19235        // projection campaign's owned-input corner.
19236        for &variant in super::DepList::ALL {
19237            let via_trait: std::borrow::Cow<'static, str> =
19238                <std::borrow::Cow<'static, str> as From<super::DepList>>::from(variant);
19239            let via_method: &'static str = variant.as_str();
19240            assert_eq!(
19241                via_trait.as_ref(),
19242                via_method,
19243                "From<DepList> for Cow<'static, str> impl must \
19244                 round-trip DepList::{variant:?} to the same lifted \
19245                 crate::render::DEP_AUTHOR_KEY_DEPS* const \
19246                 DepList::as_str returns — divergence signals a \
19247                 silent detour off the substrate-primitive accessor"
19248            );
19249            assert!(
19250                matches!(via_trait, std::borrow::Cow::Borrowed(_)),
19251                "From<DepList> for Cow<'static, str> impl must land \
19252                 on the zero-alloc Cow::Borrowed arm on \
19253                 DepList::{variant:?} — a Cow::Owned outcome signals \
19254                 the projection has silently allocated where the \
19255                 substrate-primitive DepList::as_str `&'static str` \
19256                 return makes the borrowed arm the type-correct \
19257                 projection"
19258            );
19259            let via_into: std::borrow::Cow<'static, str> = variant.into();
19260            assert_eq!(
19261                via_into.as_ref(),
19262                via_method,
19263                "Into<Cow<'static, str>>::into on DepList::\
19264                 {variant:?} must byte-equal DepList::as_str on the \
19265                 same input — the blanket-derived Into shape must \
19266                 resolve to the same as_str dispatch as the explicit \
19267                 From impl"
19268            );
19269            assert!(
19270                matches!(via_into, std::borrow::Cow::Borrowed(_)),
19271                "Into<Cow<'static, str>>::into on DepList::\
19272                 {variant:?} must land on the zero-alloc \
19273                 Cow::Borrowed arm — the blanket-derived Into shape \
19274                 must resolve to the same Cow::Borrowed dispatch as \
19275                 the explicit From impl"
19276            );
19277        }
19278    }
19279
19280    #[test]
19281    fn dep_list_from_into_static_cow_str_agrees_with_paired_axes_on_every_arm() {
19282        // Cross-axis partition pin: the newly lifted trait-idiomatic
19283        // `From<DepList> for std::borrow::Cow<'static, str>` (this
19284        // lift), the paired owned-input `From<DepList> for
19285        // &'static str` (3455cbf), and the paired owned-input
19286        // `From<DepList> for String` (32b0ee8) forward projections
19287        // must resolve identically on every arm, locking the three
19288        // return-shape paths together by construction so any future
19289        // detour trips at caixa-core test time. Also byte-parity
19290        // witness against the sibling [`ToString::to_string`]
19291        // surface routed through [`std::fmt::Display`] — every
19292        // owned-heap-string path (the `Cow::Owned` promotion of
19293        // this axis's `.into_owned()`, `From<DepList> for String`,
19294        // and `.to_string()`) resolves to the same two-arm lifted
19295        // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19296        // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] byte-string per
19297        // arm.
19298        //
19299        // Then a `.iter().copied().map(std::borrow::Cow::from)` pipe
19300        // witness over [`super::DepList::ALL`] that materializes the
19301        // two-arm accept-set through the
19302        // [`std::borrow::Cow<'static, str>`] axis alone — the exact
19303        // shape a future M4 admission-webhook rejection body's
19304        // accepted-`:deps` / `:deps-dev` list-key enumeration, a
19305        // future substrate-wide per-arm diagnostic surface whose
19306        // typing rules out the sibling [`AsRef<str>`] borrowed
19307        // return, or a future per-arm dep-list emitter that binds
19308        // through a [`std::borrow::Cow<'static, str>`] boundary
19309        // reaches through — opening the composable-projection axis
19310        // on the first outside-M3 caixa-core closed-set fieldless
19311        // typed enum peer on the caixa surface. The pipe witness
19312        // also pins the zero-alloc discipline: every element in the
19313        // collected vector satisfies the
19314        // [`std::borrow::Cow::Borrowed`] arm predicate, so a future
19315        // accidental silent-allocation regression on the pipe's
19316        // iteration axis is a caixa-core-test-time failure.
19317        for &variant in super::DepList::ALL {
19318            let via_cow: std::borrow::Cow<'static, str> =
19319                <std::borrow::Cow<'static, str> as From<super::DepList>>::from(variant);
19320            let via_static: &'static str = <&'static str as From<super::DepList>>::from(variant);
19321            let via_string: String = <String as From<super::DepList>>::from(variant);
19322            assert_eq!(
19323                via_cow.as_ref(),
19324                via_static,
19325                "From<DepList> for Cow<'static, str> and \
19326                 From<DepList> for &'static str must resolve \
19327                 identically on DepList::{variant:?} — divergence \
19328                 signals the Cow<'static, str> and &'static str \
19329                 return-shape paths have drifted onto different \
19330                 emit-sets"
19331            );
19332            assert_eq!(
19333                via_cow.as_ref(),
19334                via_string.as_str(),
19335                "From<DepList> for Cow<'static, str> and \
19336                 From<DepList> for String must resolve identically \
19337                 on DepList::{variant:?} — divergence signals the \
19338                 Cow<'static, str> and String return-shape paths \
19339                 have drifted onto different emit-sets"
19340            );
19341            let via_to_string: String = variant.to_string();
19342            assert_eq!(
19343                via_cow.as_ref(),
19344                via_to_string.as_str(),
19345                "From<DepList> for Cow<'static, str> must byte-equal \
19346                 DepList::to_string on DepList::{variant:?} — \
19347                 divergence signals the trait-idiomatic \
19348                 Cow<'static, str> forward-projection axis and the \
19349                 ToString-through-Display axis have drifted onto \
19350                 different emit-sets"
19351            );
19352        }
19353        let via_iter: Vec<std::borrow::Cow<'static, str>> = super::DepList::ALL
19354            .iter()
19355            .copied()
19356            .map(std::borrow::Cow::from)
19357            .collect();
19358        let via_method: Vec<std::borrow::Cow<'static, str>> = super::DepList::ALL
19359            .iter()
19360            .map(|l| std::borrow::Cow::Borrowed(l.as_str()))
19361            .collect();
19362        assert_eq!(
19363            via_iter, via_method,
19364            "`.iter().copied().map(Cow::from)` over DepList::ALL \
19365             must byte-equal `.iter().map(|l| \
19366             Cow::Borrowed(l.as_str()))` on every arm — the trait-\
19367             idiomatic `From<DepList> for Cow<'static, str>` axis is \
19368             what makes the `Cow::from` composition route through \
19369             the substrate-primitive `DepList::as_str` accessor with \
19370             the zero-alloc Cow::Borrowed arm by construction, \
19371             rather than a per-call-site `Cow::Owned(list.to_string())` \
19372             allocation"
19373        );
19374        for cow in &via_iter {
19375            assert!(
19376                matches!(cow, std::borrow::Cow::Borrowed(_)),
19377                "every element of the .iter().copied().map(Cow::from) \
19378                 pipe over DepList::ALL must land on the zero-alloc \
19379                 Cow::Borrowed arm — a Cow::Owned outcome on any arm \
19380                 signals the pipe's iteration axis has silently \
19381                 allocated where the substrate-primitive \
19382                 DepList::as_str `&'static str` return makes the \
19383                 borrowed arm the type-correct projection"
19384            );
19385        }
19386    }
19387
19388    #[test]
19389    fn dep_list_from_borrowed_into_static_cow_str_routes_through_as_str_accessor() {
19390        // Fail-before-pass-after byte-parity pin on the newly lifted
19391        // `impl From<&DepList> for std::borrow::Cow<'static, str>` —
19392        // asserts the borrowed-input standard-library trait impl and
19393        // the substrate-primitive [`super::DepList::as_str`] `pub const
19394        // fn` accessor resolve to the same two-arm emit-set across
19395        // every arm the exhaustive [`super::DepList::ALL`] slice
19396        // enumerates. Rust's standard library does not carry a blanket
19397        // `impl<T: AsRef<str>> From<&T> for Cow<'static, str>` (nor a
19398        // `Copy`-based `impl<T: Copy, U: From<T>> From<&T> for U`), so
19399        // the borrowed-input `Cow<'static, str>` forward-projection
19400        // axis is a distinct trait-idiomatic surface that a
19401        // `let key: Cow<'static, str> = (&list).into();`-shaped call
19402        // site or a `DepList::ALL.iter().map(Cow::from)`-shaped pipe
19403        // reaches through this impl and no other — the paired owned-
19404        // input `From<DepList> for Cow<'static, str>` impl (6858bac)
19405        // forces every borrowed-input call site through an explicit
19406        // `Copy` deref (`Cow::from(*list)`) or a
19407        // `Cow::Borrowed(list.as_str())` open-code whose type bounds
19408        // have no compile-time link back to the substrate primitive.
19409        //
19410        // Also asserts the projection lands on the zero-alloc
19411        // [`std::borrow::Cow::Borrowed`] arm (not the
19412        // [`std::borrow::Cow::Owned`] arm) — the substrate-primitive
19413        // [`super::DepList::as_str`] accessor's `&'static str` return
19414        // lifetime by construction (each match arm resolves to one of
19415        // the two lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19416        // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str`
19417        // values) makes the borrowed arm the type-correct projection
19418        // with no runtime allocation on the borrowed-input surface
19419        // just as on the paired owned-input surface.
19420        //
19421        // Closes the `{Self, &Self}` input-shape corner on the outside-
19422        // M3 caixa-core two-list dep-graph [`Cow<'static, str>`] axis
19423        // on the first outside-M3 caixa-core closed-set fieldless typed
19424        // enum peer on the caixa surface, exactly as afdf0f4 closed it
19425        // on the second M3-mesh-primitive peer
19426        // ([`crate::aplicacao::PlacementStrategy`]) one commit after
19427        // the owning half (eee504d) landed, as 25690ef closed it on
19428        // the first M3-mesh-primitive peer
19429        // ([`crate::aplicacao::WitShape`]) one commit after the owning
19430        // half (8634dec) landed, as d45c409 closed it on the top-level
19431        // [`crate::CaixaKind`] one commit after the owning half
19432        // (99c1735) landed, and as 9b3e4b3 / ee577fd closed it on the
19433        // M2 OTP-shape [`crate::supervisor::RestartStrategy`] /
19434        // [`crate::supervisor::RestartPolicy`] sibling peers one
19435        // commit after (7dd28b3 / 0612398) landed.
19436        for &variant in super::DepList::ALL {
19437            let via_trait: std::borrow::Cow<'static, str> =
19438                <std::borrow::Cow<'static, str> as From<&super::DepList>>::from(&variant);
19439            let via_method: &'static str = variant.as_str();
19440            assert_eq!(
19441                via_trait.as_ref(),
19442                via_method,
19443                "From<&DepList> for Cow<'static, str> impl must \
19444                 round-trip &DepList::{variant:?} to the same lifted \
19445                 crate::render::DEP_AUTHOR_KEY_DEPS* const \
19446                 DepList::as_str returns — divergence signals a silent \
19447                 detour off the substrate-primitive accessor"
19448            );
19449            assert!(
19450                matches!(via_trait, std::borrow::Cow::Borrowed(_)),
19451                "From<&DepList> for Cow<'static, str> impl must land \
19452                 on the zero-alloc Cow::Borrowed arm on \
19453                 &DepList::{variant:?} — a Cow::Owned outcome signals \
19454                 the projection has silently allocated where the \
19455                 substrate-primitive DepList::as_str `&'static str` \
19456                 return makes the borrowed arm the type-correct \
19457                 projection"
19458            );
19459            let via_into: std::borrow::Cow<'static, str> = (&variant).into();
19460            assert_eq!(
19461                via_into.as_ref(),
19462                via_method,
19463                "Into<Cow<'static, str>>::into on &DepList::\
19464                 {variant:?} must byte-equal DepList::as_str on the \
19465                 same input — the blanket-derived Into shape must \
19466                 resolve to the same as_str dispatch as the explicit \
19467                 From impl"
19468            );
19469            assert!(
19470                matches!(via_into, std::borrow::Cow::Borrowed(_)),
19471                "Into<Cow<'static, str>>::into on &DepList::\
19472                 {variant:?} must land on the zero-alloc \
19473                 Cow::Borrowed arm — the blanket-derived Into shape \
19474                 must resolve to the same Cow::Borrowed dispatch as \
19475                 the explicit From impl"
19476            );
19477        }
19478    }
19479
19480    #[test]
19481    fn dep_list_from_borrowed_into_static_cow_str_agrees_with_paired_axes_on_every_arm() {
19482        // Cross-axis partition pin: the newly lifted trait-idiomatic
19483        // borrowed-input `From<&DepList> for std::borrow::Cow<'static,
19484        // str>` (this lift), the paired owned-input `From<DepList> for
19485        // std::borrow::Cow<'static, str>` (6858bac), the paired
19486        // borrowed-input owned-`&'static str` `From<&DepList> for
19487        // &'static str` (3455cbf), and the paired borrowed-input
19488        // owned-`String` `From<&DepList> for String` must resolve
19489        // identically on every arm, locking the four return-shape ×
19490        // input-shape paths together by construction so any future
19491        // detour trips at caixa-core test time. Also byte-parity
19492        // witness against the sibling [`ToString::to_string`] surface
19493        // routed through [`std::fmt::Display`] — every owned-heap-
19494        // string path (this axis's `.into_owned()` promotion, the
19495        // paired [`From<&DepList> for String`], and `.to_string()`)
19496        // resolves to the same two-arm lifted
19497        // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19498        // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] byte-string per
19499        // arm.
19500        //
19501        // Then a `.iter().map(std::borrow::Cow::from)` pipe witness
19502        // over [`super::DepList::ALL`] — whose iterator yields
19503        // `&DepList` by construction, so the borrowed-input
19504        // [`Cow<'static, str>`] axis is what routes the pipe through
19505        // the substrate-primitive [`super::DepList::as_str`] accessor
19506        // without a spurious [`Copy`] deref (which would only be
19507        // reachable through the owned-input [`From<DepList> for
19508        // Cow<'static, str>`] axis by first calling `.copied()` on the
19509        // iterator). The pipe witness also pins the zero-alloc
19510        // discipline: every element in the collected vector satisfies
19511        // the [`std::borrow::Cow::Borrowed`] arm predicate, so a
19512        // future accidental silent-allocation regression on the pipe's
19513        // iteration axis is a caixa-core-test-time failure. Peer of
19514        // the sibling
19515        // [`placement_strategy_from_borrowed_into_static_cow_str_agrees_with_paired_axes_on_every_arm`]
19516        // (afdf0f4) on the M3 mesh-shape `:placement :estrategia`
19517        // axis — extends the whole borrowed-input `Cow<'static, str>`
19518        // + paired `{&'static str, String}` cross-axis-parity corner
19519        // onto the first outside-M3 caixa-core closed-set fieldless
19520        // typed enum peer on the caixa surface.
19521        for &variant in super::DepList::ALL {
19522            let borrowed_cow: std::borrow::Cow<'static, str> =
19523                <std::borrow::Cow<'static, str> as From<&super::DepList>>::from(&variant);
19524            let owned_cow: std::borrow::Cow<'static, str> =
19525                <std::borrow::Cow<'static, str> as From<super::DepList>>::from(variant);
19526            let borrowed_static: &'static str =
19527                <&'static str as From<&super::DepList>>::from(&variant);
19528            let borrowed_string: String = <String as From<&super::DepList>>::from(&variant);
19529            assert_eq!(
19530                borrowed_cow, owned_cow,
19531                "From<&DepList> for Cow<'static, str> and \
19532                 From<DepList> for Cow<'static, str> must resolve \
19533                 identically on DepList::{variant:?} — divergence \
19534                 signals the borrowed-input and owned-input \
19535                 Cow<'static, str> forward-projection input-shape \
19536                 paths have drifted onto different emit-sets"
19537            );
19538            assert_eq!(
19539                borrowed_cow.as_ref(),
19540                borrowed_static,
19541                "From<&DepList> for Cow<'static, str> and \
19542                 From<&DepList> for &'static str must resolve \
19543                 identically on DepList::{variant:?} — divergence \
19544                 signals the borrowed-input Cow<'static, str> and \
19545                 &'static str return-shape paths have drifted onto \
19546                 different emit-sets"
19547            );
19548            assert_eq!(
19549                borrowed_cow.as_ref(),
19550                borrowed_string.as_str(),
19551                "From<&DepList> for Cow<'static, str> and \
19552                 From<&DepList> for String must resolve identically \
19553                 on DepList::{variant:?} — divergence signals the \
19554                 borrowed-input Cow<'static, str> and owned-`String` \
19555                 return-shape paths have drifted onto different \
19556                 emit-sets"
19557            );
19558            let via_to_string: String = variant.to_string();
19559            assert_eq!(
19560                borrowed_cow.as_ref(),
19561                via_to_string.as_str(),
19562                "From<&DepList> for Cow<'static, str> must byte-equal \
19563                 DepList::to_string on DepList::{variant:?} — \
19564                 divergence signals the trait-idiomatic borrowed-input \
19565                 Cow<'static, str> forward-projection axis and the \
19566                 ToString-through-Display axis have drifted onto \
19567                 different emit-sets"
19568            );
19569        }
19570        let via_iter: Vec<std::borrow::Cow<'static, str>> = super::DepList::ALL
19571            .iter()
19572            .map(std::borrow::Cow::from)
19573            .collect();
19574        let via_method: Vec<std::borrow::Cow<'static, str>> = super::DepList::ALL
19575            .iter()
19576            .map(|l| std::borrow::Cow::Borrowed(l.as_str()))
19577            .collect();
19578        assert_eq!(
19579            via_iter, via_method,
19580            "`.iter().map(Cow::from)` over DepList::ALL — a call site \
19581             whose iteration axis holds &DepList by construction — \
19582             must byte-equal `.iter().map(|l| \
19583             Cow::Borrowed(l.as_str()))` on every arm — the borrowed-\
19584             input Cow<'static, str> `From<&DepList> for Cow<'static, \
19585             str>` axis is what makes the `Cow::from` composition \
19586             route through the substrate-primitive `DepList::as_str` \
19587             accessor with the zero-alloc Cow::Borrowed arm by \
19588             construction and without a spurious `Copy` deref (which \
19589             would only be reachable through the owned-input \
19590             `From<DepList> for Cow<'static, str>` axis by first \
19591             calling `.copied()` on the iterator)"
19592        );
19593        for cow in &via_iter {
19594            assert!(
19595                matches!(cow, std::borrow::Cow::Borrowed(_)),
19596                "every element of the .iter().map(Cow::from) pipe \
19597                 over DepList::ALL must land on the zero-alloc \
19598                 Cow::Borrowed arm — a Cow::Owned outcome on any arm \
19599                 signals the pipe's iteration axis has silently \
19600                 allocated where the substrate-primitive \
19601                 DepList::as_str `&'static str` return makes the \
19602                 borrowed arm the type-correct projection"
19603            );
19604        }
19605    }
19606
19607    #[test]
19608    fn dep_list_from_into_box_str_routes_through_as_str_accessor() {
19609        // Fail-before-pass-after byte-parity pin on the newly lifted
19610        // `impl From<DepList> for Box<str>` — asserts the owned-input
19611        // standard-library trait impl and the substrate-primitive
19612        // [`super::DepList::as_str`] `pub const fn` accessor resolve to
19613        // the same two-arm emit-set (the paired
19614        // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19615        // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str`
19616        // byte-strings) across every arm the exhaustive
19617        // [`super::DepList::ALL`] slice enumerates. Extends the caixa-
19618        // core-internal tier of the substrate-wide [`Box<str>`] forward-
19619        // projection campaign onto the second caixa-core-internal peer,
19620        // after the render-side path-shape-diagnostic
19621        // [`super::super::render::PathShapeViolation`] pair (0d87a72,
19622        // both corners in one axis) opened the tier. Rust's standard
19623        // library carries `impl From<&str> for Box<str>` and
19624        // `impl From<String> for Box<str>` but no blanket
19625        // `impl<T: AsRef<str>> From<T> for Box<str>`, so this axis is a
19626        // distinct trait-idiomatic surface that a
19627        // `let key: Box<str> = list.into();`-shaped call site reaches
19628        // through this impl and no other — a paired
19629        // `Box::from(list.as_str())` open-code has no compile-time link
19630        // back to the substrate primitive.
19631        for &variant in super::DepList::ALL {
19632            let via_trait: Box<str> = <Box<str> as From<super::DepList>>::from(variant);
19633            let via_method: &'static str = variant.as_str();
19634            assert_eq!(
19635                via_trait.as_ref(),
19636                via_method,
19637                "From<DepList> for Box<str> impl must round-trip \
19638                 DepList::{variant:?} to the same lifted \
19639                 crate::render::DEP_AUTHOR_KEY_DEPS* const \
19640                 DepList::as_str returns — divergence signals a silent \
19641                 detour off the substrate-primitive accessor"
19642            );
19643            let via_into: Box<str> = variant.into();
19644            assert_eq!(
19645                via_into.as_ref(),
19646                via_method,
19647                "Into<Box<str>>::into on DepList::{variant:?} must \
19648                 byte-equal DepList::as_str on the same input — the \
19649                 blanket-derived Into shape must resolve to the same \
19650                 as_str dispatch as the explicit From impl"
19651            );
19652        }
19653    }
19654
19655    #[test]
19656    fn dep_list_from_borrowed_into_box_str_routes_through_as_str_accessor() {
19657        // Fail-before-pass-after byte-parity pin on the newly lifted
19658        // `impl From<&DepList> for Box<str>` — asserts the borrowed-input
19659        // standard-library trait impl and the substrate-primitive
19660        // [`super::DepList::as_str`] `pub const fn` accessor resolve to
19661        // the same two-arm emit-set (the paired
19662        // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19663        // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str`
19664        // byte-strings) across every arm the exhaustive
19665        // [`super::DepList::ALL`] slice enumerates. Rust's standard
19666        // library carries `impl From<&str> for Box<str>` and
19667        // `impl From<String> for Box<str>` but no blanket
19668        // `impl<T: AsRef<str>> From<&T> for Box<str>` (nor a `Copy`-based
19669        // `impl<T: Copy, U: From<T>> From<&T> for U`), so the borrowed-
19670        // input [`Box<str>`] forward-projection axis is a distinct
19671        // trait-idiomatic surface that a
19672        // `DepList::ALL.iter().map(Box::<str>::from)`-shaped pipe (whose
19673        // iterator over `&'static [DepList]` yields `&DepList` by
19674        // construction) or a `let key: Box<str> = (&list).into();`-shaped
19675        // call site reaches through this impl and no other — the paired
19676        // owned-input `From<DepList> for Box<str>` impl alone would force
19677        // every borrowed-input call site through an explicit `Copy` deref
19678        // (`Box::<str>::from(*list)`) or a
19679        // `Box::<str>::from(list.as_str())` open-code whose type bounds
19680        // have no compile-time link back to the substrate primitive.
19681        //
19682        // Closes the `{Self, &Self}` input-shape corner on the second
19683        // caixa-core-internal closed-set fieldless typed enum peer of
19684        // the substrate-wide [`Box<str>`] forward-projection campaign —
19685        // one commit after the paired render-side path-shape-diagnostic
19686        // [`super::super::render::PathShapeViolation`] pair (0d87a72)
19687        // opened the caixa-core-internal tier — matching the trajectory
19688        // the paired caixa-theme `Semantic` pair (0cd7dc3, both corners
19689        // in one axis), the caixa-provedor `FerriteRuntime` pair
19690        // (14886a8, both corners in one axis), and the render-side
19691        // `PathShapeViolation` pair (0d87a72, both corners in one axis)
19692        // walked before it.
19693        for &variant in super::DepList::ALL {
19694            let via_trait: Box<str> = <Box<str> as From<&super::DepList>>::from(&variant);
19695            let via_method: &'static str = variant.as_str();
19696            assert_eq!(
19697                via_trait.as_ref(),
19698                via_method,
19699                "From<&DepList> for Box<str> impl must round-trip \
19700                 &DepList::{variant:?} to the same lifted \
19701                 crate::render::DEP_AUTHOR_KEY_DEPS* const \
19702                 DepList::as_str returns — divergence signals a silent \
19703                 detour off the substrate-primitive accessor"
19704            );
19705            let via_into: Box<str> = (&variant).into();
19706            assert_eq!(
19707                via_into.as_ref(),
19708                via_method,
19709                "Into<Box<str>>::into on &DepList::{variant:?} must \
19710                 byte-equal DepList::as_str on the same input — the \
19711                 blanket-derived Into shape on the borrowed-input \
19712                 surface must resolve to the same as_str dispatch as \
19713                 the explicit From impl"
19714            );
19715        }
19716
19717        // Pipe witness — the distinguishing shape that forces the
19718        // borrowed-input axis to be independent of the owned-input
19719        // peer. `DepList::ALL.iter()` yields `&DepList` by
19720        // construction, so `.map(Box::<str>::from)` resolves through
19721        // the borrowed-input `From<&DepList> for Box<str>` impl and
19722        // no other — without this axis, the same pipe would force an
19723        // explicit `.copied()` restatement whose type bounds bypass
19724        // the substrate primitive.
19725        let via_pipe: Vec<Box<str>> = super::DepList::ALL.iter().map(Box::<str>::from).collect();
19726        let via_accessor: Vec<&'static str> =
19727            super::DepList::ALL.iter().map(|l| l.as_str()).collect();
19728        assert_eq!(
19729            via_pipe.len(),
19730            via_accessor.len(),
19731            "DepList::ALL.iter().map(Box::<str>::from) pipe must \
19732             preserve arity against the paired DepList::as_str \
19733             accessor — a length divergence signals the borrowed-input \
19734             axis has silently rejected an arm"
19735        );
19736        for (pipe_arm, accessor_arm) in via_pipe.iter().zip(via_accessor.iter()) {
19737            assert_eq!(
19738                pipe_arm.as_ref(),
19739                *accessor_arm,
19740                "DepList::ALL.iter().map(Box::<str>::from) pipe must \
19741                 byte-equal the paired \
19742                 DepList::ALL.iter().map(|l| l.as_str()) pipe on every \
19743                 arm — divergence signals the borrowed-input \
19744                 `From<&DepList> for Box<str>` axis has silently \
19745                 detoured off the substrate-primitive accessor"
19746            );
19747        }
19748    }
19749
19750    #[test]
19751    fn dep_list_from_into_arc_str_routes_through_as_str_accessor() {
19752        // Fail-before-pass-after byte-parity pin on the newly lifted
19753        // `impl From<DepList> for std::sync::Arc<str>` — asserts the
19754        // owned-input standard-library trait impl and the substrate-
19755        // primitive [`super::DepList::as_str`] `pub const fn` accessor
19756        // resolve to the same two-arm emit-set (the paired
19757        // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19758        // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str`
19759        // byte-strings) across every arm the exhaustive
19760        // [`super::DepList::ALL`] slice enumerates. Extends the caixa-
19761        // core-internal tier of the substrate-wide
19762        // [`std::sync::Arc<str>`] forward-projection campaign onto the
19763        // second caixa-core-internal peer, after the top-level
19764        // [`crate::CaixaKind`] pair (c17be64, both corners in one axis)
19765        // opened the tier. Rust's standard library carries
19766        // `impl From<&str> for std::sync::Arc<str>` and
19767        // `impl From<String> for std::sync::Arc<str>` but no blanket
19768        // `impl<T: AsRef<str>> From<T> for std::sync::Arc<str>` (nor an
19769        // `impl<T: fmt::Display> From<T> for std::sync::Arc<str>`), so
19770        // this axis is a distinct trait-idiomatic surface that a
19771        // `let key: std::sync::Arc<str> = list.into();`-shaped call site
19772        // reaches through this impl and no other — a paired
19773        // `std::sync::Arc::<str>::from(list.as_str())` open-code has no
19774        // compile-time link back to the substrate primitive, and a two-
19775        // step `std::sync::Arc::<str>::from(String::from(list))`
19776        // composition through the owned-`String` axis allocates twice
19777        // (once into the intermediate `String`, once into the
19778        // [`std::sync::Arc<str>`] on the `From<String>` conversion)
19779        // where the single-step trait impl allocates once.
19780        //
19781        // Cross-axis byte-parity witness against the sibling owned-input
19782        // `{&'static str, String, Cow<'static, str>, Box<str>}` return-
19783        // shape axes — locking the five return-shape paths on the owned-
19784        // input surface together by construction so any future detour
19785        // off the substrate-primitive [`super::DepList::as_str`] accessor
19786        // trips at caixa-core test time.
19787        for &variant in super::DepList::ALL {
19788            let via_trait: std::sync::Arc<str> =
19789                <std::sync::Arc<str> as From<super::DepList>>::from(variant);
19790            let via_method: &'static str = variant.as_str();
19791            assert_eq!(
19792                via_trait.as_ref(),
19793                via_method,
19794                "From<DepList> for std::sync::Arc<str> impl must round-\
19795                 trip DepList::{variant:?} to the same lifted \
19796                 crate::render::DEP_AUTHOR_KEY_DEPS* const \
19797                 DepList::as_str returns — divergence signals a silent \
19798                 detour off the substrate-primitive accessor"
19799            );
19800            let via_into: std::sync::Arc<str> = variant.into();
19801            assert_eq!(
19802                via_into.as_ref(),
19803                via_method,
19804                "Into<std::sync::Arc<str>>::into on DepList::{variant:?} \
19805                 must byte-equal DepList::as_str on the same input — \
19806                 the blanket-derived Into shape must resolve to the same \
19807                 as_str dispatch as the explicit From impl"
19808            );
19809            let owned_static: &'static str = <&'static str as From<super::DepList>>::from(variant);
19810            assert_eq!(
19811                via_trait.as_ref(),
19812                owned_static,
19813                "From<DepList> for std::sync::Arc<str> and \
19814                 From<DepList> for &'static str must resolve identically \
19815                 on DepList::{variant:?} — divergence signals the owned-\
19816                 input std::sync::Arc<str> and &'static str return-shape \
19817                 paths have drifted onto different emit-sets"
19818            );
19819            let owned_string: String = <String as From<super::DepList>>::from(variant);
19820            assert_eq!(
19821                via_trait.as_ref(),
19822                owned_string.as_str(),
19823                "From<DepList> for std::sync::Arc<str> and \
19824                 From<DepList> for String must resolve identically on \
19825                 DepList::{variant:?} — divergence signals the owned-\
19826                 input std::sync::Arc<str> and owned-`String` return-shape \
19827                 paths have drifted onto different emit-sets"
19828            );
19829            let owned_cow: std::borrow::Cow<'static, str> =
19830                <std::borrow::Cow<'static, str> as From<super::DepList>>::from(variant);
19831            assert_eq!(
19832                via_trait.as_ref(),
19833                owned_cow.as_ref(),
19834                "From<DepList> for std::sync::Arc<str> and \
19835                 From<DepList> for Cow<'static, str> must resolve \
19836                 identically on DepList::{variant:?} — divergence signals \
19837                 the owned-input std::sync::Arc<str> and \
19838                 Cow<'static, str> return-shape paths have drifted onto \
19839                 different emit-sets"
19840            );
19841            let owned_box: Box<str> = <Box<str> as From<super::DepList>>::from(variant);
19842            assert_eq!(
19843                via_trait.as_ref(),
19844                owned_box.as_ref(),
19845                "From<DepList> for std::sync::Arc<str> and \
19846                 From<DepList> for Box<str> must resolve identically on \
19847                 DepList::{variant:?} — divergence signals the owned-\
19848                 input std::sync::Arc<str> and Box<str> return-shape \
19849                 paths have drifted onto different emit-sets"
19850            );
19851        }
19852    }
19853
19854    #[test]
19855    #[allow(
19856        clippy::too_many_lines,
19857        reason = "cross-axis partition pin folds four borrowed-input \
19858                  return-shape paths (&'static str, String, Cow<'static, \
19859                  str>, Box<str>) plus the paired owned-input Arc<str> \
19860                  witness and the .iter().map(std::sync::Arc::<str>::from) \
19861                  pipe witness into one exhaustive round-trip over \
19862                  DepList::ALL — the accepted line-count cost of keying \
19863                  the whole borrowed-input Arc<str> corner to the \
19864                  substrate-primitive as_str accessor at the same test-site"
19865    )]
19866    fn dep_list_from_borrowed_into_arc_str_routes_through_as_str_accessor() {
19867        // Fail-before-pass-after byte-parity pin on the newly lifted
19868        // `impl From<&DepList> for std::sync::Arc<str>` — asserts the
19869        // borrowed-input standard-library trait impl and the substrate-
19870        // primitive [`super::DepList::as_str`] `pub const fn` accessor
19871        // resolve to the same two-arm emit-set across every arm the
19872        // exhaustive [`super::DepList::ALL`] slice enumerates. Rust's
19873        // standard library does not carry a blanket
19874        // `impl<T: AsRef<str>> From<&T> for std::sync::Arc<str>` (nor a
19875        // `Copy`-based `impl<T: Copy, U: From<T>> From<&T> for U`), so
19876        // the borrowed-input `std::sync::Arc<str>` forward-projection
19877        // axis is a distinct trait-idiomatic surface that a
19878        // `let key: std::sync::Arc<str> = (&list).into();`-shaped call
19879        // site or a
19880        // `DepList::ALL.iter().map(std::sync::Arc::<str>::from)`-shaped
19881        // pipe reaches through this impl and no other — the paired
19882        // owned-input `From<DepList> for std::sync::Arc<str>` impl alone
19883        // forces every borrowed-input call site through a spurious
19884        // `Copy` deref
19885        // (`std::sync::Arc::<str>::from((*list).as_str())`) or a
19886        // `.copied()` restatement whose type bounds have no compile-time
19887        // link back to the substrate primitive.
19888        //
19889        // Closes the `{Self, &Self}` input-shape corner on the second
19890        // caixa-core-internal closed-set fieldless typed enum peer of
19891        // the substrate-wide trait-idiomatic [`std::sync::Arc<str>`]
19892        // forward-projection campaign — one commit after the paired
19893        // top-level [`crate::CaixaKind`] pair (c17be64) opened the
19894        // caixa-core-internal tier — matching the
19895        // `{Self, &Self} × {&'static str, String, Cow<'static, str>,
19896        // Box<str>}` 2×4 forward-projection matrix the peer projection
19897        // surfaces already close on this same enum.
19898        //
19899        // Cross-axis partition pin against the paired owned-input
19900        // [`From<DepList> for std::sync::Arc<str>`] and the sibling
19901        // borrowed-input `{&'static str, String, Cow<'static, str>,
19902        // Box<str>}` return-shape axes — locking the five return-shape
19903        // × input-shape paths on the borrowed-input surface together by
19904        // construction so any future detour off the substrate-primitive
19905        // accessor trips at caixa-core test time. Then a
19906        // `.iter().map(std::sync::Arc::<str>::from)` pipe witness over
19907        // [`super::DepList::ALL`] — whose iterator yields `&DepList` by
19908        // construction, so the borrowed-input
19909        // [`std::sync::Arc<str>`] axis is what routes the pipe through
19910        // the substrate-primitive [`super::DepList::as_str`] accessor
19911        // without a spurious [`Copy`] deref (which would only be
19912        // reachable through the owned-input
19913        // [`From<DepList> for std::sync::Arc<str>`] axis by first
19914        // calling `.copied()` on the iterator).
19915        for &variant in super::DepList::ALL {
19916            let via_trait: std::sync::Arc<str> =
19917                <std::sync::Arc<str> as From<&super::DepList>>::from(&variant);
19918            let via_method: &'static str = variant.as_str();
19919            assert_eq!(
19920                via_trait.as_ref(),
19921                via_method,
19922                "From<&DepList> for std::sync::Arc<str> impl must round-\
19923                 trip &DepList::{variant:?} to the same lifted \
19924                 crate::render::DEP_AUTHOR_KEY_DEPS* const \
19925                 DepList::as_str returns — divergence signals a silent \
19926                 detour off the substrate-primitive accessor"
19927            );
19928            let via_into: std::sync::Arc<str> = (&variant).into();
19929            assert_eq!(
19930                via_into.as_ref(),
19931                via_method,
19932                "Into<std::sync::Arc<str>>::into on &DepList::\
19933                 {variant:?} must byte-equal DepList::as_str on the \
19934                 same input — the blanket-derived Into shape on the \
19935                 borrowed-input surface must resolve to the same as_str \
19936                 dispatch as the explicit From impl"
19937            );
19938            let owned_arc: std::sync::Arc<str> =
19939                <std::sync::Arc<str> as From<super::DepList>>::from(variant);
19940            assert_eq!(
19941                via_trait, owned_arc,
19942                "From<&DepList> for std::sync::Arc<str> and \
19943                 From<DepList> for std::sync::Arc<str> must resolve \
19944                 identically on DepList::{variant:?} — divergence \
19945                 signals the borrowed-input and owned-input \
19946                 std::sync::Arc<str> forward-projection input-shape \
19947                 paths have drifted onto different emit-sets"
19948            );
19949            let borrowed_static: &'static str =
19950                <&'static str as From<&super::DepList>>::from(&variant);
19951            assert_eq!(
19952                via_trait.as_ref(),
19953                borrowed_static,
19954                "From<&DepList> for std::sync::Arc<str> and \
19955                 From<&DepList> for &'static str must resolve \
19956                 identically on DepList::{variant:?} — divergence \
19957                 signals the borrowed-input std::sync::Arc<str> and \
19958                 &'static str return-shape paths have drifted onto \
19959                 different emit-sets"
19960            );
19961            let borrowed_string: String = <String as From<&super::DepList>>::from(&variant);
19962            assert_eq!(
19963                via_trait.as_ref(),
19964                borrowed_string.as_str(),
19965                "From<&DepList> for std::sync::Arc<str> and \
19966                 From<&DepList> for String must resolve identically on \
19967                 DepList::{variant:?} — divergence signals the \
19968                 borrowed-input std::sync::Arc<str> and owned-`String` \
19969                 return-shape paths have drifted onto different emit-\
19970                 sets"
19971            );
19972            let borrowed_cow: std::borrow::Cow<'static, str> =
19973                <std::borrow::Cow<'static, str> as From<&super::DepList>>::from(&variant);
19974            assert_eq!(
19975                via_trait.as_ref(),
19976                borrowed_cow.as_ref(),
19977                "From<&DepList> for std::sync::Arc<str> and \
19978                 From<&DepList> for Cow<'static, str> must resolve \
19979                 identically on DepList::{variant:?} — divergence \
19980                 signals the borrowed-input std::sync::Arc<str> and \
19981                 Cow<'static, str> return-shape paths have drifted onto \
19982                 different emit-sets"
19983            );
19984            let borrowed_box: Box<str> = <Box<str> as From<&super::DepList>>::from(&variant);
19985            assert_eq!(
19986                via_trait.as_ref(),
19987                borrowed_box.as_ref(),
19988                "From<&DepList> for std::sync::Arc<str> and \
19989                 From<&DepList> for Box<str> must resolve identically \
19990                 on DepList::{variant:?} — divergence signals the \
19991                 borrowed-input std::sync::Arc<str> and Box<str> \
19992                 return-shape paths have drifted onto different emit-sets"
19993            );
19994        }
19995        let via_iter: Vec<std::sync::Arc<str>> = super::DepList::ALL
19996            .iter()
19997            .map(std::sync::Arc::<str>::from)
19998            .collect();
19999        let via_method: Vec<std::sync::Arc<str>> = super::DepList::ALL
20000            .iter()
20001            .map(|l| std::sync::Arc::<str>::from(l.as_str()))
20002            .collect();
20003        assert_eq!(
20004            via_iter, via_method,
20005            "`.iter().map(std::sync::Arc::<str>::from)` over \
20006             DepList::ALL — a call site whose iteration axis holds \
20007             `&DepList` by construction — must byte-equal \
20008             `.iter().map(|l| std::sync::Arc::<str>::from(l.as_str()))` \
20009             on every arm — the borrowed-input std::sync::Arc<str> \
20010             `From<&DepList> for std::sync::Arc<str>` axis is what \
20011             makes the `std::sync::Arc::<str>::from` composition route \
20012             through the substrate-primitive `DepList::as_str` \
20013             accessor without a spurious `Copy` deref (which would \
20014             only be reachable through the owned-input \
20015             `From<DepList> for std::sync::Arc<str>` axis by first \
20016             calling `.copied()` on the iterator)"
20017        );
20018    }
20019
20020    #[test]
20021    fn dep_list_from_into_rc_str_routes_through_as_str_accessor() {
20022        // Fail-before-pass-after byte-parity pin on the newly lifted
20023        // `impl From<DepList> for std::rc::Rc<str>` — asserts the
20024        // owned-input standard-library trait impl and the substrate-
20025        // primitive [`super::DepList::as_str`] `pub const fn` accessor
20026        // resolve to the same two-arm emit-set (the paired
20027        // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
20028        // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str`
20029        // byte-strings) across every arm the exhaustive
20030        // [`super::DepList::ALL`] slice enumerates. Extends the caixa-
20031        // core-internal tier of the substrate-wide
20032        // [`std::rc::Rc<str>`] forward-projection campaign onto the
20033        // third caixa-core-internal peer, after the top-level
20034        // [`crate::CaixaKind`] (e04aff0), the second-peer
20035        // [`crate::dialeto::CaixaDialeto`] (c5595e5), and the render-
20036        // side [`crate::render::PathShapeViolation`] (31fc43e) pairs
20037        // opened the tier. Rust's standard library carries
20038        // `impl From<&str> for std::rc::Rc<str>` and
20039        // `impl From<String> for std::rc::Rc<str>` but no blanket
20040        // `impl<T: AsRef<str>> From<T> for std::rc::Rc<str>`, and the
20041        // [`std::sync::Arc<str>`] and [`std::rc::Rc<str>`] trait
20042        // tables are disjoint, so this axis is a distinct trait-
20043        // idiomatic surface that a
20044        // `let key: std::rc::Rc<str> = list.into();`-shaped call site
20045        // reaches through this impl and no other — a paired
20046        // `std::rc::Rc::<str>::from(list.as_str())` open-code has no
20047        // compile-time link back to the substrate primitive, and a
20048        // two-step `std::rc::Rc::<str>::from(String::from(list))`
20049        // composition through the owned-`String` axis allocates twice
20050        // (once into the intermediate `String`, once into the
20051        // [`std::rc::Rc<str>`] on the `From<String>` conversion) where
20052        // the single-step trait impl allocates once.
20053        //
20054        // Cross-axis byte-parity witness against the sibling owned-
20055        // input `{&'static str, String, Cow<'static, str>, Box<str>,
20056        // std::sync::Arc<str>}` return-shape axes — locking the six
20057        // return-shape paths on the owned-input surface together by
20058        // construction so any future detour off the substrate-
20059        // primitive [`super::DepList::as_str`] accessor trips at
20060        // caixa-core test time.
20061        for &variant in super::DepList::ALL {
20062            let via_trait: std::rc::Rc<str> =
20063                <std::rc::Rc<str> as From<super::DepList>>::from(variant);
20064            let via_method: &'static str = variant.as_str();
20065            assert_eq!(
20066                via_trait.as_ref(),
20067                via_method,
20068                "From<DepList> for std::rc::Rc<str> impl must round-\
20069                 trip DepList::{variant:?} to the same lifted \
20070                 crate::render::DEP_AUTHOR_KEY_DEPS* const \
20071                 DepList::as_str returns — divergence signals a silent \
20072                 detour off the substrate-primitive accessor"
20073            );
20074            let via_into: std::rc::Rc<str> = variant.into();
20075            assert_eq!(
20076                via_into.as_ref(),
20077                via_method,
20078                "Into<std::rc::Rc<str>>::into on DepList::{variant:?} \
20079                 must byte-equal DepList::as_str on the same input — \
20080                 the blanket-derived Into shape must resolve to the \
20081                 same as_str dispatch as the explicit From impl"
20082            );
20083            let owned_static: &'static str = <&'static str as From<super::DepList>>::from(variant);
20084            assert_eq!(
20085                via_trait.as_ref(),
20086                owned_static,
20087                "From<DepList> for std::rc::Rc<str> and \
20088                 From<DepList> for &'static str must resolve identically \
20089                 on DepList::{variant:?} — divergence signals the owned-\
20090                 input std::rc::Rc<str> and &'static str return-shape \
20091                 paths have drifted onto different emit-sets"
20092            );
20093            let owned_string: String = <String as From<super::DepList>>::from(variant);
20094            assert_eq!(
20095                via_trait.as_ref(),
20096                owned_string.as_str(),
20097                "From<DepList> for std::rc::Rc<str> and \
20098                 From<DepList> for String must resolve identically on \
20099                 DepList::{variant:?} — divergence signals the owned-\
20100                 input std::rc::Rc<str> and owned-`String` return-shape \
20101                 paths have drifted onto different emit-sets"
20102            );
20103            let owned_cow: std::borrow::Cow<'static, str> =
20104                <std::borrow::Cow<'static, str> as From<super::DepList>>::from(variant);
20105            assert_eq!(
20106                via_trait.as_ref(),
20107                owned_cow.as_ref(),
20108                "From<DepList> for std::rc::Rc<str> and \
20109                 From<DepList> for Cow<'static, str> must resolve \
20110                 identically on DepList::{variant:?} — divergence signals \
20111                 the owned-input std::rc::Rc<str> and Cow<'static, str> \
20112                 return-shape paths have drifted onto different emit-sets"
20113            );
20114            let owned_box: Box<str> = <Box<str> as From<super::DepList>>::from(variant);
20115            assert_eq!(
20116                via_trait.as_ref(),
20117                owned_box.as_ref(),
20118                "From<DepList> for std::rc::Rc<str> and \
20119                 From<DepList> for Box<str> must resolve identically on \
20120                 DepList::{variant:?} — divergence signals the owned-\
20121                 input std::rc::Rc<str> and Box<str> return-shape paths \
20122                 have drifted onto different emit-sets"
20123            );
20124            let owned_arc: std::sync::Arc<str> =
20125                <std::sync::Arc<str> as From<super::DepList>>::from(variant);
20126            assert_eq!(
20127                via_trait.as_ref(),
20128                owned_arc.as_ref(),
20129                "From<DepList> for std::rc::Rc<str> and \
20130                 From<DepList> for std::sync::Arc<str> must resolve \
20131                 identically on DepList::{variant:?} — divergence signals \
20132                 the owned-input std::rc::Rc<str> and std::sync::Arc<str> \
20133                 return-shape paths have drifted onto different emit-sets \
20134                 (the two disjoint reference-counted trait tables have \
20135                 desynchronized on the caixa-core two-list dep-graph axis)"
20136            );
20137        }
20138    }
20139
20140    #[test]
20141    #[allow(
20142        clippy::too_many_lines,
20143        reason = "cross-axis partition pin folds five borrowed-input \
20144                  return-shape paths (&'static str, String, Cow<'static, \
20145                  str>, Box<str>, std::sync::Arc<str>) plus the paired \
20146                  owned-input Rc<str> witness and the \
20147                  .iter().map(std::rc::Rc::<str>::from) pipe witness into \
20148                  one exhaustive round-trip over DepList::ALL — the \
20149                  accepted line-count cost of keying the whole borrowed-\
20150                  input Rc<str> corner to the substrate-primitive as_str \
20151                  accessor at the same test-site"
20152    )]
20153    fn dep_list_from_borrowed_into_rc_str_routes_through_as_str_accessor() {
20154        // Fail-before-pass-after byte-parity pin on the newly lifted
20155        // `impl From<&DepList> for std::rc::Rc<str>` — asserts the
20156        // borrowed-input standard-library trait impl and the substrate-
20157        // primitive [`super::DepList::as_str`] `pub const fn` accessor
20158        // resolve to the same two-arm emit-set across every arm the
20159        // exhaustive [`super::DepList::ALL`] slice enumerates. Rust's
20160        // standard library does not carry a blanket
20161        // `impl<T: AsRef<str>> From<&T> for std::rc::Rc<str>` (nor a
20162        // `Copy`-based `impl<T: Copy, U: From<T>> From<&T> for U`), so
20163        // the borrowed-input `std::rc::Rc<str>` forward-projection axis
20164        // is a distinct trait-idiomatic surface that a
20165        // `let key: std::rc::Rc<str> = (&list).into();`-shaped call
20166        // site or a
20167        // `DepList::ALL.iter().map(std::rc::Rc::<str>::from)`-shaped
20168        // pipe reaches through this impl and no other — the paired
20169        // owned-input `From<DepList> for std::rc::Rc<str>` impl alone
20170        // would force every borrowed-input call site through a spurious
20171        // `Copy` deref
20172        // (`std::rc::Rc::<str>::from((*list).as_str())`) or a
20173        // `.copied()` restatement whose type bounds have no compile-
20174        // time link back to the substrate primitive.
20175        //
20176        // Closes the `{Self, &Self}` input-shape corner on the third
20177        // caixa-core-internal closed-set fieldless typed enum peer of
20178        // the substrate-wide trait-idiomatic [`std::rc::Rc<str>`]
20179        // forward-projection campaign, matching the trajectory the
20180        // paired [`crate::CaixaKind`] (e04aff0),
20181        // [`crate::dialeto::CaixaDialeto`] (c5595e5), and
20182        // [`crate::render::PathShapeViolation`] (31fc43e) pairs walked
20183        // before it on the same tier of the same axis.
20184        //
20185        // Cross-axis partition pin against the paired owned-input
20186        // [`From<DepList> for std::rc::Rc<str>`] and the sibling
20187        // borrowed-input `{&'static str, String, Cow<'static, str>,
20188        // Box<str>, std::sync::Arc<str>}` return-shape axes — locking
20189        // the six return-shape × input-shape paths on the borrowed-
20190        // input surface together by construction so any future detour
20191        // off the substrate-primitive accessor trips at caixa-core
20192        // test time. Then a `.iter().map(std::rc::Rc::<str>::from)`
20193        // pipe witness over [`super::DepList::ALL`] — whose iterator
20194        // yields `&DepList` by construction, so the borrowed-input
20195        // [`std::rc::Rc<str>`] axis is what routes the pipe through
20196        // the substrate-primitive [`super::DepList::as_str`] accessor
20197        // without a spurious [`Copy`] deref (which would only be
20198        // reachable through the owned-input
20199        // [`From<DepList> for std::rc::Rc<str>`] axis by first calling
20200        // `.copied()` on the iterator).
20201        for &variant in super::DepList::ALL {
20202            let via_trait: std::rc::Rc<str> =
20203                <std::rc::Rc<str> as From<&super::DepList>>::from(&variant);
20204            let via_method: &'static str = variant.as_str();
20205            assert_eq!(
20206                via_trait.as_ref(),
20207                via_method,
20208                "From<&DepList> for std::rc::Rc<str> impl must round-\
20209                 trip &DepList::{variant:?} to the same lifted \
20210                 crate::render::DEP_AUTHOR_KEY_DEPS* const \
20211                 DepList::as_str returns — divergence signals a silent \
20212                 detour off the substrate-primitive accessor"
20213            );
20214            let via_into: std::rc::Rc<str> = (&variant).into();
20215            assert_eq!(
20216                via_into.as_ref(),
20217                via_method,
20218                "Into<std::rc::Rc<str>>::into on &DepList::\
20219                 {variant:?} must byte-equal DepList::as_str on the \
20220                 same input — the blanket-derived Into shape on the \
20221                 borrowed-input surface must resolve to the same \
20222                 as_str dispatch as the explicit From impl"
20223            );
20224            let owned_rc: std::rc::Rc<str> =
20225                <std::rc::Rc<str> as From<super::DepList>>::from(variant);
20226            assert_eq!(
20227                via_trait, owned_rc,
20228                "From<&DepList> for std::rc::Rc<str> and \
20229                 From<DepList> for std::rc::Rc<str> must resolve \
20230                 identically on DepList::{variant:?} — divergence \
20231                 signals the borrowed-input and owned-input \
20232                 std::rc::Rc<str> forward-projection input-shape \
20233                 paths have drifted onto different emit-sets"
20234            );
20235            let borrowed_static: &'static str =
20236                <&'static str as From<&super::DepList>>::from(&variant);
20237            assert_eq!(
20238                via_trait.as_ref(),
20239                borrowed_static,
20240                "From<&DepList> for std::rc::Rc<str> and \
20241                 From<&DepList> for &'static str must resolve \
20242                 identically on DepList::{variant:?} — divergence \
20243                 signals the borrowed-input std::rc::Rc<str> and \
20244                 &'static str return-shape paths have drifted onto \
20245                 different emit-sets"
20246            );
20247            let borrowed_string: String = <String as From<&super::DepList>>::from(&variant);
20248            assert_eq!(
20249                via_trait.as_ref(),
20250                borrowed_string.as_str(),
20251                "From<&DepList> for std::rc::Rc<str> and \
20252                 From<&DepList> for String must resolve identically on \
20253                 DepList::{variant:?} — divergence signals the \
20254                 borrowed-input std::rc::Rc<str> and owned-`String` \
20255                 return-shape paths have drifted onto different emit-\
20256                 sets"
20257            );
20258            let borrowed_cow: std::borrow::Cow<'static, str> =
20259                <std::borrow::Cow<'static, str> as From<&super::DepList>>::from(&variant);
20260            assert_eq!(
20261                via_trait.as_ref(),
20262                borrowed_cow.as_ref(),
20263                "From<&DepList> for std::rc::Rc<str> and \
20264                 From<&DepList> for Cow<'static, str> must resolve \
20265                 identically on DepList::{variant:?} — divergence \
20266                 signals the borrowed-input std::rc::Rc<str> and \
20267                 Cow<'static, str> return-shape paths have drifted onto \
20268                 different emit-sets"
20269            );
20270            let borrowed_box: Box<str> = <Box<str> as From<&super::DepList>>::from(&variant);
20271            assert_eq!(
20272                via_trait.as_ref(),
20273                borrowed_box.as_ref(),
20274                "From<&DepList> for std::rc::Rc<str> and \
20275                 From<&DepList> for Box<str> must resolve identically \
20276                 on DepList::{variant:?} — divergence signals the \
20277                 borrowed-input std::rc::Rc<str> and Box<str> \
20278                 return-shape paths have drifted onto different emit-sets"
20279            );
20280            let borrowed_arc: std::sync::Arc<str> =
20281                <std::sync::Arc<str> as From<&super::DepList>>::from(&variant);
20282            assert_eq!(
20283                via_trait.as_ref(),
20284                borrowed_arc.as_ref(),
20285                "From<&DepList> for std::rc::Rc<str> and \
20286                 From<&DepList> for std::sync::Arc<str> must resolve \
20287                 identically on DepList::{variant:?} — divergence \
20288                 signals the borrowed-input std::rc::Rc<str> and \
20289                 std::sync::Arc<str> return-shape paths have drifted \
20290                 onto different emit-sets (the two disjoint reference-\
20291                 counted trait tables have desynchronized on the \
20292                 caixa-core two-list dep-graph axis)"
20293            );
20294        }
20295        let via_iter: Vec<std::rc::Rc<str>> = super::DepList::ALL
20296            .iter()
20297            .map(std::rc::Rc::<str>::from)
20298            .collect();
20299        let via_method: Vec<std::rc::Rc<str>> = super::DepList::ALL
20300            .iter()
20301            .map(|l| std::rc::Rc::<str>::from(l.as_str()))
20302            .collect();
20303        assert_eq!(
20304            via_iter, via_method,
20305            "`.iter().map(std::rc::Rc::<str>::from)` over \
20306             DepList::ALL — a call site whose iteration axis holds \
20307             `&DepList` by construction — must byte-equal \
20308             `.iter().map(|l| std::rc::Rc::<str>::from(l.as_str()))` \
20309             on every arm — the borrowed-input std::rc::Rc<str> \
20310             `From<&DepList> for std::rc::Rc<str>` axis is what makes \
20311             the `std::rc::Rc::<str>::from` composition route through \
20312             the substrate-primitive `DepList::as_str` accessor \
20313             without a spurious `Copy` deref (which would only be \
20314             reachable through the owned-input \
20315             `From<DepList> for std::rc::Rc<str>` axis by first \
20316             calling `.copied()` on the iterator)"
20317        );
20318    }
20319
20320    #[test]
20321    fn dep_list_author_keys_covers_every_arm() {
20322        // Load-bearing pin on the substrate-canonical
20323        // [`super::DepList::AUTHOR_KEYS`] exhaustive accept-set roster
20324        // on the `:`-prefixed kebab-case tatara-lisp author-surface
20325        // key axis: every variant of the sibling
20326        // [`super::DepList::ALL`] exhaustive-iteration surface must
20327        // project through [`super::DepList::as_str`] onto an entry the
20328        // [`super::DepList::AUTHOR_KEYS`] roster carries, and the
20329        // roster's length must byte-equal `super::DepList::ALL.len()`
20330        // so a silent skew between the [`super::DepList::as_str`]
20331        // match's arm-set and the roster's arm-set trips here at
20332        // caixa-core test time rather than at a downstream M4
20333        // `mesh.pleme.io/v1alpha1/Caixa` CR admission-webhook rejection
20334        // body's `:deps` / `:deps-dev` accepted-key enumeration miss /
20335        // a `feira dep --list …` "did you mean" hint drift / a
20336        // downstream [`super::DepError`] widening's typed `list:
20337        // DepList` carry that fans on the enum through a stale
20338        // accepted-set. A future arm addition (a `:build-dep` or
20339        // `:tool-dep` third list once the substrate grows Cargo-style
20340        // split-graphs — both trajectory items the sibling
20341        // [`super::DepList::from_wire`] doc block already names)
20342        // extends [`super::DepList::ALL`] as a single edit and this
20343        // pin sweeps the new arm by iteration; the paired
20344        // [`super::DepList::AUTHOR_KEYS`] roster must grow in lockstep
20345        // or this assertion trips. Every entry is further pinned to
20346        // open with the ASCII `:` byte (the tatara-lisp author-surface
20347        // keyword marker) so a silent collapse of the author-key axis
20348        // with any hypothetical peer un-prefixed wire-form axis (an
20349        // entry byte-identical to a sibling `deps` / `deps-dev`
20350        // bare-kebab byte-string that would let an author-key-axis
20351        // consumer accept the un-prefixed vocabulary) trips here
20352        // rather than at a downstream consumer's
20353        // vocabulary-collision miss.
20354        //
20355        // Peer of the sibling
20356        // [`crate::kind::tests::caixa_kind_wire_names_covers_every_arm`]
20357        // (bd708bd) /
20358        // [`crate::kind::tests::caixa_kind_labels_covers_every_arm`]
20359        // (427fe75) /
20360        // [`crate::supervisor::tests::restart_strategy_wire_names_covers_every_arm`]
20361        // (3033f45) /
20362        // [`crate::supervisor::tests::restart_policy_wire_names_covers_every_arm`]
20363        // (ce9412b) /
20364        // [`crate::aplicacao::tests::placement_strategy_wire_names_covers_every_arm`]
20365        // (3e5b194) /
20366        // [`crate::aplicacao::tests::wit_shape_labels_covers_every_arm`]
20367        // (9d9f585) /
20368        // [`crate::aplicacao::tests::rate_limit_unit_suffixes_covers_every_arm`]
20369        // (b553ec9) /
20370        // [`crate::upgrade::tests::upgrade_instruction_lisp_forms_covers_every_arm`]
20371        // (1898d77) /
20372        // [`crate::upgrade::tests::upgrade_instruction_wire_forms_covers_every_arm`]
20373        // (cc42c0e) pins — the same closed-set exhaustive-roster
20374        // coverage discipline extended here onto the two-list dep-graph
20375        // closed-set typed enum, the ninth substrate-side closed-set
20376        // typed enum on the roster axis and the last unlifted
20377        // `&'static str`-carrying closed-set typed enum on the top-
20378        // level manifest surface to converge onto the discipline.
20379        //
20380        // Fail-before-pass-after locally verified by mutating one arm
20381        // of the paired [`crate::render::DEP_AUTHOR_KEY_*`] const
20382        // family (e.g. rebranding `DEP_AUTHOR_KEY_DEPS_DEV` from
20383        // `":deps-dev"` to `":deps_dev"`) — the length pin still
20384        // passes but the `contains` check fires on the mutated arm;
20385        // and by shortening the roster to one entry — the length pin
20386        // fires first.
20387        assert_eq!(
20388            super::DepList::AUTHOR_KEYS.len(),
20389            super::DepList::ALL.len(),
20390            "DepList::AUTHOR_KEYS.len() must byte-equal \
20391             DepList::ALL.len() — a mismatch means the roster and \
20392             the enum's arm-set have drifted; downstream consumers \
20393             that fan through both will silently disagree on the \
20394             accepted arm-set"
20395        );
20396        for &variant in super::DepList::ALL {
20397            let key = variant.as_str();
20398            assert!(
20399                super::DepList::AUTHOR_KEYS.contains(&key),
20400                "DepList::{variant:?}.as_str() = {key:?} must be a \
20401                 member of DepList::AUTHOR_KEYS — the emitter and the \
20402                 roster have drifted out of lockstep"
20403            );
20404        }
20405        for tag in super::DepList::AUTHOR_KEYS {
20406            let first = tag.chars().next().unwrap_or_else(|| {
20407                panic!(
20408                    "DepList::AUTHOR_KEYS entry {tag:?} must be a \
20409                     non-empty `:`-prefixed kebab-case tatara-lisp \
20410                     author-surface key byte-string"
20411                )
20412            });
20413            assert_eq!(
20414                first, ':',
20415                "DepList::AUTHOR_KEYS entry {tag:?} must open with \
20416                 the ASCII `:` byte (tatara-lisp author-surface \
20417                 keyword marker) — an un-prefixed entry would \
20418                 collide the roster with any hypothetical peer bare-\
20419                 kebab wire-form axis a downstream consumer might \
20420                 disambiguate against"
20421            );
20422        }
20423        // Pin the exact two-arm roster in declaration order so a
20424        // future arm-swap on either the roster or the paired
20425        // `render::DEP_AUTHOR_KEY_*` constants (a rebrand of the
20426        // arm-key mapping that leaves both the length pin and the
20427        // membership pin passing on their own) trips at caixa-core
20428        // test time under `assert_eq!`. Order matches variant
20429        // declaration order verbatim (`Prod` → `Dev`) so the roster
20430        // is the canonical ordering every listing / rendering
20431        // consumer defers to. Same declaration-order pin the sibling
20432        // [`crate::aplicacao::tests::rate_limit_unit_suffixes_covers_every_arm`]
20433        // (b553ec9) closes on the M3 `:politicas :rate-limit`
20434        // canonical-suffix axis.
20435        assert_eq!(
20436            super::DepList::AUTHOR_KEYS,
20437            &[
20438                crate::render::DEP_AUTHOR_KEY_DEPS,
20439                crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
20440            ],
20441            "DepList::AUTHOR_KEYS must enumerate every arm's \
20442             author-surface key exactly once, in variant declaration \
20443             order (Prod → Dev)"
20444        );
20445    }
20446
20447    #[test]
20448    fn dep_list_from_str_routes_through_try_from_str_impl() {
20449        // Fail-before-pass-after byte-parity pin on the newly lifted
20450        // `impl std::str::FromStr for DepList` — asserts the standard-
20451        // library `.parse()` parse-axis entry point and the paired
20452        // [`super::DepList::try_from`] `TryFrom<&str>` impl (which in
20453        // turn routes through the substrate-primitive
20454        // [`super::DepList::from_wire`] `Option<Self>` accessor)
20455        // resolve to the same two-arm accept-set across every arm the
20456        // exhaustive [`super::DepList::ALL`] slice enumerates. First-
20457        // mover on the substrate-wide `FromStr` parse-axis campaign —
20458        // the peer method-named `from_wire` accessor and the paired
20459        // `TryFrom<&str>` trait impl fix the two-arm accept set; this
20460        // pin locks the `FromStr::from_str` trait entry point onto the
20461        // same set so any future divergence (a stray per-arm `match s`
20462        // re-inlining that opens a compile-time link to an un-lifted
20463        // arm-literal, a swap onto a hand-rolled parser that widens
20464        // the accept-set past the two wire-format consts) trips at
20465        // caixa-core test time.
20466        use std::str::FromStr;
20467        for &list in super::DepList::ALL {
20468            let wire = list.as_str();
20469            assert_eq!(
20470                <super::DepList as FromStr>::from_str(wire),
20471                Ok(list),
20472                "FromStr impl on DepList must round-trip \
20473                 DepList::{list:?}.as_str() = {wire:?} back to \
20474                 Ok(DepList::{list:?}) — divergence from \
20475                 DepList::try_from signals a silent detour off the \
20476                 paired reverse-projection trait impl"
20477            );
20478            assert_eq!(
20479                <super::DepList as FromStr>::from_str(wire).ok(),
20480                super::DepList::from_wire(wire),
20481                "FromStr ok()-projection on {wire:?} must byte-equal \
20482                 DepList::from_wire on the same input — divergence \
20483                 signals the two reverse-projection trait paths have \
20484                 drifted off the substrate-primitive accessor"
20485            );
20486            // `.parse::<DepList>()` short-form witness — the stdlib
20487            // consumer surface that reaches the enum through the
20488            // `T: FromStr` bound, not through `TryFrom<&str>`.
20489            let via_parse: Result<super::DepList, ()> = wire.parse();
20490            assert_eq!(
20491                via_parse,
20492                Ok(list),
20493                "`{wire:?}`.parse::<DepList>() must resolve to \
20494                 Ok(DepList::{list:?}) — divergence signals the \
20495                 stdlib `.parse()` short-form has drifted from the \
20496                 lifted `FromStr::from_str` impl"
20497            );
20498        }
20499    }
20500
20501    #[test]
20502    fn dep_list_from_str_rejects_unknown_byte_strings() {
20503        // Rejection witness on the `impl FromStr for DepList` —
20504        // sweeps candidate byte-strings outside the two-arm accept-set
20505        // the sibling [`super::DepList::as_str`] emits (`:deps` /
20506        // `:deps-dev`) and asserts every one lands on `Err(())`, so a
20507        // future accidental widening of the trait impl's accept-set (a
20508        // stray case-fold path, a silent inclusion of a rebrand alias
20509        // like `":packages"`, an English rebrand `":dev-deps"` in
20510        // reverse arm-order that would silently swap the two arms) trips
20511        // at caixa-core test time. Peer of the sibling
20512        // `dep_list_try_from_str_rejects_unknown_byte_strings` rejection
20513        // witness — the two pins together bracket both reverse-projection
20514        // trait impls against the same rejected set.
20515        use std::str::FromStr;
20516        let rejected: &[&str] = &[
20517            "",
20518            " ",
20519            "\t",
20520            "\n",
20521            ":deps ",
20522            " :deps",
20523            ":DEPS",
20524            ":Deps",
20525            ":Deps-Dev",
20526            ":deps_dev",
20527            ":deps-development",
20528            ":dev-deps",
20529            ":packages",
20530            ":packages-dev",
20531            "deps",
20532            "deps-dev",
20533            "Prod",
20534            "Dev",
20535            "prod",
20536            "dev",
20537            "\":deps\"",
20538            "\":deps-dev\"",
20539            ":deps\n",
20540            ":deps-dev\n",
20541        ];
20542        for &input in rejected {
20543            assert_eq!(
20544                <super::DepList as FromStr>::from_str(input),
20545                Err(()),
20546                "FromStr impl on DepList must reject unknown \
20547                 byte-string {input:?} — divergence from \
20548                 DepList::from_wire on the same input signals a silent \
20549                 accept-set widening past the two lifted \
20550                 crate::render::DEP_AUTHOR_KEY_DEPS* wire constants"
20551            );
20552            assert_eq!(
20553                <super::DepList as FromStr>::from_str(input).ok(),
20554                super::DepList::from_wire(input),
20555                "FromStr ok()-projection on {input:?} must byte-equal \
20556                 DepList::from_wire on the same input — divergence \
20557                 signals the FromStr trait path has drifted off the \
20558                 substrate-primitive accessor"
20559            );
20560            let via_parse: Result<super::DepList, ()> = input.parse();
20561            assert_eq!(
20562                via_parse,
20563                Err(()),
20564                "`{input:?}`.parse::<DepList>() must reject the \
20565                 unknown byte-string — divergence signals the stdlib \
20566                 `.parse()` short-form has drifted from the lifted \
20567                 `FromStr::from_str` impl"
20568            );
20569        }
20570    }
20571}
20572
20573#[cfg(test)]
20574mod dep_source_is_variant_tests {
20575    use super::*;
20576
20577    fn all_variants() -> Vec<(DepSource, &'static str)> {
20578        vec![
20579            (
20580                DepSource::Git {
20581                    repo: "github:pleme-io/caixa-teia".into(),
20582                    tag: Some("v0.1.0".into()),
20583                    rev: None,
20584                    branch: None,
20585                },
20586                "Git",
20587            ),
20588            (
20589                DepSource::Path {
20590                    caminho: "../caixa-teia".into(),
20591                },
20592                "Path",
20593            ),
20594        ]
20595    }
20596
20597    fn predicate_row(s: &DepSource) -> [bool; 2] {
20598        [s.is_git(), s.is_path()]
20599    }
20600
20601    // Fail-before-pass-after pin on the [`gen_platform::IsVariant`]
20602    // derive-generated per-arm predicate partition — for every variant
20603    // in `all_variants()`, the observed 2-slot predicate row must equal
20604    // a one-hot row with the `true` at exactly the same index as the
20605    // variant's declaration order. Expected rows are generated live
20606    // from the enumeration rather than transcribed by hand, so a
20607    // copy-paste flip that reroutes one arm through the wrong predicate
20608    // lane trips at the identity-diagonal assertion the way every peer
20609    // sibling [`DepList`] / [`crate::CaixaKind`] / [`crate::CaixaDialeto`]
20610    // / [`crate::supervisor::RestartStrategy`] / [`crate::supervisor::RestartPolicy`]
20611    // / [`crate::upgrade::UpgradeInstruction`] /
20612    // [`crate::aplicacao::PlacementStrategy`] /
20613    // [`crate::aplicacao::RateLimitUnit`] /
20614    // [`crate::aplicacao::WitTarget`] /
20615    // [`crate::render::PathShapeViolation`] partition pin already does.
20616    #[test]
20617    fn dep_source_is_variant_predicates_partition_the_arm_set() {
20618        let variants = all_variants();
20619        for (idx, (variant, name)) in variants.iter().enumerate() {
20620            let observed = predicate_row(variant);
20621            let mut expected = [false; 2];
20622            expected[idx] = true;
20623            assert_eq!(
20624                observed, expected,
20625                "DepSource::{name} at declaration-order slot {idx} must \
20626                 satisfy exactly one is_* predicate (its own); observed \
20627                 row must equal the one-hot expected row — a drift \
20628                 would silently reroute one `:fonte`-arm consumer \
20629                 through the wrong predicate lane"
20630            );
20631        }
20632    }
20633
20634    // Byte-parity pin on the two field-agnostic `matches!` shapes the
20635    // per-arm arm-discriminator predicates replace at any future
20636    // consumer site (a `:fonte`-shape-only lint rule that flags path
20637    // deps outside dev-caixas via `dep.fonte().is_some_and(DepSource::is_path)`,
20638    // a future admission-webhook that rejects `:fonte` shapes outside
20639    // the `is_git()` accept-set, a caixa-lacre indexing pass that
20640    // dispatches on `s.is_git()` without extracting `repo` / `caminho`).
20641    // Refuses a future accidental split between the derived predicate
20642    // and its `matches!` shape — a hand-rolled shadow impl that
20643    // overrides one path, an accidental rebrand that leaves one
20644    // consumer on the raw `matches!` form — on the two load-bearing
20645    // `:fonte`-arm-discriminator axes every downstream substrate
20646    // consumer of the dep-source axis keys off.
20647    #[test]
20648    fn dep_source_is_git_and_is_path_byte_equal_matches_shape() {
20649        for (variant, name) in all_variants() {
20650            let via_matches_git = matches!(variant, DepSource::Git { .. });
20651            let via_predicate_git = variant.is_git();
20652            assert_eq!(
20653                via_predicate_git, via_matches_git,
20654                "DepSource::{name}.is_git() must byte-equal \
20655                 matches!(_, DepSource::Git {{ .. }}) — otherwise a \
20656                 future converged consumer site would silently \
20657                 disagree with its pre-lift shape"
20658            );
20659            let via_matches_path = matches!(variant, DepSource::Path { .. });
20660            let via_predicate_path = variant.is_path();
20661            assert_eq!(
20662                via_predicate_path, via_matches_path,
20663                "DepSource::{name}.is_path() must byte-equal \
20664                 matches!(_, DepSource::Path {{ .. }}) — otherwise a \
20665                 future converged consumer site would silently \
20666                 disagree with its pre-lift shape"
20667            );
20668        }
20669    }
20670
20671    // Cross-pin against every constructor path that materializes a
20672    // [`DepSource`] shape today (the [`DepSource::default_github`]
20673    // resolver-side fallback that materializes an unpinned
20674    // `github:<org>/<nome>` git shorthand, the [`Dep::git`] author-
20675    // surface constructor that materializes a pinned `:tag`-carrying
20676    // `DepSource::Git`, a hand-rolled `DepSource::Path` the dev-mode
20677    // fixture family builds inline). Every constructor's return must
20678    // satisfy the arm-discriminator predicate the constructor's
20679    // variant name matches — a future constructor addition (an
20680    // in-tree registry-fetch pin, a `DepSource::Feira` variant the
20681    // enclosing docstring already names as a trajectory item) surfaces
20682    // as a build-time failure that names the offending drift when its
20683    // return arm doesn't route through the paired predicate.
20684    #[test]
20685    fn dep_source_constructors_route_through_paired_is_variant_predicate() {
20686        let via_default_github = DepSource::default_github("pleme-io", "caixa-teia");
20687        assert!(
20688            via_default_github.is_git(),
20689            "DepSource::default_github must materialize a Git-arm shape — \
20690             a future constructor that routed through a non-Git arm \
20691             (a registry-fetch pin, a `DepSource::Feira` promotion) \
20692             would silently split the resolver's unpinned-shorthand \
20693             materializer from the sole_pin() precedence cascade"
20694        );
20695        assert!(
20696            !via_default_github.is_path(),
20697            "DepSource::default_github must NOT materialize a Path-arm \
20698             shape — the paired negation pin"
20699        );
20700
20701        let via_dep_git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0")
20702            .fonte
20703            .expect("Dep::git materializes a Some(fonte)");
20704        assert!(
20705            via_dep_git.is_git(),
20706            "Dep::git's `:fonte` materialization must land on the Git \
20707             arm — the author-surface pinned-git constructor's return \
20708             must route through the paired predicate"
20709        );
20710        assert!(!via_dep_git.is_path(), "paired negation pin");
20711
20712        let via_path = DepSource::Path {
20713            caminho: "../caixa-teia".into(),
20714        };
20715        assert!(
20716            via_path.is_path(),
20717            "the dev-mode Path-arm materialization must satisfy is_path()"
20718        );
20719        assert!(!via_path.is_git(), "paired negation pin");
20720    }
20721
20722    // ── `dep_nome_axis_reason_ctors!` — the `{ nome: String, <axis>:
20723    //    String, reason: String }` three-slot envelope on `DepError`,
20724    //    strict sibling of the peer `dep_nome_only_ctors!` (792aa92) on
20725    //    the one-slot `{ nome }` envelope, `dep_nome_list_ctors!`
20726    //    (6f5e0cd) on the two-slot `{ nome, list: &'static str }`
20727    //    envelope, `fonte_caminho_ctors!` (f85f145) on the two-slot
20728    //    `{ nome, caminho }` envelope, and `fonte_caminho_byte_ctors!`
20729    //    (0e35793) on the three-slot `{ nome, caminho, byte }` envelope.
20730
20731    #[test]
20732    fn versao_invalid_ctor_matches_struct_literal_wrap() {
20733        assert_eq!(
20734            DepError::versao_invalid("caixa-teia", "^0..1", "invalid comparator".to_string()),
20735            DepError::VersaoInvalid {
20736                nome: "caixa-teia".to_string(),
20737                versao: "^0..1".to_string(),
20738                reason: "invalid comparator".to_string(),
20739            },
20740            "versao_invalid ctor must produce byte-equal \
20741             `DepError::VersaoInvalid` to the pre-lift struct-literal wrap",
20742        );
20743    }
20744
20745    #[test]
20746    fn fonte_repo_shape_ctor_matches_struct_literal_wrap() {
20747        assert_eq!(
20748            DepError::fonte_repo_shape(
20749                "caixa-teia",
20750                "-upload-pack=evil",
20751                "leading dash rejected".to_string(),
20752            ),
20753            DepError::FonteRepoShape {
20754                nome: "caixa-teia".to_string(),
20755                repo: "-upload-pack=evil".to_string(),
20756                reason: "leading dash rejected".to_string(),
20757            },
20758            "fonte_repo_shape ctor must produce byte-equal \
20759             `DepError::FonteRepoShape` to the pre-lift struct-literal wrap",
20760        );
20761    }
20762
20763    #[test]
20764    fn caracteristica_invalid_ctor_matches_struct_literal_wrap() {
20765        assert_eq!(
20766            DepError::caracteristica_invalid(
20767                "caixa-teia",
20768                "bad feature!",
20769                "embedded space rejected".to_string(),
20770            ),
20771            DepError::CaracteristicaInvalid {
20772                nome: "caixa-teia".to_string(),
20773                caracteristica: "bad feature!".to_string(),
20774                reason: "embedded space rejected".to_string(),
20775            },
20776            "caracteristica_invalid ctor must produce byte-equal \
20777             `DepError::CaracteristicaInvalid` to the pre-lift struct-literal wrap",
20778        );
20779    }
20780
20781    #[test]
20782    fn dep_nome_axis_reason_ctors_route_nome_axis_and_reason_through_uniformly() {
20783        // Cross-axis routing pin: sweep the three constructor input axes
20784        // (`nome: &str`, `<axis>: &str`, `reason: String`) through
20785        // distinct-per-axis fixtures against every generated arm in the
20786        // [`dep_nome_axis_reason_ctors!`] macro, so any wrapper-side
20787        // lowercase / trim / truncate on the two `&str` axes — a silent
20788        // field swap between `nome`, the middle `<axis>` field, and
20789        // `reason`, or a `reason` axis silently rerouted through
20790        // `.to_string()` instead of forwarded owned — surfaces here rather
20791        // than at a downstream diagnostic-shape mismatch. Peer of the
20792        // sibling `fonte_caminho_byte_ctors_route_nome_caminho_and_byte_
20793        // through_to_string` (0e35793) cross-axis routing pin on the same
20794        // envelope's `{ nome, caminho, byte }` three-slot family and of
20795        // the peer `dep_nome_list_ctors_route_nome_and_list_through_
20796        // uniformly` (6f5e0cd) pin on the same envelope's two-slot family
20797        // — extended here onto the `{ nome, <axis>: String, reason:
20798        // String }` three-slot envelope so every substrate-primitive ctor
20799        // family in caixa-core's `DepError` envelope guarantees each field
20800        // routes the caller's value verbatim through `.to_string()` (or
20801        // owned-forward for `reason: String`) in declared field order.
20802        // Distinct-per-axis fixtures rule out any two-axis swap
20803        // (`nome` ↔ `<axis>`, `<axis>` ↔ `reason`) that would still pass a
20804        // same-fixture-per-axis pin.
20805        let nome = "sibling-teia";
20806        let axis = "distinct-axis-value";
20807        let reason = "distinct rejection sentence".to_string();
20808        assert_eq!(
20809            DepError::versao_invalid(nome, axis, reason.clone()),
20810            DepError::VersaoInvalid {
20811                nome: nome.to_string(),
20812                versao: axis.to_string(),
20813                reason: reason.clone(),
20814            },
20815            "versao_invalid must route `nome` → `nome`, `axis` → `versao`, \
20816             `reason` → `reason` in declared field order",
20817        );
20818        assert_eq!(
20819            DepError::fonte_repo_shape(nome, axis, reason.clone()),
20820            DepError::FonteRepoShape {
20821                nome: nome.to_string(),
20822                repo: axis.to_string(),
20823                reason: reason.clone(),
20824            },
20825            "fonte_repo_shape must route `nome` → `nome`, `axis` → `repo`, \
20826             `reason` → `reason` in declared field order",
20827        );
20828        assert_eq!(
20829            DepError::caracteristica_invalid(nome, axis, reason.clone()),
20830            DepError::CaracteristicaInvalid {
20831                nome: nome.to_string(),
20832                caracteristica: axis.to_string(),
20833                reason: reason.clone(),
20834            },
20835            "caracteristica_invalid must route `nome` → `nome`, \
20836             `axis` → `caracteristica`, `reason` → `reason` in declared \
20837             field order",
20838        );
20839    }
20840
20841    // ── `dep_nome_axis_ctors!` — the `{ nome: String, <axis>: String }`
20842    //    two-slot envelope on `DepError`, missing rung between
20843    //    `dep_nome_only_ctors!` (792aa92) on the one-slot `{ nome }`
20844    //    envelope and `dep_nome_axis_reason_ctors!` (5621f8a) on the
20845    //    three-slot `{ nome, <axis>: String, reason: String }` envelope.
20846    //    Sibling of `dep_nome_list_ctors!` (6f5e0cd) on the peer
20847    //    two-slot `{ nome, list: &'static str }` envelope (same slot
20848    //    count, `&'static str` axis instead of owned `String` axis).
20849
20850    #[test]
20851    fn fonte_pin_empty_ctor_matches_struct_literal_wrap() {
20852        assert_eq!(
20853            DepError::fonte_pin_empty("caixa-teia", ":tag"),
20854            DepError::FontePinEmpty {
20855                nome: "caixa-teia".to_string(),
20856                pin: ":tag".to_string(),
20857            },
20858            "fonte_pin_empty ctor must produce byte-equal \
20859             `DepError::FontePinEmpty` to the pre-lift struct-literal wrap \
20860             on the same `(&str, &str)` fixture",
20861        );
20862    }
20863
20864    #[test]
20865    fn fonte_pin_ambiguous_ctor_matches_struct_literal_wrap() {
20866        assert_eq!(
20867            DepError::fonte_pin_ambiguous("caixa-teia", ":tag, :rev"),
20868            DepError::FontePinAmbiguous {
20869                nome: "caixa-teia".to_string(),
20870                pins: ":tag, :rev".to_string(),
20871            },
20872            "fonte_pin_ambiguous ctor must produce byte-equal \
20873             `DepError::FontePinAmbiguous` to the pre-lift struct-literal \
20874             wrap on the same `(&str, &str)` fixture",
20875        );
20876    }
20877
20878    #[test]
20879    fn caracteristica_duplicate_ctor_matches_struct_literal_wrap() {
20880        assert_eq!(
20881            DepError::caracteristica_duplicate("caixa-teia", "http"),
20882            DepError::CaracteristicaDuplicate {
20883                nome: "caixa-teia".to_string(),
20884                caracteristica: "http".to_string(),
20885            },
20886            "caracteristica_duplicate ctor must produce byte-equal \
20887             `DepError::CaracteristicaDuplicate` to the pre-lift \
20888             struct-literal wrap on the same `(&str, &str)` fixture",
20889        );
20890    }
20891
20892    #[test]
20893    fn fonte_pin_ambiguous_ctor_matches_owned_string_join_shape() {
20894        // Owned-`String` routing pin: thread the real
20895        // `set.join(", ")` `String` carrier through the ctor's
20896        // `&str`-parameter Deref coercion, so the ambiguity-arm
20897        // wire-up site's actual `&set.join(", ")` shape stays
20898        // byte-equal to a direct `":tag, :rev"` literal. A future
20899        // parameter-shape change silently dropping the Deref
20900        // coercion route (e.g., a switch to `impl Into<String>`)
20901        // surfaces here rather than at the wire-up's compile
20902        // error far from the ctor definition.
20903        let set: Vec<&'static str> = vec![":tag", ":rev"];
20904        let joined: String = set.join(", ");
20905        assert_eq!(
20906            DepError::fonte_pin_ambiguous("caixa-teia", &joined),
20907            DepError::FontePinAmbiguous {
20908                nome: "caixa-teia".to_string(),
20909                pins: ":tag, :rev".to_string(),
20910            },
20911            "fonte_pin_ambiguous ctor must accept an owned-`String` \
20912             `&set.join(\", \")` carrier via Deref coercion — the exact \
20913             shape the ambiguity-arm wire-up site passes into it",
20914        );
20915    }
20916
20917    #[test]
20918    fn dep_nome_axis_ctors_route_nome_and_axis_through_to_string_uniformly() {
20919        // Cross-axis routing pin: sweep the two constructor input axes
20920        // (`nome: &str`, `<axis>: &str`) through distinct-per-axis
20921        // fixtures against every generated arm in the
20922        // [`dep_nome_axis_ctors!`] macro, so any wrapper-side lowercase /
20923        // trim / truncate at codegen time — a silent field swap between
20924        // `nome` and the middle `<axis>` field, or a `<axis>` axis
20925        // silently rerouted through the wrong field on any one variant
20926        // — surfaces here rather than at a downstream diagnostic-shape
20927        // mismatch. Peer of the sibling
20928        // `dep_nome_list_ctors_route_nome_and_list_through_uniformly`
20929        // (6f5e0cd) pin on the same envelope's peer two-slot family
20930        // (`{ nome, list: &'static str }`) and of the sibling
20931        // `dep_nome_axis_reason_ctors_route_nome_axis_and_reason_through_uniformly`
20932        // (5621f8a) pin on the same envelope's three-slot `{ nome,
20933        // <axis>: String, reason: String }` family — extended here onto
20934        // the `{ nome, <axis>: String }` two-slot envelope so the last
20935        // per-`DepError`-two-slot-owned-axis rung on the ctor-family
20936        // ladder guarantees each field routes the caller's value
20937        // verbatim through `.to_string()` in declared field order.
20938        // Distinct-per-axis fixtures rule out any two-axis swap
20939        // (`nome` ↔ `<axis>`) that would still pass a same-fixture-
20940        // per-axis pin.
20941        let nome = "sibling-teia";
20942        let axis = "distinct-axis-value";
20943        assert_eq!(
20944            DepError::fonte_pin_empty(nome, axis),
20945            DepError::FontePinEmpty {
20946                nome: nome.to_string(),
20947                pin: axis.to_string(),
20948            },
20949            "fonte_pin_empty must route `nome` → `nome`, `axis` → `pin` \
20950             in declared field order",
20951        );
20952        assert_eq!(
20953            DepError::fonte_pin_ambiguous(nome, axis),
20954            DepError::FontePinAmbiguous {
20955                nome: nome.to_string(),
20956                pins: axis.to_string(),
20957            },
20958            "fonte_pin_ambiguous must route `nome` → `nome`, `axis` → `pins` \
20959             in declared field order",
20960        );
20961        assert_eq!(
20962            DepError::caracteristica_duplicate(nome, axis),
20963            DepError::CaracteristicaDuplicate {
20964                nome: nome.to_string(),
20965                caracteristica: axis.to_string(),
20966            },
20967            "caracteristica_duplicate must route `nome` → `nome`, \
20968             `axis` → `caracteristica` in declared field order",
20969        );
20970    }
20971
20972    #[test]
20973    fn nome_invalid_ctor_matches_struct_literal_wrap() {
20974        // Equivalence pin: the ctor produces byte-equal
20975        // `DepError::NomeInvalid` to the pre-lift open-coded struct-
20976        // literal that cloned the offending `:deps :nome` verbatim and
20977        // forwarded the [`crate::render::is_dns_1123_label`]-shaped
20978        // owned `reason` payload at the caller site inside
20979        // [`Dep::validate`]. Guards any future field-addition /
20980        // reordering / accessor-return tweak on the variant. Sibling of
20981        // the peer four-slot `fonte_pin_shape` ctor equivalence pins
20982        // (below) and the sibling three-slot
20983        // `dep_nome_axis_reason_ctors_route_nome_axis_and_reason_through_uniformly`
20984        // pin on the same envelope's three-slot `{ nome, <axis>: String,
20985        // reason: String }` family.
20986        let nome = "Caixa-Teia";
20987        let reason = crate::render::is_dns_1123_label(nome).unwrap_err();
20988        let via_ctor = DepError::nome_invalid(nome, reason.clone());
20989        let via_literal = DepError::NomeInvalid {
20990            nome: nome.to_string(),
20991            reason,
20992        };
20993        assert_eq!(
20994            via_ctor, via_literal,
20995            "nome_invalid(nome, reason) must byte-equal the open-coded \
20996             NomeInvalid struct-literal on the same `(nome, reason)` fixture"
20997        );
20998        assert_eq!(
20999            via_ctor.to_string(),
21000            via_literal.to_string(),
21001            "Display byte-string must byte-equal the open-coded struct-literal"
21002        );
21003    }
21004
21005    #[test]
21006    fn nome_invalid_ctor_routes_nome_and_reason_through_to_string_uniformly() {
21007        // Boundary-sweep pin on the ctor's two-slot projection: sweep
21008        // the two ctor input axes (`nome: &str`, `reason: String`)
21009        // through distinct-per-axis fixtures against a representative
21010        // set of DNS-1123-refused `:deps :nome` byte-strings, so any
21011        // wrapper-side silent lowercase / trim / truncate at codegen
21012        // time — a silent field swap between `nome` and `reason`, an
21013        // accidental `nome`-side `.to_lowercase()` shim, or a `.into()`
21014        // divergence on the `reason` axis — surfaces at caixa-core
21015        // build time rather than at a downstream diagnostic consumer
21016        // that reads `err.nome` / `err.reason` back and gets a different
21017        // value than the one it stored. Peer of the sibling
21018        // `dep_nome_axis_ctors_route_nome_and_axis_through_to_string_uniformly`
21019        // (7f7c950) pin on the same envelope's peer two-slot family
21020        // (`{ nome, <axis>: String }`) — extended here onto the
21021        // `{ nome, reason: String }` two-slot rung the sole `NomeInvalid`
21022        // variant carries. Distinct-per-axis fixtures rule out any
21023        // two-axis swap (`nome` ↔ `reason`) that would still pass a
21024        // same-fixture-per-axis pin. The sweep list carries a mixed
21025        // DNS-1123-refused set (uppercase-carrying, underscore-carrying,
21026        // dot-carrying, leading-hyphen, trailing-hyphen, slash-carrying,
21027        // over-63-byte) so a future silent per-input normalization
21028        // surfaces on the arm that diverges.
21029        for nome in [
21030            "Caixa-Teia",
21031            "caixa_teia",
21032            "caixa.teia",
21033            "-caixa-teia",
21034            "caixa-teia-",
21035            "caixa/teia",
21036            &"a".repeat(64),
21037        ] {
21038            let reason = crate::render::is_dns_1123_label(nome)
21039                .expect_err("fixture must be a DNS-1123-refused label");
21040            let via_ctor = DepError::nome_invalid(nome, reason.clone());
21041            let DepError::NomeInvalid {
21042                nome: stored_nome,
21043                reason: stored_reason,
21044            } = via_ctor
21045            else {
21046                panic!("nome_invalid must construct NomeInvalid for {nome:?}");
21047            };
21048            assert_eq!(
21049                stored_nome, nome,
21050                "nome slot must round-trip verbatim through `.to_string()` for {nome:?}"
21051            );
21052            assert_eq!(
21053                stored_reason, reason,
21054                "reason slot must forward the owned `String` verbatim for {nome:?}"
21055            );
21056        }
21057    }
21058
21059    #[test]
21060    fn validate_nome_invalid_arm_routes_through_nome_invalid_ctor() {
21061        // End-to-end pin: the sole in-crate wire-up site
21062        // ([`Dep::validate`]'s DNS-1123 refusal arm) routes through
21063        // [`DepError::nome_invalid`] and the observed `Err` byte-equals
21064        // the ctor's output on the same DNS-1123-refused `:deps :nome`
21065        // fixture, with identical `Display` rendering. A future silent
21066        // de-lift of the wire-up back to the open-coded struct-literal
21067        // trips this test at caixa-core build time rather than at a
21068        // downstream diagnostic consumer far from the wire-up commit.
21069        // Sibling of the peer
21070        // `nome_invalid_diagnostic_carries_offending_name` pattern-match
21071        // pin on the same wire-up — extended here from a `matches!`
21072        // shape check to a byte-identity + Display parity route through
21073        // the ctor.
21074        let d = Dep::simple("Caixa_Teia", "^0.1");
21075        let observed = d.validate().unwrap_err();
21076        let reason = crate::render::is_dns_1123_label("Caixa_Teia")
21077            .expect_err("fixture must be DNS-1123-refused");
21078        let expected = DepError::nome_invalid("Caixa_Teia", reason);
21079        assert_eq!(
21080            observed, expected,
21081            "Dep::validate's DNS-1123 refusal arm must byte-equal \
21082             nome_invalid(nome, reason)"
21083        );
21084        assert_eq!(
21085            observed.to_string(),
21086            expected.to_string(),
21087            "Display byte-string parity"
21088        );
21089    }
21090}