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    /// Canonical author-surface tag every substrate consumer that
3223    /// names the offending dep-list in a diagnostic reaches for —
3224    /// [`crate::render::DEP_AUTHOR_KEY_DEPS`] for [`Self::Prod`] and
3225    /// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] for [`Self::Dev`],
3226    /// the same `&'static str` payload the sibling
3227    /// [`DepError::DuplicateNome`] and [`DepError::DepIsSelf`] variants
3228    /// already carry. Routing every dep-list diagnostic through the
3229    /// closed-set enum's `as_str` closes the last `&'static str`-shape
3230    /// literal-carry axis on the two-list dep-graph surface — a
3231    /// future kebab-case rebrand (`":deps"` → `":packages"`) or a
3232    /// wire-format promotion (a distinct diagnostic form for the
3233    /// `Dev` arm) reaches every consumer through one edit on the
3234    /// canonical constant, not a coordinated rewrite across the
3235    /// substrate's dep-graph consumers.
3236    #[must_use]
3237    pub const fn as_str(self) -> &'static str {
3238        match self {
3239            Self::Prod => crate::render::DEP_AUTHOR_KEY_DEPS,
3240            Self::Dev => crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
3241        }
3242    }
3243
3244    /// Substrate-canonical reverse projection on the two-list dep-graph
3245    /// axis — parses the author-surface wire tag back to the typed
3246    /// variant, or `None` when `s` is outside the closed-set arm-string
3247    /// set [`Self::as_str`] emits. Dispatches on the same lifted
3248    /// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3249    /// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] constants the
3250    /// [`Self::as_str`] emitter walks, so the parse and emit halves of
3251    /// the round-trip migrate through one caixa-core edit on any future
3252    /// list-axis addition.
3253    ///
3254    /// Prior to this lift the substrate carried only the forward
3255    /// `Self → &str` projection on the two-list dep-graph axis (the
3256    /// [`Self::as_str`] emitter, the [`std::fmt::Display`] impl routed
3257    /// through it, the two [`DepError::DuplicateNome`] /
3258    /// [`DepError::DepIsSelf`] variants that carry the wire tag verbatim
3259    /// as a `&'static str` `list:` field). Every future consumer that
3260    /// wanted to promote the wire tag back to the typed enum (a future
3261    /// `feira dep --list <deps|deps-dev>` CLI arg-parse that binds the
3262    /// wire form into the typed enum before dispatching to
3263    /// [`crate::Caixa::deps_of`] / [`crate::Caixa::push_dep`], the M4
3264    /// `mesh.pleme.io/v1alpha1/Caixa` CR materializer's admission-time
3265    /// wire re-parse of the per-list diagnostic body, a future
3266    /// [`DepError`] widening that promotes the two `list: &'static str`
3267    /// fields to a typed `list: DepList` carry so downstream consumers
3268    /// dispatch on the enum rather than string-comparing the wire
3269    /// scalar) would have had to re-inline a two-arm `match s { ":deps"
3270    /// => …, ":deps-dev" => …, _ => … }` cascade that expressed no
3271    /// compile-time link back to the typed [`DepList`] enum. A future
3272    /// variant addition (a `:build-dep` or `:test-dep` third list once
3273    /// the substrate grows Cargo-style split-graphs, a `:tool-dep` for
3274    /// build-time-only tooling per the peer Cargo `[build-dependencies]`
3275    /// / `[target.<cfg>.dev-dependencies]` future admission surface)
3276    /// would silently split the wire byte-string the emitter walks from
3277    /// the parser's arm-set — the round-trip would carry the new list
3278    /// through the forward projection but land on the fallback silently
3279    /// at every non-updated reverse parser, far from the arm-addition
3280    /// commit that caused the drift. Lifting the resolver to a typed
3281    /// method on the substrate primitive closes the drift footgun by
3282    /// construction: the parser's accept-set is the same set the
3283    /// [`Self::as_str`] emitter walks (routed through the same lifted
3284    /// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3285    /// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] consts), so both halves
3286    /// of the round-trip migrate through one caixa-core edit on any
3287    /// future list-axis addition.
3288    ///
3289    /// Same closed-set-reverse-projection discipline the sibling
3290    /// [`crate::CaixaKind::from_wire`] (2aa6d23) /
3291    /// [`crate::supervisor::RestartStrategy::from_wire`] (4eec29c) /
3292    /// [`crate::supervisor::RestartPolicy::from_wire`] (dd32ccf) /
3293    /// [`crate::aplicacao::PlacementStrategy::from_wire`] (18c7342) /
3294    /// [`crate::aplicacao::RateLimitUnit::from_suffix`] typed enums
3295    /// carry on the peer wire-side `str → Self` axes — extended onto
3296    /// the two-list dep-graph closed-set axis, the sixth substrate-side
3297    /// closed-set typed enum on the caixa surface to converge on the
3298    /// two-way `str ↔ Self` round-trip. Method-named `from_wire` (not
3299    /// `from_str`) to match the peer shapes verbatim and side-step the
3300    /// derived [`std::str::FromStr`] impls the sibling
3301    /// [`gen_platform::FromStrKind`]-carrying axes install on their
3302    /// kebab-case dispatcher-catalog identity. Returns `Option<Self>`
3303    /// (rather than `Result<Self, _>`) to match the peer shapes: the
3304    /// caller picks the diagnostic form appropriate for its use site —
3305    /// a future `feira dep --list …` arg-parse that surfaces
3306    /// `unknown list: <arg>` at the CLI builds one on top by iterating
3307    /// [`Self::ALL`], while the future M4 admission-webhook's rejection
3308    /// path folds `None` onto its per-CR structured refusal body.
3309    #[must_use]
3310    pub fn from_wire(s: &str) -> Option<Self> {
3311        match s {
3312            crate::render::DEP_AUTHOR_KEY_DEPS => Some(Self::Prod),
3313            crate::render::DEP_AUTHOR_KEY_DEPS_DEV => Some(Self::Dev),
3314            _ => None,
3315        }
3316    }
3317}
3318
3319/// Route [`std::fmt::Display`] through [`DepList::as_str`], so every
3320/// consumer that formats the axis as user-facing text (a future
3321/// `feira app graph` per-list summary, a future M4 admission-webhook
3322/// rejection body naming the offending list, this crate's own
3323/// [`DepError`] `#[error(...)]` templates when they widen to carry a
3324/// typed [`DepList`]) lands on the same author-surface tag the
3325/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3326/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] constants carry. Same
3327/// as-str-through-Display convergence discipline the sibling
3328/// [`crate::aplicacao::PlacementStrategy`],
3329/// [`crate::aplicacao::RateLimitUnit`],
3330/// [`crate::supervisor::RestartStrategy`],
3331/// [`crate::supervisor::RestartPolicy`], and [`crate::CaixaKind`]
3332/// closed-set typed enums carry.
3333impl std::fmt::Display for DepList {
3334    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3335        f.write_str(self.as_str())
3336    }
3337}
3338
3339/// Substrate-canonical [`AsRef<str>`] projection on the two-list
3340/// dep-graph closed-set typed enum — routes through the same
3341/// [`DepList::as_str`] `pub const fn` scalar accessor the paired
3342/// [`std::fmt::Display`] impl already delegates through, so any future
3343/// consumer that binds a [`DepList`] through the standard-library
3344/// `impl AsRef<str>` bound (a [`std::process::Command::arg`] shell-out
3345/// that composes the canonical author-surface tag into a
3346/// `feira dep --list <deps|deps-dev>` diagnostic overlay, a
3347/// `tracing::field::Value::Str`-arm structured-log recorder on the
3348/// [`DepError::DuplicateNome`] / [`DepError::DepIsSelf`] refusal paths,
3349/// a [`std::collections::HashMap`] lookup keyed on the canonical tag
3350/// through `map.get::<str>(list.as_ref())` on a future M4 admission-
3351/// webhook's per-list rejection-body composition table) reaches the
3352/// paired [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3353/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] byte-string through one
3354/// substrate-primitive dispatch rather than an open-coded `.as_str()`
3355/// re-inlining at every wire-up.
3356///
3357/// Same "route the trait impl through the substrate-primitive
3358/// accessor" discipline the sibling [`crate::CaixaDialeto`]
3359/// [`AsRef<str>`] impl (1723611), the [`crate::aplicacao::RateLimitUnit`]
3360/// [`AsRef<str>`] impl (d8136db), the [`crate::CaixaKind`]
3361/// [`AsRef<str>`] impl (cd2091f), the M3
3362/// [`crate::aplicacao::PlacementStrategy`] [`AsRef<str>`] impl
3363/// (d86edd2), the M2 [`crate::supervisor::RestartPolicy`]
3364/// [`AsRef<str>`] impl (419ea81), the M2
3365/// [`crate::supervisor::RestartStrategy`] [`AsRef<str>`] impl
3366/// (63eb1a4), and the [`crate::CaixaVersion`] [`AsRef<str>`] impl
3367/// (16d5c7e) carry — closes the substrate primitive's
3368/// [`AsRef<str>`] projection axis on the seventh (and last unlifted)
3369/// closed-set typed enum on the caixa surface: the two-list dep-graph
3370/// axis previously carried [`fmt::Display`]-through-`as_str` but not
3371/// yet the paired [`AsRef<str>`] impl, so a downstream consumer that
3372/// bound the enum through the standard-library `AsRef<str>` trait had
3373/// to reach the canonical byte-string through an open-coded
3374/// `.as_str()` call rather than the trait-idiomatic `.as_ref()` the
3375/// peer closed-set typed enums already admit.
3376///
3377/// Pinned load-bearing by
3378/// [`tests::dep_list_as_ref_str_routes_through_as_str_accessor`]
3379/// (byte-parity pin against [`DepList::as_str`] across the two-arm
3380/// closed set) and
3381/// [`tests::dep_list_as_ref_str_routes_through_display_via_shared_accessor`]
3382/// (three-path convergence: `AsRef<str>` + `Display` + `as_str` all
3383/// resolve to the same byte-string per arm) — any future silent detour
3384/// that routes the impl through a divergent projection (a per-arm
3385/// inline `match self { DepList::Prod => ":deps", … }` re-inlining
3386/// that opens a compile-time link to the un-lifted arm-literal, a
3387/// swap onto a second projection axis) trips at caixa-core test time
3388/// under `assert_eq!` rather than at a downstream
3389/// `impl AsRef<str>`-bound consumer's silent split.
3390impl AsRef<str> for DepList {
3391    fn as_ref(&self) -> &str {
3392        self.as_str()
3393    }
3394}
3395
3396/// Trait-idiomatic *reverse* projection on the two-list dep-graph
3397/// [`DepList`] closed-set typed enum — routes through the paired
3398/// substrate-primitive [`DepList::from_wire`] `Option<Self>` accessor
3399/// so `<DepList>::try_from(":deps")` reaches the same two-arm
3400/// accept-set the sibling [`DepList::from_wire`] resolver dispatches
3401/// through, rather than an open-coded per-arm
3402/// `match s { ":deps" => Ok(Self::Prod), … }` cascade whose arm-set
3403/// has no compile-time link back to the substrate primitive.
3404///
3405/// Corrects a completeness gap in the substrate-wide trait-idiomatic
3406/// reverse-projection campaign (opened by [`crate::CaixaKind`] via
3407/// 3c83606, closed onto 14 sibling closed-set fieldless typed enums
3408/// across the caixa surface — 5b828ed, 6fdd0d9, 5472902, bf78400,
3409/// e67e48a, e21a857, 0a4cc45, a7bf74c, df86c94, bd7da69, 42ab951 —
3410/// which silently omitted [`DepList`] despite this enum being listed
3411/// as a sibling closed-set fieldless typed enum in every peer's
3412/// docstring). Every sibling closed-set fieldless typed enum on the
3413/// caixa surface now carries both trait-idiomatic axes
3414/// (`TryFrom<&str> for Self` + `From<Self> for &'static str`) paired
3415/// against the substrate-primitive canonical projection accessors
3416/// (`as_str`/`variant_slug` + `from_wire`) — the two-list dep-graph
3417/// closed-set is the fifteenth and true-final peer.
3418///
3419/// `type Error = ()` matches the sibling [`DepList::from_wire`]'s
3420/// `Option<Self>` return-shape's deliberate deferral of error typing:
3421/// the caller picks the diagnostic form appropriate for its use site
3422/// (a future `feira dep --list <deps|deps-dev>` arg-parse composes
3423/// `unknown list: <arg> — accepted: {…}` enumerating [`DepList::ALL`];
3424/// the M4 admission-webhook rejection body wraps `Err(())` with the
3425/// accepted-set enumeration).
3426///
3427/// Pinned load-bearing by
3428/// [`tests::dep_list_try_from_str_routes_through_from_wire_accessor`]
3429/// (byte-parity pin against [`DepList::from_wire`] across the two-arm
3430/// accept-set) and
3431/// [`tests::dep_list_try_from_str_rejects_unknown_byte_strings`]
3432/// (rejection witness against silent accept-set widening).
3433impl TryFrom<&str> for DepList {
3434    type Error = ();
3435
3436    fn try_from(s: &str) -> Result<Self, Self::Error> {
3437        Self::from_wire(s).ok_or(())
3438    }
3439}
3440
3441/// Trait-idiomatic *forward* projection on the two-list dep-graph
3442/// [`DepList`] closed-set typed enum onto the `&'static str` axis —
3443/// routes byte-for-byte through the paired substrate-primitive
3444/// [`DepList::as_str`] `pub const fn` accessor so
3445/// `<&'static str>::from(list)` / `list.into::<&'static str>()`
3446/// reaches the same two-arm lifted
3447/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3448/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] const the sibling
3449/// [`std::fmt::Display`], [`AsRef<str>`], and [`DepList::as_str`]
3450/// surfaces already return.
3451///
3452/// Closes the substrate-wide trait-idiomatic forward-projection
3453/// campaign for real — the campaign opened on [`crate::supervisor::RestartStrategy`]
3454/// via 523157d and traced through the 13 sibling closed-set typed
3455/// enums (9fb37d0, edb827b, c189a6f, afa3562, 56998ec, 7fdfbf4,
3456/// 070a6de, f2ca7bc, d4559cb, 5cc3b8b, 2a56127, 07f36bb, 85d0443)
3457/// silently omitted [`DepList`] on both trait-idiomatic axes despite
3458/// every peer's docstring naming it as a sibling. Paired with the
3459/// [`TryFrom<&str> for DepList`] impl immediately above, this closes
3460/// the two-way `DepList ↔ &'static str` round-trip on the trait-
3461/// idiomatic axis pair, mirroring the pre-existing method-named
3462/// [`DepList::as_str`] + [`DepList::from_wire`] pair on the
3463/// substrate-primitive axis pair.
3464///
3465/// The paired [`DepList::as_str`] returns `&'static str` by
3466/// construction — each arm resolves to a
3467/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3468/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str` with
3469/// static lifetime — so the trait's return-type promise is upheld
3470/// structurally.
3471///
3472/// Pinned load-bearing by
3473/// [`tests::dep_list_from_into_static_str_routes_through_as_str_accessor`]
3474/// (byte-parity pin against [`DepList::as_str`] across the two-arm
3475/// emit-set, plus a `const`-context materialization witness for the
3476/// `&'static str` lifetime promise) and
3477/// [`tests::dep_list_from_into_static_str_and_as_str_partition_the_emit_set`]
3478/// (partition pin + two-way round-trip through the paired
3479/// [`TryFrom<&str>`] axis).
3480impl From<DepList> for &'static str {
3481    fn from(list: DepList) -> &'static str {
3482        list.as_str()
3483    }
3484}
3485
3486/// Trait-idiomatic *forward* projection on the two-list dep-graph
3487/// [`DepList`] closed-set typed enum from a *borrowed* input onto the
3488/// `&'static str` axis — the borrowed-input companion to the paired
3489/// owned-input [`From<DepList> for &'static str`] impl immediately
3490/// above. Routes byte-for-byte through the same substrate-primitive
3491/// [`DepList::as_str`] `pub const fn` accessor so every consumer that
3492/// binds a `&DepList` through the standard-library `.into()` /
3493/// [`From<&Self> for &'static str`] axis (a
3494/// `DepList::ALL.iter().map(<&'static str>::from).collect::<Vec<_>>()`
3495/// per-arm accept-set materializer that iterates the substrate-
3496/// canonical [`DepList::ALL`] slice — whose iterator yields `&DepList`,
3497/// not `DepList`, so the owned-input [`From<DepList>`] axis alone
3498/// forces every call site through an explicit `.copied()` /
3499/// dereference / [`Copy`]-bound restatement rather than the direct
3500/// trait-idiomatic projection; a future generic
3501/// `<T: Copy + for<'a> Into<&'static str>>`-bound diagnostic column
3502/// that walks the `iter().map(Into::into)` shape verbatim; the future
3503/// M4 admission-webhook rejection body that composes the accepted-set
3504/// enumeration from an iterated `DepList::ALL.iter().map(|l| l.into())`
3505/// pipe rather than a per-arm `match l { … }` cascade) reaches the same
3506/// two-arm lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3507/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] const the paired
3508/// owned-input [`From<DepList> for &'static str`], the sibling
3509/// [`std::fmt::Display`], [`AsRef<str>`], and [`DepList::as_str`]
3510/// surfaces already return.
3511///
3512/// Opens the substrate-wide trait-idiomatic *borrowed-input*
3513/// forward-projection family on the last-touched closed-set fieldless
3514/// typed enum — first-mover on the borrowed-input axis, mirroring the
3515/// role [`crate::supervisor::RestartStrategy`] played on the owned-
3516/// input axis (523157d). Rust's `From` trait does not auto-derive the
3517/// `From<&Self>` sibling from a `From<Self>` impl (the blanket
3518/// `impl<T, U> From<&T> for U where T: Copy, U: From<T>` does not exist
3519/// in `core`), so every closed-set typed enum that carries the
3520/// owned-input axis but not the borrowed-input axis forces every
3521/// borrowed-input call site through a `.copied()` /
3522/// `<&'static str>::from(*list)` / `list.as_str()` detour whose type
3523/// bounds have no compile-time link to the substrate primitive. The
3524/// remaining fourteen substrate-wide closed-set fieldless typed enum
3525/// peers (`CaixaKind`, `CaixaDialeto`, `RestartStrategy`,
3526/// `RestartPolicy`, `WitShape`, `RateLimitUnit`, `PlacementStrategy`,
3527/// `PathShapeViolation`, `InvariantKind`, `ArchVerdict`, `Severity`,
3528/// `FixSafety`, `Semantic`, `FerriteRuntime`) are the future targets
3529/// of this campaign.
3530///
3531/// Pinned load-bearing by
3532/// [`tests::dep_list_from_borrowed_into_static_str_routes_through_as_str_accessor`]
3533/// (byte-parity pin against [`DepList::as_str`] across the two-arm
3534/// emit-set via a borrowed input, plus a `const`-context materialization
3535/// witness) and
3536/// [`tests::dep_list_from_owned_and_borrowed_into_static_str_agree_on_every_arm`]
3537/// (cross-axis partition pin against the paired owned-input
3538/// [`From<DepList> for &'static str`] impl).
3539impl From<&DepList> for &'static str {
3540    fn from(list: &DepList) -> &'static str {
3541        list.as_str()
3542    }
3543}
3544
3545/// Trait-idiomatic *forward* projection on the two-list dep-graph
3546/// [`DepList`] closed-set typed enum from an *owned* input onto the
3547/// owned-[`String`] axis — routes byte-for-byte through the
3548/// substrate-primitive [`DepList::as_str`] `pub const fn` accessor so
3549/// every consumer that binds a [`DepList`] through the standard-library
3550/// `.into()` / [`From<Self> for String`] (equivalently [`Into<String>`])
3551/// axis reaches the same two-arm lifted
3552/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3553/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] byte-string the paired
3554/// owned-input [`From<DepList> for &'static str`], the borrowed-input
3555/// [`From<&DepList> for &'static str`], the sibling [`std::fmt::Display`],
3556/// [`AsRef<str>`], and [`DepList::as_str`] surfaces already return.
3557///
3558/// Extends the trait-idiomatic *owned-[`String`]* forward-projection
3559/// family (opened on [`crate::supervisor::RestartStrategy`] — 7baa18a —
3560/// the first-mover on the M2 OTP-shape sibling-restart-strategy axis,
3561/// extended onto [`crate::supervisor::RestartPolicy`] — 7851725 — the
3562/// second-of-two-in-M2 per-child restart-decision axis, then onto
3563/// [`crate::CaixaKind`] — 231a18c — the structurally most fundamental
3564/// closed-set fieldless typed enum on the caixa surface, then onto
3565/// [`crate::CaixaDialeto`] — 88942cd — the dialect-classification axis)
3566/// onto the fifth peer: the two-list dep-graph axis [`DepList`] carries.
3567/// Rust's standard library does not carry a blanket
3568/// `impl<T: AsRef<str>> From<T> for String` (nor an
3569/// `impl<T: fmt::Display> From<T> for String`), so every closed-set
3570/// typed enum that carries the paired [`AsRef<str>`] / [`std::fmt::Display`] /
3571/// [`From<Self> for &'static str`] / [`From<&Self> for &'static str`]
3572/// quadruple but not the owned-[`String`] axis forces every owned-string
3573/// call site through a `.to_string()` / `.as_str().to_owned()` /
3574/// `String::from(list.as_str())` detour whose type bounds have no
3575/// compile-time link to the substrate primitive.
3576///
3577/// Same as the peer [`crate::supervisor::RestartStrategy`] /
3578/// [`crate::supervisor::RestartPolicy`] / [`crate::CaixaDialeto`]
3579/// owned-[`String`] axis pairs (whose forward emit and reverse parse
3580/// share one vocabulary by construction — `PascalCase` on the three
3581/// prior peers, the `":deps"` / `":deps-dev"` leading-colon lispy
3582/// author-surface tags on this one), [`DepList`]'s [`DepList::as_str`]
3583/// emit and [`DepList::from_wire`] parse resolve through the same
3584/// lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3585/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] consts by construction
3586/// (there is no wire/diagnostic axis split on this enum — both halves
3587/// of the round-trip route through the same two `pub const &str` values),
3588/// so the owned-[`String`] forward projection this impl exposes composes
3589/// directly with the paired trait-idiomatic reverse
3590/// [`TryFrom<&str>`] axis on the owned-[`String`]'s [`String::as_str`]
3591/// borrow — no intermediate wire-vocab hop like the peer
3592/// [`crate::CaixaKind`] axis pair requires.
3593///
3594/// The remaining ten closed-set typed enums on the caixa substrate
3595/// surface (`PlacementStrategy`, `WitShape`, `RateLimitUnit`,
3596/// `PathShapeViolation`, `InvariantKind`, `ArchVerdict`, `Severity`,
3597/// `FixSafety`, `Semantic`, `FerriteRuntime`) are the future targets of
3598/// this campaign — each carries the same paired [`AsRef<str>`] /
3599/// [`std::fmt::Display`] / [`From<Self> for &'static str`] /
3600/// [`From<&Self> for &'static str`] quadruple that this owned-[`String`]
3601/// axis extends onto.
3602///
3603/// Pinned load-bearing by
3604/// [`tests::dep_list_from_into_owned_string_routes_through_as_str_accessor`]
3605/// (byte-parity pin against [`DepList::as_str`] across the two-arm
3606/// [`DepList::ALL`] emit-set plus a blanket `.into::<String>()` shape
3607/// witness) and
3608/// [`tests::dep_list_from_into_owned_string_and_static_str_agree_on_every_arm`]
3609/// (cross-axis partition against the sibling owned-`&'static str` axis
3610/// and the [`ToString::to_string`] surface, a
3611/// `.iter().copied().map(String::from)` pipe witness over
3612/// [`DepList::ALL`], plus a direct `Self → String → Self` round-trip
3613/// via [`TryFrom<&str>`] on the owned-[`String`]'s [`String::as_str`]
3614/// borrow — composes directly without the wire-vocab intermediate hop
3615/// the peer [`crate::CaixaKind`] axis pair requires).
3616impl From<DepList> for String {
3617    fn from(list: DepList) -> String {
3618        list.as_str().to_owned()
3619    }
3620}
3621
3622/// Errors raised by [`Dep::validate`].
3623///
3624/// Mirrors the per-axis error families the other `:versao`-carrying
3625/// typed surfaces expose
3626/// ([`crate::AplicacaoError::MembroVersaoEmpty`] /
3627/// [`crate::AplicacaoError::MembroVersaoInvalid`],
3628/// [`crate::SupervisorError::EmptyChildVersion`] /
3629/// [`crate::SupervisorError::ChildVersaoInvalid`]) so a future top-
3630/// level `CaixaError` (M4) sums these without reshaping the diagnostic.
3631#[derive(Debug, Error, PartialEq, Eq)]
3632pub enum DepError {
3633    #[error(
3634        ":deps entry has empty :nome (every dep must name a target caixa; \
3635         omit the entry instead of carrying an empty name)"
3636    )]
3637    NomeEmpty,
3638    #[error(
3639        ":deps entry :nome {nome:?} is not a valid DNS-1123 label: {reason} \
3640         (the value flows verbatim as the target caixa's `:nome`, the rendered \
3641         `lareira-<nome>` Helm chart name segment, the `LABEL_PROGRAM` label \
3642         value, and the resolver's checkout-directory leaf — each apiserver-side \
3643         schema rejects non-DNS-1123 names at admission time; use a lowercase \
3644         RFC 1123 label like `\"caixa-teia\"` or `\"pleme-mesh\"`, 1..=63 bytes, \
3645         pattern `^[a-z0-9]([-a-z0-9]*[a-z0-9])?$`)"
3646    )]
3647    NomeInvalid { nome: String, reason: String },
3648    #[error(
3649        ":deps entry {nome:?} has empty :versao (every dep must pin a semver \
3650         constraint that resolves through the lacre pipeline)"
3651    )]
3652    VersaoEmpty { nome: String },
3653    #[error(
3654        ":deps entry {nome:?} :versao {versao:?} is not a valid semver \
3655         requirement: {reason} (use Cargo-shaped forms like `\"^0.1\"`, \
3656         `\"~0.1.2\"`, `\"0.1.0\"`, or `\"*\"` — the same shape `:membros :versao` \
3657         and `:children :versao` carry; the lacre pipeline resolves all three \
3658         through the same parser)"
3659    )]
3660    VersaoInvalid {
3661        nome: String,
3662        versao: String,
3663        reason: String,
3664    },
3665    #[error(
3666        ":deps entry {nome:?} :fonte (:tipo git …) has empty :repo \
3667         (every git source must name a repo — use a `github:org/repo` \
3668         shorthand, an `https://…` URL, or an ssh-git URL; omit the \
3669         entire :fonte block to fall back to the default-host resolver \
3670         convention)"
3671    )]
3672    FonteRepoEmpty { nome: String },
3673    #[error(
3674        ":deps entry {nome:?} :fonte (:tipo git …) :repo {repo:?} has \
3675         invalid value-shape: {reason} (the value flows verbatim into the \
3676         caixa-resolver's `git clone <repo>` subprocess invocation; every \
3677         documented form carries a `:` separator and no whitespace / \
3678         control / non-ASCII bytes — use a `github:org/repo` shorthand, \
3679         an `https://host/path` / `ssh://[user@]host/path` / \
3680         `git://host/path` / `file:///path` URL, or the `git@host:path` \
3681         scp-style SSH form)"
3682    )]
3683    FonteRepoShape {
3684        nome: String,
3685        repo: String,
3686        reason: String,
3687    },
3688    #[error(
3689        ":deps entry {nome:?} :fonte (:tipo git …) has no pin set \
3690         (set exactly one of :tag, :rev, or :branch so the resolver \
3691         can pick a reproducible commit; omit the entire :fonte block \
3692         to fall back to the default-host resolver convention, which \
3693         resolves the latest tag matching :versao)"
3694    )]
3695    FontePinMissing { nome: String },
3696    #[error(
3697        ":deps entry {nome:?} :fonte (:tipo git …) has multiple pins \
3698         set ({pins}); exactly one of :tag, :rev, or :branch must be \
3699         set so the resolver's checkout target is unambiguous (the \
3700         resolver's silent precedence is :rev > :tag > :branch — if \
3701         you intended one specifically, drop the others)"
3702    )]
3703    FontePinAmbiguous { nome: String, pins: String },
3704    #[error(
3705        ":deps entry {nome:?} :fonte (:tipo git …) has empty {pin} \
3706         (a set pin must name a non-empty git ref; drop the {pin} key \
3707         entirely to fall through to another pin axis)"
3708    )]
3709    FontePinEmpty { nome: String, pin: String },
3710    #[error(
3711        ":deps entry {nome:?} :fonte (:tipo git …) {pin} {value:?} has invalid \
3712         value-shape: {reason} (the git porcelain enforces the same shape at \
3713         `git fetch` / `git checkout` time on every pin; use a leaf refname \
3714         like `\"v0.1.0\"` for `:tag` or `\"main\"` / `\"feature/foo\"` for \
3715         `:branch`, or a full 40/64 lowercase-hex commit OID for `:rev` — \
3716         drop any `refs/heads/` or `refs/tags/` prefix the caixa-resolver \
3717         prepends at clone time, and avoid abbreviated SHAs which are \
3718         ambiguous across repository history)"
3719    )]
3720    FontePinShape {
3721        nome: String,
3722        pin: String,
3723        value: String,
3724        reason: String,
3725    },
3726    #[error(
3727        ":deps entry {nome:?} :fonte (:tipo path …) has empty :caminho \
3728         (every path source must name a non-empty filesystem path; \
3729         omit the entire :fonte block to fall back to the default-host \
3730         resolver convention)"
3731    )]
3732    FonteCaminhoEmpty { nome: String },
3733    #[error(
3734        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} is \
3735         absolute (the lacre pipeline embeds the value verbatim in its \
3736         per-dep content-address `path:{caminho}` at \
3737         caixa-resolver/src/resolve.rs:189, so an absolute path makes the \
3738         BLAKE3 closure differ across machines — defeating the \
3739         reproducibility contract that's load-bearing for CSE; express \
3740         the path relative to the caixa.lisp location, e.g. \
3741         \"../caixa-teia\" for a sibling workspace dep)"
3742    )]
3743    FonteCaminhoAbsolute { nome: String, caminho: String },
3744    #[error(
3745        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
3746         with `~` (the leading-tilde is a shell-expansion convention, not a \
3747         POSIX path component — `Path::is_absolute` returns false on it, so \
3748         the b94fd83 absolute-path gate doesn't catch it, but the lacre \
3749         pipeline embeds the value verbatim in its per-dep content-address \
3750         `path:{caminho}` at caixa-resolver/src/resolve.rs:189 and the \
3751         caixa-resolver folds it through `Path::join` without `~`-expansion, \
3752         so the build looks for a literal `./{caminho}` subdirectory and \
3753         fails at resolve time far from the source caixa.lisp; even worse, a \
3754         future caixa-resolver pass that *does* expand `~` would silently \
3755         re-open the host-layout-leak the b94fd83 absolute gate closes — \
3756         Alice's `~` resolves to `/home/alice`, Bob's to `/home/bob`, two CI \
3757         runners with different `$HOME` layouts resolve to two distinct paths \
3758         for the byte-identical caixa, defeating the THEORY.md §V.2 render-\
3759         determinism contract; express the path relative to the caixa.lisp \
3760         location, e.g. \"../caixa-teia\" for a sibling workspace dep, or \
3761         spell out the full relative path explicitly if a workstation-rooted \
3762         dep is genuinely intended)"
3763    )]
3764    FonteCaminhoTildeExpansion { nome: String, caminho: String },
3765    #[error(
3766        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
3767         with `$` (the leading-`$` is a shell-variable-expansion convention, \
3768         not a POSIX path component — `Path::is_absolute` returns false on it \
3769         and the a5c248e tilde gate doesn't catch it, but the lacre pipeline \
3770         embeds the value verbatim in its per-dep content-address \
3771         `path:{caminho}` at caixa-resolver/src/resolve.rs:189 and the \
3772         caixa-resolver folds it through `Path::join` without `$`-expansion, \
3773         so the build looks for a literal `./{caminho}` subdirectory and \
3774         fails at resolve time far from the source caixa.lisp; even worse, a \
3775         future caixa-resolver pass that *does* expand `$VAR` (the canonical \
3776         shell-convention idiom that CI's `${{WORKSPACE}}` paste-idiom \
3777         invites) would silently re-open the host-layout-leak the b94fd83 \
3778         absolute gate closes — Alice's `$HOME` resolves to `/home/alice`, \
3779         Bob's to `/home/bob`, two CI runners with different `${{WORKSPACE}}` \
3780         layouts resolve to two distinct paths for the byte-identical caixa, \
3781         defeating the THEORY.md §V.2 render-determinism contract; express \
3782         the path relative to the caixa.lisp location, e.g. \"../caixa-teia\" \
3783         for a sibling workspace dep, or spell out the full relative path \
3784         explicitly if a workstation-rooted dep is genuinely intended)"
3785    )]
3786    FonteCaminhoVarExpansion { nome: String, caminho: String },
3787    #[error(
3788        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
3789         with a space (the leading ASCII space `0x20` is the orthogonal \
3790         paste-from-aligned-doc footgun that silently passes \
3791         `Path::is_absolute` and every prior leading-byte arm — \
3792         `\" ../caixa-teia\"` resolves via `Path::join` to a literal \
3793         `./ ../caixa-teia` subdirectory the resolver fails to find at \
3794         resolve time with a non-self-locating `No such file or directory` \
3795         error far from the source caixa.lisp; the lacre pipeline embeds \
3796         the value verbatim in its per-dep content-address `path:{caminho}` \
3797         at caixa-resolver/src/resolve.rs:189, so byte-divergent / \
3798         semantic-identical caixa values (` ../caixa-teia` vs \
3799         `../caixa-teia`) yield two distinct BLAKE3 closures across two \
3800         workstations whose authors differ only in paste-from-aligned- \
3801         caixa.lisp-doc whitespace habits — the most insidious failure \
3802         mode the typed slot can carry (no error surfaces; the divergence \
3803         is invisible until two machines compare lacres), defeating the \
3804         THEORY.md §V.2 render-determinism contract. The canonical \
3805         paste-from-aligned-`:deps`-block footgun (every `:fonte` form in \
3806         a multi-entry `:deps` block sits at the same column — an author \
3807         selecting `\"<sp><sp><sp>../caixa-teia\"` and pasting it from \
3808         the rendered alignment into a fresh entry preserves the leading \
3809         whitespace verbatim); peer `:fonte :repo` axis already rejects \
3810         leading whitespace via `is_git_repo_url`, `:fonte :tag` / \
3811         `:fonte :branch` via `is_git_ref_name`, `:descricao` via \
3812         `is_chart_description_shape`, `:licenca` via \
3813         `is_spdx_expression_shape`. Drop the leading space; express the \
3814         path as a bare relative single-token like \"../caixa-teia\")"
3815    )]
3816    FonteCaminhoLeadingWhitespace { nome: String, caminho: String },
3817    #[error(
3818        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
3819         with `-` (the canonical CLI-argument-injection footgun on the \
3820         `:caminho` axis — the lacre pipeline embeds the value verbatim in \
3821         its per-dep content-address `path:{caminho}` at \
3822         caixa-resolver/src/resolve.rs:189 and the caixa-resolver folds it \
3823         through `Path::join` looking for a literal `./{caminho}` \
3824         subdirectory. Every downstream subprocess that consumes the resolved \
3825         path — `git -C {caminho} <verb>`, `terraform -chdir={caminho}`, \
3826         `nix build --path {caminho}`, `find {caminho}`, `stat {caminho}`, \
3827         `cp -r {caminho} …`, `rm -rf {caminho}` — reinterprets a leading-`-` \
3828         value as a CLI flag rather than a positional path when the invocation \
3829         does not carry a `--` argument-list terminator between the flag block \
3830         and the path (the common case at every porcelain entry point). The \
3831         canonical footguns: `:caminho \"-rf\"` (bare short-flag paste), \
3832         `:caminho \"-C\"` (`git -C -C` config-injection paste), \
3833         `:caminho \"--upload-pack=cat /etc/passwd\"` (the canonical long-flag \
3834         CLI-arg-injection vector at every git porcelain entry point that \
3835         consumes a path or URL argument, peer with is_git_repo_url's \
3836         leading-`-` arm on the sibling `:fonte :repo` axis), \
3837         `:caminho \"--config=…\"` (`git -c foo=bar` config-override paste). \
3838         POSIX `std::path::Path` treats a leading `-` as a literal filename \
3839         byte so the resolver folds `\"-rf\"` through `Path::join` and looks \
3840         for a literal `./-rf` subdirectory that fails at resolve time with a \
3841         non-self-locating `No such file or directory` error far from the \
3842         source caixa.lisp — but on any downstream shell-out without `--` the \
3843         reinterpretation is silent and the failure mode is arbitrary-\
3844         argument-injection. Peer arms: `is_git_repo_url` (render.rs:2037) \
3845         rejects leading `-` on `:fonte :repo` for `git clone <repo>` CLI-\
3846         arg-injection; `is_git_ref_name` (render.rs:1381, 5a28454) rejects \
3847         leading `-` on `:fonte :tag` / `:branch` for `git checkout <ref>` \
3848         CLI-arg-injection; `is_dns_1123_label` rejects leading `-` on every \
3849         DNS-1123-shaped axis (top-level Caixa `:nome`, `:membros :caixa`, \
3850         `:children :caixa`, `:deps :nome`, cluster names); \
3851         `is_cargo_feature_name` rejects leading `-` on `:caracteristicas`; \
3852         the feira `init` / `add <nome>` positional gate (868c191) rejects \
3853         leading `-` on the CLI positional itself. Express the path as a bare \
3854         relative single-token like \"../caixa-teia\" — the sibling-workspace \
3855         directory name carries no leading-hyphen semantic, and `./` / `../` \
3856         prefixes structurally partition the leading-byte set to safe values.)"
3857    )]
3858    FonteCaminhoLeadingHyphen { nome: String, caminho: String },
3859    #[error(
3860        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains \
3861         ASCII control byte 0x{byte:02x} (POSIX paths reject NUL `0x00` outright — \
3862         every `std::fs` syscall routes the path through `CString::new` which \
3863         fails with `NulError` at resolve time; the lacre pipeline embeds the \
3864         value verbatim in its per-dep content-address `path:{caminho}` at \
3865         caixa-resolver/src/resolve.rs:189 so a control byte anywhere in the \
3866         value lands in the BLAKE3 closure and breaks the THEORY.md §V.2 render-\
3867         determinism contract — the canonical paste-from-multiline-doc \
3868         (`\\n`/`\\r`), paste-from-aligned-table (`\\t`), or paste-from-binary-\
3869         blob (`0x00`-DEL) footgun every peer single-token-shaped axis \
3870         (`:fonte :repo`, `:fonte :tag`/`:branch`, the Helm chart-string axes) \
3871         already gates against. Express the path as a relative single-line ASCII \
3872         string, e.g. \"../caixa-teia\" for a sibling workspace dep)"
3873    )]
3874    FonteCaminhoControlChar {
3875        nome: String,
3876        caminho: String,
3877        byte: u8,
3878    },
3879    #[error(
3880        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains `\\` \
3881         (POSIX `std::path::Path` treats `\\` as a literal byte inside a single path \
3882         component, so `..\\caixa-teia` is one directory named literally `..\\caixa-teia` — \
3883         not the parent's sibling — and the caixa-resolver folds the value through \
3884         `Path::join` looking for a literal `./{caminho}` subdirectory that fails at \
3885         resolve time with a non-self-locating `No such file or directory` error far \
3886         from the source caixa.lisp; Windows `std::path::Path` treats `\\` as a \
3887         primary path separator equal to `/`, so byte-identical caixa.lisp values \
3888         resolve to two distinct directories across runner OSes — the lacre pipeline \
3889         embeds the value verbatim in its per-dep content-address `path:{caminho}` at \
3890         caixa-resolver/src/resolve.rs:189, defeating the THEORY.md §V.2 render-\
3891         determinism contract via the cross-host-OS-separator divergence vector. The \
3892         canonical Windows-Explorer `Copy as path` / PowerShell `Get-Location` \
3893         paste-idiom footgun; peer `:fonte :tag` / `:fonte :branch` axis already \
3894         rejects `\\` via `is_git_ref_name` for the same Windows-path-leak reason, \
3895         and `:entrada :paths` rejects `\\` via `is_gateway_api_http_path`'s eleven-\
3896         byte RFC-3986-reserved set. Express the path with `/` as the separator, e.g. \
3897         \"../caixa-teia\" for a sibling workspace dep)"
3898    )]
3899    FonteCaminhoBackslash { nome: String, caminho: String },
3900    #[error(
3901        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3902         redirection metacharacter 0x{byte:02x} `{ch}` (every interactive shell — bash / \
3903         zsh / fish / nushell — lexes `<` and `>` as input / output redirection \
3904         operators, so `:caminho \"../caixa-teia>build.log\"` is the canonical \
3905         paste-from-shell-pipeline footgun where an author copies a `command > log` \
3906         tail without trimming the redirect; POSIX `std::path::Path` treats both bytes \
3907         as literal path-component bytes, so the resolver folds the value through \
3908         `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
3909         subdirectory and fails at resolve time with a non-self-locating `No such \
3910         file or directory` error far from the source caixa.lisp. The lacre pipeline \
3911         embeds the value verbatim in its per-dep content-address `path:{caminho}` at \
3912         caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure \
3913         and rides into every shell-spawned subprocess (the resolver's `git clone`, a \
3914         future `feira tofu` shell-out, a future operator-side `nix` spawn) as the \
3915         canonical CRLF-at-subprocess-argument / shell-metachar injection surface every \
3916         peer single-token-shaped typed slot already closes. The peer `:fonte :tag` / \
3917         `:fonte :branch` axis already rejects `<` / `>` via `is_git_ref_name`, and \
3918         `:entrada :paths` rejects them via `is_gateway_api_http_path`'s eleven-byte \
3919         RFC-3986-reserved set. Express the path as a bare relative single-token like \
3920         \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
3921         redirection semantic.",
3922        ch = *byte as char
3923    )]
3924    FonteCaminhoShellRedirection {
3925        nome: String,
3926        caminho: String,
3927        byte: u8,
3928    },
3929    #[error(
3930        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-pipe \
3931         metacharacter `|` (every interactive shell — bash / zsh / fish / nushell — lexes \
3932         `|` as the pipe operator that wires one command's stdout to the next command's \
3933         stdin, so `:caminho \"../caixa-teia | grep foo\"` is the canonical paste-from-\
3934         shell-history footgun where an author copies a `ls ../caixa-teia | grep` line \
3935         without trimming the pipeline tail, and `:caminho \"../foo||bar\"` is the \
3936         symmetric `cmd-a || cmd-b` short-circuit-OR paste shape; POSIX `std::path::Path` \
3937         treats `|` as a literal path-component byte, so the resolver folds the value \
3938         through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
3939         subdirectory and fails at resolve time with a non-self-locating `No such file or \
3940         directory` error far from the source caixa.lisp. The lacre pipeline embeds the \
3941         value verbatim in its per-dep content-address `path:{caminho}` at caixa-resolver/\
3942         src/resolve.rs:189, so the byte lands in the BLAKE3 closure and rides into every \
3943         shell-spawned subprocess (the resolver's `git clone`, a future `feira tofu` \
3944         shell-out, a future operator-side `nix` spawn) as the canonical CRLF-at-\
3945         subprocess-argument / shell-metachar injection surface every peer single-token-\
3946         shaped typed slot already closes. The peer `:entrada :paths` axis rejects `|` \
3947         via `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the \
3948         path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
3949         workspace directory name carries no shell-pipe semantic."
3950    )]
3951    FonteCaminhoShellPipe { nome: String, caminho: String },
3952    #[error(
3953        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3954         command-separator metacharacter `;` (every interactive shell — bash / zsh / fish \
3955         / nushell — lexes `;` as the sequential-command terminator that fires the next \
3956         command regardless of the prior command's exit status, so `:caminho \
3957         \"../caixa-teia; rm -rf build\"` is the canonical paste-from-shell-one-liner \
3958         footgun where an author copies a `cd path; do-thing` chain without trimming \
3959         the cleanup tail, and `:caminho \"../foo;;bar\"` is the symmetric POSIX `case` \
3960         arm `;;` terminator paste shape; POSIX `std::path::Path` treats `;` as a \
3961         literal path-component byte, so the resolver folds the value through \
3962         `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
3963         subdirectory and fails at resolve time with a non-self-locating `No such file \
3964         or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
3965         the value verbatim in its per-dep content-address `path:{caminho}` at \
3966         caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
3967         rides into every shell-spawned subprocess (the resolver's `git clone`, a \
3968         future `feira tofu` shell-out, a future operator-side `nix` spawn) as the \
3969         canonical shell-metachar injection surface every peer single-token-shaped \
3970         typed slot already closes. The peer `:entrada :paths` axis rejects `;` via \
3971         `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the \
3972         path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
3973         workspace directory name carries no shell-command-separator semantic."
3974    )]
3975    FonteCaminhoShellSemicolon { nome: String, caminho: String },
3976    #[error(
3977        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3978         background / list-AND metacharacter `&` (every interactive shell — bash / zsh \
3979         / fish / nushell — lexes `&` two ways: single `&` as the background-task \
3980         terminator detaching the prior command and returning control immediately to \
3981         the prompt, double `&&` as the logical-AND list operator firing the next \
3982         command only if the prior succeeded; POSIX `std::path::Path` treats it as a \
3983         literal byte. The canonical paste-from-shell-prompt footgun is a `cd path & \
3984         sleep 1` background-launch one-liner or a `cd path && make install` build-\
3985         chain idiom selected whole into the `:caminho` slot — the prior `;` arm at \
3986         05c358e closed the sequential-command-separator vector, this arm closes the \
3987         orthogonal background-task / logical-AND vector on the same paste-from-shell-\
3988         prompt class. The lacre pipeline embeds the value verbatim in its per-dep \
3989         content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the \
3990         byte lands in the BLAKE3 closure and rides into every shell-spawned \
3991         subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a \
3992         future operator-side `nix` spawn) as the canonical shell-metachar injection \
3993         surface every peer single-token-shaped typed slot already closes. The peer \
3994         `:entrada :paths` axis rejects `&` via `is_gateway_api_http_path`'s eleven-\
3995         byte RFC-3986-reserved set. Express the path as a bare relative single-token \
3996         like \"../caixa-teia\" — the sibling-workspace directory name carries no \
3997         shell-background / logical-AND semantic."
3998    )]
3999    FonteCaminhoShellBackground { nome: String, caminho: String },
4000    #[error(
4001        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4002         command-substitution metacharacter `` ` `` (every POSIX shell — sh / bash / zsh / \
4003         dash / ksh / fish / nushell — lexes the byte as the legacy command-substitution \
4004         wrapper that runs the enclosed command and substitutes its standard-output \
4005         verbatim into the surrounding word, so a backticked `whoami` expands to the \
4006         current user's name and a backticked `cat /etc/passwd` expands to the file's \
4007         contents — the canonical CWE-78 shell-command-injection vector; POSIX \
4008         `std::path::Path` treats the byte as a literal path-component byte. The canonical \
4009         paste-from-shell-prompt footgun is a `cd ../path/<backtick>whoami<backtick>` legacy substitution \
4010         one-liner or a `cd <backtick>pwd<backtick>/path` working-directory expansion idiom selected whole \
4011         into the `:caminho` slot — the prior `&` arm at e12e4f3 closed the shell-\
4012         background / logical-AND vector, this arm closes the orthogonal command-\
4013         substitution vector on the same paste-from-shell-prompt class (the modern `$()` \
4014         form is gated at leading position by the f4efe9c `FonteCaminhoVarExpansion` arm; \
4015         the legacy backtick form is the orthogonal axis). The lacre pipeline embeds the \
4016         value verbatim in its per-dep content-address `path:{caminho}` at \
4017         caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
4018         rides into every shell-spawned subprocess (the resolver's `git clone`, a future \
4019         `feira tofu` shell-out, a future operator-side `nix` spawn) as the canonical \
4020         shell-metachar injection surface every peer single-token-shaped typed slot \
4021         already closes. The peer `:entrada :paths` axis rejects the byte via \
4022         `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the path \
4023         as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
4024         directory name carries no shell-command-substitution semantic."
4025    )]
4026    FonteCaminhoShellCommandSubstitution { nome: String, caminho: String },
4027    #[error(
4028        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4029         glob / pathname-expansion metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — \
4030         sh / bash / zsh / dash / ksh / fish / nushell — lexes `*` and `?` as pathname-\
4031         expansion wildcards: `*` matches any sequence of characters in a path component \
4032         and `?` matches exactly one character, so a `:caminho \"../caixa-teia/*\"` is the \
4033         canonical paste-from-shell-listing footgun where an author copies a \
4034         `ls ../caixa-teia/*` listing without trimming the wildcard, and `:caminho \
4035         \"../foo?\"` is the symmetric single-char-wildcard paste shape; POSIX \
4036         `std::path::Path` treats both bytes as literal path-component bytes, so the \
4037         resolver folds the value through `Path::new(caminho).join(<file>)` looking for \
4038         a literal `./{caminho}` subdirectory and fails at resolve time with a non-self-\
4039         locating `No such file or directory` error far from the source caixa.lisp. The \
4040         lacre pipeline embeds the value verbatim in its per-dep content-address \
4041         `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in the \
4042         BLAKE3 closure and rides into every shell-spawned subprocess (the resolver's \
4043         `git clone`, a future `feira tofu` shell-out, a future operator-side `nix` \
4044         spawn) as the canonical shell-metachar / glob-expansion surface every peer \
4045         single-token-shaped typed slot already closes. The peer `:entrada :paths` axis \
4046         rejects `*` and `?` via `is_gateway_api_http_path`'s eleven-byte RFC-3986-\
4047         reserved set. Express the path as a bare relative single-token like \
4048         \"../caixa-teia\" — the sibling-workspace directory name carries no shell-glob \
4049         / pathname-expansion semantic.",
4050        ch = *byte as char
4051    )]
4052    FonteCaminhoShellGlob {
4053        nome: String,
4054        caminho: String,
4055        byte: u8,
4056    },
4057    #[error(
4058        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4059         subshell-grouping metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / \
4060         zsh / dash / ksh / fish / nushell — lexes `(` and `)` as the subshell-grouping \
4061         operator: `(<cmd>)` runs `<cmd>` in a child shell with a fresh environment scope \
4062         (the canonical `(cd <path> && <cmd>)` shell-history one-liner scopes a `cd` to one \
4063         subshell without disturbing the parent's working directory), and `$(<cmd>)` is the \
4064         modern Bourne command-substitution shape the leading-`$` `FonteCaminhoVarExpansion` \
4065         arm closes the leading byte of — together the two arms now structurally exclude the \
4066         entire `$(<cmd>)` substitution surface from the typed `:caminho` accepted set. \
4067         POSIX `std::path::Path` treats the byte as a literal path-component byte, so a \
4068         `:caminho \"../caixa-teia/$(date)/build\"` (the canonical paste-from-shell-history \
4069         modern-command-substitution footgun) or `:caminho \"../(cd foo && pwd)/caixa-teia\"` \
4070         (the symmetric subshell-grouping working-directory-probe paste idiom) silently passes \
4071         every prior arm and the resolver folds the value through `Path::new(caminho).join(\
4072         <file>)` looking for a literal subdirectory and fails at resolve time with a non-\
4073         self-locating `No such file or directory` error far from the source caixa.lisp. The \
4074         lacre pipeline embeds the value verbatim in its per-dep content-address `path:\
4075         {caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 \
4076         closure and rides into every shell-spawned subprocess (the resolver's `git clone`, a \
4077         future `feira tofu` shell-out, a future operator-side `nix` spawn) as the canonical \
4078         shell-metachar / subshell-grouping surface every peer single-token-shaped typed slot \
4079         already closes. The peer `:fonte :repo` axis (3b99147) closes the same byte under the \
4080         same shell-subshell-grouping / RFC-3986-sub-delims banner on `is_git_repo_url`, \
4081         together with the leading-`$` `FonteCaminhoVarExpansion` arm closing the leading byte \
4082         of every `$(<cmd>)` shape. Express the path as a bare relative single-token \
4083         like \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
4084         subshell-grouping semantic.",
4085        ch = *byte as char
4086    )]
4087    FonteCaminhoShellSubshellGrouping {
4088        nome: String,
4089        caminho: String,
4090        byte: u8,
4091    },
4092    #[error(
4093        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4094         brace-expansion / URI-Template placeholder metacharacter 0x{byte:02x} `{ch}` \
4095         (every POSIX-derived brace-expanding shell — bash / zsh / ksh / fish — lexes `{{` / \
4096         `}}` as the brace-expansion operator: `{{a,b,c}}` expands to the cross-product of \
4097         comma-separated members and `{{1..10}}` expands to the integer range — the \
4098         canonical `mkdir -p ../{{caixa-teia,caixa-helm,caixa-flux}}` / `cp file{{,.bak}}` \
4099         idiom every shell-history block carries; RFC 6570 reserves the matched pair for \
4100         URI Template placeholders (the canonical `https://{{host}}/{{org}}/{{repo}}` \
4101         substitution shape every OpenAPI / Swagger / Postman / GitHub Octokit client \
4102         library / Helm chart-URL fragment carries) and the Mustache / Handlebars / \
4103         Tera / Jinja2 / Go html/template doubled-brace substitution form every IaC \
4104         templating engine (Helm, Kustomize, Terraform's `${{var}}` cousin) emits. POSIX \
4105         `std::path::Path` treats the byte as a literal path-component byte, so a \
4106         `:caminho \"../{{caixa-teia,caixa-helm}}/build\"` (the canonical paste-from-\
4107         shell-history brace-expansion fan-across-siblings footgun) or `:caminho \"../{{{{org}}}}/\
4108         caixa-teia\"` (the symmetric paste-from-templated-doc URI-Template placeholder \
4109         idiom every README quick-start / OpenAPI spec / Helm chart `home:` field carries) \
4110         silently passes every prior arm and the resolver folds the value through \
4111         `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
4112         resolve time with a non-self-locating `No such file or directory` error far from \
4113         the source caixa.lisp. The lacre pipeline embeds the value verbatim in its \
4114         per-dep content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, \
4115         so the byte lands in the BLAKE3 closure and rides into every shell-spawned \
4116         subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a \
4117         future operator-side `nix` spawn) as the canonical shell-metachar / brace-\
4118         expansion / URI-Template-placeholder surface every peer single-token-shaped \
4119         typed slot already closes. The peer `:fonte :repo` axis (42d8f9d) closes the \
4120         same byte pair on `is_git_repo_url` under the same RFC-3986-'delims' / \
4121         RFC-6570-URI-Template / shell-brace-expansion banner. Express the path as a \
4122         bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
4123         directory name carries no shell-brace-expansion / URI-Template-placeholder \
4124         semantic; if two siblings actually need pinning, author two separate `:deps` \
4125         entries rather than one brace-expanded `:caminho` value.",
4126        ch = *byte as char
4127    )]
4128    FonteCaminhoShellBraceExpansion {
4129        nome: String,
4130        caminho: String,
4131        byte: u8,
4132    },
4133    #[error(
4134        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4135         bracket-expansion / POSIX glob-character-class / shell-`test`-builtin metacharacter \
4136         0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / nushell \
4137         — lexes the bracket pair as the glob character-class operator: `[abc]` matches one of \
4138         `a` / `b` / `c`, `[a-z]` matches any lowercase ASCII letter, `[^x]` negates — the \
4139         canonical `ls *.[ch]` C-source-file glob and `cd ../caixa-[a-z]*` lowercase-sibling \
4140         glob every shell-history block carries; the bracket pair additionally carries the \
4141         POSIX `test` / `[` builtin command (`[ -d ../caixa-teia ] && cd ...` every shell-\
4142         script conditional uses) and bash's `[[ ... ]]` extended-test grammar; beyond shell \
4143         the pair is the TOML inline-array delimiter (`features = [\"a\", \"b\"]` — the \
4144         canonical paste-from-Cargo-manifest cross-idiom-leak vector), the YAML flow-sequence \
4145         delimiter (`paths: [/a, /b]` — the canonical paste-from-values.yaml cross-idiom \
4146         leak), the JSON array delimiter, and the POSIX-ERE / PCRE bracket-expression anchor. \
4147         POSIX `std::path::Path` treats the byte as a literal path-component byte, so a \
4148         `:caminho \"../caixa-[a-z]/build\"` (the canonical paste-from-shell-history glob-\
4149         character-class fan-across-siblings footgun) or `:caminho \"../[caixa-teia]/build\"` \
4150         (the symmetric paste-from-TOML-array / paste-from-YAML-flow-sequence cross-idiom \
4151         leak) silently passes every prior arm and the resolver folds the value through \
4152         `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
4153         resolve time with a non-self-locating `No such file or directory` error far from \
4154         the source caixa.lisp. The lacre pipeline embeds the value verbatim in its per-dep \
4155         content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte \
4156         lands in the BLAKE3 closure and rides into every shell-spawned subprocess (the \
4157         resolver's `git clone`, a future `feira tofu` shell-out, a future operator-side \
4158         `nix` spawn) as the canonical shell-metachar / glob-character-class / TOML-array \
4159         surface every peer single-token-shaped typed slot already closes. Express the path \
4160         as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
4161         directory name carries no shell-bracket-expansion / glob-character-class / array-\
4162         literal semantic; if a family of sibling caixas actually needs pinning, author \
4163         separate `:deps` entries rather than one character-class-expanded `:caminho` value.",
4164        ch = *byte as char
4165    )]
4166    FonteCaminhoShellBracketExpansion {
4167        nome: String,
4168        caminho: String,
4169        byte: u8,
4170    },
4171    #[error(
4172        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4173         quote-grouping / cross-config-DSL string-literal-delimiter metacharacter \
4174         0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / \
4175         nushell — lexes `'` as the strong string-literal delimiter (`'…'` — no expansion) \
4176         and `\"` as the weak string-literal delimiter (`\"…\"` — variable- / command-\
4177         substitution-preserving); the canonical `cd '../caixa-teia'` shell-history idiom \
4178         every path-with-embedded-whitespace paste block carries and the symmetric \
4179         `git clone \"$REPO\"` weak-quoted CI-manifest shape both leak the pair verbatim. \
4180         Beyond shell the pair is the JSON string-literal delimiter (`\"key\": \"value\"` — \
4181         the canonical paste-from-JSON-config cross-idiom-leak vector), the YAML double- \
4182         and single-quoted flow-scalar delimiter (`path: \"../caixa-teia\"` — the canonical \
4183         paste-from-values.yaml / paste-from-K8s-YAML-manifest cross-idiom leak), the TOML \
4184         basic and literal string delimiter (`path = \"../caixa-teia\"` — the canonical \
4185         paste-from-Cargo-manifest cross-idiom leak), the tatara-lisp string-literal \
4186         delimiter itself (`(:caminho \"../caixa-teia\")` — the canonical \"I copied the \
4187         entire `:caminho \"...\"` slot rather than just the string body\" author-surface \
4188         footgun), and RFC 3986 §2.2's `gen-delims` / `sub-delims` grammar which excludes \
4189         both bytes from the `pchar = unreserved / pct-encoded / sub-delims / \":\" / \"@\"` \
4190         production. POSIX `std::path::Path` treats the byte as a literal path-component \
4191         byte, so a `:caminho \"'../caixa-teia'\"` (the canonical paste-from-shell-history \
4192         strong-quoted sibling-workspace path footgun) or `:caminho \"\\\"../caixa-teia\\\"\"` \
4193         (the symmetric weak-quoted paste-from-JSON / paste-from-YAML flow-scalar / paste-\
4194         from-TOML basic-string / paste-from-tatara-lisp string-literal cross-idiom-leak \
4195         shape) silently passes every prior arm and the resolver folds the value through \
4196         `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
4197         resolve time with a non-self-locating `No such file or directory` error far from \
4198         the source caixa.lisp. The lacre pipeline embeds the value verbatim in its per-dep \
4199         content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte \
4200         lands in the BLAKE3 closure and rides into every shell-spawned subprocess (the \
4201         resolver's `git clone`, a future `feira tofu` shell-out, a future operator-side \
4202         `nix` spawn) as the canonical shell-metachar / string-literal-delimiter surface \
4203         every peer single-token-shaped typed slot already closes. The peer `:fonte :repo` \
4204         axis closes both bytes under the same shell-quote-grouping / RFC-3986-sub-delims \
4205         banner (e7a109f `'` shell-single-quote + 4267d8b `\"` shell-double-quote on \
4206         `is_git_repo_url`). Express the path as a bare relative single-token like \
4207         \"../caixa-teia\" — the sibling-workspace directory name carries no shell-quote-\
4208         grouping / string-literal-delimiter semantic; strip the outer quote pair from the \
4209         paste (the tatara-lisp `:caminho \"...\"` slot already carries the string-literal \
4210         quoting on the outer syntactic layer, so an inner quote pair would nest and \
4211         desugar to a broken layer).",
4212        ch = *byte as char
4213    )]
4214    FonteCaminhoShellQuoteGrouping {
4215        nome: String,
4216        caminho: String,
4217        byte: u8,
4218    },
4219    #[error(
4220        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4221         comment / URL-fragment-identifier / YAML-comment cross-config-DSL metacharacter \
4222         0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / \
4223         nushell — lexes an unquoted `#` at the head of a word or after unquoted \
4224         whitespace as the comment-lead per POSIX.1-2017 §2.3 Token Recognition step 6, \
4225         discarding the byte and everything after it to the end of the physical line \
4226         before command parsing (`cd ../caixa-teia  # legacy sibling` — the canonical \
4227         paste-from-shell-history-with-trailing-annotation shape every operator-notebook \
4228         and CI-manifest carries); YAML 1.2 §6.6 makes `#` the comment-lead at any \
4229         position preceded by whitespace or at line-start (`path: ../caixa-teia  # pin` \
4230         — the canonical paste-from-values.yaml / paste-from-K8s-manifest cross-idiom-\
4231         leak); RFC 3986 §3.5 reserves `#` as the URL fragment-identifier delimiter (the \
4232         canonical paste-from-browser-address-bar `github.com/foo/bar#readme` / \
4233         `github.com/foo/bar#L42` permalink shape, and the symmetric Nix-flake-ref \
4234         cross-idiom leak `github:foo/bar#packageName` where `#` selects a flake \
4235         output); the same cross-config-DSL surface extends to HCL / Terraform / Nix \
4236         flake attributes / dotenv `.env` / gitconfig / .gitignore / ini / TOML where \
4237         `#` is likewise the comment-lead. POSIX `std::path::Path` treats the byte as a \
4238         literal path-component byte, so a `:caminho \"../caixa-teia # legacy sibling\"` \
4239         (the canonical paste-from-shell-history-with-trailing-annotation footgun), \
4240         `:caminho \"../caixa-teia  # pin\"` (the symmetric YAML flow-scalar paste-with-\
4241         trailing-comment shape), or `:caminho \"../caixa-teia#readme\"` (the URL \
4242         fragment paste-from-browser-address-bar shape) silently passes every prior arm \
4243         and the resolver folds the value through `Path::new(caminho).join(<file>)` \
4244         looking for a literal subdirectory named `../caixa-teia # legacy sibling` and \
4245         fails at resolve time with a non-self-locating `No such file or directory` \
4246         error far from the source caixa.lisp — while every downstream shell / YAML / \
4247         URL parser silently truncates the value at the `#` byte to `../caixa-teia`, so \
4248         a `feira tofu` shell-out and a `nix flake check` on an emitted YAML `path:` \
4249         scalar disagree with the resolver on which directory the value names. The \
4250         lacre pipeline embeds the value verbatim in its per-dep content-address \
4251         `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in \
4252         the BLAKE3 closure and rides into every shell-spawned subprocess (the \
4253         resolver's `git clone`, a future `feira tofu` shell-out, a future operator-\
4254         side `nix` spawn) as the canonical shell-metachar / comment-lead / URL-\
4255         fragment-delimiter surface every peer single-token-shaped typed slot already \
4256         closes. The peer `:fonte :repo` axis closes the byte under the same URL-\
4257         fragment-identifier banner (a68f818 `#` on `is_git_repo_url`). Express the \
4258         path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
4259         workspace directory name carries no shell-comment / URL-fragment / YAML-\
4260         comment semantic; move any trailing annotation to a tatara-lisp `;`-comment \
4261         on the surrounding form (`;; legacy sibling` above the `(:caminho ...)` slot) \
4262         and drop any `#fragment` tail entirely (fragment identifiers select \
4263         renderings, not directories, and `:caminho` names a directory).",
4264        ch = *byte as char
4265    )]
4266    FonteCaminhoShellComment {
4267        nome: String,
4268        caminho: String,
4269        byte: u8,
4270    },
4271    #[error(
4272        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains URL-\
4273         percent-encoding-escape / printf-format-specifier / bash-job-control-specifier \
4274         / YAML-directive-lead metacharacter 0x{byte:02x} `{ch}` (RFC 3986 §2.1 reserves \
4275         `%` as the URL percent-encoding-escape — `%HH` is the mandatory encoding \
4276         mechanism for every byte outside the `unreserved` alphanumeric / `-` / `.` / \
4277         `_` / `~` set, and `%` itself must be percent-encoded as `%25` to appear \
4278         literally inside a URL value. The canonical paste-from-browser-address-bar \
4279         percent-encoded-space footgun (an author copies `../caixa%20teia` out of a URL-\
4280         encoded README hyperlink / browser address bar / percent-encoded permalink \
4281         expecting `%20` to decode to a literal space at the filesystem layer) locks two \
4282         distinct BLAKE3 closures (`path:../caixa%20teia` vs `path:../caixa teia`) for \
4283         what the author intended as the byte-identical sibling-workspace dep. POSIX \
4284         `std::path::Path` treats the byte as a literal path-component byte, so \
4285         `Path::join` looks for a literal `./{caminho}` subdirectory and fails at \
4286         resolve time with a non-self-locating `No such file or directory` error far \
4287         from the source caixa.lisp — while every downstream URL parser / shell printf \
4288         builtin / YAML directive parser silently reinterprets the byte to a different \
4289         value than the resolver's `Path::join` sees. Beyond the URL-encoding hazard, \
4290         `%` is the C / POSIX printf format-directive lead-in (`%s`, `%d`, `%02x` — \
4291         wired into every POSIX shell's `printf` builtin, the canonical CWE-134 format-\
4292         string-injection vector); the bash / zsh / ksh job-control-specifier lead-in \
4293         (`%1` names \"job 1\", `%%` names \"the current job\", `%foo` names \"the most \
4294         recent job whose command started with `foo`\" — a future `kill %1` invocation \
4295         silently redirects the signal to a wrong target); the YAML 1.2 §6.8.1 \
4296         directive lead-in (`%YAML 1.2` / `%TAG` — the paste-from-top-of-doc YAML \
4297         directive block cross-idiom leak); and the Windows-shell env-var-reference \
4298         lead-in (`%PATH%` — the paste-from-`.bat` / paste-from-PowerShell-`%env:PATH%` \
4299         cross-idiom leak). The lacre pipeline embeds the value verbatim in its per-dep \
4300         content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the \
4301         byte lands in the BLAKE3 closure and rides into every shell-spawned subprocess \
4302         (the resolver's `git clone`, a future `feira tofu` shell-out, a future \
4303         operator-side `nix` spawn) as the canonical URL-percent-encoding-escape / \
4304         printf-format-specifier / job-control-specifier surface every peer single-\
4305         token-shaped typed slot already closes. The peer `:fonte :repo` axis closes \
4306         the byte under the same URL-percent-encoding-escape banner (a323db8 `%` on \
4307         `is_git_repo_url`). Express the path as a bare relative single-token like \
4308         \"../caixa-teia\" — the sibling-workspace directory name carries no URL-\
4309         percent-encoding-escape / format-specifier / job-control semantic; substitute \
4310         any `%20` percent-encoded-space with a literal space then reject the whole \
4311         value at the leading-whitespace / embedded-`?` arm on the same axis (a caixa \
4312         directory name never carries an embedded space in practice); drop any \
4313         `%2F`-encoded path separator in favor of a literal `/`; and drop any leading \
4314         `%YAML` / `%PATH%` cross-idiom-leak prefix entirely.",
4315        ch = *byte as char
4316    )]
4317    FonteCaminhoUrlPercentEncoding {
4318        nome: String,
4319        caminho: String,
4320        byte: u8,
4321    },
4322    #[error(
4323        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4324         variable-expansion / command-substitution / arithmetic-expansion / cross-config-\
4325         DSL-interpolation metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — sh / \
4326         bash / zsh / dash / ksh / busybox ash / fish / nushell — lexes `$` per \
4327         POSIX.1-2017 §2.6 as the variable-expansion `$<name>` / braced-form `${{<name>}}` \
4328         / command-substitution `$(<cmd>)` / arithmetic-expansion `$((<expr>))` operator; \
4329         Nix uses `${{var}}` as the string-interpolation lead, Make uses `$(var)` / `$@` \
4330         / `$<` for variables and automatic-variables, JavaScript / TypeScript template \
4331         literals use `${{expr}}` for interpolation, envsubst / Kubernetes / OpenShift \
4332         templates use `${{VAR}}` for env-var-reference, PHP uses `$_GET` / `$_ENV` for \
4333         superglobals, Perl uses `$foo` for scalars, SASS / SCSS uses `$primary-color` \
4334         for variables, and PostgreSQL / SQLite use `$1` / `$2` for bind parameters — \
4335         the byte is a first-class parser byte in nearly every config / templating / \
4336         build-system DSL the substrate's paste-idiom surface routinely crosses. POSIX \
4337         `std::path::Path` treats the byte as a literal path-component byte, so the \
4338         canonical paste-from-shell-one-liner `:caminho \"../foo$HOME/bar\"` / paste-\
4339         from-CI-manifest `:caminho \"../foo${{WORKSPACE}}/bar\"` / paste-from-shell-\
4340         prompt `:caminho \"../foo$(whoami)/bar\"` footguns silently pass every prior \
4341         cascade arm (`$` isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / \
4342         `?` / `(` / `)` / `{{` / `}}` / `[` / `]` / `'` / `\"` / `#` / `%`) and route \
4343         through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
4344         subdirectory that fails at resolve time with a non-self-locating `No such file \
4345         or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
4346         the value verbatim in its per-dep content-address `path:{caminho}` at \
4347         caixa-resolver/src/resolve.rs:189, so byte-identical caixa.lisp values differing \
4348         only in whether the author substituted `$HOME` / `${{WORKSPACE}}` at author \
4349         time lock to two distinct BLAKE3 closures across two workstations whose \
4350         downstream envsubst / Nix / Make / K8s-template layers differ in `$VAR` \
4351         recognition — defeating the THEORY.md §V.2 render-determinism contract on the \
4352         same axis every prior `:caminho` arm protects. Beyond the determinism vector, \
4353         `$` at any position in a value flowing verbatim into a shell-spawned subprocess \
4354         is the canonical CWE-78 shell-command-injection surface every peer single-\
4355         token-shaped typed slot already closes: peer `:fonte :repo` axis rejects `$` \
4356         under the shell-variable-expansion / URL-sub-delim banner via `is_git_repo_url` \
4357         (b9d187c), peer `:fonte :tag` / `:fonte :branch` axes reject `$` as part of \
4358         `is_git_ref_name`'s printable-ASCII-restricted grammar (`git check-ref-format` \
4359         rejects the byte outright), and peer `:entrada :paths` axis rejects `$` via \
4360         `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. The leading-`$` \
4361         position on the same axis routes through `FonteCaminhoVarExpansion` at the \
4362         f4efe9c leading-byte arm; this arm closes the last positional gap on the byte \
4363         so every position — leading and embedded — is structurally rejected. Substitute \
4364         the `$VAR` / `${{VAR}}` / `$(cmd)` template with the literal value at author \
4365         time, or express the path as a bare relative single-token like \
4366         \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
4367         variable-expansion / command-substitution / arithmetic-expansion semantic.",
4368        ch = *byte as char
4369    )]
4370    FonteCaminhoShellVariableExpansion {
4371        nome: String,
4372        caminho: String,
4373        byte: u8,
4374    },
4375    #[error(
4376        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4377         history-expansion / RFC-3986-sub-delims / bang-operator metacharacter 0x{byte:02x} \
4378         `{ch}` (every interactive POSIX shell with history enabled — bash / ksh / zsh's \
4379         `bashcompat` / csh / tcsh — lexes `!` as the history-expansion prefix per bash \
4380         reference §9.3: `!command` re-runs the most recent history entry beginning with \
4381         `command`, `!!` re-runs the prior command verbatim, `!$` substitutes the last \
4382         word of the prior command, `!:N` substitutes the Nth word of the prior command, \
4383         and the substitution fires at every history-expansion-enabled shell context — \
4384         `set -o histexpand` is bash's default for interactive sessions and the layer \
4385         every `feira tofu` / `git clone` / `nix flake check` subprocess-argument \
4386         invocation crosses when spawned under `bash -i`. Beyond shell history, RFC 3986 \
4387         §2.2 lists `!` in the `sub-delims` set (the URL grammar admits the byte inside \
4388         a path segment, but every WHATWG-conformant special-scheme URL parser percent-\
4389         encodes it inside a query component via the 'special-query percent-encode set' \
4390         the peer `is_git_repo_url` `*` / `(` / `)` / `'` arms close on); the byte is \
4391         also the C / C++ / Rust / JavaScript / Python bang-operator (logical-negation \
4392         prefix — the paste-from-source-code idiom where an author copies \
4393         `!path.exists()` out of a Rust snippet and the trailing punctuation crosses \
4394         the string-literal boundary); the canonical English-typography emphasis / \
4395         exclamation mark (the paste-from-prose enthusiasm-form idiom where an author \
4396         writes `:caminho \"../caixa-teia!\"` expecting the substrate to coerce it to a \
4397         kebab-case slug); and the Nix flake-ref attribute-selection operator surface. \
4398         POSIX `std::path::Path` treats `!` as a literal path-component byte, so the \
4399         canonical paste-from-shell-history footgun `:caminho \"../caixa-teia!sudo\"` \
4400         (an author copies a `cd ../caixa-teia && !sudo make install` one-liner from a \
4401         quick-start README and the trailing `!sudo` rides in verbatim as a history-\
4402         expansion reference), the symmetric `:caminho \"../foo!!/bar\"` (the `!!` \
4403         repeat-prior-command paste idiom), the English-typography `:caminho \
4404         \"../caixa-teia!\"` (paste-from-prose enthusiasm-form), and the last-word-\
4405         substitution `:caminho \"../foo!$\"` shape silently pass every prior cascade \
4406         arm (`!` isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / `?` / `(` \
4407         / `)` / `{{` / `}}` / `[` / `]` / `'` / `\"` / `#` / `%` / `$`) and route \
4408         through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
4409         subdirectory that fails at resolve time with a non-self-locating `No such file \
4410         or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
4411         the value verbatim in its per-dep content-address `path:{caminho}` at \
4412         caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
4413         rides into every shell-spawned subprocess (the resolver's `git clone`, a \
4414         future `feira tofu` shell-out, a future operator-side `nix flake check` spawn) \
4415         as the canonical shell-history-expansion / RFC-3986-sub-delims surface every \
4416         peer single-token-shaped typed slot already closes. The peer `:fonte :repo` \
4417         axis closes the byte under the same shell-history-expansion / RFC-3986-sub-\
4418         delims banner (7d53c68 `!` on `is_git_repo_url`). Express the path as a bare \
4419         relative single-token like \"../caixa-teia\" — the sibling-workspace directory \
4420         name carries no shell-history-expansion / bang-operator semantic; drop any \
4421         `!sudo` / `!!` / `!$` history-expansion trailing paste-from-shell-history \
4422         idiom; and drop any trailing English-typography exclamation mark that pasted \
4423         from prose.",
4424        ch = *byte as char
4425    )]
4426    FonteCaminhoShellHistoryExpansion {
4427        nome: String,
4428        caminho: String,
4429        byte: u8,
4430    },
4431    #[error(
4432        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4433         history-substitution / RFC-3986-'unwise' / regex-negation metacharacter 0x{byte:02x} \
4434         `{ch}` (POSIX bash's `set -o histexpand` mode — the default for every interactive \
4435         session and every `bash -i` subprocess-argument context `feira tofu` / `git clone` / \
4436         `nix flake check` cross — lexes `^old^new^` per bash reference §9.3 as the 'quick \
4437         substitution' history operator that rewrites the prior command's `old` string to \
4438         `new` and re-executes it verbatim, the canonical typo-correction one-liner idiom \
4439         (`git clone <bad-url>` → `^bad^good` typo-fix-and-rerun the paste-from-shell-\
4440         history author trims only the leading `git clone` prefix from). RFC 3986 §2 lists \
4441         `^` in the 'unwise' set every URL parser is required to percent-encode-or-refuse at \
4442         the wire boundary, and the WHATWG URL spec's 'fragment percent-encode set' maps \
4443         `^` → `%5E` at the query / fragment component transition, so `Path::join` on the \
4444         literal value diverges from every downstream `feira tofu` curl-invocation / \
4445         artifact-registry-fetch that percent-encodes the byte before the wire. `^` is also \
4446         the regex character-class negation prefix (`[^abc]`), the bitwise XOR operator in \
4447         C / C++ / Rust / Python / JavaScript / Nix / Go, the Windows `cmd.exe` escape \
4448         metacharacter, and the LaTeX / Markdown / BibTeX superscript operator. POSIX \
4449         `std::path::Path` treats `^` as a literal path-component byte, so \
4450         `:caminho \"../foo^bar/baz\"` (embedded quick-substitution), `:caminho \
4451         \"../foo^\"` (trailing history-substitution-open shape), or `:caminho \"../x^y\"` \
4452         (XOR-expression paste-from-source) silently pass every prior cascade arm (`^` \
4453         isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / `?` / `(` / `)` / `{{` \
4454         / `}}` / `[` / `]` / `'` / `\"` / `#` / `%` / `$` / `!`) and route through \
4455         `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` subdirectory \
4456         that fails at resolve time with a non-self-locating `No such file or directory` \
4457         error far from the source caixa.lisp. The lacre pipeline embeds the value verbatim \
4458         in its per-dep content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, \
4459         so the byte lands in the BLAKE3 closure and rides into every shell-spawned \
4460         subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a future \
4461         operator-side `nix flake check` spawn) as the canonical shell-history-substitution \
4462         / RFC-3986-unwise surface every peer single-token-shaped typed slot already closes. \
4463         The peer `:fonte :repo` axis closes the byte under the same shell-history-\
4464         substitution / RFC-3986-unwise banner (49e142f `^` on `is_git_repo_url`). Together \
4465         with the immediate-predecessor `!` arm (6a04767) this arm closes the full `set -o \
4466         histexpand` operator surface on the `:caminho` axis — the `!command` / `!!` / `!$` \
4467         prefix form via `!`, the `^old^new^` quick-substitution form via `^`. Express the \
4468         path as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
4469         directory name carries no shell-history-substitution / regex-negation / XOR-operator \
4470         semantic; drop any `^old^new` history-substitution paste-from-shell-history idiom; \
4471         drop any trailing `^` history-substitution-open fragment.",
4472        ch = *byte as char
4473    )]
4474    FonteCaminhoShellHistorySubstitution {
4475        nome: String,
4476        caminho: String,
4477        byte: u8,
4478    },
4479    #[error(
4480        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} has a trailing \
4481         `/` (the resolver's `Path::join` resolves `\"../caixa-teia\"` and \
4482         `\"../caixa-teia/\"` to the same directory, but the lacre pipeline embeds the \
4483         value verbatim in its per-dep content-address `path:{caminho}` at \
4484         caixa-resolver/src/resolve.rs:189, so two authors whose only difference is \
4485         shell tab-completion emit byte-divergent BLAKE3 closures for the same caixa — \
4486         defeating the THEORY.md §V.2 render-determinism contract via the trailing-\
4487         separator vector (the canonical paste-from-shell-tab-completion + paste-from-\
4488         `pwd`-with-`/`-suffix footgun, and the canonical Cargo-style `path = \
4489         \"../caixa-teia/\"` paste-from-Cargo-manifest cross-idiom leak). Drop the \
4490         trailing `/`; every `:caminho` value names a sibling-workspace directory \
4491         already, so the trailing separator carries no information. Use \
4492         `\"../caixa-teia\"` rather than `\"../caixa-teia/\"`)"
4493    )]
4494    FonteCaminhoTrailingSlash { nome: String, caminho: String },
4495    #[error(
4496        "{list} carries duplicate entry :nome {nome:?} — every dep list keys its \
4497         entries by caixa name (Cargo's [dependencies] / [dev-dependencies] tables \
4498         apply the same set-not-multiset discipline; one package per table), and \
4499         two entries naming the same caixa carry two version constraints / source \
4500         pins / feature sets for one identity. The caixa-resolver's lacre pipeline \
4501         consumes the list as a `HashMap`-keyed-by-`:nome` lookup: the second entry \
4502         silently overwrites the first at the resolver-side `concrete_versao` step, \
4503         and the dropped entry's pin / features never reach the closure — far from \
4504         the source caixa.lisp, with no field naming which `:deps` entry was the \
4505         silent loser. If two version constraints are genuinely needed (the rare \
4506         multi-version closure case the lacre pipeline doesn't yet support), the \
4507         author surface is two distinct caixa names (e.g. a `caixa-teia-v01` / \
4508         `caixa-teia-v02` aliased pair); within one list, one entry per caixa name."
4509    )]
4510    DuplicateNome { nome: String, list: &'static str },
4511    #[error(
4512        ":deps entry {nome:?} has empty :caracteristicas entry — every feature flag must \
4513         name a non-empty identifier on the target caixa (Cargo's [dependencies.<dep>.features] \
4514         applies the same per-entry non-empty discipline). An empty feature flag reaches the \
4515         caixa-resolver's lacre pipeline as a no-op feature enable, silently dropping the \
4516         author's intent far from the source caixa.lisp; drop the empty entry, or replace it \
4517         with the canonical kebab-case feature name the target caixa declares."
4518    )]
4519    CaracteristicaEmpty { nome: String },
4520    #[error(
4521        ":deps entry {nome:?} :caracteristicas entry {caracteristica:?} is not a valid Cargo \
4522         feature name: {reason} (the value flows verbatim into Cargo's \
4523         [dependencies.<dep>.features] list and Cargo's `restricted_names::validate_feature_name` \
4524         parser enforces the same shape at `cargo metadata` time; use a single-token \
4525         identifier like `\"http\"`, `\"derive\"`, or `\"runtime-tokio\"` — kebab-case ASCII \
4526         alphanumeric with `-`, `_`, `+`, or `.` as continuation characters, starting with \
4527         an ASCII alphanumeric or `_`)"
4528    )]
4529    CaracteristicaInvalid {
4530        nome: String,
4531        caracteristica: String,
4532        reason: String,
4533    },
4534    #[error(
4535        ":deps entry {nome:?} :caracteristicas carries duplicate feature {caracteristica:?} — \
4536         every feature-flag list keys its entries by name (Cargo's \
4537         [dependencies.<dep>.features] applies the same set-not-multiset discipline; one entry \
4538         per feature per dep), and two entries naming the same feature are a redundant \
4539         set-membership declaration for one identity (the feature-toggle slot is set-shaped; \
4540         enabling a feature twice has no additional semantic). The caixa-resolver's lacre \
4541         pipeline consumes the list as a set-shaped feature toggle — the resolver enables the \
4542         feature once regardless of declaration count, so the duplicate's pin / position never \
4543         reaches the closure with no field naming the silent loser. One entry per feature per \
4544         dep; if two distinct features are intended, name each verbatim."
4545    )]
4546    CaracteristicaDuplicate {
4547        nome: String,
4548        caracteristica: String,
4549    },
4550    #[error(
4551        "{list} entry :nome {nome:?} names the caixa itself — a caixa cannot depend \
4552         on itself (the lacre closure's dep-graph traversal is rooted at the caixa's \
4553         :nome, and a self-dep would be a one-node cycle the caixa-resolver either \
4554         rejects mid-traversal far from the source caixa.lisp or recurses on until \
4555         it exhausts its stack). Every :nome is globally-unique substrate identity, \
4556         so a :deps / :deps-dev entry whose :nome equals the parent caixa's :nome \
4557         *is* the parent itself, not a coincidentally-named peer. Drop the \
4558         self-referential dep entry — to reference code from this caixa, use \
4559         :bibliotecas / :exe / :servicos (the substrate-blessed shape for \
4560         referencing the caixa's own code surface) instead."
4561    )]
4562    DepIsSelf { nome: String, list: &'static str },
4563}
4564
4565// Fold the eleven `DepError::FonteCaminho<Variant> { nome: nome.to_string(),
4566// caminho: caminho.to_string() }` two-slot struct-variant wire-up sites at
4567// [`DepSource::validate_caminho`] onto one substrate primitive per typed
4568// variant — the paired `{ nome: String, caminho: String }` two-slot family
4569// on [`DepError`], sibling of the peer
4570// [`crate::supervisor::supervisor_caixa_only_ctors!`] (db09650, 3 variants
4571// on `{ caixa: String }`) on the `SupervisorError` envelope, the peer
4572// [`crate::aplicacao::contrato_empty_pair_ctors!`] (8580068, 4 variants on
4573// `{ de, para }`), [`crate::aplicacao::aplicacao_field_reason_ctors!`]
4574// (981060b, 7 variants on `{ <field>: String, reason: String }`),
4575// [`crate::aplicacao::contrato_target_ctors!`] (14b81d5, 2 variants on
4576// `{ de, para, wit, expected }`), and
4577// [`crate::aplicacao::contrato_pair_value_reason_ctors!`] (14e13f1, 3
4578// variants on `{ de, para, <field>: String, reason: String }`) on the
4579// `AplicacaoError` envelopes, the peer
4580// [`crate::layout::layout_violation_ctors!`] (131ca0d, 16 variants on
4581// `{ caixa, issue }`), [`crate::layout::layout_slot_kind_ctors!`]
4582// (0419438, 4 variants on `{ caixa, kind, slots }`),
4583// [`crate::LayoutError::missing_entry`] (1b09f9d, one variant on
4584// `{ kind, path }`), and [`crate::layout::layout_nome_only_ctors!`]
4585// (3fe3dd7, 6 variants on `<Variant>(String)`) on the `LayoutError`
4586// envelopes, the peer three [`crate::limits::limits_codec_value_*_ctors!`]
4587// codec-family macros (81c856c, 12 wire-ups) on the `LimitsError`
4588// envelope, and the peer [`crate::upgrade::upgrade_from_script_ctors!`]
4589// (8e67041, 3 variants on `{ from: String, script: PathBuf }`) on the
4590// `UpgradeError` envelope. First fold family on this `DepError` envelope.
4591//
4592// Each of the eleven wire-up sites on this shape (the leading-byte cascade
4593// closing the seven `FonteCaminho{Absolute, TildeExpansion, VarExpansion,
4594// LeadingWhitespace, LeadingHyphen}` arms; the orthogonal single-metachar
4595// cascade closing `FonteCaminhoBackslash` on `\`; the shell-lexer-metachar
4596// cascade closing `FonteCaminhoShell{Pipe, Semicolon, Background,
4597// CommandSubstitution}` on the four single-byte shell operators; and the
4598// trailing-`/` reproducibility arm closing `FonteCaminhoTrailingSlash`)
4599// opened the identical `DepError::FonteCaminho<Variant> { nome:
4600// nome.to_string(), caminho: caminho.to_string() }` four-line
4601// struct-literal against the same `(nome: &str, caminho: &str)` local pair
4602// — the exact "same block re-inlined at every consumer" shape the PRIME
4603// DIRECTIVE names as a bug, on the same altitude the peer `LayoutError` /
4604// `AplicacaoError` / `SupervisorError` / `LimitsError` / `UpgradeError`
4605// families each closed on their sibling envelopes. The eleven variants
4606// share one `{ nome: String, caminho: String }` shape, so the fold routes
4607// each wire-up site through one dispatch per typed variant.
4608//
4609// The macro below generates one `#[must_use]` inherent constructor per
4610// variant of shape `fn <ctor>(nome: &str, caminho: &str) -> Self`, so every
4611// wire-up site collapses onto one dispatch:
4612// `DepError::<ctor>(nome, caminho)`, byte-equal to the pre-lift
4613// struct-literal on the same `(&str, &str)` fixture. The uniform two-field
4614// construction (`nome.to_string()` / `caminho.to_string()`) is spelled
4615// once — inside the macro — rather than at every wire-up site.
4616//
4617// The twelve `FonteCaminho<Variant> { nome, caminho, byte }` three-field
4618// shapes at the per-byte-classification arms — the
4619// `FonteCaminho{ControlChar,ShellRedirection,ShellGlob,
4620// ShellSubshellGrouping,ShellBraceExpansion,ShellBracketExpansion,
4621// ShellQuoteGrouping,ShellComment,UrlPercentEncoding,
4622// ShellVariableExpansion,ShellHistoryExpansion,ShellHistorySubstitution}`
4623// cluster — carry an additional `byte: u8` naming the offending byte and
4624// so would break the uniform-two-field routing this macro promises. They
4625// instead fold onto the sibling three-field envelope through
4626// [`fonte_caminho_byte_ctors!`] (this-commit-lift, 12 variants on the
4627// `{ nome, caminho, byte }` shape), whose sole additional axis over this
4628// two-slot family is the `byte: u8` classification the arms carry. The
4629// remaining `FonteCaminhoEmpty` one-field `{ nome }` shape at the empty-
4630// first arm folds instead onto the peer [`dep_nome_only_ctors!`]
4631// (792aa92, 5 variants on `{ nome: String }`) sibling family of this
4632// envelope.
4633//
4634// Every future consumer that wants to construct one of these eleven
4635// variants outside the current in-crate [`DepSource::validate_caminho`]
4636// wire-up sites (a deferred `caixa-resolver` per-`:caminho` re-validator
4637// at lacre-resolve time re-checking the same value-shape axes the resolver
4638// consumes, a future `feira validate --deps` per-caixa admission verb
4639// re-checking the `:fonte :caminho` axis, a per-lacre overlay resolver
4640// rejecting a `:caminho` value against a cluster-local snapshot) now
4641// reaches each variant through one call rather than re-inlining the
4642// four-line struct-literal in lockstep with the eleven in-crate wire-up
4643// sites.
4644macro_rules! fonte_caminho_ctors {
4645    ($($ctor:ident => $variant:ident),* $(,)?) => {
4646        impl DepError {
4647            $(
4648                #[doc = concat!(
4649                    "Construct a [`DepError::",
4650                    stringify!($variant),
4651                    "`] naming the offending `:deps :nome` + `:fonte ",
4652                    "(:tipo path …) :caminho` pair. Folds the uniform ",
4653                    "`Self::",
4654                    stringify!($variant),
4655                    " { nome: nome.to_string(), caminho: caminho.to_string() }` ",
4656                    "two-slot struct-literal onto one substrate primitive so ",
4657                    "every [`DepSource::validate_caminho`] wire-up on this ",
4658                    "variant reads through one dispatch rather than the ",
4659                    "pre-lift four-line open-coded block."
4660                )]
4661                #[must_use]
4662                pub fn $ctor(nome: &str, caminho: &str) -> Self {
4663                    Self::$variant {
4664                        nome: nome.to_string(),
4665                        caminho: caminho.to_string(),
4666                    }
4667                }
4668            )*
4669        }
4670    };
4671}
4672
4673fonte_caminho_ctors! {
4674    fonte_caminho_absolute => FonteCaminhoAbsolute,
4675    fonte_caminho_tilde_expansion => FonteCaminhoTildeExpansion,
4676    fonte_caminho_var_expansion => FonteCaminhoVarExpansion,
4677    fonte_caminho_leading_whitespace => FonteCaminhoLeadingWhitespace,
4678    fonte_caminho_leading_hyphen => FonteCaminhoLeadingHyphen,
4679    fonte_caminho_backslash => FonteCaminhoBackslash,
4680    fonte_caminho_shell_pipe => FonteCaminhoShellPipe,
4681    fonte_caminho_shell_semicolon => FonteCaminhoShellSemicolon,
4682    fonte_caminho_shell_background => FonteCaminhoShellBackground,
4683    fonte_caminho_shell_command_substitution => FonteCaminhoShellCommandSubstitution,
4684    fonte_caminho_trailing_slash => FonteCaminhoTrailingSlash,
4685}
4686
4687// Fold the twelve `DepError::FonteCaminho<Variant> { nome: nome.to_string(),
4688// caminho: caminho.to_string(), byte: b }` three-slot struct-variant wire-up
4689// sites at [`DepSource::validate_caminho`] onto one substrate primitive per
4690// typed variant — the paired `{ nome: String, caminho: String, byte: u8 }`
4691// three-slot family on [`DepError`], strict sibling of the peer
4692// [`fonte_caminho_ctors!`] (f85f145, 11 variants on the two-slot
4693// `{ nome: String, caminho: String }` envelope) of this envelope. Extends
4694// that fold onto the `byte`-classifying arms whose additional `byte: u8`
4695// axis broke its uniform-two-field routing — the exact "future compounding
4696// work" the pre-lift `fonte_caminho_ctors!` prose named as deferred, closed
4697// here. Third fold family on this `DepError` envelope, sibling of the peer
4698// two-slot [`fonte_caminho_ctors!`] and one-slot [`dep_nome_only_ctors!`]
4699// (792aa92, 5 variants on the `{ nome: String }` envelope) families on the
4700// same enum.
4701//
4702// Each of the twelve wire-up sites on this shape (the control-byte arm
4703// closing `FonteCaminhoControlChar` on the sub-`0x20` / `0x7F` cluster; the
4704// shell-lexer-metachar cascade closing `FonteCaminhoShellRedirection` on
4705// `< >`, `FonteCaminhoShellGlob` on `* ?`, `FonteCaminhoShellSubshellGrouping`
4706// on `( )`, `FonteCaminhoShellBraceExpansion` on `{ }`,
4707// `FonteCaminhoShellBracketExpansion` on `[ ]`, and
4708// `FonteCaminhoShellQuoteGrouping` on `' "`; the single-metachar arms
4709// closing `FonteCaminhoShellComment` on `#`, `FonteCaminhoUrlPercentEncoding`
4710// on `%`, `FonteCaminhoShellVariableExpansion` on `$`,
4711// `FonteCaminhoShellHistoryExpansion` on `!`, and
4712// `FonteCaminhoShellHistorySubstitution` on `^`) opened the identical
4713// `DepError::FonteCaminho<Variant> { nome: nome.to_string(),
4714// caminho: caminho.to_string(), byte: b }` five-line struct-literal against
4715// the same `(nome: &str, caminho: &str, b: u8)` local triple — the exact
4716// "same block re-inlined at every consumer" shape the PRIME DIRECTIVE names
4717// as a bug, on the same altitude the peer two-slot `fonte_caminho_ctors!`
4718// closed on the sibling two-field envelope of this same enum. The twelve
4719// variants share one `{ nome: String, caminho: String, byte: u8 }` shape, so
4720// the fold routes each wire-up site through one dispatch per typed variant.
4721//
4722// The macro below generates one `#[must_use]` inherent constructor per
4723// variant of shape `fn <ctor>(nome: &str, caminho: &str, byte: u8) -> Self`,
4724// so every wire-up site collapses onto one dispatch:
4725// `DepError::<ctor>(nome, caminho, b)`, byte-equal to the pre-lift
4726// struct-literal on the same `(&str, &str, u8)` fixture. The uniform
4727// three-field construction (`nome.to_string()` / `caminho.to_string()` /
4728// `byte`) is spelled once — inside the macro — rather than at every wire-up
4729// site.
4730//
4731// Every future consumer that wants to construct one of these twelve
4732// variants outside the current in-crate [`DepSource::validate_caminho`]
4733// wire-up sites (a deferred `caixa-resolver` per-`:caminho` re-validator
4734// at lacre-resolve time re-checking the same value-shape axes the resolver
4735// consumes, a future `feira validate --deps` per-caixa admission verb
4736// re-checking the `:fonte :caminho` axis against the shell-metachar
4737// classification bytes this cluster catches, a per-lacre overlay resolver
4738// rejecting a `:caminho` value against a cluster-local snapshot) now
4739// reaches each variant through one call rather than re-inlining the
4740// five-line struct-literal in lockstep with the twelve in-crate wire-up
4741// sites.
4742macro_rules! fonte_caminho_byte_ctors {
4743    ($($ctor:ident => $variant:ident),* $(,)?) => {
4744        impl DepError {
4745            $(
4746                #[doc = concat!(
4747                    "Construct a [`DepError::",
4748                    stringify!($variant),
4749                    "`] naming the offending `:deps :nome` + `:fonte ",
4750                    "(:tipo path …) :caminho` pair + the offending `byte: u8` ",
4751                    "classification. Folds the uniform `Self::",
4752                    stringify!($variant),
4753                    " { nome: nome.to_string(), caminho: caminho.to_string(), ",
4754                    "byte }` three-slot struct-literal onto one substrate ",
4755                    "primitive so every [`DepSource::validate_caminho`] wire-up ",
4756                    "on this variant reads through one dispatch rather than ",
4757                    "the pre-lift five-line open-coded block."
4758                )]
4759                #[must_use]
4760                pub fn $ctor(nome: &str, caminho: &str, byte: u8) -> Self {
4761                    Self::$variant {
4762                        nome: nome.to_string(),
4763                        caminho: caminho.to_string(),
4764                        byte,
4765                    }
4766                }
4767            )*
4768        }
4769    };
4770}
4771
4772fonte_caminho_byte_ctors! {
4773    fonte_caminho_control_char => FonteCaminhoControlChar,
4774    fonte_caminho_shell_redirection => FonteCaminhoShellRedirection,
4775    fonte_caminho_shell_glob => FonteCaminhoShellGlob,
4776    fonte_caminho_shell_subshell_grouping => FonteCaminhoShellSubshellGrouping,
4777    fonte_caminho_shell_brace_expansion => FonteCaminhoShellBraceExpansion,
4778    fonte_caminho_shell_bracket_expansion => FonteCaminhoShellBracketExpansion,
4779    fonte_caminho_shell_quote_grouping => FonteCaminhoShellQuoteGrouping,
4780    fonte_caminho_shell_comment => FonteCaminhoShellComment,
4781    fonte_caminho_url_percent_encoding => FonteCaminhoUrlPercentEncoding,
4782    fonte_caminho_shell_variable_expansion => FonteCaminhoShellVariableExpansion,
4783    fonte_caminho_shell_history_expansion => FonteCaminhoShellHistoryExpansion,
4784    fonte_caminho_shell_history_substitution => FonteCaminhoShellHistorySubstitution,
4785}
4786
4787// Fold the five `DepError::<Variant> { nome: <owner>.clone_or_to_string() }`
4788// single-slot struct-variant wire-up sites scattered across
4789// [`Dep::validate`] / [`Dep::validate_caracteristicas`] /
4790// [`DepSource::validate`] / [`DepSource::validate_caminho`] onto one
4791// substrate primitive per typed variant — the paired `{ nome: String }`
4792// single-slot family on [`DepError`], sibling of the peer
4793// [`fonte_caminho_ctors!`] (f85f145, 11 variants on
4794// `{ nome: String, caminho: String }`) on the sibling two-slot envelope of
4795// the same enum, and of the peer
4796// [`crate::supervisor::supervisor_caixa_only_ctors!`] (db09650, 3 variants
4797// on `{ caixa: String }`) on the `SupervisorError` envelope's single-slot
4798// axis. Second fold family on this `DepError` envelope, and the first on
4799// the single-`{ nome }` shape.
4800//
4801// The five wire-up sites this fold closes each opened the identical
4802// `DepError::<Variant> { nome: <owner>.to_string_or_clone() }` three-line
4803// struct-literal against the same `nome: &str` (or `self.nome: &String`)
4804// local — the exact "same block re-inlined at every consumer" shape the
4805// PRIME DIRECTIVE names as a bug. The five variants share one
4806// `{ nome: String }` shape, so the fold routes each wire-up site through
4807// one dispatch per typed variant.
4808//
4809// The macro below generates one `#[must_use]` inherent constructor per
4810// variant of shape `fn <ctor>(nome: &str) -> Self`, so every wire-up site
4811// collapses onto one dispatch: `DepError::<ctor>(nome)`, byte-equal to the
4812// pre-lift struct-literal on the same `&str` fixture. The uniform
4813// one-field construction (`nome.to_string()`) is spelled once — inside
4814// the macro — rather than at every wire-up site. Callers that hold a
4815// `String` (`self.nome`) pass `&self.nome`, which auto-derefs to `&str`
4816// and lets the macro-owned `.to_string()` produce the fresh owning copy
4817// the enum variant needs; the semantics collapse onto the same
4818// `.clone()`-equivalent one this fold replaces at every site.
4819//
4820// The sibling `NomeEmpty` unit-variant (`enum DepError { NomeEmpty, … }`)
4821// on the same envelope stays on its pre-lift open-coded wire-up shape —
4822// it carries no `nome` field (the offending `:nome` value *is* the empty
4823// string this variant catches) so the uniform `fn(nome: &str) -> Self`
4824// signature this macro promises does not apply. Every future consumer
4825// that wants to construct one of these five variants outside the current
4826// in-crate wire-up sites (a deferred `caixa-resolver` per-`:versao` /
4827// `:caracteristicas` / `:fonte :repo` / `:fonte :pin` / `:fonte :caminho`
4828// re-validator at lacre-resolve time, a future `feira validate --deps`
4829// per-caixa admission verb, a per-lacre overlay resolver rejecting one of
4830// these empty-value shapes against a cluster-local snapshot) now reaches
4831// each variant through one call rather than re-inlining the three-line
4832// struct-literal in lockstep with the five in-crate wire-up sites.
4833macro_rules! dep_nome_only_ctors {
4834    ($($ctor:ident => $variant:ident),* $(,)?) => {
4835        impl DepError {
4836            $(
4837                #[doc = concat!(
4838                    "Construct a [`DepError::",
4839                    stringify!($variant),
4840                    "`] naming the offending `:deps :nome`. Folds the ",
4841                    "uniform `Self::",
4842                    stringify!($variant),
4843                    " { nome: nome.to_string() }` one-field ",
4844                    "struct-literal onto one substrate primitive so every ",
4845                    "in-crate wire-up on this variant reads through one ",
4846                    "dispatch rather than the pre-lift three-line ",
4847                    "open-coded block."
4848                )]
4849                #[must_use]
4850                pub fn $ctor(nome: &str) -> Self {
4851                    Self::$variant { nome: nome.to_string() }
4852                }
4853            )*
4854        }
4855    };
4856}
4857
4858dep_nome_only_ctors! {
4859    versao_empty => VersaoEmpty,
4860    fonte_repo_empty => FonteRepoEmpty,
4861    fonte_pin_missing => FontePinMissing,
4862    fonte_caminho_empty => FonteCaminhoEmpty,
4863    caracteristica_empty => CaracteristicaEmpty,
4864}
4865
4866// Fold the four `DepError::{DuplicateNome, DepIsSelf}` struct-variant
4867// wire-up sites at [`crate::manifest::Caixa::push_dep`] +
4868// [`crate::manifest::Caixa::validate_deps`] +
4869// [`validate_no_self_dep`] onto one substrate-primitive family per
4870// typed variant — the `DepError`-side siblings of the peer
4871// [`crate::supervisor::supervisor_caixa_only_ctors!`] macro (db09650)
4872// on the `SupervisorError { caixa: String }` one-slot envelope and of
4873// the peer [`dep_nome_only_ctors!`] macro (792aa92) on the
4874// `DepError { nome: String }` one-slot envelope. The two variants
4875// carry the same `{ nome: String, list: &'static str }` two-slot
4876// shape: the `nome` field names the offending dep the diagnostic
4877// points the author back at, and the `list` field carries the
4878// `":deps"` / `":deps-dev"` author-surface tag verbatim (via
4879// [`crate::dep::DepList::as_str`] on the [`push_dep`] /
4880// [`validate_deps`] arms, and via the paired
4881// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
4882// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `&'static str`
4883// canonicals on the [`validate_no_self_dep`] arm) so the author can
4884// grep their caixa.lisp for the offending list block in one edit.
4885//
4886// Each of the four wire-up sites opened the same struct-literal
4887// `DepError::<Variant> { nome: <name>.to_string(), list: <tag> }`
4888// two-line block — the exact "same block re-inlined at every
4889// consumer" shape the PRIME DIRECTIVE names as a bug, on the same
4890// altitude the peer `DepError` / `SupervisorError` /
4891// `AplicacaoError` / `LayoutError` / `LimitsError` ctor families
4892// already closed on their sibling envelopes. The two `#[must_use]`
4893// inherent constructors below fold each wire-up onto one dispatch:
4894// `DepError::duplicate_nome(<nome>, <list>)` and
4895// `DepError::dep_is_self(<nome>, <list>)`, byte-equal to the
4896// pre-lift struct-literal on the same scalar fixtures. The `list:
4897// &'static str` parameter (not `impl Into<String>`) preserves the
4898// exact wire tag every consumer already passes verbatim — no
4899// downstream diagnostic reshaping at the lift, matching the peer
4900// `DepList::as_str` / `DEP_AUTHOR_KEY_DEPS*` `&'static str`
4901// contract each wire-up site already keys off.
4902macro_rules! dep_nome_list_ctors {
4903    ($($ctor:ident => $variant:ident),* $(,)?) => {
4904        impl DepError {
4905            $(
4906                #[doc = concat!(
4907                    "Construct a [`DepError::",
4908                    stringify!($variant),
4909                    "`] naming the offending `:deps :nome` and the ",
4910                    "author-surface list tag (`:deps` vs. `:deps-dev`) ",
4911                    "the diagnostic points the author back at. Folds ",
4912                    "the uniform `Self::",
4913                    stringify!($variant),
4914                    " { nome: nome.to_string(), list }` two-field ",
4915                    "struct-literal onto one substrate primitive so ",
4916                    "every in-crate wire-up on this variant reads ",
4917                    "through one dispatch rather than the pre-lift ",
4918                    "open-coded struct-literal block."
4919                )]
4920                #[must_use]
4921                pub fn $ctor(nome: &str, list: &'static str) -> Self {
4922                    Self::$variant { nome: nome.to_string(), list }
4923                }
4924            )*
4925        }
4926    };
4927}
4928
4929dep_nome_list_ctors! {
4930    duplicate_nome => DuplicateNome,
4931    dep_is_self => DepIsSelf,
4932}
4933
4934// Fold the three `DepError::{VersaoInvalid, FonteRepoShape,
4935// CaracteristicaInvalid} { nome: <nome>.to_string(), <axis>:
4936// <value>.to_string(), reason }` struct-variant wire-up sites at
4937// [`Dep::validate`]'s `:versao` requirement-shape gate + [`DepSource::validate`]'s
4938// `:fonte (:tipo git …) :repo` value-shape gate + [`Dep::validate_caracteristicas`]'s
4939// per-entry `:caracteristicas` feature-name-shape gate onto one substrate-
4940// primitive family per typed variant — the `DepError`-side siblings of the
4941// peer [`dep_nome_only_ctors!`] (792aa92) on the one-slot `{ nome }`
4942// envelope, [`dep_nome_list_ctors!`] (6f5e0cd) on the two-slot `{ nome,
4943// list: &'static str }` envelope, [`fonte_caminho_ctors!`] (f85f145) on
4944// the two-slot `{ nome, caminho }` envelope, and
4945// [`fonte_caminho_byte_ctors!`] (0e35793) on the three-slot `{ nome,
4946// caminho, byte }` envelope. The three variants share the same
4947// `{ nome: String, <axis>: String, reason: String }` three-slot shape —
4948// the `nome` field names the offending dep the diagnostic points the
4949// author back at, the middle `<axis>: String` field carries the offending
4950// axis value verbatim (`:versao` requirement scalar on `VersaoInvalid`,
4951// `:repo` URL scalar on `FonteRepoShape`, `:caracteristicas` per-entry
4952// feature-name scalar on `CaracteristicaInvalid`), and the `reason: String`
4953// field carries the parser-shaped rejection sentence the paired
4954// [`crate::render::require_valid_versao_requirement`] /
4955// [`crate::render::is_git_repo_url`] /
4956// [`crate::render::is_cargo_feature_name`] predicate returned. The middle
4957// axis-field name differs across variants (`versao` / `repo` /
4958// `caracteristica`) so the ctor family below takes the axis field name as
4959// a macro parameter (`$axis:ident`) alongside the ctor + variant names,
4960// generating one `pub fn $ctor(nome: &str, $axis: &str, reason: String)
4961// -> Self` inherent constructor per typed variant that spells the uniform
4962// three-field construction (`nome.to_string()` / `<axis>.to_string()` /
4963// `reason` forwarded owned) exactly once. Peer of the sibling
4964// [`crate::aplicacao::aplicacao_field_reason_ctors!`] (981060b) macro
4965// family on the `AplicacaoError` envelope's mirror-symmetric
4966// `{ <field>: String, reason: String }` two-slot shape — same
4967// `<axis>: <value>.to_string()` + `reason` owned-forward payload shape,
4968// one `nome`-axis added at the per-dep-owned altitude the `DepError`
4969// envelope keys off (every `DepError` variant carries the offending
4970// `:deps :nome` verbatim so the author can grep their caixa.lisp for the
4971// offending block in one edit).
4972//
4973// The three wire-up sites this fold closes are:
4974// - [`DepSource::validate`]'s `:repo` value-shape arm
4975//   (`Err(DepError::FonteRepoShape { nome: nome.to_string(), repo:
4976//   repo.clone(), reason })` after [`crate::render::is_git_repo_url`]
4977//   rejects the offending URL);
4978// - [`Dep::validate`]'s `:versao` requirement-shape arm
4979//   (`|reason| DepError::VersaoInvalid { nome: self.nome.clone(), versao:
4980//   self.versao_requirement().to_string(), reason }` inside the
4981//   [`crate::render::require_valid_versao_requirement`] callback pair);
4982// - [`Dep::validate_caracteristicas`]'s per-entry feature-name-shape arm
4983//   (`Err(DepError::CaracteristicaInvalid { nome: self.nome.clone(),
4984//   caracteristica: c.clone(), reason })` after
4985//   [`crate::render::is_cargo_feature_name`] rejects the offending
4986//   feature-name).
4987//
4988// Each opened the identical five-line struct-literal against the same
4989// `(nome, <axis>, reason)` local triple — the exact "same block re-inlined
4990// at every consumer" shape the PRIME DIRECTIVE names as a bug, on the
4991// same altitude the peer four already-lifted `DepError` ctor families
4992// closed on their sibling shape-envelopes. The three variant / axis-field
4993// discriminators are the only things that vary between them; the rest of
4994// the struct-literal is a byte-for-byte re-inline.
4995//
4996// Every future consumer wanting to raise one of these three diagnostics
4997// (a deferred `caixa-resolver` per-`:deps` re-validator at lacre-resolve
4998// time re-checking each declared dep against the same requirement +
4999// git-URL + feature-name value-shape cascade, a future `feira validate
5000// --deps` per-caixa admission verb re-running the shape gates on demand,
5001// a per-lacre overlay resolver rejecting an author-supplied dep against a
5002// cluster-local snapshot) now reaches one dispatch rather than re-inlining
5003// the five-line struct-literal in lockstep with the three in-crate
5004// wire-up sites.
5005macro_rules! dep_nome_axis_reason_ctors {
5006    ($($ctor:ident => $variant:ident { $axis:ident }),* $(,)?) => {
5007        impl DepError {
5008            $(
5009                #[doc = concat!(
5010                    "Construct a [`DepError::",
5011                    stringify!($variant),
5012                    "`] naming the offending `:deps :nome`, the offending ",
5013                    "`:", stringify!($axis), "` axis value, and the ",
5014                    "parser-shaped rejection `reason`. Folds the uniform ",
5015                    "`Self::",
5016                    stringify!($variant),
5017                    " { nome: nome.to_string(), ",
5018                    stringify!($axis),
5019                    ": ",
5020                    stringify!($axis),
5021                    ".to_string(), reason }` three-field struct-literal ",
5022                    "onto one substrate primitive so every in-crate ",
5023                    "wire-up on this variant reads through one dispatch ",
5024                    "rather than the pre-lift five-line open-coded block. ",
5025                    "The `nome: &str` and `",
5026                    stringify!($axis),
5027                    ": &str` parameters accept `&str` literals and ",
5028                    "`&String` (via Deref coercion) so every existing ",
5029                    "wire-up threads through the ctor without a ",
5030                    "pre-conversion; the `reason: String` parameter takes ",
5031                    "an owned `String` (not `impl Into<String>`) matching ",
5032                    "the paired `crate::render::*` predicate's ",
5033                    "`Result<(), String>` return shape every wire-up ",
5034                    "already holds owned at the call site."
5035                )]
5036                #[must_use]
5037                pub fn $ctor(nome: &str, $axis: &str, reason: String) -> Self {
5038                    Self::$variant {
5039                        nome: nome.to_string(),
5040                        $axis: $axis.to_string(),
5041                        reason,
5042                    }
5043                }
5044            )*
5045        }
5046    };
5047}
5048
5049dep_nome_axis_reason_ctors! {
5050    versao_invalid => VersaoInvalid { versao },
5051    fonte_repo_shape => FonteRepoShape { repo },
5052    caracteristica_invalid => CaracteristicaInvalid { caracteristica },
5053}
5054
5055// Fold the three `DepError::{FontePinEmpty, FontePinAmbiguous,
5056// CaracteristicaDuplicate} { nome: <nome>.to_string(), <axis>:
5057// <value>.to_string() }` struct-variant wire-up sites at
5058// [`DepSource::validate`]'s per-`:fonte` git-pin single-pin-empty +
5059// multi-pin-ambiguous cascade and [`Dep::validate_caracteristicas`]'s
5060// per-entry set-not-multiset dedup closure onto one substrate-primitive
5061// family per typed variant — the missing two-slot rung on the
5062// `DepError`-side four-family ladder ([`dep_nome_only_ctors!`] (792aa92)
5063// one-slot `{ nome }` → this two-slot `{ nome, <axis>: String }` →
5064// [`dep_nome_list_ctors!`] (6f5e0cd) two-slot `{ nome, list: &'static
5065// str }` → [`dep_nome_axis_reason_ctors!`] (5621f8a) three-slot
5066// `{ nome, <axis>: String, reason: String }` → [`fonte_pin_shape`]
5067// (86e2a17) four-slot `{ nome, pin, value, reason }`), and mirror-
5068// symmetric sibling of the peer
5069// [`crate::aplicacao::aplicacao_field_reason_ctors!`] (981060b) two-slot
5070// `{ <field>: String, reason: String }` fold on the `AplicacaoError`
5071// envelope — same `<axis>: <value>.to_string()` owned-forward payload
5072// shape, `reason` axis removed and `nome`-axis added at the per-dep-
5073// owned altitude the `DepError` envelope keys off (every `DepError`
5074// variant carries the offending `:deps :nome` verbatim so the author
5075// can grep their caixa.lisp for the offending block in one edit). The
5076// three variants share the same `{ nome: String, <axis>: String }`
5077// two-slot shape: the `nome` field names the offending dep the
5078// diagnostic points the author back at, and the middle `<axis>:
5079// String` field carries the offending per-envelope axis value verbatim
5080// (`:fonte` per-pin author-surface tag on `FontePinEmpty`, the
5081// comma-joined multi-pin ambiguity report on `FontePinAmbiguous`, the
5082// duplicate `:caracteristicas` entry on `CaracteristicaDuplicate`).
5083// The middle axis-field name differs across variants (`pin` / `pins` /
5084// `caracteristica`) so the ctor family below takes the axis field name
5085// as a macro parameter (`$axis:ident`) alongside the ctor + variant
5086// names, generating one `pub fn $ctor(nome: &str, $axis: &str) ->
5087// Self` inherent constructor per typed variant that spells the
5088// uniform two-field construction (`nome.to_string()` /
5089// `<axis>.to_string()`) exactly once.
5090//
5091// The three wire-up sites this fold closes are:
5092// - [`DepSource::validate`]'s per-`:fonte` set-of-one empty-pin arm
5093//   (`return Err(DepError::FontePinEmpty { nome: nome.to_string(), pin:
5094//   pin.to_string() });` inside the `set.len() == 1` branch after the
5095//   `is_some_and(String::is_empty)` iterator);
5096// - [`DepSource::validate`]'s per-`:fonte` set-of-two-or-more
5097//   ambiguity arm (`return Err(DepError::FontePinAmbiguous { nome:
5098//   nome.to_string(), pins: set.join(", ") });` inside the `_` branch);
5099// - [`Dep::validate_caracteristicas`]'s per-entry
5100//   set-not-multiset-dedup closure (`|| DepError::CaracteristicaDuplicate
5101//   { nome: self.nome.clone(), caracteristica: c.clone() }` passed to
5102//   [`crate::render::insert_first_seen`]).
5103//
5104// Each opened the identical four-line struct-literal against the same
5105// `(nome, <axis>)` local pair — the exact "same block re-inlined at
5106// every consumer" shape the PRIME DIRECTIVE names as a bug, on the
5107// same altitude the peer four already-lifted `DepError` ctor families
5108// closed on their sibling shape-envelopes. The three variant / axis-
5109// field discriminators are the only things that vary between them;
5110// the rest of the struct-literal is a byte-for-byte re-inline.
5111//
5112// Every future consumer wanting to raise one of these three
5113// diagnostics (a deferred `caixa-resolver` per-`:deps` re-validator
5114// at lacre-resolve time re-checking each declared dep against the
5115// same `:fonte` set-of-one / set-of-many + `:caracteristicas`
5116// set-not-multiset cascade, a future `feira validate --deps` per-
5117// caixa admission verb re-running the shape gates on demand, a
5118// per-lacre overlay resolver rejecting an author-supplied dep against
5119// a cluster-local snapshot the M4 CR materializer projects) now
5120// reaches one dispatch rather than re-inlining the four-line struct-
5121// literal in lockstep with the three in-crate wire-up sites.
5122macro_rules! dep_nome_axis_ctors {
5123    ($($ctor:ident => $variant:ident { $axis:ident }),* $(,)?) => {
5124        impl DepError {
5125            $(
5126                #[doc = concat!(
5127                    "Construct a [`DepError::",
5128                    stringify!($variant),
5129                    "`] naming the offending `:deps :nome` and the ",
5130                    "offending `:", stringify!($axis), "` axis value. ",
5131                    "Folds the uniform `Self::",
5132                    stringify!($variant),
5133                    " { nome: nome.to_string(), ",
5134                    stringify!($axis),
5135                    ": ",
5136                    stringify!($axis),
5137                    ".to_string() }` two-field struct-literal onto one ",
5138                    "substrate primitive so every in-crate wire-up on ",
5139                    "this variant reads through one dispatch rather than ",
5140                    "the pre-lift four-line open-coded block. Both `nome: ",
5141                    "&str` and `",
5142                    stringify!($axis),
5143                    ": &str` parameters accept `&str` literals and ",
5144                    "`&String` (via Deref coercion) so every existing ",
5145                    "wire-up threads through the ctor without a pre-",
5146                    "conversion."
5147                )]
5148                #[must_use]
5149                pub fn $ctor(nome: &str, $axis: &str) -> Self {
5150                    Self::$variant {
5151                        nome: nome.to_string(),
5152                        $axis: $axis.to_string(),
5153                    }
5154                }
5155            )*
5156        }
5157    };
5158}
5159
5160dep_nome_axis_ctors! {
5161    fonte_pin_empty => FontePinEmpty { pin },
5162    fonte_pin_ambiguous => FontePinAmbiguous { pins },
5163    caracteristica_duplicate => CaracteristicaDuplicate { caracteristica },
5164}
5165
5166// Fold the two `DepError::FontePinShape { nome: nome.to_string(),
5167// pin: <pin>.to_string(), value: v.clone(), reason }` four-slot
5168// struct-variant wire-up sites at [`DepSource::validate`]'s
5169// per-`:fonte` git-pin value-shape gate onto one substrate primitive on
5170// the `DepError` envelope — the last open-coded ctor site remaining on
5171// the `:fonte (:tipo git …)` value-shape trajectory this envelope
5172// carries, and the single-variant sibling of the peer four already-
5173// lifted [`DepError`] ctor families ([`fonte_caminho_ctors!`] f85f145
5174// on the two-slot `{ nome, caminho }` envelope,
5175// [`fonte_caminho_byte_ctors!`] 0e35793 on the three-slot
5176// `{ nome, caminho, byte }` envelope, [`dep_nome_only_ctors!`] 792aa92
5177// on the one-slot `{ nome }` envelope, and [`dep_nome_list_ctors!`]
5178// 6f5e0cd on the two-slot `{ nome, list }` envelope). Peer of the
5179// sibling [`crate::aplicacao::contrato_pair_value_reason_ctors!`]
5180// (14e13f1) four-slot fold on the `AplicacaoError` envelope — same
5181// `{ …, value: String, reason: String }` payload shape, one axis
5182// removed at the `nome`-only-owner altitude the `DepError` envelope
5183// keys off (no `edge_pair()` de/para pair).
5184//
5185// The two wire-up sites this fold closes are the paired refname-pin
5186// arm (`|| DepError::FontePinShape { nome: nome.to_string(),
5187// pin: pin.to_string(), value: v.clone(), reason }` inside the
5188// `[(":tag", tag), (":branch", branch)]` iterator against
5189// [`crate::render::is_git_ref_name`]) and the hex-OID-pin arm
5190// (`|| DepError::FontePinShape { nome: nome.to_string(),
5191// pin: ":rev".to_string(), value: v.clone(), reason }` against
5192// [`crate::render::is_git_oid`]) — each opened the identical
5193// `DepError::FontePinShape { … }` six-line struct-literal against the
5194// same `(nome: &str, pin: &str, v: &String, reason: String)` local
5195// tuple, the exact "same block re-inlined at every consumer" shape
5196// the PRIME DIRECTIVE names as a bug. The `pin` axis discriminator is
5197// the only thing that varies between them (`":tag"`/`":branch"` on
5198// the refname arm, `":rev"` on the hex-OID arm); the rest of the
5199// struct-literal is a byte-for-byte re-inline. Refname/hex-OID both
5200// route through the same ctor because their `pin` field carries the
5201// author-surface tag verbatim (matching the `FontePinEmpty` /
5202// `FontePinAmbiguous` sibling variants' `pin: String` axis
5203// convention), so the offending author can grep their caixa.lisp for
5204// the offending `:tag "<value>"` / `:branch "<value>"` /
5205// `:rev "<value>"` literal in one edit.
5206//
5207// The single ctor below folds each wire-up onto one dispatch:
5208// `DepError::fonte_pin_shape(nome, pin, v, reason)`, byte-equal to
5209// the pre-lift struct-literal on the same `(&str, &str, &str,
5210// String)` fixture. The uniform four-field construction
5211// (`nome.to_string()` / `pin.to_string()` / `value.to_string()` /
5212// `reason` forwarded owned) is spelled once here rather than at every
5213// wire-up site. The `reason: String` field takes an owned `String`
5214// (not `impl Into<String>`) matching the two call sites' pre-existing
5215// `let Err(reason) = crate::render::is_git_ref_name(v)` /
5216// `let Err(reason) = crate::render::is_git_oid(v)` shape — both
5217// predicates return `Result<(), String>`, so the caller always holds
5218// an owned `String` at the wire-up site and threading it through the
5219// ctor without a `.into()` shim keeps the routing shape byte-equal to
5220// the pre-lift block. The `value: &str` parameter accepts both `&str`
5221// literals (unused today) and `&String` (from the caller-held
5222// `v: &String` on each arm, via Deref coercion), so every existing
5223// wire-up threads through the ctor without a pre-conversion.
5224//
5225// Every future consumer that wants to construct this variant outside
5226// the two in-crate [`DepSource::validate`] wire-up sites (a deferred
5227// `caixa-resolver` per-`:fonte` re-validator at lacre-resolve time
5228// re-checking the same value-shape axes the resolver consumes, a
5229// future `feira validate --deps` per-caixa admission verb re-checking
5230// the `:fonte :tag`/`:branch`/`:rev` axes, a per-lacre overlay
5231// resolver rejecting a git-pin value against a cluster-local
5232// snapshot) now reaches this variant through one call rather than
5233// re-inlining the six-line struct-literal in lockstep with the two
5234// in-crate wire-up sites.
5235impl DepError {
5236    /// Construct a [`DepError::FontePinShape`] naming the offending
5237    /// `:deps :nome`, the offending `:fonte (:tipo git …) :<pin>`
5238    /// axis tag, the offending value, and the parser-shaped `reason`.
5239    /// Folds the uniform
5240    /// `Self::FontePinShape { nome: nome.to_string(),
5241    /// pin: pin.to_string(), value: value.to_string(), reason }`
5242    /// four-field struct-literal onto one substrate primitive so
5243    /// every [`DepSource::validate`] wire-up on this variant reads
5244    /// through one dispatch rather than the pre-lift six-line
5245    /// open-coded block. The `nome` string threads verbatim from
5246    /// [`Dep::nome`] at the call site; the `pin` string carries the
5247    /// author-surface `:tag` / `:branch` / `:rev` tag verbatim; the
5248    /// `value` string carries the offending refname / hex-OID
5249    /// verbatim; and `reason` forwards the owned `String` returned
5250    /// by [`crate::render::is_git_ref_name`] /
5251    /// [`crate::render::is_git_oid`] without a `.into()` shim.
5252    #[must_use]
5253    pub fn fonte_pin_shape(nome: &str, pin: &str, value: &str, reason: String) -> Self {
5254        Self::FontePinShape {
5255            nome: nome.to_string(),
5256            pin: pin.to_string(),
5257            value: value.to_string(),
5258            reason,
5259        }
5260    }
5261
5262    /// Construct a [`DepError::NomeInvalid`] naming the offending
5263    /// `:deps :nome` byte-string and the parser-shaped rejection
5264    /// `reason` returned by [`crate::render::is_dns_1123_label`].
5265    ///
5266    /// Folds the uniform
5267    /// `Self::NomeInvalid { nome: nome.to_string(), reason }` two-field
5268    /// struct-literal onto one substrate primitive so every wire-up on
5269    /// this variant reads through one dispatch rather than the pre-lift
5270    /// four-line open-coded `DepError::NomeInvalid { nome:
5271    /// self.nome.clone(), reason }` block inside [`Dep::validate`]. The
5272    /// missing two-slot `{ nome, reason }` rung on the `DepError`-side
5273    /// ctor-family ladder (`{ nome }` one-slot →
5274    /// [`dep_nome_only_ctors!`] (792aa92); `{ nome, <axis>: String }`
5275    /// two-slot → [`dep_nome_axis_ctors!`] (7f7c950); `{ nome, list:
5276    /// &'static str }` two-slot → [`dep_nome_list_ctors!`] (6f5e0cd);
5277    /// `{ nome, <axis>: String, reason: String }` three-slot →
5278    /// [`dep_nome_axis_reason_ctors!`] (5621f8a); `{ nome, pin, value,
5279    /// reason }` four-slot → [`DepError::fonte_pin_shape`] (86e2a17))
5280    /// — the sole variant on the envelope carrying the
5281    /// `{ nome: String, reason: String }` two-slot shape without a
5282    /// middle axis, matching the peer
5283    /// [`crate::manifest::ManifestError::NomeInvalid`] +
5284    /// [`crate::aplicacao::AplicacaoError::MembroCaixaInvalid`] +
5285    /// [`crate::supervisor::SupervisorError::ChildCaixaInvalid`]
5286    /// four-axis DNS-1123 caixa-identifier diagnostic family the
5287    /// existing `nome_invalid_diagnostic_carries_offending_name` test
5288    /// pins on this envelope.
5289    ///
5290    /// The `nome: &str` parameter accepts `&str` literals and `&String`
5291    /// (via Deref coercion) so the sole in-crate wire-up threads through
5292    /// the ctor without a pre-conversion; the `reason: String`
5293    /// parameter takes an owned `String` (not `impl Into<String>`)
5294    /// matching the [`crate::render::is_dns_1123_label`] predicate's
5295    /// `Result<(), String>` return shape the sole wire-up site already
5296    /// holds owned at the call site, keeping the routing byte-equal to
5297    /// the pre-lift block. Same owned-`String`-forward `reason` payload
5298    /// discipline as the sibling three-slot family
5299    /// [`dep_nome_axis_reason_ctors!`] on `{ nome, <axis>, reason }`
5300    /// and the four-slot [`DepError::fonte_pin_shape`] on
5301    /// `{ nome, pin, value, reason }`.
5302    ///
5303    /// Every future consumer that raises the same diagnostic outside
5304    /// [`Dep::validate`] — a deferred `caixa-resolver` per-`:deps`
5305    /// re-validator at lacre-resolve time re-checking each declared
5306    /// dep's `:nome` against the same DNS-1123 predicate the apiserver-
5307    /// side schema uses (the `:nome` value flows verbatim as the target
5308    /// caixa's `:nome`, the rendered `lareira-<nome>` Helm chart name
5309    /// segment, the `LABEL_PROGRAM` label value, and the resolver's
5310    /// checkout-directory leaf), a future `feira validate --deps`
5311    /// per-caixa admission verb re-running the shape gate on demand, a
5312    /// per-lacre overlay resolver rejecting an author-supplied dep's
5313    /// `:nome` against a cluster-local snapshot the M4 CR materializer
5314    /// projects, a future authoring-surface widening the field into a
5315    /// `(String, Vec<Suggestion>)` pair carrying a
5316    /// "did-you-mean-<nearest-valid-label>" hint — now reaches this
5317    /// variant through one call rather than re-inlining the four-line
5318    /// struct-literal in lockstep with the one in-crate wire-up site.
5319    #[must_use]
5320    pub fn nome_invalid(nome: &str, reason: String) -> Self {
5321        Self::NomeInvalid {
5322            nome: nome.to_string(),
5323            reason,
5324        }
5325    }
5326}
5327
5328#[allow(clippy::trivially_copy_pass_by_ref)]
5329fn is_false(b: &bool) -> bool {
5330    !*b
5331}
5332
5333#[cfg(test)]
5334mod tests {
5335    use super::*;
5336
5337    #[test]
5338    fn registry_dep_is_minimal() {
5339        let d = Dep::simple("caixa-teia", "^0.1");
5340        assert_eq!(d.nome, "caixa-teia");
5341        assert_eq!(d.versao, "^0.1");
5342        assert!(d.fonte.is_none());
5343        assert!(!d.opcional());
5344        assert!(d.caracteristicas().is_empty());
5345    }
5346
5347    #[test]
5348    fn dep_string_scalar_accessor_pair_is_const_fn() {
5349        // Fail-before-pass-after pin on [`Dep::nome`] +
5350        // [`Dep::versao_requirement`]'s `const`-eval-surface posture.
5351        // Each accessor projects the per-`:deps` / per-`:deps-dev`
5352        // entry's [`String`] storage through the `pub const fn`
5353        // [`String::as_str`] (const-stable since Rust 1.87, well
5354        // within the workspace MSRV) — any future accidental
5355        // downgrade to non-`const` fails the corresponding
5356        // `<name>_via_const_fn` wrapper at caixa-core build time with
5357        // E0015 (`cannot call non-const method`), strictly stronger
5358        // than a runtime `assert!`. Sibling of the peer
5359        // per-M2/M3/universal-axis `String → &str` scalar-accessor
5360        // family pins on the sibling `const`-eval-surface passes
5361        // ([`crate::Caixa::nome`] / [`crate::Caixa::versao`] at the
5362        // top-level manifest, [`crate::CaixaVersion::as_str`] at the
5363        // typed-newtype wrapper, [`crate::aplicacao::Membro::nome`] /
5364        // [`crate::aplicacao::Membro::versao_requirement`] at the M3
5365        // membership axis, [`crate::aplicacao::Entrada::hostname`] /
5366        // [`crate::aplicacao::Entrada::destination`] at the M3
5367        // ingress axis, [`crate::supervisor::ChildSpec::nome`] /
5368        // [`crate::supervisor::ChildSpec::versao_requirement`] at the
5369        // M2 supervisor-tree axis,
5370        // [`crate::upgrade::UpgradeFromEntry::prior_versao`] at the
5371        // M2 upgrade axis, and the per-`:contratos`
5372        // [`crate::aplicacao::WitContract::source`] /
5373        // [`crate::aplicacao::WitContract::destination`] /
5374        // [`crate::aplicacao::WitContract::world_ref`] trio the
5375        // sibling pin at 279823b already anchors).
5376        const fn nome_via_const_fn(d: &Dep) -> &str {
5377            d.nome()
5378        }
5379        const fn versao_via_const_fn(d: &Dep) -> &str {
5380            d.versao_requirement()
5381        }
5382        for (nome, versao) in [
5383            ("caixa-teia", "^0.1"),
5384            ("caixa-mesh", "~0.2.3"),
5385            ("caixa-helm", "*"),
5386        ] {
5387            let d = Dep::simple(nome, versao);
5388            assert_eq!(nome_via_const_fn(&d), d.nome());
5389            assert_eq!(versao_via_const_fn(&d), d.versao_requirement());
5390            assert_eq!(d.nome(), nome);
5391            assert_eq!(d.versao_requirement(), versao);
5392        }
5393    }
5394
5395    #[test]
5396    fn dep_outer_accessor_family_is_const_fn() {
5397        // Fail-before-pass-after pin on [`Dep::fonte`] +
5398        // [`Dep::caracteristicas`]'s `const`-eval-surface posture.
5399        // Each accessor projects the per-`:deps` / per-`:deps-dev`
5400        // entry's composite / list storage through a `pub const fn`
5401        // stdlib method (`Option::<DepSource>::as_ref` /
5402        // `Vec::<String>::as_slice`, both const-stable since Rust
5403        // 1.83, well within the workspace MSRV). Any future
5404        // accidental downgrade to non-`const` fails the corresponding
5405        // `<name>_via_const_fn` wrapper at caixa-core build time with
5406        // E0015 (`cannot call non-const method`), strictly stronger
5407        // than a runtime `assert!` and side-stepping the destructor-
5408        // in-const restriction the `Dep` fixture's `String` /
5409        // `Option<DepSource>` / `Vec<String>` carriers rule out on the
5410        // direct-`const _: () = assert!(...)` residence.
5411        //
5412        // Peer of the sibling per-`Dep` scalar-accessor pair pin
5413        // [`dep_string_scalar_accessor_pair_is_const_fn`] on the same
5414        // outer per-dep-list-entry [`Dep`] altitude — this pin extends
5415        // the `const`-eval-surface discipline onto the composite-
5416        // reference and slice-return arms of the outer-`Dep` accessor
5417        // family, closing the four-slot outer surface (`:nome` +
5418        // `:versao` + `:fonte` + `:caracteristicas`) on the `const`-fn
5419        // posture. The `:opcional` `bool` arm already carries the
5420        // posture through [`Dep::opcional`]'s prior `pub const fn`
5421        // declaration, so this pin lands the last two unlifted
5422        // outer-`Dep` accessors and closes the family.
5423        const fn fonte_via_const_fn(d: &Dep) -> Option<&DepSource> {
5424            d.fonte()
5425        }
5426        const fn caracteristicas_via_const_fn(d: &Dep) -> &[String] {
5427            d.caracteristicas()
5428        }
5429        // `Dep::simple` — no `:fonte`, empty `:caracteristicas`.
5430        let empty = Dep::simple("caixa-teia", "^0.1");
5431        assert!(fonte_via_const_fn(&empty).is_none());
5432        assert_eq!(fonte_via_const_fn(&empty), empty.fonte());
5433        assert!(caracteristicas_via_const_fn(&empty).is_empty());
5434        assert_eq!(
5435            caracteristicas_via_const_fn(&empty),
5436            empty.caracteristicas()
5437        );
5438        // `Dep::git` — `:fonte` is `Some(Git{…})`, `:caracteristicas`
5439        // still empty.
5440        let git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
5441        assert!(fonte_via_const_fn(&git).is_some());
5442        assert_eq!(fonte_via_const_fn(&git), git.fonte());
5443        assert_eq!(caracteristicas_via_const_fn(&git), git.caracteristicas());
5444        // Populated `:caracteristicas` — exercise the non-empty
5445        // slice-view arm to pin the accessor's borrow shape against
5446        // both a `Vec::new()` empty backing buffer and a populated one.
5447        let mut with_features = Dep::simple("caixa-teia", "^0.1");
5448        with_features.caracteristicas = vec!["feat-a".into(), "feat-b".into()];
5449        assert_eq!(caracteristicas_via_const_fn(&with_features).len(), 2);
5450        assert_eq!(
5451            caracteristicas_via_const_fn(&with_features),
5452            with_features.caracteristicas()
5453        );
5454    }
5455
5456    #[test]
5457    fn git_dep_carries_tag() {
5458        let d = Dep::git("t", "*", "github:o/r", "v1");
5459        match d.fonte {
5460            Some(DepSource::Git {
5461                ref repo, ref tag, ..
5462            }) => {
5463                assert_eq!(repo, "github:o/r");
5464                assert_eq!(tag.as_deref(), Some("v1"));
5465            }
5466            _ => panic!("expected Git source"),
5467        }
5468    }
5469
5470    #[test]
5471    fn validate_accepts_simple_dep() {
5472        Dep::simple("caixa-teia", "^0.1").validate().unwrap();
5473    }
5474
5475    #[test]
5476    fn validate_rejects_empty_nome() {
5477        // The fail-before-pass-after pin for `:nome ""`: the empty-name
5478        // arm fires first so the per-entry parse-side diagnostic doesn't
5479        // emit a useless `nome: ""` reference.
5480        let mut d = Dep::simple("placeholder", "^0.1");
5481        d.nome = String::new();
5482        assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
5483    }
5484
5485    #[test]
5486    fn validate_rejects_empty_versao() {
5487        // `parse_requirement("")` returns `Ok(VersionReq::STAR)` (the
5488        // semver crate accepts the empty string as a wildcard match),
5489        // so the empty-`:versao` arm is structurally necessary even
5490        // with the parse arm in place — mirrors `MembroVersaoEmpty` /
5491        // `EmptyChildVersion` ordering on the other two `:versao` axes.
5492        let mut d = Dep::simple("caixa-teia", "ignored");
5493        d.versao = String::new();
5494        let err = d.validate().unwrap_err();
5495        assert!(
5496            matches!(err, DepError::VersaoEmpty { ref nome } if nome == "caixa-teia"),
5497            "got {err:?}"
5498        );
5499    }
5500
5501    // ── value-shape: DNS-1123 label on :deps :nome ────────────────────────
5502
5503    #[test]
5504    fn validate_rejects_nome_with_uppercase() {
5505        // The fail-before-pass-after pin: a non-empty but uppercase
5506        // `:nome` silently passed `validate()` on every pre-gate
5507        // codebase because the prior shape only refused the empty
5508        // string. The DNS-1123 violation surfaced far downstream at
5509        // lacre-resolve time when the *target* caixa's `:nome` failed
5510        // its own gate — far from the `:deps` entry, with a diagnostic
5511        // naming the target rather than the dep entry that referenced
5512        // it. Same fail-before-pass-after fixture pinned for
5513        // `:membros :caixa` (3f9d7a0), `:children :caixa` (31bfa43),
5514        // and Caixa `:nome` (6c992f8).
5515        let d = Dep::simple("Caixa-Teia", "^0.1");
5516        let err = d.validate().unwrap_err();
5517        assert!(
5518            matches!(
5519                err,
5520                DepError::NomeInvalid { ref nome, ref reason }
5521                    if nome == "Caixa-Teia" && reason.contains("uppercase")
5522            ),
5523            "got {err:?}"
5524        );
5525    }
5526
5527    #[test]
5528    fn validate_rejects_nome_with_underscore() {
5529        // RFC 1123 allows `[a-z0-9-]` only; underscore is the canonical
5530        // "I'm thinking of Go module names / Python identifiers" leak.
5531        // Same fixture pinned for the peer caixa-identifier axes.
5532        let d = Dep::simple("caixa_teia", "^0.1");
5533        let err = d.validate().unwrap_err();
5534        assert!(
5535            matches!(
5536                err,
5537                DepError::NomeInvalid { ref nome, ref reason }
5538                    if nome == "caixa_teia" && reason.contains('_')
5539            ),
5540            "got {err:?}"
5541        );
5542    }
5543
5544    #[test]
5545    fn validate_rejects_nome_with_dot() {
5546        // A `:deps :nome` is a single DNS-1123 *label*, not a
5547        // subdomain — dots are rejected. The `"caixa.teia"` shape is
5548        // the canonical "I confused the dep name with the FQDN /
5549        // namespace" footgun, distinct from the legitimate
5550        // `:fonte :repo "github:org/caixa-teia"` axis.
5551        let d = Dep::simple("caixa.teia", "^0.1");
5552        let err = d.validate().unwrap_err();
5553        assert!(
5554            matches!(
5555                err,
5556                DepError::NomeInvalid { ref nome, ref reason }
5557                    if nome == "caixa.teia" && reason.contains('.')
5558            ),
5559            "got {err:?}"
5560        );
5561    }
5562
5563    #[test]
5564    fn validate_rejects_nome_with_leading_hyphen() {
5565        // RFC 1123 requires alphanumeric at both label boundaries.
5566        // Pinned in parity with the peer DNS-1123 fixtures.
5567        let d = Dep::simple("-caixa-teia", "^0.1");
5568        let err = d.validate().unwrap_err();
5569        assert!(
5570            matches!(
5571                err,
5572                DepError::NomeInvalid { ref nome, ref reason }
5573                    if nome == "-caixa-teia" && reason.contains("alphanumeric")
5574            ),
5575            "got {err:?}"
5576        );
5577    }
5578
5579    #[test]
5580    fn validate_rejects_nome_with_trailing_hyphen() {
5581        let d = Dep::simple("caixa-teia-", "^0.1");
5582        let err = d.validate().unwrap_err();
5583        assert!(
5584            matches!(
5585                err,
5586                DepError::NomeInvalid { ref nome, ref reason }
5587                    if nome == "caixa-teia-" && reason.contains("alphanumeric")
5588            ),
5589            "got {err:?}"
5590        );
5591    }
5592
5593    #[test]
5594    fn validate_rejects_nome_with_slash() {
5595        // The canonical "I copied the GitHub repo path into `:nome`
5596        // instead of `:fonte :repo`" typo. A `/` in the name leaks the
5597        // lacre-side `:repositorio` shape (`pleme-io/caixa-teia`) into
5598        // the local-name slot. Same fixture pinned for `:membros
5599        // :caixa` (3f9d7a0).
5600        let d = Dep::simple("pleme-io/caixa-teia", "^0.1");
5601        let err = d.validate().unwrap_err();
5602        assert!(
5603            matches!(
5604                err,
5605                DepError::NomeInvalid { ref nome, ref reason }
5606                    if nome == "pleme-io/caixa-teia" && reason.contains('/')
5607            ),
5608            "got {err:?}"
5609        );
5610    }
5611
5612    #[test]
5613    fn validate_rejects_nome_too_long() {
5614        // 64-byte label — one over the RFC 1035 / RFC 1123 label cap.
5615        // Built from a valid character set so the length-bound
5616        // diagnostic surfaces before any per-character check (the
5617        // order pin parallel to the per-character predicates inside
5618        // [`crate::render::is_dns_1123_label`]).
5619        let long = "a".repeat(64);
5620        let d = Dep::simple(&long, "^0.1");
5621        let err = d.validate().unwrap_err();
5622        assert!(
5623            matches!(
5624                err,
5625                DepError::NomeInvalid { ref nome, ref reason }
5626                    if nome.len() == 64 && reason.contains("max length of 63")
5627            ),
5628            "got {err:?}"
5629        );
5630    }
5631
5632    #[test]
5633    fn validate_accepts_canonical_nome_labels() {
5634        // Positive-control sweep — every form the K8s apiserver
5635        // accepts as a DNS-1123 label must round-trip through
5636        // validate. Covers a hyphen-bearing label, a numeric-suffix
5637        // label, a leading-digit label, a single-character label, and
5638        // a 63-byte (exactly the cap) label — the same fixture set
5639        // the peer `:membros :caixa` / `:children :caixa` positive
5640        // controls pin.
5641        for nome in [
5642            "caixa-teia",
5643            "caixa-resolver2",
5644            "2nd-tier-cache",
5645            "x",
5646            "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0",
5647        ] {
5648            Dep::simple(nome, "^0.1")
5649                .validate()
5650                .unwrap_or_else(|e| panic!("canonical label {nome:?} must validate, got {e:?}"));
5651        }
5652    }
5653
5654    #[test]
5655    fn nome_empty_takes_precedence_over_nome_invalid() {
5656        // Ordering pin: `NomeEmpty` is the more self-locating
5657        // diagnostic on `""` and must lead — `is_dns_1123_label` is
5658        // only reached after the empty-check fires at the call site.
5659        // Mirrors `membro_caixa_empty_takes_precedence_over_invalid`
5660        // (3f9d7a0) on the peer caixa-identifier axis.
5661        let mut d = Dep::simple("placeholder", "^0.1");
5662        d.nome = String::new();
5663        assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
5664    }
5665
5666    #[test]
5667    fn nome_invalid_fires_before_versao_empty() {
5668        // Ordering pin: a malformed `:nome` fires before any `:versao`
5669        // axis check on the *same* entry — the per-entry shape gates
5670        // run top-to-bottom (nome empty → nome shape → versao empty →
5671        // versao parse → fonte shape), so a one-entry caixa.lisp with
5672        // both wrong sees the name-side diagnostic first (the name is
5673        // the self-locating axis — without a valid name, the parse
5674        // diagnostic can't quote `:nome "<bad>"`). Same ordering
5675        // discipline as `membro_caixa_invalid_fires_before_versao_check`
5676        // (3f9d7a0).
5677        let mut d = Dep::simple("Caixa-Teia", "^0.1");
5678        d.versao = String::new();
5679        let err = d.validate().unwrap_err();
5680        assert!(
5681            matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
5682            "got {err:?}"
5683        );
5684    }
5685
5686    #[test]
5687    fn nome_invalid_fires_before_versao_invalid() {
5688        // Ordering pin: a malformed `:nome` fires before the `:versao`
5689        // parse-side check on the *same* entry. Pin separately from
5690        // the empty-versao ordering so a future re-ordering surfaces
5691        // here, parallel to the b0c8389 / c4213a4 trajectory.
5692        let d = Dep::simple("Caixa-Teia", "^^0.1");
5693        let err = d.validate().unwrap_err();
5694        assert!(
5695            matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
5696            "got {err:?}"
5697        );
5698    }
5699
5700    #[test]
5701    fn nome_invalid_fires_before_fonte_invalid() {
5702        // Ordering pin: a malformed `:nome` fires before the `:fonte`
5703        // shape check on the *same* entry. The `:fonte` diagnostic
5704        // names the offending dep's `:nome` verbatim (via
5705        // `DepSource::validate(&self.nome)`), so a non-self-locating
5706        // name would taint the downstream diagnostic too — the gate
5707        // ordering keeps both diagnostics individually self-locating.
5708        let mut d = Dep::simple("Caixa-Teia", "^0.1");
5709        d.fonte = Some(DepSource::Git {
5710            repo: String::new(),
5711            tag: None,
5712            rev: None,
5713            branch: None,
5714        });
5715        let err = d.validate().unwrap_err();
5716        assert!(
5717            matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
5718            "got {err:?}"
5719        );
5720    }
5721
5722    #[test]
5723    fn nome_invalid_diagnostic_carries_offending_name() {
5724        // The diagnostic-shape pin: the error names the offending
5725        // `:nome` value verbatim so the author can grep their
5726        // caixa.lisp without re-running the build, and carries a
5727        // non-empty `reason` from `is_dns_1123_label` so the
5728        // predicate's own wording flows through to the diagnostic.
5729        // Same shape as `MembroCaixaInvalid` (3f9d7a0),
5730        // `ChildCaixaInvalid` (31bfa43), `ManifestError::NomeInvalid`
5731        // (6c992f8) — the four DNS-1123 caixa-identifier axes now
5732        // share a structurally-equivalent diagnostic family.
5733        let d = Dep::simple("Caixa_Teia", "^0.1");
5734        let err = d.validate().unwrap_err();
5735        let DepError::NomeInvalid { nome, reason } = err else {
5736            panic!("expected NomeInvalid, got other variant");
5737        };
5738        assert_eq!(nome, "Caixa_Teia");
5739        assert!(
5740            !reason.is_empty(),
5741            "NomeInvalid `reason` must carry the predicate's wording verbatim"
5742        );
5743    }
5744
5745    #[test]
5746    fn validate_rejects_invalid_versao_requirement() {
5747        // The fail-before-pass-after pin: a non-empty but malformed
5748        // requirement (`"^bad-version"`) silently passed every pre-gate
5749        // codebase because `:deps :versao` wasn't validated. The parse
5750        // failure surfaced far downstream at lacre-resolve time with a
5751        // `semver::Error` that didn't name which `:deps` entry carried
5752        // the typo. The new gate moves the check to caixa-build time
5753        // at the source caixa.lisp.
5754        let d = Dep::simple("caixa-teia", "^bad-version");
5755        let err = d.validate().unwrap_err();
5756        assert!(
5757            matches!(
5758                err,
5759                DepError::VersaoInvalid { ref nome, ref versao, .. }
5760                    if nome == "caixa-teia" && versao == "^bad-version"
5761            ),
5762            "got {err:?}"
5763        );
5764    }
5765
5766    #[test]
5767    fn validate_rejects_versao_with_double_caret_typo() {
5768        // `"^^0.1"` is the canonical doubled-caret typo — looks like a
5769        // Cargo-shaped requirement on first glance but fails the parser
5770        // because semver doesn't accept stacked operators. Pin this
5771        // adjacent-shape footgun explicitly so a future relaxation that
5772        // accepts "looks-canonical-but-isn't" forms surfaces here, in
5773        // parity with the `:membros` / `:children` fixtures.
5774        let d = Dep::simple("caixa-teia", "^^0.1");
5775        let err = d.validate().unwrap_err();
5776        assert!(
5777            matches!(
5778                err,
5779                DepError::VersaoInvalid { ref nome, ref versao, .. }
5780                    if nome == "caixa-teia" && versao == "^^0.1"
5781            ),
5782            "got {err:?}"
5783        );
5784    }
5785
5786    #[test]
5787    fn validate_rejects_versao_with_v_prefixed_tag() {
5788        // `"v0.1"` is the canonical "git-tag-shape leaking into the
5789        // semver requirement slot" typo — an author copies the
5790        // publish-side git-tag string verbatim into `:versao`, but
5791        // Cargo's semver parser rejects the leading `v`. Same fixture
5792        // pinned for `:membros :versao` (9888b13) and `:children
5793        // :versao` (b38ff3a). (Bare `x`-glob shorthands like `^0.1.x`
5794        // are *accepted* by the semver crate as an `*` wildcard on the
5795        // patch axis — they're a Cargo-side valid shape, not a typo.)
5796        let d = Dep::simple("caixa-teia", "v0.1");
5797        let err = d.validate().unwrap_err();
5798        assert!(
5799            matches!(
5800                err,
5801                DepError::VersaoInvalid { ref nome, ref versao, .. }
5802                    if nome == "caixa-teia" && versao == "v0.1"
5803            ),
5804            "got {err:?}"
5805        );
5806    }
5807
5808    #[test]
5809    fn validate_accepts_canonical_versao_forms() {
5810        // The five Cargo-shaped requirement forms `:membros :versao`
5811        // and `:children :versao` already accept via
5812        // `crate::parse_requirement` must pass the deps gate without
5813        // re-validating at the resolver layer. Pin every leg so a
5814        // future tightening of the canonical set surfaces here as a
5815        // test failure.
5816        for form in [
5817            "^0.1",      // caret — minor-range pin (the most common shape)
5818            "~0.1.2",    // tilde — patch-range pin
5819            "0.1.0",     // exact — single-version pin
5820            "*",         // wildcard — explicitly any-version
5821            ">=0.1, <2", // multi-range — comma-separated comparators
5822        ] {
5823            Dep::simple("caixa-teia", form)
5824                .validate()
5825                .unwrap_or_else(|e| panic!("canonical form {form:?} must validate, got {e:?}"));
5826        }
5827    }
5828
5829    #[test]
5830    fn versao_empty_takes_precedence_over_invalid() {
5831        // Order pin: the existing `VersaoEmpty` diagnostic (which
5832        // doesn't try to parse) fires before the new `VersaoInvalid`
5833        // parse-side diagnostic, so an empty `:versao` keeps its
5834        // narrower error message — `parse_requirement("")` would
5835        // otherwise return `Ok(STAR)` and silently pass, but the empty
5836        // arm catches it first.
5837        let mut d = Dep::simple("caixa-teia", "ignored");
5838        d.versao = String::new();
5839        let err = d.validate().unwrap_err();
5840        assert!(
5841            matches!(err, DepError::VersaoEmpty { ref nome } if nome == "caixa-teia"),
5842            "got {err:?}"
5843        );
5844    }
5845
5846    #[test]
5847    fn nome_empty_takes_precedence_over_versao_invalid() {
5848        // Order pin: even when `:versao` is malformed and would raise
5849        // its own diagnostic, `:nome ""` fires first because the
5850        // per-entry parse diagnostic needs a non-empty name to be
5851        // self-locating. Mirrors the
5852        // `membros_validation_runs_before_contratos_membership_check`
5853        // ordering on the typed-graph layer.
5854        let mut d = Dep::simple("placeholder", "^bad");
5855        d.nome = String::new();
5856        let err = d.validate().unwrap_err();
5857        assert_eq!(err, DepError::NomeEmpty);
5858    }
5859
5860    #[test]
5861    fn versao_invalid_diagnostic_carries_offending_versao() {
5862        // The diagnostic-shape pin: the error names the offending
5863        // `:versao` value verbatim so the author can grep their
5864        // caixa.lisp without re-running the build, and carries a
5865        // non-empty `reason` from `semver::VersionReq::parse` so the
5866        // parser's own wording flows through to the diagnostic.
5867        let d = Dep::simple("caixa-teia", "not-a-req");
5868        let err = d.validate().unwrap_err();
5869        let DepError::VersaoInvalid {
5870            nome,
5871            versao,
5872            reason,
5873        } = err
5874        else {
5875            panic!("expected VersaoInvalid, got other variant");
5876        };
5877        assert_eq!(nome, "caixa-teia");
5878        assert_eq!(versao, "not-a-req");
5879        assert!(
5880            !reason.is_empty(),
5881            "VersaoInvalid `reason` must carry the parser's wording verbatim"
5882        );
5883    }
5884
5885    // -- :fonte value-shape gate ------------------------------------------
5886
5887    fn dep_with_fonte(fonte: DepSource) -> Dep {
5888        let mut d = Dep::simple("caixa-teia", "^0.1");
5889        d.fonte = Some(fonte);
5890        d
5891    }
5892
5893    #[test]
5894    fn validate_accepts_git_fonte_with_tag() {
5895        // The positive-control pin on the canonical git source — exactly
5896        // one of :tag/:rev/:branch set, non-empty :repo. Mirrors the
5897        // shape every existing caixa-resolver integration test uses.
5898        let d = dep_with_fonte(DepSource::Git {
5899            repo: "github:pleme-io/caixa-teia".into(),
5900            tag: Some("v0.1.0".into()),
5901            rev: None,
5902            branch: None,
5903        });
5904        d.validate().unwrap();
5905    }
5906
5907    #[test]
5908    fn validate_accepts_git_fonte_with_rev() {
5909        // Each of the three pin axes is independently a valid single-pin
5910        // shape; pin the :rev arm so a future relaxation that only
5911        // accepts :tag surfaces here. The value is a full 40-hex SHA-1
5912        // OID — the canonical `git rev-parse HEAD` emission shape the
5913        // `crate::render::is_git_oid` value-shape gate now requires;
5914        // abbreviated OIDs are ambiguous across repo history and
5915        // rejected at this gate (pinned separately by
5916        // `validate_rejects_git_fonte_with_rev_abbreviated_prefix`).
5917        let d = dep_with_fonte(DepSource::Git {
5918            repo: "github:pleme-io/caixa-teia".into(),
5919            tag: None,
5920            rev: Some("c0ffee0123abcdef0123456789abcdef01234567".into()),
5921            branch: None,
5922        });
5923        d.validate().unwrap();
5924    }
5925
5926    #[test]
5927    fn validate_accepts_git_fonte_with_branch() {
5928        // The :branch arm is the third valid single-pin shape — pinned
5929        // separately so the gate-accepts-all-three-pin-axes contract is
5930        // a build-error to relax.
5931        let d = dep_with_fonte(DepSource::Git {
5932            repo: "github:pleme-io/caixa-teia".into(),
5933            tag: None,
5934            rev: None,
5935            branch: Some("main".into()),
5936        });
5937        d.validate().unwrap();
5938    }
5939
5940    #[test]
5941    fn validate_accepts_path_fonte() {
5942        // The positive-control pin on the path source — non-empty
5943        // :caminho, no pin axes (paths have no commit identity). Pinned
5944        // so a future "paths must also pin a rev" tightening surfaces
5945        // here as a structural decision, not a silent break.
5946        let d = dep_with_fonte(DepSource::Path {
5947            caminho: "../caixa-teia".into(),
5948        });
5949        d.validate().unwrap();
5950    }
5951
5952    #[test]
5953    fn validate_rejects_git_fonte_with_empty_repo() {
5954        // The fail-before-pass-after pin for `(:tipo git :repo "" :tag
5955        // "v1")`: the empty-repo shape silently passed every pre-gate
5956        // codebase because `:fonte` wasn't validated. The git-clone
5957        // failure surfaced far downstream at lacre-resolve time with no
5958        // field naming which `:deps` entry carried the typo. The new
5959        // gate moves the check to caixa-build time at the source
5960        // caixa.lisp.
5961        let d = dep_with_fonte(DepSource::Git {
5962            repo: String::new(),
5963            tag: Some("v0.1.0".into()),
5964            rev: None,
5965            branch: None,
5966        });
5967        let err = d.validate().unwrap_err();
5968        assert!(
5969            matches!(err, DepError::FonteRepoEmpty { ref nome } if nome == "caixa-teia"),
5970            "got {err:?}"
5971        );
5972    }
5973
5974    // -- :repo value-shape gate -------------------------------------------
5975    //
5976    // The `:fonte (:tipo git :repo …)` value flows verbatim into the
5977    // caixa-resolver's `git clone <repo>` subprocess. The pre-gate
5978    // codebase admitted any non-empty string; the new
5979    // [`crate::render::is_git_repo_url`] predicate gates the git-porcelain
5980    // URL intersection-floor at validate time, peer with the three pin
5981    // axes (`:tag` + `:branch` via `is_git_ref_name`, `:rev` via
5982    // `is_git_oid`). Every test in this section is a fail-before /
5983    // pass-after pin on a specific authoring footgun.
5984
5985    #[test]
5986    fn validate_rejects_git_fonte_with_repo_carrying_trailing_space() {
5987        // The canonical paste-from-doc footgun on `:repo` — an author
5988        // copies `"github:pleme-io/caixa-teia "` (trailing space) out of
5989        // a doc paragraph. Until this gate landed the empty-repo arm
5990        // passed (the string isn't empty), the resolver issued
5991        // `git clone 'github:pleme-io/caixa-teia '`, and the failure
5992        // surfaced at clone time with a quoting-confused error far from
5993        // the source caixa.lisp. Same paste-from-doc footgun the
5994        // `:tag "v0.1.0 "` gate (e70d213) closes on the peer refname
5995        // axis — now closed on the `:repo` URL axis too.
5996        let d = dep_with_fonte(DepSource::Git {
5997            repo: "github:pleme-io/caixa-teia ".into(),
5998            tag: Some("v0.1.0".into()),
5999            rev: None,
6000            branch: None,
6001        });
6002        let err = d.validate().unwrap_err();
6003        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6004            panic!("expected FonteRepoShape, got other variant");
6005        };
6006        assert_eq!(nome, "caixa-teia");
6007        assert_eq!(repo, "github:pleme-io/caixa-teia ");
6008        assert!(
6009            reason.contains("whitespace"),
6010            "reason must surface the whitespace arm, got {reason:?}"
6011        );
6012    }
6013
6014    #[test]
6015    fn validate_rejects_git_fonte_with_repo_starting_with_dash() {
6016        // The canonical CLI-argument-injection footgun at the `git clone`
6017        // subprocess boundary — `:repo "-upload-pack=evil"` makes git's
6018        // argv parser read the value as a CLI flag, escaping the
6019        // subprocess argument boundary. The `--` separator workaround
6020        // does not fix the typed slot's accepted set; the gate rejects
6021        // the shape upstream at validate time so the resolver never
6022        // invokes a `git clone -…` subprocess.
6023        let d = dep_with_fonte(DepSource::Git {
6024            repo: "-upload-pack=evil".into(),
6025            tag: Some("v0.1.0".into()),
6026            rev: None,
6027            branch: None,
6028        });
6029        let err = d.validate().unwrap_err();
6030        let DepError::FonteRepoShape { repo, reason, .. } = err else {
6031            panic!("expected FonteRepoShape, got other variant");
6032        };
6033        assert_eq!(repo, "-upload-pack=evil");
6034        assert!(
6035            reason.contains("must not start with `-`"),
6036            "reason must surface the leading-`-` arm, got {reason:?}"
6037        );
6038    }
6039
6040    #[test]
6041    fn validate_rejects_git_fonte_with_repo_carrying_embedded_newline() {
6042        // The canonical paste-from-multiline-doc footgun — a `:repo`
6043        // string with an embedded `\n` silently breaks git's URL parser
6044        // and is a class of CRLF-injection at the subprocess-argument
6045        // boundary. Caught by the control-char arm (0x0A < 0x20).
6046        let d = dep_with_fonte(DepSource::Git {
6047            repo: "github:pleme-io/caixa-teia\nrm -rf /".into(),
6048            tag: Some("v0.1.0".into()),
6049            rev: None,
6050            branch: None,
6051        });
6052        let err = d.validate().unwrap_err();
6053        let DepError::FonteRepoShape { reason, .. } = err else {
6054            panic!("expected FonteRepoShape, got other variant");
6055        };
6056        assert!(
6057            reason.contains("control character"),
6058            "reason must surface the control-char arm, got {reason:?}"
6059        );
6060    }
6061
6062    #[test]
6063    fn validate_rejects_git_fonte_with_repo_carrying_tab() {
6064        // Tab is the sibling whitespace footgun (the canonical
6065        // copy-from-aligned-table paste); pinned separately from the
6066        // space arm so a future relaxation that only catches one
6067        // surfaces here.
6068        let d = dep_with_fonte(DepSource::Git {
6069            repo: "github:pleme-io/caixa-teia\t".into(),
6070            tag: Some("v0.1.0".into()),
6071            rev: None,
6072            branch: None,
6073        });
6074        let err = d.validate().unwrap_err();
6075        assert!(
6076            matches!(
6077                err,
6078                DepError::FonteRepoShape { ref reason, .. }
6079                    if reason.contains("whitespace")
6080            ),
6081            "got {err:?}"
6082        );
6083    }
6084
6085    #[test]
6086    fn validate_rejects_git_fonte_with_repo_carrying_non_ascii() {
6087        // IDN hosts must be pre-encoded as Punycode (`xn--…`) — raw
6088        // non-ASCII silently breaks at git's URL parser and round-trips
6089        // inconsistently across NFC/NFD normalization on APFS /
6090        // case-folding filesystems. Same intersection-floor
6091        // [`is_git_ref_name`] enforces on the refname axes.
6092        let d = dep_with_fonte(DepSource::Git {
6093            repo: "https://github.com/pleme-io/café".into(),
6094            tag: Some("v0.1.0".into()),
6095            rev: None,
6096            branch: None,
6097        });
6098        let err = d.validate().unwrap_err();
6099        assert!(
6100            matches!(
6101                err,
6102                DepError::FonteRepoShape { ref reason, .. }
6103                    if reason.contains("non-ASCII")
6104            ),
6105            "got {err:?}"
6106        );
6107    }
6108
6109    #[test]
6110    fn validate_rejects_git_fonte_with_repo_carrying_fragment_anchor() {
6111        // The fail-before-pass-after pin for the canonical paste-from-
6112        // browser-address-bar footgun on `:repo`: an author copies a
6113        // GitHub permalink to a README anchor / line-permalink and
6114        // forgets to trim the `#fragment` tail. Until this arm landed
6115        // `:repo "https://github.com/pleme-io/caixa-teia#readme"`
6116        // silently passed every prior arm (no whitespace, no control
6117        // chars, no non-ASCII, contains a `:`, doesn't start with `-`
6118        // or `:`), libcurl's URL parser stripped the `#readme` tail
6119        // before opening the HTTPS transport, and the lacre embedded
6120        // the value verbatim in its per-dep BLAKE3 closure — two
6121        // authors whose values differ only in their fragment anchor
6122        // (`#readme` vs `#L42`) resolve to the byte-identical upstream
6123        // `git clone` but lock to two distinct lacres, defeating the
6124        // THEORY.md §V.2 render-determinism contract. Same value-shape
6125        // axis-floor every peer typed surface enforces; peer `:fonte
6126        // :tag` / `:fonte :branch` already reject the byte-class through
6127        // `is_git_ref_name`'s alphabet (refs are leaf identifiers, no
6128        // URL grammar admitted) and `:entrada :paths` rejects `#` as
6129        // part of `is_gateway_api_http_path`'s RFC-3986-reserved set.
6130        let d = dep_with_fonte(DepSource::Git {
6131            repo: "https://github.com/pleme-io/caixa-teia#readme".into(),
6132            tag: Some("v0.1.0".into()),
6133            rev: None,
6134            branch: None,
6135        });
6136        let err = d.validate().unwrap_err();
6137        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6138            panic!("expected FonteRepoShape, got other variant");
6139        };
6140        assert_eq!(nome, "caixa-teia");
6141        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia#readme");
6142        assert!(
6143            reason.contains("must not contain `#`"),
6144            "reason must surface the fragment-`#` arm, got {reason:?}"
6145        );
6146        assert!(
6147            reason.contains("fragment"),
6148            "reason must name the URL fragment grammar, got {reason:?}"
6149        );
6150    }
6151
6152    #[test]
6153    fn validate_rejects_git_fonte_with_repo_carrying_flake_ref_fragment() {
6154        // The symmetric paste-from-Nix-flake-ref footgun — an author
6155        // confuses the Nix flake-reference idiom (`github:foo/
6156        // bar#packageName`, where `#packageName` selects a flake
6157        // output) with the bare git `:repo` shape. The pleme-io
6158        // substrate authors compose flakes downstream of caixa
6159        // (caixa-flake renders a flake.nix), so the cross-idiom leak
6160        // is the canonical near-miss: the author writes the
6161        // flake-ref shape into a git `:repo` slot. Pinned separately
6162        // from the HTTPS-anchor arm so a future relaxation that
6163        // narrows to one URL scheme surfaces here.
6164        let d = dep_with_fonte(DepSource::Git {
6165            repo: "github:pleme-io/caixa-teia#caixa-teia".into(),
6166            tag: Some("v0.1.0".into()),
6167            rev: None,
6168            branch: None,
6169        });
6170        let err = d.validate().unwrap_err();
6171        let DepError::FonteRepoShape { reason, .. } = err else {
6172            panic!("expected FonteRepoShape, got other variant");
6173        };
6174        assert!(
6175            reason.contains("must not contain `#`"),
6176            "reason must surface the fragment-`#` arm, got {reason:?}"
6177        );
6178        assert!(
6179            reason.contains("Nix flake"),
6180            "reason must name the Nix-flake-ref cross-idiom footgun, got {reason:?}"
6181        );
6182    }
6183
6184    #[test]
6185    fn validate_rejects_git_fonte_with_repo_carrying_query_string() {
6186        // The fail-before-pass-after pin for the canonical paste-from-
6187        // browser-address-bar footgun on `:repo` (peer with the
6188        // a68f818 fragment-`#` arm on the same axis). An author
6189        // copies a GitHub tab deep-link out of the address bar and
6190        // forgets to trim the `?tab=…` query tail. Until this arm
6191        // landed `:repo "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file"`
6192        // silently passed every prior arm (no whitespace, no control
6193        // chars, no non-ASCII, no `#` fragment, contains a `:`,
6194        // doesn't start with `-` or `:`); GitHub silently ignored
6195        // the `?query` tail and served the same repo regardless;
6196        // the lacre embedded the value verbatim in its per-dep
6197        // BLAKE3 closure — two authors whose values differ only in
6198        // their query tail (`?tab=readme-ov-file` vs `?ref=main` vs
6199        // `?utm_source=twitter`) resolve to the byte-identical
6200        // upstream `git clone` but lock to two distinct lacres,
6201        // defeating the THEORY.md §V.2 render-determinism contract
6202        // on the same axis the `#` fragment arm closes. Same value-
6203        // shape axis-floor every peer typed surface enforces; peer
6204        // `:fonte :tag` / `:fonte :branch` already reject the byte-
6205        // class through `is_git_ref_name`'s alphabet (refspec glob
6206        // wildcards, caixa-core/src/render.rs:1426) and `:entrada
6207        // :paths` rejects `?` as the query separator in
6208        // `is_gateway_api_http_path` (caixa-core/src/render.rs:473).
6209        let d = dep_with_fonte(DepSource::Git {
6210            repo: "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file".into(),
6211            tag: Some("v0.1.0".into()),
6212            rev: None,
6213            branch: None,
6214        });
6215        let err = d.validate().unwrap_err();
6216        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6217            panic!("expected FonteRepoShape, got other variant");
6218        };
6219        assert_eq!(nome, "caixa-teia");
6220        assert_eq!(
6221            repo,
6222            "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file"
6223        );
6224        assert!(
6225            reason.contains("must not contain `?`"),
6226            "reason must surface the query-`?` arm, got {reason:?}"
6227        );
6228        assert!(
6229            reason.contains("query"),
6230            "reason must name the URL query grammar, got {reason:?}"
6231        );
6232    }
6233
6234    #[test]
6235    fn validate_rejects_git_fonte_with_repo_carrying_utm_tracker() {
6236        // The symmetric paste-from-social-share footgun — an author
6237        // copies a repo URL out of a Slack unfurl / Twitter share /
6238        // newsletter link / Discord embed and forgets to trim the
6239        // `?utm_source=…` / `?utm_medium=…` / `?utm_campaign=…`
6240        // campaign-tracker tail. Every major social-share / unfurl /
6241        // newsletter platform appends these UTM parameters; the
6242        // canonical near-miss on the `:repo` axis. Pinned separately
6243        // from the GitHub-tab-deep-link arm so a future relaxation
6244        // that narrows to one query-parameter class surfaces here.
6245        let d = dep_with_fonte(DepSource::Git {
6246            repo: "https://github.com/pleme-io/caixa-teia?utm_source=twitter&utm_campaign=launch"
6247                .into(),
6248            tag: Some("v0.1.0".into()),
6249            rev: None,
6250            branch: None,
6251        });
6252        let err = d.validate().unwrap_err();
6253        let DepError::FonteRepoShape { reason, .. } = err else {
6254            panic!("expected FonteRepoShape, got other variant");
6255        };
6256        assert!(
6257            reason.contains("must not contain `?`"),
6258            "reason must surface the query-`?` arm, got {reason:?}"
6259        );
6260        assert!(
6261            reason.contains("campaign-tracker"),
6262            "reason must name the campaign-tracker paste footgun, got {reason:?}"
6263        );
6264    }
6265
6266    #[test]
6267    fn fonte_repo_fragment_fires_before_query_when_fragment_first() {
6268        // Cascade pin: the fragment-`#` arm and the query-`?` arm are
6269        // both per-byte arms inside the same `for &b in s.as_bytes()`
6270        // loop, so the byte that appears first in the value's byte
6271        // order wins. A `:repo "https://github.com/p/x#readme?ref=main"`
6272        // (fragment before query — unusual URL-grammar but value-
6273        // disjoint at byte level) carries both `#` and `?`; the `#`
6274        // byte appears first, so the fragment-`#` arm fires, surfacing
6275        // the more self-locating diagnostic on the byte the author
6276        // pasted earliest in the URL. Mirrors the peer cascade
6277        // discipline `fonte_repo_control_char_fires_before_fragment`
6278        // pins on the prior `:repo` byte-class arm.
6279        let d = dep_with_fonte(DepSource::Git {
6280            repo: "https://github.com/pleme-io/caixa-teia#readme?ref=main".into(),
6281            tag: Some("v0.1.0".into()),
6282            rev: None,
6283            branch: None,
6284        });
6285        let err = d.validate().unwrap_err();
6286        let DepError::FonteRepoShape { reason, .. } = err else {
6287            panic!("expected FonteRepoShape, got other variant");
6288        };
6289        assert!(
6290            reason.contains("must not contain `#`"),
6291            "reason must surface the fragment-`#` arm (fires before query-`?` when \
6292             `#` byte appears first in value), got {reason:?}"
6293        );
6294    }
6295
6296    #[test]
6297    fn fonte_repo_control_char_fires_before_fragment() {
6298        // Cascade pin: the control-char arm structurally precedes the
6299        // fragment-`#` arm. A value like `"github:p/x\n#readme"` probes
6300        // positive on both arms (contains LF and `#`), but the narrower
6301        // POSIX-syscall-rejected / CRLF-injection-class diagnostic
6302        // (`control character`) wins so the author sees the more
6303        // self-locating arm first. Mirrors the peer cascade discipline
6304        // every prior `:repo` byte-class arm establishes.
6305        let d = dep_with_fonte(DepSource::Git {
6306            repo: "github:pleme-io/caixa-teia\n#readme".into(),
6307            tag: Some("v0.1.0".into()),
6308            rev: None,
6309            branch: None,
6310        });
6311        let err = d.validate().unwrap_err();
6312        let DepError::FonteRepoShape { reason, .. } = err else {
6313            panic!("expected FonteRepoShape, got other variant");
6314        };
6315        assert!(
6316            reason.contains("control character"),
6317            "reason must surface the control-char arm, got {reason:?}"
6318        );
6319    }
6320
6321    #[test]
6322    fn validate_rejects_git_fonte_with_repo_carrying_embedded_backslash() {
6323        // The fail-before-pass-after pin for the canonical Windows-
6324        // file-path-confusion footgun on `:repo` (peer with the 3a4e1d7
6325        // backslash arm on the sibling `:caminho` path-fonte axis).
6326        // An author pastes a Windows Explorer address-bar / PowerShell
6327        // `Get-Location` output into a `file://` URL slot, producing
6328        // `file:///C:\Users\me\caixa-teia`. Until this arm landed the
6329        // value silently passed every prior arm (no whitespace, no
6330        // control chars, no non-ASCII, no `#`, no `?`, doesn't start
6331        // with `-` or `:`); libcurl's URL parser silently translates
6332        // `\` → `/` on some platforms and refuses it on others, so
6333        // the byte rides verbatim into the lacre's per-dep content-
6334        // address but is silently rewritten / rejected at the wire —
6335        // two authors whose `:repo` values differ only in backslash-
6336        // vs-forward-slash (`file:///C:\path` vs `file:///C:/path`)
6337        // resolve to the byte-identical local clone but lock to two
6338        // distinct BLAKE3 closures, defeating the THEORY.md §V.2
6339        // render-determinism contract on the same axis the `#`
6340        // fragment and `?` query arms close. Same value-shape axis-
6341        // floor every peer typed surface enforces; the `:caminho`
6342        // 3a4e1d7 arm closes the same byte on the path-fonte axis.
6343        let d = dep_with_fonte(DepSource::Git {
6344            repo: "file:///C:\\Users\\me\\caixa-teia".into(),
6345            tag: Some("v0.1.0".into()),
6346            rev: None,
6347            branch: None,
6348        });
6349        let err = d.validate().unwrap_err();
6350        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6351            panic!("expected FonteRepoShape, got other variant");
6352        };
6353        assert_eq!(nome, "caixa-teia");
6354        assert_eq!(repo, "file:///C:\\Users\\me\\caixa-teia");
6355        assert!(
6356            reason.contains("must not contain `\\`"),
6357            "reason must surface the backslash-`\\` arm, got {reason:?}"
6358        );
6359        assert!(
6360            reason.contains("Windows"),
6361            "reason must name the Windows-path-confusion footgun, got {reason:?}"
6362        );
6363    }
6364
6365    #[test]
6366    fn validate_rejects_git_fonte_with_repo_carrying_mangled_https_backslashes() {
6367        // The symmetric Win32-shell-mangled-slashes footgun — an author
6368        // copies `https://github.com/foo/bar` into a Win32 shell that
6369        // rewrites every `/` to `\` (the canonical `cmd.exe` path-
6370        // separator-coercion bug), pastes the result into a `:repo`
6371        // slot, and produces `https:\\github.com\foo\bar`. Pinned
6372        // separately from the `file://` Explorer-paste arm so a future
6373        // relaxation that narrows to one URL scheme surfaces here.
6374        let d = dep_with_fonte(DepSource::Git {
6375            repo: "https:\\\\github.com\\pleme-io\\caixa-teia".into(),
6376            tag: Some("v0.1.0".into()),
6377            rev: None,
6378            branch: None,
6379        });
6380        let err = d.validate().unwrap_err();
6381        let DepError::FonteRepoShape { reason, .. } = err else {
6382            panic!("expected FonteRepoShape, got other variant");
6383        };
6384        assert!(
6385            reason.contains("must not contain `\\`"),
6386            "reason must surface the backslash-`\\` arm, got {reason:?}"
6387        );
6388        assert!(
6389            reason.contains("path separator") || reason.contains("path-segment separator"),
6390            "reason must name the URL path-segment separator grammar, got {reason:?}"
6391        );
6392    }
6393
6394    #[test]
6395    fn fonte_repo_fragment_fires_before_backslash_when_fragment_first() {
6396        // Cascade pin: the fragment-`#` arm and the backslash-`\` arm
6397        // are both per-byte arms inside the same `for &b in s.as_bytes()`
6398        // loop, so the byte that appears first in the value's byte order
6399        // wins. A `:repo "https://github.com/p/x#readme\\foo"` carries
6400        // both `#` and `\`; the `#` byte appears first, so the fragment-
6401        // `#` arm fires, surfacing the more self-locating diagnostic on
6402        // the byte the author pasted earliest in the URL. Mirrors the
6403        // peer cascade discipline `fonte_repo_fragment_fires_before_query_when_fragment_first`
6404        // pins on the prior `:repo` byte-class arm.
6405        let d = dep_with_fonte(DepSource::Git {
6406            repo: "https://github.com/pleme-io/caixa-teia#readme\\foo".into(),
6407            tag: Some("v0.1.0".into()),
6408            rev: None,
6409            branch: None,
6410        });
6411        let err = d.validate().unwrap_err();
6412        let DepError::FonteRepoShape { reason, .. } = err else {
6413            panic!("expected FonteRepoShape, got other variant");
6414        };
6415        assert!(
6416            reason.contains("must not contain `#`"),
6417            "reason must surface the fragment-`#` arm (fires before backslash-`\\` when \
6418             `#` byte appears first in value), got {reason:?}"
6419        );
6420    }
6421
6422    #[test]
6423    fn validate_rejects_git_fonte_with_repo_carrying_uri_template_placeholder() {
6424        // The fail-before-pass-after pin for the canonical URI Template
6425        // (RFC 6570) placeholder footgun on `:repo`. An author copies a
6426        // README quick-start snippet / OpenAPI `servers:` URL / Helm
6427        // chart `home:` template that carries unresolved
6428        // `{org}` / `{repo}` placeholders and pastes the raw template
6429        // into the `:repo` slot, expecting the substrate to resolve the
6430        // placeholder downstream. Until this arm landed the value
6431        // silently passed every prior arm (no whitespace, no control
6432        // chars, no non-ASCII, no `#`, no `?`, no `\`, doesn't start
6433        // with `-` or `:`); libcurl percent-encodes `{` / `}` to `%7B`
6434        // / `%7D` on the wire, so the byte rides verbatim into the
6435        // lacre's per-dep content-address but round-trips inconsistently
6436        // between the lacre's per-dep content-address and the
6437        // resolver's `git clone <repo>` invocation, defeating the
6438        // THEORY.md §V.2 render-determinism contract on the same axis
6439        // the `#` fragment, `?` query, and `\` backslash arms close;
6440        // every git porcelain entry-point additionally fetches a
6441        // nonexistent literal-`{placeholder}`-named path far from the
6442        // source caixa.lisp.
6443        let d = dep_with_fonte(DepSource::Git {
6444            repo: "https://github.com/{org}/caixa-teia".into(),
6445            tag: Some("v0.1.0".into()),
6446            rev: None,
6447            branch: None,
6448        });
6449        let err = d.validate().unwrap_err();
6450        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6451            panic!("expected FonteRepoShape, got other variant");
6452        };
6453        assert_eq!(nome, "caixa-teia");
6454        assert_eq!(repo, "https://github.com/{org}/caixa-teia");
6455        assert!(
6456            reason.contains("must not contain `{`"),
6457            "reason must surface the open-brace `{{` arm, got {reason:?}"
6458        );
6459        assert!(
6460            reason.contains("URI Template") || reason.contains("RFC 6570"),
6461            "reason must name the RFC 6570 URI Template grammar, got {reason:?}"
6462        );
6463    }
6464
6465    #[test]
6466    fn validate_rejects_git_fonte_with_repo_carrying_handlebars_doubled_brace() {
6467        // The symmetric Mustache / Handlebars doubled-brace
6468        // substitution-form footgun every CI / IaC templating engine
6469        // (Argo Workflows, Jinja2, Liquid, Vue / Angular interpolation,
6470        // GitHub Actions `${{ … }}` even though Actions uses `${{`) /
6471        // chart README quick-start snippet emits. Pinned separately
6472        // from the single-`{` `{org}` arm so a future relaxation that
6473        // narrows to one substitution-form surfaces here.
6474        let d = dep_with_fonte(DepSource::Git {
6475            repo: "https://github.com/{{org}}/caixa-teia".into(),
6476            tag: Some("v0.1.0".into()),
6477            rev: None,
6478            branch: None,
6479        });
6480        let err = d.validate().unwrap_err();
6481        let DepError::FonteRepoShape { reason, .. } = err else {
6482            panic!("expected FonteRepoShape, got other variant");
6483        };
6484        assert!(
6485            reason.contains("must not contain `{`"),
6486            "reason must surface the open-brace `{{` arm, got {reason:?}"
6487        );
6488    }
6489
6490    #[test]
6491    fn validate_rejects_git_fonte_with_repo_carrying_closing_brace_only() {
6492        // Asymmetric `}`-only shape — covers the closing-brace-by-
6493        // itself footgun (an author truncated `{org}/{repo}` mid-edit
6494        // and left a trailing `}` from the prior template fragment,
6495        // or pasted a value that included a closing brace from a
6496        // surrounding shell context). Pinned to ensure the predicate
6497        // refuses each brace independently rather than only when both
6498        // appear — a future regression that ANDs the two byte tests
6499        // surfaces here.
6500        let d = dep_with_fonte(DepSource::Git {
6501            repo: "https://github.com/pleme-io/caixa-teia}".into(),
6502            tag: Some("v0.1.0".into()),
6503            rev: None,
6504            branch: None,
6505        });
6506        let err = d.validate().unwrap_err();
6507        let DepError::FonteRepoShape { reason, .. } = err else {
6508            panic!("expected FonteRepoShape, got other variant");
6509        };
6510        assert!(
6511            reason.contains("must not contain `}`"),
6512            "reason must surface the close-brace `}}` arm, got {reason:?}"
6513        );
6514    }
6515
6516    #[test]
6517    fn fonte_repo_fragment_fires_before_template_placeholder_when_fragment_first() {
6518        // Cascade pin: the fragment-`#` arm and the template-`{` /
6519        // `}` arm are both per-byte arms inside the same
6520        // `for &b in s.as_bytes()` loop, so the byte that appears
6521        // first in the value's byte order wins. A `:repo
6522        // "https://github.com/p/x#readme{org}"` carries both `#` and
6523        // `{`; the `#` byte appears first, so the fragment-`#` arm
6524        // fires, surfacing the more self-locating diagnostic on the
6525        // byte the author pasted earliest in the URL. Mirrors the
6526        // peer cascade discipline `fonte_repo_fragment_fires_before_backslash_when_fragment_first`
6527        // pins on the prior `:repo` byte-class arm.
6528        let d = dep_with_fonte(DepSource::Git {
6529            repo: "https://github.com/pleme-io/caixa-teia#readme{org}".into(),
6530            tag: Some("v0.1.0".into()),
6531            rev: None,
6532            branch: None,
6533        });
6534        let err = d.validate().unwrap_err();
6535        let DepError::FonteRepoShape { reason, .. } = err else {
6536            panic!("expected FonteRepoShape, got other variant");
6537        };
6538        assert!(
6539            reason.contains("must not contain `#`"),
6540            "reason must surface the fragment-`#` arm (fires before template-`{{` when \
6541             `#` byte appears first in value), got {reason:?}"
6542        );
6543    }
6544
6545    #[test]
6546    fn validate_rejects_git_fonte_with_repo_carrying_output_redirection() {
6547        // The fail-before-pass-after pin for the canonical
6548        // shell-output-redirection footgun on `:repo`: an author
6549        // pastes a shell-pipeline tail (`git clone <repo> > build.log`
6550        // / `… >output.txt`) into the `:repo` slot without trimming
6551        // the redirect. Until this arm landed the value silently
6552        // passed every prior arm (no whitespace, no control chars,
6553        // no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, doesn't
6554        // start with `-` or `:`); RFC 3986 §2 lists `<` / `>` in the
6555        // 'delims' / 'unwise' set and the WHATWG URL spec's fragment
6556        // percent-encode set maps `>` → `%3E` on the wire, so the
6557        // byte rides verbatim into the lacre's per-dep BLAKE3 closure
6558        // but is silently rewritten or rejected at libcurl's URL-
6559        // parser layer — two authors whose values differ only in
6560        // their redirect tail (`>build.log` vs nothing) resolve to
6561        // the byte-identical upstream `git clone` but lock to two
6562        // distinct lacres, defeating the THEORY.md §V.2 render-
6563        // determinism contract. Peer with the `:caminho` axis's
6564        // `FonteCaminhoShellRedirection` arm (e457141) on the sibling
6565        // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
6566        // byte RFC-3986-reserved set on `:entrada :paths`.
6567        let d = dep_with_fonte(DepSource::Git {
6568            repo: "https://github.com/pleme-io/caixa-teia>build.log".into(),
6569            tag: Some("v0.1.0".into()),
6570            rev: None,
6571            branch: None,
6572        });
6573        let err = d.validate().unwrap_err();
6574        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6575            panic!("expected FonteRepoShape, got other variant");
6576        };
6577        assert_eq!(nome, "caixa-teia");
6578        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia>build.log");
6579        assert!(
6580            reason.contains("must not contain `>`"),
6581            "reason must surface the output-redirection `>` arm, got {reason:?}"
6582        );
6583        assert!(
6584            reason.contains("redirection") || reason.contains("'delims'"),
6585            "reason must name the shell-redirection / RFC-3986-unwise rationale, got {reason:?}"
6586        );
6587    }
6588
6589    #[test]
6590    fn validate_rejects_git_fonte_with_repo_carrying_input_redirection() {
6591        // The symmetric shell-input-redirection footgun — an author
6592        // pastes a shell-pipeline head (`git clone <input.url` /
6593        // `cat <README.md`) into the `:repo` slot. Pinned separately
6594        // from the `>`-output arm so a future relaxation that only
6595        // catches one of the two redirect bytes surfaces here. Peer
6596        // with the `:caminho` axis's `FonteCaminhoShellRedirection`
6597        // arm which closes both `<` and `>` under the same banner.
6598        let d = dep_with_fonte(DepSource::Git {
6599            repo: "https://github.com/pleme-io/caixa-teia<input.url".into(),
6600            tag: Some("v0.1.0".into()),
6601            rev: None,
6602            branch: None,
6603        });
6604        let err = d.validate().unwrap_err();
6605        let DepError::FonteRepoShape { reason, .. } = err else {
6606            panic!("expected FonteRepoShape, got other variant");
6607        };
6608        assert!(
6609            reason.contains("must not contain `<`"),
6610            "reason must surface the input-redirection `<` arm, got {reason:?}"
6611        );
6612        assert!(
6613            reason.contains("RFC 3986") || reason.contains("'unwise'"),
6614            "reason must name the RFC 3986 'unwise' grammar, got {reason:?}"
6615        );
6616    }
6617
6618    #[test]
6619    fn validate_rejects_git_fonte_with_repo_carrying_backtick_command_substitution() {
6620        // The fail-before-pass-after pin for the canonical
6621        // paste-from-shell-prompt-with-backticked-substitution footgun
6622        // on `:repo` (peer with the c4d62b3 backtick arm on the sibling
6623        // `:caminho` path-fonte axis). An author pastes a URL whose
6624        // segment carries a backticked command-substitution wrapper
6625        // (`` `whoami` ``, `` `git config user.name` ``, `` `pwd` ``)
6626        // from a doc / README quick-start snippet that expected the
6627        // substrate to substitute the value downstream. Until this arm
6628        // landed the value silently passed every prior arm (no
6629        // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
6630        // no `\`, no `{`/`}`, no `<`/`>`, doesn't start with `-` or
6631        // `:`); RFC 3986 §2 lists the backtick byte in the 'delims' /
6632        // 'unwise' set and the WHATWG URL spec's fragment percent-
6633        // encode set maps `` ` `` → `%60` on the wire, so the byte
6634        // rides verbatim into the lacre's per-dep BLAKE3 closure but
6635        // is silently rewritten or rejected at libcurl's URL-parser
6636        // layer — two authors whose values differ only in their
6637        // backtick wrapper (`` `whoami` `` vs nothing) resolve to the
6638        // byte-identical upstream `git clone` but lock to two distinct
6639        // lacres, defeating the THEORY.md §V.2 render-determinism
6640        // contract. Peer with the `:caminho` axis's
6641        // `FonteCaminhoShellCommandSubstitution` arm (c4d62b3) on the
6642        // sibling path-fonte axis, and `is_gateway_api_http_path`'s
6643        // eleven-byte RFC-3986-reserved set on `:entrada :paths`.
6644        let d = dep_with_fonte(DepSource::Git {
6645            repo: "https://github.com/pleme-io/`whoami`/caixa-teia".into(),
6646            tag: Some("v0.1.0".into()),
6647            rev: None,
6648            branch: None,
6649        });
6650        let err = d.validate().unwrap_err();
6651        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6652            panic!("expected FonteRepoShape, got other variant");
6653        };
6654        assert_eq!(nome, "caixa-teia");
6655        assert_eq!(repo, "https://github.com/pleme-io/`whoami`/caixa-teia");
6656        assert!(
6657            reason.contains("must not contain `` ` ``"),
6658            "reason must surface the backtick command-substitution arm, got {reason:?}"
6659        );
6660        assert!(
6661            reason.contains("command-substitution") || reason.contains("'unwise'"),
6662            "reason must name the shell-command-substitution / RFC-3986-unwise rationale, \
6663             got {reason:?}"
6664        );
6665    }
6666
6667    #[test]
6668    fn fonte_repo_fragment_fires_before_backtick_when_fragment_first() {
6669        // Cascade pin: the fragment-`#` arm and the backtick command-
6670        // substitution arm are both per-byte arms inside the same
6671        // `for &b in s.as_bytes()` loop, so the byte that appears first
6672        // in the value's byte order wins. A `:repo
6673        // "https://github.com/p/x#readme/`whoami`"` carries both `#`
6674        // and backtick; the `#` byte appears first, so the fragment-
6675        // `#` arm fires, surfacing the more self-locating diagnostic
6676        // on the byte the author pasted earliest in the URL. Mirrors
6677        // the peer cascade discipline
6678        // `fonte_repo_fragment_fires_before_shell_redirection_when_fragment_first`
6679        // pins on the prior `:repo` byte-class arm.
6680        let d = dep_with_fonte(DepSource::Git {
6681            repo: "https://github.com/pleme-io/caixa-teia#readme/`whoami`".into(),
6682            tag: Some("v0.1.0".into()),
6683            rev: None,
6684            branch: None,
6685        });
6686        let err = d.validate().unwrap_err();
6687        let DepError::FonteRepoShape { reason, .. } = err else {
6688            panic!("expected FonteRepoShape, got other variant");
6689        };
6690        assert!(
6691            reason.contains("must not contain `#`"),
6692            "reason must surface the fragment-`#` arm (fires before backtick when `#` byte \
6693             appears first in value), got {reason:?}"
6694        );
6695    }
6696
6697    #[test]
6698    fn fonte_repo_shell_redirection_fires_before_backtick_when_redirection_first() {
6699        // Cascade pin: the shell-redirection `<` / `>` arm and the
6700        // backtick command-substitution arm are both per-byte arms
6701        // inside the same `for &b in s.as_bytes()` loop, so the byte
6702        // that appears first in the value's byte order wins. A `:repo
6703        // "https://github.com/p/x>build.log/`whoami`"` carries both
6704        // `>` and backtick; the `>` byte appears first, so the
6705        // shell-redirection arm fires, surfacing the more self-
6706        // locating diagnostic on the byte the author pasted earliest
6707        // in the URL. Pins the natural-order cascade so a future
6708        // reorder of the per-byte arms surfaces here.
6709        let d = dep_with_fonte(DepSource::Git {
6710            repo: "https://github.com/pleme-io/caixa-teia>build.log/`whoami`".into(),
6711            tag: Some("v0.1.0".into()),
6712            rev: None,
6713            branch: None,
6714        });
6715        let err = d.validate().unwrap_err();
6716        let DepError::FonteRepoShape { reason, .. } = err else {
6717            panic!("expected FonteRepoShape, got other variant");
6718        };
6719        assert!(
6720            reason.contains("must not contain `>`"),
6721            "reason must surface the shell-redirection `>` arm (fires before backtick when \
6722             `>` byte appears first in value), got {reason:?}"
6723        );
6724    }
6725
6726    #[test]
6727    fn fonte_repo_fragment_fires_before_shell_redirection_when_fragment_first() {
6728        // Cascade pin: the fragment-`#` arm and the shell-redirection
6729        // `<` / `>` arm are both per-byte arms inside the same
6730        // `for &b in s.as_bytes()` loop, so the byte that appears
6731        // first in the value's byte order wins. A `:repo
6732        // "https://github.com/p/x#readme>build.log"` carries both
6733        // `#` and `>`; the `#` byte appears first, so the fragment-
6734        // `#` arm fires, surfacing the more self-locating diagnostic
6735        // on the byte the author pasted earliest in the URL. Mirrors
6736        // the peer cascade discipline
6737        // `fonte_repo_fragment_fires_before_template_placeholder_when_fragment_first`
6738        // pins on the prior `:repo` byte-class arm.
6739        let d = dep_with_fonte(DepSource::Git {
6740            repo: "https://github.com/pleme-io/caixa-teia#readme>build.log".into(),
6741            tag: Some("v0.1.0".into()),
6742            rev: None,
6743            branch: None,
6744        });
6745        let err = d.validate().unwrap_err();
6746        let DepError::FonteRepoShape { reason, .. } = err else {
6747            panic!("expected FonteRepoShape, got other variant");
6748        };
6749        assert!(
6750            reason.contains("must not contain `#`"),
6751            "reason must surface the fragment-`#` arm (fires before shell-redirection `>` when \
6752             `#` byte appears first in value), got {reason:?}"
6753        );
6754    }
6755
6756    #[test]
6757    fn validate_rejects_git_fonte_with_repo_carrying_shell_pipe() {
6758        // The fail-before-pass-after pin for the canonical
6759        // paste-from-shell-prompt-with-piped-pipeline footgun on
6760        // `:repo` (peer with the 124106f pipe arm on the sibling
6761        // `:caminho` path-fonte axis). An author pastes a shell
6762        // pipeline (`git clone <url> | tee build.log`,
6763        // `git ls-remote <url> | head`) into the `:repo` slot,
6764        // forgetting to trim the `| <consumer>` tail. Until this arm
6765        // landed the value silently passed every prior arm (no
6766        // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
6767        // no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, doesn't start
6768        // with `-` or `:`); RFC 3986 §2 lists the pipe byte in the
6769        // 'unwise' set and the WHATWG URL spec's fragment percent-
6770        // encode set maps `|` → `%7C` on the wire, so the byte rides
6771        // verbatim into the lacre's per-dep BLAKE3 closure but is
6772        // silently rewritten or rejected at libcurl's URL-parser
6773        // layer — two authors whose values differ only in their pipe
6774        // tail (`|tee build.log` vs nothing) resolve to the byte-
6775        // identical upstream `git clone` but lock to two distinct
6776        // lacres, defeating the THEORY.md §V.2 render-determinism
6777        // contract. Peer with the `:caminho` axis's
6778        // `FonteCaminhoShellPipe` arm (124106f) on the sibling path-
6779        // fonte axis, and `is_gateway_api_http_path`'s eleven-byte
6780        // RFC-3986-reserved set on `:entrada :paths`.
6781        let d = dep_with_fonte(DepSource::Git {
6782            repo: "https://github.com/pleme-io/caixa-teia|tee build.log".into(),
6783            tag: Some("v0.1.0".into()),
6784            rev: None,
6785            branch: None,
6786        });
6787        let err = d.validate().unwrap_err();
6788        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6789            panic!("expected FonteRepoShape, got other variant");
6790        };
6791        assert_eq!(nome, "caixa-teia");
6792        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia|tee build.log");
6793        assert!(
6794            reason.contains("must not contain `|`"),
6795            "reason must surface the shell-pipe arm, got {reason:?}"
6796        );
6797        assert!(
6798            reason.contains("pipe") || reason.contains("'unwise'"),
6799            "reason must name the shell-pipe / RFC-3986-unwise rationale, got {reason:?}"
6800        );
6801    }
6802
6803    #[test]
6804    fn fonte_repo_fragment_fires_before_pipe_when_fragment_first() {
6805        // Cascade pin: the fragment-`#` arm and the pipe arm are both
6806        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
6807        // so the byte that appears first in the value's byte order
6808        // wins. A `:repo "https://github.com/p/x#readme|tee"` carries
6809        // both `#` and `|`; the `#` byte appears first, so the
6810        // fragment-`#` arm fires, surfacing the more self-locating
6811        // diagnostic on the byte the author pasted earliest in the
6812        // URL. Mirrors the peer cascade discipline
6813        // `fonte_repo_fragment_fires_before_backtick_when_fragment_first`
6814        // pins on the prior `:repo` byte-class arm.
6815        let d = dep_with_fonte(DepSource::Git {
6816            repo: "https://github.com/pleme-io/caixa-teia#readme|tee".into(),
6817            tag: Some("v0.1.0".into()),
6818            rev: None,
6819            branch: None,
6820        });
6821        let err = d.validate().unwrap_err();
6822        let DepError::FonteRepoShape { reason, .. } = err else {
6823            panic!("expected FonteRepoShape, got other variant");
6824        };
6825        assert!(
6826            reason.contains("must not contain `#`"),
6827            "reason must surface the fragment-`#` arm (fires before pipe when `#` byte \
6828             appears first in value), got {reason:?}"
6829        );
6830    }
6831
6832    #[test]
6833    fn fonte_repo_backtick_fires_before_pipe_when_backtick_first() {
6834        // Cascade pin: the backtick arm and the pipe arm are both per-
6835        // byte arms inside the same `for &b in s.as_bytes()` loop, so
6836        // the byte that appears first in the value's byte order wins.
6837        // A `:repo "https://github.com/p/x/`whoami`|tee"` carries both
6838        // `` ` `` and `|`; the backtick byte appears first, so the
6839        // backtick arm fires, surfacing the more self-locating
6840        // diagnostic on the byte the author pasted earliest in the
6841        // URL. Pins the natural-order cascade so a future reorder of
6842        // the per-byte arms surfaces here.
6843        let d = dep_with_fonte(DepSource::Git {
6844            repo: "https://github.com/pleme-io/caixa-teia/`whoami`|tee".into(),
6845            tag: Some("v0.1.0".into()),
6846            rev: None,
6847            branch: None,
6848        });
6849        let err = d.validate().unwrap_err();
6850        let DepError::FonteRepoShape { reason, .. } = err else {
6851            panic!("expected FonteRepoShape, got other variant");
6852        };
6853        assert!(
6854            reason.contains("must not contain `` ` ``"),
6855            "reason must surface the backtick arm (fires before pipe when `` ` `` byte \
6856             appears first in value), got {reason:?}"
6857        );
6858    }
6859
6860    #[test]
6861    fn validate_rejects_git_fonte_with_repo_carrying_shell_command_separator() {
6862        // The fail-before-pass-after pin for the canonical
6863        // paste-from-shell-prompt-with-sequential-command-tail footgun
6864        // on `:repo` (peer with the 05c358e `;` arm on the sibling
6865        // `:caminho` path-fonte axis). An author pastes a shell
6866        // one-liner that chained a cleanup tail after the URL
6867        // (`git clone <url>; rm -rf build`, `git ls-remote <url>;
6868        // echo done`) into the `:repo` slot, forgetting to trim the
6869        // `; <cmd>` tail. Until this arm landed the value silently
6870        // passed every prior `is_git_repo_url` arm (no whitespace, no
6871        // control chars, no non-ASCII, no `#`, no `?`, no `\`, no
6872        // `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, doesn't start with
6873        // `-` or `:`); RFC 3986 §2 lists `;` in the 'sub-delims' /
6874        // reserved set and the WHATWG URL spec's fragment percent-
6875        // encode set maps `;` → `%3B` on the wire, so the byte rides
6876        // verbatim into the lacre's per-dep BLAKE3 closure but is
6877        // silently rewritten at libcurl's URL-parser layer — two
6878        // authors whose values differ only in their sequential-command
6879        // tail (`; rm -rf build` vs nothing) resolve to the byte-
6880        // identical upstream `git clone` but lock to two distinct
6881        // lacres, defeating the THEORY.md §V.2 render-determinism
6882        // contract. Peer with the `:caminho` axis's
6883        // `FonteCaminhoShellSemicolon` arm (05c358e) on the sibling
6884        // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
6885        // byte RFC-3986-reserved set on `:entrada :paths`.
6886        let d = dep_with_fonte(DepSource::Git {
6887            repo: "https://github.com/pleme-io/caixa-teia; rm -rf build".into(),
6888            tag: Some("v0.1.0".into()),
6889            rev: None,
6890            branch: None,
6891        });
6892        let err = d.validate().unwrap_err();
6893        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6894            panic!("expected FonteRepoShape, got other variant");
6895        };
6896        assert_eq!(nome, "caixa-teia");
6897        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia; rm -rf build");
6898        assert!(
6899            reason.contains("must not contain `;`"),
6900            "reason must surface the shell-command-separator arm, got {reason:?}"
6901        );
6902        assert!(
6903            reason.contains("sequential-command") || reason.contains("'sub-delims'"),
6904            "reason must name the shell-command-separator / RFC-3986-sub-delims \
6905             rationale, got {reason:?}"
6906        );
6907    }
6908
6909    #[test]
6910    fn fonte_repo_fragment_fires_before_semicolon_when_fragment_first() {
6911        // Cascade pin: the fragment-`#` arm and the semicolon arm are
6912        // both per-byte arms inside the same `for &b in s.as_bytes()`
6913        // loop, so the byte that appears first in the value's byte
6914        // order wins. A `:repo "https://github.com/p/x#readme; rm"`
6915        // carries both `#` and `;`; the `#` byte appears first, so the
6916        // fragment-`#` arm fires, surfacing the more self-locating
6917        // diagnostic on the byte the author pasted earliest in the URL.
6918        // Mirrors the peer cascade discipline
6919        // `fonte_repo_fragment_fires_before_pipe_when_fragment_first`
6920        // pins on the prior `:repo` byte-class arm.
6921        let d = dep_with_fonte(DepSource::Git {
6922            repo: "https://github.com/pleme-io/caixa-teia#readme; rm".into(),
6923            tag: Some("v0.1.0".into()),
6924            rev: None,
6925            branch: None,
6926        });
6927        let err = d.validate().unwrap_err();
6928        let DepError::FonteRepoShape { reason, .. } = err else {
6929            panic!("expected FonteRepoShape, got other variant");
6930        };
6931        assert!(
6932            reason.contains("must not contain `#`"),
6933            "reason must surface the fragment-`#` arm (fires before semicolon when `#` \
6934             byte appears first in value), got {reason:?}"
6935        );
6936    }
6937
6938    #[test]
6939    fn fonte_repo_pipe_fires_before_semicolon_when_pipe_first() {
6940        // Cascade pin: the pipe arm and the semicolon arm are both
6941        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
6942        // so the byte that appears first in the value's byte order
6943        // wins. A `:repo "https://github.com/p/x|tee; rm"` carries
6944        // both `|` and `;`; the `|` byte appears first, so the
6945        // pipe arm fires, surfacing the more self-locating diagnostic
6946        // on the byte the author pasted earliest in the URL. Pins the
6947        // natural-order cascade so a future reorder of the per-byte
6948        // arms surfaces here.
6949        let d = dep_with_fonte(DepSource::Git {
6950            repo: "https://github.com/pleme-io/caixa-teia|tee; rm".into(),
6951            tag: Some("v0.1.0".into()),
6952            rev: None,
6953            branch: None,
6954        });
6955        let err = d.validate().unwrap_err();
6956        let DepError::FonteRepoShape { reason, .. } = err else {
6957            panic!("expected FonteRepoShape, got other variant");
6958        };
6959        assert!(
6960            reason.contains("must not contain `|`"),
6961            "reason must surface the pipe arm (fires before semicolon when `|` byte \
6962             appears first in value), got {reason:?}"
6963        );
6964    }
6965
6966    #[test]
6967    fn validate_rejects_git_fonte_with_repo_carrying_shell_background() {
6968        // The fail-before-pass-after pin for the canonical
6969        // paste-from-shell-prompt-with-background-launch-tail footgun
6970        // on `:repo` (peer with the e12e4f3 `&` arm on the sibling
6971        // `:caminho` path-fonte axis). An author pastes a shell one-
6972        // liner that detached the clone into the background
6973        // (`git clone <url> & sleep 1`, `git clone <url> && cd …`)
6974        // into the `:repo` slot, forgetting to trim the `& <cmd>` /
6975        // `&& <cmd>` tail. Until this arm landed the value silently
6976        // passed every prior `is_git_repo_url` arm (no whitespace,
6977        // no control chars, no non-ASCII, no `#`, no `?`, no `\`,
6978        // no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no `;`,
6979        // doesn't start with `-` or `:`); RFC 3986 §2 lists `&` in
6980        // the 'sub-delims' / reserved set and the WHATWG URL spec's
6981        // fragment percent-encode set maps `&` → `%26` on the wire,
6982        // so the byte rides verbatim into the lacre's per-dep
6983        // BLAKE3 closure but is silently rewritten at libcurl's
6984        // URL-parser layer — two authors whose values differ only
6985        // in their background-launch tail (`& sleep 1` vs nothing)
6986        // resolve to the byte-identical upstream `git clone` but
6987        // lock to two distinct lacres, defeating the THEORY.md
6988        // §V.2 render-determinism contract. Peer with the
6989        // `:caminho` axis's `FonteCaminhoShellBackground` arm
6990        // (e12e4f3) on the sibling path-fonte axis, and
6991        // `is_gateway_api_http_path`'s eleven-byte RFC-3986-
6992        // reserved set on `:entrada :paths`.
6993        let d = dep_with_fonte(DepSource::Git {
6994            repo: "https://github.com/pleme-io/caixa-teia&sleep".into(),
6995            tag: Some("v0.1.0".into()),
6996            rev: None,
6997            branch: None,
6998        });
6999        let err = d.validate().unwrap_err();
7000        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7001            panic!("expected FonteRepoShape, got other variant");
7002        };
7003        assert_eq!(nome, "caixa-teia");
7004        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia&sleep");
7005        assert!(
7006            reason.contains("must not contain `&`"),
7007            "reason must surface the shell-background / logical-AND arm, got {reason:?}"
7008        );
7009        assert!(
7010            reason.contains("background-task") || reason.contains("'sub-delims'"),
7011            "reason must name the shell-background / RFC-3986-sub-delims rationale, \
7012             got {reason:?}"
7013        );
7014    }
7015
7016    #[test]
7017    fn validate_rejects_git_fonte_with_repo_carrying_logical_and() {
7018        // The fail-before-pass-after pin for the symmetric `&&`
7019        // logical-AND build-chain paste footgun: an author pastes
7020        // a `git clone <url> && cd <repo>` build-chain one-liner
7021        // and forgets to trim the `&& <cmd>` tail. The `&&` shape
7022        // is the same `&` byte twice in a row; the per-byte arm
7023        // fires on the first `&` it sees. Pinned separately from
7024        // the single-`&` background-launch shape so a future
7025        // diagnostic-surface change that special-cased the
7026        // doubled-byte form surfaces here.
7027        let d = dep_with_fonte(DepSource::Git {
7028            repo: "github:pleme-io/caixa-teia&&echo".into(),
7029            tag: Some("v0.1.0".into()),
7030            rev: None,
7031            branch: None,
7032        });
7033        let err = d.validate().unwrap_err();
7034        let DepError::FonteRepoShape { reason, .. } = err else {
7035            panic!("expected FonteRepoShape, got other variant");
7036        };
7037        assert!(
7038            reason.contains("must not contain `&`"),
7039            "reason must surface the shell-background / logical-AND arm on the doubled-`&&` \
7040             shape too, got {reason:?}"
7041        );
7042    }
7043
7044    #[test]
7045    fn fonte_repo_fragment_fires_before_background_when_fragment_first() {
7046        // Cascade pin: the fragment-`#` arm and the background-`&`
7047        // arm are both per-byte arms inside the same `for &b in
7048        // s.as_bytes()` loop, so the byte that appears first in the
7049        // value's byte order wins. A `:repo
7050        // "https://github.com/p/x#readme & sleep"` carries both `#`
7051        // and `&`; the `#` byte appears first, so the fragment-`#`
7052        // arm fires, surfacing the more self-locating diagnostic on
7053        // the byte the author pasted earliest in the URL. Mirrors
7054        // the peer cascade discipline
7055        // `fonte_repo_fragment_fires_before_semicolon_when_fragment_first`
7056        // on the prior `:repo` byte-class arm.
7057        let d = dep_with_fonte(DepSource::Git {
7058            repo: "https://github.com/pleme-io/caixa-teia#readme&sleep".into(),
7059            tag: Some("v0.1.0".into()),
7060            rev: None,
7061            branch: None,
7062        });
7063        let err = d.validate().unwrap_err();
7064        let DepError::FonteRepoShape { reason, .. } = err else {
7065            panic!("expected FonteRepoShape, got other variant");
7066        };
7067        assert!(
7068            reason.contains("must not contain `#`"),
7069            "reason must surface the fragment-`#` arm (fires before background-`&` when `#` \
7070             byte appears first in value), got {reason:?}"
7071        );
7072    }
7073
7074    #[test]
7075    fn fonte_repo_semicolon_fires_before_background_when_semicolon_first() {
7076        // Cascade pin: the semicolon arm and the background-`&` arm
7077        // are both per-byte arms inside the same `for &b in
7078        // s.as_bytes()` loop, so the byte that appears first in the
7079        // value's byte order wins. A `:repo
7080        // "https://github.com/p/x; rm & sleep"` carries both `;` and
7081        // `&`; the `;` byte appears first, so the semicolon arm
7082        // fires, surfacing the more self-locating diagnostic on the
7083        // byte the author pasted earliest in the URL. Pins the
7084        // natural-order cascade so a future reorder of the per-byte
7085        // arms surfaces here.
7086        let d = dep_with_fonte(DepSource::Git {
7087            repo: "https://github.com/pleme-io/caixa-teia;rm&sleep".into(),
7088            tag: Some("v0.1.0".into()),
7089            rev: None,
7090            branch: None,
7091        });
7092        let err = d.validate().unwrap_err();
7093        let DepError::FonteRepoShape { reason, .. } = err else {
7094            panic!("expected FonteRepoShape, got other variant");
7095        };
7096        assert!(
7097            reason.contains("must not contain `;`"),
7098            "reason must surface the semicolon arm (fires before background-`&` when `;` \
7099             byte appears first in value), got {reason:?}"
7100        );
7101    }
7102
7103    #[test]
7104    fn validate_rejects_git_fonte_with_repo_carrying_shell_variable_expansion() {
7105        // The fail-before-pass-after pin for the canonical
7106        // paste-from-shell-prompt-with-unsubstituted-variable footgun
7107        // on `:repo` (peer with the f4efe9c `$` arm on the sibling
7108        // `:caminho` path-fonte axis). An author pastes a shell one-
7109        // liner that referenced an environment variable
7110        // (`git clone https://github.com/$ORG/x`, `git clone
7111        // github:$USER/repo`) into the `:repo` slot, forgetting to
7112        // substitute the literal value at author time. Until this arm
7113        // landed the value silently passed every prior
7114        // `is_git_repo_url` arm (no whitespace, no control chars, no
7115        // non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no `<`/`>`,
7116        // no `` ` ``, no `|`, no `;`, no `&`, doesn't start with `-`
7117        // or `:`); RFC 3986 §2 lists `$` in the 'sub-delims' /
7118        // reserved set and the WHATWG URL spec's fragment percent-
7119        // encode set maps `$` → `%24` on the wire, so the byte rides
7120        // verbatim into the lacre's per-dep BLAKE3 closure but is
7121        // silently rewritten at libcurl's URL-parser layer — two
7122        // authors whose values differ only in their `$VAR` /
7123        // `${VAR}` / `$(cmd)` expansion tail resolve to the byte-
7124        // identical upstream `git clone` but lock to two distinct
7125        // lacres, defeating the THEORY.md §V.2 render-determinism
7126        // contract. Beyond determinism, the value is a structural
7127        // host-layout leak: two authors with the same `:repo` slot
7128        // but different `$ORG` / `$HOME` / `$WORKSPACE` resolve
7129        // different upstreams. Peer with the `:caminho` axis's
7130        // `FonteCaminhoVarExpansion` arm (f4efe9c) on the sibling
7131        // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
7132        // byte RFC-3986-reserved set on `:entrada :paths`.
7133        let d = dep_with_fonte(DepSource::Git {
7134            repo: "https://github.com/$ORG/caixa-teia".into(),
7135            tag: Some("v0.1.0".into()),
7136            rev: None,
7137            branch: None,
7138        });
7139        let err = d.validate().unwrap_err();
7140        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7141            panic!("expected FonteRepoShape, got other variant");
7142        };
7143        assert_eq!(nome, "caixa-teia");
7144        assert_eq!(repo, "https://github.com/$ORG/caixa-teia");
7145        assert!(
7146            reason.contains("must not contain `$`"),
7147            "reason must surface the shell-variable-expansion arm, got {reason:?}"
7148        );
7149        assert!(
7150            reason.contains("variable-expansion") || reason.contains("'sub-delims'"),
7151            "reason must name the shell-variable-expansion / RFC-3986-sub-delims \
7152             rationale, got {reason:?}"
7153        );
7154    }
7155
7156    #[test]
7157    fn validate_rejects_git_fonte_with_repo_carrying_braced_variable_expansion() {
7158        // The fail-before-pass-after pin for the symmetric POSIX-
7159        // shell braced `${VAR}` expansion paste footgun: an author
7160        // pastes a CI-manifest line `git clone
7161        // https://github.com/${WORKSPACE}/x` (the canonical GitHub
7162        // Actions / GitLab CI / Drone shape) and forgets to
7163        // substitute the literal value. The `${...}` shape is the
7164        // same `$` byte at the leading position of the expansion;
7165        // the per-byte arm fires on the `$`. Pinned separately from
7166        // the bare-`$VAR` shape so a future diagnostic-surface
7167        // change that special-cased the braced form surfaces here.
7168        let d = dep_with_fonte(DepSource::Git {
7169            repo: "https://github.com/${WORKSPACE}/caixa-teia".into(),
7170            tag: Some("v0.1.0".into()),
7171            rev: None,
7172            branch: None,
7173        });
7174        let err = d.validate().unwrap_err();
7175        let DepError::FonteRepoShape { reason, .. } = err else {
7176            panic!("expected FonteRepoShape, got other variant");
7177        };
7178        assert!(
7179            reason.contains("must not contain `$`"),
7180            "reason must surface the shell-variable-expansion arm on the braced `${{...}}` \
7181             shape too, got {reason:?}"
7182        );
7183    }
7184
7185    #[test]
7186    fn fonte_repo_fragment_fires_before_var_expansion_when_fragment_first() {
7187        // Cascade pin: the fragment-`#` arm and the var-expansion-`$`
7188        // arm are both per-byte arms inside the same `for &b in
7189        // s.as_bytes()` loop, so the byte that appears first in the
7190        // value's byte order wins. A `:repo
7191        // "https://github.com/p/x#readme$HOME"` carries both `#` and
7192        // `$`; the `#` byte appears first, so the fragment-`#` arm
7193        // fires, surfacing the more self-locating diagnostic on the
7194        // byte the author pasted earliest in the URL. Mirrors the
7195        // peer cascade discipline
7196        // `fonte_repo_fragment_fires_before_background_when_fragment_first`
7197        // on the prior `:repo` byte-class arm.
7198        let d = dep_with_fonte(DepSource::Git {
7199            repo: "https://github.com/pleme-io/caixa-teia#readme$HOME".into(),
7200            tag: Some("v0.1.0".into()),
7201            rev: None,
7202            branch: None,
7203        });
7204        let err = d.validate().unwrap_err();
7205        let DepError::FonteRepoShape { reason, .. } = err else {
7206            panic!("expected FonteRepoShape, got other variant");
7207        };
7208        assert!(
7209            reason.contains("must not contain `#`"),
7210            "reason must surface the fragment-`#` arm (fires before var-expansion-`$` when \
7211             `#` byte appears first in value), got {reason:?}"
7212        );
7213    }
7214
7215    #[test]
7216    fn fonte_repo_background_fires_before_var_expansion_when_background_first() {
7217        // Cascade pin: the background-`&` arm and the
7218        // var-expansion-`$` arm are both per-byte arms inside the
7219        // same `for &b in s.as_bytes()` loop, so the byte that
7220        // appears first in the value's byte order wins. A `:repo
7221        // "https://github.com/p/x&sleep$HOME"` carries both `&` and
7222        // `$`; the `&` byte appears first, so the background arm
7223        // fires, surfacing the more self-locating diagnostic on the
7224        // byte the author pasted earliest in the URL. Pins the
7225        // natural-order cascade so a future reorder of the per-byte
7226        // arms surfaces here — `$` is the most recent byte-class arm,
7227        // so the cascade-pin sweep extends to cover every immediately
7228        // prior byte arm (`#`, `&`) firing first when ordered ahead
7229        // of `$` in the value.
7230        let d = dep_with_fonte(DepSource::Git {
7231            repo: "https://github.com/pleme-io/caixa-teia&sleep$HOME".into(),
7232            tag: Some("v0.1.0".into()),
7233            rev: None,
7234            branch: None,
7235        });
7236        let err = d.validate().unwrap_err();
7237        let DepError::FonteRepoShape { reason, .. } = err else {
7238            panic!("expected FonteRepoShape, got other variant");
7239        };
7240        assert!(
7241            reason.contains("must not contain `&`"),
7242            "reason must surface the background-`&` arm (fires before var-expansion-`$` when \
7243             `&` byte appears first in value), got {reason:?}"
7244        );
7245    }
7246
7247    #[test]
7248    fn validate_rejects_git_fonte_with_repo_carrying_shell_glob_wildcard() {
7249        // The fail-before-pass-after pin for the canonical
7250        // paste-from-shell-prompt glob footgun on `:repo` (peer with
7251        // the cf9034b `*` / `?` arm on the sibling `:caminho`
7252        // path-fonte axis). An author pastes a shell one-liner that
7253        // referenced a glob expansion (`ls
7254        // github.com/pleme-io/caixa-*`, `git clone
7255        // github:pleme-io/caixa-*`) into the `:repo` slot, forgetting
7256        // to substitute the literal repo name. Until this arm landed
7257        // the `*` byte silently passed every prior `is_git_repo_url`
7258        // arm (no whitespace, no control chars, no non-ASCII, no `#`,
7259        // no `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`,
7260        // no `;`, no `&`, no `$`, doesn't start with `-` or `:`); RFC
7261        // 3986 §2 lists `*` in the 'sub-delims' / reserved set and
7262        // the WHATWG URL spec's special-query percent-encode set maps
7263        // `*` → `%2A` on the wire, so the byte rides verbatim into
7264        // the lacre's per-dep BLAKE3 closure but is silently
7265        // rewritten at libcurl's URL-parser layer — two authors
7266        // whose values differ only in their asterisk presence
7267        // resolve to the byte-identical upstream `git clone` but
7268        // lock to two distinct lacres, defeating the THEORY.md §V.2
7269        // render-determinism contract. Peer with the `:caminho`
7270        // axis's `FonteCaminhoShellGlob` arm (cf9034b) on the
7271        // sibling path-fonte axis, and the `is_git_ref_name`
7272        // refspec-wildcard cascade on the `:fonte :tag` / `:branch`
7273        // axes.
7274        let d = dep_with_fonte(DepSource::Git {
7275            repo: "https://github.com/pleme-io/caixa-*".into(),
7276            tag: Some("v0.1.0".into()),
7277            rev: None,
7278            branch: None,
7279        });
7280        let err = d.validate().unwrap_err();
7281        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7282            panic!("expected FonteRepoShape, got other variant");
7283        };
7284        assert_eq!(nome, "caixa-teia");
7285        assert_eq!(repo, "https://github.com/pleme-io/caixa-*");
7286        assert!(
7287            reason.contains("must not contain `*`"),
7288            "reason must surface the shell-glob arm, got {reason:?}"
7289        );
7290        assert!(
7291            reason.contains("pathname-expansion") || reason.contains("'sub-delims'"),
7292            "reason must name the shell-glob / pathname-expansion / \
7293             RFC-3986-sub-delims rationale, got {reason:?}"
7294        );
7295    }
7296
7297    #[test]
7298    fn validate_rejects_git_fonte_with_repo_carrying_recursive_shell_glob() {
7299        // The fail-before-pass-after pin for the symmetric bash
7300        // `globstar` recursive-glob paste footgun: an author pastes
7301        // a `ls github.com/pleme-io/**/x` (the canonical
7302        // `globstar`-shopt-enabled recursive-listing tail) into the
7303        // `:repo` slot. The `**` shape is two `*` bytes adjacent;
7304        // the per-byte arm fires on the first `*`. Pinned
7305        // separately from the single-`*` shape so a future
7306        // diagnostic-surface change that special-cased the
7307        // double-`*` form surfaces here.
7308        let d = dep_with_fonte(DepSource::Git {
7309            repo: "https://github.com/pleme-io/**/caixa-teia".into(),
7310            tag: Some("v0.1.0".into()),
7311            rev: None,
7312            branch: None,
7313        });
7314        let err = d.validate().unwrap_err();
7315        let DepError::FonteRepoShape { reason, .. } = err else {
7316            panic!("expected FonteRepoShape, got other variant");
7317        };
7318        assert!(
7319            reason.contains("must not contain `*`"),
7320            "reason must surface the shell-glob arm on the `**` recursive-glob shape too, \
7321             got {reason:?}"
7322        );
7323    }
7324
7325    #[test]
7326    fn fonte_repo_fragment_fires_before_glob_when_fragment_first() {
7327        // Cascade pin: the fragment-`#` arm and the glob-`*` arm are
7328        // both per-byte arms inside the same `for &b in s.as_bytes()`
7329        // loop, so the byte that appears first in the value's byte
7330        // order wins. A `:repo
7331        // "https://github.com/p/x#readme*tail"` carries both `#` and
7332        // `*`; the `#` byte appears first, so the fragment-`#` arm
7333        // fires, surfacing the more self-locating diagnostic on the
7334        // byte the author pasted earliest in the URL. Mirrors the
7335        // peer cascade discipline
7336        // `fonte_repo_fragment_fires_before_var_expansion_when_fragment_first`
7337        // on the prior `:repo` byte-class arm.
7338        let d = dep_with_fonte(DepSource::Git {
7339            repo: "https://github.com/pleme-io/caixa-teia#readme*tail".into(),
7340            tag: Some("v0.1.0".into()),
7341            rev: None,
7342            branch: None,
7343        });
7344        let err = d.validate().unwrap_err();
7345        let DepError::FonteRepoShape { reason, .. } = err else {
7346            panic!("expected FonteRepoShape, got other variant");
7347        };
7348        assert!(
7349            reason.contains("must not contain `#`"),
7350            "reason must surface the fragment-`#` arm (fires before glob-`*` when `#` byte \
7351             appears first in value), got {reason:?}"
7352        );
7353    }
7354
7355    #[test]
7356    fn fonte_repo_var_expansion_fires_before_glob_when_var_expansion_first() {
7357        // Cascade pin: the var-expansion-`$` arm and the glob-`*`
7358        // arm are both per-byte arms inside the same `for &b in
7359        // s.as_bytes()` loop, so the byte that appears first in the
7360        // value's byte order wins. A `:repo
7361        // "https://github.com/p/$ORG-*"` carries both `$` and `*`;
7362        // the `$` byte appears first, so the var-expansion arm
7363        // fires, surfacing the more self-locating diagnostic on the
7364        // byte the author pasted earliest in the URL. Pins the
7365        // natural-order cascade so a future reorder of the per-byte
7366        // arms surfaces here — `*` is the most recent byte-class
7367        // arm, so the cascade-pin sweep extends to cover the
7368        // immediately prior `$` byte arm firing first when ordered
7369        // ahead of `*` in the value.
7370        let d = dep_with_fonte(DepSource::Git {
7371            repo: "https://github.com/pleme-io/$ORG-caixa-*".into(),
7372            tag: Some("v0.1.0".into()),
7373            rev: None,
7374            branch: None,
7375        });
7376        let err = d.validate().unwrap_err();
7377        let DepError::FonteRepoShape { reason, .. } = err else {
7378            panic!("expected FonteRepoShape, got other variant");
7379        };
7380        assert!(
7381            reason.contains("must not contain `$`"),
7382            "reason must surface the var-expansion-`$` arm (fires before glob-`*` when `$` \
7383             byte appears first in value), got {reason:?}"
7384        );
7385    }
7386
7387    #[test]
7388    fn validate_rejects_git_fonte_with_repo_carrying_subshell_open_paren() {
7389        // The fail-before-pass-after pin for the canonical paste-from-
7390        // shell-prompt subshell-grouping footgun on `:repo`. An author
7391        // pastes a doc / README snippet carrying a regex-alternation
7392        // grouping shape (`https://github.com/(foo|bar)/repo`) or a
7393        // dynamic-config-substitution wrapper (`$(<cmd>)`) into the
7394        // `:repo` slot, forgetting to substitute one literal org name.
7395        // Until this arm landed the `(` byte silently passed every
7396        // prior `is_git_repo_url` arm (no whitespace, no control
7397        // chars, no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no
7398        // `<`/`>`, no `` ` ``, no `|`, no `;`, no `&`, no `$`, no
7399        // `*`, doesn't start with `-` or `:`); RFC 3986 §2 lists `(`
7400        // / `)` in the 'sub-delims' / reserved set, and the WHATWG
7401        // URL spec's special-query percent-encode set maps `(` →
7402        // `%28` and `)` → `%29` on the wire, so the byte rides
7403        // verbatim into the lacre's per-dep BLAKE3 closure but is
7404        // silently rewritten at libcurl's URL-parser layer —
7405        // defeating the THEORY.md §V.2 render-determinism contract on
7406        // the same axis the prior twelve byte-class arms close.
7407        let d = dep_with_fonte(DepSource::Git {
7408            repo: "https://github.com/(foo|bar)/caixa-teia".into(),
7409            tag: Some("v0.1.0".into()),
7410            rev: None,
7411            branch: None,
7412        });
7413        let err = d.validate().unwrap_err();
7414        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7415            panic!("expected FonteRepoShape, got other variant");
7416        };
7417        assert_eq!(nome, "caixa-teia");
7418        assert_eq!(repo, "https://github.com/(foo|bar)/caixa-teia");
7419        assert!(
7420            reason.contains("must not contain `(`"),
7421            "reason must surface the subshell-open-paren arm, got {reason:?}"
7422        );
7423        assert!(
7424            reason.contains("subshell-grouping") || reason.contains("'sub-delims'"),
7425            "reason must name the shell-subshell-grouping / RFC-3986-sub-delims rationale, \
7426             got {reason:?}"
7427        );
7428    }
7429
7430    #[test]
7431    fn validate_rejects_git_fonte_with_repo_carrying_subshell_close_paren() {
7432        // The symmetric arm pin on the closing `)` byte: an author
7433        // pastes a `$(date)` command-substitution wrapper or a
7434        // regex-alternation `(foo|bar)` tail into the `:repo` slot.
7435        // Pinned separately from the opening `(` shape so a future
7436        // diagnostic-surface change that only checked one boundary
7437        // surfaces here. The `(` byte appears earlier in the
7438        // canonical regex / subshell wrapper so the per-byte loop
7439        // fires on `(` first; this test exercises a `:repo` value
7440        // carrying only the closing `)` byte (no opening paren) so
7441        // the `)` arm fires directly — pinning the byte-class arm
7442        // independent of order.
7443        let d = dep_with_fonte(DepSource::Git {
7444            repo: "github:pleme-io/caixa-teia)tail".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 { reason, .. } = err else {
7451            panic!("expected FonteRepoShape, got other variant");
7452        };
7453        assert!(
7454            reason.contains("must not contain `)`"),
7455            "reason must surface the subshell-close-paren arm on the bare `)` shape, \
7456             got {reason:?}"
7457        );
7458    }
7459
7460    #[test]
7461    fn fonte_repo_fragment_fires_before_subshell_when_fragment_first() {
7462        // Cascade pin: the fragment-`#` arm and the subshell-`(` arm
7463        // are both per-byte arms inside the same `for &b in
7464        // s.as_bytes()` loop, so the byte that appears first in the
7465        // value's byte order wins. A `:repo
7466        // "https://github.com/p/x#readme(tail)"` carries both `#` and
7467        // `(`; the `#` byte appears first, so the fragment-`#` arm
7468        // fires, surfacing the more self-locating diagnostic on the
7469        // byte the author pasted earliest in the URL. Mirrors the
7470        // peer cascade discipline
7471        // `fonte_repo_fragment_fires_before_glob_when_fragment_first`
7472        // on the prior `:repo` byte-class arm.
7473        let d = dep_with_fonte(DepSource::Git {
7474            repo: "https://github.com/pleme-io/caixa-teia#readme(tail)".into(),
7475            tag: Some("v0.1.0".into()),
7476            rev: None,
7477            branch: None,
7478        });
7479        let err = d.validate().unwrap_err();
7480        let DepError::FonteRepoShape { reason, .. } = err else {
7481            panic!("expected FonteRepoShape, got other variant");
7482        };
7483        assert!(
7484            reason.contains("must not contain `#`"),
7485            "reason must surface the fragment-`#` arm (fires before subshell-`(` when `#` \
7486             byte appears first in value), got {reason:?}"
7487        );
7488    }
7489
7490    #[test]
7491    fn fonte_repo_glob_fires_before_subshell_when_glob_first() {
7492        // Cascade pin: the glob-`*` arm (the immediate-predecessor
7493        // byte-class arm, 3902a9a) and the subshell-`(` arm are both
7494        // per-byte arms inside the same `for &b in s.as_bytes()`
7495        // loop, so the byte that appears first in the value's byte
7496        // order wins. A `:repo
7497        // "https://github.com/p/x-*-(date)"` carries both `*` and
7498        // `(`; the `*` byte appears first, so the glob arm fires,
7499        // surfacing the more self-locating diagnostic on the byte
7500        // the author pasted earliest in the URL. Pins the natural-
7501        // order cascade so a future reorder of the per-byte arms
7502        // surfaces here — `(` is the most recent byte-class arm,
7503        // so the cascade-pin sweep extends to cover the immediately
7504        // prior `*` byte arm firing first when ordered ahead of `(`
7505        // in the value.
7506        let d = dep_with_fonte(DepSource::Git {
7507            repo: "https://github.com/pleme-io/caixa-teia-*-(date)".into(),
7508            tag: Some("v0.1.0".into()),
7509            rev: None,
7510            branch: None,
7511        });
7512        let err = d.validate().unwrap_err();
7513        let DepError::FonteRepoShape { reason, .. } = err else {
7514            panic!("expected FonteRepoShape, got other variant");
7515        };
7516        assert!(
7517            reason.contains("must not contain `*`"),
7518            "reason must surface the glob-`*` arm (fires before subshell-`(` when `*` byte \
7519             appears first in value), got {reason:?}"
7520        );
7521    }
7522
7523    #[test]
7524    fn validate_rejects_git_fonte_with_repo_carrying_shell_double_quote() {
7525        // The fail-before-pass-after pin for the canonical paste-from-
7526        // doc-shell-quoting footgun on `:repo`. An author copies a
7527        // README quick-start snippet (`$ git clone "https://github.com/
7528        // foo/bar"`) and keeps the surrounding double-quote bytes when
7529        // pasting into the `:repo` slot — the doc wraps the URL in
7530        // double quotes so the shell doesn't re-lex metachars inside,
7531        // but the typed slot is itself a byte-level string parser, not
7532        // a shell context, so the quote bytes ride into the value
7533        // verbatim. Until this arm landed the `"` byte silently passed
7534        // every prior `is_git_repo_url` arm (no whitespace, no control
7535        // chars, no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no
7536        // `<`/`>`, no `` ` ``, no `|`, no `;`, no `&`, no `$`, no `*`,
7537        // no `(`/`)`, doesn't start with `-` or `:`); RFC 3986 §2 lists
7538        // `"` in the strict four-byte 'delims' subset (with `<`, `>`,
7539        // `` ` ``) every URL parser is required to refuse or percent-
7540        // encode, and the WHATWG URL spec's 'C0 control percent-encode
7541        // set' maps `"` → `%22` on the wire, so the byte rides verbatim
7542        // into the lacre's per-dep BLAKE3 closure but is silently
7543        // rewritten at libcurl's URL-parser layer, defeating the
7544        // THEORY.md §V.2 render-determinism contract.
7545        let d = dep_with_fonte(DepSource::Git {
7546            repo: "\"https://github.com/pleme-io/caixa-teia\"".into(),
7547            tag: Some("v0.1.0".into()),
7548            rev: None,
7549            branch: None,
7550        });
7551        let err = d.validate().unwrap_err();
7552        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7553            panic!("expected FonteRepoShape, got other variant");
7554        };
7555        assert_eq!(nome, "caixa-teia");
7556        assert_eq!(repo, "\"https://github.com/pleme-io/caixa-teia\"");
7557        assert!(
7558            reason.contains("must not contain `\"`"),
7559            "reason must surface the shell-double-quote arm, got {reason:?}"
7560        );
7561        assert!(
7562            reason.contains("double-quote") || reason.contains("'delims'"),
7563            "reason must name the shell-double-quote / RFC-3986-delims rationale, \
7564             got {reason:?}"
7565        );
7566    }
7567
7568    #[test]
7569    fn validate_rejects_git_fonte_with_repo_carrying_stray_trailing_double_quote() {
7570        // The symmetric stray-quote tail pin: an author pastes only a
7571        // closing `"` from a shell-history line like `git clone
7572        // "https://github.com/foo/bar" && cd …` (the trim went too
7573        // far in one direction but not the other) into the `:repo`
7574        // slot. Pinned separately from the wrapped-quote shape so a
7575        // future diagnostic-surface change that only checked one
7576        // boundary (only leading, only trailing, only paired) surfaces
7577        // here — the per-byte arm fires anywhere `"` appears.
7578        let d = dep_with_fonte(DepSource::Git {
7579            repo: "github:pleme-io/caixa-teia\"".into(),
7580            tag: Some("v0.1.0".into()),
7581            rev: None,
7582            branch: None,
7583        });
7584        let err = d.validate().unwrap_err();
7585        let DepError::FonteRepoShape { reason, .. } = err else {
7586            panic!("expected FonteRepoShape, got other variant");
7587        };
7588        assert!(
7589            reason.contains("must not contain `\"`"),
7590            "reason must surface the shell-double-quote arm on the trailing-`\"` shape, \
7591             got {reason:?}"
7592        );
7593    }
7594
7595    #[test]
7596    fn fonte_repo_fragment_fires_before_double_quote_when_fragment_first() {
7597        // Cascade pin: the fragment-`#` arm and the double-quote arm
7598        // are both per-byte arms inside the same `for &b in
7599        // s.as_bytes()` loop, so the byte that appears first in the
7600        // value's byte order wins. A `:repo
7601        // "https://github.com/p/x#readme\"tail"` carries both `#` and
7602        // `"`; the `#` byte appears first, so the fragment-`#` arm
7603        // fires, surfacing the more self-locating diagnostic on the
7604        // byte the author pasted earliest in the URL.
7605        let d = dep_with_fonte(DepSource::Git {
7606            repo: "https://github.com/pleme-io/caixa-teia#readme\"tail".into(),
7607            tag: Some("v0.1.0".into()),
7608            rev: None,
7609            branch: None,
7610        });
7611        let err = d.validate().unwrap_err();
7612        let DepError::FonteRepoShape { reason, .. } = err else {
7613            panic!("expected FonteRepoShape, got other variant");
7614        };
7615        assert!(
7616            reason.contains("must not contain `#`"),
7617            "reason must surface the fragment-`#` arm (fires before double-quote when `#` \
7618             byte appears first in value), got {reason:?}"
7619        );
7620    }
7621
7622    #[test]
7623    fn fonte_repo_subshell_fires_before_double_quote_when_subshell_first() {
7624        // Cascade pin: the subshell-`(` arm (the immediate-predecessor
7625        // byte-class arm, 3b99147) and the double-quote arm are both
7626        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
7627        // so the byte that appears first in the value's byte order
7628        // wins. A `:repo "github:p/x(date)\"tail"` carries both `(`
7629        // and `"`; the `(` byte appears first, so the subshell arm
7630        // fires, surfacing the more self-locating diagnostic on the
7631        // byte the author pasted earliest in the URL. Pins the natural-
7632        // order cascade so a future reorder of the per-byte arms
7633        // surfaces here — `"` is the most recent byte-class arm, so
7634        // the cascade-pin sweep extends to cover the immediately prior
7635        // `(` byte arm firing first when ordered ahead of `"` in the
7636        // value.
7637        let d = dep_with_fonte(DepSource::Git {
7638            repo: "github:pleme-io/caixa-teia(date)\"tail".into(),
7639            tag: Some("v0.1.0".into()),
7640            rev: None,
7641            branch: None,
7642        });
7643        let err = d.validate().unwrap_err();
7644        let DepError::FonteRepoShape { reason, .. } = err else {
7645            panic!("expected FonteRepoShape, got other variant");
7646        };
7647        assert!(
7648            reason.contains("must not contain `(`"),
7649            "reason must surface the subshell-`(` arm (fires before double-quote when `(` \
7650             byte appears first in value), got {reason:?}"
7651        );
7652    }
7653
7654    #[test]
7655    fn validate_rejects_git_fonte_with_repo_carrying_shell_single_quote() {
7656        // The fail-before-pass-after pin for the canonical paste-from-
7657        // doc-strong-quoting footgun on `:repo`. An author copies a
7658        // security-conscious README quick-start snippet (`$ git clone
7659        // 'https://github.com/foo/bar'`) and keeps the surrounding
7660        // single-quote bytes when pasting into the `:repo` slot — the
7661        // doc strong-quotes the URL so the shell suppresses every form
7662        // of expansion on the bytes inside (no `$`, no backtick, no
7663        // glob, no word-splitting), but the typed slot is itself a
7664        // byte-level string parser, not a shell context, so the quote
7665        // bytes ride into the value verbatim. Until this arm landed the
7666        // `'` byte silently passed every prior `is_git_repo_url` arm
7667        // (no whitespace, no control chars, no non-ASCII, no `#`, no
7668        // `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no
7669        // `;`, no `&`, no `$`, no `*`, no `(`/`)`, no `"`, doesn't start
7670        // with `-` or `:`); RFC 3986 §2.2 lists `'` in the 'sub-delims'
7671        // set, peer with the `\"` 'delims' double-quote arm and the
7672        // partner ASCII shell-string-delimiter byte every byte-level
7673        // string parser sharing a value-shape with a shell argument
7674        // must refuse on a URL-shaped slot.
7675        let d = dep_with_fonte(DepSource::Git {
7676            repo: "'https://github.com/pleme-io/caixa-teia'".into(),
7677            tag: Some("v0.1.0".into()),
7678            rev: None,
7679            branch: None,
7680        });
7681        let err = d.validate().unwrap_err();
7682        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7683            panic!("expected FonteRepoShape, got other variant");
7684        };
7685        assert_eq!(nome, "caixa-teia");
7686        assert_eq!(repo, "'https://github.com/pleme-io/caixa-teia'");
7687        assert!(
7688            reason.contains("must not contain `'`"),
7689            "reason must surface the shell-single-quote arm, got {reason:?}"
7690        );
7691        assert!(
7692            reason.contains("single-quote") || reason.contains("strong-quote"),
7693            "reason must name the shell-single-quote / strong-quote rationale, \
7694             got {reason:?}"
7695        );
7696    }
7697
7698    #[test]
7699    fn validate_rejects_git_fonte_with_repo_carrying_english_apostrophe() {
7700        // The symmetric English-typography pin: an author writes
7701        // `:repo "github:p/repo's-fork"` (the possessive-form paste-
7702        // from-prose idiom every README / commit-message / chat-thread
7703        // reference to a repo carries) expecting the substrate to
7704        // coerce it to a kebab-case slug — but the byte rides into the
7705        // lacre verbatim. Pinned separately from the wrapped-quote
7706        // shape so a future diagnostic-surface change that only checked
7707        // the boundary positions (only leading, only trailing, only
7708        // paired) surfaces here — the per-byte arm fires anywhere `'`
7709        // appears in the value.
7710        let d = dep_with_fonte(DepSource::Git {
7711            repo: "github:pleme-io/repo's-fork".into(),
7712            tag: Some("v0.1.0".into()),
7713            rev: None,
7714            branch: None,
7715        });
7716        let err = d.validate().unwrap_err();
7717        let DepError::FonteRepoShape { reason, .. } = err else {
7718            panic!("expected FonteRepoShape, got other variant");
7719        };
7720        assert!(
7721            reason.contains("must not contain `'`"),
7722            "reason must surface the shell-single-quote arm on the mid-string \
7723             apostrophe shape, got {reason:?}"
7724        );
7725    }
7726
7727    #[test]
7728    fn fonte_repo_fragment_fires_before_single_quote_when_fragment_first() {
7729        // Cascade pin: the fragment-`#` arm and the single-quote arm
7730        // are both per-byte arms inside the same `for &b in
7731        // s.as_bytes()` loop, so the byte that appears first in the
7732        // value's byte order wins. A `:repo
7733        // "https://github.com/p/x#readme'tail"` carries both `#` and
7734        // `'`; the `#` byte appears first, so the fragment-`#` arm
7735        // fires, surfacing the more self-locating diagnostic on the
7736        // byte the author pasted earliest in the URL.
7737        let d = dep_with_fonte(DepSource::Git {
7738            repo: "https://github.com/pleme-io/caixa-teia#readme'tail".into(),
7739            tag: Some("v0.1.0".into()),
7740            rev: None,
7741            branch: None,
7742        });
7743        let err = d.validate().unwrap_err();
7744        let DepError::FonteRepoShape { reason, .. } = err else {
7745            panic!("expected FonteRepoShape, got other variant");
7746        };
7747        assert!(
7748            reason.contains("must not contain `#`"),
7749            "reason must surface the fragment-`#` arm (fires before single-quote when `#` \
7750             byte appears first in value), got {reason:?}"
7751        );
7752    }
7753
7754    #[test]
7755    fn fonte_repo_double_quote_fires_before_single_quote_when_double_quote_first() {
7756        // Cascade pin: the double-quote-`"` arm (the immediate-predecessor
7757        // byte-class arm, 4267d8b) and the single-quote arm are both
7758        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
7759        // so the byte that appears first in the value's byte order
7760        // wins. A `:repo "github:p/x\"mid'tail"` carries both `"` and
7761        // `'`; the `"` byte appears first, so the double-quote arm
7762        // fires, surfacing the more self-locating diagnostic on the
7763        // byte the author pasted earliest in the URL. Pins the natural-
7764        // order cascade so a future reorder of the per-byte arms
7765        // surfaces here — `'` is the most recent byte-class arm, so
7766        // the cascade-pin sweep extends to cover the immediately prior
7767        // `"` byte arm firing first when ordered ahead of `'` in the
7768        // value.
7769        let d = dep_with_fonte(DepSource::Git {
7770            repo: "github:pleme-io/caixa-teia\"mid'tail".into(),
7771            tag: Some("v0.1.0".into()),
7772            rev: None,
7773            branch: None,
7774        });
7775        let err = d.validate().unwrap_err();
7776        let DepError::FonteRepoShape { reason, .. } = err else {
7777            panic!("expected FonteRepoShape, got other variant");
7778        };
7779        assert!(
7780            reason.contains("must not contain `\"`"),
7781            "reason must surface the double-quote arm (fires before single-quote when `\"` \
7782             byte appears first in value), got {reason:?}"
7783        );
7784    }
7785
7786    #[test]
7787    fn validate_rejects_git_fonte_with_repo_carrying_shell_history_expansion() {
7788        // The fail-before-pass-after pin for the canonical paste-from-
7789        // shell-history footgun on `:repo`. An author copies a `git
7790        // clone <url>!sudo make install` one-liner from a README's
7791        // quick-start snippet, intending the trailing `!sudo` as a
7792        // shell-history-expansion reference but the typed slot is itself
7793        // a byte-level string parser, not a shell context, so the byte
7794        // rides into the value verbatim. Until this arm landed the `!`
7795        // byte silently passed every prior `is_git_repo_url` arm (no
7796        // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
7797        // no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no `;`,
7798        // no `&`, no `$`, no `*`, no `(`/`)`, no `"`, no `'`, doesn't
7799        // start with `-` or `:`); bash with the default `histexpand`
7800        // mode rewrites `!command` to the most recent history entry
7801        // beginning with `command`, the canonical RCE-class injection
7802        // vector when the byte rides into a shell argument.
7803        let d = dep_with_fonte(DepSource::Git {
7804            repo: "https://github.com/pleme-io/caixa-teia!sudo".into(),
7805            tag: Some("v0.1.0".into()),
7806            rev: None,
7807            branch: None,
7808        });
7809        let err = d.validate().unwrap_err();
7810        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7811            panic!("expected FonteRepoShape, got other variant");
7812        };
7813        assert_eq!(nome, "caixa-teia");
7814        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia!sudo");
7815        assert!(
7816            reason.contains("must not contain `!`"),
7817            "reason must surface the shell-history-expansion arm, got {reason:?}"
7818        );
7819        assert!(
7820            reason.contains("history-expansion") || reason.contains("bang"),
7821            "reason must name the shell-history-expansion / bang rationale, got {reason:?}"
7822        );
7823    }
7824
7825    #[test]
7826    fn validate_rejects_git_fonte_with_repo_carrying_double_bang_history_reference() {
7827        // The symmetric `!!` repeat-prior-command pin: an author paste-
7828        // trims a `git clone <url>` retry idiom from shell history that
7829        // expands to the previous command via `!!`. Pinned separately
7830        // from the wrapped `!command` shape so a future diagnostic-
7831        // surface change that only checked the leading or paired-bang
7832        // position surfaces here — the per-byte arm fires anywhere `!`
7833        // appears in the value.
7834        let d = dep_with_fonte(DepSource::Git {
7835            repo: "github:pleme-io/caixa-teia!!".into(),
7836            tag: Some("v0.1.0".into()),
7837            rev: None,
7838            branch: None,
7839        });
7840        let err = d.validate().unwrap_err();
7841        let DepError::FonteRepoShape { reason, .. } = err else {
7842            panic!("expected FonteRepoShape, got other variant");
7843        };
7844        assert!(
7845            reason.contains("must not contain `!`"),
7846            "reason must surface the shell-history-expansion arm on the trailing-`!!` shape, \
7847             got {reason:?}"
7848        );
7849    }
7850
7851    #[test]
7852    fn fonte_repo_fragment_fires_before_bang_when_fragment_first() {
7853        // Cascade pin: the fragment-`#` arm and the bang arm are both
7854        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
7855        // so the byte that appears first in the value's byte order
7856        // wins. A `:repo "https://github.com/p/x#readme!tail"` carries
7857        // both `#` and `!`; the `#` byte appears first, so the
7858        // fragment-`#` arm fires, surfacing the more self-locating
7859        // diagnostic on the byte the author pasted earliest in the URL.
7860        let d = dep_with_fonte(DepSource::Git {
7861            repo: "https://github.com/pleme-io/caixa-teia#readme!tail".into(),
7862            tag: Some("v0.1.0".into()),
7863            rev: None,
7864            branch: None,
7865        });
7866        let err = d.validate().unwrap_err();
7867        let DepError::FonteRepoShape { reason, .. } = err else {
7868            panic!("expected FonteRepoShape, got other variant");
7869        };
7870        assert!(
7871            reason.contains("must not contain `#`"),
7872            "reason must surface the fragment-`#` arm (fires before bang when `#` byte \
7873             appears first in value), got {reason:?}"
7874        );
7875    }
7876
7877    #[test]
7878    fn fonte_repo_single_quote_fires_before_bang_when_single_quote_first() {
7879        // Cascade pin: the single-quote-`'` arm (the immediate-predecessor
7880        // byte-class arm, e7a109f) and the bang arm are both per-byte
7881        // arms inside the same `for &b in s.as_bytes()` loop, so the
7882        // byte that appears first in the value's byte order wins. A
7883        // `:repo "github:p/x'mid!tail"` carries both `'` and `!`; the
7884        // `'` byte appears first, so the single-quote arm fires,
7885        // surfacing the more self-locating diagnostic on the byte the
7886        // author pasted earliest in the URL. Pins the natural-order
7887        // cascade so a future reorder of the per-byte arms surfaces
7888        // here — `!` is the most recent byte-class arm, so the
7889        // cascade-pin sweep extends to cover the immediately prior `'`
7890        // byte arm firing first when ordered ahead of `!` in the value.
7891        let d = dep_with_fonte(DepSource::Git {
7892            repo: "github:pleme-io/caixa-teia'mid!tail".into(),
7893            tag: Some("v0.1.0".into()),
7894            rev: None,
7895            branch: None,
7896        });
7897        let err = d.validate().unwrap_err();
7898        let DepError::FonteRepoShape { reason, .. } = err else {
7899            panic!("expected FonteRepoShape, got other variant");
7900        };
7901        assert!(
7902            reason.contains("must not contain `'`"),
7903            "reason must surface the single-quote arm (fires before bang when `'` byte \
7904             appears first in value), got {reason:?}"
7905        );
7906    }
7907
7908    #[test]
7909    fn validate_rejects_git_fonte_with_repo_carrying_list_separator_comma() {
7910        // The fail-before-pass-after pin for the canonical
7911        // list-separator-belongs-to-list-grammar footgun on `:repo`.
7912        // An author copies a `git clone <a>, <b>, <c>` paste-from-CSV
7913        // one-liner from a multi-repo bootstrap doc, intending the
7914        // comma to separate multiple repo entries but the typed
7915        // `:repo` slot names *one* repo (the list-separator belongs
7916        // to the `:deps` list grammar, not to the value). Until this
7917        // arm landed the `,` byte silently passed every prior
7918        // `is_git_repo_url` arm (no whitespace, no control chars, no
7919        // non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no `<`/`>`,
7920        // no `` ` ``, no `|`, no `;`, no `&`, no `$`, no `*`, no
7921        // `(`/`)`, no `"`, no `'`, no `!`, doesn't start with `-` or
7922        // `:`); the byte rode into the lacre's per-dep content-
7923        // address and the resolver's `git clone <repo>` subprocess
7924        // invocation, where no host's repo registry resolved the
7925        // comma-bearing slug.
7926        let d = dep_with_fonte(DepSource::Git {
7927            repo: "github:pleme-io/caixa-teia,github:pleme-io/caixa-feira".into(),
7928            tag: Some("v0.1.0".into()),
7929            rev: None,
7930            branch: None,
7931        });
7932        let err = d.validate().unwrap_err();
7933        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7934            panic!("expected FonteRepoShape, got other variant");
7935        };
7936        assert_eq!(nome, "caixa-teia");
7937        assert_eq!(
7938            repo,
7939            "github:pleme-io/caixa-teia,github:pleme-io/caixa-feira"
7940        );
7941        assert!(
7942            reason.contains("must not contain `,`"),
7943            "reason must surface the list-separator-comma arm, got {reason:?}"
7944        );
7945        assert!(
7946            reason.contains("list-separator") || reason.contains("sub-delims"),
7947            "reason must name the list-separator / RFC-3986-sub-delims rationale, \
7948             got {reason:?}"
7949        );
7950    }
7951
7952    #[test]
7953    fn validate_rejects_git_fonte_with_repo_carrying_trailing_comma() {
7954        // The symmetric trailing-`,` paste-from-prose pin: an author
7955        // writes `:repo "github:pleme-io/caixa-feira,"` (the trailing
7956        // comma every README-prose list-of-projects sentence carries,
7957        // mistakenly retained when the slug is pasted mid-sentence)
7958        // expecting the substrate to coerce it to a kebab-case slug.
7959        // Pinned separately from the wrapped mid-token shape so a
7960        // future diagnostic-surface change that only checked the
7961        // leading or paired-comma position surfaces here — the
7962        // per-byte arm fires anywhere `,` appears in the value.
7963        let d = dep_with_fonte(DepSource::Git {
7964            repo: "github:pleme-io/caixa-feira,".into(),
7965            tag: Some("v0.1.0".into()),
7966            rev: None,
7967            branch: None,
7968        });
7969        let err = d.validate().unwrap_err();
7970        let DepError::FonteRepoShape { reason, .. } = err else {
7971            panic!("expected FonteRepoShape, got other variant");
7972        };
7973        assert!(
7974            reason.contains("must not contain `,`"),
7975            "reason must surface the list-separator-comma arm on the trailing-`,` shape, \
7976             got {reason:?}"
7977        );
7978    }
7979
7980    #[test]
7981    fn fonte_repo_fragment_fires_before_comma_when_fragment_first() {
7982        // Cascade pin: the fragment-`#` arm and the comma arm are
7983        // both per-byte arms inside the same `for &b in s.as_bytes()`
7984        // loop, so the byte that appears first in the value's byte
7985        // order wins. A `:repo "https://github.com/p/x#readme,tail"`
7986        // carries both `#` and `,`; the `#` byte appears first, so
7987        // the fragment-`#` arm fires, surfacing the more self-
7988        // locating diagnostic on the byte the author pasted earliest
7989        // in the URL.
7990        let d = dep_with_fonte(DepSource::Git {
7991            repo: "https://github.com/pleme-io/caixa-teia#readme,tail".into(),
7992            tag: Some("v0.1.0".into()),
7993            rev: None,
7994            branch: None,
7995        });
7996        let err = d.validate().unwrap_err();
7997        let DepError::FonteRepoShape { reason, .. } = err else {
7998            panic!("expected FonteRepoShape, got other variant");
7999        };
8000        assert!(
8001            reason.contains("must not contain `#`"),
8002            "reason must surface the fragment-`#` arm (fires before comma when `#` byte \
8003             appears first in value), got {reason:?}"
8004        );
8005    }
8006
8007    #[test]
8008    fn fonte_repo_bang_fires_before_comma_when_bang_first() {
8009        // Cascade pin: the bang-`!` arm (the immediate-predecessor
8010        // byte-class arm, 7d53c68) and the comma arm are both
8011        // per-byte arms inside the same `for &b in s.as_bytes()`
8012        // loop, so the byte that appears first in the value's byte
8013        // order wins. A `:repo "github:p/x!mid,tail"` carries both
8014        // `!` and `,`; the `!` byte appears first, so the bang arm
8015        // fires, surfacing the more self-locating diagnostic on the
8016        // byte the author pasted earliest in the URL. Pins the
8017        // natural-order cascade so a future reorder of the per-byte
8018        // arms surfaces here — `,` is the most recent byte-class
8019        // arm, so the cascade-pin sweep extends to cover the
8020        // immediately prior `!` byte arm firing first when ordered
8021        // ahead of `,` in the value.
8022        let d = dep_with_fonte(DepSource::Git {
8023            repo: "github:pleme-io/caixa-teia!mid,tail".into(),
8024            tag: Some("v0.1.0".into()),
8025            rev: None,
8026            branch: None,
8027        });
8028        let err = d.validate().unwrap_err();
8029        let DepError::FonteRepoShape { reason, .. } = err else {
8030            panic!("expected FonteRepoShape, got other variant");
8031        };
8032        assert!(
8033            reason.contains("must not contain `!`"),
8034            "reason must surface the bang arm (fires before comma when `!` byte \
8035             appears first in value), got {reason:?}"
8036        );
8037    }
8038
8039    #[test]
8040    fn validate_rejects_git_fonte_with_repo_carrying_shell_env_var_assignment() {
8041        // The fail-before-pass-after pin for the canonical
8042        // shell-env-var-assignment-belongs-to-shell-grammar footgun
8043        // on `:repo`. An author copies
8044        // `GIT_TERMINAL_PROMPT=0 git clone <url>` (or
8045        // `GIT_SSL_NO_VERIFY=1 git clone <url>`, `HTTPS_PROXY=…
8046        // git clone <url>`, etc. — the canonical
8047        // git-troubleshooting README idiom for a one-shot env-var
8048        // scoped to the `git clone` invocation) from a shell-prompt
8049        // one-liner, intending the `KEY=VALUE` prefix as a shell-
8050        // grammar env-var assignment but the typed `:repo` slot is
8051        // a value parser, not a shell context, so the bytes ride
8052        // into the value verbatim. Until this arm landed the `=`
8053        // byte silently passed every prior `is_git_repo_url` arm
8054        // (no whitespace, no control chars, no non-ASCII, no `#`,
8055        // no `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no
8056        // `|`, no `;`, no `&`, no `$`, no `*`, no `(`/`)`, no `"`,
8057        // no `'`, no `!`, no `,`, doesn't start with `-` or `:`);
8058        // the byte rode into the lacre's per-dep content-address
8059        // and the resolver's `git clone <repo>` subprocess
8060        // invocation, where the upstream host's git porcelain
8061        // fetched a literal `GIT_TERMINAL_PROMPT=0 https://…`-shaped
8062        // path that no host's repo registry resolves.
8063        let d = dep_with_fonte(DepSource::Git {
8064            repo: "GIT_TERMINAL_PROMPT=0 https://github.com/pleme-io/caixa-teia".into(),
8065            tag: Some("v0.1.0".into()),
8066            rev: None,
8067            branch: None,
8068        });
8069        let err = d.validate().unwrap_err();
8070        let DepError::FonteRepoShape { nome, repo, reason } = err else {
8071            panic!("expected FonteRepoShape, got other variant");
8072        };
8073        assert_eq!(nome, "caixa-teia");
8074        assert_eq!(
8075            repo,
8076            "GIT_TERMINAL_PROMPT=0 https://github.com/pleme-io/caixa-teia"
8077        );
8078        // The `=` byte at position 19 of `GIT_TERMINAL_PROMPT=0 …`
8079        // appears before the ` ` byte at position 21, so the `=`
8080        // arm fires (not the whitespace arm) — both arms guard
8081        // the slot, but the per-byte for-loop scans left-to-right
8082        // and the first matching byte wins.
8083        assert!(
8084            reason.contains("must not contain `=`"),
8085            "reason must surface the equals-`=` arm on the env-var-assignment \
8086             paste shape, got {reason:?}"
8087        );
8088        assert!(
8089            reason.contains("env-var-assignment") || reason.contains("KEY=VALUE"),
8090            "reason must name the shell-env-var-assignment rationale, got {reason:?}"
8091        );
8092    }
8093
8094    #[test]
8095    fn validate_rejects_git_fonte_with_repo_carrying_gitconfig_url_key_prefix() {
8096        // The symmetric paste-from-gitconfig pin: an author copies
8097        // `url=https://github.com/p/x` from `git config --get-all
8098        // remote.origin.url` output, a `.gitconfig` `[remote
8099        // "origin"] url = https://…` ini-stanza paste, or a
8100        // `git config remote.origin.url <value>` doc snippet,
8101        // intending the `url=` prefix as the ini-key but the typed
8102        // `:repo` slot is a URL value parser, not a gitconfig
8103        // grammar. With no leading whitespace and no earlier-arm
8104        // bytes in the value, the `=` arm itself fires (rather
8105        // than cascading to the whitespace arm as in the env-var
8106        // paste shape). Pinned separately so a future diagnostic-
8107        // surface change that only checked the whitespace-leading
8108        // shape surfaces here — the per-byte arm fires anywhere
8109        // `=` appears in the value.
8110        let d = dep_with_fonte(DepSource::Git {
8111            repo: "url=https://github.com/pleme-io/caixa-feira".into(),
8112            tag: Some("v0.1.0".into()),
8113            rev: None,
8114            branch: None,
8115        });
8116        let err = d.validate().unwrap_err();
8117        let DepError::FonteRepoShape { reason, .. } = err else {
8118            panic!("expected FonteRepoShape, got other variant");
8119        };
8120        assert!(
8121            reason.contains("must not contain `=`"),
8122            "reason must surface the equals-`=` arm on the `url=…` gitconfig \
8123             paste shape, got {reason:?}"
8124        );
8125        assert!(
8126            reason.contains("key-value-separator") || reason.contains("sub-delims"),
8127            "reason must name the key-value-separator / RFC-3986-sub-delims \
8128             rationale, got {reason:?}"
8129        );
8130    }
8131
8132    #[test]
8133    fn fonte_repo_fragment_fires_before_equals_when_fragment_first() {
8134        // Cascade pin: the fragment-`#` arm and the `=` arm are
8135        // both per-byte arms inside the same `for &b in s.as_bytes()`
8136        // loop, so the byte that appears first in the value's byte
8137        // order wins. A `:repo "https://github.com/p/x#readme=tail"`
8138        // carries both `#` and `=`; the `#` byte appears first, so
8139        // the fragment-`#` arm fires, surfacing the more self-
8140        // locating diagnostic on the byte the author pasted earliest
8141        // in the URL.
8142        let d = dep_with_fonte(DepSource::Git {
8143            repo: "https://github.com/pleme-io/caixa-teia#readme=tail".into(),
8144            tag: Some("v0.1.0".into()),
8145            rev: None,
8146            branch: None,
8147        });
8148        let err = d.validate().unwrap_err();
8149        let DepError::FonteRepoShape { reason, .. } = err else {
8150            panic!("expected FonteRepoShape, got other variant");
8151        };
8152        assert!(
8153            reason.contains("must not contain `#`"),
8154            "reason must surface the fragment-`#` arm (fires before equals when \
8155             `#` byte appears first in value), got {reason:?}"
8156        );
8157    }
8158
8159    #[test]
8160    fn fonte_repo_comma_fires_before_equals_when_comma_first() {
8161        // Cascade pin: the comma-`,` arm (the immediate-predecessor
8162        // byte-class arm, 775b80e) and the `=` arm are both per-byte
8163        // arms inside the same `for &b in s.as_bytes()` loop, so
8164        // the byte that appears first in the value's byte order
8165        // wins. A `:repo "github:p/x,mid=tail"` carries both `,`
8166        // and `=`; the `,` byte appears first, so the comma arm
8167        // fires, surfacing the more self-locating diagnostic on
8168        // the byte the author pasted earliest in the URL. Pins the
8169        // natural-order cascade so a future reorder of the per-byte
8170        // arms surfaces here — `=` is the most recent byte-class
8171        // arm, so the cascade-pin sweep extends to cover the
8172        // immediately prior `,` byte arm firing first when ordered
8173        // ahead of `=` in the value.
8174        let d = dep_with_fonte(DepSource::Git {
8175            repo: "github:pleme-io/caixa-teia,mid=tail".into(),
8176            tag: Some("v0.1.0".into()),
8177            rev: None,
8178            branch: None,
8179        });
8180        let err = d.validate().unwrap_err();
8181        let DepError::FonteRepoShape { reason, .. } = err else {
8182            panic!("expected FonteRepoShape, got other variant");
8183        };
8184        assert!(
8185            reason.contains("must not contain `,`"),
8186            "reason must surface the comma arm (fires before equals when `,` byte \
8187             appears first in value), got {reason:?}"
8188        );
8189    }
8190
8191    #[test]
8192    fn validate_rejects_git_fonte_with_repo_carrying_percent_encoded_space() {
8193        // The fail-before-pass-after pin for the canonical paste-from-
8194        // browser-address-bar percent-encoded-space footgun on `:repo`.
8195        // An author copies `https://github.com/p/x%20test` from a
8196        // browser address bar (or a percent-encoded README hyperlink,
8197        // or a `curl --data-urlencode` shell-pipeline output)
8198        // intending `%20` as the URL encoding of a literal space; the
8199        // typed `:repo` slot already rejects the literal space byte
8200        // (the whitespace arm at the top of `is_git_repo_url`), so an
8201        // author trying to express "I really meant a space" reaches
8202        // for percent-encoding. Until this arm landed the `%` byte
8203        // silently passed every prior `is_git_repo_url` arm and rode
8204        // verbatim into the lacre's per-dep content-address — but
8205        // libcurl re-percent-encodes `%` to `%25` on the wire (since
8206        // `%` is reserved as the escape-sequence lead-in), so the
8207        // wire request becomes `https://github.com/p/x%2520test`, a
8208        // path the lacre's content-address never names. The classic
8209        // render-determinism violation on the encoding-mechanism axis
8210        // itself.
8211        let d = dep_with_fonte(DepSource::Git {
8212            repo: "https://github.com/pleme-io/caixa-teia%20test".into(),
8213            tag: Some("v0.1.0".into()),
8214            rev: None,
8215            branch: None,
8216        });
8217        let err = d.validate().unwrap_err();
8218        let DepError::FonteRepoShape { nome, repo, reason } = err else {
8219            panic!("expected FonteRepoShape, got other variant");
8220        };
8221        assert_eq!(nome, "caixa-teia");
8222        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia%20test");
8223        assert!(
8224            reason.contains("must not contain `%`"),
8225            "reason must surface the percent-`%` arm on the percent-encoded-space \
8226             paste shape, got {reason:?}"
8227        );
8228        assert!(
8229            reason.contains("percent-encoding") || reason.contains("%25"),
8230            "reason must name the percent-encoding / `%25` re-encoding rationale, \
8231             got {reason:?}"
8232        );
8233    }
8234
8235    #[test]
8236    fn validate_rejects_git_fonte_with_repo_carrying_percent_encoded_slash() {
8237        // The symmetric over-encoded-path-separator pin: an author
8238        // writes `:repo "https://github.com/p%2Fx"` intending the
8239        // `%2F` as the URL encoding of `/` (the canonical
8240        // paste-from-OpenAPI-spec / paste-from-percent-encoded-template
8241        // footgun every API client library and OAuth redirect-URI
8242        // documentation surfaces — the `/` is the URL-path-separator
8243        // and some templates percent-encode it to escape interpretation
8244        // as a path separator). The GitHub Smart-HTTP transport
8245        // resolves the URL's path-segment grammar before the
8246        // percent-decoding pass, so the value identifies a different
8247        // resource on the wire than the literal-`/` form the lacre's
8248        // content-address must agree with — two authors whose `:repo`
8249        // values differ only in their `/` vs `%2F` presence lock to
8250        // two distinct BLAKE3 closures for the byte-identical upstream
8251        // `git clone`. Pinned separately so a future diagnostic
8252        // surface that only catches the `%20` shape surfaces here too.
8253        let d = dep_with_fonte(DepSource::Git {
8254            repo: "https://github.com/pleme-io%2Fcaixa-teia".into(),
8255            tag: Some("v0.1.0".into()),
8256            rev: None,
8257            branch: None,
8258        });
8259        let err = d.validate().unwrap_err();
8260        let DepError::FonteRepoShape { reason, .. } = err else {
8261            panic!("expected FonteRepoShape, got other variant");
8262        };
8263        assert!(
8264            reason.contains("must not contain `%`"),
8265            "reason must surface the percent-`%` arm on the over-encoded-path \
8266             shape, got {reason:?}"
8267        );
8268        assert!(
8269            reason.contains("render-determinism") || reason.contains("BLAKE3"),
8270            "reason must name the render-determinism / BLAKE3-closure rationale, \
8271             got {reason:?}"
8272        );
8273    }
8274
8275    #[test]
8276    fn fonte_repo_fragment_fires_before_percent_when_fragment_first() {
8277        // Cascade pin: the fragment-`#` arm and the `%` arm are both
8278        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
8279        // so the byte that appears first in the value's byte order
8280        // wins. A `:repo "https://github.com/p/x#sec%20tail"` carries
8281        // both `#` and `%`; the `#` byte appears first, so the
8282        // fragment-`#` arm fires, surfacing the more self-locating
8283        // diagnostic on the byte the author pasted earliest in the URL.
8284        let d = dep_with_fonte(DepSource::Git {
8285            repo: "https://github.com/pleme-io/caixa-teia#sec%20tail".into(),
8286            tag: Some("v0.1.0".into()),
8287            rev: None,
8288            branch: None,
8289        });
8290        let err = d.validate().unwrap_err();
8291        let DepError::FonteRepoShape { reason, .. } = err else {
8292            panic!("expected FonteRepoShape, got other variant");
8293        };
8294        assert!(
8295            reason.contains("must not contain `#`"),
8296            "reason must surface the fragment-`#` arm (fires before percent when \
8297             `#` byte appears first in value), got {reason:?}"
8298        );
8299    }
8300
8301    #[test]
8302    fn fonte_repo_equals_fires_before_percent_when_equals_first() {
8303        // Cascade pin: the equals-`=` arm (the immediate-predecessor
8304        // byte-class arm, acf99af) and the `%` arm are both per-byte
8305        // arms inside the same `for &b in s.as_bytes()` loop, so the
8306        // byte that appears first in the value's byte order wins.
8307        // A `:repo "github:p/x=mid%20tail"` carries both `=` and `%`;
8308        // the `=` byte appears first, so the equals arm fires,
8309        // surfacing the more self-locating diagnostic on the byte the
8310        // author pasted earliest in the URL. Pins the natural-order
8311        // cascade so a future reorder of the per-byte arms surfaces
8312        // here — `%` is the most recent byte-class arm, so the
8313        // cascade-pin sweep extends to cover the immediately prior
8314        // `=` byte arm firing first when ordered ahead of `%` in the
8315        // value.
8316        let d = dep_with_fonte(DepSource::Git {
8317            repo: "github:pleme-io/caixa-teia=mid%20tail".into(),
8318            tag: Some("v0.1.0".into()),
8319            rev: None,
8320            branch: None,
8321        });
8322        let err = d.validate().unwrap_err();
8323        let DepError::FonteRepoShape { reason, .. } = err else {
8324            panic!("expected FonteRepoShape, got other variant");
8325        };
8326        assert!(
8327            reason.contains("must not contain `=`"),
8328            "reason must surface the equals arm (fires before percent when `=` byte \
8329             appears first in value), got {reason:?}"
8330        );
8331    }
8332
8333    #[test]
8334    fn validate_rejects_git_fonte_with_repo_carrying_caret_history_substitution() {
8335        // The fail-before-pass-after pin for the canonical paste-from-
8336        // shell-history footgun on `:repo`. An author copies a
8337        // `git clone <url>` line from their terminal followed by a
8338        // bash / ksh / zsh `^typo^fix^` quick-edit-and-rerun shell-
8339        // history shorthand (the `^old^new^` form re-runs the prior
8340        // history entry with the first `old` substituted by `new`,
8341        // bash's default behavior on interactive sessions with
8342        // `set -o histexpand`), forgetting to trim the trailing
8343        // `^...^...` shell-history fragment from the URL value. The
8344        // `^` byte sits in the RFC 3986 §2 'unwise' set (peer with
8345        // `{`, `}`, `|`, `\\` — the strictest of the §2 reserved
8346        // classes), the WHATWG URL spec's 'fragment percent-encode
8347        // set' maps `^` → `%5E` on the wire, so the byte rides
8348        // verbatim into the lacre's per-dep content-address but
8349        // libcurl re-encodes it to `%5E` at `git clone` time — the
8350        // classic render-determinism violation on the same axis the
8351        // peer `%`, `=`, `,`, `!`, `'`, `"`, `(`, `)`, `*`, `$`,
8352        // `&`, `;`, `|`, backtick, `<`, `>`, `{`, `}`, `\\`, `?`,
8353        // `#` arms close.
8354        let d = dep_with_fonte(DepSource::Git {
8355            repo: "https://github.com/pleme-io/caixa-teia^typo^fix".into(),
8356            tag: Some("v0.1.0".into()),
8357            rev: None,
8358            branch: None,
8359        });
8360        let err = d.validate().unwrap_err();
8361        let DepError::FonteRepoShape { nome, repo, reason } = err else {
8362            panic!("expected FonteRepoShape, got other variant");
8363        };
8364        assert_eq!(nome, "caixa-teia");
8365        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia^typo^fix");
8366        assert!(
8367            reason.contains("must not contain `^`"),
8368            "reason must surface the caret-`^` arm on the paste-from-shell-history \
8369             shape, got {reason:?}"
8370        );
8371        assert!(
8372            reason.contains("history-substitution") || reason.contains("%5E"),
8373            "reason must name the shell-history-substitution / `%5E` wire-encoding \
8374             rationale, got {reason:?}"
8375        );
8376    }
8377
8378    #[test]
8379    fn validate_rejects_git_fonte_with_repo_carrying_caret_regex_anchor() {
8380        // The symmetric paste-from-doc-grep-pipeline footgun: an
8381        // author writes `:repo "github:p/^archived"` after copying a
8382        // `grep '^archived'` regex-anchor / negation idiom from a
8383        // doc / README quick-listing snippet, expecting the substrate
8384        // to coerce it to a literal repo name. The byte rides
8385        // verbatim into the lacre's per-dep content-address and
8386        // diverges from the byte-identical literal `archived` form
8387        // every other author authored — the canonical render-
8388        // determinism violation pin on the second footgun shape the
8389        // caret-`^` arm closes.
8390        let d = dep_with_fonte(DepSource::Git {
8391            repo: "github:pleme-io/^archived".into(),
8392            tag: Some("v0.1.0".into()),
8393            rev: None,
8394            branch: None,
8395        });
8396        let err = d.validate().unwrap_err();
8397        let DepError::FonteRepoShape { reason, .. } = err else {
8398            panic!("expected FonteRepoShape, got other variant");
8399        };
8400        assert!(
8401            reason.contains("must not contain `^`"),
8402            "reason must surface the caret-`^` arm on the regex-anchor shape, \
8403             got {reason:?}"
8404        );
8405        assert!(
8406            reason.contains("render-determinism") || reason.contains("BLAKE3"),
8407            "reason must name the render-determinism / BLAKE3-closure rationale, \
8408             got {reason:?}"
8409        );
8410    }
8411
8412    #[test]
8413    fn fonte_repo_percent_fires_before_caret_when_percent_first() {
8414        // Cascade pin: the `%` arm (the immediate-predecessor byte-
8415        // class arm, a323db8) and the `^` arm are both per-byte arms
8416        // inside the same `for &b in s.as_bytes()` loop, so the byte
8417        // that appears first in the value's byte order wins. A
8418        // `:repo "https://github.com/p/x%20mid^tail"` carries both
8419        // `%` and `^`; the `%` byte appears first, so the percent
8420        // arm fires, surfacing the more self-locating diagnostic on
8421        // the byte the author pasted earliest in the URL. Pins the
8422        // natural-order cascade so a future reorder of the per-byte
8423        // arms surfaces here — `^` is the most recent byte-class arm,
8424        // so the cascade-pin sweep extends to cover the immediately
8425        // prior `%` byte arm firing first when ordered ahead of `^`
8426        // in the value.
8427        let d = dep_with_fonte(DepSource::Git {
8428            repo: "https://github.com/pleme-io/caixa-teia%20mid^tail".into(),
8429            tag: Some("v0.1.0".into()),
8430            rev: None,
8431            branch: None,
8432        });
8433        let err = d.validate().unwrap_err();
8434        let DepError::FonteRepoShape { reason, .. } = err else {
8435            panic!("expected FonteRepoShape, got other variant");
8436        };
8437        assert!(
8438            reason.contains("must not contain `%`"),
8439            "reason must surface the percent arm (fires before caret when `%` byte \
8440             appears first in value), got {reason:?}"
8441        );
8442    }
8443
8444    #[test]
8445    fn validate_rejects_git_fonte_with_repo_missing_colon_separator() {
8446        // The "I dropped the scheme" footgun — `:repo "pleme-io/caixa-teia"`
8447        // (no `github:` prefix, no scheme). Every documented form
8448        // carries a `:` (`github:`, `https://`, `ssh://`, `git://`,
8449        // `file://`, or `git@host:path`); a bare `org/repo` is
8450        // ambiguous (`git clone` reads as a relative filesystem path
8451        // rather than the GitHub-shorthand expansion the author
8452        // probably intended) and the gate rejects the shape upstream.
8453        let d = dep_with_fonte(DepSource::Git {
8454            repo: "pleme-io/caixa-teia".into(),
8455            tag: Some("v0.1.0".into()),
8456            rev: None,
8457            branch: None,
8458        });
8459        let err = d.validate().unwrap_err();
8460        let DepError::FonteRepoShape { reason, .. } = err else {
8461            panic!("expected FonteRepoShape, got other variant");
8462        };
8463        assert!(
8464            reason.contains("must contain a `:`"),
8465            "reason must surface the missing-`:` arm, got {reason:?}"
8466        );
8467        assert!(
8468            reason.contains("github:"),
8469            "reason must name the canonical `github:` shorthand prefix, got {reason:?}"
8470        );
8471    }
8472
8473    #[test]
8474    fn validate_rejects_git_fonte_with_repo_leading_colon() {
8475        // The "empty scheme" footgun — `:repo ":foo"` has a zero-length
8476        // scheme that no git porcelain entry-point accepts. Pinned
8477        // separately from the missing-`:` arm because a value with a
8478        // leading `:` does technically contain a `:` separator; the
8479        // shape gate rejects on a dedicated arm so the diagnostic
8480        // names the specific footgun.
8481        let d = dep_with_fonte(DepSource::Git {
8482            repo: ":pleme-io/caixa-teia".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 start with `:`"),
8493            "reason must surface the leading-`:` arm, got {reason:?}"
8494        );
8495    }
8496
8497    #[test]
8498    fn validate_rejects_git_fonte_with_repo_too_long() {
8499        // The cap arm — a `:repo` value longer than
8500        // [`crate::render::GIT_REPO_URL_MAX_LEN`] (2048) bytes is
8501        // structurally untenable on every realistic landing site (the
8502        // resolver's `git clone` invocation, the future M4 CR
8503        // materializer's per-dep `repo:` axis); a value of that length
8504        // is almost certainly a paste-from-binary slug.
8505        let too_long = format!(
8506            "github:pleme-io/{}",
8507            "x".repeat(crate::render::GIT_REPO_URL_MAX_LEN)
8508        );
8509        let d = dep_with_fonte(DepSource::Git {
8510            repo: too_long.clone(),
8511            tag: Some("v0.1.0".into()),
8512            rev: None,
8513            branch: None,
8514        });
8515        let err = d.validate().unwrap_err();
8516        let DepError::FonteRepoShape { reason, .. } = err else {
8517            panic!("expected FonteRepoShape, got other variant");
8518        };
8519        assert!(
8520            reason.contains("2048"),
8521            "reason must name the cap, got {reason:?}"
8522        );
8523    }
8524
8525    #[test]
8526    fn validate_accepts_canonical_git_fonte_repo_shapes() {
8527        // The positive-control sweep: every documented author shape on
8528        // the `:fonte :repo` axis ([`crate::DepSource::Git`] doc comment)
8529        // must pass the value-shape gate. Pinned so a future tightening
8530        // (e.g. forbidding `http://` in favor of `https://`-only) surfaces
8531        // here as a structural decision. Each form is exercised with the
8532        // same canonical `:tag` pin so only the `:repo` axis varies.
8533        for repo in [
8534            // The pleme-io registry-shorthand convention — `github:org/repo`.
8535            "github:pleme-io/caixa-teia",
8536            // Other host-aliased shorthands (the resolver's pluggable
8537            // host-prefix table).
8538            "gitlab:pleme-io/caixa-teia",
8539            "codeberg:pleme-io/caixa-teia",
8540            "sourcehut:~pleme-io/caixa-teia",
8541            // Full HTTPS URL with and without `.git` suffix.
8542            "https://github.com/pleme-io/caixa-teia",
8543            "https://github.com/pleme-io/caixa-teia.git",
8544            // HTTP (rare; dev / mirror).
8545            "http://example.com/pleme-io/caixa-teia.git",
8546            // SSH URL.
8547            "ssh://git@github.com/pleme-io/caixa-teia.git",
8548            "ssh://git@git.example.com:2222/pleme-io/caixa-teia.git",
8549            // Scp-style SSH — the canonical `git@host:path` short form.
8550            "git@github.com:pleme-io/caixa-teia.git",
8551            "git@git.example.com:team/private.git",
8552            // Anonymous git protocol.
8553            "git://git.example.com/pleme-io/caixa-teia.git",
8554            // Local file URL (dev path).
8555            "file:///tmp/caixa-teia",
8556        ] {
8557            let d = dep_with_fonte(DepSource::Git {
8558                repo: repo.into(),
8559                tag: Some("v0.1.0".into()),
8560                rev: None,
8561                branch: None,
8562            });
8563            d.validate()
8564                .unwrap_or_else(|e| panic!("canonical repo {repo:?} must validate, got {e:?}"));
8565        }
8566    }
8567
8568    #[test]
8569    fn fonte_repo_empty_takes_precedence_over_shape() {
8570        // Order pin: the existing `FonteRepoEmpty` diagnostic (narrower
8571        // diagnostic; doesn't try to parse the URL shape) fires before
8572        // the new `FonteRepoShape` per-axis gate, so an empty `:repo`
8573        // keeps its narrower error message. Mirrors
8574        // `fonte_repo_empty_fires_before_pin_missing` (already pinned)
8575        // on the ordering layer.
8576        let d = dep_with_fonte(DepSource::Git {
8577            repo: String::new(),
8578            tag: Some("v0.1.0".into()),
8579            rev: None,
8580            branch: None,
8581        });
8582        let err = d.validate().unwrap_err();
8583        assert!(
8584            matches!(err, DepError::FonteRepoEmpty { .. }),
8585            "got {err:?}"
8586        );
8587    }
8588
8589    #[test]
8590    fn fonte_repo_shape_fires_before_pin_missing() {
8591        // Order pin: a malformed `:repo` value on a dep with no pin set
8592        // surfaces the `:repo` shape diagnostic (the more self-locating
8593        // axis — the `:repo` is the load-bearing identity of the source;
8594        // a missing pin is downstream from "do we even know the repo")
8595        // rather than collapsing onto the pin-missing diagnostic. The
8596        // shape gate runs inline before the pin enumeration in
8597        // `DepSource::validate`.
8598        let d = dep_with_fonte(DepSource::Git {
8599            repo: "pleme-io/caixa-teia".into(), // missing `:` separator
8600            tag: None,
8601            rev: None,
8602            branch: None,
8603        });
8604        let err = d.validate().unwrap_err();
8605        assert!(
8606            matches!(err, DepError::FonteRepoShape { .. }),
8607            "got {err:?}"
8608        );
8609    }
8610
8611    #[test]
8612    fn fonte_repo_shape_diagnostic_carries_offending_repo_verbatim() {
8613        // The diagnostic-shape pin: the error names the offending
8614        // `:repo` value verbatim plus a non-empty parser-shaped `reason`
8615        // so the author can grep their caixa.lisp without re-running
8616        // the build. Mirrors the diagnostic-shape sweep on every prior
8617        // value-shape gate (3f9d7a0, 6cbb900, c7d05ec, e70d213, be07fd5).
8618        let d = dep_with_fonte(DepSource::Git {
8619            repo: "pleme-io/caixa-teia".into(),
8620            tag: Some("v0.1.0".into()),
8621            rev: None,
8622            branch: None,
8623        });
8624        let err = d.validate().unwrap_err();
8625        let DepError::FonteRepoShape { nome, repo, reason } = err else {
8626            panic!("expected FonteRepoShape, got other variant");
8627        };
8628        assert_eq!(nome, "caixa-teia");
8629        assert_eq!(repo, "pleme-io/caixa-teia");
8630        assert!(
8631            !reason.is_empty(),
8632            "FonteRepoShape `reason` must carry the predicate's wording verbatim"
8633        );
8634    }
8635
8636    #[test]
8637    fn validate_rejects_git_fonte_with_no_pin() {
8638        // The fail-before-pass-after pin for the canonical
8639        // `(:tipo git :repo "github:pleme-io/x")` shape with no
8640        // :tag/:rev/:branch — until this gate landed the resolver's
8641        // ResolveError::MissingPin surfaced at fetch time, far from the
8642        // source caixa.lisp. The new gate moves the check to validate
8643        // time and names the offending dep.
8644        let d = dep_with_fonte(DepSource::Git {
8645            repo: "github:pleme-io/caixa-teia".into(),
8646            tag: None,
8647            rev: None,
8648            branch: None,
8649        });
8650        let err = d.validate().unwrap_err();
8651        assert!(
8652            matches!(err, DepError::FontePinMissing { ref nome } if nome == "caixa-teia"),
8653            "got {err:?}"
8654        );
8655    }
8656
8657    #[test]
8658    fn validate_rejects_git_fonte_with_ambiguous_tag_and_branch() {
8659        // The canonical "pin drift" footgun: an author writes
8660        // `:tag "v1"` and later adds `:branch "main"` without removing
8661        // the :tag, and the resolver silently picks :tag (precedence
8662        // :rev > :tag > :branch). The :branch was dropped with no
8663        // diagnostic. The gate now rejects multi-pin shapes so the
8664        // author makes the precedence explicit at the source.
8665        let d = dep_with_fonte(DepSource::Git {
8666            repo: "github:pleme-io/caixa-teia".into(),
8667            tag: Some("v0.1.0".into()),
8668            rev: None,
8669            branch: Some("main".into()),
8670        });
8671        let err = d.validate().unwrap_err();
8672        let DepError::FontePinAmbiguous { nome, pins } = err else {
8673            panic!("expected FontePinAmbiguous");
8674        };
8675        assert_eq!(nome, "caixa-teia");
8676        assert!(pins.contains(":tag"));
8677        assert!(pins.contains(":branch"));
8678        assert!(!pins.contains(":rev"));
8679    }
8680
8681    #[test]
8682    fn validate_rejects_git_fonte_with_ambiguous_tag_and_rev() {
8683        // Sibling arm of the pin-drift footgun: :tag + :rev set
8684        // simultaneously. Pinned separately so a future relaxation
8685        // that only catches the (:tag, :branch) pair surfaces here.
8686        let d = dep_with_fonte(DepSource::Git {
8687            repo: "github:pleme-io/caixa-teia".into(),
8688            tag: Some("v0.1.0".into()),
8689            rev: Some("c0ffee".into()),
8690            branch: None,
8691        });
8692        let err = d.validate().unwrap_err();
8693        let DepError::FontePinAmbiguous { nome, pins } = err else {
8694            panic!("expected FontePinAmbiguous");
8695        };
8696        assert_eq!(nome, "caixa-teia");
8697        assert!(pins.contains(":tag"));
8698        assert!(pins.contains(":rev"));
8699    }
8700
8701    #[test]
8702    fn validate_rejects_git_fonte_with_all_three_pins() {
8703        // The maximal ambiguity case — every pin axis set. Pinned so a
8704        // future relaxation that only catches pairs surfaces here. The
8705        // diagnostic must enumerate every offending axis so the author
8706        // sees the full set, not just the first match.
8707        let d = dep_with_fonte(DepSource::Git {
8708            repo: "github:pleme-io/caixa-teia".into(),
8709            tag: Some("v0.1.0".into()),
8710            rev: Some("c0ffee".into()),
8711            branch: Some("main".into()),
8712        });
8713        let err = d.validate().unwrap_err();
8714        let DepError::FontePinAmbiguous { nome, pins } = err else {
8715            panic!("expected FontePinAmbiguous");
8716        };
8717        assert_eq!(nome, "caixa-teia");
8718        assert!(pins.contains(":tag"));
8719        assert!(pins.contains(":rev"));
8720        assert!(pins.contains(":branch"));
8721    }
8722
8723    #[test]
8724    fn validate_rejects_git_fonte_with_empty_tag_pin() {
8725        // The empty-pin arm: exactly one pin axis is `Some(_)`, but its
8726        // inner string is empty. Distinct from FontePinMissing (where
8727        // every axis is None) — pinned separately so a future
8728        // tightening collapsing them surfaces here as a structural
8729        // decision.
8730        let d = dep_with_fonte(DepSource::Git {
8731            repo: "github:pleme-io/caixa-teia".into(),
8732            tag: Some(String::new()),
8733            rev: None,
8734            branch: None,
8735        });
8736        let err = d.validate().unwrap_err();
8737        let DepError::FontePinEmpty { nome, pin } = err else {
8738            panic!("expected FontePinEmpty");
8739        };
8740        assert_eq!(nome, "caixa-teia");
8741        assert_eq!(pin, ":tag");
8742    }
8743
8744    #[test]
8745    fn validate_rejects_git_fonte_with_empty_rev_pin() {
8746        // Sibling arm — the empty-pin diagnostic names which axis
8747        // carries the empty value, so the author's grep target is
8748        // unambiguous.
8749        let d = dep_with_fonte(DepSource::Git {
8750            repo: "github:pleme-io/caixa-teia".into(),
8751            tag: None,
8752            rev: Some(String::new()),
8753            branch: None,
8754        });
8755        let err = d.validate().unwrap_err();
8756        let DepError::FontePinEmpty { nome, pin } = err else {
8757            panic!("expected FontePinEmpty");
8758        };
8759        assert_eq!(nome, "caixa-teia");
8760        assert_eq!(pin, ":rev");
8761    }
8762
8763    #[test]
8764    fn validate_rejects_path_fonte_with_empty_caminho() {
8765        // The fail-before-pass-after pin for `(:tipo path :caminho "")`:
8766        // until this gate landed the resolver's
8767        // ResolveError::MissingPath surfaced with `path: PathBuf("")` at
8768        // fetch time — not actionable. The new gate moves the check to
8769        // validate time and names the offending dep.
8770        let d = dep_with_fonte(DepSource::Path {
8771            caminho: String::new(),
8772        });
8773        let err = d.validate().unwrap_err();
8774        assert!(
8775            matches!(err, DepError::FonteCaminhoEmpty { ref nome } if nome == "caixa-teia"),
8776            "got {err:?}"
8777        );
8778    }
8779
8780    #[test]
8781    fn validate_rejects_path_fonte_with_absolute_caminho() {
8782        // The fail-before-pass-after pin for the absolute-`:caminho`
8783        // shape: `(:tipo path :caminho "/home/me/work/caixa-teia")`.
8784        // Until this gate landed an absolute `:caminho` silently
8785        // passed validate; the lacre pipeline embedded the
8786        // host-specific filesystem path verbatim in its
8787        // content-address (`conteudo: format!("path:{caminho}")`,
8788        // caixa-resolver/src/resolve.rs:189), so the BLAKE3 closure
8789        // differed per machine — the build succeeded but two CI
8790        // runners with different `${HOME}` layouts emitted two
8791        // distinct lacres for the byte-identical caixa, silently
8792        // breaking the THEORY.md §V.2 render-determinism contract
8793        // far from the source caixa.lisp. The new gate moves the
8794        // check to validate time and names the offending dep +
8795        // caminho verbatim.
8796        let d = dep_with_fonte(DepSource::Path {
8797            caminho: "/home/me/work/caixa-teia".into(),
8798        });
8799        let err = d.validate().unwrap_err();
8800        let DepError::FonteCaminhoAbsolute { nome, caminho } = err else {
8801            panic!("expected FonteCaminhoAbsolute, got other variant");
8802        };
8803        assert_eq!(nome, "caixa-teia");
8804        assert_eq!(caminho, "/home/me/work/caixa-teia");
8805    }
8806
8807    #[test]
8808    fn validate_accepts_path_fonte_with_parent_escape_caminho() {
8809        // The canonical sibling-workspace dep form
8810        // (`:caminho "../caixa-teia"`) remains accepted. The
8811        // absolute-path gate above is specifically narrower than the
8812        // shared [`crate::render::is_sandboxed_relative_path`]
8813        // predicate (which additionally forbids `..` traversal): a
8814        // local-path dep's canonical author surface is the in-tree
8815        // sibling-workspace path, so a full sandboxed-relative-path
8816        // lift would structurally reject every legitimate path-fonte
8817        // dep. Pinned so a future tightening to the full predicate
8818        // surfaces here as a structural decision, not a silent break.
8819        let d = dep_with_fonte(DepSource::Path {
8820            caminho: "../caixa-teia".into(),
8821        });
8822        d.validate().unwrap();
8823    }
8824
8825    #[test]
8826    fn validate_accepts_path_fonte_with_deeply_nested_relative_caminho() {
8827        // A multi-segment relative `:caminho`
8828        // (`"vendor/forks/caixa-teia"`) remains accepted — the
8829        // absolute-path gate brackets the host-layout-leaking shape
8830        // at the leading-`/` boundary only; every relative shape past
8831        // the empty arm continues to pass. Pinned alongside the
8832        // `..`-traversal positive control so a future tightening
8833        // surfaces the full set of legitimate relative forms here
8834        // rather than at a downstream consumer.
8835        let d = dep_with_fonte(DepSource::Path {
8836            caminho: "vendor/forks/caixa-teia".into(),
8837        });
8838        d.validate().unwrap();
8839    }
8840
8841    #[test]
8842    fn validate_rejects_path_fonte_with_tilde_prefix_caminho() {
8843        // The fail-before-pass-after pin for the tilde-expansion
8844        // `:caminho` shape: `(:tipo path :caminho "~/work/caixa-teia")`.
8845        // Until this gate landed the b94fd83 absolute arm let `~/foo`
8846        // through (`Path::is_absolute` returns false on a leading `~`
8847        // — the tilde is a shell-expansion convention, not a POSIX
8848        // path component), so the lacre embedded the value verbatim
8849        // and the resolver folded it through `Path::join` without
8850        // expansion, looking for a literal `./~/work/caixa-teia`
8851        // subdirectory and failing at resolve time with a
8852        // `No such file or directory` error far from the source
8853        // caixa.lisp. The new gate moves the check to validate time
8854        // and names the offending dep + caminho verbatim.
8855        let d = dep_with_fonte(DepSource::Path {
8856            caminho: "~/work/caixa-teia".into(),
8857        });
8858        let err = d.validate().unwrap_err();
8859        let DepError::FonteCaminhoTildeExpansion { nome, caminho } = err else {
8860            panic!("expected FonteCaminhoTildeExpansion, got {err:?}");
8861        };
8862        assert_eq!(nome, "caixa-teia");
8863        assert_eq!(caminho, "~/work/caixa-teia");
8864    }
8865
8866    #[test]
8867    fn validate_rejects_path_fonte_with_bare_tilde_caminho() {
8868        // The bare `~` form (canonical "I meant `$HOME` and forgot
8869        // the rest"): both the leading-tilde arm catches it and the
8870        // canonical-user-tilde shell idiom (`~alice/dev/caixa-teia`)
8871        // sweeps through the same arm. Pinned both to ensure the
8872        // gate doesn't narrow to `~/` only.
8873        for s in ["~", "~alice/dev/caixa-teia", "~/", "~root/work"] {
8874            let d = dep_with_fonte(DepSource::Path { caminho: s.into() });
8875            let err = d.validate().unwrap_err();
8876            assert!(
8877                matches!(err, DepError::FonteCaminhoTildeExpansion { .. }),
8878                "{s:?} → {err:?}",
8879            );
8880        }
8881    }
8882
8883    #[test]
8884    fn validate_accepts_path_fonte_with_mid_path_tilde_caminho() {
8885        // The leading-`~` is the canonical shell-expansion footgun —
8886        // a tilde mid-path (`"../foo~bar/caixa-teia"` — the canonical
8887        // backup-file-suffix idiom) is a legitimate POSIX path byte
8888        // with no shell-expansion semantic at the leading position.
8889        // Pinned so the gate doesn't widen to a full no-tilde-anywhere
8890        // sweep that would break every legitimate-shape backup-file
8891        // path.
8892        let d = dep_with_fonte(DepSource::Path {
8893            caminho: "../foo~bar/caixa-teia".into(),
8894        });
8895        d.validate().unwrap();
8896    }
8897
8898    #[test]
8899    fn fonte_caminho_empty_fires_before_tilde_expansion() {
8900        // Cascade pin: the empty arm structurally precedes the
8901        // tilde arm (the bytes `""` and `"~"` don't overlap), but the
8902        // pin establishes the precedence at the diagnostic-shape
8903        // level should a future codec round-trip ever produce a
8904        // probe-as-both value. Mirrors the peer
8905        // `fonte_repo_empty_fires_before_pin_missing` cascade
8906        // discipline.
8907        let d = dep_with_fonte(DepSource::Path {
8908            caminho: String::new(),
8909        });
8910        let err = d.validate().unwrap_err();
8911        assert!(
8912            matches!(err, DepError::FonteCaminhoEmpty { .. }),
8913            "got {err:?}",
8914        );
8915    }
8916
8917    #[test]
8918    fn fonte_caminho_tilde_diagnostic_carries_offending_dep_and_caminho() {
8919        // Diagnostic-shape pin (peer with
8920        // `validate_rejects_path_fonte_with_absolute_caminho`'s
8921        // payload assertion): the error's Display surfaces both the
8922        // offending `:nome` and the offending `:caminho` verbatim
8923        // so a `feira lint` run can render the diagnostic without
8924        // re-parsing.
8925        let d = dep_with_fonte(DepSource::Path {
8926            caminho: "~alice/dev/caixa-teia".into(),
8927        });
8928        let rendered = d.validate().unwrap_err().to_string();
8929        assert!(
8930            rendered.contains("caixa-teia"),
8931            "diagnostic must name the offending dep: {rendered}",
8932        );
8933        assert!(
8934            rendered.contains("~alice/dev/caixa-teia"),
8935            "diagnostic must quote the offending caminho: {rendered}",
8936        );
8937        assert!(
8938            rendered.contains('~'),
8939            "diagnostic must reference the tilde footgun: {rendered}",
8940        );
8941    }
8942
8943    #[test]
8944    fn validate_rejects_path_fonte_with_dollar_prefix_caminho() {
8945        // The fail-before-pass-after pin for the shell-variable-
8946        // expansion `:caminho` shape: `(:tipo path :caminho
8947        // "$HOME/work/caixa-teia")`. Until this gate landed the
8948        // b94fd83 absolute arm + the a5c248e tilde arm both let
8949        // `$HOME/foo` through (`Path::is_absolute` returns false on
8950        // a leading `$` — the `$` is a shell convention, not a POSIX
8951        // path component; `starts_with('~')` returns false too), so
8952        // the lacre embedded the value verbatim and the resolver
8953        // folded it through `Path::join` without `$`-expansion,
8954        // looking for a literal `./$HOME/work/caixa-teia`
8955        // subdirectory and failing at resolve time with a
8956        // `No such file or directory` error far from the source
8957        // caixa.lisp. The new gate moves the check to validate time
8958        // and names the offending dep + caminho verbatim.
8959        let d = dep_with_fonte(DepSource::Path {
8960            caminho: "$HOME/work/caixa-teia".into(),
8961        });
8962        let err = d.validate().unwrap_err();
8963        let DepError::FonteCaminhoVarExpansion { nome, caminho } = err else {
8964            panic!("expected FonteCaminhoVarExpansion, got {err:?}");
8965        };
8966        assert_eq!(nome, "caixa-teia");
8967        assert_eq!(caminho, "$HOME/work/caixa-teia");
8968    }
8969
8970    #[test]
8971    fn validate_rejects_path_fonte_with_dollar_brace_prefix_caminho() {
8972        // Sweep over every leading-`$` shape: the `${VAR}`-braced
8973        // form (canonical "paste-from-CI-manifest" footgun every
8974        // GitHub Actions / GitLab CI / Drone manifest carries on
8975        // `${WORKSPACE}`), the XDG idiom (`$XDG_CONFIG_HOME/caixa`,
8976        // canonical "I'm referencing a per-user config dir"),
8977        // and the bare `$` (canonical "I meant `$HOME` and forgot
8978        // the rest"). All shapes route through the same gate's
8979        // byte check. Pinned so the gate doesn't narrow to a
8980        // single shape (e.g. `$HOME/` only).
8981        for s in [
8982            "${HOME}/work/caixa-teia",
8983            "${WORKSPACE}/caixa-teia",
8984            "$XDG_CONFIG_HOME/caixa",
8985            "$",
8986        ] {
8987            let d = dep_with_fonte(DepSource::Path { caminho: s.into() });
8988            let err = d.validate().unwrap_err();
8989            assert!(
8990                matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
8991                "{s:?} → {err:?}",
8992            );
8993        }
8994    }
8995
8996    #[test]
8997    fn validate_rejects_path_fonte_with_mid_path_dollar_caminho() {
8998        // The `$` byte is the canonical shell-variable-expansion /
8999        // command-substitution / arithmetic-expansion sentinel and
9000        // is rejected at *every* position on the `:caminho` axis: the
9001        // leading arm surfaces `FonteCaminhoVarExpansion`, the
9002        // embedded arm surfaces `FonteCaminhoShellVariableExpansion`
9003        // (6620f39). Pinned so a future arm doesn't narrow the gate
9004        // back to the leading position and re-open the paste-from-
9005        // shell-one-liner `"../foo$HOME/bar"` / paste-from-CI-
9006        // manifest `"../foo${WORKSPACE}/bar"` / paste-from-shell-
9007        // prompt `"../foo$(whoami)/bar"` cross-idiom-leak surface on
9008        // the lacre content-address (`path:{caminho}`,
9009        // caixa-resolver/src/resolve.rs:189).
9010        let d = dep_with_fonte(DepSource::Path {
9011            caminho: "../foo$bar/caixa-teia".into(),
9012        });
9013        let err = d.validate().unwrap_err();
9014        assert!(
9015            matches!(
9016                err,
9017                DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
9018            ),
9019            "got {err:?}",
9020        );
9021    }
9022
9023    #[test]
9024    fn fonte_caminho_tilde_fires_before_var_expansion() {
9025        // Cascade pin: the tilde arm structurally precedes the var
9026        // arm (the bytes `~` and `$` don't overlap at the leading
9027        // position), but the pin establishes the precedence at the
9028        // diagnostic-shape level should a future codec round-trip
9029        // ever produce a probe-as-both value. Mirrors the peer
9030        // `fonte_caminho_empty_fires_before_tilde_expansion` cascade
9031        // discipline on the immediate-predecessor arm.
9032        let d = dep_with_fonte(DepSource::Path {
9033            caminho: "~/work/caixa-teia".into(),
9034        });
9035        let err = d.validate().unwrap_err();
9036        assert!(
9037            matches!(err, DepError::FonteCaminhoTildeExpansion { .. }),
9038            "got {err:?}",
9039        );
9040    }
9041
9042    #[test]
9043    fn fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho() {
9044        // Diagnostic-shape pin (peer with
9045        // `fonte_caminho_tilde_diagnostic_carries_offending_dep_and_caminho`'s
9046        // payload assertion on the immediate-predecessor arm): the
9047        // error's Display surfaces both the offending `:nome` and
9048        // the offending `:caminho` verbatim plus the `$` footgun
9049        // character itself so a `feira lint` run can render the
9050        // diagnostic without re-parsing.
9051        let d = dep_with_fonte(DepSource::Path {
9052            caminho: "${WORKSPACE}/caixa-teia".into(),
9053        });
9054        let rendered = d.validate().unwrap_err().to_string();
9055        assert!(
9056            rendered.contains("caixa-teia"),
9057            "diagnostic must name the offending dep: {rendered}",
9058        );
9059        assert!(
9060            rendered.contains("${WORKSPACE}/caixa-teia"),
9061            "diagnostic must quote the offending caminho: {rendered}",
9062        );
9063        assert!(
9064            rendered.contains('$'),
9065            "diagnostic must reference the dollar footgun: {rendered}",
9066        );
9067    }
9068
9069    #[test]
9070    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_nul() {
9071        // The fail-before-pass-after pin for the load-bearing NUL byte:
9072        // POSIX paths cannot contain `0x00` (every `std::fs` syscall
9073        // routes the path through `CString::new` which fails with
9074        // `NulError`); until this gate landed a `:caminho
9075        // "../caixa\0teia"` silently passed validate, the lacre
9076        // pipeline embedded the value verbatim, and the failure
9077        // surfaced at the resolver's `Path::join` → `CString::new`
9078        // boundary with a non-self-locating `NulError` far from the
9079        // source caixa.lisp. The new gate moves the check to validate
9080        // time and names the offending dep + caminho + offending byte
9081        // verbatim.
9082        let d = dep_with_fonte(DepSource::Path {
9083            caminho: "../caixa\0teia".into(),
9084        });
9085        let err = d.validate().unwrap_err();
9086        let DepError::FonteCaminhoControlChar {
9087            nome,
9088            caminho,
9089            byte,
9090        } = err
9091        else {
9092            panic!("expected FonteCaminhoControlChar, got {err:?}");
9093        };
9094        assert_eq!(nome, "caixa-teia");
9095        assert_eq!(caminho, "../caixa\0teia");
9096        assert_eq!(byte, 0x00);
9097    }
9098
9099    #[test]
9100    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_newline() {
9101        // The canonical paste-from-multiline-doc footgun on `:caminho`
9102        // — author copies `"../caixa-teia\n"` (trailing newline) out
9103        // of a multi-line code-fence or, worse, a `:caminho
9104        // "../caixa-teia\nrm -rf /"` value (CRLF-at-subprocess-argument
9105        // injection sibling on the path axis the `is_git_repo_url`
9106        // control-char arm already closes on `:repo`). Pinned
9107        // separately from the NUL arm so a future relaxation that
9108        // catches one but not the other surfaces here.
9109        let d = dep_with_fonte(DepSource::Path {
9110            caminho: "../caixa-teia\n".into(),
9111        });
9112        let err = d.validate().unwrap_err();
9113        let DepError::FonteCaminhoControlChar { byte, .. } = err else {
9114            panic!("expected FonteCaminhoControlChar, got {err:?}");
9115        };
9116        assert_eq!(byte, 0x0A);
9117    }
9118
9119    #[test]
9120    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_carriage_return() {
9121        // The CRLF sibling of the LF arm — Windows-line-ending
9122        // paste-from-multiline-doc on a `\r\n`-terminated buffer
9123        // leaves a stray `\r` mid-string after the LF strip. Pinned
9124        // separately from the LF arm so a future relaxation that
9125        // only catches LF surfaces here.
9126        let d = dep_with_fonte(DepSource::Path {
9127            caminho: "../caixa-teia\r".into(),
9128        });
9129        let err = d.validate().unwrap_err();
9130        let DepError::FonteCaminhoControlChar { byte, .. } = err else {
9131            panic!("expected FonteCaminhoControlChar, got {err:?}");
9132        };
9133        assert_eq!(byte, 0x0D);
9134    }
9135
9136    #[test]
9137    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_tab() {
9138        // The canonical paste-from-aligned-table footgun — a `\t`
9139        // mid-`:caminho` is invisible in most editors but rides
9140        // through the lacre's content-address verbatim, so two
9141        // paste-from-distinct-tables (one editor strips tabs, one
9142        // preserves them) yield divergent lacres for the byte-
9143        // identical-looking caixa. Pinned separately from the
9144        // whitespace-shaped LF/CR arms so a future relaxation that
9145        // narrows to line-terminator-only surfaces here.
9146        let d = dep_with_fonte(DepSource::Path {
9147            caminho: "../caixa\tteia".into(),
9148        });
9149        let err = d.validate().unwrap_err();
9150        let DepError::FonteCaminhoControlChar { byte, .. } = err else {
9151            panic!("expected FonteCaminhoControlChar, got {err:?}");
9152        };
9153        assert_eq!(byte, 0x09);
9154    }
9155
9156    #[test]
9157    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_del() {
9158        // The DEL byte (`0x7F`) closes the upper-end paste-from-
9159        // binary-blob footgun — the gate's contract is `b < 0x20 ||
9160        // b == 0x7F`, matching the `is_git_repo_url` /
9161        // `is_git_ref_name` predicates' control-char arms. Pinned
9162        // separately from the lower-range arms so a future narrowing
9163        // to `< 0x20` only surfaces here.
9164        let d = dep_with_fonte(DepSource::Path {
9165            caminho: "../caixa\x7fteia".into(),
9166        });
9167        let err = d.validate().unwrap_err();
9168        let DepError::FonteCaminhoControlChar { byte, .. } = err else {
9169            panic!("expected FonteCaminhoControlChar, got {err:?}");
9170        };
9171        assert_eq!(byte, 0x7F);
9172    }
9173
9174    #[test]
9175    fn validate_accepts_path_fonte_with_caminho_carrying_high_bit_utf8() {
9176        // The control-byte arm targets `0x00..=0x1F` + `0x7F` only —
9177        // high-bit / non-ASCII UTF-8 bytes are not gated. POSIX paths
9178        // are opaque byte sequences and UTF-8 multi-byte sequences
9179        // are a legitimate filename shape (the `café-teia/foo` idiom).
9180        // Pinned so the gate doesn't widen to a full ASCII-only sweep
9181        // that would break every legitimate-shape UTF-8 path.
9182        let d = dep_with_fonte(DepSource::Path {
9183            caminho: "../café-teia/foo".into(),
9184        });
9185        d.validate().unwrap();
9186    }
9187
9188    #[test]
9189    fn fonte_caminho_var_fires_before_control_char() {
9190        // Cascade pin: the var-expansion arm structurally precedes the
9191        // control-char arm. A value like `"$\n"` probes positive on
9192        // both arms (`starts_with('$')` and contains LF), but the
9193        // narrower leading-byte diagnostic (`FonteCaminhoVarExpansion`)
9194        // wins so the author sees the more self-locating shell-
9195        // expansion arm first. Mirrors the
9196        // `fonte_caminho_tilde_fires_before_var_expansion` cascade
9197        // discipline on the immediate-predecessor arm.
9198        let d = dep_with_fonte(DepSource::Path {
9199            caminho: "$HOME\n".into(),
9200        });
9201        let err = d.validate().unwrap_err();
9202        assert!(
9203            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
9204            "got {err:?}",
9205        );
9206    }
9207
9208    #[test]
9209    fn validate_rejects_path_fonte_with_leading_space_caminho() {
9210        // The fail-before-pass-after pin for the leading ASCII space
9211        // `:caminho` shape: `(:tipo path :caminho " ../caixa-teia")`.
9212        // Until this gate landed the b94fd83 absolute arm + the a5c248e
9213        // tilde arm + the f4efe9c var arm + the d624c8d control-byte arm
9214        // all let `" ../caixa-teia"` through: `Path::is_absolute` returns
9215        // false on a leading space (the leading byte is `0x20`, not `0x2F`),
9216        // `starts_with('~')` / `starts_with('$')` return false, and `0x20`
9217        // is not in the `0x00..=0x1F` plus `0x7F` control-byte set (the
9218        // four ASCII whitespace bytes `0x09` tab, `0x0A` LF, `0x0D` CR
9219        // are caught, but the most common whitespace `0x20` space is
9220        // not). The lacre embedded the value verbatim and the resolver
9221        // folded it through `Path::join` looking for a literal `./ ../
9222        // caixa-teia` subdirectory and failing at resolve time with a
9223        // non-self-locating `No such file or directory` error far from
9224        // the source caixa.lisp. The new gate moves the check to
9225        // validate time and names the offending dep + caminho verbatim.
9226        let d = dep_with_fonte(DepSource::Path {
9227            caminho: " ../caixa-teia".into(),
9228        });
9229        let err = d.validate().unwrap_err();
9230        let DepError::FonteCaminhoLeadingWhitespace { nome, caminho } = err else {
9231            panic!("expected FonteCaminhoLeadingWhitespace, got {err:?}");
9232        };
9233        assert_eq!(nome, "caixa-teia");
9234        assert_eq!(caminho, " ../caixa-teia");
9235    }
9236
9237    #[test]
9238    fn validate_rejects_path_fonte_with_multiple_leading_spaces_caminho() {
9239        // The aligned-doc paste footgun sweep: more than one leading
9240        // space (`"   ../caixa-teia"` — the canonical "I selected the
9241        // aligned column from a four-`:fonte`-entry `:deps` block"
9242        // paste) routes through the same gate's `starts_with(' ')`
9243        // byte check. Pinned so the gate doesn't narrow to a
9244        // single-space prefix.
9245        let d = dep_with_fonte(DepSource::Path {
9246            caminho: "   ../caixa-teia".into(),
9247        });
9248        let err = d.validate().unwrap_err();
9249        assert!(
9250            matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
9251            "got {err:?}",
9252        );
9253    }
9254
9255    #[test]
9256    fn validate_accepts_path_fonte_with_mid_path_space_caminho() {
9257        // The leading-space is the canonical paste-from-aligned-doc
9258        // footgun — a space mid-path (`"../my dir/caixa-teia"` — the
9259        // canonical "I have a directory with a space in its name"
9260        // idiom; ASCII `0x20` is a valid POSIX filename byte) is a
9261        // legitimate path with no whitespace-leak semantic at the
9262        // non-leading position. Pinned so the gate doesn't widen to a
9263        // full no-space-anywhere sweep that would break every
9264        // legitimate-shape space-in-filename path.
9265        let d = dep_with_fonte(DepSource::Path {
9266            caminho: "../my dir/caixa-teia".into(),
9267        });
9268        d.validate().unwrap();
9269    }
9270
9271    #[test]
9272    fn fonte_caminho_var_fires_before_leading_whitespace() {
9273        // Cascade pin: the var-expansion arm structurally precedes the
9274        // leading-whitespace arm. A value like `"$ "` would probe positive
9275        // on var (`starts_with('$')`) but the leading-byte arms walk
9276        // left-to-right so the var arm fires on the leading `$` before
9277        // the leading-whitespace arm probes. Mirrors the
9278        // `fonte_caminho_tilde_fires_before_var_expansion` cascade
9279        // discipline on the immediate-predecessor arms.
9280        let d = dep_with_fonte(DepSource::Path {
9281            caminho: "$VAR".into(),
9282        });
9283        let err = d.validate().unwrap_err();
9284        assert!(
9285            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
9286            "got {err:?}",
9287        );
9288    }
9289
9290    #[test]
9291    fn fonte_caminho_leading_whitespace_fires_before_control_char() {
9292        // Cascade pin: the leading-whitespace arm structurally precedes
9293        // the control-char arm. A value like `" ../foo\n"` probes
9294        // positive on both (starts with space AND contains LF), but
9295        // the narrower leading-byte diagnostic
9296        // (`FonteCaminhoLeadingWhitespace`) wins so the author sees the
9297        // more self-locating paste-from-aligned-doc arm first. Mirrors
9298        // the `fonte_caminho_var_fires_before_control_char` cascade
9299        // discipline on the immediate-predecessor arm.
9300        let d = dep_with_fonte(DepSource::Path {
9301            caminho: " ../foo\n".into(),
9302        });
9303        let err = d.validate().unwrap_err();
9304        assert!(
9305            matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
9306            "got {err:?}",
9307        );
9308    }
9309
9310    #[test]
9311    fn fonte_caminho_leading_whitespace_diagnostic_carries_offending_dep_and_caminho() {
9312        // Diagnostic-shape pin (peer with
9313        // `fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho`'s
9314        // payload assertion on the immediate-predecessor arm): the
9315        // error's Display surfaces both the offending `:nome` and the
9316        // offending `:caminho` verbatim, so a `feira lint` run can
9317        // render the diagnostic without re-parsing and the author can
9318        // grep their caixa.lisp for `:caminho "<value>"` and fix it in
9319        // one edit.
9320        let d = dep_with_fonte(DepSource::Path {
9321            caminho: " ../caixa-teia".into(),
9322        });
9323        let rendered = d.validate().unwrap_err().to_string();
9324        assert!(
9325            rendered.contains("caixa-teia"),
9326            "diagnostic must name the offending dep: {rendered}",
9327        );
9328        assert!(
9329            rendered.contains(" ../caixa-teia"),
9330            "diagnostic must quote the offending caminho: {rendered}",
9331        );
9332        assert!(
9333            rendered.contains("space"),
9334            "diagnostic must name the space footgun: {rendered}",
9335        );
9336    }
9337
9338    #[test]
9339    fn fonte_caminho_absolute_fires_before_control_char() {
9340        // Cascade pin on the sibling leading-byte arm: a leading `/`
9341        // value with embedded control byte (`"/etc/passwd\n"`) routes
9342        // through `FonteCaminhoAbsolute` not `FonteCaminhoControlChar`
9343        // — the host-layout-leak diagnostic is the load-bearing axis,
9344        // the control byte is the secondary observation. Same precedence
9345        // logic on every prior leading-byte arm.
9346        let d = dep_with_fonte(DepSource::Path {
9347            caminho: "/etc/passwd\n".into(),
9348        });
9349        let err = d.validate().unwrap_err();
9350        assert!(
9351            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
9352            "got {err:?}",
9353        );
9354    }
9355
9356    #[test]
9357    fn validate_rejects_path_fonte_with_leading_hyphen_caminho() {
9358        // The fail-before-pass-after pin for the leading-`-` CLI-arg-
9359        // injection `:caminho` shape sweep. Until this gate landed
9360        // every prior leading-byte arm passed a leading-`-` value
9361        // through: `Path::is_absolute` returns false on `-` (the
9362        // leading byte is `0x2D`, not `0x2F`), `starts_with('~')` /
9363        // `starts_with('$')` / `starts_with(' ')` all return false,
9364        // and `0x2D` sits outside the control-byte set. The lacre
9365        // embedded the value verbatim and the resolver folded it
9366        // through `Path::join` looking for a literal `./-rf` /
9367        // `./-C` / `./--upload-pack=…` subdirectory; the failure at
9368        // `Path::join` time is non-self-locating but harmless, while
9369        // the failure at every downstream `git -C {caminho}` /
9370        // `terraform -chdir={caminho}` / `find {caminho}` shell-out
9371        // is arbitrary-CLI-arg-injection because none of those
9372        // porcelains carry a `--` argument-list terminator between
9373        // the flag block and the path argument. The new arm moves the
9374        // rejection to `Caixa::from_lisp` boundary time and names
9375        // the offending dep + caminho verbatim.
9376        //
9377        // Sweep spans the canonical CLI-arg-injection shapes matching
9378        // the peer sweep on the sibling `is_git_ref_name` /
9379        // `is_git_repo_url` axes: short-flag `-rf` (the `rm -rf` /
9380        // `find -rf` reinterpretation vector), `-C` (the `git -C`
9381        // change-directory-config-injection paste), long-flag
9382        // `--upload-pack=cat /etc/passwd` (the canonical
9383        // arbitrary-command-execution vector on every git porcelain
9384        // entry point), git-config-injection `--config=core.merge=ours`,
9385        // and the degenerate single-byte `-` value.
9386        for caminho in [
9387            "-rf",
9388            "-C",
9389            "--upload-pack=cat /etc/passwd",
9390            "--config=core.merge=ours",
9391            "-",
9392        ] {
9393            let d = dep_with_fonte(DepSource::Path {
9394                caminho: caminho.into(),
9395            });
9396            let err = d.validate().unwrap_err();
9397            let DepError::FonteCaminhoLeadingHyphen { nome, caminho: got } = err else {
9398                panic!("expected FonteCaminhoLeadingHyphen for {caminho:?}, got {err:?}");
9399            };
9400            assert_eq!(nome, "caixa-teia");
9401            assert_eq!(got, caminho);
9402        }
9403    }
9404
9405    #[test]
9406    fn validate_accepts_path_fonte_with_mid_path_hyphen_caminho() {
9407        // The leading-`-` is the canonical CLI-arg-injection footgun
9408        // — a `-` anywhere else in the path (`"../caixa-teia"` — the
9409        // canonical kebab-separator-between-alphanumeric-segments
9410        // shape every DNS-1123-shaped caixa name carries; `"../-hidden"`
9411        // — a mid-path segment starting with `-`, still a legitimate
9412        // POSIX filename byte at that non-leading position because the
9413        // subprocess reads the whole `{caminho}` value as one positional
9414        // argument, so only the very first byte of the composite path
9415        // string is at the CLI-arg-injection boundary) is a legitimate
9416        // path with no CLI-flag-reinterpretation semantic at the non-
9417        // leading position of the top-level value. Pinned so the gate
9418        // doesn't widen to a full no-`-`-anywhere sweep that would
9419        // break every legitimate-shape kebab-in-filename path (i.e.
9420        // essentially every sibling-workspace caixa dep).
9421        for caminho in [
9422            "../caixa-teia",
9423            "../caixa-teia/-hidden",
9424            "./my-lib",
9425            "../foo-bar/baz",
9426        ] {
9427            let d = dep_with_fonte(DepSource::Path {
9428                caminho: caminho.into(),
9429            });
9430            d.validate()
9431                .unwrap_or_else(|e| panic!("mid-path `-` caminho {caminho:?} must pass: {e:?}"));
9432        }
9433    }
9434
9435    #[test]
9436    fn fonte_caminho_leading_whitespace_fires_before_leading_hyphen() {
9437        // Cascade pin: the leading-whitespace arm structurally precedes
9438        // the leading-hyphen arm. A value like `" -rf"` probes positive
9439        // on both (leading space AND, one byte in, a `-` — though the
9440        // leading-hyphen arm probes only the very first byte so it
9441        // wouldn't fire on this value; the pin instead documents the
9442        // arm order on the more common "leading space then a hyphen"
9443        // paste-from-aligned-doc paste-flag-shell-one-liner idiom).
9444        // The narrower leading-space diagnostic (the paste-from-aligned-
9445        // doc footgun) wins so the author sees the more self-locating
9446        // whitespace arm first. Mirrors the
9447        // `fonte_caminho_var_fires_before_leading_whitespace` cascade
9448        // discipline on the immediate-predecessor arm.
9449        let d = dep_with_fonte(DepSource::Path {
9450            caminho: " -rf".into(),
9451        });
9452        let err = d.validate().unwrap_err();
9453        assert!(
9454            matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
9455            "got {err:?}",
9456        );
9457    }
9458
9459    #[test]
9460    fn fonte_caminho_leading_hyphen_fires_before_control_char() {
9461        // Cascade pin: the leading-hyphen arm structurally precedes
9462        // the control-char arm. A value like `"-rf\n"` probes positive
9463        // on both (starts with `-` AND contains LF), but the narrower
9464        // leading-byte diagnostic (`FonteCaminhoLeadingHyphen`) wins so
9465        // the author sees the more self-locating CLI-arg-injection arm
9466        // first. Mirrors the
9467        // `fonte_caminho_leading_whitespace_fires_before_control_char`
9468        // cascade discipline on the immediate-predecessor arm.
9469        let d = dep_with_fonte(DepSource::Path {
9470            caminho: "-rf\n".into(),
9471        });
9472        let err = d.validate().unwrap_err();
9473        assert!(
9474            matches!(err, DepError::FonteCaminhoLeadingHyphen { .. }),
9475            "got {err:?}",
9476        );
9477    }
9478
9479    #[test]
9480    fn fonte_caminho_leading_hyphen_diagnostic_carries_offending_dep_and_caminho() {
9481        // Diagnostic-shape pin (peer with
9482        // `fonte_caminho_leading_whitespace_diagnostic_carries_offending_dep_and_caminho`'s
9483        // payload assertion on the immediate-predecessor arm): the
9484        // error's Display surfaces both the offending `:nome` and the
9485        // offending `:caminho` verbatim plus the CLI-argument-injection
9486        // vocabulary, so a `feira lint` run can render the diagnostic
9487        // without re-parsing and the author can grep their caixa.lisp
9488        // for `:caminho "<value>"` and fix it in one edit.
9489        let d = dep_with_fonte(DepSource::Path {
9490            caminho: "--upload-pack=cat /etc/passwd".into(),
9491        });
9492        let rendered = d.validate().unwrap_err().to_string();
9493        assert!(
9494            rendered.contains("caixa-teia"),
9495            "diagnostic must name the offending dep: {rendered}",
9496        );
9497        assert!(
9498            rendered.contains("--upload-pack=cat /etc/passwd"),
9499            "diagnostic must quote the offending caminho: {rendered}",
9500        );
9501        assert!(
9502            rendered.contains("CLI-argument-injection"),
9503            "diagnostic must name the CLI-argument-injection vector: {rendered}",
9504        );
9505        assert!(
9506            rendered.contains("`-`"),
9507            "diagnostic must name the offending byte: {rendered}",
9508        );
9509    }
9510
9511    #[test]
9512    fn fonte_caminho_control_diagnostic_carries_offending_dep_caminho_byte() {
9513        // Diagnostic-shape pin (peer with
9514        // `fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho`'s
9515        // payload assertion on the immediate-predecessor arm): the
9516        // error's Display surfaces the offending `:nome`, the
9517        // offending `:caminho` verbatim, and the offending byte in
9518        // hex form (`0x09` for tab) so a `feira lint` run can render
9519        // the diagnostic without re-parsing.
9520        let d = dep_with_fonte(DepSource::Path {
9521            caminho: "../caixa\tteia".into(),
9522        });
9523        let rendered = d.validate().unwrap_err().to_string();
9524        assert!(
9525            rendered.contains("caixa-teia"),
9526            "diagnostic must name the offending dep: {rendered}",
9527        );
9528        assert!(
9529            rendered.contains("../caixa\tteia"),
9530            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
9531        );
9532        assert!(
9533            rendered.contains("0x09"),
9534            "diagnostic must name the offending byte in hex: {rendered:?}",
9535        );
9536    }
9537
9538    #[test]
9539    fn validate_rejects_path_fonte_with_caminho_carrying_backslash() {
9540        // The fail-before-pass-after pin for the canonical Windows-
9541        // path-separator paste footgun: an author who pastes a path
9542        // from Windows-Explorer's `Copy as path`, PowerShell's
9543        // `Get-Location`, or any CMD/Cygwin/MSYS shell prompt
9544        // produces `..\caixa-teia`-shape values that silently passed
9545        // every prior arm (`Path::is_absolute("..\\caixa-teia")` is
9546        // false; `\` is neither a leading-byte sentinel nor a
9547        // control byte). On POSIX resolvers the value rides through
9548        // `Path::join` as a literal directory name and fails at
9549        // resolve time with `No such file or directory`; on Windows
9550        // resolvers the value resolves to the parent's sibling — two
9551        // distinct directories for the byte-identical caixa.lisp.
9552        // The new arm moves the rejection to validate time and names
9553        // the offending dep + caminho verbatim.
9554        let d = dep_with_fonte(DepSource::Path {
9555            caminho: "..\\caixa-teia".into(),
9556        });
9557        let err = d.validate().unwrap_err();
9558        let DepError::FonteCaminhoBackslash { nome, caminho } = err else {
9559            panic!("expected FonteCaminhoBackslash, got {err:?}");
9560        };
9561        assert_eq!(nome, "caixa-teia");
9562        assert_eq!(caminho, "..\\caixa-teia");
9563    }
9564
9565    #[test]
9566    fn validate_rejects_path_fonte_with_caminho_carrying_windows_drive_letter() {
9567        // The Windows drive-letter paste shape (`C:\work\caixa-teia`
9568        // out of Explorer / `cd`-and-`pwd`-on-Windows). On POSIX
9569        // hosts `Path::is_absolute("C:\\work\\caixa-teia")` returns
9570        // false (POSIX absolute paths start with `/`, drive letters
9571        // are not a POSIX concept), so the b94fd83 absolute arm
9572        // doesn't fire; the value contains `\` bytes that this arm
9573        // now catches with the more self-locating Windows-path-
9574        // separator diagnostic. Pinned separately from the bare
9575        // `..\caixa-teia` shape so a future arm that targets only
9576        // leading-`..\` doesn't regress the drive-letter coverage.
9577        let d = dep_with_fonte(DepSource::Path {
9578            caminho: "C:\\work\\caixa-teia".into(),
9579        });
9580        let err = d.validate().unwrap_err();
9581        assert!(
9582            matches!(err, DepError::FonteCaminhoBackslash { .. }),
9583            "got {err:?}",
9584        );
9585    }
9586
9587    #[test]
9588    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_backslash() {
9589        // The trailing-`\` shape (`..\caixa-teia\` — the canonical
9590        // PowerShell tab-completion-on-a-directory append). Pinned
9591        // separately from the embedded-`\` shape so the gate's
9592        // contract is "any `\` anywhere", not "any `\` not at end".
9593        let d = dep_with_fonte(DepSource::Path {
9594            caminho: "..\\caixa-teia\\".into(),
9595        });
9596        let err = d.validate().unwrap_err();
9597        assert!(
9598            matches!(err, DepError::FonteCaminhoBackslash { .. }),
9599            "got {err:?}",
9600        );
9601    }
9602
9603    #[test]
9604    fn validate_accepts_path_fonte_with_caminho_carrying_legitimate_forward_slash() {
9605        // The positive-control pin: the gate targets `\` only,
9606        // never `/`. The canonical relative POSIX path
9607        // (`../caixa-teia/foo/bar`) must continue to validate cleanly
9608        // so legitimate nested-directory deps aren't broken. Pinned
9609        // so the gate doesn't accidentally widen to a "no path
9610        // separators at all" sweep.
9611        let d = dep_with_fonte(DepSource::Path {
9612            caminho: "../caixa-teia/foo/bar".into(),
9613        });
9614        d.validate().unwrap();
9615    }
9616
9617    #[test]
9618    fn fonte_caminho_control_char_fires_before_backslash() {
9619        // Cascade pin: the control-char arm structurally precedes the
9620        // backslash arm. A value like `"..\caixa\0teia"` probes
9621        // positive on both (`\` byte + NUL byte), but the control-
9622        // char diagnostic wins so the author sees the more self-
9623        // locating POSIX-syscall-rejected-byte diagnostic first
9624        // (NUL outright breaks `CString::new` at every `std::fs`
9625        // syscall boundary; the `\` divergence is the cross-OS-
9626        // separator axis). Mirrors the
9627        // `fonte_caminho_var_fires_before_control_char` cascade
9628        // discipline on the immediate-predecessor arm.
9629        let d = dep_with_fonte(DepSource::Path {
9630            caminho: "..\\caixa\0teia".into(),
9631        });
9632        let err = d.validate().unwrap_err();
9633        assert!(
9634            matches!(err, DepError::FonteCaminhoControlChar { .. }),
9635            "got {err:?}",
9636        );
9637    }
9638
9639    #[test]
9640    fn fonte_caminho_absolute_fires_before_backslash() {
9641        // Cascade pin on the load-bearing leading-byte arm: a leading
9642        // `/` value with embedded `\` (`/etc/passwd\foo`) routes
9643        // through `FonteCaminhoAbsolute` not `FonteCaminhoBackslash`
9644        // — the host-layout-leak diagnostic is the load-bearing
9645        // axis, the `\` byte is the secondary observation. Same
9646        // precedence logic as every prior leading-byte arm.
9647        let d = dep_with_fonte(DepSource::Path {
9648            caminho: "/etc/passwd\\foo".into(),
9649        });
9650        let err = d.validate().unwrap_err();
9651        assert!(
9652            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
9653            "got {err:?}",
9654        );
9655    }
9656
9657    #[test]
9658    fn fonte_caminho_var_fires_before_backslash() {
9659        // Cascade pin on the var-expansion arm: a leading-`$` value
9660        // with embedded `\` (`$WORKSPACE\caixa-teia` — the canonical
9661        // PowerShell-env-var paste-from-CI-manifest footgun) routes
9662        // through `FonteCaminhoVarExpansion` not `FonteCaminhoBackslash`.
9663        // The shell-expansion diagnostic is the more self-locating
9664        // axis since both the leading `$` and the embedded `\`
9665        // are Windows-shell artifacts but the `$` is the root-cause
9666        // surface (an author who removes the `$` is likely to leave
9667        // the `\` too).
9668        let d = dep_with_fonte(DepSource::Path {
9669            caminho: "$WORKSPACE\\caixa-teia".into(),
9670        });
9671        let err = d.validate().unwrap_err();
9672        assert!(
9673            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
9674            "got {err:?}",
9675        );
9676    }
9677
9678    #[test]
9679    fn fonte_caminho_backslash_diagnostic_carries_offending_dep_and_caminho() {
9680        // Diagnostic-shape pin (peer with the prior
9681        // `fonte_caminho_*_diagnostic_carries_*` payload assertions
9682        // on every preceding arm): the error's Display surfaces the
9683        // offending `:nome` and the offending `:caminho` verbatim
9684        // so a `feira lint` run can render the diagnostic without
9685        // re-parsing.
9686        let d = dep_with_fonte(DepSource::Path {
9687            caminho: "..\\caixa-teia".into(),
9688        });
9689        let rendered = d.validate().unwrap_err().to_string();
9690        assert!(
9691            rendered.contains("caixa-teia"),
9692            "diagnostic must name the offending dep: {rendered}",
9693        );
9694        assert!(
9695            rendered.contains("..\\caixa-teia"),
9696            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
9697        );
9698        assert!(
9699            rendered.contains('\\'),
9700            "diagnostic must reference the backslash footgun: {rendered:?}",
9701        );
9702    }
9703
9704    #[test]
9705    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_slash() {
9706        // The fail-before-pass-after pin for the canonical trailing-`/`
9707        // paste footgun: an author who shell-tab-completes a sibling
9708        // directory (every interactive shell — bash/zsh/fish/nushell —
9709        // appends `/` on tab-completing a directory) produces
9710        // `"../caixa-teia/"`-shape values that silently passed every
9711        // prior arm (the leading byte is `.`, no control bytes, no
9712        // backslash). `Path::join` resolves both shapes to the same
9713        // directory at the resolver, but the lacre embeds the value
9714        // verbatim and the BLAKE3 closures diverge across two
9715        // workstations whose authors differ only in tab-completion
9716        // habits.
9717        let d = dep_with_fonte(DepSource::Path {
9718            caminho: "../caixa-teia/".into(),
9719        });
9720        let err = d.validate().unwrap_err();
9721        let DepError::FonteCaminhoTrailingSlash { nome, caminho } = err else {
9722            panic!("expected FonteCaminhoTrailingSlash, got {err:?}");
9723        };
9724        assert_eq!(nome, "caixa-teia");
9725        assert_eq!(caminho, "../caixa-teia/");
9726    }
9727
9728    #[test]
9729    fn validate_rejects_path_fonte_with_caminho_carrying_bare_dot_slash() {
9730        // The `"./"` shape (the canonical "I meant the caixa.lisp's own
9731        // directory and tab-completed it" footgun). Pinned separately
9732        // from the canonical `"../caixa-teia/"` shape so the gate's
9733        // contract is "any trailing `/`", not "trailing `/` after a leaf
9734        // name".
9735        let d = dep_with_fonte(DepSource::Path {
9736            caminho: "./".into(),
9737        });
9738        let err = d.validate().unwrap_err();
9739        assert!(
9740            matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
9741            "got {err:?}",
9742        );
9743    }
9744
9745    #[test]
9746    fn validate_rejects_path_fonte_with_caminho_carrying_consecutive_trailing_slashes() {
9747        // The `"foo//"` shape (the canonical "I pasted from a CI manifest
9748        // that double-templated `${VAR}/` over an already-`/`-suffixed
9749        // path" footgun). The gate fires on the last byte being `/`
9750        // regardless of how many `/` precede it; the arm contract is
9751        // "the value ends with `/`", structurally.
9752        let d = dep_with_fonte(DepSource::Path {
9753            caminho: "../caixa-teia//".into(),
9754        });
9755        let err = d.validate().unwrap_err();
9756        assert!(
9757            matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
9758            "got {err:?}",
9759        );
9760    }
9761
9762    #[test]
9763    fn validate_rejects_path_fonte_with_caminho_carrying_dotdot_trailing_slash() {
9764        // The `"../"` shape (the canonical "I want the parent" tab-
9765        // completion footgun on a bare `..` path). Pinned separately so
9766        // the gate doesn't accidentally narrow to "trailing `/` only on
9767        // multi-segment paths".
9768        let d = dep_with_fonte(DepSource::Path {
9769            caminho: "../".into(),
9770        });
9771        let err = d.validate().unwrap_err();
9772        assert!(
9773            matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
9774            "got {err:?}",
9775        );
9776    }
9777
9778    #[test]
9779    fn validate_accepts_path_fonte_with_caminho_carrying_internal_slashes() {
9780        // The positive-control pin: the gate targets the trailing byte
9781        // only, never internal `/` separators. The canonical nested
9782        // relative POSIX path (`"../caixa-teia/foo/bar"`) must continue
9783        // to validate cleanly so legitimate deeply-nested deps aren't
9784        // broken. Pinned so the gate doesn't accidentally widen to a
9785        // "no `/` separators anywhere" sweep that would defeat the
9786        // entire path-fonte author surface.
9787        let d = dep_with_fonte(DepSource::Path {
9788            caminho: "../caixa-teia/foo/bar".into(),
9789        });
9790        d.validate().unwrap();
9791    }
9792
9793    #[test]
9794    fn validate_accepts_path_fonte_with_caminho_carrying_bare_dot() {
9795        // The positive-control pin on the degenerate single-`.` shape
9796        // (the canonical "the caixa.lisp's own directory" idiom). The
9797        // gate fires on the trailing byte being `/`, not on the path
9798        // being short, so `"."` (one byte, not `/`) must continue to
9799        // validate cleanly.
9800        let d = dep_with_fonte(DepSource::Path {
9801            caminho: ".".into(),
9802        });
9803        d.validate().unwrap();
9804    }
9805
9806    #[test]
9807    fn fonte_caminho_control_char_fires_before_trailing_slash() {
9808        // Cascade pin: the control-char arm structurally precedes the
9809        // trailing-slash arm. A value like `"../foo\n/"` ends in `/`
9810        // but the embedded LF (`0x0A`) is the load-bearing diagnostic
9811        // (control bytes are the paste-from-multiline-doc footgun the
9812        // d624c8d arm already closes). Mirrors the
9813        // `fonte_caminho_control_char_fires_before_backslash` cascade
9814        // discipline on the immediate-predecessor arm.
9815        let d = dep_with_fonte(DepSource::Path {
9816            caminho: "../foo\n/".into(),
9817        });
9818        let err = d.validate().unwrap_err();
9819        assert!(
9820            matches!(err, DepError::FonteCaminhoControlChar { .. }),
9821            "got {err:?}",
9822        );
9823    }
9824
9825    #[test]
9826    fn fonte_caminho_backslash_fires_before_trailing_slash() {
9827        // Cascade pin on the backslash arm: a value like `"..\foo/"`
9828        // ends in `/` but the embedded `\` is the load-bearing
9829        // diagnostic (the cross-host-OS-separator divergence vector
9830        // the 3a4e1d7 arm closes). Same precedence logic as the prior
9831        // narrower-diagnostic-first cascade.
9832        let d = dep_with_fonte(DepSource::Path {
9833            caminho: "..\\caixa-teia/".into(),
9834        });
9835        let err = d.validate().unwrap_err();
9836        assert!(
9837            matches!(err, DepError::FonteCaminhoBackslash { .. }),
9838            "got {err:?}",
9839        );
9840    }
9841
9842    #[test]
9843    fn fonte_caminho_absolute_fires_before_trailing_slash() {
9844        // Cascade pin on the load-bearing leading-byte arm: a leading
9845        // `/` value with a trailing `/` (`"/etc/passwd/"`) routes
9846        // through `FonteCaminhoAbsolute` not `FonteCaminhoTrailingSlash`
9847        // — the host-layout-leak diagnostic is the load-bearing axis,
9848        // the trailing `/` is the secondary observation. Same
9849        // precedence logic as every prior leading-byte arm.
9850        let d = dep_with_fonte(DepSource::Path {
9851            caminho: "/etc/passwd/".into(),
9852        });
9853        let err = d.validate().unwrap_err();
9854        assert!(
9855            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
9856            "got {err:?}",
9857        );
9858    }
9859
9860    #[test]
9861    fn fonte_caminho_trailing_slash_diagnostic_carries_offending_dep_and_caminho() {
9862        // Diagnostic-shape pin (peer with the prior
9863        // `fonte_caminho_*_diagnostic_carries_*` payload assertions on
9864        // every preceding arm): the error's Display surfaces the
9865        // offending `:nome` and the offending `:caminho` verbatim so a
9866        // `feira lint` run can render the diagnostic without re-parsing.
9867        let d = dep_with_fonte(DepSource::Path {
9868            caminho: "../caixa-teia/".into(),
9869        });
9870        let rendered = d.validate().unwrap_err().to_string();
9871        assert!(
9872            rendered.contains("caixa-teia"),
9873            "diagnostic must name the offending dep: {rendered}",
9874        );
9875        assert!(
9876            rendered.contains("../caixa-teia/"),
9877            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
9878        );
9879        assert!(
9880            rendered.contains("trailing"),
9881            "diagnostic must reference the trailing-slash footgun: {rendered:?}",
9882        );
9883    }
9884
9885    // -- :caminho shell-redirection metacharacter arm -----------------------
9886
9887    #[test]
9888    fn validate_rejects_path_fonte_with_caminho_carrying_gt_redirection() {
9889        // The fail-before-pass-after pin for the canonical output-redirection
9890        // paste footgun: an author copies a shell pipeline tail
9891        // (`"../caixa-teia>build.log"` — the canonical "I selected the whole
9892        // line including the `> build.log` redirect" idiom) and silently
9893        // passed every prior arm (`Path::is_absolute` false on `..`, no
9894        // control bytes, no backslash, doesn't end in `/`). The lacre
9895        // embedded the value verbatim, the resolver folded it through
9896        // `Path::join` looking for a literal `./../caixa-teia>build.log`
9897        // subdirectory, and the failure surfaced at resolve time with a
9898        // non-self-locating `No such file or directory` error. The new arm
9899        // moves the rejection to validate time and names the offending dep
9900        // + caminho + byte verbatim.
9901        let d = dep_with_fonte(DepSource::Path {
9902            caminho: "../caixa-teia>build.log".into(),
9903        });
9904        let err = d.validate().unwrap_err();
9905        let DepError::FonteCaminhoShellRedirection {
9906            nome,
9907            caminho,
9908            byte,
9909        } = err
9910        else {
9911            panic!("expected FonteCaminhoShellRedirection, got {err:?}");
9912        };
9913        assert_eq!(nome, "caixa-teia");
9914        assert_eq!(caminho, "../caixa-teia>build.log");
9915        assert_eq!(byte, b'>');
9916    }
9917
9918    #[test]
9919    fn validate_rejects_path_fonte_with_caminho_carrying_lt_redirection() {
9920        // The symmetric input-redirection paste shape
9921        // (`"../caixa-teia<input.lisp"` — the canonical "I copied a
9922        // `command < input.lisp` line from a tatara-lisp REPL log"
9923        // idiom). Pinned separately from the `>` shape so the gate's
9924        // contract is "any `<` or `>` anywhere", not single-byte coverage.
9925        let d = dep_with_fonte(DepSource::Path {
9926            caminho: "../caixa-teia<input.lisp".into(),
9927        });
9928        let err = d.validate().unwrap_err();
9929        let DepError::FonteCaminhoShellRedirection { byte, .. } = err else {
9930            panic!("expected FonteCaminhoShellRedirection, got {err:?}");
9931        };
9932        assert_eq!(byte, b'<');
9933    }
9934
9935    #[test]
9936    fn validate_rejects_path_fonte_with_caminho_carrying_leading_gt_redirection() {
9937        // Leading-position `>` shape (`">../caixa-teia"` — the degenerate
9938        // "I forgot the source side of the redirect" idiom). Pinned
9939        // separately from the embedded-byte shapes so the gate covers
9940        // every position, not only mid-path.
9941        let d = dep_with_fonte(DepSource::Path {
9942            caminho: ">../caixa-teia".into(),
9943        });
9944        let err = d.validate().unwrap_err();
9945        assert!(
9946            matches!(
9947                err,
9948                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
9949            ),
9950            "got {err:?}",
9951        );
9952    }
9953
9954    #[test]
9955    fn validate_rejects_path_fonte_with_caminho_carrying_double_gt_append() {
9956        // The bash append-redirection shape (`"../caixa-teia>>build.log"` —
9957        // the canonical "I copied a `>>` append redirect" idiom). The arm
9958        // fires on the first `>` encountered; pinned so a future arm that
9959        // tries to distinguish `>` from `>>` doesn't break the broader
9960        // contract.
9961        let d = dep_with_fonte(DepSource::Path {
9962            caminho: "../caixa-teia>>build.log".into(),
9963        });
9964        let err = d.validate().unwrap_err();
9965        assert!(
9966            matches!(
9967                err,
9968                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
9969            ),
9970            "got {err:?}",
9971        );
9972    }
9973
9974    #[test]
9975    fn validate_accepts_path_fonte_with_caminho_carrying_no_redirection() {
9976        // The positive-control pin: the gate targets only `<` / `>`,
9977        // never adjacent printable ASCII or POSIX-valid bytes. The
9978        // canonical relative POSIX path (`"../caixa-teia"`) and a
9979        // nested deeply-pathed variant (`"../caixa-teia/foo/bar"`) must
9980        // continue to validate cleanly so the gate doesn't widen to a
9981        // "no printable punctuation anywhere" sweep that would defeat
9982        // the entire path-fonte author surface.
9983        let d = dep_with_fonte(DepSource::Path {
9984            caminho: "../caixa-teia/foo/bar".into(),
9985        });
9986        d.validate().unwrap();
9987    }
9988
9989    #[test]
9990    fn fonte_caminho_backslash_fires_before_shell_redirection() {
9991        // Cascade pin on the immediate-predecessor arm: a value carrying
9992        // both `\` and `<` / `>` (`"..\caixa-teia>build.log"` — the
9993        // canonical "I pasted a Windows-shell command with output
9994        // redirect" footgun) routes through `FonteCaminhoBackslash` not
9995        // `FonteCaminhoShellRedirection`. The cross-host-OS-separator
9996        // divergence is the load-bearing axis (an author who removes
9997        // the `\` is the root-cause edit; the `>` falls away in the
9998        // same edit since it's downstream of the Windows-shell
9999        // convention).
10000        let d = dep_with_fonte(DepSource::Path {
10001            caminho: "..\\caixa-teia>build.log".into(),
10002        });
10003        let err = d.validate().unwrap_err();
10004        assert!(
10005            matches!(err, DepError::FonteCaminhoBackslash { .. }),
10006            "got {err:?}",
10007        );
10008    }
10009
10010    #[test]
10011    fn fonte_caminho_control_char_fires_before_shell_redirection() {
10012        // Cascade pin on the embedded-control-byte arm: a value carrying
10013        // both a control byte and `<` / `>` (`"../foo\n>bar"` — the
10014        // canonical paste-from-multiline-doc footgun where a newline
10015        // landed mid-caminho) routes through `FonteCaminhoControlChar`
10016        // not `FonteCaminhoShellRedirection`. The POSIX-syscall-
10017        // rejected-byte / NUL-`CString::new`-fail diagnostic is the
10018        // load-bearing axis on every value that probes positive for
10019        // both — mirrors the cascade discipline on every prior arm.
10020        let d = dep_with_fonte(DepSource::Path {
10021            caminho: "../foo\n>bar".into(),
10022        });
10023        let err = d.validate().unwrap_err();
10024        assert!(
10025            matches!(err, DepError::FonteCaminhoControlChar { .. }),
10026            "got {err:?}",
10027        );
10028    }
10029
10030    #[test]
10031    fn fonte_caminho_absolute_fires_before_shell_redirection() {
10032        // Cascade pin on the load-bearing leading-byte arm: a leading
10033        // `/` value with embedded `<` / `>` (`"/etc/passwd>out"`)
10034        // routes through `FonteCaminhoAbsolute` not
10035        // `FonteCaminhoShellRedirection` — the host-layout-leak
10036        // diagnostic is the load-bearing axis, the `>` byte is the
10037        // secondary observation. Same precedence logic as every prior
10038        // leading-byte arm.
10039        let d = dep_with_fonte(DepSource::Path {
10040            caminho: "/etc/passwd>out".into(),
10041        });
10042        let err = d.validate().unwrap_err();
10043        assert!(
10044            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10045            "got {err:?}",
10046        );
10047    }
10048
10049    #[test]
10050    fn fonte_caminho_shell_redirection_fires_before_trailing_slash() {
10051        // Cascade pin on the immediate-successor arm: a value carrying
10052        // both `<` / `>` and a trailing `/` (`"../foo></"` — the
10053        // canonical "I tab-completed a path that already had a
10054        // redirect" footgun) routes through `FonteCaminhoShellRedirection`
10055        // not `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
10056        // the more semantic-locating axis (an author who removes the
10057        // `<` / `>` typically also drops the trailing separator since
10058        // both are paste-from-shell artifacts).
10059        let d = dep_with_fonte(DepSource::Path {
10060            caminho: "../foo></".into(),
10061        });
10062        let err = d.validate().unwrap_err();
10063        assert!(
10064            matches!(
10065                err,
10066                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
10067            ),
10068            "got {err:?}",
10069        );
10070    }
10071
10072    #[test]
10073    fn fonte_caminho_shell_redirection_diagnostic_carries_offending_dep_caminho_byte() {
10074        // Diagnostic-shape pin (peer with
10075        // `fonte_caminho_control_diagnostic_carries_offending_dep_caminho_byte`'s
10076        // payload assertion on the closest peer arm that also carries a
10077        // `byte` field): the error's Display surfaces the offending
10078        // `:nome`, the offending `:caminho` verbatim, and the offending
10079        // byte in hex (`0x3c` for `<`, `0x3e` for `>`) so a `feira lint`
10080        // run can render the diagnostic without re-parsing.
10081        let d = dep_with_fonte(DepSource::Path {
10082            caminho: "../caixa-teia>build.log".into(),
10083        });
10084        let rendered = d.validate().unwrap_err().to_string();
10085        assert!(
10086            rendered.contains("caixa-teia"),
10087            "diagnostic must name the offending dep: {rendered}",
10088        );
10089        assert!(
10090            rendered.contains("../caixa-teia>build.log"),
10091            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10092        );
10093        assert!(
10094            rendered.contains("0x3e"),
10095            "diagnostic must name the offending byte in hex: {rendered:?}",
10096        );
10097        assert!(
10098            rendered.contains("redirection"),
10099            "diagnostic must name the shell-redirection footgun: {rendered:?}",
10100        );
10101    }
10102
10103    // -- :caminho shell-pipe metacharacter arm ----------------------------
10104
10105    #[test]
10106    fn validate_rejects_path_fonte_with_caminho_carrying_pipe() {
10107        // The fail-before-pass-after pin for the canonical shell-pipe
10108        // paste footgun: an author copies a shell-history line
10109        // (`"../caixa-teia | grep foo"` — the canonical "I selected
10110        // the whole `ls dir | grep` line out of zsh history") and
10111        // silently passed every prior arm (`Path::is_absolute` false
10112        // on `..`, no control bytes, no backslash, no `<` / `>`,
10113        // doesn't end in `/`). The lacre embedded the value verbatim,
10114        // the resolver folded it through `Path::join` looking for a
10115        // literal `./../caixa-teia | grep foo` subdirectory, and the
10116        // failure surfaced at resolve time with a non-self-locating
10117        // `No such file or directory` error. The new arm moves the
10118        // rejection to validate time and names the offending dep +
10119        // caminho verbatim.
10120        let d = dep_with_fonte(DepSource::Path {
10121            caminho: "../caixa-teia | grep foo".into(),
10122        });
10123        let err = d.validate().unwrap_err();
10124        let DepError::FonteCaminhoShellPipe { nome, caminho } = err else {
10125            panic!("expected FonteCaminhoShellPipe, got {err:?}");
10126        };
10127        assert_eq!(nome, "caixa-teia");
10128        assert_eq!(caminho, "../caixa-teia | grep foo");
10129    }
10130
10131    #[test]
10132    fn validate_rejects_path_fonte_with_caminho_carrying_leading_pipe() {
10133        // Leading-position `|` shape (`"|../caixa-teia"` — the
10134        // degenerate "I forgot the source side of the pipe" idiom).
10135        // Pinned separately from the embedded-byte shape so the gate
10136        // covers every position, not only mid-path.
10137        let d = dep_with_fonte(DepSource::Path {
10138            caminho: "|../caixa-teia".into(),
10139        });
10140        let err = d.validate().unwrap_err();
10141        assert!(
10142            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10143            "got {err:?}",
10144        );
10145    }
10146
10147    #[test]
10148    fn validate_rejects_path_fonte_with_caminho_carrying_double_pipe_or() {
10149        // The bash short-circuit-OR shape (`"../caixa-teia||fallback"`
10150        // — the canonical "I copied a `cmd-a || cmd-b` fallback line"
10151        // idiom). The arm fires on the first `|` encountered; pinned
10152        // so a future arm that tries to distinguish `|` from `||`
10153        // doesn't break the broader contract.
10154        let d = dep_with_fonte(DepSource::Path {
10155            caminho: "../caixa-teia||fallback".into(),
10156        });
10157        let err = d.validate().unwrap_err();
10158        assert!(
10159            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10160            "got {err:?}",
10161        );
10162    }
10163
10164    #[test]
10165    fn validate_accepts_path_fonte_with_caminho_carrying_no_pipe() {
10166        // The positive-control pin: the gate targets only `|`, never
10167        // adjacent printable ASCII or POSIX-valid bytes. The canonical
10168        // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
10169        // pathed variant with adjacent printable punctuation
10170        // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
10171        // cleanly so the gate doesn't widen to a "no printable
10172        // punctuation anywhere" sweep that would defeat the entire
10173        // path-fonte author surface.
10174        let d = dep_with_fonte(DepSource::Path {
10175            caminho: "../caixa-teia/sub-dir.v2".into(),
10176        });
10177        d.validate().unwrap();
10178    }
10179
10180    #[test]
10181    fn fonte_caminho_shell_redirection_fires_before_shell_pipe() {
10182        // Cascade pin on the immediate-predecessor arm: a value carrying
10183        // both `<` / `>` and `|` (`"../caixa-teia<input|tee"` — the
10184        // canonical "I pasted a `cmd < input | tee` pipeline tail"
10185        // footgun) routes through `FonteCaminhoShellRedirection` not
10186        // `FonteCaminhoShellPipe`. The input/output redirection
10187        // metachar carries the more self-locating `byte: u8` payload
10188        // (it names which of `<` or `>` triggered), so the prior arm
10189        // wins on every probe-as-both value — same cascade discipline
10190        // every prior `:caminho` arm establishes.
10191        let d = dep_with_fonte(DepSource::Path {
10192            caminho: "../caixa-teia<input|tee".into(),
10193        });
10194        let err = d.validate().unwrap_err();
10195        assert!(
10196            matches!(
10197                err,
10198                DepError::FonteCaminhoShellRedirection { byte: b'<', .. }
10199            ),
10200            "got {err:?}",
10201        );
10202    }
10203
10204    #[test]
10205    fn fonte_caminho_backslash_fires_before_shell_pipe() {
10206        // Cascade pin on the upstream backslash arm: a value carrying
10207        // both `\` and `|` (`"..\caixa-teia|tee"` — the canonical
10208        // "I pasted a Windows-shell command with pipe to tee"
10209        // footgun) routes through `FonteCaminhoBackslash` not
10210        // `FonteCaminhoShellPipe`. The cross-host-OS-separator
10211        // divergence is the load-bearing axis on every probe-as-both
10212        // value (an author who removes the `\` is the root-cause edit;
10213        // the `|` falls away in the same edit since it's downstream of
10214        // the Windows-shell convention).
10215        let d = dep_with_fonte(DepSource::Path {
10216            caminho: "..\\caixa-teia|tee".into(),
10217        });
10218        let err = d.validate().unwrap_err();
10219        assert!(
10220            matches!(err, DepError::FonteCaminhoBackslash { .. }),
10221            "got {err:?}",
10222        );
10223    }
10224
10225    #[test]
10226    fn fonte_caminho_control_char_fires_before_shell_pipe() {
10227        // Cascade pin on the embedded-control-byte arm: a value
10228        // carrying both a control byte and `|` (`"../foo\n|bar"` —
10229        // the canonical paste-from-multiline-doc footgun where a
10230        // newline landed mid-caminho) routes through
10231        // `FonteCaminhoControlChar` not `FonteCaminhoShellPipe`. The
10232        // POSIX-syscall-rejected-byte / NUL-`CString::new`-fail
10233        // diagnostic is the load-bearing axis on every value that
10234        // probes positive for both — mirrors the cascade discipline
10235        // on every prior arm.
10236        let d = dep_with_fonte(DepSource::Path {
10237            caminho: "../foo\n|bar".into(),
10238        });
10239        let err = d.validate().unwrap_err();
10240        assert!(
10241            matches!(err, DepError::FonteCaminhoControlChar { .. }),
10242            "got {err:?}",
10243        );
10244    }
10245
10246    #[test]
10247    fn fonte_caminho_absolute_fires_before_shell_pipe() {
10248        // Cascade pin on the load-bearing leading-byte arm: a leading
10249        // `/` value with embedded `|` (`"/etc/passwd|tee"`) routes
10250        // through `FonteCaminhoAbsolute` not `FonteCaminhoShellPipe`
10251        // — the host-layout-leak diagnostic is the load-bearing axis,
10252        // the `|` byte is the secondary observation. Same precedence
10253        // logic as every prior leading-byte arm.
10254        let d = dep_with_fonte(DepSource::Path {
10255            caminho: "/etc/passwd|tee".into(),
10256        });
10257        let err = d.validate().unwrap_err();
10258        assert!(
10259            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10260            "got {err:?}",
10261        );
10262    }
10263
10264    #[test]
10265    fn fonte_caminho_shell_pipe_fires_before_trailing_slash() {
10266        // Cascade pin on the immediate-successor arm: a value carrying
10267        // both `|` and a trailing `/` (`"../foo|tee/"` — the canonical
10268        // "I tab-completed a path that already had a pipeline tail"
10269        // footgun) routes through `FonteCaminhoShellPipe` not
10270        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
10271        // the more semantic-locating axis (an author who removes the
10272        // `|` typically also drops the trailing separator since both
10273        // are paste-from-shell artifacts).
10274        let d = dep_with_fonte(DepSource::Path {
10275            caminho: "../foo|tee/".into(),
10276        });
10277        let err = d.validate().unwrap_err();
10278        assert!(
10279            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10280            "got {err:?}",
10281        );
10282    }
10283
10284    #[test]
10285    fn fonte_caminho_shell_pipe_diagnostic_carries_offending_dep_and_caminho() {
10286        // Diagnostic-shape pin (peer with
10287        // `fonte_caminho_backslash_diagnostic_carries_offending_dep_and_caminho`
10288        // on the closest single-byte peer arm): the error's Display
10289        // surfaces the offending `:nome` and the offending `:caminho`
10290        // verbatim, and names the shell-pipe footgun explicitly so a
10291        // `feira lint` run can render the diagnostic without
10292        // re-parsing.
10293        let d = dep_with_fonte(DepSource::Path {
10294            caminho: "../caixa-teia | grep foo".into(),
10295        });
10296        let rendered = d.validate().unwrap_err().to_string();
10297        assert!(
10298            rendered.contains("caixa-teia"),
10299            "diagnostic must name the offending dep: {rendered}",
10300        );
10301        assert!(
10302            rendered.contains("../caixa-teia | grep foo"),
10303            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10304        );
10305        assert!(
10306            rendered.contains('|'),
10307            "diagnostic must reference the pipe footgun: {rendered:?}",
10308        );
10309        assert!(
10310            rendered.contains("pipe"),
10311            "diagnostic must name the shell-pipe footgun: {rendered:?}",
10312        );
10313    }
10314
10315    // -- :caminho shell-command-separator metacharacter arm ---------------
10316
10317    #[test]
10318    fn validate_rejects_path_fonte_with_caminho_carrying_semicolon() {
10319        // The fail-before-pass-after pin for the canonical shell-command-
10320        // separator paste footgun: an author copies a shell one-liner
10321        // (`"../caixa-teia; rm -rf build"` — the canonical "I selected the
10322        // whole `cd path; do-thing` chain out of a shell-history block")
10323        // and silently passed every prior arm (`Path::is_absolute` false
10324        // on `..`, no control bytes, no backslash, no `<` / `>`, no `|`,
10325        // doesn't end in `/`). The lacre embedded the value verbatim, the
10326        // resolver folded it through `Path::join` looking for a literal
10327        // `./../caixa-teia; rm -rf build` subdirectory, and the failure
10328        // surfaced at resolve time with a non-self-locating `No such file
10329        // or directory` error. The new arm moves the rejection to validate
10330        // time and names the offending dep + caminho verbatim.
10331        let d = dep_with_fonte(DepSource::Path {
10332            caminho: "../caixa-teia; rm -rf build".into(),
10333        });
10334        let err = d.validate().unwrap_err();
10335        let DepError::FonteCaminhoShellSemicolon { nome, caminho } = err else {
10336            panic!("expected FonteCaminhoShellSemicolon, got {err:?}");
10337        };
10338        assert_eq!(nome, "caixa-teia");
10339        assert_eq!(caminho, "../caixa-teia; rm -rf build");
10340    }
10341
10342    #[test]
10343    fn validate_rejects_path_fonte_with_caminho_carrying_leading_semicolon() {
10344        // Leading-position `;` shape (`";../caixa-teia"` — the degenerate
10345        // "I forgot the prior command side of the separator" idiom).
10346        // Pinned separately from the embedded-byte shape so the gate
10347        // covers every position, not only mid-path.
10348        let d = dep_with_fonte(DepSource::Path {
10349            caminho: ";../caixa-teia".into(),
10350        });
10351        let err = d.validate().unwrap_err();
10352        assert!(
10353            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
10354            "got {err:?}",
10355        );
10356    }
10357
10358    #[test]
10359    fn validate_rejects_path_fonte_with_caminho_carrying_double_semicolon() {
10360        // The POSIX `case` arm `;;` terminator shape
10361        // (`"../caixa-teia;;next"` — the canonical "I copied a `case`
10362        // arm tail" idiom). The arm fires on the first `;` encountered;
10363        // pinned so a future arm that tries to distinguish `;` from `;;`
10364        // doesn't break the broader contract.
10365        let d = dep_with_fonte(DepSource::Path {
10366            caminho: "../caixa-teia;;next".into(),
10367        });
10368        let err = d.validate().unwrap_err();
10369        assert!(
10370            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
10371            "got {err:?}",
10372        );
10373    }
10374
10375    #[test]
10376    fn validate_accepts_path_fonte_with_caminho_carrying_no_semicolon() {
10377        // The positive-control pin: the gate targets only `;`, never
10378        // adjacent printable ASCII or POSIX-valid bytes. The canonical
10379        // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
10380        // pathed variant with adjacent printable punctuation
10381        // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
10382        // cleanly so the gate doesn't widen to a "no printable
10383        // punctuation anywhere" sweep that would defeat the entire
10384        // path-fonte author surface.
10385        let d = dep_with_fonte(DepSource::Path {
10386            caminho: "../caixa-teia/sub-dir.v2".into(),
10387        });
10388        d.validate().unwrap();
10389    }
10390
10391    #[test]
10392    fn fonte_caminho_shell_pipe_fires_before_shell_semicolon() {
10393        // Cascade pin on the immediate-predecessor arm: a value carrying
10394        // both `|` and `;` (`"../caixa-teia | tee; rm"` — the canonical
10395        // "I pasted a `cmd | tee; cleanup` chain" footgun) routes through
10396        // `FonteCaminhoShellPipe` not `FonteCaminhoShellSemicolon`. The
10397        // pipeline-tail paste is the load-bearing root-cause edit on
10398        // every probe-as-both value (an author who removes the `|`
10399        // typically also drops the trailing `; cleanup` since both are
10400        // the same paste-from-shell-history artifact) — same cascade
10401        // discipline every prior `:caminho` arm establishes.
10402        let d = dep_with_fonte(DepSource::Path {
10403            caminho: "../caixa-teia | tee; rm".into(),
10404        });
10405        let err = d.validate().unwrap_err();
10406        assert!(
10407            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10408            "got {err:?}",
10409        );
10410    }
10411
10412    #[test]
10413    fn fonte_caminho_shell_redirection_fires_before_shell_semicolon() {
10414        // Cascade pin on the upstream shell-redirection arm: a value
10415        // carrying both `<` / `>` and `;` (`"../caixa-teia>log; rm"` —
10416        // the canonical "I pasted a `cmd > log; cleanup` chain"
10417        // footgun) routes through `FonteCaminhoShellRedirection` not
10418        // `FonteCaminhoShellSemicolon`. The input/output redirection
10419        // metachar carries the more self-locating `byte: u8` payload
10420        // (it names which of `<` or `>` triggered), so the prior arm
10421        // wins on every probe-as-both value.
10422        let d = dep_with_fonte(DepSource::Path {
10423            caminho: "../caixa-teia>log; rm".into(),
10424        });
10425        let err = d.validate().unwrap_err();
10426        assert!(
10427            matches!(
10428                err,
10429                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
10430            ),
10431            "got {err:?}",
10432        );
10433    }
10434
10435    #[test]
10436    fn fonte_caminho_backslash_fires_before_shell_semicolon() {
10437        // Cascade pin on the upstream backslash arm: a value carrying
10438        // both `\` and `;` (`"..\caixa-teia;rm"` — the canonical "I
10439        // pasted a Windows-shell `cd ..\path; cleanup` chain") routes
10440        // through `FonteCaminhoBackslash` not `FonteCaminhoShellSemicolon`.
10441        // The cross-host-OS-separator divergence is the load-bearing axis
10442        // on every probe-as-both value (an author who removes the `\` is
10443        // the root-cause edit; the `;` falls away in the same edit since
10444        // it's downstream of the Windows-shell convention).
10445        let d = dep_with_fonte(DepSource::Path {
10446            caminho: "..\\caixa-teia;rm".into(),
10447        });
10448        let err = d.validate().unwrap_err();
10449        assert!(
10450            matches!(err, DepError::FonteCaminhoBackslash { .. }),
10451            "got {err:?}",
10452        );
10453    }
10454
10455    #[test]
10456    fn fonte_caminho_control_char_fires_before_shell_semicolon() {
10457        // Cascade pin on the embedded-control-byte arm: a value carrying
10458        // both a control byte and `;` (`"../foo\n;bar"` — the canonical
10459        // paste-from-multiline-doc footgun where a newline landed mid-
10460        // caminho) routes through `FonteCaminhoControlChar` not
10461        // `FonteCaminhoShellSemicolon`. The POSIX-syscall-rejected-byte
10462        // / NUL-`CString::new`-fail diagnostic is the load-bearing axis
10463        // on every value that probes positive for both — mirrors the
10464        // cascade discipline on every prior arm.
10465        let d = dep_with_fonte(DepSource::Path {
10466            caminho: "../foo\n;bar".into(),
10467        });
10468        let err = d.validate().unwrap_err();
10469        assert!(
10470            matches!(err, DepError::FonteCaminhoControlChar { .. }),
10471            "got {err:?}",
10472        );
10473    }
10474
10475    #[test]
10476    fn fonte_caminho_absolute_fires_before_shell_semicolon() {
10477        // Cascade pin on the load-bearing leading-byte arm: a leading
10478        // `/` value with embedded `;` (`"/etc/passwd;rm"`) routes
10479        // through `FonteCaminhoAbsolute` not `FonteCaminhoShellSemicolon`
10480        // — the host-layout-leak diagnostic is the load-bearing axis,
10481        // the `;` byte is the secondary observation. Same precedence
10482        // logic as every prior leading-byte arm.
10483        let d = dep_with_fonte(DepSource::Path {
10484            caminho: "/etc/passwd;rm".into(),
10485        });
10486        let err = d.validate().unwrap_err();
10487        assert!(
10488            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10489            "got {err:?}",
10490        );
10491    }
10492
10493    #[test]
10494    fn fonte_caminho_shell_semicolon_fires_before_trailing_slash() {
10495        // Cascade pin on the immediate-successor arm: a value carrying
10496        // both `;` and a trailing `/` (`"../foo;rm/"` — the canonical
10497        // "I tab-completed a path that already had a `; cleanup` tail"
10498        // footgun) routes through `FonteCaminhoShellSemicolon` not
10499        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
10500        // the more semantic-locating axis (an author who removes the
10501        // `;` typically also drops the trailing separator since both
10502        // are paste-from-shell artifacts).
10503        let d = dep_with_fonte(DepSource::Path {
10504            caminho: "../foo;rm/".into(),
10505        });
10506        let err = d.validate().unwrap_err();
10507        assert!(
10508            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
10509            "got {err:?}",
10510        );
10511    }
10512
10513    #[test]
10514    fn fonte_caminho_shell_semicolon_diagnostic_carries_offending_dep_and_caminho() {
10515        // Diagnostic-shape pin (peer with
10516        // `fonte_caminho_shell_pipe_diagnostic_carries_offending_dep_and_caminho`
10517        // on the closest single-byte peer arm): the error's Display
10518        // surfaces the offending `:nome` and the offending `:caminho`
10519        // verbatim, and names the shell-command-separator footgun
10520        // explicitly so a `feira lint` run can render the diagnostic
10521        // without re-parsing.
10522        let d = dep_with_fonte(DepSource::Path {
10523            caminho: "../caixa-teia; rm -rf build".into(),
10524        });
10525        let rendered = d.validate().unwrap_err().to_string();
10526        assert!(
10527            rendered.contains("caixa-teia"),
10528            "diagnostic must name the offending dep: {rendered}",
10529        );
10530        assert!(
10531            rendered.contains("../caixa-teia; rm -rf build"),
10532            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10533        );
10534        assert!(
10535            rendered.contains(';'),
10536            "diagnostic must reference the semicolon footgun: {rendered:?}",
10537        );
10538        assert!(
10539            rendered.contains("command-separator"),
10540            "diagnostic must name the shell-command-separator footgun: {rendered:?}",
10541        );
10542    }
10543
10544    #[test]
10545    fn validate_rejects_path_fonte_with_caminho_carrying_ampersand() {
10546        // The fail-before-pass-after pin for the canonical shell-
10547        // background-task paste footgun: an author copies a shell one-
10548        // liner (`"../caixa-teia & sleep 1"` — the canonical "I selected
10549        // the whole `cd path & sleep 1` background-launch out of a
10550        // shell-history block") and silently passed every prior arm
10551        // (`Path::is_absolute` false on `..`, no control bytes, no
10552        // backslash, no `<` / `>`, no `|`, no `;`, doesn't end in `/`).
10553        // The lacre embedded the value verbatim, the resolver folded it
10554        // through `Path::join` looking for a literal `./../caixa-teia &
10555        // sleep 1` subdirectory, and the failure surfaced at resolve
10556        // time with a non-self-locating `No such file or directory`
10557        // error. The new arm moves the rejection to validate time and
10558        // names the offending dep + caminho verbatim.
10559        let d = dep_with_fonte(DepSource::Path {
10560            caminho: "../caixa-teia & sleep 1".into(),
10561        });
10562        let err = d.validate().unwrap_err();
10563        let DepError::FonteCaminhoShellBackground { nome, caminho } = err else {
10564            panic!("expected FonteCaminhoShellBackground, got {err:?}");
10565        };
10566        assert_eq!(nome, "caixa-teia");
10567        assert_eq!(caminho, "../caixa-teia & sleep 1");
10568    }
10569
10570    #[test]
10571    fn validate_rejects_path_fonte_with_caminho_carrying_leading_ampersand() {
10572        // Leading-position `&` shape (`"&../caixa-teia"` — the
10573        // degenerate "I forgot the prior command side of the
10574        // background terminator" idiom). Pinned separately from the
10575        // embedded-byte shape so the gate covers every position, not
10576        // only mid-path.
10577        let d = dep_with_fonte(DepSource::Path {
10578            caminho: "&../caixa-teia".into(),
10579        });
10580        let err = d.validate().unwrap_err();
10581        assert!(
10582            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
10583            "got {err:?}",
10584        );
10585    }
10586
10587    #[test]
10588    fn validate_rejects_path_fonte_with_caminho_carrying_double_ampersand() {
10589        // The logical-AND `&&` shape (`"../caixa-teia && make"` — the
10590        // canonical "I copied a `cd path && make` build chain" idiom
10591        // every Makefile / shell-script wraps). The arm fires on the
10592        // first `&` encountered; pinned so a future arm that tries to
10593        // distinguish `&` from `&&` doesn't break the broader contract.
10594        let d = dep_with_fonte(DepSource::Path {
10595            caminho: "../caixa-teia && make".into(),
10596        });
10597        let err = d.validate().unwrap_err();
10598        assert!(
10599            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
10600            "got {err:?}",
10601        );
10602    }
10603
10604    #[test]
10605    fn validate_accepts_path_fonte_with_caminho_carrying_no_ampersand() {
10606        // The positive-control pin: the gate targets only `&`, never
10607        // adjacent printable ASCII or POSIX-valid bytes. The canonical
10608        // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
10609        // pathed variant with adjacent printable punctuation
10610        // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
10611        // cleanly so the gate doesn't widen to a "no printable
10612        // punctuation anywhere" sweep that would defeat the entire
10613        // path-fonte author surface.
10614        let d = dep_with_fonte(DepSource::Path {
10615            caminho: "../caixa-teia/sub-dir.v2".into(),
10616        });
10617        d.validate().unwrap();
10618    }
10619
10620    #[test]
10621    fn fonte_caminho_shell_semicolon_fires_before_shell_background() {
10622        // Cascade pin on the immediate-predecessor arm: a value carrying
10623        // both `;` and `&` (`"../caixa-teia; rm & sleep"` — the
10624        // canonical "I pasted a `cmd; cleanup & sleep` chain" footgun)
10625        // routes through `FonteCaminhoShellSemicolon` not
10626        // `FonteCaminhoShellBackground`. The sequential-command-
10627        // separator paste is the more common shell-history paste idiom
10628        // on every probe-as-both value (an author who removes the `;`
10629        // typically also drops the trailing `& sleep` since both are
10630        // paste-from-shell-history artifacts) — same cascade discipline
10631        // every prior `:caminho` arm establishes.
10632        let d = dep_with_fonte(DepSource::Path {
10633            caminho: "../caixa-teia; rm & sleep".into(),
10634        });
10635        let err = d.validate().unwrap_err();
10636        assert!(
10637            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
10638            "got {err:?}",
10639        );
10640    }
10641
10642    #[test]
10643    fn fonte_caminho_shell_pipe_fires_before_shell_background() {
10644        // Cascade pin on the upstream shell-pipe arm: a value carrying
10645        // both `|` and `&` (`"../caixa-teia | tee & sleep"` — the
10646        // canonical "I pasted a `cmd | tee & sleep` background-pipeline
10647        // chain" footgun) routes through `FonteCaminhoShellPipe` not
10648        // `FonteCaminhoShellBackground`. The pipeline-tail paste is the
10649        // load-bearing root-cause edit on every probe-as-both value.
10650        let d = dep_with_fonte(DepSource::Path {
10651            caminho: "../caixa-teia | tee & sleep".into(),
10652        });
10653        let err = d.validate().unwrap_err();
10654        assert!(
10655            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10656            "got {err:?}",
10657        );
10658    }
10659
10660    #[test]
10661    fn fonte_caminho_shell_redirection_fires_before_shell_background() {
10662        // Cascade pin on the upstream shell-redirection arm: a value
10663        // carrying both `>` and `&` (`"../caixa-teia>log & sleep"` —
10664        // the canonical "I pasted a `cmd > log & sleep` background-
10665        // redirect chain" footgun) routes through
10666        // `FonteCaminhoShellRedirection` not
10667        // `FonteCaminhoShellBackground`. The input/output redirection
10668        // metachar carries the more self-locating `byte: u8` payload
10669        // (it names which of `<` or `>` triggered), so the prior arm
10670        // wins on every probe-as-both value.
10671        let d = dep_with_fonte(DepSource::Path {
10672            caminho: "../caixa-teia>log & sleep".into(),
10673        });
10674        let err = d.validate().unwrap_err();
10675        assert!(
10676            matches!(
10677                err,
10678                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
10679            ),
10680            "got {err:?}",
10681        );
10682    }
10683
10684    #[test]
10685    fn fonte_caminho_backslash_fires_before_shell_background() {
10686        // Cascade pin on the upstream backslash arm: a value carrying
10687        // both `\` and `&` (`"..\caixa-teia & sleep"` — the canonical
10688        // "I pasted a Windows-shell `cd ..\path & sleep` background-
10689        // launch chain") routes through `FonteCaminhoBackslash` not
10690        // `FonteCaminhoShellBackground`. The cross-host-OS-separator
10691        // divergence is the load-bearing axis on every probe-as-both
10692        // value (an author who removes the `\` is the root-cause edit;
10693        // the `&` falls away in the same edit since it's downstream of
10694        // the Windows-shell convention).
10695        let d = dep_with_fonte(DepSource::Path {
10696            caminho: "..\\caixa-teia & sleep".into(),
10697        });
10698        let err = d.validate().unwrap_err();
10699        assert!(
10700            matches!(err, DepError::FonteCaminhoBackslash { .. }),
10701            "got {err:?}",
10702        );
10703    }
10704
10705    #[test]
10706    fn fonte_caminho_control_char_fires_before_shell_background() {
10707        // Cascade pin on the embedded-control-byte arm: a value
10708        // carrying both a control byte and `&` (`"../foo\n&sleep"` —
10709        // the canonical paste-from-multiline-doc footgun where a
10710        // newline landed mid-caminho) routes through
10711        // `FonteCaminhoControlChar` not `FonteCaminhoShellBackground`.
10712        // The POSIX-syscall-rejected-byte / NUL-`CString::new`-fail
10713        // diagnostic is the load-bearing axis on every value that
10714        // probes positive for both — mirrors the cascade discipline on
10715        // every prior arm.
10716        let d = dep_with_fonte(DepSource::Path {
10717            caminho: "../foo\n&sleep".into(),
10718        });
10719        let err = d.validate().unwrap_err();
10720        assert!(
10721            matches!(err, DepError::FonteCaminhoControlChar { .. }),
10722            "got {err:?}",
10723        );
10724    }
10725
10726    #[test]
10727    fn fonte_caminho_absolute_fires_before_shell_background() {
10728        // Cascade pin on the load-bearing leading-byte arm: a leading
10729        // `/` value with embedded `&` (`"/etc/passwd & sleep"`) routes
10730        // through `FonteCaminhoAbsolute` not
10731        // `FonteCaminhoShellBackground` — the host-layout-leak
10732        // diagnostic is the load-bearing axis, the `&` byte is the
10733        // secondary observation. Same precedence logic as every prior
10734        // leading-byte arm.
10735        let d = dep_with_fonte(DepSource::Path {
10736            caminho: "/etc/passwd & sleep".into(),
10737        });
10738        let err = d.validate().unwrap_err();
10739        assert!(
10740            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10741            "got {err:?}",
10742        );
10743    }
10744
10745    #[test]
10746    fn fonte_caminho_shell_background_fires_before_trailing_slash() {
10747        // Cascade pin on the immediate-successor arm: a value carrying
10748        // both `&` and a trailing `/` (`"../foo&sleep/"` — the
10749        // canonical "I tab-completed a path that already had a `&
10750        // sleep` background-launch tail" footgun) routes through
10751        // `FonteCaminhoShellBackground` not `FonteCaminhoTrailingSlash`.
10752        // The embedded shell-metachar is the more semantic-locating
10753        // axis (an author who removes the `&` typically also drops
10754        // the trailing separator since both are paste-from-shell
10755        // artifacts).
10756        let d = dep_with_fonte(DepSource::Path {
10757            caminho: "../foo&sleep/".into(),
10758        });
10759        let err = d.validate().unwrap_err();
10760        assert!(
10761            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
10762            "got {err:?}",
10763        );
10764    }
10765
10766    #[test]
10767    fn fonte_caminho_shell_background_diagnostic_carries_offending_dep_and_caminho() {
10768        // Diagnostic-shape pin (peer with
10769        // `fonte_caminho_shell_semicolon_diagnostic_carries_offending_dep_and_caminho`
10770        // on the closest single-byte peer arm): the error's Display
10771        // surfaces the offending `:nome` and the offending `:caminho`
10772        // verbatim, and names the shell-background / logical-AND
10773        // footgun explicitly so a `feira lint` run can render the
10774        // diagnostic without re-parsing.
10775        let d = dep_with_fonte(DepSource::Path {
10776            caminho: "../caixa-teia & sleep 1".into(),
10777        });
10778        let rendered = d.validate().unwrap_err().to_string();
10779        assert!(
10780            rendered.contains("caixa-teia"),
10781            "diagnostic must name the offending dep: {rendered}",
10782        );
10783        assert!(
10784            rendered.contains("../caixa-teia & sleep 1"),
10785            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10786        );
10787        assert!(
10788            rendered.contains('&'),
10789            "diagnostic must reference the ampersand footgun: {rendered:?}",
10790        );
10791        assert!(
10792            rendered.contains("background") || rendered.contains("list-AND"),
10793            "diagnostic must name the shell-background / logical-AND footgun: {rendered:?}",
10794        );
10795    }
10796
10797    #[test]
10798    fn validate_rejects_path_fonte_with_caminho_carrying_backtick() {
10799        // The fail-before-pass-after pin for the canonical shell-
10800        // command-substitution paste footgun: an author copies a
10801        // POSIX legacy backticked one-liner (`"../caixa-teia/`whoami`"`
10802        // — the canonical "I pasted a path that included a `pwd`
10803        // / `whoami` / `date` legacy command-substitution expansion
10804        // out of a shell-history block") and silently passed every
10805        // prior arm (`Path::is_absolute` false on `..`, no control
10806        // bytes, no `\`, no `<` / `>`, no `|`, no `;`, no `&`, doesn't
10807        // end in `/`). The lacre embedded the value verbatim, the
10808        // resolver folded it through `Path::join` looking for a
10809        // literal `./../caixa-teia/`whoami`` subdirectory, and the
10810        // failure surfaced at resolve time with a non-self-locating
10811        // `No such file or directory` error. The new arm moves the
10812        // rejection to validate time and names the offending dep +
10813        // caminho verbatim.
10814        let d = dep_with_fonte(DepSource::Path {
10815            caminho: "../caixa-teia/`whoami`".into(),
10816        });
10817        let err = d.validate().unwrap_err();
10818        let DepError::FonteCaminhoShellCommandSubstitution { nome, caminho } = err else {
10819            panic!("expected FonteCaminhoShellCommandSubstitution, got {err:?}");
10820        };
10821        assert_eq!(nome, "caixa-teia");
10822        assert_eq!(caminho, "../caixa-teia/`whoami`");
10823    }
10824
10825    #[test]
10826    fn validate_rejects_path_fonte_with_caminho_carrying_leading_backtick() {
10827        // Leading-position backtick shape (``"`pwd`/caixa-teia"`` —
10828        // the canonical `<backtick>pwd<backtick>/path` working-
10829        // directory expansion shape every shell-side path-composition
10830        // idiom carries). Pinned separately from the embedded-byte
10831        // shape so the gate covers every position, not only mid-path.
10832        let d = dep_with_fonte(DepSource::Path {
10833            caminho: "`pwd`/caixa-teia".into(),
10834        });
10835        let err = d.validate().unwrap_err();
10836        assert!(
10837            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
10838            "got {err:?}",
10839        );
10840    }
10841
10842    #[test]
10843    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_backtick() {
10844        // Trailing-position backtick shape (`"../caixa-teia`"` — the
10845        // degenerate "I selected an unbalanced backtick out of a
10846        // shell-history block" idiom that probes for the cascade's
10847        // last-byte handling). The trailing-`/` arm fires only on
10848        // last-byte `/`; an unbalanced trailing backtick must route
10849        // through this arm regardless of position.
10850        let d = dep_with_fonte(DepSource::Path {
10851            caminho: "../caixa-teia`".into(),
10852        });
10853        let err = d.validate().unwrap_err();
10854        assert!(
10855            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
10856            "got {err:?}",
10857        );
10858    }
10859
10860    #[test]
10861    fn validate_rejects_path_fonte_with_caminho_carrying_balanced_backtick_pair() {
10862        // The canonical balanced-pair shape (``"../<backtick>cat
10863        // /etc/passwd<backtick>"`` — the canonical CWE-78 shell-
10864        // command-injection paste idiom every shell-side hardening
10865        // guide enumerates first). The arm fires on the first
10866        // backtick encountered; pinned so a future arm that tries to
10867        // distinguish the opening from the closing byte doesn't break
10868        // the broader contract.
10869        let d = dep_with_fonte(DepSource::Path {
10870            caminho: "../`cat /etc/passwd`".into(),
10871        });
10872        let err = d.validate().unwrap_err();
10873        assert!(
10874            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
10875            "got {err:?}",
10876        );
10877    }
10878
10879    #[test]
10880    fn validate_accepts_path_fonte_with_caminho_carrying_no_backtick() {
10881        // The positive-control pin: the gate targets only the
10882        // backtick byte, never adjacent printable ASCII or POSIX-
10883        // valid bytes. The canonical relative POSIX path
10884        // (`"../caixa-teia"`) and a nested deeply-pathed variant with
10885        // adjacent printable punctuation
10886        // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
10887        // cleanly so the gate doesn't widen to a "no printable
10888        // punctuation anywhere" sweep that would defeat the entire
10889        // path-fonte author surface.
10890        let d = dep_with_fonte(DepSource::Path {
10891            caminho: "../caixa-teia/sub-dir.v2".into(),
10892        });
10893        d.validate().unwrap();
10894    }
10895
10896    #[test]
10897    fn fonte_caminho_shell_background_fires_before_shell_command_substitution() {
10898        // Cascade pin on the immediate-predecessor arm: a value
10899        // carrying both `&` and a backtick (``"../caixa-teia &
10900        // <backtick>sleep 1<backtick>"`` — the canonical "I pasted a
10901        // `cmd & <backtick>sleep N<backtick>` background-launch +
10902        // command-substitution chain" footgun) routes through
10903        // `FonteCaminhoShellBackground` not
10904        // `FonteCaminhoShellCommandSubstitution`. The background-
10905        // launch tail is the more common shell-history paste idiom
10906        // on every probe-as-both value — same cascade discipline
10907        // every prior `:caminho` arm establishes.
10908        let d = dep_with_fonte(DepSource::Path {
10909            caminho: "../caixa-teia & `sleep 1`".into(),
10910        });
10911        let err = d.validate().unwrap_err();
10912        assert!(
10913            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
10914            "got {err:?}",
10915        );
10916    }
10917
10918    #[test]
10919    fn fonte_caminho_shell_semicolon_fires_before_shell_command_substitution() {
10920        // Cascade pin on the upstream shell-semicolon arm: a value
10921        // carrying both `;` and a backtick (``"../caixa-teia;
10922        // <backtick>whoami<backtick>"`` — the canonical "I pasted a
10923        // `cmd; <backtick>follow-up<backtick>` sequential-chain
10924        // footgun) routes through `FonteCaminhoShellSemicolon` not
10925        // `FonteCaminhoShellCommandSubstitution`. The sequential-
10926        // command-separator paste is the load-bearing root-cause
10927        // edit on every probe-as-both value.
10928        let d = dep_with_fonte(DepSource::Path {
10929            caminho: "../caixa-teia; `whoami`".into(),
10930        });
10931        let err = d.validate().unwrap_err();
10932        assert!(
10933            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
10934            "got {err:?}",
10935        );
10936    }
10937
10938    #[test]
10939    fn fonte_caminho_shell_pipe_fires_before_shell_command_substitution() {
10940        // Cascade pin on the upstream shell-pipe arm: a value
10941        // carrying both `|` and a backtick (``"../caixa-teia |
10942        // <backtick>tee log<backtick>"`` — the canonical pipeline-to-
10943        // command-substitution paste idiom) routes through
10944        // `FonteCaminhoShellPipe` not
10945        // `FonteCaminhoShellCommandSubstitution`. The pipeline-tail
10946        // paste is the load-bearing root-cause edit on every
10947        // probe-as-both value.
10948        let d = dep_with_fonte(DepSource::Path {
10949            caminho: "../caixa-teia | `tee log`".into(),
10950        });
10951        let err = d.validate().unwrap_err();
10952        assert!(
10953            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10954            "got {err:?}",
10955        );
10956    }
10957
10958    #[test]
10959    fn fonte_caminho_shell_redirection_fires_before_shell_command_substitution() {
10960        // Cascade pin on the upstream shell-redirection arm: a value
10961        // carrying both `>` and a backtick (``"../caixa-teia>log
10962        // <backtick>date<backtick>"`` — the canonical "I pasted a
10963        // `cmd > log <backtick>date<backtick>` redirect-plus-
10964        // substitution chain" footgun) routes through
10965        // `FonteCaminhoShellRedirection` not
10966        // `FonteCaminhoShellCommandSubstitution`. The input/output
10967        // redirection metachar carries the more self-locating `byte`
10968        // payload (it names which of `<` or `>` triggered), so the
10969        // prior arm wins on every probe-as-both value.
10970        let d = dep_with_fonte(DepSource::Path {
10971            caminho: "../caixa-teia>log `date`".into(),
10972        });
10973        let err = d.validate().unwrap_err();
10974        assert!(
10975            matches!(
10976                err,
10977                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
10978            ),
10979            "got {err:?}",
10980        );
10981    }
10982
10983    #[test]
10984    fn fonte_caminho_backslash_fires_before_shell_command_substitution() {
10985        // Cascade pin on the upstream backslash arm: a value
10986        // carrying both `\` and a backtick (``"..\caixa-teia
10987        // <backtick>whoami<backtick>"`` — the canonical "I pasted a
10988        // Windows-shell `cd ..\path <backtick>whoami<backtick>`
10989        // chain") routes through `FonteCaminhoBackslash` not
10990        // `FonteCaminhoShellCommandSubstitution`. The cross-host-OS-
10991        // separator divergence is the load-bearing axis on every
10992        // probe-as-both value (an author who removes the `\` is the
10993        // root-cause edit; the backtick falls away in the same edit
10994        // since it's downstream of the Windows-shell convention).
10995        let d = dep_with_fonte(DepSource::Path {
10996            caminho: "..\\caixa-teia `whoami`".into(),
10997        });
10998        let err = d.validate().unwrap_err();
10999        assert!(
11000            matches!(err, DepError::FonteCaminhoBackslash { .. }),
11001            "got {err:?}",
11002        );
11003    }
11004
11005    #[test]
11006    fn fonte_caminho_control_char_fires_before_shell_command_substitution() {
11007        // Cascade pin on the embedded-control-byte arm: a value
11008        // carrying both a control byte and a backtick (`"../foo\n
11009        // `whoami`"` — the canonical paste-from-multiline-doc
11010        // footgun where a newline landed mid-caminho between two
11011        // paste fragments) routes through `FonteCaminhoControlChar`
11012        // not `FonteCaminhoShellCommandSubstitution`. The POSIX-
11013        // syscall-rejected-byte / NUL-`CString::new`-fail diagnostic
11014        // is the load-bearing axis on every value that probes
11015        // positive for both — mirrors the cascade discipline on
11016        // every prior arm.
11017        let d = dep_with_fonte(DepSource::Path {
11018            caminho: "../foo\n`whoami`".into(),
11019        });
11020        let err = d.validate().unwrap_err();
11021        assert!(
11022            matches!(err, DepError::FonteCaminhoControlChar { .. }),
11023            "got {err:?}",
11024        );
11025    }
11026
11027    #[test]
11028    fn fonte_caminho_absolute_fires_before_shell_command_substitution() {
11029        // Cascade pin on the load-bearing leading-byte arm: a
11030        // leading `/` value with embedded backtick (``"/etc/passwd
11031        // <backtick>whoami<backtick>"``) routes through
11032        // `FonteCaminhoAbsolute` not
11033        // `FonteCaminhoShellCommandSubstitution` — the host-layout-
11034        // leak diagnostic is the load-bearing axis, the backtick
11035        // byte is the secondary observation. Same precedence logic
11036        // as every prior leading-byte arm.
11037        let d = dep_with_fonte(DepSource::Path {
11038            caminho: "/etc/passwd `whoami`".into(),
11039        });
11040        let err = d.validate().unwrap_err();
11041        assert!(
11042            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11043            "got {err:?}",
11044        );
11045    }
11046
11047    #[test]
11048    fn fonte_caminho_shell_command_substitution_fires_before_trailing_slash() {
11049        // Cascade pin on the immediate-successor arm: a value
11050        // carrying both a backtick and a trailing `/`
11051        // (``"../`whoami`/"`` — the canonical "I tab-completed a
11052        // path that already had a backticked `whoami` substitution
11053        // tail" footgun) routes through
11054        // `FonteCaminhoShellCommandSubstitution` not
11055        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
11056        // is the more semantic-locating axis (an author who removes
11057        // the backtick typically also drops the trailing separator
11058        // since both are paste-from-shell artifacts).
11059        let d = dep_with_fonte(DepSource::Path {
11060            caminho: "../`whoami`/".into(),
11061        });
11062        let err = d.validate().unwrap_err();
11063        assert!(
11064            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11065            "got {err:?}",
11066        );
11067    }
11068
11069    #[test]
11070    fn fonte_caminho_shell_command_substitution_diagnostic_carries_offending_dep_and_caminho() {
11071        // Diagnostic-shape pin (peer with
11072        // `fonte_caminho_shell_background_diagnostic_carries_offending_dep_and_caminho`
11073        // on the closest single-byte peer arm): the error's Display
11074        // surfaces the offending `:nome` and the offending `:caminho`
11075        // verbatim, and names the shell-command-substitution footgun
11076        // explicitly so a `feira lint` run can render the diagnostic
11077        // without re-parsing.
11078        let d = dep_with_fonte(DepSource::Path {
11079            caminho: "../caixa-teia/`whoami`".into(),
11080        });
11081        let rendered = d.validate().unwrap_err().to_string();
11082        assert!(
11083            rendered.contains("caixa-teia"),
11084            "diagnostic must name the offending dep: {rendered}",
11085        );
11086        assert!(
11087            rendered.contains("../caixa-teia/`whoami`"),
11088            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11089        );
11090        assert!(
11091            rendered.contains('`'),
11092            "diagnostic must reference the backtick footgun: {rendered:?}",
11093        );
11094        assert!(
11095            rendered.contains("command-substitution"),
11096            "diagnostic must name the shell-command-substitution footgun: {rendered:?}",
11097        );
11098    }
11099
11100    #[test]
11101    fn validate_rejects_path_fonte_with_caminho_carrying_star_glob() {
11102        // The fail-before-pass-after pin for the canonical pathname-
11103        // expansion paste footgun: an author copies an `ls
11104        // ../caixa-teia/*` shell-listing tail into the `:caminho`
11105        // slot and silently passes every prior arm
11106        // (`Path::is_absolute` false on `..`, no control bytes, no
11107        // `\`, no `<` / `>`, no `|`, no `;`, no `&`, no backtick,
11108        // doesn't end in `/`). The lacre embedded the value
11109        // verbatim, the resolver folded it through `Path::join`
11110        // looking for a literal `./../caixa-teia/*` subdirectory,
11111        // and the failure surfaced at resolve time with a non-self-
11112        // locating `No such file or directory` error. The new arm
11113        // moves the rejection to validate time and names the
11114        // offending dep + caminho + byte verbatim.
11115        let d = dep_with_fonte(DepSource::Path {
11116            caminho: "../caixa-teia/*".into(),
11117        });
11118        let err = d.validate().unwrap_err();
11119        let DepError::FonteCaminhoShellGlob {
11120            nome,
11121            caminho,
11122            byte,
11123        } = err
11124        else {
11125            panic!("expected FonteCaminhoShellGlob, got {err:?}");
11126        };
11127        assert_eq!(nome, "caixa-teia");
11128        assert_eq!(caminho, "../caixa-teia/*");
11129        assert_eq!(byte, b'*');
11130    }
11131
11132    #[test]
11133    fn validate_rejects_path_fonte_with_caminho_carrying_question_glob() {
11134        // The symmetric single-char-wildcard paste shape
11135        // (`"../foo?"` — the canonical "I copied a `rm foo?` line
11136        // out of shell history" idiom). Pinned separately from the
11137        // `*` shape so the gate's contract is "any `*` or `?`
11138        // anywhere", not single-byte coverage.
11139        let d = dep_with_fonte(DepSource::Path {
11140            caminho: "../foo?".into(),
11141        });
11142        let err = d.validate().unwrap_err();
11143        let DepError::FonteCaminhoShellGlob { byte, .. } = err else {
11144            panic!("expected FonteCaminhoShellGlob, got {err:?}");
11145        };
11146        assert_eq!(byte, b'?');
11147    }
11148
11149    #[test]
11150    fn validate_rejects_path_fonte_with_caminho_carrying_leading_star_glob() {
11151        // Leading-position `*` shape (`"*/caixa-teia"` — the
11152        // degenerate "I selected only the wildcard prefix out of a
11153        // shell-glob expression" idiom). Pinned separately from the
11154        // embedded-byte shapes so the gate covers every position,
11155        // not only mid-path.
11156        let d = dep_with_fonte(DepSource::Path {
11157            caminho: "*/caixa-teia".into(),
11158        });
11159        let err = d.validate().unwrap_err();
11160        assert!(
11161            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
11162            "got {err:?}",
11163        );
11164    }
11165
11166    #[test]
11167    fn validate_rejects_path_fonte_with_caminho_carrying_double_star_recursive_glob() {
11168        // The bash/zsh `globstar` recursive-glob shape
11169        // (`"../caixa-teia/**/foo"` — the canonical "I copied a
11170        // `find ../caixa-teia/**/foo` recursive expansion" idiom).
11171        // The arm fires on the first `*` encountered; pinned so a
11172        // future arm that tries to distinguish single `*` from
11173        // double `**` doesn't break the broader contract.
11174        let d = dep_with_fonte(DepSource::Path {
11175            caminho: "../caixa-teia/**/foo".into(),
11176        });
11177        let err = d.validate().unwrap_err();
11178        assert!(
11179            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
11180            "got {err:?}",
11181        );
11182    }
11183
11184    #[test]
11185    fn validate_rejects_path_fonte_with_caminho_carrying_dotted_extension_glob() {
11186        // The canonical extension-glob shape (`"../caixa-teia/*.lisp"`
11187        // — the "I selected `*.lisp` to mean every Lisp source file
11188        // in the dep root" footgun the prior arms structurally
11189        // cannot catch since `.` is a POSIX-valid path-component
11190        // byte). Pinned so the gate's contract covers the most
11191        // idiomatic glob-paste shape every author meets first.
11192        let d = dep_with_fonte(DepSource::Path {
11193            caminho: "../caixa-teia/*.lisp".into(),
11194        });
11195        let err = d.validate().unwrap_err();
11196        assert!(
11197            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
11198            "got {err:?}",
11199        );
11200    }
11201
11202    #[test]
11203    fn validate_accepts_path_fonte_with_caminho_carrying_no_glob() {
11204        // The positive-control pin: the gate targets only `*` /
11205        // `?`, never adjacent printable ASCII or POSIX-valid bytes.
11206        // The canonical relative POSIX path (`"../caixa-teia"`) and
11207        // a nested deeply-pathed variant with adjacent printable
11208        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
11209        // to validate cleanly so the gate doesn't widen to a "no
11210        // printable punctuation anywhere" sweep that would defeat
11211        // the entire path-fonte author surface.
11212        let d = dep_with_fonte(DepSource::Path {
11213            caminho: "../caixa-teia/sub-dir.v2".into(),
11214        });
11215        d.validate().unwrap();
11216    }
11217
11218    #[test]
11219    fn fonte_caminho_shell_command_substitution_fires_before_shell_glob() {
11220        // Cascade pin on the immediate-predecessor arm: a value
11221        // carrying both a backtick and `*` (``"../`whoami`/*"`` —
11222        // the canonical "I pasted a `cd <backtick>whoami<backtick>/*`
11223        // command-substitution + glob chain") routes through
11224        // `FonteCaminhoShellCommandSubstitution` not
11225        // `FonteCaminhoShellGlob`. The CWE-78 shell-command-
11226        // injection vector is the load-bearing root-cause edit on
11227        // every probe-as-both value — same cascade discipline every
11228        // prior `:caminho` arm establishes.
11229        let d = dep_with_fonte(DepSource::Path {
11230            caminho: "../`whoami`/*".into(),
11231        });
11232        let err = d.validate().unwrap_err();
11233        assert!(
11234            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11235            "got {err:?}",
11236        );
11237    }
11238
11239    #[test]
11240    fn fonte_caminho_shell_background_fires_before_shell_glob() {
11241        // Cascade pin on the upstream shell-background arm: a value
11242        // carrying both `&` and `*` (`"../caixa-teia & ls /*"` — the
11243        // canonical "I pasted a `cmd & ls /*` background + glob
11244        // chain" footgun) routes through `FonteCaminhoShellBackground`
11245        // not `FonteCaminhoShellGlob`. The background-launch tail is
11246        // the load-bearing root-cause edit on every probe-as-both
11247        // value.
11248        let d = dep_with_fonte(DepSource::Path {
11249            caminho: "../caixa-teia & ls /*".into(),
11250        });
11251        let err = d.validate().unwrap_err();
11252        assert!(
11253            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11254            "got {err:?}",
11255        );
11256    }
11257
11258    #[test]
11259    fn fonte_caminho_shell_semicolon_fires_before_shell_glob() {
11260        // Cascade pin on the upstream shell-semicolon arm: a value
11261        // carrying both `;` and `*` (`"../caixa-teia; rm *"` — the
11262        // canonical sequential-cleanup + glob paste idiom) routes
11263        // through `FonteCaminhoShellSemicolon` not
11264        // `FonteCaminhoShellGlob`. The sequential-command-separator
11265        // paste is the load-bearing root-cause edit on every
11266        // probe-as-both value.
11267        let d = dep_with_fonte(DepSource::Path {
11268            caminho: "../caixa-teia; rm *".into(),
11269        });
11270        let err = d.validate().unwrap_err();
11271        assert!(
11272            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11273            "got {err:?}",
11274        );
11275    }
11276
11277    #[test]
11278    fn fonte_caminho_shell_pipe_fires_before_shell_glob() {
11279        // Cascade pin on the upstream shell-pipe arm: a value
11280        // carrying both `|` and `*` (`"../caixa-teia | ls *"` — the
11281        // canonical pipeline-to-glob paste idiom) routes through
11282        // `FonteCaminhoShellPipe` not `FonteCaminhoShellGlob`. The
11283        // pipeline-tail paste is the load-bearing root-cause edit
11284        // on every probe-as-both value.
11285        let d = dep_with_fonte(DepSource::Path {
11286            caminho: "../caixa-teia | ls *".into(),
11287        });
11288        let err = d.validate().unwrap_err();
11289        assert!(
11290            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11291            "got {err:?}",
11292        );
11293    }
11294
11295    #[test]
11296    fn fonte_caminho_shell_redirection_fires_before_shell_glob() {
11297        // Cascade pin on the upstream shell-redirection arm: a value
11298        // carrying both `>` and `*` (`"../caixa-teia>log *"` — the
11299        // canonical "I pasted a `cmd > log *` redirect-plus-glob
11300        // chain" footgun) routes through
11301        // `FonteCaminhoShellRedirection` not `FonteCaminhoShellGlob`.
11302        // The input/output redirection metachar carries the more
11303        // self-locating `byte` payload (it names which of `<` or `>`
11304        // triggered), so the prior arm wins on every probe-as-both
11305        // value.
11306        let d = dep_with_fonte(DepSource::Path {
11307            caminho: "../caixa-teia>log *".into(),
11308        });
11309        let err = d.validate().unwrap_err();
11310        assert!(
11311            matches!(
11312                err,
11313                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11314            ),
11315            "got {err:?}",
11316        );
11317    }
11318
11319    #[test]
11320    fn fonte_caminho_backslash_fires_before_shell_glob() {
11321        // Cascade pin on the upstream backslash arm: a value
11322        // carrying both `\` and `*` (`"..\caixa-teia\*"` — the
11323        // canonical "I pasted a Windows-shell `cd ..\path\*` glob
11324        // expression" footgun) routes through
11325        // `FonteCaminhoBackslash` not `FonteCaminhoShellGlob`. The
11326        // cross-host-OS-separator divergence is the load-bearing
11327        // axis on every probe-as-both value (an author who removes
11328        // the `\` is the root-cause edit; the `*` falls away in the
11329        // same edit since it's downstream of the Windows-shell
11330        // convention).
11331        let d = dep_with_fonte(DepSource::Path {
11332            caminho: "..\\caixa-teia\\*".into(),
11333        });
11334        let err = d.validate().unwrap_err();
11335        assert!(
11336            matches!(err, DepError::FonteCaminhoBackslash { .. }),
11337            "got {err:?}",
11338        );
11339    }
11340
11341    #[test]
11342    fn fonte_caminho_control_char_fires_before_shell_glob() {
11343        // Cascade pin on the embedded-control-byte arm: a value
11344        // carrying both a control byte and `*` (`"../foo\n*"` — the
11345        // canonical paste-from-multiline-doc footgun where a
11346        // newline landed mid-caminho between two paste fragments)
11347        // routes through `FonteCaminhoControlChar` not
11348        // `FonteCaminhoShellGlob`. The POSIX-syscall-rejected-byte /
11349        // NUL-`CString::new`-fail diagnostic is the load-bearing
11350        // axis on every value that probes positive for both —
11351        // mirrors the cascade discipline on every prior arm.
11352        let d = dep_with_fonte(DepSource::Path {
11353            caminho: "../foo\n*".into(),
11354        });
11355        let err = d.validate().unwrap_err();
11356        assert!(
11357            matches!(err, DepError::FonteCaminhoControlChar { .. }),
11358            "got {err:?}",
11359        );
11360    }
11361
11362    #[test]
11363    fn fonte_caminho_absolute_fires_before_shell_glob() {
11364        // Cascade pin on the load-bearing leading-byte arm: a
11365        // leading `/` value with embedded `*` (`"/etc/*"`) routes
11366        // through `FonteCaminhoAbsolute` not `FonteCaminhoShellGlob`
11367        // — the host-layout-leak diagnostic is the load-bearing
11368        // axis, the glob byte is the secondary observation. Same
11369        // precedence logic as every prior leading-byte arm.
11370        let d = dep_with_fonte(DepSource::Path {
11371            caminho: "/etc/*".into(),
11372        });
11373        let err = d.validate().unwrap_err();
11374        assert!(
11375            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11376            "got {err:?}",
11377        );
11378    }
11379
11380    #[test]
11381    fn fonte_caminho_shell_glob_fires_before_trailing_slash() {
11382        // Cascade pin on the immediate-successor arm: a value
11383        // carrying both `*` and a trailing `/` (`"../foo*/"` — the
11384        // canonical "I tab-completed a path that already had a
11385        // glob-expansion tail" footgun) routes through
11386        // `FonteCaminhoShellGlob` not `FonteCaminhoTrailingSlash`.
11387        // The embedded shell-metachar is the more semantic-locating
11388        // axis (an author who removes the `*` typically also drops
11389        // the trailing separator since both are paste-from-shell
11390        // artifacts).
11391        let d = dep_with_fonte(DepSource::Path {
11392            caminho: "../foo*/".into(),
11393        });
11394        let err = d.validate().unwrap_err();
11395        assert!(
11396            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
11397            "got {err:?}",
11398        );
11399    }
11400
11401    #[test]
11402    fn fonte_caminho_shell_glob_diagnostic_carries_offending_dep_caminho_and_byte() {
11403        // Diagnostic-shape pin (peer with
11404        // `fonte_caminho_shell_redirection_diagnostic_*` on the
11405        // closest two-byte peer arm): the error's Display surfaces
11406        // the offending `:nome`, the offending `:caminho` verbatim,
11407        // the offending byte's hex / character form, and names the
11408        // shell-glob / pathname-expansion footgun explicitly so a
11409        // `feira lint` run can render the diagnostic without
11410        // re-parsing.
11411        let d = dep_with_fonte(DepSource::Path {
11412            caminho: "../caixa-teia/*.lisp".into(),
11413        });
11414        let rendered = d.validate().unwrap_err().to_string();
11415        assert!(
11416            rendered.contains("caixa-teia"),
11417            "diagnostic must name the offending dep: {rendered}",
11418        );
11419        assert!(
11420            rendered.contains("../caixa-teia/*.lisp"),
11421            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11422        );
11423        assert!(
11424            rendered.contains("0x2a"),
11425            "diagnostic must surface the offending byte hex: {rendered:?}",
11426        );
11427        assert!(
11428            rendered.contains("glob"),
11429            "diagnostic must name the shell-glob footgun: {rendered:?}",
11430        );
11431        assert!(
11432            rendered.contains("pathname-expansion"),
11433            "diagnostic must reference the POSIX pathname-expansion vocabulary: {rendered:?}",
11434        );
11435    }
11436
11437    #[test]
11438    fn validate_rejects_path_fonte_with_caminho_carrying_modern_command_substitution() {
11439        // The fail-before-pass-after pin for the canonical modern-Bourne
11440        // command-substitution paste footgun: an author copies a
11441        // `cd ../caixa-teia/$(date)/build` shell-history one-liner whose
11442        // `$(<cmd>)` expansion would land the current date as a
11443        // subdirectory name and silently passed every prior arm
11444        // (`Path::is_absolute` false on `..`, no control bytes, no `\`,
11445        // no `<` / `>`, no `|`, no `;`, no `&`, no backtick, no `*` /
11446        // `?`, doesn't end in `/`; the leading-`$` f4efe9c
11447        // `FonteCaminhoVarExpansion` arm doesn't fire because the `$`
11448        // sits mid-path). The lacre embedded the value verbatim, the
11449        // resolver folded it through `Path::join` looking for a literal
11450        // `./../caixa-teia/$(date)/build` subdirectory, and the failure
11451        // surfaced at resolve time with a non-self-locating `No such
11452        // file or directory` error. The new arm moves the rejection to
11453        // validate time and names the offending dep + caminho + byte
11454        // verbatim. The arm fires on the first `(` encountered (the
11455        // opening byte of `$(date)`).
11456        let d = dep_with_fonte(DepSource::Path {
11457            caminho: "../caixa-teia/$(date)/build".into(),
11458        });
11459        let err = d.validate().unwrap_err();
11460        let DepError::FonteCaminhoShellSubshellGrouping {
11461            nome,
11462            caminho,
11463            byte,
11464        } = err
11465        else {
11466            panic!("expected FonteCaminhoShellSubshellGrouping, got {err:?}");
11467        };
11468        assert_eq!(nome, "caixa-teia");
11469        assert_eq!(caminho, "../caixa-teia/$(date)/build");
11470        assert_eq!(byte, b'(');
11471    }
11472
11473    #[test]
11474    fn validate_rejects_path_fonte_with_caminho_carrying_close_paren() {
11475        // The symmetric close-paren paste shape (`"../caixa-teia)"` —
11476        // the degenerate "I selected an unbalanced closing paren out of
11477        // a shell-history block" idiom that probes for the cascade's
11478        // last-byte handling on a value carrying only the closing byte).
11479        // Pinned separately from the open-paren shape so the gate's
11480        // contract is "any `(` or `)` anywhere", not single-byte
11481        // coverage. Mirrors the peer `validate_rejects_path_fonte_with_\
11482        // caminho_carrying_question_glob` shape on the immediate-
11483        // predecessor `FonteCaminhoShellGlob` arm.
11484        let d = dep_with_fonte(DepSource::Path {
11485            caminho: "../caixa-teia)".into(),
11486        });
11487        let err = d.validate().unwrap_err();
11488        let DepError::FonteCaminhoShellSubshellGrouping { byte, .. } = err else {
11489            panic!("expected FonteCaminhoShellSubshellGrouping, got {err:?}");
11490        };
11491        assert_eq!(byte, b')');
11492    }
11493
11494    #[test]
11495    fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_paren() {
11496        // Leading-position `(` shape (`"(cd foo)/caixa-teia"` — the
11497        // canonical "I selected a `(cd foo)` subshell-grouping prefix
11498        // out of a `(cd foo) && cmd` shell-history one-liner" idiom).
11499        // Pinned separately from the embedded-byte shape so the gate
11500        // covers every position, not only mid-path.
11501        let d = dep_with_fonte(DepSource::Path {
11502            caminho: "(cd foo)/caixa-teia".into(),
11503        });
11504        let err = d.validate().unwrap_err();
11505        assert!(
11506            matches!(
11507                err,
11508                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
11509            ),
11510            "got {err:?}",
11511        );
11512    }
11513
11514    #[test]
11515    fn validate_rejects_path_fonte_with_caminho_carrying_balanced_subshell_grouping_pair() {
11516        // The canonical balanced-pair shape (`"../(pwd)/caixa-teia"`
11517        // — the canonical "I copied a `(pwd)` working-directory-probe
11518        // subshell-grouping idiom every shell-history block carries"
11519        // footgun). The value carries no other cascade-preceding
11520        // shell metachar (`&` / `;` / `|` / `<` / `>` / backtick /
11521        // `*` / `?`) so the arm fires on the first `(` encountered;
11522        // pinned so a future arm that tries to distinguish the
11523        // opening from the closing byte doesn't break the broader
11524        // contract. Mirrors the peer
11525        // `validate_rejects_path_fonte_with_caminho_carrying_balanced_\
11526        // backtick_pair` shape on the upstream `FonteCaminhoShell\
11527        // CommandSubstitution` arm.
11528        let d = dep_with_fonte(DepSource::Path {
11529            caminho: "../(pwd)/caixa-teia".into(),
11530        });
11531        let err = d.validate().unwrap_err();
11532        assert!(
11533            matches!(
11534                err,
11535                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
11536            ),
11537            "got {err:?}",
11538        );
11539    }
11540
11541    #[test]
11542    fn validate_accepts_path_fonte_with_caminho_carrying_no_subshell_grouping() {
11543        // The positive-control pin: the gate targets only `(` / `)`,
11544        // never adjacent printable ASCII or POSIX-valid bytes. The
11545        // canonical relative POSIX path (`"../caixa-teia"`) and a
11546        // nested deeply-pathed variant with adjacent printable
11547        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue to
11548        // validate cleanly so the gate doesn't widen to a "no printable
11549        // punctuation anywhere" sweep that would defeat the entire
11550        // path-fonte author surface.
11551        let d = dep_with_fonte(DepSource::Path {
11552            caminho: "../caixa-teia/sub-dir.v2".into(),
11553        });
11554        d.validate().unwrap();
11555    }
11556
11557    #[test]
11558    fn fonte_caminho_shell_glob_fires_before_shell_subshell_grouping() {
11559        // Cascade pin on the immediate-predecessor arm: a value
11560        // carrying both `*` and `(` (`"../caixa-teia/*(date)"` — the
11561        // canonical "I pasted a glob expansion followed by a
11562        // subshell-grouping tail" footgun) routes through
11563        // `FonteCaminhoShellGlob` not
11564        // `FonteCaminhoShellSubshellGrouping`. The pathname-expansion
11565        // shape is the more common shell-history paste idiom on every
11566        // probe-as-both value — same cascade discipline every prior
11567        // `:caminho` arm establishes.
11568        let d = dep_with_fonte(DepSource::Path {
11569            caminho: "../caixa-teia/*(date)".into(),
11570        });
11571        let err = d.validate().unwrap_err();
11572        assert!(
11573            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
11574            "got {err:?}",
11575        );
11576    }
11577
11578    #[test]
11579    fn fonte_caminho_shell_command_substitution_fires_before_shell_subshell_grouping() {
11580        // Cascade pin on the upstream shell-command-substitution arm: a
11581        // value carrying both a backtick and `(` (``"../`whoami`/$(date)"``
11582        // — the canonical "I pasted a legacy-backtick + modern-paren
11583        // command-substitution chain" footgun) routes through
11584        // `FonteCaminhoShellCommandSubstitution` not
11585        // `FonteCaminhoShellSubshellGrouping`. The CWE-78 shell-
11586        // command-injection vector is the load-bearing root-cause edit
11587        // on every probe-as-both value.
11588        let d = dep_with_fonte(DepSource::Path {
11589            caminho: "../`whoami`/$(date)".into(),
11590        });
11591        let err = d.validate().unwrap_err();
11592        assert!(
11593            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11594            "got {err:?}",
11595        );
11596    }
11597
11598    #[test]
11599    fn fonte_caminho_shell_background_fires_before_shell_subshell_grouping() {
11600        // Cascade pin on the upstream shell-background arm: a value
11601        // carrying both `&` and `(` (`"../caixa-teia & (cd foo)"` —
11602        // the canonical "I pasted a `cmd & (cd foo)` background-launch
11603        // + subshell-grouping chain" footgun) routes through
11604        // `FonteCaminhoShellBackground` not
11605        // `FonteCaminhoShellSubshellGrouping`. The background-launch
11606        // tail is the load-bearing root-cause edit on every probe-as-
11607        // both value.
11608        let d = dep_with_fonte(DepSource::Path {
11609            caminho: "../caixa-teia & (cd foo)".into(),
11610        });
11611        let err = d.validate().unwrap_err();
11612        assert!(
11613            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11614            "got {err:?}",
11615        );
11616    }
11617
11618    #[test]
11619    fn fonte_caminho_shell_semicolon_fires_before_shell_subshell_grouping() {
11620        // Cascade pin on the upstream shell-semicolon arm: a value
11621        // carrying both `;` and `(` (`"../caixa-teia; (cd foo)"` —
11622        // the canonical sequential-cleanup + subshell-grouping paste
11623        // idiom) routes through `FonteCaminhoShellSemicolon` not
11624        // `FonteCaminhoShellSubshellGrouping`. The sequential-command-
11625        // separator paste is the load-bearing root-cause edit on
11626        // every probe-as-both value.
11627        let d = dep_with_fonte(DepSource::Path {
11628            caminho: "../caixa-teia; (cd foo)".into(),
11629        });
11630        let err = d.validate().unwrap_err();
11631        assert!(
11632            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11633            "got {err:?}",
11634        );
11635    }
11636
11637    #[test]
11638    fn fonte_caminho_shell_pipe_fires_before_shell_subshell_grouping() {
11639        // Cascade pin on the upstream shell-pipe arm: a value carrying
11640        // both `|` and `(` (`"../caixa-teia | (tee log)"` — the
11641        // canonical pipeline-to-subshell-grouping paste idiom) routes
11642        // through `FonteCaminhoShellPipe` not
11643        // `FonteCaminhoShellSubshellGrouping`. The pipeline-tail paste
11644        // is the load-bearing root-cause edit on every probe-as-both
11645        // value.
11646        let d = dep_with_fonte(DepSource::Path {
11647            caminho: "../caixa-teia | (tee log)".into(),
11648        });
11649        let err = d.validate().unwrap_err();
11650        assert!(
11651            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11652            "got {err:?}",
11653        );
11654    }
11655
11656    #[test]
11657    fn fonte_caminho_shell_redirection_fires_before_shell_subshell_grouping() {
11658        // Cascade pin on the upstream shell-redirection arm: a value
11659        // carrying both `>` and `(` (`"../caixa-teia>log (cd foo)"` —
11660        // the canonical "I pasted a `cmd > log (cd foo)` redirect-
11661        // plus-subshell-grouping chain" footgun) routes through
11662        // `FonteCaminhoShellRedirection` not
11663        // `FonteCaminhoShellSubshellGrouping`. The input/output
11664        // redirection metachar carries the more self-locating `byte`
11665        // payload (it names which of `<` or `>` triggered), so the
11666        // prior arm wins on every probe-as-both value.
11667        let d = dep_with_fonte(DepSource::Path {
11668            caminho: "../caixa-teia>log (cd foo)".into(),
11669        });
11670        let err = d.validate().unwrap_err();
11671        assert!(
11672            matches!(
11673                err,
11674                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11675            ),
11676            "got {err:?}",
11677        );
11678    }
11679
11680    #[test]
11681    fn fonte_caminho_backslash_fires_before_shell_subshell_grouping() {
11682        // Cascade pin on the upstream backslash arm: a value carrying
11683        // both `\` and `(` (`"..\caixa-teia\(cd foo)"` — the canonical
11684        // "I pasted a Windows-shell `cd ..\path\(cmd)` chain") routes
11685        // through `FonteCaminhoBackslash` not
11686        // `FonteCaminhoShellSubshellGrouping`. The cross-host-OS-
11687        // separator divergence is the load-bearing axis on every
11688        // probe-as-both value (an author who removes the `\` is the
11689        // root-cause edit; the `(` falls away in the same edit since
11690        // it's downstream of the Windows-shell convention).
11691        let d = dep_with_fonte(DepSource::Path {
11692            caminho: "..\\caixa-teia\\(cd foo)".into(),
11693        });
11694        let err = d.validate().unwrap_err();
11695        assert!(
11696            matches!(err, DepError::FonteCaminhoBackslash { .. }),
11697            "got {err:?}",
11698        );
11699    }
11700
11701    #[test]
11702    fn fonte_caminho_control_char_fires_before_shell_subshell_grouping() {
11703        // Cascade pin on the embedded-control-byte arm: a value
11704        // carrying both a control byte and `(` (`"../foo\n(cd bar)"` —
11705        // the canonical paste-from-multiline-doc footgun where a
11706        // newline landed mid-caminho between two paste fragments)
11707        // routes through `FonteCaminhoControlChar` not
11708        // `FonteCaminhoShellSubshellGrouping`. The POSIX-syscall-
11709        // rejected-byte / NUL-`CString::new`-fail diagnostic is the
11710        // load-bearing axis on every value that probes positive for
11711        // both — mirrors the cascade discipline on every prior arm.
11712        let d = dep_with_fonte(DepSource::Path {
11713            caminho: "../foo\n(cd bar)".into(),
11714        });
11715        let err = d.validate().unwrap_err();
11716        assert!(
11717            matches!(err, DepError::FonteCaminhoControlChar { .. }),
11718            "got {err:?}",
11719        );
11720    }
11721
11722    #[test]
11723    fn fonte_caminho_absolute_fires_before_shell_subshell_grouping() {
11724        // Cascade pin on the load-bearing leading-byte arm: a leading
11725        // `/` value with embedded `(` (`"/etc/(cd foo)"`) routes
11726        // through `FonteCaminhoAbsolute` not
11727        // `FonteCaminhoShellSubshellGrouping` — the host-layout-leak
11728        // diagnostic is the load-bearing axis, the subshell-grouping
11729        // byte is the secondary observation. Same precedence logic as
11730        // every prior leading-byte arm.
11731        let d = dep_with_fonte(DepSource::Path {
11732            caminho: "/etc/(cd foo)".into(),
11733        });
11734        let err = d.validate().unwrap_err();
11735        assert!(
11736            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11737            "got {err:?}",
11738        );
11739    }
11740
11741    #[test]
11742    fn fonte_caminho_var_expansion_fires_before_shell_subshell_grouping() {
11743        // Cascade pin on the upstream leading-`$` var-expansion arm: a
11744        // value carrying both a leading `$` and a `(` (`"$(date)/\
11745        // caixa-teia"` — the canonical "I pasted a `$(date)` modern-
11746        // command-substitution at the head of a sibling-workspace
11747        // path" footgun) routes through `FonteCaminhoVarExpansion` not
11748        // `FonteCaminhoShellSubshellGrouping`. The leading-byte
11749        // shell-variable-expansion is the more self-locating diagnostic
11750        // on values that probe as both — same load-bearing-leading-
11751        // byte cascade discipline every prior `:caminho` arm
11752        // establishes. Closing both halves of `$(<cmd>)` structurally
11753        // (leading `$` here, trailing `)` on the new arm) excludes the
11754        // entire modern Bourne command-substitution surface from the
11755        // typed `:caminho` accepted set; the cascade preserves the
11756        // narrower leading-byte diagnostic on values that probe both
11757        // halves at the canonical leading position.
11758        let d = dep_with_fonte(DepSource::Path {
11759            caminho: "$(date)/caixa-teia".into(),
11760        });
11761        let err = d.validate().unwrap_err();
11762        assert!(
11763            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
11764            "got {err:?}",
11765        );
11766    }
11767
11768    #[test]
11769    fn fonte_caminho_shell_subshell_grouping_fires_before_trailing_slash() {
11770        // Cascade pin on the immediate-successor arm: a value carrying
11771        // both `(` and a trailing `/` (`"../(cd foo)/"` — the canonical
11772        // "I tab-completed a path that already had a subshell-grouping
11773        // expansion tail" footgun) routes through
11774        // `FonteCaminhoShellSubshellGrouping` not
11775        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
11776        // the more semantic-locating axis (an author who removes the
11777        // `(` typically also drops the trailing separator since both
11778        // are paste-from-shell artifacts).
11779        let d = dep_with_fonte(DepSource::Path {
11780            caminho: "../(cd foo)/".into(),
11781        });
11782        let err = d.validate().unwrap_err();
11783        assert!(
11784            matches!(
11785                err,
11786                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
11787            ),
11788            "got {err:?}",
11789        );
11790    }
11791
11792    #[test]
11793    fn fonte_caminho_shell_subshell_grouping_diagnostic_carries_offending_dep_caminho_and_byte() {
11794        // Diagnostic-shape pin (peer with
11795        // `fonte_caminho_shell_glob_diagnostic_carries_offending_dep_caminho_and_byte`
11796        // on the closest two-byte peer arm): the error's Display
11797        // surfaces the offending `:nome`, the offending `:caminho`
11798        // verbatim, the offending byte's hex / character form, and
11799        // names the shell-subshell-grouping footgun explicitly so a
11800        // `feira lint` run can render the diagnostic without re-
11801        // parsing.
11802        let d = dep_with_fonte(DepSource::Path {
11803            caminho: "../caixa-teia/$(date)/build".into(),
11804        });
11805        let rendered = d.validate().unwrap_err().to_string();
11806        assert!(
11807            rendered.contains("caixa-teia"),
11808            "diagnostic must name the offending dep: {rendered}",
11809        );
11810        assert!(
11811            rendered.contains("../caixa-teia/$(date)/build"),
11812            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11813        );
11814        assert!(
11815            rendered.contains("0x28"),
11816            "diagnostic must surface the offending byte hex: {rendered:?}",
11817        );
11818        assert!(
11819            rendered.contains("subshell-grouping"),
11820            "diagnostic must name the shell-subshell-grouping footgun: {rendered:?}",
11821        );
11822        assert!(
11823            rendered.contains("command-substitution"),
11824            "diagnostic must reference the `$(<cmd>)` command-substitution vocabulary: \
11825             {rendered:?}",
11826        );
11827    }
11828
11829    // ── shell-brace-expansion / URI-Template-placeholder arm ───────────
11830    //
11831    // Peer with the prior `FonteCaminhoShellSubshellGrouping` (`(` /
11832    // `)`) byte-pair arm: the same per-byte cascade with the same
11833    // self-locating `byte: u8` diagnostic on the orthogonal `{` /
11834    // `}` brace-expansion / URI-Template placeholder axis. The peer
11835    // [`crate::render::is_git_repo_url`] (42d8f9d) closes the same
11836    // byte pair on the sibling `:fonte :repo` axis under the same
11837    // banner.
11838
11839    #[test]
11840    fn validate_rejects_path_fonte_with_caminho_carrying_brace_expansion_fan_across_siblings() {
11841        // The fail-before-pass-after pin for the canonical paste-from-
11842        // shell-history brace-expansion footgun: an author copies a
11843        // `cd ../{caixa-teia,caixa-helm}/build` shell-history one-
11844        // liner whose `{a,b}` brace expansion fans across two siblings
11845        // and silently passed every prior arm (`Path::is_absolute`
11846        // false on `..`, no control bytes, no `\`, no `<` / `>`, no
11847        // `|`, no `;`, no `&`, no backtick, no `*` / `?`, no `(` /
11848        // `)`, doesn't end in `/`; the leading-`$` f4efe9c
11849        // `FonteCaminhoVarExpansion` arm doesn't fire because the
11850        // value starts with `..` not `$`). The lacre embedded the
11851        // value verbatim, the resolver folded it through `Path::join`
11852        // looking for a literal `./../{caixa-teia,caixa-helm}/build`
11853        // subdirectory, and the failure surfaced at resolve time with
11854        // a non-self-locating `No such file or directory` error. The
11855        // new arm moves the rejection to validate time and names the
11856        // offending dep + caminho + byte verbatim. The arm fires on
11857        // the first `{` encountered.
11858        let d = dep_with_fonte(DepSource::Path {
11859            caminho: "../{caixa-teia,caixa-helm}/build".into(),
11860        });
11861        let err = d.validate().unwrap_err();
11862        let DepError::FonteCaminhoShellBraceExpansion {
11863            nome,
11864            caminho,
11865            byte,
11866        } = err
11867        else {
11868            panic!("expected FonteCaminhoShellBraceExpansion, got {err:?}");
11869        };
11870        assert_eq!(nome, "caixa-teia");
11871        assert_eq!(caminho, "../{caixa-teia,caixa-helm}/build");
11872        assert_eq!(byte, b'{');
11873    }
11874
11875    #[test]
11876    fn validate_rejects_path_fonte_with_caminho_carrying_close_brace() {
11877        // The symmetric close-brace paste shape (`"../caixa-teia}"` —
11878        // the degenerate "I selected an unbalanced closing brace out
11879        // of a shell-history block" idiom that probes for the
11880        // cascade's last-byte handling on a value carrying only the
11881        // closing byte). Pinned separately from the open-brace shape
11882        // so the gate's contract is "any `{` or `}` anywhere", not
11883        // single-byte coverage. Mirrors the peer
11884        // `validate_rejects_path_fonte_with_caminho_carrying_close_paren`
11885        // shape on the immediate-predecessor `FonteCaminhoShellSubshellGrouping`
11886        // arm.
11887        let d = dep_with_fonte(DepSource::Path {
11888            caminho: "../caixa-teia}".into(),
11889        });
11890        let err = d.validate().unwrap_err();
11891        let DepError::FonteCaminhoShellBraceExpansion { byte, .. } = err else {
11892            panic!("expected FonteCaminhoShellBraceExpansion, got {err:?}");
11893        };
11894        assert_eq!(byte, b'}');
11895    }
11896
11897    #[test]
11898    fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_brace() {
11899        // Leading-position `{` shape (`"{caixa-teia,caixa-helm}/build"`
11900        // — the canonical "I selected a `{a,b}` brace-expansion prefix
11901        // out of a shell-history one-liner" idiom). Pinned separately
11902        // from the embedded-byte shape so the gate covers every
11903        // position, not only mid-path.
11904        let d = dep_with_fonte(DepSource::Path {
11905            caminho: "{caixa-teia,caixa-helm}/build".into(),
11906        });
11907        let err = d.validate().unwrap_err();
11908        assert!(
11909            matches!(
11910                err,
11911                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
11912            ),
11913            "got {err:?}",
11914        );
11915    }
11916
11917    #[test]
11918    fn validate_rejects_path_fonte_with_caminho_carrying_uri_template_placeholder() {
11919        // The canonical URI-Template / Mustache / Helm doubled-brace
11920        // placeholder shape (`"../{{org}}/caixa-teia"` — the canonical
11921        // "I copied a `https://github.com/{{org}}/caixa-teia` README
11922        // quick-start / OpenAPI spec / Helm chart `home:` template
11923        // and forgot to substitute the placeholder" footgun). The arm
11924        // fires on the first `{` encountered; pinned so the gate's
11925        // coverage extends from the bare-brace shell-history shape to
11926        // the doubled-brace URI-Template / templating-engine shape.
11927        // Mirrors the peer 42d8f9d `is_git_repo_url` arm on the
11928        // sibling `:fonte :repo` axis.
11929        let d = dep_with_fonte(DepSource::Path {
11930            caminho: "../{{org}}/caixa-teia".into(),
11931        });
11932        let err = d.validate().unwrap_err();
11933        assert!(
11934            matches!(
11935                err,
11936                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
11937            ),
11938            "got {err:?}",
11939        );
11940    }
11941
11942    #[test]
11943    fn validate_rejects_path_fonte_with_caminho_carrying_brace_range_expansion() {
11944        // The canonical bash brace-range-expansion shape (`"../caixa-
11945        // v{1..10}"` — the `{1..10}` sequence expansion every bash /
11946        // zsh `for i in {1..10}; do …; done` idiom uses, the symmetric
11947        // sequence-range form to the `{a,b,c}` comma-separated form).
11948        // The arm fires on the first `{` encountered; pinned so the
11949        // gate's coverage extends from the comma-separated form to
11950        // the integer-range form.
11951        let d = dep_with_fonte(DepSource::Path {
11952            caminho: "../caixa-v{1..10}".into(),
11953        });
11954        let err = d.validate().unwrap_err();
11955        assert!(
11956            matches!(
11957                err,
11958                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
11959            ),
11960            "got {err:?}",
11961        );
11962    }
11963
11964    #[test]
11965    fn validate_accepts_path_fonte_with_caminho_carrying_no_brace_expansion() {
11966        // The positive-control pin: the gate targets only `{` / `}`,
11967        // never adjacent printable ASCII or POSIX-valid bytes. The
11968        // canonical relative POSIX path (`"../caixa-teia"`) and a
11969        // nested deeply-pathed variant with adjacent printable
11970        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue to
11971        // validate cleanly so the gate doesn't widen to a "no
11972        // printable punctuation anywhere" sweep that would defeat
11973        // the entire path-fonte author surface. Peer with
11974        // `validate_accepts_path_fonte_with_caminho_carrying_no_subshell_grouping`
11975        // on the immediate-predecessor arm.
11976        let d = dep_with_fonte(DepSource::Path {
11977            caminho: "../caixa-teia/sub-dir.v2".into(),
11978        });
11979        d.validate().unwrap();
11980    }
11981
11982    #[test]
11983    fn fonte_caminho_shell_subshell_grouping_fires_before_shell_brace_expansion() {
11984        // Cascade pin on the immediate-predecessor arm: a value
11985        // carrying both `(` and `{` (`"../(cd foo)/{a,b}"` — the
11986        // canonical "I pasted a subshell-grouping followed by a
11987        // brace-expansion tail" footgun) routes through
11988        // `FonteCaminhoShellSubshellGrouping` not
11989        // `FonteCaminhoShellBraceExpansion`. The subshell-grouping
11990        // shape is the more semantic-locating axis on every probe-
11991        // as-both value because it closes both halves of the modern
11992        // Bourne `$(<cmd>)` command-substitution surface — same
11993        // cascade discipline every prior `:caminho` arm establishes.
11994        let d = dep_with_fonte(DepSource::Path {
11995            caminho: "../(cd foo)/{a,b}".into(),
11996        });
11997        let err = d.validate().unwrap_err();
11998        assert!(
11999            matches!(
12000                err,
12001                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
12002            ),
12003            "got {err:?}",
12004        );
12005    }
12006
12007    #[test]
12008    fn fonte_caminho_shell_glob_fires_before_shell_brace_expansion() {
12009        // Cascade pin on the upstream shell-glob arm: a value carrying
12010        // both `*` and `{` (`"../caixa-teia/*{a,b}"` — the canonical
12011        // "I pasted a glob expansion followed by a brace-expansion
12012        // tail" footgun) routes through `FonteCaminhoShellGlob` not
12013        // `FonteCaminhoShellBraceExpansion`. The pathname-expansion
12014        // shape is the load-bearing root-cause edit on every
12015        // probe-as-both value.
12016        let d = dep_with_fonte(DepSource::Path {
12017            caminho: "../caixa-teia/*{a,b}".into(),
12018        });
12019        let err = d.validate().unwrap_err();
12020        assert!(
12021            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12022            "got {err:?}",
12023        );
12024    }
12025
12026    #[test]
12027    fn fonte_caminho_shell_command_substitution_fires_before_shell_brace_expansion() {
12028        // Cascade pin on the upstream shell-command-substitution arm:
12029        // a value carrying both a backtick and `{` (``"../`whoami`/{a,b}"``
12030        // — the canonical "I pasted a legacy-backtick command-
12031        // substitution followed by a brace-expansion fan-out" footgun)
12032        // routes through `FonteCaminhoShellCommandSubstitution` not
12033        // `FonteCaminhoShellBraceExpansion`. The CWE-78 shell-
12034        // command-injection vector is the load-bearing root-cause
12035        // edit on every probe-as-both value.
12036        let d = dep_with_fonte(DepSource::Path {
12037            caminho: "../`whoami`/{a,b}".into(),
12038        });
12039        let err = d.validate().unwrap_err();
12040        assert!(
12041            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
12042            "got {err:?}",
12043        );
12044    }
12045
12046    #[test]
12047    fn fonte_caminho_shell_background_fires_before_shell_brace_expansion() {
12048        // Cascade pin on the upstream shell-background arm: a value
12049        // carrying both `&` and `{` (`"../caixa-teia & {a,b}"` — the
12050        // canonical "I pasted a `cmd & {fork-fan}` background-launch
12051        // + brace-expansion chain" footgun) routes through
12052        // `FonteCaminhoShellBackground` not
12053        // `FonteCaminhoShellBraceExpansion`. The background-launch
12054        // tail is the load-bearing root-cause edit on every
12055        // probe-as-both value.
12056        let d = dep_with_fonte(DepSource::Path {
12057            caminho: "../caixa-teia & {a,b}".into(),
12058        });
12059        let err = d.validate().unwrap_err();
12060        assert!(
12061            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
12062            "got {err:?}",
12063        );
12064    }
12065
12066    #[test]
12067    fn fonte_caminho_shell_semicolon_fires_before_shell_brace_expansion() {
12068        // Cascade pin on the upstream shell-semicolon arm: a value
12069        // carrying both `;` and `{` (`"../caixa-teia; {a,b}"` — the
12070        // canonical sequential-cleanup + brace-expansion paste
12071        // idiom) routes through `FonteCaminhoShellSemicolon` not
12072        // `FonteCaminhoShellBraceExpansion`. The sequential-command-
12073        // separator paste is the load-bearing root-cause edit on
12074        // every probe-as-both value.
12075        let d = dep_with_fonte(DepSource::Path {
12076            caminho: "../caixa-teia; {a,b}".into(),
12077        });
12078        let err = d.validate().unwrap_err();
12079        assert!(
12080            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
12081            "got {err:?}",
12082        );
12083    }
12084
12085    #[test]
12086    fn fonte_caminho_shell_pipe_fires_before_shell_brace_expansion() {
12087        // Cascade pin on the upstream shell-pipe arm: a value
12088        // carrying both `|` and `{` (`"../caixa-teia | {tee,cat}"`
12089        // — the canonical pipeline-to-brace-expansion paste idiom)
12090        // routes through `FonteCaminhoShellPipe` not
12091        // `FonteCaminhoShellBraceExpansion`. The pipeline-tail paste
12092        // is the load-bearing root-cause edit on every probe-as-
12093        // both value.
12094        let d = dep_with_fonte(DepSource::Path {
12095            caminho: "../caixa-teia | {tee,cat}".into(),
12096        });
12097        let err = d.validate().unwrap_err();
12098        assert!(
12099            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
12100            "got {err:?}",
12101        );
12102    }
12103
12104    #[test]
12105    fn fonte_caminho_shell_redirection_fires_before_shell_brace_expansion() {
12106        // Cascade pin on the upstream shell-redirection arm: a value
12107        // carrying both `>` and `{` (`"../caixa-teia>log {a,b}"` —
12108        // the canonical "I pasted a `cmd > log {a,b}` redirect-
12109        // plus-brace-expansion chain" footgun) routes through
12110        // `FonteCaminhoShellRedirection` not
12111        // `FonteCaminhoShellBraceExpansion`. The input/output
12112        // redirection metachar carries the more self-locating
12113        // `byte` payload, so the prior arm wins on every probe-
12114        // as-both value.
12115        let d = dep_with_fonte(DepSource::Path {
12116            caminho: "../caixa-teia>log {a,b}".into(),
12117        });
12118        let err = d.validate().unwrap_err();
12119        assert!(
12120            matches!(
12121                err,
12122                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
12123            ),
12124            "got {err:?}",
12125        );
12126    }
12127
12128    #[test]
12129    fn fonte_caminho_backslash_fires_before_shell_brace_expansion() {
12130        // Cascade pin on the upstream backslash arm: a value
12131        // carrying both `\` and `{` (`"..\caixa-teia\{a,b}"` — the
12132        // canonical "I pasted a Windows-shell `cd ..\path\{a,b}`
12133        // chain") routes through `FonteCaminhoBackslash` not
12134        // `FonteCaminhoShellBraceExpansion`. The cross-host-OS-
12135        // separator divergence is the load-bearing axis on every
12136        // probe-as-both value.
12137        let d = dep_with_fonte(DepSource::Path {
12138            caminho: "..\\caixa-teia\\{a,b}".into(),
12139        });
12140        let err = d.validate().unwrap_err();
12141        assert!(
12142            matches!(err, DepError::FonteCaminhoBackslash { .. }),
12143            "got {err:?}",
12144        );
12145    }
12146
12147    #[test]
12148    fn fonte_caminho_control_char_fires_before_shell_brace_expansion() {
12149        // Cascade pin on the embedded-control-byte arm: a value
12150        // carrying both a control byte and `{` (`"../foo\n{a,b}"` —
12151        // the canonical paste-from-multiline-doc footgun where a
12152        // newline landed mid-caminho between two paste fragments)
12153        // routes through `FonteCaminhoControlChar` not
12154        // `FonteCaminhoShellBraceExpansion`. The POSIX-syscall-
12155        // rejected-byte / NUL-`CString::new`-fail diagnostic is the
12156        // load-bearing axis on every value that probes positive for
12157        // both — mirrors the cascade discipline on every prior arm.
12158        let d = dep_with_fonte(DepSource::Path {
12159            caminho: "../foo\n{a,b}".into(),
12160        });
12161        let err = d.validate().unwrap_err();
12162        assert!(
12163            matches!(err, DepError::FonteCaminhoControlChar { .. }),
12164            "got {err:?}",
12165        );
12166    }
12167
12168    #[test]
12169    fn fonte_caminho_absolute_fires_before_shell_brace_expansion() {
12170        // Cascade pin on the load-bearing leading-byte arm: a
12171        // leading `/` value with embedded `{` (`"/etc/{a,b}"`)
12172        // routes through `FonteCaminhoAbsolute` not
12173        // `FonteCaminhoShellBraceExpansion` — the host-layout-leak
12174        // diagnostic is the load-bearing axis, the brace-expansion
12175        // byte is the secondary observation. Same precedence logic
12176        // as every prior leading-byte arm.
12177        let d = dep_with_fonte(DepSource::Path {
12178            caminho: "/etc/{a,b}".into(),
12179        });
12180        let err = d.validate().unwrap_err();
12181        assert!(
12182            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
12183            "got {err:?}",
12184        );
12185    }
12186
12187    #[test]
12188    fn fonte_caminho_var_expansion_fires_before_shell_brace_expansion() {
12189        // Cascade pin on the upstream leading-`$` var-expansion
12190        // arm: a value carrying both a leading `$` and a `{`
12191        // (`"${ORG}/caixa-teia"` — the canonical "I pasted a
12192        // `${ORG}` shell-variable + curly-brace expansion at the
12193        // head of a sibling-workspace path" footgun) routes through
12194        // `FonteCaminhoVarExpansion` not
12195        // `FonteCaminhoShellBraceExpansion`. The leading-byte
12196        // shell-variable-expansion is the more self-locating
12197        // diagnostic on values that probe as both — same
12198        // load-bearing-leading-byte cascade discipline every prior
12199        // `:caminho` arm establishes.
12200        let d = dep_with_fonte(DepSource::Path {
12201            caminho: "${ORG}/caixa-teia".into(),
12202        });
12203        let err = d.validate().unwrap_err();
12204        assert!(
12205            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
12206            "got {err:?}",
12207        );
12208    }
12209
12210    #[test]
12211    fn fonte_caminho_shell_brace_expansion_fires_before_trailing_slash() {
12212        // Cascade pin on the immediate-successor arm: a value
12213        // carrying both `{` and a trailing `/`
12214        // (`"../{caixa-teia,caixa-helm}/"` — the canonical "I
12215        // tab-completed a path that already had a brace-expansion
12216        // expansion tail" footgun) routes through
12217        // `FonteCaminhoShellBraceExpansion` not
12218        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
12219        // is the more semantic-locating axis (an author who removes
12220        // the `{` typically also drops the trailing separator since
12221        // both are paste-from-shell artifacts).
12222        let d = dep_with_fonte(DepSource::Path {
12223            caminho: "../{caixa-teia,caixa-helm}/".into(),
12224        });
12225        let err = d.validate().unwrap_err();
12226        assert!(
12227            matches!(
12228                err,
12229                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
12230            ),
12231            "got {err:?}",
12232        );
12233    }
12234
12235    #[test]
12236    fn fonte_caminho_shell_brace_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
12237        // Diagnostic-shape pin (peer with
12238        // `fonte_caminho_shell_subshell_grouping_diagnostic_carries_offending_dep_caminho_and_byte`
12239        // on the closest two-byte peer arm): the error's Display
12240        // surfaces the offending `:nome`, the offending `:caminho`
12241        // verbatim, the offending byte's hex / character form, and
12242        // names the shell-brace-expansion / URI-Template footgun
12243        // explicitly so a `feira lint` run can render the diagnostic
12244        // without re-parsing.
12245        let d = dep_with_fonte(DepSource::Path {
12246            caminho: "../{caixa-teia,caixa-helm}/build".into(),
12247        });
12248        let rendered = d.validate().unwrap_err().to_string();
12249        assert!(
12250            rendered.contains("caixa-teia"),
12251            "diagnostic must name the offending dep: {rendered}",
12252        );
12253        assert!(
12254            rendered.contains("../{caixa-teia,caixa-helm}/build"),
12255            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
12256        );
12257        assert!(
12258            rendered.contains("0x7b"),
12259            "diagnostic must surface the offending byte hex: {rendered:?}",
12260        );
12261        assert!(
12262            rendered.contains("brace-expansion"),
12263            "diagnostic must name the shell-brace-expansion footgun: {rendered:?}",
12264        );
12265        assert!(
12266            rendered.contains("URI Template"),
12267            "diagnostic must reference the RFC-6570 URI-Template-placeholder vocabulary: \
12268             {rendered:?}",
12269        );
12270    }
12271
12272    #[test]
12273    fn validate_rejects_path_fonte_with_caminho_carrying_bracket_glob_character_class() {
12274        // The canonical paste-from-shell-history bracket-glob /
12275        // character-class footgun: an author copies a
12276        // `cd ../caixa-[a-z]/build` shell-history one-liner whose
12277        // `[a-z]` POSIX glob character-class matches every lowercase-
12278        // ASCII-suffix sibling caixa directory and silently passed
12279        // every prior arm (`Path::is_absolute` false on `..`, no
12280        // control bytes, no `\`, no `<` / `>`, no `|`, no `;`, no
12281        // `&`, no backtick, no `*` / `?`, no `(` / `)`, no `{` /
12282        // `}`, doesn't end in `/`; the leading-`$` f4efe9c
12283        // `FonteCaminhoVarExpansion` arm doesn't fire because the
12284        // value starts with `..` not `$`). The lacre embedded the
12285        // value verbatim, the resolver folded it through
12286        // `Path::join` looking for a literal `./../caixa-[a-z]/
12287        // build` subdirectory, and the failure surfaced at resolve
12288        // time with a non-self-locating `No such file or directory`
12289        // error. The new arm moves the rejection to validate time
12290        // and names the offending dep + caminho + byte verbatim.
12291        // The arm fires on the first `[` encountered.
12292        let d = dep_with_fonte(DepSource::Path {
12293            caminho: "../caixa-[a-z]/build".into(),
12294        });
12295        let err = d.validate().unwrap_err();
12296        let DepError::FonteCaminhoShellBracketExpansion {
12297            nome,
12298            caminho,
12299            byte,
12300        } = err
12301        else {
12302            panic!("expected FonteCaminhoShellBracketExpansion, got {err:?}");
12303        };
12304        assert_eq!(nome, "caixa-teia");
12305        assert_eq!(caminho, "../caixa-[a-z]/build");
12306        assert_eq!(byte, b'[');
12307    }
12308
12309    #[test]
12310    fn validate_rejects_path_fonte_with_caminho_carrying_close_bracket() {
12311        // The symmetric close-bracket paste shape (`"../caixa-teia]"`
12312        // — the degenerate "I selected an unbalanced closing bracket
12313        // out of a glob character-class block" idiom that probes for
12314        // the cascade's last-byte handling on a value carrying only
12315        // the closing byte). Pinned separately from the open-bracket
12316        // shape so the gate's contract is "any `[` or `]` anywhere",
12317        // not single-byte coverage. Mirrors the peer
12318        // `validate_rejects_path_fonte_with_caminho_carrying_close_brace`
12319        // shape on the immediate-predecessor
12320        // `FonteCaminhoShellBraceExpansion` arm.
12321        let d = dep_with_fonte(DepSource::Path {
12322            caminho: "../caixa-teia]".into(),
12323        });
12324        let err = d.validate().unwrap_err();
12325        let DepError::FonteCaminhoShellBracketExpansion { byte, .. } = err else {
12326            panic!("expected FonteCaminhoShellBracketExpansion, got {err:?}");
12327        };
12328        assert_eq!(byte, b']');
12329    }
12330
12331    #[test]
12332    fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_bracket() {
12333        // Leading-position `[` shape (`"[caixa-teia]/build"` — the
12334        // canonical "I selected a `[caixa-teia]` TOML-table-header /
12335        // glob-character-class prefix out of an aligned config /
12336        // shell-history one-liner" idiom). Pinned separately from
12337        // the embedded-byte shape so the gate covers every position,
12338        // not only mid-path.
12339        let d = dep_with_fonte(DepSource::Path {
12340            caminho: "[caixa-teia]/build".into(),
12341        });
12342        let err = d.validate().unwrap_err();
12343        assert!(
12344            matches!(
12345                err,
12346                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
12347            ),
12348            "got {err:?}",
12349        );
12350    }
12351
12352    #[test]
12353    fn validate_rejects_path_fonte_with_caminho_carrying_toml_inline_array() {
12354        // The canonical TOML inline-array / YAML flow-sequence
12355        // paste shape (`"../[\"a\", \"b\"]/caixa-teia"` — the
12356        // canonical "I copied a `features = [\"a\", \"b\"]` TOML
12357        // inline-array out of a sibling-Cargo manifest" cross-idiom
12358        // leak; the symmetric YAML flow-sequence form `paths: [/a,
12359        // /b]` paste-from-values.yaml shape carries the same
12360        // bracket pair). The arm fires on the first `[` encountered;
12361        // pinned so the gate's coverage extends from the bare-
12362        // bracket glob-character-class shape to the TOML / YAML /
12363        // JSON array-literal shape.
12364        let d = dep_with_fonte(DepSource::Path {
12365            caminho: "../[\"a\", \"b\"]/caixa-teia".into(),
12366        });
12367        let err = d.validate().unwrap_err();
12368        assert!(
12369            matches!(
12370                err,
12371                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
12372            ),
12373            "got {err:?}",
12374        );
12375    }
12376
12377    #[test]
12378    fn validate_rejects_path_fonte_with_caminho_carrying_shell_test_builtin() {
12379        // The canonical POSIX `test` / `[` builtin command paste
12380        // shape (`"../[ -d caixa-teia ]"` — the `[ <expr> ]` shell-
12381        // script conditional every paste-from-shell-script idiom
12382        // carries; bash's `[[ <expr> ]]` extended-test grammar
12383        // would surface the same byte pair). The arm fires on the
12384        // first `[` encountered; pinned so the gate's coverage
12385        // extends from the embedded-glob-character-class shape to
12386        // the leading-`test`-builtin / extended-test form.
12387        let d = dep_with_fonte(DepSource::Path {
12388            caminho: "../[ -d caixa-teia ]".into(),
12389        });
12390        let err = d.validate().unwrap_err();
12391        assert!(
12392            matches!(
12393                err,
12394                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
12395            ),
12396            "got {err:?}",
12397        );
12398    }
12399
12400    #[test]
12401    fn validate_accepts_path_fonte_with_caminho_carrying_no_bracket_expansion() {
12402        // The positive-control pin: the gate targets only `[` /
12403        // `]`, never adjacent printable ASCII or POSIX-valid bytes.
12404        // The canonical relative POSIX path (`"../caixa-teia"`) and
12405        // a nested deeply-pathed variant with adjacent printable
12406        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
12407        // to validate cleanly so the gate doesn't widen to a "no
12408        // printable punctuation anywhere" sweep that would defeat
12409        // the entire path-fonte author surface. Peer with
12410        // `validate_accepts_path_fonte_with_caminho_carrying_no_brace_expansion`
12411        // on the immediate-predecessor arm.
12412        let d = dep_with_fonte(DepSource::Path {
12413            caminho: "../caixa-teia/sub-dir.v2".into(),
12414        });
12415        d.validate().unwrap();
12416    }
12417
12418    #[test]
12419    fn fonte_caminho_shell_brace_expansion_fires_before_shell_bracket_expansion() {
12420        // Cascade pin on the immediate-predecessor arm: a value
12421        // carrying both `{` and `[` (`"../{a,b}[ch]"` — the
12422        // canonical "I pasted a brace-expansion fan followed by a
12423        // glob-character-class tail" footgun) routes through
12424        // `FonteCaminhoShellBraceExpansion` not
12425        // `FonteCaminhoShellBracketExpansion`. The brace-expansion
12426        // fan is the load-bearing root-cause edit on every
12427        // probe-as-both value because the bracket-class tail
12428        // typically rides on a prior brace-expansion expansion;
12429        // same cascade discipline every prior `:caminho` arm
12430        // establishes.
12431        let d = dep_with_fonte(DepSource::Path {
12432            caminho: "../{a,b}[ch]".into(),
12433        });
12434        let err = d.validate().unwrap_err();
12435        assert!(
12436            matches!(
12437                err,
12438                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
12439            ),
12440            "got {err:?}",
12441        );
12442    }
12443
12444    #[test]
12445    fn fonte_caminho_shell_subshell_grouping_fires_before_shell_bracket_expansion() {
12446        // Cascade pin on the upstream shell-subshell-grouping arm:
12447        // a value carrying both `(` and `[` (`"../(cd foo)/[ch]"` —
12448        // the canonical "I pasted a subshell-grouping followed by
12449        // a glob-character-class tail" footgun) routes through
12450        // `FonteCaminhoShellSubshellGrouping` not
12451        // `FonteCaminhoShellBracketExpansion`. The modern Bourne
12452        // `$(<cmd>)` command-substitution boundary is the load-
12453        // bearing axis on every probe-as-both value.
12454        let d = dep_with_fonte(DepSource::Path {
12455            caminho: "../(cd foo)/[ch]".into(),
12456        });
12457        let err = d.validate().unwrap_err();
12458        assert!(
12459            matches!(
12460                err,
12461                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
12462            ),
12463            "got {err:?}",
12464        );
12465    }
12466
12467    #[test]
12468    fn fonte_caminho_shell_glob_fires_before_shell_bracket_expansion() {
12469        // Cascade pin on the upstream shell-glob arm: a value
12470        // carrying both `*` and `[` (`"../caixa-teia/*[ch]"` — the
12471        // canonical "I pasted a `*.[ch]` C-source-file glob whose
12472        // unbounded `*` precedes the bracket character-class"
12473        // footgun) routes through `FonteCaminhoShellGlob` not
12474        // `FonteCaminhoShellBracketExpansion`. The unbounded
12475        // pathname-expansion sentinel is the load-bearing root-
12476        // cause edit on every probe-as-both value — the unbounded
12477        // `*` carries the more aggressive expansion vector than
12478        // the bounded `[ch]` class, so the prior arm wins.
12479        let d = dep_with_fonte(DepSource::Path {
12480            caminho: "../caixa-teia/*[ch]".into(),
12481        });
12482        let err = d.validate().unwrap_err();
12483        assert!(
12484            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12485            "got {err:?}",
12486        );
12487    }
12488
12489    #[test]
12490    fn fonte_caminho_shell_command_substitution_fires_before_shell_bracket_expansion() {
12491        // Cascade pin on the upstream shell-command-substitution
12492        // arm: a value carrying both a backtick and `[`
12493        // (``"../`whoami`/[ch]"`` — the canonical "I pasted a
12494        // legacy-backtick command-substitution followed by a
12495        // glob-character-class tail" footgun) routes through
12496        // `FonteCaminhoShellCommandSubstitution` not
12497        // `FonteCaminhoShellBracketExpansion`. The CWE-78 shell-
12498        // command-injection vector is the load-bearing root-cause
12499        // edit on every probe-as-both value.
12500        let d = dep_with_fonte(DepSource::Path {
12501            caminho: "../`whoami`/[ch]".into(),
12502        });
12503        let err = d.validate().unwrap_err();
12504        assert!(
12505            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
12506            "got {err:?}",
12507        );
12508    }
12509
12510    #[test]
12511    fn fonte_caminho_shell_background_fires_before_shell_bracket_expansion() {
12512        // Cascade pin on the upstream shell-background arm: a
12513        // value carrying both `&` and `[` (`"../caixa-teia & [ch]"`
12514        // — the canonical "I pasted a `cmd & [glob]` background-
12515        // launch + bracket-class chain" footgun) routes through
12516        // `FonteCaminhoShellBackground` not
12517        // `FonteCaminhoShellBracketExpansion`. The background-
12518        // launch tail is the load-bearing root-cause edit on
12519        // every probe-as-both value.
12520        let d = dep_with_fonte(DepSource::Path {
12521            caminho: "../caixa-teia & [ch]".into(),
12522        });
12523        let err = d.validate().unwrap_err();
12524        assert!(
12525            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
12526            "got {err:?}",
12527        );
12528    }
12529
12530    #[test]
12531    fn fonte_caminho_shell_semicolon_fires_before_shell_bracket_expansion() {
12532        // Cascade pin on the upstream shell-semicolon arm: a value
12533        // carrying both `;` and `[` (`"../caixa-teia; [ch]"` — the
12534        // canonical sequential-cleanup + bracket-class paste
12535        // idiom) routes through `FonteCaminhoShellSemicolon` not
12536        // `FonteCaminhoShellBracketExpansion`. The sequential-
12537        // command-separator paste is the load-bearing root-cause
12538        // edit on every probe-as-both value.
12539        let d = dep_with_fonte(DepSource::Path {
12540            caminho: "../caixa-teia; [ch]".into(),
12541        });
12542        let err = d.validate().unwrap_err();
12543        assert!(
12544            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
12545            "got {err:?}",
12546        );
12547    }
12548
12549    #[test]
12550    fn fonte_caminho_shell_pipe_fires_before_shell_bracket_expansion() {
12551        // Cascade pin on the upstream shell-pipe arm: a value
12552        // carrying both `|` and `[` (`"../caixa-teia | [tee]"` —
12553        // the canonical pipeline-to-bracket-class paste idiom)
12554        // routes through `FonteCaminhoShellPipe` not
12555        // `FonteCaminhoShellBracketExpansion`. The pipeline-tail
12556        // paste is the load-bearing root-cause edit on every
12557        // probe-as-both value.
12558        let d = dep_with_fonte(DepSource::Path {
12559            caminho: "../caixa-teia | [tee]".into(),
12560        });
12561        let err = d.validate().unwrap_err();
12562        assert!(
12563            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
12564            "got {err:?}",
12565        );
12566    }
12567
12568    #[test]
12569    fn fonte_caminho_shell_redirection_fires_before_shell_bracket_expansion() {
12570        // Cascade pin on the upstream shell-redirection arm: a
12571        // value carrying both `>` and `[` (`"../caixa-teia>log
12572        // [ch]"` — the canonical "I pasted a `cmd > log [glob]`
12573        // redirect-plus-bracket chain" footgun) routes through
12574        // `FonteCaminhoShellRedirection` not
12575        // `FonteCaminhoShellBracketExpansion`. The input/output
12576        // redirection metachar carries the more self-locating
12577        // `byte` payload, so the prior arm wins on every
12578        // probe-as-both value.
12579        let d = dep_with_fonte(DepSource::Path {
12580            caminho: "../caixa-teia>log [ch]".into(),
12581        });
12582        let err = d.validate().unwrap_err();
12583        assert!(
12584            matches!(
12585                err,
12586                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
12587            ),
12588            "got {err:?}",
12589        );
12590    }
12591
12592    #[test]
12593    fn fonte_caminho_backslash_fires_before_shell_bracket_expansion() {
12594        // Cascade pin on the upstream backslash arm: a value
12595        // carrying both `\` and `[` (`"..\caixa-teia\[ch]"` — the
12596        // canonical "I pasted a Windows-shell `cd ..\path\[glob]`
12597        // chain") routes through `FonteCaminhoBackslash` not
12598        // `FonteCaminhoShellBracketExpansion`. The cross-host-OS-
12599        // separator divergence is the load-bearing axis on every
12600        // probe-as-both value.
12601        let d = dep_with_fonte(DepSource::Path {
12602            caminho: "..\\caixa-teia\\[ch]".into(),
12603        });
12604        let err = d.validate().unwrap_err();
12605        assert!(
12606            matches!(err, DepError::FonteCaminhoBackslash { .. }),
12607            "got {err:?}",
12608        );
12609    }
12610
12611    #[test]
12612    fn fonte_caminho_control_char_fires_before_shell_bracket_expansion() {
12613        // Cascade pin on the embedded-control-byte arm: a value
12614        // carrying both a control byte and `[` (`"../foo\n[ch]"` —
12615        // the canonical paste-from-multiline-doc footgun where a
12616        // newline landed mid-caminho between two paste fragments)
12617        // routes through `FonteCaminhoControlChar` not
12618        // `FonteCaminhoShellBracketExpansion`. The POSIX-syscall-
12619        // rejected-byte / NUL-`CString::new`-fail diagnostic is
12620        // the load-bearing axis on every value that probes
12621        // positive for both — mirrors the cascade discipline on
12622        // every prior arm.
12623        let d = dep_with_fonte(DepSource::Path {
12624            caminho: "../foo\n[ch]".into(),
12625        });
12626        let err = d.validate().unwrap_err();
12627        assert!(
12628            matches!(err, DepError::FonteCaminhoControlChar { .. }),
12629            "got {err:?}",
12630        );
12631    }
12632
12633    #[test]
12634    fn fonte_caminho_absolute_fires_before_shell_bracket_expansion() {
12635        // Cascade pin on the load-bearing leading-byte arm: a
12636        // leading `/` value with embedded `[` (`"/etc/[ch]"`)
12637        // routes through `FonteCaminhoAbsolute` not
12638        // `FonteCaminhoShellBracketExpansion` — the host-layout-
12639        // leak diagnostic is the load-bearing axis, the bracket-
12640        // expansion byte is the secondary observation. Same
12641        // precedence logic as every prior leading-byte arm.
12642        let d = dep_with_fonte(DepSource::Path {
12643            caminho: "/etc/[ch]".into(),
12644        });
12645        let err = d.validate().unwrap_err();
12646        assert!(
12647            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
12648            "got {err:?}",
12649        );
12650    }
12651
12652    #[test]
12653    fn fonte_caminho_var_expansion_fires_before_shell_bracket_expansion() {
12654        // Cascade pin on the upstream leading-`$` var-expansion
12655        // arm: a value carrying both a leading `$` and a `[`
12656        // (`"$DIR/[ch]"` — the canonical "I pasted a `$DIR` shell-
12657        // variable + bracket-class at the head of a sibling-
12658        // workspace path" footgun) routes through
12659        // `FonteCaminhoVarExpansion` not
12660        // `FonteCaminhoShellBracketExpansion`. The leading-byte
12661        // shell-variable-expansion is the more self-locating
12662        // diagnostic on values that probe as both — same
12663        // load-bearing-leading-byte cascade discipline every
12664        // prior `:caminho` arm establishes.
12665        let d = dep_with_fonte(DepSource::Path {
12666            caminho: "$DIR/[ch]".into(),
12667        });
12668        let err = d.validate().unwrap_err();
12669        assert!(
12670            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
12671            "got {err:?}",
12672        );
12673    }
12674
12675    #[test]
12676    fn fonte_caminho_shell_bracket_expansion_fires_before_trailing_slash() {
12677        // Cascade pin on the immediate-successor arm: a value
12678        // carrying both `[` and a trailing `/` (`"../[a-z]/"` —
12679        // the canonical "I tab-completed a path that already had
12680        // a bracket-glob-character-class expansion tail" footgun)
12681        // routes through `FonteCaminhoShellBracketExpansion` not
12682        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
12683        // is the more semantic-locating axis (an author who
12684        // removes the `[` typically also drops the trailing
12685        // separator since both are paste-from-shell artifacts).
12686        let d = dep_with_fonte(DepSource::Path {
12687            caminho: "../[a-z]/".into(),
12688        });
12689        let err = d.validate().unwrap_err();
12690        assert!(
12691            matches!(
12692                err,
12693                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
12694            ),
12695            "got {err:?}",
12696        );
12697    }
12698
12699    #[test]
12700    fn fonte_caminho_shell_bracket_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
12701        // Diagnostic-shape pin (peer with
12702        // `fonte_caminho_shell_brace_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
12703        // on the closest two-byte peer arm): the error's Display
12704        // surfaces the offending `:nome`, the offending `:caminho`
12705        // verbatim, the offending byte's hex / character form, and
12706        // names the shell-bracket-expansion / glob-character-class
12707        // footgun explicitly so a `feira lint` run can render the
12708        // diagnostic without re-parsing.
12709        let d = dep_with_fonte(DepSource::Path {
12710            caminho: "../caixa-[a-z]/build".into(),
12711        });
12712        let rendered = d.validate().unwrap_err().to_string();
12713        assert!(
12714            rendered.contains("caixa-teia"),
12715            "diagnostic must name the offending dep: {rendered}",
12716        );
12717        assert!(
12718            rendered.contains("../caixa-[a-z]/build"),
12719            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
12720        );
12721        assert!(
12722            rendered.contains("0x5b"),
12723            "diagnostic must surface the offending byte hex: {rendered:?}",
12724        );
12725        assert!(
12726            rendered.contains("bracket-expansion"),
12727            "diagnostic must name the shell-bracket-expansion footgun: {rendered:?}",
12728        );
12729        assert!(
12730            rendered.contains("glob-character-class"),
12731            "diagnostic must reference the POSIX glob-character-class vocabulary: \
12732             {rendered:?}",
12733        );
12734    }
12735
12736    #[test]
12737    fn validate_rejects_path_fonte_with_caminho_carrying_single_quote_grouping() {
12738        // The canonical paste-from-shell-history strong-quoted
12739        // sibling-workspace-path footgun: an author copies a
12740        // `cd '../caixa-teia'` shell-history one-liner whose strong-
12741        // quoting preserved the path across a whitespace paste
12742        // boundary and silently passed every prior arm
12743        // (`Path::is_absolute` false on `'..`, no control bytes, no
12744        // `\`, no `<` / `>`, no `|`, no `;`, no `&`, no backtick, no
12745        // `*` / `?`, no `(` / `)`, no `{` / `}`, no `[` / `]`,
12746        // doesn't end in `/`; the leading-`$` f4efe9c
12747        // `FonteCaminhoVarExpansion` arm doesn't fire because the
12748        // value starts with `'` not `$`). The lacre embedded the
12749        // value verbatim, the resolver folded it through
12750        // `Path::join` looking for a literal `./'../caixa-teia'`
12751        // subdirectory, and the failure surfaced at resolve time
12752        // with a non-self-locating `No such file or directory`
12753        // error. The new arm moves the rejection to validate time
12754        // and names the offending dep + caminho + byte verbatim.
12755        // The arm fires on the first `'` encountered.
12756        let d = dep_with_fonte(DepSource::Path {
12757            caminho: "'../caixa-teia'".into(),
12758        });
12759        let err = d.validate().unwrap_err();
12760        let DepError::FonteCaminhoShellQuoteGrouping {
12761            nome,
12762            caminho,
12763            byte,
12764        } = err
12765        else {
12766            panic!("expected FonteCaminhoShellQuoteGrouping, got {err:?}");
12767        };
12768        assert_eq!(nome, "caixa-teia");
12769        assert_eq!(caminho, "'../caixa-teia'");
12770        assert_eq!(byte, b'\'');
12771    }
12772
12773    #[test]
12774    fn validate_rejects_path_fonte_with_caminho_carrying_double_quote_grouping() {
12775        // The symmetric weak-quoted paste shape (`"\"../caixa-teia\""`
12776        // — the canonical paste-from-JSON-config / paste-from-YAML-
12777        // flow-scalar / paste-from-TOML-basic-string / paste-from-
12778        // tatara-lisp-string-literal cross-idiom leak). Pinned
12779        // separately from the single-quote shape so the gate's
12780        // contract is "any `'` or `\"` anywhere", not single-byte
12781        // coverage. Mirrors the peer
12782        // `validate_rejects_path_fonte_with_caminho_carrying_close_bracket`
12783        // shape on the immediate-predecessor
12784        // `FonteCaminhoShellBracketExpansion` arm.
12785        let d = dep_with_fonte(DepSource::Path {
12786            caminho: "\"../caixa-teia\"".into(),
12787        });
12788        let err = d.validate().unwrap_err();
12789        let DepError::FonteCaminhoShellQuoteGrouping { byte, .. } = err else {
12790            panic!("expected FonteCaminhoShellQuoteGrouping, got {err:?}");
12791        };
12792        assert_eq!(byte, b'"');
12793    }
12794
12795    #[test]
12796    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_double_quote() {
12797        // Embedded-position `"` shape (`"../\"caixa-teia\""` — the
12798        // canonical "I pasted a JSON key-value pair fragment into
12799        // the middle of the path" idiom). Pinned separately from
12800        // the leading-byte shape so the gate covers every position,
12801        // not only leading.
12802        let d = dep_with_fonte(DepSource::Path {
12803            caminho: "../\"caixa-teia\"".into(),
12804        });
12805        let err = d.validate().unwrap_err();
12806        assert!(
12807            matches!(
12808                err,
12809                DepError::FonteCaminhoShellQuoteGrouping { byte: b'"', .. },
12810            ),
12811            "got {err:?}",
12812        );
12813    }
12814
12815    #[test]
12816    fn validate_rejects_path_fonte_with_caminho_carrying_yaml_flow_scalar_paste() {
12817        // The canonical YAML double-quoted flow-scalar cross-idiom
12818        // leak shape (`"path: \"../caixa-teia\""` — the "I copied a
12819        // `path: \"...\"` YAML flow-scalar entry out of an aligned
12820        // values.yaml / K8s manifest and dropped it verbatim into
12821        // the `:caminho` slot including the `path: ` key prefix"
12822        // paste-idiom). The arm fires on the first `"` encountered;
12823        // pinned so the gate's coverage extends from the bare-quote
12824        // paste shape to the aligned-YAML-manifest cross-idiom-leak
12825        // shape.
12826        let d = dep_with_fonte(DepSource::Path {
12827            caminho: "path: \"../caixa-teia\"".into(),
12828        });
12829        let err = d.validate().unwrap_err();
12830        assert!(
12831            matches!(
12832                err,
12833                DepError::FonteCaminhoShellQuoteGrouping { byte: b'"', .. },
12834            ),
12835            "got {err:?}",
12836        );
12837    }
12838
12839    #[test]
12840    fn validate_accepts_path_fonte_with_caminho_carrying_no_quote_grouping() {
12841        // The positive-control pin: the gate targets only `'` /
12842        // `"`, never adjacent printable ASCII or POSIX-valid bytes.
12843        // The canonical relative POSIX path (`"../caixa-teia"`) and
12844        // a nested deeply-pathed variant with adjacent printable
12845        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
12846        // to validate cleanly so the gate doesn't widen to a "no
12847        // printable punctuation anywhere" sweep that would defeat
12848        // the entire path-fonte author surface. Peer with
12849        // `validate_accepts_path_fonte_with_caminho_carrying_no_bracket_expansion`
12850        // on the immediate-predecessor arm.
12851        let d = dep_with_fonte(DepSource::Path {
12852            caminho: "../caixa-teia/sub-dir.v2".into(),
12853        });
12854        d.validate().unwrap();
12855    }
12856
12857    #[test]
12858    fn fonte_caminho_shell_bracket_expansion_fires_before_shell_quote_grouping() {
12859        // Cascade pin on the immediate-predecessor arm: a value
12860        // carrying both `[` and `'` (`"../[a-z]'x'"` — the canonical
12861        // "I pasted a glob-character-class followed by a strong-
12862        // quoted literal tail" footgun) routes through
12863        // `FonteCaminhoShellBracketExpansion` not
12864        // `FonteCaminhoShellQuoteGrouping`. The glob-character-class
12865        // expansion is the load-bearing root-cause edit on every
12866        // probe-as-both value; same cascade discipline every prior
12867        // `:caminho` arm establishes.
12868        let d = dep_with_fonte(DepSource::Path {
12869            caminho: "../[a-z]'x'".into(),
12870        });
12871        let err = d.validate().unwrap_err();
12872        assert!(
12873            matches!(
12874                err,
12875                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
12876            ),
12877            "got {err:?}",
12878        );
12879    }
12880
12881    #[test]
12882    fn fonte_caminho_shell_brace_expansion_fires_before_shell_quote_grouping() {
12883        // Cascade pin on the upstream shell-brace-expansion arm: a
12884        // value carrying both `{` and `'` (`"../{a,b}'x'"` — the
12885        // canonical "I pasted a brace-expansion fan followed by a
12886        // strong-quoted literal tail" footgun) routes through
12887        // `FonteCaminhoShellBraceExpansion` not
12888        // `FonteCaminhoShellQuoteGrouping`. The brace-expansion fan
12889        // is the load-bearing root-cause edit on every probe-as-
12890        // both value.
12891        let d = dep_with_fonte(DepSource::Path {
12892            caminho: "../{a,b}'x'".into(),
12893        });
12894        let err = d.validate().unwrap_err();
12895        assert!(
12896            matches!(
12897                err,
12898                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
12899            ),
12900            "got {err:?}",
12901        );
12902    }
12903
12904    #[test]
12905    fn fonte_caminho_shell_subshell_grouping_fires_before_shell_quote_grouping() {
12906        // Cascade pin on the upstream shell-subshell-grouping arm:
12907        // a value carrying both `(` and `'` (`"../(cd foo)/'x'"` —
12908        // the canonical "I pasted a subshell-grouping followed by
12909        // a strong-quoted literal tail" footgun) routes through
12910        // `FonteCaminhoShellSubshellGrouping` not
12911        // `FonteCaminhoShellQuoteGrouping`. The modern Bourne
12912        // `$(<cmd>)` command-substitution boundary is the load-
12913        // bearing axis on every probe-as-both value.
12914        let d = dep_with_fonte(DepSource::Path {
12915            caminho: "../(cd foo)/'x'".into(),
12916        });
12917        let err = d.validate().unwrap_err();
12918        assert!(
12919            matches!(
12920                err,
12921                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
12922            ),
12923            "got {err:?}",
12924        );
12925    }
12926
12927    #[test]
12928    fn fonte_caminho_shell_glob_fires_before_shell_quote_grouping() {
12929        // Cascade pin on the upstream shell-glob arm: a value
12930        // carrying both `*` and `'` (`"../caixa-teia/*'x'"` — the
12931        // canonical "I pasted a `*` unbounded pathname-expansion
12932        // followed by a strong-quoted literal tail" footgun) routes
12933        // through `FonteCaminhoShellGlob` not
12934        // `FonteCaminhoShellQuoteGrouping`. The unbounded pathname-
12935        // expansion sentinel is the load-bearing root-cause edit
12936        // on every probe-as-both value.
12937        let d = dep_with_fonte(DepSource::Path {
12938            caminho: "../caixa-teia/*'x'".into(),
12939        });
12940        let err = d.validate().unwrap_err();
12941        assert!(
12942            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12943            "got {err:?}",
12944        );
12945    }
12946
12947    #[test]
12948    fn fonte_caminho_shell_command_substitution_fires_before_shell_quote_grouping() {
12949        // Cascade pin on the upstream shell-command-substitution
12950        // arm: a value carrying both a backtick and `'`
12951        // (``"../`whoami`/'x'"`` — the canonical "I pasted a
12952        // legacy-backtick command-substitution followed by a
12953        // strong-quoted literal tail" footgun) routes through
12954        // `FonteCaminhoShellCommandSubstitution` not
12955        // `FonteCaminhoShellQuoteGrouping`. The CWE-78 shell-
12956        // command-injection vector is the load-bearing root-cause
12957        // edit on every probe-as-both value.
12958        let d = dep_with_fonte(DepSource::Path {
12959            caminho: "../`whoami`/'x'".into(),
12960        });
12961        let err = d.validate().unwrap_err();
12962        assert!(
12963            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
12964            "got {err:?}",
12965        );
12966    }
12967
12968    #[test]
12969    fn fonte_caminho_shell_background_fires_before_shell_quote_grouping() {
12970        // Cascade pin on the upstream shell-background arm: a value
12971        // carrying both `&` and `'` (`"../caixa-teia & 'x'"` — the
12972        // canonical "I pasted a `cmd & 'literal'` background-launch
12973        // + quote chain" footgun) routes through
12974        // `FonteCaminhoShellBackground` not
12975        // `FonteCaminhoShellQuoteGrouping`. The background-launch
12976        // tail is the load-bearing root-cause edit on every
12977        // probe-as-both value.
12978        let d = dep_with_fonte(DepSource::Path {
12979            caminho: "../caixa-teia & 'x'".into(),
12980        });
12981        let err = d.validate().unwrap_err();
12982        assert!(
12983            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
12984            "got {err:?}",
12985        );
12986    }
12987
12988    #[test]
12989    fn fonte_caminho_shell_semicolon_fires_before_shell_quote_grouping() {
12990        // Cascade pin on the upstream shell-semicolon arm: a value
12991        // carrying both `;` and `'` (`"../caixa-teia; 'x'"` — the
12992        // canonical sequential-cleanup + quote paste idiom) routes
12993        // through `FonteCaminhoShellSemicolon` not
12994        // `FonteCaminhoShellQuoteGrouping`. The sequential-command-
12995        // separator paste is the load-bearing root-cause edit on
12996        // every probe-as-both value.
12997        let d = dep_with_fonte(DepSource::Path {
12998            caminho: "../caixa-teia; 'x'".into(),
12999        });
13000        let err = d.validate().unwrap_err();
13001        assert!(
13002            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
13003            "got {err:?}",
13004        );
13005    }
13006
13007    #[test]
13008    fn fonte_caminho_shell_pipe_fires_before_shell_quote_grouping() {
13009        // Cascade pin on the upstream shell-pipe arm: a value
13010        // carrying both `|` and `'` (`"../caixa-teia | 'x'"` — the
13011        // canonical pipeline-to-quoted-literal paste idiom) routes
13012        // through `FonteCaminhoShellPipe` not
13013        // `FonteCaminhoShellQuoteGrouping`. The pipeline-tail paste
13014        // is the load-bearing root-cause edit on every probe-as-
13015        // both value.
13016        let d = dep_with_fonte(DepSource::Path {
13017            caminho: "../caixa-teia | 'x'".into(),
13018        });
13019        let err = d.validate().unwrap_err();
13020        assert!(
13021            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
13022            "got {err:?}",
13023        );
13024    }
13025
13026    #[test]
13027    fn fonte_caminho_shell_redirection_fires_before_shell_quote_grouping() {
13028        // Cascade pin on the upstream shell-redirection arm: a
13029        // value carrying both `>` and `'` (`"../caixa-teia>log 'x'"`
13030        // — the canonical "I pasted a `cmd > log 'literal'`
13031        // redirect-plus-quote chain" footgun) routes through
13032        // `FonteCaminhoShellRedirection` not
13033        // `FonteCaminhoShellQuoteGrouping`. The input/output
13034        // redirection metachar carries the more self-locating
13035        // `byte` payload, so the prior arm wins on every probe-as-
13036        // both value.
13037        let d = dep_with_fonte(DepSource::Path {
13038            caminho: "../caixa-teia>log 'x'".into(),
13039        });
13040        let err = d.validate().unwrap_err();
13041        assert!(
13042            matches!(
13043                err,
13044                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
13045            ),
13046            "got {err:?}",
13047        );
13048    }
13049
13050    #[test]
13051    fn fonte_caminho_backslash_fires_before_shell_quote_grouping() {
13052        // Cascade pin on the upstream backslash arm: a value
13053        // carrying both `\` and `'` (`"..\caixa-teia\'x'"` — the
13054        // canonical "I pasted a Windows-shell `cd ..\path\'literal'`
13055        // chain" footgun) routes through `FonteCaminhoBackslash`
13056        // not `FonteCaminhoShellQuoteGrouping`. The cross-host-OS-
13057        // separator divergence is the load-bearing axis on every
13058        // probe-as-both value.
13059        let d = dep_with_fonte(DepSource::Path {
13060            caminho: "..\\caixa-teia\\'x'".into(),
13061        });
13062        let err = d.validate().unwrap_err();
13063        assert!(
13064            matches!(err, DepError::FonteCaminhoBackslash { .. }),
13065            "got {err:?}",
13066        );
13067    }
13068
13069    #[test]
13070    fn fonte_caminho_control_char_fires_before_shell_quote_grouping() {
13071        // Cascade pin on the embedded-control-byte arm: a value
13072        // carrying both a control byte and `'` (`"../foo\n'x'"` —
13073        // the canonical paste-from-multiline-doc footgun where a
13074        // newline landed mid-caminho between two paste fragments)
13075        // routes through `FonteCaminhoControlChar` not
13076        // `FonteCaminhoShellQuoteGrouping`. The POSIX-syscall-
13077        // rejected-byte / NUL-`CString::new`-fail diagnostic is
13078        // the load-bearing axis on every value that probes
13079        // positive for both — mirrors the cascade discipline on
13080        // every prior arm.
13081        let d = dep_with_fonte(DepSource::Path {
13082            caminho: "../foo\n'x'".into(),
13083        });
13084        let err = d.validate().unwrap_err();
13085        assert!(
13086            matches!(err, DepError::FonteCaminhoControlChar { .. }),
13087            "got {err:?}",
13088        );
13089    }
13090
13091    #[test]
13092    fn fonte_caminho_absolute_fires_before_shell_quote_grouping() {
13093        // Cascade pin on the load-bearing leading-byte arm: a
13094        // leading `/` value with embedded `'` (`"/etc/'x'"`) routes
13095        // through `FonteCaminhoAbsolute` not
13096        // `FonteCaminhoShellQuoteGrouping` — the host-layout-leak
13097        // diagnostic is the load-bearing axis, the quote byte is
13098        // the secondary observation. Same precedence logic as every
13099        // prior leading-byte arm.
13100        let d = dep_with_fonte(DepSource::Path {
13101            caminho: "/etc/'x'".into(),
13102        });
13103        let err = d.validate().unwrap_err();
13104        assert!(
13105            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
13106            "got {err:?}",
13107        );
13108    }
13109
13110    #[test]
13111    fn fonte_caminho_var_expansion_fires_before_shell_quote_grouping() {
13112        // Cascade pin on the upstream leading-`$` var-expansion
13113        // arm: a value carrying both a leading `$` and a `'`
13114        // (`"$DIR/'x'"` — the canonical "I pasted a `$DIR` shell-
13115        // variable + quoted literal at the head of a sibling-
13116        // workspace path" footgun) routes through
13117        // `FonteCaminhoVarExpansion` not
13118        // `FonteCaminhoShellQuoteGrouping`. The leading-byte
13119        // shell-variable-expansion is the more self-locating
13120        // diagnostic on values that probe as both — same
13121        // load-bearing-leading-byte cascade discipline every
13122        // prior `:caminho` arm establishes.
13123        let d = dep_with_fonte(DepSource::Path {
13124            caminho: "$DIR/'x'".into(),
13125        });
13126        let err = d.validate().unwrap_err();
13127        assert!(
13128            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
13129            "got {err:?}",
13130        );
13131    }
13132
13133    #[test]
13134    fn fonte_caminho_shell_quote_grouping_fires_before_trailing_slash() {
13135        // Cascade pin on the immediate-successor arm: a value
13136        // carrying both `'` and a trailing `/` (`"../'caixa-teia'/"`
13137        // — the canonical "I tab-completed a path whose strong-
13138        // quoted body already carried the quoting from a shell-
13139        // history paste" footgun) routes through
13140        // `FonteCaminhoShellQuoteGrouping` not
13141        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
13142        // is the more semantic-locating axis (an author who removes
13143        // the `'` typically also drops the trailing separator since
13144        // both are paste-from-shell artifacts).
13145        let d = dep_with_fonte(DepSource::Path {
13146            caminho: "../'caixa-teia'/".into(),
13147        });
13148        let err = d.validate().unwrap_err();
13149        assert!(
13150            matches!(
13151                err,
13152                DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
13153            ),
13154            "got {err:?}",
13155        );
13156    }
13157
13158    #[test]
13159    fn fonte_caminho_shell_quote_grouping_diagnostic_carries_offending_dep_caminho_and_byte() {
13160        // Diagnostic-shape pin (peer with
13161        // `fonte_caminho_shell_bracket_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
13162        // on the closest two-byte peer arm): the error's Display
13163        // surfaces the offending `:nome`, the offending `:caminho`
13164        // verbatim, the offending byte's hex / character form, and
13165        // names the shell-quote-grouping / cross-config-DSL-string-
13166        // literal-delimiter footgun explicitly so a `feira lint`
13167        // run can render the diagnostic without re-parsing.
13168        let d = dep_with_fonte(DepSource::Path {
13169            caminho: "'../caixa-teia'".into(),
13170        });
13171        let rendered = d.validate().unwrap_err().to_string();
13172        assert!(
13173            rendered.contains("caixa-teia"),
13174            "diagnostic must name the offending dep: {rendered}",
13175        );
13176        assert!(
13177            rendered.contains("'../caixa-teia'"),
13178            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
13179        );
13180        assert!(
13181            rendered.contains("0x27"),
13182            "diagnostic must surface the offending byte hex: {rendered:?}",
13183        );
13184        assert!(
13185            rendered.contains("quote-grouping"),
13186            "diagnostic must name the shell-quote-grouping footgun: {rendered:?}",
13187        );
13188        assert!(
13189            rendered.contains("string-literal"),
13190            "diagnostic must reference the cross-config-DSL string-literal-delimiter \
13191             vocabulary: {rendered:?}",
13192        );
13193    }
13194
13195    #[test]
13196    fn validate_rejects_path_fonte_with_caminho_carrying_shell_comment_lead() {
13197        // The canonical paste-from-shell-history-with-trailing-
13198        // annotation footgun: an author pastes a `cd ../caixa-teia
13199        // # legacy sibling` shell-history one-liner whose unquoted `#`
13200        // comment-lead separates the path from an inline annotation.
13201        // The POSIX shell trims the annotation to `../caixa-teia`
13202        // (POSIX.1-2017 §2.3 Token Recognition step 6), but
13203        // `Path::is_absolute` returns false on `..`, `#` is neither
13204        // a leading-byte sentinel nor a control byte nor `\` nor
13205        // `<` / `>` nor `|` nor `;` nor `&` nor backtick nor `*` /
13206        // `?` nor `(` / `)` nor `{` / `}` nor `[` / `]` nor `'` /
13207        // `"`, and the value's last byte isn't `/` — so the value
13208        // silently passed every prior arm. The resolver folded the
13209        // value through `Path::join` looking for a literal
13210        // `./../caixa-teia # legacy sibling` subdirectory and the
13211        // failure surfaced at resolve time with a non-self-locating
13212        // `No such file or directory` error. The new arm moves the
13213        // rejection to validate time and names the offending dep +
13214        // caminho + byte verbatim.
13215        let d = dep_with_fonte(DepSource::Path {
13216            caminho: "../caixa-teia # legacy sibling".into(),
13217        });
13218        let err = d.validate().unwrap_err();
13219        let DepError::FonteCaminhoShellComment {
13220            nome,
13221            caminho,
13222            byte,
13223        } = err
13224        else {
13225            panic!("expected FonteCaminhoShellComment, got {err:?}");
13226        };
13227        assert_eq!(nome, "caixa-teia");
13228        assert_eq!(caminho, "../caixa-teia # legacy sibling");
13229        assert_eq!(byte, b'#');
13230    }
13231
13232    #[test]
13233    fn validate_rejects_path_fonte_with_caminho_carrying_yaml_comment_paste() {
13234        // The symmetric YAML flow-scalar / values.yaml / K8s-manifest
13235        // cross-idiom-leak shape (`"../caixa-teia  # pin"` — the
13236        // canonical "I copied a `path: ../caixa-teia  # pin` YAML
13237        // scalar-plus-comment entry out of an aligned values.yaml and
13238        // dropped it verbatim into the `:caminho` slot" paste-idiom).
13239        // Pinned separately from the shell-history shape so the
13240        // gate's coverage extends from the single-space `#` shape to
13241        // the YAML-canonical double-space `  #` shape. YAML 1.2 §6.6
13242        // requires the `#` to be preceded by whitespace to lex as a
13243        // comment (bare `foo#bar` is a single scalar); the double-
13244        // space paste from an aligned manifest is the canonical
13245        // shape.
13246        let d = dep_with_fonte(DepSource::Path {
13247            caminho: "../caixa-teia  # pin".into(),
13248        });
13249        let err = d.validate().unwrap_err();
13250        assert!(
13251            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
13252            "got {err:?}",
13253        );
13254    }
13255
13256    #[test]
13257    fn validate_rejects_path_fonte_with_caminho_carrying_url_fragment_anchor() {
13258        // The URL-fragment-identifier paste shape
13259        // (`"../caixa-teia#readme"` — the canonical
13260        // paste-from-browser-address-bar permalink shape where the
13261        // browser preserved the `#anchor` tail on the copy). Pinned
13262        // separately from the whitespace-separated shell / YAML
13263        // comment shapes so the gate covers the unpadded RFC 3986
13264        // §3.5 fragment-delimiter position too, not only positions
13265        // preceded by unquoted whitespace. Peer with the immediate-
13266        // sibling `is_git_repo_url` arm on the `:fonte :repo` axis
13267        // (a68f818) which closes the same byte under the same URL-
13268        // fragment-identifier banner.
13269        let d = dep_with_fonte(DepSource::Path {
13270            caminho: "../caixa-teia#readme".into(),
13271        });
13272        let err = d.validate().unwrap_err();
13273        assert!(
13274            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
13275            "got {err:?}",
13276        );
13277    }
13278
13279    #[test]
13280    fn validate_rejects_path_fonte_with_caminho_carrying_leading_shell_comment() {
13281        // Leading-position `#` shape (`"#../caixa-teia"` — the
13282        // "I copied a shell-comment-out entry from a commented-out
13283        // dep row" footgun). Pinned separately from the embedded
13284        // shapes so the gate covers every position, not only
13285        // whitespace-preceded / mid-value.
13286        let d = dep_with_fonte(DepSource::Path {
13287            caminho: "#../caixa-teia".into(),
13288        });
13289        let err = d.validate().unwrap_err();
13290        assert!(
13291            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
13292            "got {err:?}",
13293        );
13294    }
13295
13296    #[test]
13297    fn validate_accepts_path_fonte_with_caminho_carrying_no_shell_comment() {
13298        // The positive-control pin: the gate targets only `#`,
13299        // never adjacent printable ASCII or POSIX-valid bytes. The
13300        // canonical relative POSIX path (`"../caixa-teia"`) and a
13301        // nested deeply-pathed variant with adjacent printable
13302        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
13303        // to validate cleanly so the gate doesn't widen to a "no
13304        // printable punctuation anywhere" sweep that would defeat
13305        // the entire path-fonte author surface. Peer with
13306        // `validate_accepts_path_fonte_with_caminho_carrying_no_quote_grouping`
13307        // on the immediate-predecessor arm.
13308        let d = dep_with_fonte(DepSource::Path {
13309            caminho: "../caixa-teia/sub-dir.v2".into(),
13310        });
13311        d.validate().unwrap();
13312    }
13313
13314    #[test]
13315    fn fonte_caminho_shell_quote_grouping_fires_before_shell_comment() {
13316        // Cascade pin on the immediate-predecessor arm: a value
13317        // carrying both `'` and `#` (`"../'x'#pin"` — the canonical
13318        // "I pasted a strong-quoted literal followed by a URL-
13319        // fragment permalink tail" footgun) routes through
13320        // `FonteCaminhoShellQuoteGrouping` not
13321        // `FonteCaminhoShellComment`. The shell-string-literal-
13322        // delimiter is the load-bearing root-cause edit on every
13323        // probe-as-both value; same cascade discipline every prior
13324        // `:caminho` arm establishes.
13325        let d = dep_with_fonte(DepSource::Path {
13326            caminho: "../'x'#pin".into(),
13327        });
13328        let err = d.validate().unwrap_err();
13329        assert!(
13330            matches!(
13331                err,
13332                DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
13333            ),
13334            "got {err:?}",
13335        );
13336    }
13337
13338    #[test]
13339    fn fonte_caminho_shell_bracket_expansion_fires_before_shell_comment() {
13340        // Cascade pin on the upstream shell-bracket-expansion arm:
13341        // a value carrying both `[` and `#` (`"../[a-z]#pin"` — the
13342        // canonical "I pasted a glob-character-class followed by a
13343        // URL-fragment tail" footgun) routes through
13344        // `FonteCaminhoShellBracketExpansion` not
13345        // `FonteCaminhoShellComment`. The glob-character-class
13346        // expansion is the load-bearing root-cause edit on every
13347        // probe-as-both value.
13348        let d = dep_with_fonte(DepSource::Path {
13349            caminho: "../[a-z]#pin".into(),
13350        });
13351        let err = d.validate().unwrap_err();
13352        assert!(
13353            matches!(
13354                err,
13355                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
13356            ),
13357            "got {err:?}",
13358        );
13359    }
13360
13361    #[test]
13362    fn fonte_caminho_shell_brace_expansion_fires_before_shell_comment() {
13363        // Cascade pin on the upstream shell-brace-expansion arm: a
13364        // value carrying both `{` and `#` (`"../{a,b}#pin"` — the
13365        // canonical "I pasted a brace-expansion fan followed by a
13366        // URL-fragment tail" footgun) routes through
13367        // `FonteCaminhoShellBraceExpansion` not
13368        // `FonteCaminhoShellComment`. The brace-expansion fan is the
13369        // load-bearing root-cause edit on every probe-as-both value.
13370        let d = dep_with_fonte(DepSource::Path {
13371            caminho: "../{a,b}#pin".into(),
13372        });
13373        let err = d.validate().unwrap_err();
13374        assert!(
13375            matches!(
13376                err,
13377                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
13378            ),
13379            "got {err:?}",
13380        );
13381    }
13382
13383    #[test]
13384    fn fonte_caminho_shell_subshell_grouping_fires_before_shell_comment() {
13385        // Cascade pin on the upstream shell-subshell-grouping arm:
13386        // a value carrying both `(` and `#` (`"../(cd foo)#pin"` —
13387        // the canonical "I pasted a subshell-grouping followed by a
13388        // URL-fragment tail" footgun) routes through
13389        // `FonteCaminhoShellSubshellGrouping` not
13390        // `FonteCaminhoShellComment`. The modern Bourne `$(<cmd>)`
13391        // command-substitution boundary is the load-bearing axis on
13392        // every probe-as-both value.
13393        let d = dep_with_fonte(DepSource::Path {
13394            caminho: "../(cd foo)#pin".into(),
13395        });
13396        let err = d.validate().unwrap_err();
13397        assert!(
13398            matches!(
13399                err,
13400                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
13401            ),
13402            "got {err:?}",
13403        );
13404    }
13405
13406    #[test]
13407    fn fonte_caminho_shell_glob_fires_before_shell_comment() {
13408        // Cascade pin on the upstream shell-glob arm: a value
13409        // carrying both `*` and `#` (`"../caixa-teia/*#pin"` — the
13410        // canonical "I pasted a `*` unbounded pathname-expansion
13411        // followed by a URL-fragment tail" footgun) routes through
13412        // `FonteCaminhoShellGlob` not `FonteCaminhoShellComment`.
13413        // The unbounded pathname-expansion sentinel is the load-
13414        // bearing root-cause edit on every probe-as-both value.
13415        let d = dep_with_fonte(DepSource::Path {
13416            caminho: "../caixa-teia/*#pin".into(),
13417        });
13418        let err = d.validate().unwrap_err();
13419        assert!(
13420            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
13421            "got {err:?}",
13422        );
13423    }
13424
13425    #[test]
13426    fn fonte_caminho_shell_command_substitution_fires_before_shell_comment() {
13427        // Cascade pin on the upstream shell-command-substitution
13428        // arm: a value carrying both a backtick and `#`
13429        // (``"../`whoami`#pin"`` — the canonical "I pasted a
13430        // legacy-backtick command-substitution followed by a URL-
13431        // fragment tail" footgun) routes through
13432        // `FonteCaminhoShellCommandSubstitution` not
13433        // `FonteCaminhoShellComment`. The CWE-78 shell-command-
13434        // injection vector is the load-bearing root-cause edit on
13435        // every probe-as-both value.
13436        let d = dep_with_fonte(DepSource::Path {
13437            caminho: "../`whoami`#pin".into(),
13438        });
13439        let err = d.validate().unwrap_err();
13440        assert!(
13441            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
13442            "got {err:?}",
13443        );
13444    }
13445
13446    #[test]
13447    fn fonte_caminho_shell_background_fires_before_shell_comment() {
13448        // Cascade pin on the upstream shell-background arm: a value
13449        // carrying both `&` and `#` (`"../caixa-teia&pin#tail"` —
13450        // the canonical "I pasted a `cmd &` background-launch
13451        // followed by a URL-fragment tail" footgun) routes through
13452        // `FonteCaminhoShellBackground` not
13453        // `FonteCaminhoShellComment`. The background-launch tail is
13454        // the load-bearing root-cause edit on every probe-as-both
13455        // value.
13456        let d = dep_with_fonte(DepSource::Path {
13457            caminho: "../caixa-teia&pin#tail".into(),
13458        });
13459        let err = d.validate().unwrap_err();
13460        assert!(
13461            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
13462            "got {err:?}",
13463        );
13464    }
13465
13466    #[test]
13467    fn fonte_caminho_shell_semicolon_fires_before_shell_comment() {
13468        // Cascade pin on the upstream shell-semicolon arm: a value
13469        // carrying both `;` and `#` (`"../caixa-teia;pin#tail"` —
13470        // the canonical sequential-cleanup + URL-fragment paste
13471        // idiom) routes through `FonteCaminhoShellSemicolon` not
13472        // `FonteCaminhoShellComment`. The sequential-command-
13473        // separator paste is the load-bearing root-cause edit on
13474        // every probe-as-both value.
13475        let d = dep_with_fonte(DepSource::Path {
13476            caminho: "../caixa-teia;pin#tail".into(),
13477        });
13478        let err = d.validate().unwrap_err();
13479        assert!(
13480            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
13481            "got {err:?}",
13482        );
13483    }
13484
13485    #[test]
13486    fn fonte_caminho_shell_pipe_fires_before_shell_comment() {
13487        // Cascade pin on the upstream shell-pipe arm: a value
13488        // carrying both `|` and `#` (`"../caixa-teia|pin#tail"` —
13489        // the canonical pipeline-to-URL-fragment paste idiom) routes
13490        // through `FonteCaminhoShellPipe` not
13491        // `FonteCaminhoShellComment`. The pipeline-tail paste is
13492        // the load-bearing root-cause edit on every probe-as-both
13493        // value.
13494        let d = dep_with_fonte(DepSource::Path {
13495            caminho: "../caixa-teia|pin#tail".into(),
13496        });
13497        let err = d.validate().unwrap_err();
13498        assert!(
13499            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
13500            "got {err:?}",
13501        );
13502    }
13503
13504    #[test]
13505    fn fonte_caminho_shell_redirection_fires_before_shell_comment() {
13506        // Cascade pin on the upstream shell-redirection arm: a
13507        // value carrying both `>` and `#` (`"../caixa-teia>log#pin"`
13508        // — the canonical "I pasted a `cmd > log` redirect followed
13509        // by a URL-fragment tail" footgun) routes through
13510        // `FonteCaminhoShellRedirection` not
13511        // `FonteCaminhoShellComment`. The input/output redirection
13512        // metachar carries the more self-locating `byte` payload,
13513        // so the prior arm wins on every probe-as-both value.
13514        let d = dep_with_fonte(DepSource::Path {
13515            caminho: "../caixa-teia>log#pin".into(),
13516        });
13517        let err = d.validate().unwrap_err();
13518        assert!(
13519            matches!(
13520                err,
13521                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
13522            ),
13523            "got {err:?}",
13524        );
13525    }
13526
13527    #[test]
13528    fn fonte_caminho_backslash_fires_before_shell_comment() {
13529        // Cascade pin on the upstream backslash arm: a value
13530        // carrying both `\` and `#` (`"..\caixa-teia#pin"` — the
13531        // canonical "I pasted a Windows-shell path followed by a
13532        // URL-fragment tail" footgun) routes through
13533        // `FonteCaminhoBackslash` not `FonteCaminhoShellComment`.
13534        // The cross-host-OS-separator divergence is the load-
13535        // bearing axis on every probe-as-both value.
13536        let d = dep_with_fonte(DepSource::Path {
13537            caminho: "..\\caixa-teia#pin".into(),
13538        });
13539        let err = d.validate().unwrap_err();
13540        assert!(
13541            matches!(err, DepError::FonteCaminhoBackslash { .. }),
13542            "got {err:?}",
13543        );
13544    }
13545
13546    #[test]
13547    fn fonte_caminho_control_char_fires_before_shell_comment() {
13548        // Cascade pin on the embedded-control-byte arm: a value
13549        // carrying both a control byte and `#` (`"../foo\n#pin"` —
13550        // the canonical paste-from-multiline-doc footgun where a
13551        // newline landed mid-caminho between the path and an
13552        // annotation) routes through `FonteCaminhoControlChar` not
13553        // `FonteCaminhoShellComment`. The POSIX-syscall-rejected-
13554        // byte diagnostic is the load-bearing axis on every value
13555        // that probes positive for both — mirrors the cascade
13556        // discipline on every prior arm.
13557        let d = dep_with_fonte(DepSource::Path {
13558            caminho: "../foo\n#pin".into(),
13559        });
13560        let err = d.validate().unwrap_err();
13561        assert!(
13562            matches!(err, DepError::FonteCaminhoControlChar { .. }),
13563            "got {err:?}",
13564        );
13565    }
13566
13567    #[test]
13568    fn fonte_caminho_absolute_fires_before_shell_comment() {
13569        // Cascade pin on the load-bearing leading-byte arm: a
13570        // leading `/` value with embedded `#` (`"/etc/foo#pin"`)
13571        // routes through `FonteCaminhoAbsolute` not
13572        // `FonteCaminhoShellComment` — the host-layout-leak
13573        // diagnostic is the load-bearing axis, the fragment byte is
13574        // the secondary observation. Same precedence logic as every
13575        // prior leading-byte arm.
13576        let d = dep_with_fonte(DepSource::Path {
13577            caminho: "/etc/foo#pin".into(),
13578        });
13579        let err = d.validate().unwrap_err();
13580        assert!(
13581            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
13582            "got {err:?}",
13583        );
13584    }
13585
13586    #[test]
13587    fn fonte_caminho_var_expansion_fires_before_shell_comment() {
13588        // Cascade pin on the upstream leading-`$` var-expansion
13589        // arm: a value carrying both a leading `$` and a `#`
13590        // (`"$DIR/foo#pin"` — the canonical "I pasted a `$DIR`
13591        // shell-variable at the head of a sibling-workspace path
13592        // followed by a URL-fragment tail" footgun) routes through
13593        // `FonteCaminhoVarExpansion` not `FonteCaminhoShellComment`.
13594        // The leading-byte shell-variable-expansion is the more
13595        // self-locating diagnostic on values that probe as both.
13596        let d = dep_with_fonte(DepSource::Path {
13597            caminho: "$DIR/foo#pin".into(),
13598        });
13599        let err = d.validate().unwrap_err();
13600        assert!(
13601            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
13602            "got {err:?}",
13603        );
13604    }
13605
13606    #[test]
13607    fn fonte_caminho_shell_comment_fires_before_trailing_slash() {
13608        // Cascade pin on the immediate-successor arm: a value
13609        // carrying both `#` and a trailing `/`
13610        // (`"../caixa-teia#pin/"` — the canonical "I tab-completed
13611        // a URL-fragment-carrying path" footgun) routes through
13612        // `FonteCaminhoShellComment` not
13613        // `FonteCaminhoTrailingSlash`. The embedded fragment /
13614        // comment-lead byte is the more semantic-locating axis (an
13615        // author who removes the `#pin` fragment typically also
13616        // drops the trailing separator since both are paste-from-
13617        // URL / paste-from-shell-tab-completion artifacts).
13618        let d = dep_with_fonte(DepSource::Path {
13619            caminho: "../caixa-teia#pin/".into(),
13620        });
13621        let err = d.validate().unwrap_err();
13622        assert!(
13623            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. },),
13624            "got {err:?}",
13625        );
13626    }
13627
13628    #[test]
13629    fn fonte_caminho_shell_comment_diagnostic_carries_offending_dep_caminho_and_byte() {
13630        // Diagnostic-shape pin (peer with
13631        // `fonte_caminho_shell_quote_grouping_diagnostic_carries_offending_dep_caminho_and_byte`
13632        // on the immediate-predecessor arm): the error's Display
13633        // surfaces the offending `:nome`, the offending `:caminho`
13634        // verbatim, the offending byte's hex / character form, and
13635        // names the shell-comment / URL-fragment-identifier /
13636        // YAML-comment cross-config-DSL footgun explicitly so a
13637        // `feira lint` run can render the diagnostic without
13638        // re-parsing.
13639        let d = dep_with_fonte(DepSource::Path {
13640            caminho: "../caixa-teia#readme".into(),
13641        });
13642        let rendered = d.validate().unwrap_err().to_string();
13643        assert!(
13644            rendered.contains("caixa-teia"),
13645            "diagnostic must name the offending dep: {rendered}",
13646        );
13647        assert!(
13648            rendered.contains("../caixa-teia#readme"),
13649            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
13650        );
13651        assert!(
13652            rendered.contains("0x23"),
13653            "diagnostic must surface the offending byte hex: {rendered:?}",
13654        );
13655        assert!(
13656            rendered.contains("shell-comment") || rendered.contains("comment-lead"),
13657            "diagnostic must name the shell-comment footgun: {rendered:?}",
13658        );
13659        assert!(
13660            rendered.contains("fragment") || rendered.contains("URL-fragment"),
13661            "diagnostic must reference the URL-fragment-identifier vocabulary: \
13662             {rendered:?}",
13663        );
13664    }
13665
13666    #[test]
13667    fn validate_rejects_path_fonte_with_caminho_carrying_url_percent_encoded_space() {
13668        // The canonical paste-from-browser-address-bar percent-
13669        // encoded-space footgun: an author copies `../caixa%20teia`
13670        // out of a URL-encoded README hyperlink / browser address
13671        // bar / percent-encoded permalink expecting `%20` to decode
13672        // to a literal space at the filesystem layer. POSIX
13673        // `std::path::Path` treats `%` as a literal path-component
13674        // byte, so `Path::join` looks for a literal
13675        // `./../caixa%20teia` subdirectory. `Path::is_absolute`
13676        // returns false on `..`, `%` is neither a leading-byte
13677        // sentinel nor a control byte nor `\` nor `<` / `>` nor
13678        // `|` nor `;` nor `&` nor backtick nor `*` / `?` nor `(` /
13679        // `)` nor `{` / `}` nor `[` / `]` nor `'` / `"` nor `#`,
13680        // and the value's last byte isn't `/` — so the value
13681        // silently passed every prior arm. The new arm moves the
13682        // rejection to validate time and names the offending dep +
13683        // caminho + byte verbatim.
13684        let d = dep_with_fonte(DepSource::Path {
13685            caminho: "../caixa%20teia".into(),
13686        });
13687        let err = d.validate().unwrap_err();
13688        let DepError::FonteCaminhoUrlPercentEncoding {
13689            nome,
13690            caminho,
13691            byte,
13692        } = err
13693        else {
13694            panic!("expected FonteCaminhoUrlPercentEncoding, got {err:?}");
13695        };
13696        assert_eq!(nome, "caixa-teia");
13697        assert_eq!(caminho, "../caixa%20teia");
13698        assert_eq!(byte, b'%');
13699    }
13700
13701    #[test]
13702    fn validate_rejects_path_fonte_with_caminho_carrying_url_percent_encoded_slash() {
13703        // The over-encoded path-separator shape (`"../caixa%2Fteia"`
13704        // intending the `%2F` as the URL encoding of `/`) locks a
13705        // `path:../caixa%2Fteia` BLAKE3 closure that diverges from
13706        // the byte-identical `path:../caixa/teia` form. Pinned
13707        // separately from the space-encoded shape so the gate's
13708        // coverage extends past the single canonical `%20` example
13709        // to any two-hex-digit percent-encoded sequence.
13710        let d = dep_with_fonte(DepSource::Path {
13711            caminho: "../caixa%2Fteia".into(),
13712        });
13713        let err = d.validate().unwrap_err();
13714        assert!(
13715            matches!(
13716                err,
13717                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
13718            ),
13719            "got {err:?}",
13720        );
13721    }
13722
13723    #[test]
13724    fn validate_rejects_path_fonte_with_caminho_carrying_lone_percent() {
13725        // The lone-`%` malformed-escape shape (`"../caixa-teia%foo"`
13726        // where `%` isn't followed by two hex digits) — every
13727        // WHATWG-conformant URL parser rejects the value at parse
13728        // time per RFC 3986 §2.1, but the byte would silently ride
13729        // into the lacre before the resolver subprocess crosses the
13730        // URL-parser boundary. Pinned separately from the well-
13731        // formed `%HH` shapes so the gate covers every percent-
13732        // occurrence, not only strictly-conformant escapes.
13733        let d = dep_with_fonte(DepSource::Path {
13734            caminho: "../caixa-teia%foo".into(),
13735        });
13736        let err = d.validate().unwrap_err();
13737        assert!(
13738            matches!(
13739                err,
13740                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
13741            ),
13742            "got {err:?}",
13743        );
13744    }
13745
13746    #[test]
13747    fn validate_rejects_path_fonte_with_caminho_carrying_leading_yaml_directive() {
13748        // The YAML-directive-lead paste shape (`"%YAML/../caixa-teia"`
13749        // — the canonical paste-from-top-of-doc YAML directive
13750        // block cross-idiom leak per YAML 1.2 §6.8.1). Pinned
13751        // separately from embedded shapes so the gate covers the
13752        // leading-position `%` too, not only mid-value occurrences.
13753        let d = dep_with_fonte(DepSource::Path {
13754            caminho: "%YAML/../caixa-teia".into(),
13755        });
13756        let err = d.validate().unwrap_err();
13757        assert!(
13758            matches!(
13759                err,
13760                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
13761            ),
13762            "got {err:?}",
13763        );
13764    }
13765
13766    #[test]
13767    fn validate_rejects_path_fonte_with_caminho_carrying_printf_format_specifier() {
13768        // The printf-format-specifier paste shape
13769        // (`"../caixa-%s-teia"` — the canonical paste-from-shell-
13770        // diagnostic-one-liner `printf "path=%s\n" ...` idiom, CWE-
13771        // 134 format-string-injection vector). Pinned separately
13772        // from the URL-encoding shapes so the gate's rationale
13773        // extends past the RFC 3986 axis to the C / POSIX printf
13774        // format-directive-lead axis.
13775        let d = dep_with_fonte(DepSource::Path {
13776            caminho: "../caixa-%s-teia".into(),
13777        });
13778        let err = d.validate().unwrap_err();
13779        assert!(
13780            matches!(
13781                err,
13782                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
13783            ),
13784            "got {err:?}",
13785        );
13786    }
13787
13788    #[test]
13789    fn validate_accepts_path_fonte_with_caminho_carrying_no_percent() {
13790        // The positive-control pin: the gate targets only `%`,
13791        // never adjacent printable ASCII or POSIX-valid bytes. The
13792        // canonical relative POSIX path (`"../caixa-teia"`) and a
13793        // nested deeply-pathed variant with adjacent printable
13794        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
13795        // to validate cleanly so the gate doesn't widen to a "no
13796        // printable punctuation anywhere" sweep that would defeat
13797        // the entire path-fonte author surface. Peer with
13798        // `validate_accepts_path_fonte_with_caminho_carrying_no_shell_comment`
13799        // on the immediate-predecessor arm.
13800        let d = dep_with_fonte(DepSource::Path {
13801            caminho: "../caixa-teia/sub-dir.v2".into(),
13802        });
13803        d.validate().unwrap();
13804    }
13805
13806    #[test]
13807    fn fonte_caminho_shell_comment_fires_before_url_percent_encoding() {
13808        // Cascade pin on the immediate-predecessor arm: a value
13809        // carrying both `#` and `%` (`"../caixa-teia#pin%20"` — the
13810        // canonical "I pasted a URL-fragment permalink followed by a
13811        // percent-encoded space tail" footgun) routes through
13812        // `FonteCaminhoShellComment` not
13813        // `FonteCaminhoUrlPercentEncoding`. The URL-fragment-
13814        // identifier is the load-bearing downstream-truncation edit
13815        // on every probe-as-both value; same cascade discipline
13816        // every prior `:caminho` arm establishes.
13817        let d = dep_with_fonte(DepSource::Path {
13818            caminho: "../caixa-teia#pin%20".into(),
13819        });
13820        let err = d.validate().unwrap_err();
13821        assert!(
13822            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
13823            "got {err:?}",
13824        );
13825    }
13826
13827    #[test]
13828    fn fonte_caminho_shell_quote_grouping_fires_before_url_percent_encoding() {
13829        // Cascade pin on the upstream shell-quote-grouping arm: a
13830        // value carrying both `'` and `%` (`"../'x'%20teia"` — the
13831        // canonical "I pasted a strong-quoted literal followed by
13832        // a percent-encoded space" footgun) routes through
13833        // `FonteCaminhoShellQuoteGrouping` not
13834        // `FonteCaminhoUrlPercentEncoding`. The shell-string-
13835        // literal-delimiter is the load-bearing root-cause edit on
13836        // every probe-as-both value.
13837        let d = dep_with_fonte(DepSource::Path {
13838            caminho: "../'x'%20teia".into(),
13839        });
13840        let err = d.validate().unwrap_err();
13841        assert!(
13842            matches!(
13843                err,
13844                DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
13845            ),
13846            "got {err:?}",
13847        );
13848    }
13849
13850    #[test]
13851    fn fonte_caminho_backslash_fires_before_url_percent_encoding() {
13852        // Cascade pin on the upstream backslash arm: a value
13853        // carrying both `\` and `%` (`"..\\caixa%20teia"` — the
13854        // canonical "I pasted a Windows-shell path followed by a
13855        // percent-encoded space" footgun) routes through
13856        // `FonteCaminhoBackslash` not
13857        // `FonteCaminhoUrlPercentEncoding`. The cross-host-OS-
13858        // separator divergence is the load-bearing root-cause edit
13859        // on every probe-as-both value.
13860        let d = dep_with_fonte(DepSource::Path {
13861            caminho: "..\\caixa%20teia".into(),
13862        });
13863        let err = d.validate().unwrap_err();
13864        assert!(
13865            matches!(err, DepError::FonteCaminhoBackslash { .. }),
13866            "got {err:?}",
13867        );
13868    }
13869
13870    #[test]
13871    fn fonte_caminho_control_char_fires_before_url_percent_encoding() {
13872        // Cascade pin on the upstream control-char arm: a value
13873        // carrying both a NUL byte and `%` (`"../caixa\0%20teia"` —
13874        // the canonical "I pasted a paste-from-binary-blob path
13875        // followed by a percent-encoded space" footgun) routes
13876        // through `FonteCaminhoControlChar` not
13877        // `FonteCaminhoUrlPercentEncoding`. The POSIX-syscall-
13878        // rejected byte is the load-bearing root-cause edit on
13879        // every probe-as-both value.
13880        let d = dep_with_fonte(DepSource::Path {
13881            caminho: "../caixa\0%20teia".into(),
13882        });
13883        let err = d.validate().unwrap_err();
13884        assert!(
13885            matches!(err, DepError::FonteCaminhoControlChar { byte: 0x00, .. },),
13886            "got {err:?}",
13887        );
13888    }
13889
13890    #[test]
13891    fn fonte_caminho_absolute_fires_before_url_percent_encoding() {
13892        // Cascade pin on the upstream absolute-path arm: a value
13893        // that's both absolute and carries `%` (`"/etc/passwd%20"`
13894        // — the canonical "I pasted an absolute path with a
13895        // percent-encoded space tail" footgun) routes through
13896        // `FonteCaminhoAbsolute` not
13897        // `FonteCaminhoUrlPercentEncoding`. The host-layout-leak is
13898        // the load-bearing root-cause edit on every probe-as-both
13899        // value.
13900        let d = dep_with_fonte(DepSource::Path {
13901            caminho: "/etc/passwd%20".into(),
13902        });
13903        let err = d.validate().unwrap_err();
13904        assert!(
13905            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
13906            "got {err:?}",
13907        );
13908    }
13909
13910    #[test]
13911    fn fonte_caminho_var_expansion_fires_before_url_percent_encoding() {
13912        // Cascade pin on the upstream var-expansion arm: a value
13913        // starting with `$` and carrying `%` (`"$HOME/caixa%20teia"`
13914        // — the canonical "I pasted a `$HOME`-rooted path with a
13915        // percent-encoded space" footgun) routes through
13916        // `FonteCaminhoVarExpansion` not
13917        // `FonteCaminhoUrlPercentEncoding`. The shell-variable-
13918        // expansion is the load-bearing root-cause edit on every
13919        // probe-as-both value.
13920        let d = dep_with_fonte(DepSource::Path {
13921            caminho: "$HOME/caixa%20teia".into(),
13922        });
13923        let err = d.validate().unwrap_err();
13924        assert!(
13925            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
13926            "got {err:?}",
13927        );
13928    }
13929
13930    #[test]
13931    fn fonte_caminho_url_percent_encoding_fires_before_trailing_slash() {
13932        // Cascade pin on the immediate-successor arm: a value
13933        // carrying both `%` and a trailing `/`
13934        // (`"../caixa%20teia/"` — the canonical "I tab-completed a
13935        // percent-encoded-space-carrying path" footgun) routes
13936        // through `FonteCaminhoUrlPercentEncoding` not
13937        // `FonteCaminhoTrailingSlash`. The embedded percent-
13938        // encoding-escape byte is the more semantic-locating axis
13939        // (an author who decodes the `%20` to a literal space is
13940        // likely to also tab-strip the trailing separator since
13941        // both are paste-from-URL / paste-from-shell-tab-completion
13942        // artifacts).
13943        let d = dep_with_fonte(DepSource::Path {
13944            caminho: "../caixa%20teia/".into(),
13945        });
13946        let err = d.validate().unwrap_err();
13947        assert!(
13948            matches!(
13949                err,
13950                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
13951            ),
13952            "got {err:?}",
13953        );
13954    }
13955
13956    #[test]
13957    fn fonte_caminho_url_percent_encoding_diagnostic_carries_offending_dep_caminho_and_byte() {
13958        // Diagnostic-shape pin (peer with
13959        // `fonte_caminho_shell_comment_diagnostic_carries_offending_dep_caminho_and_byte`
13960        // on the immediate-predecessor arm): the error's Display
13961        // surfaces the offending `:nome`, the offending `:caminho`
13962        // verbatim, the offending byte's hex / character form, and
13963        // names the URL-percent-encoding-escape / printf-format-
13964        // specifier footgun explicitly so a `feira lint` run can
13965        // render the diagnostic without re-parsing.
13966        let d = dep_with_fonte(DepSource::Path {
13967            caminho: "../caixa%20teia".into(),
13968        });
13969        let rendered = d.validate().unwrap_err().to_string();
13970        assert!(
13971            rendered.contains("caixa-teia"),
13972            "diagnostic must name the offending dep: {rendered}",
13973        );
13974        assert!(
13975            rendered.contains("../caixa%20teia"),
13976            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
13977        );
13978        assert!(
13979            rendered.contains("0x25"),
13980            "diagnostic must surface the offending byte hex: {rendered:?}",
13981        );
13982        assert!(
13983            rendered.contains("percent-encoding") || rendered.contains("percent-encoded"),
13984            "diagnostic must name the URL-percent-encoding-escape footgun: {rendered:?}",
13985        );
13986        assert!(
13987            rendered.contains("printf") || rendered.contains("format-specifier"),
13988            "diagnostic must reference the printf-format-specifier vocabulary: \
13989             {rendered:?}",
13990        );
13991    }
13992
13993    #[test]
13994    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_var_expansion() {
13995        // The canonical embedded-`$` shell-variable-expansion paste
13996        // shape (`"../foo$HOME/bar"` — an author copies a partially-
13997        // substituted shell one-liner where the leading segment is a
13998        // literal `../foo` while the mid segment carries the un-
13999        // substituted `$HOME` template). The leading-`$` position is
14000        // already gated by the f4efe9c leading-byte arm which routes
14001        // through `FonteCaminhoVarExpansion`; this arm closes the
14002        // last positional gap on `$` — every position on the axis is
14003        // structurally rejected.
14004        let d = dep_with_fonte(DepSource::Path {
14005            caminho: "../foo$HOME/bar".into(),
14006        });
14007        let err = d.validate().unwrap_err();
14008        let DepError::FonteCaminhoShellVariableExpansion {
14009            nome,
14010            caminho,
14011            byte,
14012        } = err
14013        else {
14014            panic!("expected FonteCaminhoShellVariableExpansion, got {err:?}");
14015        };
14016        assert_eq!(nome, "caixa-teia");
14017        assert_eq!(caminho, "../foo$HOME/bar");
14018        assert_eq!(byte, b'$');
14019    }
14020
14021    #[test]
14022    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_braced_var_expansion() {
14023        // The symmetric braced-CI-manifest paste shape
14024        // (`"../foo${WORKSPACE}/bar"` — the canonical paste-from-
14025        // GitHub-Actions-workflow / paste-from-`.gitlab-ci.yml`
14026        // footgun). Pinned separately from the bare-`$VAR` shape so
14027        // the gate covers both POSIX shell §2.6 Parameter Expansion
14028        // syntactic forms, not only the unbraced variant. The
14029        // embedded `{` byte in `${...}` is also caught by the 598b770
14030        // shell-brace-expansion arm but that arm fires earlier in
14031        // the cascade — the `$` arm's coverage extends to `${...}`
14032        // structurally, so the diagnostic asserted here is the
14033        // brace-expansion one (which is a valid outcome; the point
14034        // of the pin is that the value never survives validation).
14035        let d = dep_with_fonte(DepSource::Path {
14036            caminho: "../foo${WORKSPACE}/bar".into(),
14037        });
14038        let err = d.validate().unwrap_err();
14039        assert!(
14040            matches!(
14041                err,
14042                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. }
14043                    | DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
14044            ),
14045            "got {err:?}",
14046        );
14047    }
14048
14049    #[test]
14050    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_command_substitution() {
14051        // The paste-from-shell-prompt command-substitution idiom
14052        // (`"../foo$(whoami)/bar"`). Pinned separately from the bare-
14053        // `$VAR` shape so the gate's rationale extends to POSIX shell
14054        // §2.6.3 Command Substitution (the modern `$(<cmd>)` form; the
14055        // legacy `` `<cmd>` `` form is already closed by the c370458
14056        // backtick arm). The embedded `(` byte in `$(...)` is also
14057        // caught structurally by the 0633c91 shell-subshell-grouping
14058        // arm which fires earlier in the cascade — the diagnostic
14059        // asserted here is either outcome, since both structurally
14060        // reject the value; the point of the pin is that the value
14061        // never survives validation.
14062        let d = dep_with_fonte(DepSource::Path {
14063            caminho: "../foo$(whoami)/bar".into(),
14064        });
14065        let err = d.validate().unwrap_err();
14066        assert!(
14067            matches!(
14068                err,
14069                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. }
14070                    | DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
14071            ),
14072            "got {err:?}",
14073        );
14074    }
14075
14076    #[test]
14077    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_positional_parameter() {
14078        // The paste-from-`Makefile` / paste-from-SQL-migration bare-
14079        // `$1` positional-parameter shape (`"../foo$1/bar"` — a Make
14080        // automatic-variable `$1` or a PostgreSQL bind-parameter `$1`
14081        // idiom copied into a caminho template). None of the prior
14082        // shell-metachar arms cover this shape (`1` is a bare digit;
14083        // no `(` / `{` / letter follows the `$`), so the arm is the
14084        // sole gate on the shape.
14085        let d = dep_with_fonte(DepSource::Path {
14086            caminho: "../foo$1/bar".into(),
14087        });
14088        let err = d.validate().unwrap_err();
14089        assert!(
14090            matches!(
14091                err,
14092                DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
14093            ),
14094            "got {err:?}",
14095        );
14096    }
14097
14098    #[test]
14099    fn validate_accepts_path_fonte_with_caminho_carrying_no_dollar() {
14100        // The positive-control pin (peer with
14101        // `validate_accepts_path_fonte_with_caminho_carrying_no_percent`
14102        // on the immediate-predecessor arm): the gate targets only
14103        // `$`, never adjacent printable ASCII or POSIX-valid bytes.
14104        // A relative POSIX path carrying dashes / dots / slashes /
14105        // digits (`"../caixa-teia/sub-dir.v2"`) must continue to
14106        // validate cleanly so the gate doesn't widen to a "no
14107        // printable punctuation anywhere" sweep that would defeat
14108        // the entire path-fonte author surface.
14109        let d = dep_with_fonte(DepSource::Path {
14110            caminho: "../caixa-teia/sub-dir.v2".into(),
14111        });
14112        d.validate().unwrap();
14113    }
14114
14115    #[test]
14116    fn fonte_caminho_var_expansion_fires_before_shell_variable_expansion() {
14117        // Cascade pin on the leading-`$` sibling arm at line 540: a
14118        // value starting with `$` and carrying an embedded `$` too
14119        // (`"$HOME/foo$WORKSPACE/bar"` — the canonical "I pasted a
14120        // fully-templated CI path with two un-substituted variables")
14121        // routes through `FonteCaminhoVarExpansion` not
14122        // `FonteCaminhoShellVariableExpansion`. The leading-byte
14123        // host-layout-leak is the load-bearing self-locating axis
14124        // (the leading position dominates the semantic-locating
14125        // rationale on every probe-as-both value); the embedded
14126        // arm's positional-agnostic sweep catches only values whose
14127        // leading byte doesn't route through the earlier leading-
14128        // byte arms.
14129        let d = dep_with_fonte(DepSource::Path {
14130            caminho: "$HOME/foo$WORKSPACE/bar".into(),
14131        });
14132        let err = d.validate().unwrap_err();
14133        assert!(
14134            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
14135            "got {err:?}",
14136        );
14137    }
14138
14139    #[test]
14140    fn fonte_caminho_url_percent_encoding_fires_before_shell_variable_expansion() {
14141        // Cascade pin on the immediate-predecessor arm: a value
14142        // carrying both `%` and embedded `$` (`"../foo%20$HOME/bar"`
14143        // — the canonical "I pasted a percent-encoded space adjacent
14144        // to a `$HOME` template") routes through
14145        // `FonteCaminhoUrlPercentEncoding` not
14146        // `FonteCaminhoShellVariableExpansion`. The URL-percent-
14147        // encoding-escape byte is the more semantic-locating axis
14148        // (the paste-from-browser-address-bar shape is the load-
14149        // bearing self-locating edit); same cascade discipline every
14150        // prior `:caminho` arm establishes.
14151        let d = dep_with_fonte(DepSource::Path {
14152            caminho: "../foo%20$HOME/bar".into(),
14153        });
14154        let err = d.validate().unwrap_err();
14155        assert!(
14156            matches!(
14157                err,
14158                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
14159            ),
14160            "got {err:?}",
14161        );
14162    }
14163
14164    #[test]
14165    fn fonte_caminho_shell_variable_expansion_fires_before_trailing_slash() {
14166        // Cascade pin on the immediate-successor arm: a value
14167        // carrying both embedded `$` and a trailing `/`
14168        // (`"../foo$HOME/bar/"` — the canonical "I tab-completed a
14169        // `$HOME`-template-carrying path") routes through
14170        // `FonteCaminhoShellVariableExpansion` not
14171        // `FonteCaminhoTrailingSlash`. The embedded shell-variable-
14172        // expansion byte is the more semantic-locating axis on
14173        // probe-as-both values (an author who substitutes the
14174        // `$HOME` template with a literal value is likely to also
14175        // tab-strip the trailing separator).
14176        let d = dep_with_fonte(DepSource::Path {
14177            caminho: "../foo$HOME/bar/".into(),
14178        });
14179        let err = d.validate().unwrap_err();
14180        assert!(
14181            matches!(
14182                err,
14183                DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
14184            ),
14185            "got {err:?}",
14186        );
14187    }
14188
14189    #[test]
14190    fn fonte_caminho_shell_variable_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
14191        // Diagnostic-shape pin (peer with
14192        // `fonte_caminho_url_percent_encoding_diagnostic_carries_offending_dep_caminho_and_byte`
14193        // on the immediate-predecessor arm): the error's Display
14194        // surfaces the offending `:nome`, the offending `:caminho`
14195        // verbatim, the offending byte's hex / character form, and
14196        // names the shell-variable-expansion / command-substitution
14197        // footgun explicitly so a `feira lint` run can render the
14198        // diagnostic without re-parsing.
14199        let d = dep_with_fonte(DepSource::Path {
14200            caminho: "../foo$HOME/bar".into(),
14201        });
14202        let rendered = d.validate().unwrap_err().to_string();
14203        assert!(
14204            rendered.contains("caixa-teia"),
14205            "diagnostic must name the offending dep: {rendered}",
14206        );
14207        assert!(
14208            rendered.contains("../foo$HOME/bar"),
14209            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
14210        );
14211        assert!(
14212            rendered.contains("0x24"),
14213            "diagnostic must surface the offending byte hex: {rendered:?}",
14214        );
14215        assert!(
14216            rendered.contains("variable-expansion") || rendered.contains("variable expansion"),
14217            "diagnostic must name the shell-variable-expansion footgun: {rendered:?}",
14218        );
14219        assert!(
14220            rendered.contains("command-substitution") || rendered.contains("command substitution"),
14221            "diagnostic must reference the command-substitution vocabulary: {rendered:?}",
14222        );
14223    }
14224
14225    #[test]
14226    fn validate_rejects_path_fonte_with_caminho_carrying_shell_history_expansion() {
14227        // The fail-before-pass-after pin for the canonical paste-from-
14228        // shell-history footgun on `:caminho`. An author copies a `cd
14229        // ../caixa-teia && !sudo make install` one-liner from a quick-
14230        // start README, intending the trailing `!sudo` as a shell-
14231        // history-expansion reference but the typed slot is itself a
14232        // byte-level string parser, not a shell context, so the byte
14233        // rides into the value verbatim. Until this arm landed the `!`
14234        // byte silently passed every prior `:caminho` cascade arm
14235        // (`!` isn't `\` / `<` / `>` / `|` / `;` / `&` / backtick /
14236        // `*` / `?` / `(` / `)` / `{` / `}` / `[` / `]` / `'` / `"` /
14237        // `#` / `%` / `$`); bash with the default `histexpand` mode
14238        // rewrites `!command` to the most recent history entry
14239        // beginning with `command`, the canonical RCE-class injection
14240        // vector when the byte rides into a shell argument executed
14241        // under `bash -i` (the operator-notebook interactive shell).
14242        let d = dep_with_fonte(DepSource::Path {
14243            caminho: "../caixa-teia!sudo".into(),
14244        });
14245        let err = d.validate().unwrap_err();
14246        let DepError::FonteCaminhoShellHistoryExpansion {
14247            nome,
14248            caminho,
14249            byte,
14250        } = err
14251        else {
14252            panic!("expected FonteCaminhoShellHistoryExpansion, got {err:?}");
14253        };
14254        assert_eq!(nome, "caixa-teia");
14255        assert_eq!(caminho, "../caixa-teia!sudo");
14256        assert_eq!(byte, b'!');
14257    }
14258
14259    #[test]
14260    fn validate_rejects_path_fonte_with_caminho_carrying_double_bang_history_reference() {
14261        // The symmetric `!!` repeat-prior-command paste idiom (peer with
14262        // `validate_rejects_git_fonte_with_repo_carrying_double_bang_history_reference`
14263        // on `is_git_repo_url`). Pinned separately from the wrapped
14264        // `!command` shape so a future diagnostic-surface change that
14265        // only checked the leading or paired-bang position surfaces
14266        // here — the per-byte arm fires anywhere `!` appears in the
14267        // value, including at consecutive positions in the middle.
14268        let d = dep_with_fonte(DepSource::Path {
14269            caminho: "../foo!!/bar".into(),
14270        });
14271        let err = d.validate().unwrap_err();
14272        assert!(
14273            matches!(
14274                err,
14275                DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
14276            ),
14277            "got {err:?}",
14278        );
14279    }
14280
14281    #[test]
14282    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_enthusiasm_bang() {
14283        // The English-typography enthusiasm-form paste-from-prose
14284        // idiom: an author writes `:caminho "../caixa-teia!"`
14285        // expecting the substrate to coerce it to a kebab-case slug.
14286        // Pinned separately from the `!<word>` shell-history shape so
14287        // the gate's rationale extends to the paste-from-prose surface
14288        // (the same rationale the peer `is_git_repo_url` bang arm at
14289        // 7d53c68 covers). None of the prior shell-metachar arms cover
14290        // this shape (no `!<word>` reference and no `!!` repeat), so
14291        // the arm is the sole gate on the shape.
14292        let d = dep_with_fonte(DepSource::Path {
14293            caminho: "../caixa-teia!".into(),
14294        });
14295        let err = d.validate().unwrap_err();
14296        assert!(
14297            matches!(
14298                err,
14299                DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
14300            ),
14301            "got {err:?}",
14302        );
14303    }
14304
14305    #[test]
14306    fn validate_accepts_path_fonte_with_caminho_carrying_no_bang() {
14307        // The positive-control pin (peer with
14308        // `validate_accepts_path_fonte_with_caminho_carrying_no_dollar`
14309        // on the immediate-predecessor arm): the gate targets only
14310        // `!`, never adjacent printable ASCII or POSIX-valid bytes.
14311        // A relative POSIX path carrying dashes / dots / slashes /
14312        // digits (`"../caixa-teia/sub-dir.v2"`) must continue to
14313        // validate cleanly so the gate doesn't widen to a "no
14314        // printable punctuation anywhere" sweep that would defeat
14315        // the entire path-fonte author surface.
14316        let d = dep_with_fonte(DepSource::Path {
14317            caminho: "../caixa-teia/sub-dir.v2".into(),
14318        });
14319        d.validate().unwrap();
14320    }
14321
14322    #[test]
14323    fn fonte_caminho_shell_variable_expansion_fires_before_shell_history_expansion() {
14324        // Cascade pin on the immediate-predecessor arm: a value
14325        // carrying both embedded `$` and `!` (`"../foo$HOME/bar!sudo"`
14326        // — the canonical "I pasted a `$HOME`-templated path adjacent
14327        // to a trailing `!sudo` history-expansion") routes through
14328        // `FonteCaminhoShellVariableExpansion` not
14329        // `FonteCaminhoShellHistoryExpansion`. The shell-variable-
14330        // expansion byte is the more semantic-locating axis on
14331        // probe-as-both values (the paste-from-CI-manifest-with-`$VAR`-
14332        // template shape is the load-bearing self-locating edit);
14333        // same cascade discipline every prior `:caminho` arm
14334        // establishes.
14335        let d = dep_with_fonte(DepSource::Path {
14336            caminho: "../foo$HOME/bar!sudo".into(),
14337        });
14338        let err = d.validate().unwrap_err();
14339        assert!(
14340            matches!(
14341                err,
14342                DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
14343            ),
14344            "got {err:?}",
14345        );
14346    }
14347
14348    #[test]
14349    fn fonte_caminho_shell_history_expansion_fires_before_trailing_slash() {
14350        // Cascade pin on the immediate-successor arm: a value carrying
14351        // both embedded `!` and a trailing `/` (`"../caixa-teia!sudo/"`
14352        // — the canonical "I tab-completed a `!sudo`-carrying path")
14353        // routes through `FonteCaminhoShellHistoryExpansion` not
14354        // `FonteCaminhoTrailingSlash`. The embedded shell-history-
14355        // expansion byte is the more semantic-locating axis on probe-
14356        // as-both values (an author who removes the `!sudo` history
14357        // reference is likely to also tab-strip the trailing separator).
14358        let d = dep_with_fonte(DepSource::Path {
14359            caminho: "../caixa-teia!sudo/".into(),
14360        });
14361        let err = d.validate().unwrap_err();
14362        assert!(
14363            matches!(
14364                err,
14365                DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
14366            ),
14367            "got {err:?}",
14368        );
14369    }
14370
14371    #[test]
14372    fn fonte_caminho_shell_history_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
14373        // Diagnostic-shape pin (peer with
14374        // `fonte_caminho_shell_variable_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
14375        // on the immediate-predecessor arm): the error's Display
14376        // surfaces the offending `:nome`, the offending `:caminho`
14377        // verbatim, the offending byte's hex / character form, and
14378        // names the shell-history-expansion / bang-operator footgun
14379        // explicitly so a `feira lint` run can render the diagnostic
14380        // without re-parsing.
14381        let d = dep_with_fonte(DepSource::Path {
14382            caminho: "../caixa-teia!sudo".into(),
14383        });
14384        let rendered = d.validate().unwrap_err().to_string();
14385        assert!(
14386            rendered.contains("caixa-teia"),
14387            "diagnostic must name the offending dep: {rendered}",
14388        );
14389        assert!(
14390            rendered.contains("../caixa-teia!sudo"),
14391            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
14392        );
14393        assert!(
14394            rendered.contains("0x21"),
14395            "diagnostic must surface the offending byte hex: {rendered:?}",
14396        );
14397        assert!(
14398            rendered.contains("history-expansion") || rendered.contains("history expansion"),
14399            "diagnostic must name the shell-history-expansion footgun: {rendered:?}",
14400        );
14401        assert!(
14402            rendered.contains("bang"),
14403            "diagnostic must reference the bang-operator vocabulary: {rendered:?}",
14404        );
14405    }
14406
14407    #[test]
14408    fn validate_rejects_path_fonte_with_caminho_carrying_shell_history_substitution() {
14409        // The fail-before-pass-after pin for the canonical paste-from-
14410        // shell-history-quick-substitution footgun on `:caminho`. An
14411        // author copies a `git clone <bad-url>` line from their terminal,
14412        // corrects it via bash's `^bad^good` quick-substitution history
14413        // operator (bash reference §9.3, `set -o histexpand` mode's
14414        // default for interactive sessions), and pastes the trailing
14415        // `^bad^good` substitution fragment into a `:caminho` value
14416        // without trimming the leading `git clone` prefix — the byte
14417        // rides into the manifest verbatim. Until this arm landed the
14418        // `^` byte silently passed every prior `:caminho` cascade arm
14419        // (`^` isn't `\` / `<` / `>` / `|` / `;` / `&` / backtick / `*`
14420        // / `?` / `(` / `)` / `{` / `}` / `[` / `]` / `'` / `"` / `#` /
14421        // `%` / `$` / `!`); bash with the default `histexpand` mode
14422        // rewrites the prior command's `bad` string to `good` and re-
14423        // executes it, the paired-operator half of the `set -o
14424        // histexpand` feature the peer `!` arm already closes the prefix
14425        // half of. The peer `is_git_repo_url` axis rejects the byte at
14426        // 49e142f under the same shell-history-substitution / RFC-3986-
14427        // unwise banner.
14428        let d = dep_with_fonte(DepSource::Path {
14429            caminho: "../foo^bad^good".into(),
14430        });
14431        let err = d.validate().unwrap_err();
14432        let DepError::FonteCaminhoShellHistorySubstitution {
14433            nome,
14434            caminho,
14435            byte,
14436        } = err
14437        else {
14438            panic!("expected FonteCaminhoShellHistorySubstitution, got {err:?}");
14439        };
14440        assert_eq!(nome, "caixa-teia");
14441        assert_eq!(caminho, "../foo^bad^good");
14442        assert_eq!(byte, b'^');
14443    }
14444
14445    #[test]
14446    fn validate_rejects_path_fonte_with_caminho_carrying_regex_negation_anchor() {
14447        // The symmetric paste-from-doc-grep-pipeline footgun (peer with
14448        // `validate_rejects_git_fonte_with_repo_carrying_caret_regex_anchor`
14449        // on `is_git_repo_url`). An author copies a `grep '^archived'`
14450        // regex-anchor / negation idiom from a doc snippet and the byte
14451        // rides in verbatim. Pinned separately from the `^old^new^`
14452        // quick-substitution shape so a future diagnostic-surface change
14453        // that only checked the paired-caret history-substitution
14454        // position surfaces here — the per-byte arm fires anywhere `^`
14455        // appears in the value, including at a solitary leading-of-
14456        // segment position.
14457        let d = dep_with_fonte(DepSource::Path {
14458            caminho: "../foo/^archived".into(),
14459        });
14460        let err = d.validate().unwrap_err();
14461        assert!(
14462            matches!(
14463                err,
14464                DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
14465            ),
14466            "got {err:?}",
14467        );
14468    }
14469
14470    #[test]
14471    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_history_substitution_open() {
14472        // The trailing-`^` history-substitution-open shape — an author
14473        // starts typing a `^bad^good` quick-substitution but pastes only
14474        // the leading `^` sentinel before context-switching (a bash-
14475        // reference §9.3 valid histexpand prefix on its own — even a
14476        // solitary `^` on the prior command's whole re-execution shape).
14477        // Pinned separately from the `^old^new^` full-form and the leading-
14478        // of-segment `^archived` regex-anchor shape so the gate's
14479        // rationale extends to the paste-from-shell-history-with-only-
14480        // the-first-byte-selected surface. None of the prior shell-
14481        // metachar arms cover this shape.
14482        let d = dep_with_fonte(DepSource::Path {
14483            caminho: "../caixa-teia^".into(),
14484        });
14485        let err = d.validate().unwrap_err();
14486        assert!(
14487            matches!(
14488                err,
14489                DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
14490            ),
14491            "got {err:?}",
14492        );
14493    }
14494
14495    #[test]
14496    fn validate_accepts_path_fonte_with_caminho_carrying_no_caret() {
14497        // The positive-control pin (peer with
14498        // `validate_accepts_path_fonte_with_caminho_carrying_no_bang`
14499        // on the immediate-predecessor arm): the gate targets only
14500        // `^`, never adjacent printable ASCII or POSIX-valid bytes.
14501        // A relative POSIX path carrying dashes / dots / slashes /
14502        // digits / underscore (`"../caixa-teia/sub_v2.rc"`) must
14503        // continue to validate cleanly so the gate doesn't widen to
14504        // a "no printable punctuation anywhere" sweep that would
14505        // defeat the entire path-fonte author surface.
14506        let d = dep_with_fonte(DepSource::Path {
14507            caminho: "../caixa-teia/sub_v2.rc".into(),
14508        });
14509        d.validate().unwrap();
14510    }
14511
14512    #[test]
14513    fn fonte_caminho_shell_history_expansion_fires_before_shell_history_substitution() {
14514        // Cascade pin on the immediate-predecessor arm: a value carrying
14515        // both embedded `!` and `^` (`"../foo!sudo^bad^good"` — the
14516        // canonical "I pasted a `!sudo` history-reference next to a
14517        // `^bad^good` quick-substitution") routes through
14518        // `FonteCaminhoShellHistoryExpansion` not
14519        // `FonteCaminhoShellHistorySubstitution`. The `!` prefix form is
14520        // the more semantic-locating axis on probe-as-both values (an
14521        // author who removes the `!sudo` reference is likely to also
14522        // strip the paired `^` substitution fragment); same cascade
14523        // discipline every prior `:caminho` arm establishes.
14524        let d = dep_with_fonte(DepSource::Path {
14525            caminho: "../foo!sudo^bad^good".into(),
14526        });
14527        let err = d.validate().unwrap_err();
14528        assert!(
14529            matches!(
14530                err,
14531                DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
14532            ),
14533            "got {err:?}",
14534        );
14535    }
14536
14537    #[test]
14538    fn fonte_caminho_shell_history_substitution_fires_before_trailing_slash() {
14539        // Cascade pin on the immediate-successor arm: a value carrying
14540        // both embedded `^` and a trailing `/` (`"../foo^bad^good/"` —
14541        // the canonical "I tab-completed a `^bad^good`-carrying path")
14542        // routes through `FonteCaminhoShellHistorySubstitution` not
14543        // `FonteCaminhoTrailingSlash`. The embedded shell-history-
14544        // substitution byte is the more semantic-locating axis on probe-
14545        // as-both values (an author who removes the `^bad^good`
14546        // substitution fragment is likely to also tab-strip the trailing
14547        // separator).
14548        let d = dep_with_fonte(DepSource::Path {
14549            caminho: "../foo^bad^good/".into(),
14550        });
14551        let err = d.validate().unwrap_err();
14552        assert!(
14553            matches!(
14554                err,
14555                DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
14556            ),
14557            "got {err:?}",
14558        );
14559    }
14560
14561    #[test]
14562    fn fonte_caminho_shell_history_substitution_diagnostic_carries_offending_dep_caminho_and_byte()
14563    {
14564        // Diagnostic-shape pin (peer with
14565        // `fonte_caminho_shell_history_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
14566        // on the immediate-predecessor arm): the error's Display
14567        // surfaces the offending `:nome`, the offending `:caminho`
14568        // verbatim, the offending byte's hex form, and names the
14569        // shell-history-substitution / RFC-3986-'unwise' / regex-
14570        // negation footgun explicitly so a `feira lint` run can render
14571        // the diagnostic without re-parsing.
14572        let d = dep_with_fonte(DepSource::Path {
14573            caminho: "../foo^bad^good".into(),
14574        });
14575        let rendered = d.validate().unwrap_err().to_string();
14576        assert!(
14577            rendered.contains("caixa-teia"),
14578            "diagnostic must name the offending dep: {rendered}",
14579        );
14580        assert!(
14581            rendered.contains("../foo^bad^good"),
14582            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
14583        );
14584        assert!(
14585            rendered.contains("0x5e") || rendered.contains("0x5E"),
14586            "diagnostic must surface the offending byte hex: {rendered:?}",
14587        );
14588        assert!(
14589            rendered.contains("history-substitution") || rendered.contains("history substitution"),
14590            "diagnostic must name the shell-history-substitution footgun: {rendered:?}",
14591        );
14592        assert!(
14593            rendered.contains("unwise"),
14594            "diagnostic must reference the RFC-3986 'unwise' set vocabulary: {rendered:?}",
14595        );
14596    }
14597
14598    #[test]
14599    fn fonte_repo_empty_fires_before_pin_missing() {
14600        // Order pin: empty `:repo` is the more self-locating diagnostic
14601        // (every git source needs a repo; the pin discussion is
14602        // secondary), so it fires before the pin-missing arm even when
14603        // both are violated. Mirrors the
14604        // `nome_empty_takes_precedence_over_versao_invalid` ordering
14605        // discipline on the per-entry layer.
14606        let d = dep_with_fonte(DepSource::Git {
14607            repo: String::new(),
14608            tag: None,
14609            rev: None,
14610            branch: None,
14611        });
14612        let err = d.validate().unwrap_err();
14613        assert!(
14614            matches!(err, DepError::FonteRepoEmpty { .. }),
14615            "got {err:?}"
14616        );
14617    }
14618
14619    #[test]
14620    fn fonte_pin_missing_fires_before_pin_empty() {
14621        // Order pin: a fully-None pin set is structurally distinct from
14622        // a Some(empty) pin — the first surfaces as FontePinMissing
14623        // (no axis chosen), the second as FontePinEmpty (axis chosen
14624        // but value blank). Pin the disjoint relationship so a future
14625        // unification collapses to one variant only as a structural
14626        // decision.
14627        let d = dep_with_fonte(DepSource::Git {
14628            repo: "github:pleme-io/caixa-teia".into(),
14629            tag: None,
14630            rev: None,
14631            branch: None,
14632        });
14633        assert!(matches!(
14634            d.validate().unwrap_err(),
14635            DepError::FontePinMissing { .. }
14636        ));
14637    }
14638
14639    #[test]
14640    fn nome_empty_takes_precedence_over_fonte_invalid() {
14641        // Order pin: a per-entry diagnostic without a non-empty :nome
14642        // can't be self-locating, so :nome "" fires first even when
14643        // :fonte is also malformed. Mirrors
14644        // `nome_empty_takes_precedence_over_versao_invalid` on the
14645        // adjacent axis.
14646        let mut d = dep_with_fonte(DepSource::Git {
14647            repo: String::new(),
14648            tag: None,
14649            rev: None,
14650            branch: None,
14651        });
14652        d.nome = String::new();
14653        assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
14654    }
14655
14656    #[test]
14657    fn versao_invalid_takes_precedence_over_fonte_invalid() {
14658        // Order pin: the :versao parse-side diagnostic is narrower than
14659        // the :fonte shape diagnostic — a malformed :versao always names
14660        // the parser's reason, which is more actionable than the
14661        // :fonte gate's "the pins are wrong" wording. Pin the ordering
14662        // so a re-ordering surfaces here.
14663        let mut d = dep_with_fonte(DepSource::Git {
14664            repo: String::new(),
14665            tag: None,
14666            rev: None,
14667            branch: None,
14668        });
14669        d.versao = "v0.1".into();
14670        let err = d.validate().unwrap_err();
14671        assert!(
14672            matches!(err, DepError::VersaoInvalid { ref nome, .. } if nome == "caixa-teia"),
14673            "got {err:?}"
14674        );
14675    }
14676
14677    #[test]
14678    fn fonte_invalid_diagnostic_carries_offending_nome() {
14679        // The diagnostic-shape pin: every :fonte error variant names
14680        // the offending dep's :nome verbatim, so the author can grep
14681        // caixa.lisp for the `:nome "<n>"` block and fix it in one
14682        // edit. Cover all seven variants so a future variant addition
14683        // forces a parallel diagnostic-shape decision.
14684        for (case, fonte) in [
14685            (
14686                "repo-empty",
14687                DepSource::Git {
14688                    repo: String::new(),
14689                    tag: Some("v1".into()),
14690                    rev: None,
14691                    branch: None,
14692                },
14693            ),
14694            (
14695                "repo-shape",
14696                DepSource::Git {
14697                    repo: "github:p/x ".into(),
14698                    tag: Some("v1".into()),
14699                    rev: None,
14700                    branch: None,
14701                },
14702            ),
14703            (
14704                "pin-missing",
14705                DepSource::Git {
14706                    repo: "github:p/x".into(),
14707                    tag: None,
14708                    rev: None,
14709                    branch: None,
14710                },
14711            ),
14712            (
14713                "pin-ambiguous",
14714                DepSource::Git {
14715                    repo: "github:p/x".into(),
14716                    tag: Some("v1".into()),
14717                    rev: None,
14718                    branch: Some("main".into()),
14719                },
14720            ),
14721            (
14722                "pin-empty",
14723                DepSource::Git {
14724                    repo: "github:p/x".into(),
14725                    tag: Some(String::new()),
14726                    rev: None,
14727                    branch: None,
14728                },
14729            ),
14730            (
14731                "caminho-empty",
14732                DepSource::Path {
14733                    caminho: String::new(),
14734                },
14735            ),
14736            (
14737                "caminho-absolute",
14738                DepSource::Path {
14739                    caminho: "/home/me/work/caixa-teia".into(),
14740                },
14741            ),
14742        ] {
14743            let d = dep_with_fonte(fonte);
14744            let msg = d
14745                .validate()
14746                .expect_err(&format!("{case}: expected fonte error"))
14747                .to_string();
14748            assert!(
14749                msg.contains("\"caixa-teia\""),
14750                "{case}: diagnostic must quote the offending :nome verbatim, got {msg:?}"
14751            );
14752        }
14753    }
14754
14755    // -- :tag / :branch value-shape gate ----------------------------------
14756
14757    #[test]
14758    fn validate_rejects_git_fonte_with_tag_carrying_trailing_space() {
14759        // The canonical paste-from-doc footgun on `:tag` — author
14760        // copies `"v0.1.0 "` (trailing space) out of a release-notes
14761        // paragraph. Until this gate landed the empty-pin arm passed
14762        // (the string isn't empty), the resolver issued
14763        // `git fetch <remote> tag 'v0.1.0 '`, and the failure
14764        // surfaced at clone time with a quoting-confused git error
14765        // far from the source caixa.lisp. The new gate moves the
14766        // check to caixa-build time and names the offending dep +
14767        // pin + value verbatim.
14768        let d = dep_with_fonte(DepSource::Git {
14769            repo: "github:pleme-io/caixa-teia".into(),
14770            tag: Some("v0.1.0 ".into()),
14771            rev: None,
14772            branch: None,
14773        });
14774        let err = d.validate().unwrap_err();
14775        let DepError::FontePinShape {
14776            nome,
14777            pin,
14778            value,
14779            reason,
14780        } = err
14781        else {
14782            panic!("expected FontePinShape, got other variant");
14783        };
14784        assert_eq!(nome, "caixa-teia");
14785        assert_eq!(pin, ":tag");
14786        assert_eq!(value, "v0.1.0 ");
14787        assert!(
14788            reason.contains("whitespace"),
14789            "reason must surface the whitespace arm, got {reason:?}"
14790        );
14791    }
14792
14793    #[test]
14794    fn validate_rejects_git_fonte_with_tag_carrying_lock_suffix() {
14795        // The `.lock` suffix is git's atomic-rename guard for
14796        // in-flight ref updates — a refname ending in `.lock` is
14797        // unwritable on disk. Pinned separately from the whitespace
14798        // arm so a future relaxation that admits one but not the
14799        // other surfaces here.
14800        let d = dep_with_fonte(DepSource::Git {
14801            repo: "github:pleme-io/caixa-teia".into(),
14802            tag: Some("v0.1.0.lock".into()),
14803            rev: None,
14804            branch: None,
14805        });
14806        let err = d.validate().unwrap_err();
14807        let DepError::FontePinShape {
14808            pin, value, reason, ..
14809        } = err
14810        else {
14811            panic!("expected FontePinShape, got other variant");
14812        };
14813        assert_eq!(pin, ":tag");
14814        assert_eq!(value, "v0.1.0.lock");
14815        assert!(
14816            reason.contains(".lock"),
14817            "reason must surface the .lock arm, got {reason:?}"
14818        );
14819    }
14820
14821    #[test]
14822    fn validate_rejects_git_fonte_with_branch_carrying_embedded_space() {
14823        // The canonical "branch name with spaces" footgun (`feature
14824        // foo`, `release branch`) — git's refname parser rejects raw
14825        // whitespace, and the failure surfaces at `git checkout
14826        // 'feature foo'` time with a quoting-confused error far from
14827        // the source caixa.lisp. Pinned on the `:branch` axis so the
14828        // gate-applies-to-both-:tag-and-:branch contract is a build-
14829        // error to relax.
14830        let d = dep_with_fonte(DepSource::Git {
14831            repo: "github:pleme-io/caixa-teia".into(),
14832            tag: None,
14833            rev: None,
14834            branch: Some("feature/foo bar".into()),
14835        });
14836        let err = d.validate().unwrap_err();
14837        let DepError::FontePinShape {
14838            pin, value, reason, ..
14839        } = err
14840        else {
14841            panic!("expected FontePinShape, got other variant");
14842        };
14843        assert_eq!(pin, ":branch");
14844        assert_eq!(value, "feature/foo bar");
14845        assert!(
14846            reason.contains("whitespace"),
14847            "reason must surface the whitespace arm, got {reason:?}"
14848        );
14849    }
14850
14851    #[test]
14852    fn validate_rejects_git_fonte_with_branch_carrying_qualified_prefix() {
14853        // The `refs/heads/main` shape — the canonical "I copied the
14854        // fully-qualified ref out of `git show-ref` instead of the
14855        // leaf" footgun. The caixa-resolver prepends `refs/heads/`
14856        // at clone time, so this resolves to a literal ref named
14857        // `refs/heads/refs/heads/main` on disk; the silent double-
14858        // prefix is the load-bearing reason to gate at validate.
14859        // The diagnostic must enumerate the leaf the author probably
14860        // meant (`"main"`) so the fix is one edit.
14861        let d = dep_with_fonte(DepSource::Git {
14862            repo: "github:pleme-io/caixa-teia".into(),
14863            tag: None,
14864            rev: None,
14865            branch: Some("refs/heads/main".into()),
14866        });
14867        let err = d.validate().unwrap_err();
14868        let DepError::FontePinShape {
14869            pin, value, reason, ..
14870        } = err
14871        else {
14872            panic!("expected FontePinShape, got other variant");
14873        };
14874        assert_eq!(pin, ":branch");
14875        assert_eq!(value, "refs/heads/main");
14876        assert!(
14877            reason.contains("fully-qualified"),
14878            "reason must surface the qualified-prefix arm, got {reason:?}"
14879        );
14880        assert!(
14881            reason.contains("\"main\""),
14882            "reason must quote the leaf the author probably meant, got {reason:?}"
14883        );
14884    }
14885
14886    #[test]
14887    fn validate_rejects_git_fonte_with_tag_carrying_qualified_prefix() {
14888        // Sibling arm of the qualified-prefix gate on the `:tag`
14889        // axis (`refs/tags/v0.1.0` — same `git show-ref` output-leak
14890        // footgun). Pinned separately so a future relaxation that
14891        // only catches the `:branch` arm surfaces here.
14892        let d = dep_with_fonte(DepSource::Git {
14893            repo: "github:pleme-io/caixa-teia".into(),
14894            tag: Some("refs/tags/v0.1.0".into()),
14895            rev: None,
14896            branch: None,
14897        });
14898        let err = d.validate().unwrap_err();
14899        let DepError::FontePinShape {
14900            pin, value, reason, ..
14901        } = err
14902        else {
14903            panic!("expected FontePinShape, got other variant");
14904        };
14905        assert_eq!(pin, ":tag");
14906        assert_eq!(value, "refs/tags/v0.1.0");
14907        assert!(
14908            reason.contains("fully-qualified"),
14909            "reason must surface the qualified-prefix arm, got {reason:?}"
14910        );
14911        assert!(
14912            reason.contains("\"v0.1.0\""),
14913            "reason must quote the leaf the author probably meant, got {reason:?}"
14914        );
14915    }
14916
14917    #[test]
14918    fn validate_rejects_git_fonte_with_branch_named_at() {
14919        // The bare `@` is git's alias for `HEAD`; a `:branch "@"` is
14920        // unsourceable. Pinned so a future relaxation that admits
14921        // any single-character refname surfaces here.
14922        let d = dep_with_fonte(DepSource::Git {
14923            repo: "github:pleme-io/caixa-teia".into(),
14924            tag: None,
14925            rev: None,
14926            branch: Some("@".into()),
14927        });
14928        let err = d.validate().unwrap_err();
14929        let DepError::FontePinShape { pin, value, .. } = err else {
14930            panic!("expected FontePinShape, got other variant");
14931        };
14932        assert_eq!(pin, ":branch");
14933        assert_eq!(value, "@");
14934    }
14935
14936    #[test]
14937    fn validate_rejects_git_fonte_with_tag_carrying_double_dot() {
14938        // Git's `<rev1>..<rev2>` range grammar reserves `..` —
14939        // a `:tag "../escape"` (path-traversal-shaped slug) silently
14940        // passes parse and surfaces as a refname-parse error or, on
14941        // older git, a literal `../escape` checkout that escapes the
14942        // refs/ directory tree. Pinned separately from the
14943        // qualified-prefix arm so a future relaxation that catches
14944        // one but not the other surfaces here.
14945        let d = dep_with_fonte(DepSource::Git {
14946            repo: "github:pleme-io/caixa-teia".into(),
14947            tag: Some("../escape".into()),
14948            rev: None,
14949            branch: None,
14950        });
14951        let err = d.validate().unwrap_err();
14952        let DepError::FontePinShape { pin, value, .. } = err else {
14953            panic!("expected FontePinShape, got other variant");
14954        };
14955        assert_eq!(pin, ":tag");
14956        assert_eq!(value, "../escape");
14957    }
14958
14959    #[test]
14960    fn validate_accepts_git_fonte_with_hierarchical_branch() {
14961        // The positive-control pin: hierarchical refnames with one or
14962        // more `/` separators (the `feature/foo` / `user/jdoe/feat`
14963        // canonical idiom) round-trip through the gate. Pinned
14964        // separately from the leaf-`"main"` positive control so a
14965        // future tightening that rejects all multi-component refnames
14966        // surfaces here.
14967        let d = dep_with_fonte(DepSource::Git {
14968            repo: "github:pleme-io/caixa-teia".into(),
14969            tag: None,
14970            rev: None,
14971            branch: Some("feature/checkout-rewrite".into()),
14972        });
14973        d.validate().unwrap();
14974    }
14975
14976    #[test]
14977    fn validate_accepts_git_fonte_with_prerelease_tag() {
14978        // The positive-control pin: semver pre-release shape
14979        // (`v0.1.0-alpha.1`) — the in-component dot is allowed
14980        // (only consecutive `..` and trailing `.` are rejected), the
14981        // mid-component hyphen is allowed. Pinned separately from
14982        // the bare-`"v0.1.0"` positive control so a future tightening
14983        // that rejects pre-release tags surfaces here.
14984        let d = dep_with_fonte(DepSource::Git {
14985            repo: "github:pleme-io/caixa-teia".into(),
14986            tag: Some("v0.1.0-alpha.1".into()),
14987            rev: None,
14988            branch: None,
14989        });
14990        d.validate().unwrap();
14991    }
14992
14993    #[test]
14994    fn validate_rejects_git_fonte_with_rev_carrying_refname_unfriendly_value() {
14995        // The `:rev` axis is routed through `crate::render::is_git_oid`
14996        // (a SHA's character set is `[0-9a-f]`, not a refname's), so a
14997        // value with refname-shape punctuation (here, a `:` mid-string
14998        // — would be a refname violation under `is_git_ref_name` too)
14999        // is rejected at the OID-shape gate. The two predicates
15000        // partition the `:fonte` pin axes structurally: an `:rev` value
15001        // that's a valid refname (`:rev "main"`, `:rev "v0.1.0"`) is
15002        // *still* rejected here because every refname character outside
15003        // `[0-9a-f]` fails the OID gate. Same shape as
15004        // `fonte_pin_shape_diagnostic_carries_offending_nome_pin_value`
15005        // on the refname-shaped axes — the diagnostic names the
15006        // offending dep + pin + value verbatim. The flip-from-accept
15007        // case the prior `:tag`/`:branch` gate left as a "future axis"
15008        // (e70d213) — now landed.
15009        let d = dep_with_fonte(DepSource::Git {
15010            repo: "github:pleme-io/caixa-teia".into(),
15011            tag: None,
15012            rev: Some("c0ffee:notarefname".into()),
15013            branch: None,
15014        });
15015        let err = d.validate().unwrap_err();
15016        let DepError::FontePinShape {
15017            nome,
15018            pin,
15019            value,
15020            reason,
15021        } = err
15022        else {
15023            panic!("expected FontePinShape, got other variant");
15024        };
15025        assert_eq!(nome, "caixa-teia");
15026        assert_eq!(pin, ":rev");
15027        assert_eq!(value, "c0ffee:notarefname");
15028        assert!(
15029            !reason.is_empty(),
15030            "FontePinShape `reason` must carry the predicate's wording verbatim"
15031        );
15032    }
15033
15034    #[test]
15035    fn validate_accepts_git_fonte_with_rev_full_sha1() {
15036        // The positive-control pin on the SHA-1 OID width: exactly 40
15037        // lowercase hex characters — the canonical `git rev-parse HEAD`
15038        // emission on a SHA-1-hashed repository (the default on every
15039        // pre-2.42 git and the canonical pleme-io substrate hash).
15040        // Pinned separately from the SHA-256 positive control so a
15041        // future tightening that only admits one width surfaces here.
15042        let d = dep_with_fonte(DepSource::Git {
15043            repo: "github:pleme-io/caixa-teia".into(),
15044            tag: None,
15045            rev: Some("0123456789abcdef0123456789abcdef01234567".into()),
15046            branch: None,
15047        });
15048        d.validate().unwrap();
15049    }
15050
15051    #[test]
15052    fn validate_accepts_git_fonte_with_rev_full_sha256() {
15053        // The positive-control pin on the SHA-256 OID width: exactly
15054        // 64 lowercase hex characters — `git`'s
15055        // `extensions.objectFormat = sha256` emission (GA since Git
15056        // 2.42 / Oct 2023). The substrate admits either canonical
15057        // width so an `:rev` authored against a SHA-256-hashed
15058        // upstream round-trips through the gate without per-repo
15059        // configuration. Pinned separately from the SHA-1 positive
15060        // control so a future tightening that drops one width surfaces
15061        // here as a structural decision.
15062        let d = dep_with_fonte(DepSource::Git {
15063            repo: "github:pleme-io/caixa-teia".into(),
15064            tag: None,
15065            rev: Some("0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef".into()),
15066            branch: None,
15067        });
15068        d.validate().unwrap();
15069    }
15070
15071    #[test]
15072    fn validate_rejects_git_fonte_with_rev_abbreviated_prefix() {
15073        // The canonical `git log --short` / `git rev-parse --short HEAD`
15074        // paste-from-release-notes footgun: a 7-char prefix (git's
15075        // default `core.abbrev`) silently passes string emptiness
15076        // checks and resolves to one commit today, but becomes ambiguous
15077        // tomorrow as the repo grows. Until this gate landed the empty-
15078        // pin arm passed (the string isn't empty) and the resolver
15079        // accepted the prefix through git's separate prefix-lookup pass
15080        // — defeating the reproducibility contract `:rev` carries vs.
15081        // `:tag` / `:branch`. The new gate moves the check to caixa-
15082        // build time and names the offending dep + pin + value verbatim.
15083        let d = dep_with_fonte(DepSource::Git {
15084            repo: "github:pleme-io/caixa-teia".into(),
15085            tag: None,
15086            rev: Some("c0ffee0".into()),
15087            branch: None,
15088        });
15089        let err = d.validate().unwrap_err();
15090        let DepError::FontePinShape {
15091            pin, value, reason, ..
15092        } = err
15093        else {
15094            panic!("expected FontePinShape, got other variant");
15095        };
15096        assert_eq!(pin, ":rev");
15097        assert_eq!(value, "c0ffee0");
15098        assert!(
15099            reason.contains("abbreviated") || reason.contains("ambiguous"),
15100            "reason must surface the abbreviation arm, got {reason:?}"
15101        );
15102    }
15103
15104    #[test]
15105    fn validate_rejects_git_fonte_with_rev_uppercase_hex() {
15106        // The canonical "I pasted the SHA in uppercase" footgun: `git
15107        // porcelain` emits OIDs lowercase exclusively, so an uppercase-
15108        // bearing `:rev` round-trips inconsistently across the
15109        // resolver's `git fetch <remote> <:rev>` ↔ `git rev-parse HEAD`
15110        // equality-check pipeline and fails the lacre's content-
15111        // addressing probe with a confusing case-only diff. Pinned
15112        // separately from the non-hex arm so a future relaxation that
15113        // admits one but not the other surfaces here.
15114        let d = dep_with_fonte(DepSource::Git {
15115            repo: "github:pleme-io/caixa-teia".into(),
15116            tag: None,
15117            rev: Some("DEADBEEFCAFEBABE0123456789ABCDEF01234567".into()),
15118            branch: None,
15119        });
15120        let err = d.validate().unwrap_err();
15121        let DepError::FontePinShape {
15122            pin, value, reason, ..
15123        } = err
15124        else {
15125            panic!("expected FontePinShape, got other variant");
15126        };
15127        assert_eq!(pin, ":rev");
15128        assert_eq!(value, "DEADBEEFCAFEBABE0123456789ABCDEF01234567");
15129        assert!(
15130            reason.contains("uppercase"),
15131            "reason must surface the uppercase arm, got {reason:?}"
15132        );
15133    }
15134
15135    #[test]
15136    fn validate_rejects_git_fonte_with_rev_refname_value() {
15137        // The cross-axis mis-slot footgun: `:rev "main"` — the author
15138        // conflated `:rev` (hex commit ID, immutable) and `:branch`
15139        // (mutable ref pointing at whatever HEAD is today). Until this
15140        // gate landed the resolver silently dispatched on the value
15141        // shape ("`main` doesn't look like a SHA, fall back to
15142        // refname"), defeating the `:rev` reproducibility contract.
15143        // The new gate rejects every non-hex value on the `:rev` axis,
15144        // so the `:rev`/`:branch` boundary is structurally enforced —
15145        // a refname in the `:rev` slot is a build error, not a
15146        // resolver-time silent reinterpretation.
15147        let d = dep_with_fonte(DepSource::Git {
15148            repo: "github:pleme-io/caixa-teia".into(),
15149            tag: None,
15150            rev: Some("main".into()),
15151            branch: None,
15152        });
15153        let err = d.validate().unwrap_err();
15154        let DepError::FontePinShape {
15155            pin, value, reason, ..
15156        } = err
15157        else {
15158            panic!("expected FontePinShape, got other variant");
15159        };
15160        assert_eq!(pin, ":rev");
15161        assert_eq!(value, "main");
15162        // 4 chars `main` fails the length arm before the character arm,
15163        // so the diagnostic surfaces the abbreviation wording (same
15164        // path the `c0ffee0` 7-char fixture lands on); the structural
15165        // assertion is just that the `:rev "main"` value is rejected.
15166        assert!(
15167            !reason.is_empty(),
15168            "FontePinShape reason must be non-empty for refname-shaped :rev"
15169        );
15170    }
15171
15172    #[test]
15173    fn validate_rejects_git_fonte_with_rev_tag_shaped_value() {
15174        // Sibling cross-axis mis-slot: `:rev "v0.1.0"` — the author
15175        // conflated `:rev` and `:tag`. Pinned separately from the
15176        // `:rev "main"` (`:branch` mis-slot) arm so a future relaxation
15177        // that catches one but not the other surfaces here. The
15178        // length arm fires first (6 chars ≠ 40 ≠ 64); the structural
15179        // assertion is just that the cross-axis mis-slot is a build
15180        // error, regardless of which sub-arm surfaces the diagnostic
15181        // (`is_git_oid` rejects at the first violation; longer
15182        // tag-shape values would hit the non-hex arm instead).
15183        let d = dep_with_fonte(DepSource::Git {
15184            repo: "github:pleme-io/caixa-teia".into(),
15185            tag: None,
15186            rev: Some("v0.1.0".into()),
15187            branch: None,
15188        });
15189        let err = d.validate().unwrap_err();
15190        let DepError::FontePinShape {
15191            pin, value, reason, ..
15192        } = err
15193        else {
15194            panic!("expected FontePinShape, got other variant");
15195        };
15196        assert_eq!(pin, ":rev");
15197        assert_eq!(value, "v0.1.0");
15198        assert!(
15199            !reason.is_empty(),
15200            "FontePinShape reason must be non-empty for tag-shaped :rev"
15201        );
15202    }
15203
15204    #[test]
15205    fn validate_rejects_git_fonte_with_rev_too_long() {
15206        // Boundary case on the upper end: 41 hex chars — one past the
15207        // SHA-1 width, well below the SHA-256 width. Pin so a future
15208        // relaxation that admits "long enough to be a SHA" without
15209        // matching either canonical width surfaces here. The diagnostic
15210        // names the offending length verbatim so the author's grep
15211        // target is unambiguous (either trim one char or paste the
15212        // full SHA-256).
15213        let too_long: String = "0".repeat(41);
15214        let d = dep_with_fonte(DepSource::Git {
15215            repo: "github:pleme-io/caixa-teia".into(),
15216            tag: None,
15217            rev: Some(too_long.clone()),
15218            branch: None,
15219        });
15220        let err = d.validate().unwrap_err();
15221        let DepError::FontePinShape {
15222            pin, value, reason, ..
15223        } = err
15224        else {
15225            panic!("expected FontePinShape, got other variant");
15226        };
15227        assert_eq!(pin, ":rev");
15228        assert_eq!(value, too_long);
15229        assert!(
15230            reason.contains("41"),
15231            "reason must surface the offending length verbatim, got {reason:?}"
15232        );
15233    }
15234
15235    #[test]
15236    fn validate_rejects_git_fonte_with_rev_carrying_whitespace() {
15237        // The canonical paste-from-doc footgun on `:rev` — author
15238        // copies `"deadbeefcafe…0123 "` (trailing space) out of a
15239        // commit-message paragraph. Until this gate landed the empty-
15240        // pin arm passed (the string isn't empty), the resolver issued
15241        // `git fetch <remote> 'deadbeef… '` and the failure surfaced at
15242        // clone time with a quoting-confused git error far from the
15243        // source caixa.lisp. The new gate moves the check to caixa-
15244        // build time. Length is 41 (40 hex + space) so the length arm
15245        // fires first — pinned separately from the pure-length arm to
15246        // ensure the diagnostic surfaces *some* parser wording, not
15247        // silently pass through.
15248        let with_space = "0123456789abcdef0123456789abcdef01234567 ".to_string();
15249        let d = dep_with_fonte(DepSource::Git {
15250            repo: "github:pleme-io/caixa-teia".into(),
15251            tag: None,
15252            rev: Some(with_space.clone()),
15253            branch: None,
15254        });
15255        let err = d.validate().unwrap_err();
15256        let DepError::FontePinShape {
15257            pin, value, reason, ..
15258        } = err
15259        else {
15260            panic!("expected FontePinShape, got other variant");
15261        };
15262        assert_eq!(pin, ":rev");
15263        assert_eq!(value, with_space);
15264        assert!(
15265            !reason.is_empty(),
15266            "FontePinShape reason must be non-empty for whitespace-bearing :rev"
15267        );
15268    }
15269
15270    #[test]
15271    fn fonte_pin_shape_diagnostic_carries_offending_nome_pin_value_for_rev() {
15272        // Diagnostic-shape pin on the `:rev` axis: every FontePinShape
15273        // variant on this axis names the offending dep's `:nome` + the
15274        // `:rev` axis + the offending value verbatim, so the author's
15275        // grep target is the literal `:rev "<value>"` block in
15276        // caixa.lisp. Sibling of the `fonte_pin_shape_diagnostic_
15277        // carries_offending_nome_pin_value` test on the refname-shaped
15278        // (`:tag` / `:branch`) axes.
15279        let d = dep_with_fonte(DepSource::Git {
15280            repo: "github:p/x".into(),
15281            tag: None,
15282            rev: Some("not-a-sha".into()),
15283            branch: None,
15284        });
15285        let msg = d
15286            .validate()
15287            .expect_err(":rev: expected FontePinShape")
15288            .to_string();
15289        assert!(
15290            msg.contains("\"caixa-teia\""),
15291            ":rev: diagnostic must quote the offending :nome verbatim, got {msg:?}"
15292        );
15293        assert!(
15294            msg.contains(":rev"),
15295            ":rev: diagnostic must name the offending pin axis, got {msg:?}"
15296        );
15297        assert!(
15298            msg.contains("not-a-sha"),
15299            ":rev: diagnostic must quote the offending value verbatim, got {msg:?}"
15300        );
15301    }
15302
15303    #[test]
15304    fn fonte_pin_empty_fires_before_pin_shape() {
15305        // Order pin: a `Some("")` `:tag` is the more self-locating
15306        // diagnostic (the author chose an axis but left it blank;
15307        // grep is unambiguous), so it fires before the shape gate
15308        // even when both arms would match. Pinned so a future
15309        // reordering surfaces here. Mirrors the
15310        // `fonte_repo_empty_fires_before_pin_missing` ordering
15311        // discipline on the peer per-axis arms.
15312        let d = dep_with_fonte(DepSource::Git {
15313            repo: "github:pleme-io/caixa-teia".into(),
15314            tag: Some(String::new()),
15315            rev: None,
15316            branch: None,
15317        });
15318        assert!(matches!(
15319            d.validate().unwrap_err(),
15320            DepError::FontePinEmpty { ref pin, .. } if pin == ":tag"
15321        ));
15322    }
15323
15324    #[test]
15325    fn fonte_pin_shape_fires_after_repo_empty() {
15326        // Order pin: `:repo ""` is the more self-locating axis
15327        // (every git source needs a repo; the per-pin shape gate is
15328        // secondary), so the repo-empty arm fires before the
15329        // per-pin shape arm even when both are violated. Pinned so
15330        // a future reordering surfaces here. Mirrors
15331        // `fonte_repo_empty_fires_before_pin_missing` on the
15332        // adjacent axis pair.
15333        let d = dep_with_fonte(DepSource::Git {
15334            repo: String::new(),
15335            tag: Some("v0.1.0 ".into()),
15336            rev: None,
15337            branch: None,
15338        });
15339        assert!(matches!(
15340            d.validate().unwrap_err(),
15341            DepError::FonteRepoEmpty { .. }
15342        ));
15343    }
15344
15345    #[test]
15346    fn fonte_pin_shape_diagnostic_carries_offending_nome_pin_value() {
15347        // Diagnostic-shape pin across both refname-shaped axes
15348        // (`:tag` + `:branch`): every `FontePinShape` variant names
15349        // the offending dep's `:nome` + the offending pin axis + the
15350        // offending value verbatim, so the author's grep target is
15351        // unambiguous (the literal `:tag "<value>"` / `:branch
15352        // "<value>"` lands in caixa.lisp with quotes). Cover both
15353        // pin axes so a future variant addition forces a parallel
15354        // diagnostic-shape decision.
15355        for (pin_label, fonte) in [
15356            (
15357                ":tag",
15358                DepSource::Git {
15359                    repo: "github:p/x".into(),
15360                    tag: Some("v0.1.0~1".into()),
15361                    rev: None,
15362                    branch: None,
15363                },
15364            ),
15365            (
15366                ":branch",
15367                DepSource::Git {
15368                    repo: "github:p/x".into(),
15369                    tag: None,
15370                    rev: None,
15371                    branch: Some("feature/foo*".into()),
15372                },
15373            ),
15374        ] {
15375            let d = dep_with_fonte(fonte);
15376            let msg = d
15377                .validate()
15378                .expect_err(&format!("{pin_label}: expected FontePinShape"))
15379                .to_string();
15380            assert!(
15381                msg.contains("\"caixa-teia\""),
15382                "{pin_label}: diagnostic must quote the offending :nome verbatim, got {msg:?}"
15383            );
15384            assert!(
15385                msg.contains(pin_label),
15386                "{pin_label}: diagnostic must name the offending pin axis, got {msg:?}"
15387            );
15388        }
15389    }
15390
15391    #[test]
15392    fn git_source_json_round_trip() {
15393        let src = DepSource::Git {
15394            repo: "github:pleme-io/caixa-teia".into(),
15395            tag: Some("v0.1.0".into()),
15396            rev: None,
15397            branch: None,
15398        };
15399        let s = serde_json::to_string(&src).unwrap();
15400        assert!(s.contains(&format!(
15401            r#""{tipo}":"{git}""#,
15402            tipo = crate::render::DEP_SOURCE_KEY_TIPO,
15403            git = crate::render::DEP_SOURCE_TIPO_GIT,
15404        )));
15405        assert!(s.contains(r#""repo":"github:pleme-io/caixa-teia""#));
15406        assert!(s.contains(r#""tag":"v0.1.0""#));
15407        assert!(!s.contains("rev"));
15408        assert!(!s.contains("branch"));
15409        let round: DepSource = serde_json::from_str(&s).unwrap();
15410        assert_eq!(round, src);
15411    }
15412
15413    // ── DEP_SOURCE_{KEY_TIPO,TIPO_GIT,TIPO_PATH} drift-detection ────────
15414    //
15415    // The `#[serde(tag = "tipo", rename_all = "lowercase")]` derive
15416    // attribute on [`DepSource`] pins three load-bearing byte-sequences
15417    // that flow into every serialized `Dep.fonte` block: the outer
15418    // discriminator-key `"tipo"` the `tag = "tipo"` attribute names, and
15419    // the two admitted variant-tag values `"git"` / `"path"` the
15420    // `rename_all = "lowercase"` attribute pins as the discriminator's
15421    // closed-set arms. The three pin tests below round-trip a
15422    // fully-populated variant of each arm through
15423    // [`serde_json::to_value`] and assert each canonical byte-sequence
15424    // appears at its axis — pins a hypothetical future
15425    // `tag = "type"` / `tag = "source_type"` typo, a `rename_all`
15426    // rebrand (`"UPPERCASE"` / `"snake_case"` / `"kebab-case"`), or a
15427    // Rust-side variant rename (`Git` → `Repository`, `Path` → `Local`)
15428    // at build time rather than at fetch time when the resolver's
15429    // `Dep.fonte` dispatch silently fails to match on the drifted
15430    // discriminator. Same "serialize-and-check" discipline the peer
15431    // `M2_LIMITS_KEY_*`, `M2_BEHAVIOR_KEY_ON_*`, `SUPERVISOR_KEY_*`,
15432    // and `MEMBRO_KEY_*` drift-detection pins carry — extended here
15433    // to the last `#[serde(tag = ..., rename_all = ...)]` discriminator
15434    // family in caixa-core lacking a lifted peer.
15435
15436    #[test]
15437    fn dep_source_git_serde_keys_match_lifted_dep_source_key_consts() {
15438        // Fail-before-pass-after: a future `tag = "type"` at the derive
15439        // attribute would serialize under `"type":"git"`, and this test
15440        // would trip because `"tipo"` no longer appears at the emitted
15441        // discriminator key. A future `rename_all = "kebab-case"` /
15442        // `"snake_case"` (both no-ops on `Git` since it lacks internal
15443        // word boundaries) is caught by the sibling
15444        // `dep_source_path_serde_keys_match_lifted_dep_source_key_consts`
15445        // pin below (Path has no internal boundary either but the pair
15446        // catches any per-arm inconsistency). A future variant rename
15447        // `Git` → `Repository` would emit `"tipo":"repository"` and
15448        // trip this pin.
15449        let src = DepSource::Git {
15450            repo: "github:pleme-io/caixa-teia".into(),
15451            tag: Some("v0.1.0".into()),
15452            rev: None,
15453            branch: None,
15454        };
15455        let json = serde_json::to_value(&src).unwrap();
15456        let obj = json.as_object().expect("Git serializes as a JSON object");
15457        assert_eq!(
15458            obj.get(crate::render::DEP_SOURCE_KEY_TIPO)
15459                .and_then(serde_json::Value::as_str),
15460            Some(crate::render::DEP_SOURCE_TIPO_GIT),
15461            "DepSource::Git must serialize the tipo discriminator at DEP_SOURCE_KEY_TIPO \
15462             with value DEP_SOURCE_TIPO_GIT — attribute drift or variant rename \
15463             detected in {json}"
15464        );
15465    }
15466
15467    #[test]
15468    fn dep_source_path_serde_keys_match_lifted_dep_source_key_consts() {
15469        // Fail-before-pass-after: a future variant rename `Path` →
15470        // `Local` / `Filesystem` would emit `"tipo":"local"` and trip
15471        // this pin. A per-consumer disambiguation as the `defcaixa`
15472        // macro stabilizes ("caminho" → "path" for English-uniformity)
15473        // is scoped to the inner field key, not the discriminator; this
15474        // pin is orthogonal to that and catches only the outer
15475        // discriminator drift.
15476        let src = DepSource::Path {
15477            caminho: "../caixa-teia".into(),
15478        };
15479        let json = serde_json::to_value(&src).unwrap();
15480        let obj = json.as_object().expect("Path serializes as a JSON object");
15481        assert_eq!(
15482            obj.get(crate::render::DEP_SOURCE_KEY_TIPO)
15483                .and_then(serde_json::Value::as_str),
15484            Some(crate::render::DEP_SOURCE_TIPO_PATH),
15485            "DepSource::Path must serialize the tipo discriminator at DEP_SOURCE_KEY_TIPO \
15486             with value DEP_SOURCE_TIPO_PATH — attribute drift or variant rename \
15487             detected in {json}"
15488        );
15489    }
15490
15491    #[test]
15492    fn dep_source_key_consts_are_pairwise_distinct() {
15493        // Cross-axis collapse detector: a hypothetical future edit that
15494        // accidentally set two of the three consts to the same byte
15495        // (`DEP_SOURCE_TIPO_GIT = "path"` typo matching a peer arm) would
15496        // pass every per-arm serialize pin above but silently collapse
15497        // the discriminator's closed-set arms onto one another; this pin
15498        // catches the collapse at build time.
15499        assert_ne!(
15500            crate::render::DEP_SOURCE_KEY_TIPO,
15501            crate::render::DEP_SOURCE_TIPO_GIT,
15502        );
15503        assert_ne!(
15504            crate::render::DEP_SOURCE_KEY_TIPO,
15505            crate::render::DEP_SOURCE_TIPO_PATH,
15506        );
15507        assert_ne!(
15508            crate::render::DEP_SOURCE_TIPO_GIT,
15509            crate::render::DEP_SOURCE_TIPO_PATH,
15510        );
15511    }
15512
15513    #[test]
15514    fn dep_source_tipo_variant_consts_are_ascii_lowercase_shape() {
15515        // Shape pin against `rename_all` drift: the two variant-tag
15516        // consts must be ASCII-lowercase-only to match the
15517        // `rename_all = "lowercase"` attribute the derive uses; a future
15518        // rebrand to `"UPPERCASE"` / `"PascalCase"` at the attribute
15519        // would emit `"GIT"` / `"Git"` instead and trip this pin.
15520        for (label, s) in [
15521            ("DEP_SOURCE_TIPO_GIT", crate::render::DEP_SOURCE_TIPO_GIT),
15522            ("DEP_SOURCE_TIPO_PATH", crate::render::DEP_SOURCE_TIPO_PATH),
15523        ] {
15524            assert!(!s.is_empty(), "{label} must not be empty");
15525            assert!(
15526                s.bytes().all(|b| b.is_ascii_lowercase()),
15527                "{label} must be ASCII-lowercase-only (matching \
15528                 rename_all = \"lowercase\"), got {s:?}",
15529            );
15530        }
15531    }
15532
15533    // ── per-entry :caracteristicas set-not-multiset gate ────────────
15534    //
15535    // Every Vec-keyed-by-name authoring surface on the typed Caixa
15536    // surface that identifies its entries by a name field now uniformly
15537    // closes the set-not-multiset discipline at build time (cite
15538    // `validate_caracteristicas`'s peer-axis enumeration). The
15539    // `:caracteristicas` axis is per-`Dep`: the feature-toggle slot is
15540    // set-shaped (a feature is either enabled or not — there is no
15541    // `feature × 2` semantic), so two entries naming the same feature
15542    // are a redundant declaration the caixa-resolver's lacre pipeline
15543    // would silently dedup at resolve time. The empty-feature arm
15544    // closes the parallel "operationally-meaningless value" axis on
15545    // the same slot. Same linear-walk + `HashSet` + first-collision
15546    // shape every peer set gate uses; same empty-first cascade every
15547    // peer per-entry shape + duplicate gate uses (the empty-feature
15548    // axis is the more-actionable defect since two `""` entries would
15549    // both report `caracteristica: ""` under a duplicate-first
15550    // ordering, with no way to distinguish the offending site).
15551
15552    fn dep_with_features(features: &[&str]) -> Dep {
15553        Dep {
15554            nome: "caixa-teia".into(),
15555            versao: "^0.1".into(),
15556            fonte: None,
15557            opcional: false,
15558            caracteristicas: features.iter().map(|s| (*s).into()).collect(),
15559        }
15560    }
15561
15562    #[test]
15563    fn validate_rejects_empty_caracteristica() {
15564        // Fail-before-pass-after pin: every pre-gate codebase accepted
15565        // `(:caracteristicas (""))` cleanly (the `Vec<String>` field
15566        // imposed no per-entry shape contract), the dep validated, and
15567        // the empty feature would have reached the future caixa-resolver
15568        // lacre pipeline as a no-op feature enable — silently dropping
15569        // the author's intent far from the source `caixa.lisp`. The new
15570        // gate surfaces the structural defect at the typed-validate
15571        // surface with a self-locating diagnostic naming the offending
15572        // dep's `:nome`.
15573        let d = dep_with_features(&[""]);
15574        assert!(
15575            matches!(d.validate().unwrap_err(), DepError::CaracteristicaEmpty { ref nome } if nome == "caixa-teia"),
15576            "expected CaracteristicaEmpty, got {:?}",
15577            d.validate(),
15578        );
15579    }
15580
15581    #[test]
15582    fn validate_rejects_duplicate_caracteristica() {
15583        // Fail-before-pass-after pin on the set-not-multiset arm: the
15584        // feature-toggle slot is set-shaped, so `(:caracteristicas
15585        // ("http" "http"))` is a redundant declaration the lacre
15586        // pipeline dedupes silently at resolve time. The diagnostic
15587        // names the offending dep + the colliding feature verbatim so
15588        // the author can grep their caixa.lisp for `:caracteristicas`
15589        // and fix it in one edit. First-collision determinism is
15590        // pinned separately below.
15591        let d = dep_with_features(&["http", "http"]);
15592        assert!(
15593            matches!(
15594                d.validate().unwrap_err(),
15595                DepError::CaracteristicaDuplicate { ref nome, ref caracteristica }
15596                    if nome == "caixa-teia" && caracteristica == "http"
15597            ),
15598            "expected CaracteristicaDuplicate, got {:?}",
15599            d.validate(),
15600        );
15601    }
15602
15603    #[test]
15604    fn validate_accepts_distinct_caracteristicas() {
15605        // The canonical authoring shape — every feature distinct — must
15606        // remain a clean pass (positive control sweep). Covers the
15607        // canonical kebab-case feature names a target caixa typically
15608        // declares.
15609        dep_with_features(&["http", "json", "tls"])
15610            .validate()
15611            .unwrap();
15612    }
15613
15614    #[test]
15615    fn validate_accepts_single_caracteristica() {
15616        // Single-element list is the minimum non-empty shape; passes
15617        // the gate as the identity of the duplicate check (no second
15618        // entry to collide with).
15619        dep_with_features(&["http"]).validate().unwrap();
15620    }
15621
15622    #[test]
15623    fn validate_accepts_empty_caracteristicas_list() {
15624        // The bare-dep authoring shape (`Dep::simple` / `Dep::git`)
15625        // produces `caracteristicas: Vec::new()`; the empty list is
15626        // the gate's empty-set identity and passes vacuously. Pin
15627        // this so a future tightening that requires ≥1 feature
15628        // surfaces here as a test failure rather than a silent
15629        // contract narrowing.
15630        Dep::simple("caixa-teia", "^0.1").validate().unwrap();
15631        assert!(dep_with_features(&[]).validate().is_ok());
15632    }
15633
15634    #[test]
15635    fn validate_caracteristica_empty_fires_before_duplicate() {
15636        // Empty-first cascade: an entry with an empty feature *and*
15637        // duplicate entries surfaces the empty diagnostic first. The
15638        // empty-feature axis is the more-actionable defect since
15639        // `caracteristica: ""` is unambiguous; under duplicate-first
15640        // ordering the diagnostic could report the empty string from
15641        // either of two empty entries with no way to distinguish.
15642        // Mirrors the peer empty-before-duplicate ordering
15643        // discipline every per-entry shape + duplicate gate establishes
15644        // (`SupervisorSpec::validate`'s `EmptyChildName` arm before
15645        // `DuplicateChildCaixa`, `validate_membros`'s
15646        // `MembroCaixaEmpty` arm before `MembroDuplicate`).
15647        let d = dep_with_features(&["", "http", "http"]);
15648        assert!(matches!(
15649            d.validate().unwrap_err(),
15650            DepError::CaracteristicaEmpty { .. }
15651        ));
15652    }
15653
15654    #[test]
15655    fn validate_caracteristica_duplicate_first_collision_determinism() {
15656        // Three matching entries: the second occurrence surfaces the
15657        // diagnostic (the second is the first *collision* — the first
15658        // entry is the establishing one, not a duplicate). Mirrors
15659        // every peer first-collision posture
15660        // (`SupervisorError::DuplicateChildCaixa` reports the second
15661        // collision, `AplicacaoError::MembroDuplicate` reports the
15662        // second, `DepError::DuplicateNome` reports the second).
15663        // Pinning this so a future shortcut that flips to last-
15664        // collision (or non-deterministic) surfaces here.
15665        let d = dep_with_features(&["http", "http", "http"]);
15666        assert!(matches!(
15667            d.validate().unwrap_err(),
15668            DepError::CaracteristicaDuplicate { ref caracteristica, .. } if caracteristica == "http"
15669        ));
15670    }
15671
15672    #[test]
15673    fn validate_per_entry_shape_fires_before_caracteristicas() {
15674        // Per-entry shape precedence: a dep with a malformed `:nome`
15675        // (uppercase) AND duplicate `:caracteristicas` surfaces the
15676        // narrower `NomeInvalid` diagnostic first, not the set-gate
15677        // diagnostic. The `:nome` is the self-locating axis (every
15678        // diagnostic from the caracteristicas gate quotes the
15679        // offending dep's `:nome` to anchor the grep target —
15680        // surfacing the malformed name first keeps that anchor
15681        // valid). Same precedence shape every peer per-entry-shape
15682        // arm establishes against its peer set-gate
15683        // (`validate_deps_per_entry_validate_fires_before_duplicate_in_deps`
15684        // on the cross-entry `:nome` axis).
15685        let d = Dep {
15686            nome: "Caixa-Teia".into(), // uppercase — DNS-1123 violation
15687            versao: "^0.1".into(),
15688            fonte: None,
15689            opcional: false,
15690            caracteristicas: vec!["http".into(), "http".into()],
15691        };
15692        assert!(matches!(
15693            d.validate().unwrap_err(),
15694            DepError::NomeInvalid { .. }
15695        ));
15696    }
15697
15698    // ── per-entry :caracteristicas value-shape gate ──────────────────
15699    //
15700    // Until this gate landed `:caracteristicas` only refused the empty
15701    // string and cross-entry duplicates: a non-empty distinct but
15702    // structurally invalid feature name silently passed validate and the
15703    // failure surfaced at `cargo metadata` time as Cargo's
15704    // `restricted_names::validate_feature_name` parser rejection, far from
15705    // the source `caixa.lisp` with no field naming which `:deps` entry's
15706    // `:caracteristicas` carried the typo. The lifted predicate makes the
15707    // Cargo-feature-name-grammar intersection-floor a substrate-level
15708    // invariant at validate time. Same trajectory as the eight peer
15709    // value-shape predicates each typed surface downstream of a structured
15710    // grammar already follows.
15711
15712    #[test]
15713    fn validate_rejects_caracteristica_with_leading_plus() {
15714        // Fail-before-pass-after pin on the canonical Cargo
15715        // `+<feature>` activation-form-in-feature-name-slot footgun.
15716        // Cargo's `[dependencies.<dep>.features]` list grammar accepts
15717        // `+optional-feature` as an enablement of a previously-disabled
15718        // feature; pasting that activation form into `:caracteristicas`
15719        // (which names the feature itself) silently passed pre-gate and
15720        // failed at `cargo metadata` parse time.
15721        let d = dep_with_features(&["+http"]);
15722        let err = d.validate().unwrap_err();
15723        assert!(
15724            matches!(
15725                err,
15726                DepError::CaracteristicaInvalid { ref nome, ref caracteristica, .. }
15727                    if nome == "caixa-teia" && caracteristica == "+http"
15728            ),
15729            "expected CaracteristicaInvalid, got {err:?}"
15730        );
15731    }
15732
15733    #[test]
15734    fn validate_rejects_caracteristica_with_leading_hyphen() {
15735        // Fail-before-pass-after pin on the leading-hyphen footgun. `-`
15736        // is a legitimate continuation character (kebab-case feature
15737        // names like `runtime-tokio` pass) but Cargo rejects it at the
15738        // start; the structural defect — and its CLI-argument-injection
15739        // adjacency at any downstream Cargo subprocess invocation — is
15740        // closed at validate time, not at `cargo metadata` time.
15741        let d = dep_with_features(&["-json"]);
15742        let err = d.validate().unwrap_err();
15743        assert!(
15744            matches!(
15745                err,
15746                DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "-json"
15747            ),
15748            "expected CaracteristicaInvalid, got {err:?}"
15749        );
15750    }
15751
15752    #[test]
15753    fn validate_rejects_caracteristica_with_leading_dot() {
15754        // Fail-before-pass-after pin on the leading-dot footgun. `.` is
15755        // a legitimate continuation character (version-suffix shapes
15756        // like `feat.v2` pass) but the leading-dot form is the
15757        // canonical dotted-version-suffix-as-feature-name confusion.
15758        let d = dep_with_features(&[".feat"]);
15759        let err = d.validate().unwrap_err();
15760        assert!(matches!(
15761            err,
15762            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == ".feat"
15763        ));
15764    }
15765
15766    #[test]
15767    fn validate_rejects_caracteristica_with_whitespace() {
15768        // Fail-before-pass-after pin on the embedded-whitespace footgun:
15769        // a feature name with a space inside is structurally a multi-
15770        // token blob (the canonical paste-from-doc footgun, or an
15771        // accidental `"http server"` where the author meant
15772        // `"http-server"`).
15773        let d = dep_with_features(&["http feature"]);
15774        let err = d.validate().unwrap_err();
15775        assert!(matches!(
15776            err,
15777            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http feature"
15778        ));
15779    }
15780
15781    #[test]
15782    fn validate_rejects_caracteristica_with_comma() {
15783        // Fail-before-pass-after pin on the embedded-comma footgun:
15784        // the list-separator-belongs-to-the-list-grammar
15785        // miscomprehension where the author writes
15786        // `:caracteristicas ("http,json")` intending two features but
15787        // the `Vec<String>` field consumes the bare token as one entry.
15788        let d = dep_with_features(&["http,json"]);
15789        let err = d.validate().unwrap_err();
15790        assert!(matches!(
15791            err,
15792            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http,json"
15793        ));
15794    }
15795
15796    #[test]
15797    fn validate_rejects_caracteristica_with_slash() {
15798        // Fail-before-pass-after pin on the embedded-slash footgun:
15799        // Cargo's `dep/feat` namespaced-dep syntax applies inside
15800        // `[dependencies.<dep>.features]` list entries that already
15801        // name the parent dep (so the syntax says "enable feature
15802        // `feat` on a transitive dep `dep`"); `:caracteristicas` is
15803        // per-dep already (a sibling slot on the `Dep` itself), so the
15804        // segment separator within an entry must be `-`, `_`, `+`,
15805        // or `.`. The diagnostic remediation points at the canonical
15806        // Cargo namespaced-dep discipline.
15807        let d = dep_with_features(&["http/json"]);
15808        let err = d.validate().unwrap_err();
15809        assert!(matches!(
15810            err,
15811            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http/json"
15812        ));
15813    }
15814
15815    #[test]
15816    fn validate_rejects_caracteristica_with_non_ascii() {
15817        // Fail-before-pass-after pin on the un-percent-encoded non-ASCII
15818        // byte footgun: NFC-vs-NFD normalization across filesystems
15819        // silently rewrites the feature-key, breaking the lacre's
15820        // content-addressing invariant. Pinned at a canonical
15821        // smart-quote-paste shape (`café`) where the raw `é` byte is the
15822        // documented APFS round-trip break.
15823        let d = dep_with_features(&["caf\u{e9}"]);
15824        let err = d.validate().unwrap_err();
15825        assert!(matches!(
15826            err,
15827            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "caf\u{e9}"
15828        ));
15829    }
15830
15831    #[test]
15832    fn validate_rejects_caracteristica_with_control_character() {
15833        // Fail-before-pass-after pin on the embedded-control-character
15834        // footgun: a CR/LF or any 0x00..0x1F / 0x7F byte landing in a
15835        // feature name is the canonical paste-from-multiline-doc
15836        // footgun the predicate's reason wording specifically calls out.
15837        let d = dep_with_features(&["http\njson"]);
15838        let err = d.validate().unwrap_err();
15839        assert!(matches!(err, DepError::CaracteristicaInvalid { .. }));
15840    }
15841
15842    #[test]
15843    fn validate_accepts_canonical_caracteristicas_shapes() {
15844        // Positive control sweep: every canonical Cargo feature name
15845        // shape the pleme-io ecosystem uses must still pass. Mirrors
15846        // the substrate-side `cargo_feature_name_accepts_canonical_forms`
15847        // sweep — drift between either landing site and the predicate's
15848        // accepted set is a build error visible at this pair of tests,
15849        // not a per-renderer "this passed validate but failed at
15850        // cargo metadata time" surprise on the next acceptance.
15851        for s in [
15852            "http",
15853            "json",
15854            "derive",
15855            "serde_json",
15856            "runtime-tokio",
15857            "tokio.full",
15858            "v0.1",
15859            "http+json",
15860            "_internal",
15861            "__private",
15862            "default",
15863            "rt-multi-thread",
15864            "feat.v2",
15865        ] {
15866            let d = dep_with_features(&[s]);
15867            d.validate().unwrap_or_else(|e| {
15868                panic!("canonical Cargo feature name {s:?} must pass validate: {e:?}")
15869            });
15870        }
15871    }
15872
15873    #[test]
15874    fn validate_caracteristica_empty_fires_before_invalid() {
15875        // Cascade precedence pin: an entry list with both an empty
15876        // feature AND an invalid-shape feature surfaces the
15877        // `CaracteristicaEmpty` arm first (the empty value carries no
15878        // self-locating data — `caracteristica: ""` is the diagnostic
15879        // with no way to anchor a grep target — so closing the empty
15880        // axis first preserves the per-entry-shape diagnostic's
15881        // self-locating discipline). Same empty-first cascade every
15882        // peer per-entry shape gate establishes
15883        // (`SupervisorSpec::validate`'s `EmptyChildName` before
15884        // `ChildCaixaInvalid`, `validate_membros`'s `MembroCaixaEmpty`
15885        // before `MembroCaixaInvalid`).
15886        let d = dep_with_features(&["", "+http"]);
15887        assert!(matches!(
15888            d.validate().unwrap_err(),
15889            DepError::CaracteristicaEmpty { .. }
15890        ));
15891    }
15892
15893    #[test]
15894    fn validate_caracteristica_invalid_fires_before_duplicate() {
15895        // Per-entry-shape precedence pin: an entry list with the same
15896        // invalid feature shape declared twice surfaces the
15897        // `CaracteristicaInvalid` diagnostic on the first entry, not
15898        // the `CaracteristicaDuplicate` on the second collision. The
15899        // per-entry shape gate fires before the cross-entry set gate
15900        // — same precedence shape every peer two-arm-plus-set gate
15901        // establishes (`SupervisorSpec::validate`'s
15902        // `ChildCaixaInvalid` before `DuplicateChildCaixa`,
15903        // `validate_membros`'s `MembroCaixaInvalid` before
15904        // `MembroDuplicate`, `Dep::validate`'s `NomeInvalid` before
15905        // cross-list `DuplicateNome`).
15906        let d = dep_with_features(&["+http", "+http"]);
15907        assert!(matches!(
15908            d.validate().unwrap_err(),
15909            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "+http"
15910        ));
15911    }
15912
15913    #[test]
15914    fn validate_rejects_caracteristica_at_65_byte_boundary() {
15915        // Boundary pin on the 64-byte cap — both the boundary-accepting
15916        // case and the boundary-exceeding case in one place, so a
15917        // future cap shift surfaces both arms simultaneously, mirroring
15918        // the peer `cargo_feature_name_rejects_at_65_byte_boundary`
15919        // predicate-level pin at the dep-axis landing site.
15920        let max_ok = "a".repeat(64);
15921        dep_with_features(&[&max_ok])
15922            .validate()
15923            .unwrap_or_else(|e| panic!("64-byte feature name must pass: {e:?}"));
15924        let too_long = "a".repeat(65);
15925        let d = dep_with_features(&[&too_long]);
15926        assert!(matches!(
15927            d.validate().unwrap_err(),
15928            DepError::CaracteristicaInvalid { .. }
15929        ));
15930    }
15931
15932    // ── self-dep cross-slot gate ─────────────────────────────────────
15933
15934    #[test]
15935    fn validate_no_self_dep_rejects_self_in_deps() {
15936        // A caixa whose `:deps` lists its own `:nome` is a one-node
15937        // cycle in the lacre closure's dep-graph traversal — rejected,
15938        // naming the parent and the offending list tag.
15939        let deps = vec![
15940            Dep::simple("caixa-teia", "^0.1"),
15941            Dep::simple("orquestra", "^0.1"),
15942        ];
15943        let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
15944        assert!(
15945            matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS),
15946            "got {err:?}"
15947        );
15948    }
15949
15950    #[test]
15951    fn validate_no_self_dep_rejects_self_in_deps_dev() {
15952        // Same gate on the `:deps-dev` axis — neither dep list is a
15953        // second-class citizen on the self-edge invariant.
15954        let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
15955        let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
15956        assert!(
15957            matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
15958            "got {err:?}"
15959        );
15960    }
15961
15962    #[test]
15963    fn validate_no_self_dep_deps_fires_before_deps_dev() {
15964        // Walk order pin: a caixa that self-references on both lists
15965        // surfaces the `:deps` arm first — the load-bearing axis the
15966        // lacre closure resolves at every build. Mirrors the canonical
15967        // [`Caixa::validate_deps`] cascade (`:deps` → `:deps-dev`).
15968        let deps = vec![Dep::simple("orquestra", "^0.1")];
15969        let deps_dev = vec![Dep::simple("orquestra", "^0.2")];
15970        let err = validate_no_self_dep(&deps, &deps_dev, "orquestra").unwrap_err();
15971        assert!(
15972            matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS),
15973            "got {err:?}"
15974        );
15975    }
15976
15977    #[test]
15978    fn validate_no_self_dep_accepts_distinct_names() {
15979        // Positive control: every dep names a distinct caixa. The
15980        // canonical author surface — peer of
15981        // [`validate_no_self_supervision_accepts_distinct_children`].
15982        let deps = vec![
15983            Dep::simple("caixa-teia", "^0.1"),
15984            Dep::simple("caixa-arch", "^0.1"),
15985        ];
15986        let deps_dev = vec![Dep::simple("caixa-test", "^0.1")];
15987        validate_no_self_dep(&deps, &deps_dev, "orquestra").unwrap();
15988    }
15989
15990    #[test]
15991    fn validate_no_self_dep_empty_lists_pass() {
15992        // A caixa with no declared deps has nothing to self-reference —
15993        // the gate is vacuously satisfied. Peer of
15994        // [`validate_no_self_supervision_empty_children_is_ok`].
15995        validate_no_self_dep(&[], &[], "orquestra").unwrap();
15996    }
15997
15998    #[test]
15999    fn validate_no_self_dep_diagnostic_carries_offending_list_and_nome() {
16000        // Diagnostic-shape pin (peer with
16001        // [`validate_no_self_supervision`]'s diagnostic): the error's
16002        // Display surfaces both the offending list tag and the
16003        // parent's `:nome` verbatim, so the author can grep their
16004        // caixa.lisp for the offending block in one edit. Names
16005        // `:bibliotecas` / `:exe` / `:servicos` as the corrective
16006        // surface — every legitimate "I want to use code from this
16007        // caixa" intent routes through one of those three slots.
16008        let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
16009        let rendered = validate_no_self_dep(&[], &deps_dev, "orquestra")
16010            .unwrap_err()
16011            .to_string();
16012        assert!(
16013            rendered.contains(crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
16014            "diagnostic must name the offending list tag: {rendered}",
16015        );
16016        assert!(
16017            rendered.contains("orquestra"),
16018            "diagnostic must quote the parent caixa name: {rendered}",
16019        );
16020        assert!(
16021            rendered.contains(":bibliotecas"),
16022            "diagnostic must point at the corrective code-surface slot: {rendered}",
16023        );
16024    }
16025
16026    #[test]
16027    fn validate_no_self_dep_accepts_coincidental_substring_match() {
16028        // Identity is exact-string equality, not substring — a dep
16029        // named `"orquestra-helper"` is a distinct caixa even when the
16030        // parent is `"orquestra"`. Pin the exact-match discipline so a
16031        // future relaxation that uses `contains` surfaces here, peer
16032        // with the supervision-tree and Aplicacao-membership gates
16033        // which all use exact-string equality on the typed identity.
16034        let deps = vec![Dep::simple("orquestra-helper", "^0.1")];
16035        validate_no_self_dep(&deps, &[], "orquestra").unwrap();
16036    }
16037
16038    // ── drift-detection: DEP_AUTHOR_KEY_{DEPS,DEPS_DEV} pin ─────────────
16039
16040    #[test]
16041    fn dep_author_key_consts_pin_canonical_kebab_case_labels() {
16042        // Scalar-value pin: the two author-facing kebab-case labels the
16043        // `(defcaixa … :deps ((…)) :deps-dev ((…)))` surface admits on
16044        // the two-list dep-graph slot axis, one arm per typed slot.
16045        // Mirrors the peer scalar-value pin the sibling
16046        // [`crate::M2_AUTHOR_KEY_LIMITS`] /
16047        // [`crate::M2_AUTHOR_KEY_BEHAVIOR`] /
16048        // [`crate::M2_AUTHOR_KEY_UPGRADE_FROM`] (f49c8b0) M2 top-level
16049        // author-labels, [`crate::M3_AUTHOR_KEY_MEMBROS`] etc.
16050        // (882f498) M3 top-level author-labels, and
16051        // [`crate::SUPERVISOR_AUTHOR_KEY_ESTRATEGIA`] etc. (be40492)
16052        // Supervisor top-level author-labels carry, so every kind-scoped
16053        // typed-slot-family axis routes through one canonical per-arm
16054        // declaration.
16055        //
16056        // A future rebrand (`:deps` → `:dependencies` matching Cargo's
16057        // verbatim key, `:deps-dev` → `:dev-dependencies` matching the
16058        // same, `:deps` / `:deps-dev` → `:runtime-deps` / `:dev-deps`
16059        // for symmetry) lands as an edit to exactly one const, and
16060        // every consumer that reaches for the label picks it up at
16061        // build time rather than at runtime as a downstream mismatch on
16062        // a `DepError::DuplicateNome { list: … }` diagnostic far from
16063        // the rename's commit.
16064        assert_eq!(crate::render::DEP_AUTHOR_KEY_DEPS, ":deps");
16065        assert_eq!(crate::render::DEP_AUTHOR_KEY_DEPS_DEV, ":deps-dev");
16066    }
16067
16068    #[test]
16069    fn dep_author_key_consts_are_pairwise_distinct() {
16070        // Distinct-labels pin: the two `:deps` / `:deps-dev` labels
16071        // must not collapse onto one byte-string. A future copy-paste
16072        // slip that renamed both consts to the same value (or a rebrand
16073        // that dropped the `-dev` suffix from one but not the other)
16074        // would leave every `DepError::DuplicateNome { list: … }`
16075        // diagnostic naming an unattributable list — the linter would
16076        // route the author to the wrong caixa.lisp block, or the
16077        // cross-list precedence gate
16078        // (`validate_deps_duplicate_in_deps_fires_before_duplicate_in_deps_dev`)
16079        // would surface a `:deps`-tagged diagnostic on a `:deps-dev`
16080        // duplicate. Peer of the sibling
16081        // `m2_author_key_consts_are_pairwise_distinct`-shape gates the
16082        // other top-level kind-scoped slot-family axes carry
16083        // (implicitly held by their different byte-values today).
16084        assert_ne!(
16085            crate::render::DEP_AUTHOR_KEY_DEPS,
16086            crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
16087            "DEP_AUTHOR_KEY_{{DEPS,DEPS_DEV}} consts must be pairwise-distinct \
16088             so a `DepError::DuplicateNome {{ list: … }}` diagnostic \
16089             self-locates the offending block in the author's caixa.lisp",
16090        );
16091    }
16092
16093    #[test]
16094    fn validate_no_self_dep_routes_through_lifted_dep_author_key_consts() {
16095        // Production-through-const pin: the two per-arm list tags
16096        // [`validate_no_self_dep`] threads onto the `list:` field of a
16097        // returned [`DepError::DepIsSelf`] route through the lifted
16098        // [`crate::DEP_AUTHOR_KEY_DEPS`] /
16099        // [`crate::DEP_AUTHOR_KEY_DEPS_DEV`] consts. A future drift at
16100        // the walker (a rename that reaches one arm but not the const,
16101        // or vice versa) surfaces here at build time rather than at
16102        // runtime as a `feira lint` diagnostic naming the wrong list
16103        // tag. Mirror of the peer
16104        // [`crate::Caixa::declared_servico_slots`] production tagger
16105        // pin (f49c8b0) on the sibling M2 top-level slot axis, extended
16106        // onto the two-list dep-graph gate.
16107        let deps = vec![Dep::simple("orquestra", "^0.1")];
16108        let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
16109        let DepError::DepIsSelf { list, .. } = err else {
16110            panic!("expected DepIsSelf from :deps walk");
16111        };
16112        assert_eq!(list, crate::render::DEP_AUTHOR_KEY_DEPS);
16113
16114        let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
16115        let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
16116        let DepError::DepIsSelf { list, .. } = err else {
16117            panic!("expected DepIsSelf from :deps-dev walk");
16118        };
16119        assert_eq!(list, crate::render::DEP_AUTHOR_KEY_DEPS_DEV);
16120    }
16121
16122    // ── Dep::nome accessor pins ───────────────────────────────────────
16123    //
16124    // Three coherence pins on the lifted `Dep::nome` accessor: byte-equal
16125    // projection over the plain-shorthand / explicit-git / explicit-path
16126    // fixture triad the [`Dep`] docstring lists (so the accessor's
16127    // accept-set is exercised across every author-surface `:fonte`
16128    // shape); by-borrow pointer identity so the projection stays
16129    // zero-copy at every consumer site; and validate-composition through
16130    // the [`validate_no_self_dep`] cross-slot gate reading its
16131    // parent-name equality check through the lifted accessor rather than
16132    // the raw field.
16133
16134    #[test]
16135    fn dep_nome_returns_declared_nome_across_fonte_shapes() {
16136        // Plain-shorthand form (`:fonte None`).
16137        assert_eq!(Dep::simple("caixa-teia", "^0.1").nome(), "caixa-teia");
16138        // Explicit git-source form with a tag pin — same accessor path.
16139        assert_eq!(
16140            Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0").nome(),
16141            "caixa-teia",
16142        );
16143        // Explicit path-source form.
16144        assert_eq!(
16145            Dep {
16146                nome: "caixa-teia".to_string(),
16147                versao: "0.1.0".to_string(),
16148                fonte: Some(DepSource::Path {
16149                    caminho: "../caixa-teia".to_string(),
16150                }),
16151                opcional: false,
16152                caracteristicas: Vec::new(),
16153            }
16154            .nome(),
16155            "caixa-teia",
16156        );
16157        // The empty-string `:nome` sentinel (which [`Dep::validate`]
16158        // refuses through the [`DepError::NomeEmpty`] arm) still round-
16159        // trips as an empty `&str` through the accessor — the accessor is
16160        // a projection, not a gate; the gate is [`Dep::validate`].
16161        assert_eq!(Dep::simple("", "^0.1").nome(), "");
16162    }
16163
16164    #[test]
16165    fn dep_nome_is_by_borrow_pointer_identity() {
16166        // Zero-copy pin: the accessor must borrow into the field's own
16167        // storage, not clone. If a future rewrite regresses to
16168        // `self.nome.clone().leak()` or an owned-buffer shape, the two
16169        // pointers diverge and this pin fails at build time.
16170        let d = Dep::simple("caixa-teia", "^0.1");
16171        assert!(std::ptr::eq(d.nome().as_ptr(), d.nome.as_ptr()));
16172    }
16173
16174    // ── Dep::versao_requirement accessor pins ─────────────────────────
16175    //
16176    // Three coherence pins on the lifted `Dep::versao_requirement`
16177    // accessor: byte-equal projection over the plain-shorthand /
16178    // explicit-git / explicit-path fixture triad the [`Dep`] docstring
16179    // lists plus the empty-sentinel that round-trips as `""` (the accessor
16180    // is a projection, not a gate; the gate is [`Dep::validate`]); by-
16181    // borrow pointer identity so the projection stays zero-copy at every
16182    // consumer site; and validate-composition through the
16183    // [`crate::render::require_valid_versao_requirement`] cascade reading
16184    // its requirement-shape check through the lifted accessor rather than
16185    // the raw field.
16186    #[test]
16187    fn dep_versao_requirement_returns_declared_versao_across_fonte_shapes() {
16188        // Plain-shorthand form (`:fonte None`).
16189        assert_eq!(
16190            Dep::simple("caixa-teia", "^0.1").versao_requirement(),
16191            "^0.1",
16192        );
16193        // Explicit git-source form with a tag pin — same accessor path.
16194        assert_eq!(
16195            Dep::git(
16196                "caixa-teia",
16197                "~0.1.2",
16198                "github:pleme-io/caixa-teia",
16199                "v0.1.0"
16200            )
16201            .versao_requirement(),
16202            "~0.1.2",
16203        );
16204        // Explicit path-source form.
16205        assert_eq!(
16206            Dep {
16207                nome: "caixa-teia".to_string(),
16208                versao: "0.1.0".to_string(),
16209                fonte: Some(DepSource::Path {
16210                    caminho: "../caixa-teia".to_string(),
16211                }),
16212                opcional: false,
16213                caracteristicas: Vec::new(),
16214            }
16215            .versao_requirement(),
16216            "0.1.0",
16217        );
16218        // The wildcard requirement (`"*"`) — the shorthand
16219        // `parse_requirement` accepts as `VersionReq::STAR` — round-trips
16220        // verbatim through the accessor as `"*"`, same byte-shape the
16221        // author wrote.
16222        assert_eq!(Dep::simple("caixa-teia", "*").versao_requirement(), "*");
16223        // The empty-string `:versao` sentinel (which [`Dep::validate`]
16224        // refuses through the [`DepError::VersaoEmpty`] arm) still round-
16225        // trips as an empty `&str` through the accessor — the accessor is
16226        // a projection, not a gate; the gate is [`Dep::validate`]. Peer
16227        // of the sibling [`Dep::nome`] empty-sentinel round-trip pin.
16228        assert_eq!(Dep::simple("caixa-teia", "").versao_requirement(), "");
16229    }
16230
16231    #[test]
16232    fn dep_versao_requirement_is_by_borrow_pointer_identity() {
16233        // Zero-copy pin: the accessor must borrow into the field's own
16234        // storage, not clone. If a future rewrite regresses to
16235        // `self.versao.clone().leak()` or an owned-buffer shape, the two
16236        // pointers diverge and this pin fails at build time. Peer of the
16237        // sibling [`Dep::nome`] pointer-identity pin — same by-borrow
16238        // discipline extended onto the requirement-carrying axis.
16239        let d = Dep::simple("caixa-teia", "^0.1");
16240        assert!(std::ptr::eq(
16241            d.versao_requirement().as_ptr(),
16242            d.versao.as_ptr(),
16243        ));
16244    }
16245
16246    #[test]
16247    fn dep_validate_reads_requirement_through_accessor() {
16248        // Composition pin: the [`Dep::validate`]
16249        // [`crate::render::require_valid_versao_requirement`] cascade
16250        // consumes the requirement string through the lifted accessor —
16251        // both the requirement-gate input and the
16252        // [`DepError::VersaoInvalid`] error-body carrier route through
16253        // `self.versao_requirement()`. A valid requirement passes
16254        // (positive control); a malformed-but-non-empty requirement fails
16255        // and the diagnostic quotes the offending byte-string verbatim
16256        // (same shape the accessor projects), so a future regression that
16257        // detoured the requirement carrier through a different byte-
16258        // string (say the parsed `VersionReq`'s `Display`, or a
16259        // normalized rewrite) would surface here at build time. The
16260        // empty-`:versao` arm fires the [`DepError::VersaoEmpty`] variant
16261        // ahead of the parse arm, pinning the empty-first cascade the
16262        // accessor's `""` sentinel round-trip acknowledges.
16263        Dep::simple("caixa-teia", "^0.1").validate().unwrap();
16264        let err = Dep::simple("caixa-teia", "v0.1").validate().unwrap_err();
16265        assert!(
16266            matches!(
16267                &err,
16268                DepError::VersaoInvalid {
16269                    nome,
16270                    versao,
16271                    ..
16272                } if nome == "caixa-teia" && versao == "v0.1",
16273            ),
16274            "expected VersaoInvalid quoting the accessor-projected requirement, got {err:?}",
16275        );
16276        let err = Dep::simple("caixa-teia", "").validate().unwrap_err();
16277        assert!(
16278            matches!(
16279                &err,
16280                DepError::VersaoEmpty { nome } if nome == "caixa-teia",
16281            ),
16282            "expected VersaoEmpty from the empty-first arm, got {err:?}",
16283        );
16284    }
16285
16286    // ── Dep::fonte accessor pins ──────────────────────────────────────
16287    //
16288    // Three coherence pins on the lifted `Dep::fonte` accessor: byte-
16289    // equal projection over the plain-shorthand (`:fonte None`) /
16290    // explicit-git-tag / explicit-path fixture triad the [`Dep`]
16291    // docstring lists (so the accessor's accept-set is exercised across
16292    // every author-surface `:fonte` shape and both `DepSource` variants);
16293    // pointer identity so the borrowed reference points into the field's
16294    // own `Option<DepSource>` storage (not a cloned side-buffer); and
16295    // validate-composition through the [`Dep::validate`] gate reading
16296    // its per-`:fonte` [`DepSource::validate`] delegation through the
16297    // lifted accessor rather than the raw `if let Some(ref fonte) =
16298    // self.fonte` bracket.
16299
16300    #[test]
16301    fn dep_fonte_returns_declared_source_across_shapes() {
16302        // Plain-shorthand form — `:fonte` omitted, accessor projects
16303        // the `None` partition the resolver-side default-fill treats
16304        // as "resolve through `github:<default-org>/<nome>`".
16305        assert!(Dep::simple("caixa-teia", "^0.1").fonte().is_none());
16306        // Explicit git-source form with a tag pin — same accessor path.
16307        let git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
16308        match git.fonte() {
16309            Some(DepSource::Git {
16310                repo,
16311                tag,
16312                rev,
16313                branch,
16314            }) => {
16315                assert_eq!(repo, "github:pleme-io/caixa-teia");
16316                assert_eq!(tag.as_deref(), Some("v0.1.0"));
16317                assert!(rev.is_none());
16318                assert!(branch.is_none());
16319            }
16320            other => panic!("expected explicit git :fonte, got {other:?}"),
16321        }
16322        // Explicit path-source form — the dev-only local-filesystem
16323        // arm the [`Dep`] docstring's third fixture carries.
16324        let path = Dep {
16325            nome: "caixa-teia".to_string(),
16326            versao: "0.1.0".to_string(),
16327            fonte: Some(DepSource::Path {
16328                caminho: "../caixa-teia".to_string(),
16329            }),
16330            opcional: false,
16331            caracteristicas: Vec::new(),
16332        };
16333        match path.fonte() {
16334            Some(DepSource::Path { caminho }) => {
16335                assert_eq!(caminho, "../caixa-teia");
16336            }
16337            other => panic!("expected explicit path :fonte, got {other:?}"),
16338        }
16339    }
16340
16341    #[test]
16342    fn dep_fonte_is_by_borrow_pointer_identity() {
16343        // Zero-copy pin: the accessor must borrow into the field's own
16344        // `Option<DepSource>` storage, not clone into a side buffer. If
16345        // a future rewrite regresses to `self.fonte.clone()` or an
16346        // owned-buffer shape, the two pointers diverge and this pin
16347        // fails at build time. Peer of the sibling per-`Dep` [`Dep::nome`]
16348        // (eba2cde) / [`Dep::versao_requirement`] (05529b1) pointer-
16349        // identity pins — same by-borrow discipline extended onto the
16350        // outer-`Dep` `Option<&Composite>` composite-reference axis.
16351        let d = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
16352        let accessed = d.fonte().expect("git :fonte present") as *const DepSource;
16353        let raw = d.fonte.as_ref().expect("git :fonte present") as *const DepSource;
16354        assert!(std::ptr::eq(accessed, raw));
16355    }
16356
16357    #[test]
16358    fn dep_validate_reads_fonte_through_accessor() {
16359        // Composition pin: [`Dep::validate`]'s per-`:fonte`
16360        // [`DepSource::validate`] delegation consumes the typed slot
16361        // through the lifted accessor — an author-omitted `:fonte`
16362        // still passes the outer gate (positive control), an explicit
16363        // well-formed git source with exactly one pin passes, and a
16364        // malformed git source (empty `:repo`) surfaces the
16365        // [`DepError::FonteRepoEmpty`] variant quoting the offending
16366        // dep's `:nome` verbatim so a future regression that detoured
16367        // the `:fonte` delegation through a different path (say a
16368        // per-scope override projector) would surface here at build
16369        // time. Peer of the sibling
16370        // `dep_validate_reads_requirement_through_accessor` composition
16371        // pin on the `:versao` axis.
16372        // Positive control 1: no `:fonte` at all.
16373        Dep::simple("caixa-teia", "^0.1").validate().unwrap();
16374        // Positive control 2: well-formed git source.
16375        Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0")
16376            .validate()
16377            .unwrap();
16378        // Negative control: empty `:repo` — the accessor still returns
16379        // `Some(&DepSource::Git { repo: "", … })` and the delegated
16380        // `DepSource::validate` gate raises the typed carrier.
16381        let bad = Dep {
16382            nome: "caixa-teia".to_string(),
16383            versao: "^0.1".to_string(),
16384            fonte: Some(DepSource::Git {
16385                repo: String::new(),
16386                tag: Some("v0.1.0".to_string()),
16387                rev: None,
16388                branch: None,
16389            }),
16390            opcional: false,
16391            caracteristicas: Vec::new(),
16392        };
16393        let err = bad.validate().unwrap_err();
16394        assert!(
16395            matches!(
16396                &err,
16397                DepError::FonteRepoEmpty { nome } if nome == "caixa-teia",
16398            ),
16399            "expected FonteRepoEmpty from the accessor-routed :fonte gate, got {err:?}",
16400        );
16401    }
16402
16403    #[test]
16404    fn validate_no_self_dep_reads_parent_equality_through_accessor() {
16405        // Composition pin: the cross-slot [`validate_no_self_dep`] gate
16406        // rejects a `:deps` entry whose `:nome` equals the parent caixa's
16407        // own `:nome` through the lifted accessor rather than the raw
16408        // field. Fails-before-passes-after: with the accessor lifted the
16409        // gate reads its equality check through `dep.nome() ==
16410        // parent_nome` on both the `:deps` and `:deps-dev` traversals, so
16411        // the diagnostic still names the offending list tag as expected.
16412        let deps = vec![Dep::simple("orquestra", "^0.1")];
16413        let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
16414        assert!(matches!(
16415            err,
16416            DepError::DepIsSelf {
16417                ref nome,
16418                list,
16419            } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS,
16420        ));
16421        let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
16422        let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
16423        assert!(matches!(
16424            err,
16425            DepError::DepIsSelf {
16426                ref nome,
16427                list,
16428            } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
16429        ));
16430        // A non-matching `:nome` passes through the accessor gate.
16431        let deps = vec![Dep::simple("caixa-teia", "^0.1")];
16432        validate_no_self_dep(&deps, &[], "orquestra").unwrap();
16433    }
16434
16435    // ── Dep::caracteristicas accessor pins ────────────────────────────
16436    //
16437    // Three coherence pins on the lifted `Dep::caracteristicas` accessor:
16438    // byte-equal projection over the default-empty / single-entry /
16439    // multi-entry fixture triad (so the accessor's accept-set is
16440    // exercised across every author-surface `:caracteristicas` shape,
16441    // matching the peer sibling family's fixture-triad discipline); by-
16442    // borrow pointer identity so the projection stays zero-copy at every
16443    // consumer site; and validate-composition through the
16444    // [`Dep::validate_caracteristicas`] gate reading its per-entry
16445    // linear walk through the lifted accessor rather than the raw
16446    // `for c in &self.caracteristicas` bracket.
16447
16448    #[test]
16449    fn dep_caracteristicas_returns_declared_features_across_shapes() {
16450        // Default-empty form — the [`Dep::simple`] constructor's
16451        // `Vec::new()` fill; the accessor projects the empty slice
16452        // verbatim (no `None` collapse).
16453        assert!(
16454            Dep::simple("caixa-teia", "^0.1")
16455                .caracteristicas()
16456                .is_empty(),
16457        );
16458        // Single-entry form — the canonical Cargo-shaped one-feature
16459        // enable ([`crate::render::is_cargo_feature_name`] accepts the
16460        // `"http"` byte-string as a valid feature name).
16461        let one = Dep {
16462            nome: "caixa-teia".to_string(),
16463            versao: "^0.1".to_string(),
16464            fonte: None,
16465            opcional: false,
16466            caracteristicas: vec!["http".to_string()],
16467        };
16468        assert_eq!(one.caracteristicas(), &["http".to_string()]);
16469        // Multi-entry form — the substrate's set-shaped multi-feature
16470        // enable, exercising the accessor over a length-two slice with
16471        // no duplicate collapse.
16472        let two = Dep {
16473            nome: "caixa-teia".to_string(),
16474            versao: "^0.1".to_string(),
16475            fonte: None,
16476            opcional: false,
16477            caracteristicas: vec!["http".to_string(), "json".to_string()],
16478        };
16479        assert_eq!(
16480            two.caracteristicas(),
16481            &["http".to_string(), "json".to_string()],
16482        );
16483    }
16484
16485    #[test]
16486    fn dep_caracteristicas_is_by_borrow_pointer_identity() {
16487        // Zero-copy pin: the accessor must borrow into the field's own
16488        // `Vec<String>` storage, not clone into a side buffer. If a
16489        // future rewrite regresses to `self.caracteristicas.clone()` or
16490        // an owned-buffer shape, the two pointers diverge and this pin
16491        // fails at build time. Peer of the sibling per-`Dep`
16492        // [`Dep::nome`] (eba2cde) / [`Dep::versao_requirement`] (05529b1)
16493        // / [`Dep::fonte`] (d65d1bf) pointer-identity pins — same by-
16494        // borrow discipline extended onto the outer-`Dep` `&[String]`
16495        // slice-projection axis.
16496        let d = Dep {
16497            nome: "caixa-teia".to_string(),
16498            versao: "^0.1".to_string(),
16499            fonte: None,
16500            opcional: false,
16501            caracteristicas: vec!["http".to_string(), "json".to_string()],
16502        };
16503        assert!(std::ptr::eq(
16504            d.caracteristicas().as_ptr(),
16505            d.caracteristicas.as_ptr(),
16506        ));
16507    }
16508
16509    #[test]
16510    fn dep_validate_reads_caracteristicas_through_accessor() {
16511        // Composition pin: [`Dep::validate_caracteristicas`]'s per-entry
16512        // linear walk consumes the feature-toggle list through the
16513        // lifted accessor — a well-formed `:caracteristicas` set passes
16514        // (positive control), an empty-string entry surfaces the
16515        // [`DepError::CaracteristicaEmpty`] variant quoting the offending
16516        // `Dep::nome`, and a within-list duplicate surfaces the
16517        // [`DepError::CaracteristicaDuplicate`] variant so a future
16518        // regression that detoured the walk through a different byte-
16519        // string list (say a per-scope override projector) would surface
16520        // here at build time. Peer of the sibling
16521        // `dep_validate_reads_fonte_through_accessor` /
16522        // `dep_validate_reads_requirement_through_accessor` composition
16523        // pins on the `:fonte` / `:versao` axes.
16524        // Positive control: two distinct well-formed feature names pass.
16525        Dep {
16526            nome: "caixa-teia".to_string(),
16527            versao: "^0.1".to_string(),
16528            fonte: None,
16529            opcional: false,
16530            caracteristicas: vec!["http".to_string(), "json".to_string()],
16531        }
16532        .validate()
16533        .unwrap();
16534        // Negative control 1: empty-string feature-name entry — the
16535        // accessor still returns `&[""]` and the walk raises the typed
16536        // empty-first carrier.
16537        let err = Dep {
16538            nome: "caixa-teia".to_string(),
16539            versao: "^0.1".to_string(),
16540            fonte: None,
16541            opcional: false,
16542            caracteristicas: vec![String::new()],
16543        }
16544        .validate()
16545        .unwrap_err();
16546        assert!(
16547            matches!(
16548                &err,
16549                DepError::CaracteristicaEmpty { nome } if nome == "caixa-teia",
16550            ),
16551            "expected CaracteristicaEmpty from the accessor-routed walk, got {err:?}",
16552        );
16553        // Negative control 2: within-list duplicate — the accessor's
16554        // slice view carries both entries, and the walk's dedup arm
16555        // raises the typed duplicate carrier quoting the offending
16556        // feature name verbatim.
16557        let err = Dep {
16558            nome: "caixa-teia".to_string(),
16559            versao: "^0.1".to_string(),
16560            fonte: None,
16561            opcional: false,
16562            caracteristicas: vec!["http".to_string(), "http".to_string()],
16563        }
16564        .validate()
16565        .unwrap_err();
16566        assert!(
16567            matches!(
16568                &err,
16569                DepError::CaracteristicaDuplicate {
16570                    nome,
16571                    caracteristica,
16572                } if nome == "caixa-teia" && caracteristica == "http",
16573            ),
16574            "expected CaracteristicaDuplicate from the accessor-routed dedup, got {err:?}",
16575        );
16576    }
16577
16578    // ── Dep::opcional accessor pins ───────────────────────────────────
16579    //
16580    // Two coherence pins on the lifted `Dep::opcional` accessor: byte-
16581    // equal projection over the default-`false` / explicit-`true`
16582    // fixture pair across the plain-shorthand (`:fonte None`) / explicit-
16583    // git-tag / explicit-path fixture triad the [`Dep`] docstring lists,
16584    // exercising the accessor's accept-set over every author-surface
16585    // `:fonte` shape × every author-surface `:opcional` shape; and by-
16586    // `Copy` idempotency so the projection stays value-return (no
16587    // silent detour to a fresh `&bool` borrow that would introduce a
16588    // lifetime on the return type the plain-`Copy`-scalar axis's `bool`
16589    // shape elides). No composition pin — `:opcional` does not
16590    // participate in [`Dep::validate`] (an opcional dep with any bool
16591    // value is validate-accepted; the missing-source arm is a resolver-
16592    // side runtime dispatch, not a build-time refusal), so the axis
16593    // reduces to the value-shape + `Copy` pin pair the peer
16594    // [`crate::Caixa::max_restarts`] / [`crate::Caixa::estrategia`]
16595    // outer-`Option<Copy>` accessor pins already carry.
16596
16597    #[test]
16598    fn dep_opcional_returns_declared_opcional_across_fonte_shapes() {
16599        // Default-`false` form via the [`Dep::simple`] constructor —
16600        // the accessor projects the `false` bit the default-fill sets.
16601        assert!(!Dep::simple("caixa-teia", "^0.1").opcional());
16602        // Default-`false` form via the [`Dep::git`] constructor — same
16603        // default fill; the accessor projects `false` regardless of the
16604        // `:fonte` arm.
16605        assert!(!Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0").opcional(),);
16606        // Explicit-`true` form × plain-shorthand `:fonte` — the
16607        // canonical author-surface "this dep may be missing" shape.
16608        let plain_true = Dep {
16609            nome: "caixa-teia".to_string(),
16610            versao: "^0.1".to_string(),
16611            fonte: None,
16612            opcional: true,
16613            caracteristicas: Vec::new(),
16614        };
16615        assert!(plain_true.opcional());
16616        // Explicit-`true` form × explicit git-source — the accessor
16617        // projects the bit verbatim regardless of the `:fonte` arm.
16618        let git_true = Dep {
16619            nome: "caixa-teia".to_string(),
16620            versao: "^0.1".to_string(),
16621            fonte: Some(DepSource::Git {
16622                repo: "github:pleme-io/caixa-teia".to_string(),
16623                tag: Some("v0.1.0".to_string()),
16624                rev: None,
16625                branch: None,
16626            }),
16627            opcional: true,
16628            caracteristicas: Vec::new(),
16629        };
16630        assert!(git_true.opcional());
16631        // Explicit-`true` form × explicit path-source — the dev-only
16632        // local-filesystem arm the [`Dep`] docstring's third fixture
16633        // carries.
16634        let path_true = Dep {
16635            nome: "caixa-teia".to_string(),
16636            versao: "0.1.0".to_string(),
16637            fonte: Some(DepSource::Path {
16638                caminho: "../caixa-teia".to_string(),
16639            }),
16640            opcional: true,
16641            caracteristicas: Vec::new(),
16642        };
16643        assert!(path_true.opcional());
16644    }
16645
16646    #[test]
16647    fn dep_opcional_projects_bool_by_copy() {
16648        // The by-`Copy` pin: [`Dep::opcional`] returns `bool` by value
16649        // (`bool: Copy`) — the accessor does not borrow `&self` past
16650        // the call (no lifetime on the return type), and calling the
16651        // accessor twice on the same [`Dep`] must yield discriminant-
16652        // equal values (idempotent, no side effects on `&self`). Peer
16653        // of the sibling outer-`Caixa` `Option<Copy>` by-`Copy`
16654        // `max_restarts_projects_option_by_copy` (eba5211) /
16655        // `estrategia_projects_option_by_copy` (ed04d3c) pins on the
16656        // outer-`Caixa` altitude — extended here to the outer-`Dep`
16657        // altitude's plain-`Copy` `bool` axis. The `Copy` discipline
16658        // replaces the pointer-equality claim the sibling per-`Dep`
16659        // by-borrow pins (`dep_nome_is_by_borrow_pointer_identity`
16660        // eba2cde, `dep_versao_requirement_is_by_borrow_pointer_identity`
16661        // 05529b1, `dep_fonte_is_by_borrow_pointer_identity` d65d1bf,
16662        // `dep_caracteristicas_is_by_borrow_pointer_identity` 9197944)
16663        // carry (a fresh `Copy` of a `Copy` discriminant is definitionally
16664        // the same discriminant, so the axis reduces to discriminant
16665        // equality).
16666        //
16667        // Pins against a future silent detour that returned a fresh
16668        // `&bool` reference (which would type-check but silently
16669        // introduce a borrow of `&self` past the call, collapsing the
16670        // load-bearing "no lifetime on the return type" `Copy`
16671        // projection the plain-`Copy`-scalar axis's `bool` shape
16672        // carries) or a stale-read side effect that flipped the outer
16673        // discriminant on successive calls.
16674        for opcional in [false, true] {
16675            let d = Dep {
16676                nome: "caixa-teia".to_string(),
16677                versao: "^0.1".to_string(),
16678                fonte: None,
16679                opcional,
16680                caracteristicas: Vec::new(),
16681            };
16682            let first = d.opcional();
16683            let second = d.opcional();
16684            assert_eq!(
16685                first, second,
16686                "Dep::opcional must be idempotent — two successive calls \
16687                 on the same &self must return the same bool",
16688            );
16689            assert_eq!(
16690                first, opcional,
16691                "Dep::opcional must return :opcional verbatim by Copy — \
16692                 got {first}, expected {opcional}",
16693            );
16694            assert_eq!(
16695                d.opcional(),
16696                d.opcional,
16697                "Dep::opcional accessor and self.opcional field access \
16698                 must byte-equal — a bit-flip drift would silently split \
16699                 the paired resolver-side drop-vs-error dispatch from \
16700                 the storage-side default-fill the [`Dep::simple`] / \
16701                 [`Dep::git`] constructor pair carries",
16702            );
16703        }
16704    }
16705
16706    // ── DepSource::sole_pin — sole-set git-pin accessor ─────────────────
16707
16708    #[test]
16709    fn sole_pin_returns_none_for_path_source() {
16710        // A path source carries no git-ref, so `sole_pin()` returns
16711        // `None` structurally — the sibling arm every git-fetching
16712        // consumer partitions off before reaching for a git-ref. Pins
16713        // the Path-arm branch of the accessor against a future silent
16714        // detour that treats a `Self::Path` as an unpinned-git source
16715        // and returns the wrong "no pin" signal (e.g. the empty string,
16716        // or a hard-coded `Some("HEAD")` matching the caixa-crd
16717        // path-arm `git_ref` fill).
16718        let s = DepSource::Path {
16719            caminho: "../local-caixa".to_string(),
16720        };
16721        assert_eq!(s.sole_pin(), None);
16722    }
16723
16724    #[test]
16725    fn sole_pin_returns_none_for_unpinned_git_source() {
16726        // The [`DepSource::default_github`] shorthand shape carries no
16727        // pin — every `tag`/`rev`/`branch` is `None`, and `sole_pin()`
16728        // returns `None`. This is the shape caixa-resolver's `fetch_dep`
16729        // materializes when the author omits `:fonte` entirely, then
16730        // hands to `fetch_git` which raises `ResolveError::MissingPin`
16731        // on the `None` arm — the accessor's return matches the arm
16732        // the resolver's diagnostic keys off.
16733        let s = DepSource::default_github("pleme-io", "caixa-teia");
16734        assert_eq!(s.sole_pin(), None);
16735    }
16736
16737    #[test]
16738    fn sole_pin_returns_rev_when_only_rev_is_set() {
16739        let s = DepSource::Git {
16740            repo: "github:o/x".into(),
16741            tag: None,
16742            rev: Some("deadbeefcafebabe1234567890abcdef12345678".into()),
16743            branch: None,
16744        };
16745        assert_eq!(
16746            s.sole_pin(),
16747            Some("deadbeefcafebabe1234567890abcdef12345678")
16748        );
16749    }
16750
16751    #[test]
16752    fn sole_pin_returns_tag_when_only_tag_is_set() {
16753        let s = DepSource::Git {
16754            repo: "github:o/x".into(),
16755            tag: Some("v0.1.0".into()),
16756            rev: None,
16757            branch: None,
16758        };
16759        assert_eq!(s.sole_pin(), Some("v0.1.0"));
16760    }
16761
16762    #[test]
16763    fn sole_pin_returns_branch_when_only_branch_is_set() {
16764        let s = DepSource::Git {
16765            repo: "github:o/x".into(),
16766            tag: None,
16767            rev: None,
16768            branch: Some("main".into()),
16769        };
16770        assert_eq!(s.sole_pin(), Some("main"));
16771    }
16772
16773    #[test]
16774    fn sole_pin_precedence_rev_beats_tag_and_branch() {
16775        // Precedence: rev > tag > branch. Validate() rejects
16776        // multiple-pin shapes, but the accessor's precedence is defined
16777        // for pre-validate consumers (the resolver's `MissingPin`
16778        // diagnostic path, the caixa-crd round-trip's default `"main"`
16779        // fallback) and as defense-in-depth if the gate is ever
16780        // bypassed. Pins the same precedence caixa-resolver's
16781        // `fetch_git` and caixa-crd's `dep_into_ref` already apply
16782        // inline.
16783        let s = DepSource::Git {
16784            repo: "github:o/x".into(),
16785            tag: Some("v1".into()),
16786            rev: Some("deadbeefcafebabe1234567890abcdef12345678".into()),
16787            branch: Some("main".into()),
16788        };
16789        assert_eq!(
16790            s.sole_pin(),
16791            Some("deadbeefcafebabe1234567890abcdef12345678")
16792        );
16793    }
16794
16795    #[test]
16796    fn sole_pin_precedence_tag_beats_branch_when_no_rev() {
16797        let s = DepSource::Git {
16798            repo: "github:o/x".into(),
16799            tag: Some("v1".into()),
16800            rev: None,
16801            branch: Some("main".into()),
16802        };
16803        assert_eq!(s.sole_pin(), Some("v1"));
16804    }
16805
16806    #[test]
16807    fn sole_pin_byte_equals_inline_rev_or_tag_or_branch_cascade() {
16808        // Fail-before-pass-after byte-parity pin: the substrate accessor
16809        // must return byte-identical to the inline
16810        // `rev.as_deref().or(tag.as_deref()).or(branch.as_deref())`
16811        // cascade both caixa-resolver's `fetch_git` and caixa-crd's
16812        // `dep_into_ref` open-coded pre-lift. Trips at caixa-core build
16813        // time if the accessor's precedence silently drifts from the
16814        // consumer-side cascade — the exact drift this lift converges
16815        // to one substrate primitive to close structurally.
16816        //
16817        // Iterates through the 2^3 = 8 combinations of (tag, rev,
16818        // branch) each-either-`None`-or-`Some`, so every arm of the
16819        // precedence cascade lands under the pin. `validate()` refuses
16820        // the 4 multi-pin combinations, but the accessor's return is
16821        // defined on all 8.
16822        let vals = [Some("R".to_string()), None];
16823        for tag in &vals {
16824            for rev in &vals {
16825                for branch in &vals {
16826                    let s = DepSource::Git {
16827                        repo: "github:o/x".into(),
16828                        tag: tag.clone(),
16829                        rev: rev.clone(),
16830                        branch: branch.clone(),
16831                    };
16832                    // The exact inline cascade the two pre-lift
16833                    // consumer sites hand-rolled, byte-for-byte.
16834                    let expected = rev.as_deref().or(tag.as_deref()).or(branch.as_deref());
16835                    assert_eq!(
16836                        s.sole_pin(),
16837                        expected,
16838                        "sole_pin() must byte-equal \
16839                         rev.or(tag).or(branch) for \
16840                         (tag={tag:?}, rev={rev:?}, branch={branch:?}) — \
16841                         a drift would silently split caixa-resolver's \
16842                         fetch_git checkout target from caixa-crd's \
16843                         dep_into_ref git_ref fill",
16844                    );
16845                }
16846            }
16847        }
16848    }
16849
16850    // Fail-before-pass-after pins on the eleven
16851    // [`fonte_caminho_ctors!`]-generated `DepError::fonte_caminho_*`
16852    // constructors folded from the [`DepSource::validate_caminho`]
16853    // wire-up sites. Each pins the generated ctor's output to the
16854    // pre-lift struct-literal on the same `(&str, &str)` fixture, so
16855    // any wrapper-side lowercase / trim / re-order / silent-field-swap
16856    // regression on the two-field `{ nome: nome.to_string(), caminho:
16857    // caminho.to_string() }` construction surfaces here rather than at
16858    // a downstream diagnostic-shape mismatch. Peer of the sibling
16859    // `empty_child_version_ctor_matches_struct_literal_wrap` /
16860    // `contrato_endpoint_empty_ctor_matches_struct_literal_wrap` /
16861    // `entrada_host_invalid_ctor_matches_struct_literal_wrap` /
16862    // `nome_only_ctor_routes_caixa_through_nome_accessor` equivalence
16863    // pins on the peer `SupervisorError` / `AplicacaoError` /
16864    // `LayoutError` / `LimitsError` / `UpgradeError` envelopes.
16865
16866    #[test]
16867    fn fonte_caminho_absolute_ctor_matches_struct_literal_wrap() {
16868        assert_eq!(
16869            DepError::fonte_caminho_absolute("caixa-teia", "/home/me/work/caixa-teia"),
16870            DepError::FonteCaminhoAbsolute {
16871                nome: "caixa-teia".to_string(),
16872                caminho: "/home/me/work/caixa-teia".to_string(),
16873            },
16874            "generated fonte_caminho_absolute ctor must produce byte-equal \
16875             DepError to the open-coded struct-literal wrap on the same \
16876             (&str, &str) fixture",
16877        );
16878    }
16879
16880    #[test]
16881    fn fonte_caminho_tilde_expansion_ctor_matches_struct_literal_wrap() {
16882        assert_eq!(
16883            DepError::fonte_caminho_tilde_expansion("caixa-teia", "~/work/caixa-teia"),
16884            DepError::FonteCaminhoTildeExpansion {
16885                nome: "caixa-teia".to_string(),
16886                caminho: "~/work/caixa-teia".to_string(),
16887            },
16888        );
16889    }
16890
16891    #[test]
16892    fn fonte_caminho_var_expansion_ctor_matches_struct_literal_wrap() {
16893        assert_eq!(
16894            DepError::fonte_caminho_var_expansion("caixa-teia", "$HOME/work/caixa-teia"),
16895            DepError::FonteCaminhoVarExpansion {
16896                nome: "caixa-teia".to_string(),
16897                caminho: "$HOME/work/caixa-teia".to_string(),
16898            },
16899        );
16900    }
16901
16902    #[test]
16903    fn fonte_caminho_leading_whitespace_ctor_matches_struct_literal_wrap() {
16904        assert_eq!(
16905            DepError::fonte_caminho_leading_whitespace("caixa-teia", " ../caixa-teia"),
16906            DepError::FonteCaminhoLeadingWhitespace {
16907                nome: "caixa-teia".to_string(),
16908                caminho: " ../caixa-teia".to_string(),
16909            },
16910        );
16911    }
16912
16913    #[test]
16914    fn fonte_caminho_leading_hyphen_ctor_matches_struct_literal_wrap() {
16915        assert_eq!(
16916            DepError::fonte_caminho_leading_hyphen("caixa-teia", "-rf"),
16917            DepError::FonteCaminhoLeadingHyphen {
16918                nome: "caixa-teia".to_string(),
16919                caminho: "-rf".to_string(),
16920            },
16921        );
16922    }
16923
16924    #[test]
16925    fn fonte_caminho_backslash_ctor_matches_struct_literal_wrap() {
16926        assert_eq!(
16927            DepError::fonte_caminho_backslash("caixa-teia", "..\\caixa-teia"),
16928            DepError::FonteCaminhoBackslash {
16929                nome: "caixa-teia".to_string(),
16930                caminho: "..\\caixa-teia".to_string(),
16931            },
16932        );
16933    }
16934
16935    #[test]
16936    fn fonte_caminho_shell_pipe_ctor_matches_struct_literal_wrap() {
16937        assert_eq!(
16938            DepError::fonte_caminho_shell_pipe("caixa-teia", "../caixa-teia|evil"),
16939            DepError::FonteCaminhoShellPipe {
16940                nome: "caixa-teia".to_string(),
16941                caminho: "../caixa-teia|evil".to_string(),
16942            },
16943        );
16944    }
16945
16946    #[test]
16947    fn fonte_caminho_shell_semicolon_ctor_matches_struct_literal_wrap() {
16948        assert_eq!(
16949            DepError::fonte_caminho_shell_semicolon("caixa-teia", "../caixa-teia;evil"),
16950            DepError::FonteCaminhoShellSemicolon {
16951                nome: "caixa-teia".to_string(),
16952                caminho: "../caixa-teia;evil".to_string(),
16953            },
16954        );
16955    }
16956
16957    #[test]
16958    fn fonte_caminho_shell_background_ctor_matches_struct_literal_wrap() {
16959        assert_eq!(
16960            DepError::fonte_caminho_shell_background("caixa-teia", "../caixa-teia&"),
16961            DepError::FonteCaminhoShellBackground {
16962                nome: "caixa-teia".to_string(),
16963                caminho: "../caixa-teia&".to_string(),
16964            },
16965        );
16966    }
16967
16968    #[test]
16969    fn fonte_caminho_shell_command_substitution_ctor_matches_struct_literal_wrap() {
16970        assert_eq!(
16971            DepError::fonte_caminho_shell_command_substitution(
16972                "caixa-teia",
16973                "../caixa-teia`whoami`",
16974            ),
16975            DepError::FonteCaminhoShellCommandSubstitution {
16976                nome: "caixa-teia".to_string(),
16977                caminho: "../caixa-teia`whoami`".to_string(),
16978            },
16979        );
16980    }
16981
16982    #[test]
16983    fn fonte_caminho_trailing_slash_ctor_matches_struct_literal_wrap() {
16984        assert_eq!(
16985            DepError::fonte_caminho_trailing_slash("caixa-teia", "../caixa-teia/"),
16986            DepError::FonteCaminhoTrailingSlash {
16987                nome: "caixa-teia".to_string(),
16988                caminho: "../caixa-teia/".to_string(),
16989            },
16990        );
16991    }
16992
16993    #[test]
16994    fn fonte_caminho_ctors_route_nome_and_caminho_through_to_string() {
16995        // Cross-axis pin: sweep the two constructor input axes
16996        // (`nome: &str`, `caminho: &str`) through a non-default fixture
16997        // pair against every generated arm in the
16998        // [`fonte_caminho_ctors!`] macro, so any wrapper-side lowercase
16999        // / trim / truncate / re-order on the two-field
17000        // `{ nome, caminho }` construction — or a silent field swap
17001        // between the two axes at codegen time — surfaces here rather
17002        // than at a downstream diagnostic-shape mismatch. Peer of the
17003        // sibling `supervisor_caixa_only_ctors_route_caixa_through_
17004        // to_string` cross-axis routing pin on the peer
17005        // `SupervisorError` envelope, extended here onto the
17006        // `DepError` `{ nome: String, caminho: String }` envelope so
17007        // every substrate-primitive ctor family in caixa-core
17008        // guarantees each `&str`-field construction routes the
17009        // caller's `&str` verbatim through `.to_string()`.
17010        let nome = "sibling-teia";
17011        let caminho = "../workspace/sibling";
17012        let cases: [(DepError, DepError); 11] = [
17013            (
17014                DepError::fonte_caminho_absolute(nome, caminho),
17015                DepError::FonteCaminhoAbsolute {
17016                    nome: nome.to_string(),
17017                    caminho: caminho.to_string(),
17018                },
17019            ),
17020            (
17021                DepError::fonte_caminho_tilde_expansion(nome, caminho),
17022                DepError::FonteCaminhoTildeExpansion {
17023                    nome: nome.to_string(),
17024                    caminho: caminho.to_string(),
17025                },
17026            ),
17027            (
17028                DepError::fonte_caminho_var_expansion(nome, caminho),
17029                DepError::FonteCaminhoVarExpansion {
17030                    nome: nome.to_string(),
17031                    caminho: caminho.to_string(),
17032                },
17033            ),
17034            (
17035                DepError::fonte_caminho_leading_whitespace(nome, caminho),
17036                DepError::FonteCaminhoLeadingWhitespace {
17037                    nome: nome.to_string(),
17038                    caminho: caminho.to_string(),
17039                },
17040            ),
17041            (
17042                DepError::fonte_caminho_leading_hyphen(nome, caminho),
17043                DepError::FonteCaminhoLeadingHyphen {
17044                    nome: nome.to_string(),
17045                    caminho: caminho.to_string(),
17046                },
17047            ),
17048            (
17049                DepError::fonte_caminho_backslash(nome, caminho),
17050                DepError::FonteCaminhoBackslash {
17051                    nome: nome.to_string(),
17052                    caminho: caminho.to_string(),
17053                },
17054            ),
17055            (
17056                DepError::fonte_caminho_shell_pipe(nome, caminho),
17057                DepError::FonteCaminhoShellPipe {
17058                    nome: nome.to_string(),
17059                    caminho: caminho.to_string(),
17060                },
17061            ),
17062            (
17063                DepError::fonte_caminho_shell_semicolon(nome, caminho),
17064                DepError::FonteCaminhoShellSemicolon {
17065                    nome: nome.to_string(),
17066                    caminho: caminho.to_string(),
17067                },
17068            ),
17069            (
17070                DepError::fonte_caminho_shell_background(nome, caminho),
17071                DepError::FonteCaminhoShellBackground {
17072                    nome: nome.to_string(),
17073                    caminho: caminho.to_string(),
17074                },
17075            ),
17076            (
17077                DepError::fonte_caminho_shell_command_substitution(nome, caminho),
17078                DepError::FonteCaminhoShellCommandSubstitution {
17079                    nome: nome.to_string(),
17080                    caminho: caminho.to_string(),
17081                },
17082            ),
17083            (
17084                DepError::fonte_caminho_trailing_slash(nome, caminho),
17085                DepError::FonteCaminhoTrailingSlash {
17086                    nome: nome.to_string(),
17087                    caminho: caminho.to_string(),
17088                },
17089            ),
17090        ];
17091        for (via_ctor, via_struct_literal) in cases {
17092            assert_eq!(
17093                via_ctor, via_struct_literal,
17094                "fonte_caminho_ctors!-generated ctor must route (nome, caminho) \
17095                 through `.to_string()` in declared field order — a field-swap or \
17096                 silent-conversion regression surfaces here rather than at a \
17097                 downstream diagnostic-shape mismatch",
17098            );
17099        }
17100    }
17101
17102    // ── `dep_nome_only_ctors!` — the paired `{ nome: String }` single-slot
17103    //    envelope on `DepError`, sibling of the peer `fonte_caminho_ctors!`
17104    //    (f85f145) on the `{ nome, caminho }` two-slot envelope of the same
17105    //    enum, and of `supervisor_caixa_only_ctors!` (db09650) on the peer
17106    //    `SupervisorError` envelope's `{ caixa: String }` single-slot axis.
17107
17108    #[test]
17109    fn versao_empty_ctor_matches_struct_literal_wrap() {
17110        assert_eq!(
17111            DepError::versao_empty("caixa-teia"),
17112            DepError::VersaoEmpty {
17113                nome: "caixa-teia".to_string(),
17114            },
17115        );
17116    }
17117
17118    #[test]
17119    fn fonte_repo_empty_ctor_matches_struct_literal_wrap() {
17120        assert_eq!(
17121            DepError::fonte_repo_empty("caixa-teia"),
17122            DepError::FonteRepoEmpty {
17123                nome: "caixa-teia".to_string(),
17124            },
17125        );
17126    }
17127
17128    #[test]
17129    fn fonte_pin_missing_ctor_matches_struct_literal_wrap() {
17130        assert_eq!(
17131            DepError::fonte_pin_missing("caixa-teia"),
17132            DepError::FontePinMissing {
17133                nome: "caixa-teia".to_string(),
17134            },
17135        );
17136    }
17137
17138    #[test]
17139    fn fonte_caminho_empty_ctor_matches_struct_literal_wrap() {
17140        assert_eq!(
17141            DepError::fonte_caminho_empty("caixa-teia"),
17142            DepError::FonteCaminhoEmpty {
17143                nome: "caixa-teia".to_string(),
17144            },
17145        );
17146    }
17147
17148    #[test]
17149    fn caracteristica_empty_ctor_matches_struct_literal_wrap() {
17150        assert_eq!(
17151            DepError::caracteristica_empty("caixa-teia"),
17152            DepError::CaracteristicaEmpty {
17153                nome: "caixa-teia".to_string(),
17154            },
17155        );
17156    }
17157
17158    #[test]
17159    fn dep_nome_only_ctors_route_nome_through_to_string() {
17160        // Cross-axis routing pin: sweep the single constructor input
17161        // axis (`nome: &str`) through a non-default fixture against
17162        // every generated arm in the [`dep_nome_only_ctors!`] macro, so
17163        // any wrapper-side lowercase / trim / truncate at codegen time
17164        // — or a silent field re-name away from the canonical `nome`
17165        // axis on any one variant — surfaces here rather than at a
17166        // downstream diagnostic-shape mismatch. Peer of the sibling
17167        // `fonte_caminho_ctors_route_nome_and_caminho_through_
17168        // to_string` cross-axis routing pin on the same envelope's
17169        // two-slot family (f85f145) and of the peer
17170        // `supervisor_caixa_only_ctors_route_caixa_through_to_string`
17171        // pin on the `SupervisorError` single-slot family (db09650).
17172        let nome = "sibling-teia";
17173        let cases: [(DepError, DepError); 5] = [
17174            (
17175                DepError::versao_empty(nome),
17176                DepError::VersaoEmpty {
17177                    nome: nome.to_string(),
17178                },
17179            ),
17180            (
17181                DepError::fonte_repo_empty(nome),
17182                DepError::FonteRepoEmpty {
17183                    nome: nome.to_string(),
17184                },
17185            ),
17186            (
17187                DepError::fonte_pin_missing(nome),
17188                DepError::FontePinMissing {
17189                    nome: nome.to_string(),
17190                },
17191            ),
17192            (
17193                DepError::fonte_caminho_empty(nome),
17194                DepError::FonteCaminhoEmpty {
17195                    nome: nome.to_string(),
17196                },
17197            ),
17198            (
17199                DepError::caracteristica_empty(nome),
17200                DepError::CaracteristicaEmpty {
17201                    nome: nome.to_string(),
17202                },
17203            ),
17204        ];
17205        for (via_ctor, via_struct_literal) in cases {
17206            assert_eq!(
17207                via_ctor, via_struct_literal,
17208                "dep_nome_only_ctors!-generated ctor must route `nome` \
17209                 through `.to_string()` onto the canonical `nome` field \
17210                 — a field-rename or silent-conversion regression surfaces \
17211                 here rather than at a downstream diagnostic-shape mismatch",
17212            );
17213        }
17214    }
17215
17216    // ── `dep_nome_list_ctors!` — the paired `{ nome: String, list:
17217    //    &'static str }` two-slot envelope on `DepError`, strict
17218    //    sibling of the peer `dep_nome_only_ctors!` (792aa92) on the
17219    //    same envelope's `{ nome: String }` one-slot shape and of the
17220    //    peer `supervisor_caixa_only_ctors!` (db09650) on the
17221    //    `SupervisorError` envelope's `{ caixa: String }` one-slot axis.
17222
17223    #[test]
17224    fn duplicate_nome_ctor_matches_struct_literal_wrap() {
17225        assert_eq!(
17226            DepError::duplicate_nome("caixa-teia", crate::render::DEP_AUTHOR_KEY_DEPS),
17227            DepError::DuplicateNome {
17228                nome: "caixa-teia".to_string(),
17229                list: crate::render::DEP_AUTHOR_KEY_DEPS,
17230            },
17231            "generated duplicate_nome ctor must produce byte-equal \
17232             `DepError::DuplicateNome` to the pre-lift struct-literal \
17233             wrap on the same scalar fixtures",
17234        );
17235    }
17236
17237    #[test]
17238    fn dep_is_self_ctor_matches_struct_literal_wrap() {
17239        assert_eq!(
17240            DepError::dep_is_self("orquestra", crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
17241            DepError::DepIsSelf {
17242                nome: "orquestra".to_string(),
17243                list: crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
17244            },
17245            "generated dep_is_self ctor must produce byte-equal \
17246             `DepError::DepIsSelf` to the pre-lift struct-literal \
17247             wrap on the same scalar fixtures",
17248        );
17249    }
17250
17251    #[test]
17252    fn dep_nome_list_ctors_route_nome_and_list_through_uniformly() {
17253        // Cross-axis routing pin: sweep the two constructor input axes
17254        // (`nome: &str`, `list: &'static str`) through non-default
17255        // fixtures against every generated arm in the
17256        // [`dep_nome_list_ctors!`] macro, so any wrapper-side
17257        // lowercase / trim / truncate at codegen time — or a silent
17258        // field re-name away from the canonical `nome` / `list` axes
17259        // on any one variant, or a `list` axis silently rerouted
17260        // through `.to_string()` instead of passed as `&'static str`
17261        // verbatim — surfaces here rather than at a downstream
17262        // diagnostic-shape mismatch. Peer of the sibling
17263        // `dep_nome_only_ctors_route_nome_through_to_string` pin
17264        // (792aa92) on the same envelope's one-slot family, and of the
17265        // peer
17266        // `supervisor_child_reason_ctors_route_reason_through_into_uniformly`
17267        // pin (d2ef2ec) on the sibling `SupervisorError` envelope's
17268        // two-slot `{ caixa: String, reason: String }` shape.
17269        let nome = "sibling-teia";
17270        let cases: [(DepError, DepError); 4] = [
17271            (
17272                DepError::duplicate_nome(nome, crate::render::DEP_AUTHOR_KEY_DEPS),
17273                DepError::DuplicateNome {
17274                    nome: nome.to_string(),
17275                    list: crate::render::DEP_AUTHOR_KEY_DEPS,
17276                },
17277            ),
17278            (
17279                DepError::duplicate_nome(nome, crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
17280                DepError::DuplicateNome {
17281                    nome: nome.to_string(),
17282                    list: crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
17283                },
17284            ),
17285            (
17286                DepError::dep_is_self(nome, crate::render::DEP_AUTHOR_KEY_DEPS),
17287                DepError::DepIsSelf {
17288                    nome: nome.to_string(),
17289                    list: crate::render::DEP_AUTHOR_KEY_DEPS,
17290                },
17291            ),
17292            (
17293                DepError::dep_is_self(nome, crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
17294                DepError::DepIsSelf {
17295                    nome: nome.to_string(),
17296                    list: crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
17297                },
17298            ),
17299        ];
17300        for (via_ctor, via_struct_literal) in cases {
17301            assert_eq!(
17302                via_ctor, via_struct_literal,
17303                "dep_nome_list_ctors!-generated ctor must route `nome` \
17304                 through `.to_string()` onto the canonical `nome` field \
17305                 and pass `list` verbatim onto the canonical `&'static str` \
17306                 `list` field — a field-rename, silent-conversion, or \
17307                 axis-swap regression surfaces here rather than at a \
17308                 downstream diagnostic-shape mismatch",
17309            );
17310        }
17311    }
17312
17313    // ── `fonte_pin_shape` — the paired `{ nome: String, pin: String,
17314    //    value: String, reason: String }` four-slot envelope on
17315    //    `DepError`, sibling of the peer `dep_nome_only_ctors!` (792aa92),
17316    //    `dep_nome_list_ctors!` (6f5e0cd), `fonte_caminho_ctors!` (f85f145),
17317    //    and `fonte_caminho_byte_ctors!` (0e35793) folds on the same
17318    //    envelope, and of the peer `contrato_pair_value_reason_ctors!`
17319    //    (14e13f1) four-slot fold on the sibling `AplicacaoError`
17320    //    envelope. Single-variant lift closing the last open-coded ctor
17321    //    site on the `:fonte (:tipo git …)` value-shape trajectory.
17322
17323    #[test]
17324    fn fonte_pin_shape_ctor_matches_struct_literal_wrap() {
17325        // Pre-lift equivalence pin on the [`DepError::fonte_pin_shape`]
17326        // ctor: sweep both wire-up-shape arms (the refname-pin arm
17327        // routing `":tag"` / `":branch"` value through
17328        // [`crate::render::is_git_ref_name`], and the hex-OID-pin arm
17329        // routing `":rev"` through [`crate::render::is_git_oid`]) and
17330        // assert byte-equal `PartialEq` against the pre-lift
17331        // struct-literal, so any wrapper-side field-rename /
17332        // silent-conversion regression surfaces here rather than at a
17333        // downstream diagnostic-shape mismatch. Peer of the sibling
17334        // per-envelope byte-equal ctor pins
17335        // ([`fonte_pin_missing_ctor_matches_struct_literal_wrap`],
17336        // [`duplicate_nome_ctor_matches_struct_literal_wrap`],
17337        // [`dep_is_self_ctor_matches_struct_literal_wrap`]).
17338        assert_eq!(
17339            DepError::fonte_pin_shape(
17340                "caixa-teia",
17341                ":tag",
17342                "v0.1.0 ",
17343                "trailing whitespace".to_string(),
17344            ),
17345            DepError::FontePinShape {
17346                nome: "caixa-teia".to_string(),
17347                pin: ":tag".to_string(),
17348                value: "v0.1.0 ".to_string(),
17349                reason: "trailing whitespace".to_string(),
17350            },
17351            "fonte_pin_shape ctor must produce byte-equal \
17352             `DepError::FontePinShape` to the pre-lift struct-literal \
17353             wrap on a refname-pin (`:tag` / `:branch`) fixture",
17354        );
17355        assert_eq!(
17356            DepError::fonte_pin_shape(
17357                "caixa-teia",
17358                ":rev",
17359                "DEADBEEF",
17360                "abbreviated OID rejected".to_string(),
17361            ),
17362            DepError::FontePinShape {
17363                nome: "caixa-teia".to_string(),
17364                pin: ":rev".to_string(),
17365                value: "DEADBEEF".to_string(),
17366                reason: "abbreviated OID rejected".to_string(),
17367            },
17368            "fonte_pin_shape ctor must produce byte-equal \
17369             `DepError::FontePinShape` to the pre-lift struct-literal \
17370             wrap on a hex-OID-pin (`:rev`) fixture",
17371        );
17372    }
17373
17374    #[test]
17375    fn fonte_pin_shape_ctor_routes_all_four_axes_through_to_string() {
17376        // Cross-axis routing pin: sweep every one of the four
17377        // constructor input axes (`nome: &str`, `pin: &str`,
17378        // `value: &str`, `reason: String`) through non-default
17379        // fixtures against the [`DepError::fonte_pin_shape`] ctor, so
17380        // any wrapper-side lowercase / trim / truncate at codegen time
17381        // — or a silent field re-name / axis-swap on any one of the
17382        // four fields, or a `reason` axis silently routed through
17383        // `.to_string()` instead of forwarded owned — surfaces here
17384        // rather than at a downstream diagnostic-shape mismatch. Peer
17385        // of the sibling
17386        // `dep_nome_only_ctors_route_nome_through_to_string` pin
17387        // (792aa92) and
17388        // `dep_nome_list_ctors_route_nome_and_list_through_uniformly`
17389        // pin (6f5e0cd) on the same envelope's one- and two-slot
17390        // families. Distinct-per-axis fixtures rule out any two-axis
17391        // swap (`nome` ↔ `pin`, `pin` ↔ `value`, `value` ↔ `reason`,
17392        // etc.) that would still pass a same-fixture-per-axis pin.
17393        let nome = "sibling-teia";
17394        let pin = ":branch";
17395        let value = "feature/bar";
17396        let reason = "embedded space".to_string();
17397        let via_ctor = DepError::fonte_pin_shape(nome, pin, value, reason.clone());
17398        let via_struct_literal = DepError::FontePinShape {
17399            nome: nome.to_string(),
17400            pin: pin.to_string(),
17401            value: value.to_string(),
17402            reason: reason.clone(),
17403        };
17404        assert_eq!(
17405            via_ctor, via_struct_literal,
17406            "fonte_pin_shape ctor must route `nome` / `pin` / `value` \
17407             through `.to_string()` onto their canonical fields and \
17408             forward `reason` owned onto the canonical `reason` field \
17409             — a field-rename, silent-conversion, or axis-swap \
17410             regression surfaces here rather than at a downstream \
17411             diagnostic-shape mismatch",
17412        );
17413        let DepError::FontePinShape {
17414            nome: n,
17415            pin: p,
17416            value: v,
17417            reason: r,
17418        } = via_ctor
17419        else {
17420            panic!("fonte_pin_shape ctor produced non-FontePinShape variant")
17421        };
17422        assert_eq!(n, nome);
17423        assert_eq!(p, pin);
17424        assert_eq!(v, value);
17425        assert_eq!(r, reason);
17426    }
17427
17428    // ── `fonte_caminho_byte_ctors!` — the paired `{ nome: String,
17429    //    caminho: String, byte: u8 }` three-slot envelope on `DepError`,
17430    //    strict sibling of the peer `fonte_caminho_ctors!` (f85f145) on
17431    //    the same envelope's `{ nome: String, caminho: String }` two-slot
17432    //    shape, and of the peer `dep_nome_only_ctors!` (792aa92) on the
17433    //    same envelope's `{ nome: String }` one-slot shape.
17434
17435    #[test]
17436    fn fonte_caminho_control_char_ctor_matches_struct_literal_wrap() {
17437        assert_eq!(
17438            DepError::fonte_caminho_control_char("caixa-teia", "../caixa-teia\x00foo", 0x00),
17439            DepError::FonteCaminhoControlChar {
17440                nome: "caixa-teia".to_string(),
17441                caminho: "../caixa-teia\x00foo".to_string(),
17442                byte: 0x00,
17443            },
17444        );
17445    }
17446
17447    #[test]
17448    fn fonte_caminho_shell_redirection_ctor_matches_struct_literal_wrap() {
17449        assert_eq!(
17450            DepError::fonte_caminho_shell_redirection("caixa-teia", "../caixa-teia>log", b'>'),
17451            DepError::FonteCaminhoShellRedirection {
17452                nome: "caixa-teia".to_string(),
17453                caminho: "../caixa-teia>log".to_string(),
17454                byte: b'>',
17455            },
17456        );
17457    }
17458
17459    #[test]
17460    #[allow(
17461        clippy::too_many_lines,
17462        reason = "cross-axis routing pin sweeps twelve typed variants, one per \
17463                  byte-classification arm on the {nome,caminho,byte} envelope; \
17464                  the linear per-variant repetition is exactly what the sweep \
17465                  is pinning — a helper macro would hide the shape the fold is \
17466                  keying on"
17467    )]
17468    fn fonte_caminho_byte_ctors_route_nome_caminho_and_byte_through_to_string() {
17469        // Cross-axis routing pin: sweep the three constructor input axes
17470        // (`nome: &str`, `caminho: &str`, `byte: u8`) through a
17471        // non-default fixture triple against every generated arm in the
17472        // [`fonte_caminho_byte_ctors!`] macro, so any wrapper-side
17473        // lowercase / trim / truncate on the two `&str` axes — a silent
17474        // field swap between `nome` and `caminho`, or a silent
17475        // re-classification of the offending byte — surfaces here rather
17476        // than at a downstream diagnostic-shape mismatch. Peer of the
17477        // sibling `fonte_caminho_ctors_route_nome_and_caminho_through_
17478        // to_string` cross-axis routing pin on the same envelope's
17479        // two-slot family (f85f145) and of the sibling
17480        // `dep_nome_only_ctors_route_nome_through_to_string` pin on the
17481        // same envelope's one-slot family (792aa92), extended here onto
17482        // the `{ nome: String, caminho: String, byte: u8 }` three-slot
17483        // envelope so every substrate-primitive ctor family in
17484        // caixa-core's `DepError` envelope guarantees each field routes
17485        // the caller's value verbatim through `.to_string()` (or byte-
17486        // identity for `byte: u8`) in declared field order.
17487        let nome = "sibling-teia";
17488        let caminho = "../workspace/sibling";
17489        let byte = 0x2A_u8;
17490        let cases: [(DepError, DepError); 12] = [
17491            (
17492                DepError::fonte_caminho_control_char(nome, caminho, byte),
17493                DepError::FonteCaminhoControlChar {
17494                    nome: nome.to_string(),
17495                    caminho: caminho.to_string(),
17496                    byte,
17497                },
17498            ),
17499            (
17500                DepError::fonte_caminho_shell_redirection(nome, caminho, byte),
17501                DepError::FonteCaminhoShellRedirection {
17502                    nome: nome.to_string(),
17503                    caminho: caminho.to_string(),
17504                    byte,
17505                },
17506            ),
17507            (
17508                DepError::fonte_caminho_shell_glob(nome, caminho, byte),
17509                DepError::FonteCaminhoShellGlob {
17510                    nome: nome.to_string(),
17511                    caminho: caminho.to_string(),
17512                    byte,
17513                },
17514            ),
17515            (
17516                DepError::fonte_caminho_shell_subshell_grouping(nome, caminho, byte),
17517                DepError::FonteCaminhoShellSubshellGrouping {
17518                    nome: nome.to_string(),
17519                    caminho: caminho.to_string(),
17520                    byte,
17521                },
17522            ),
17523            (
17524                DepError::fonte_caminho_shell_brace_expansion(nome, caminho, byte),
17525                DepError::FonteCaminhoShellBraceExpansion {
17526                    nome: nome.to_string(),
17527                    caminho: caminho.to_string(),
17528                    byte,
17529                },
17530            ),
17531            (
17532                DepError::fonte_caminho_shell_bracket_expansion(nome, caminho, byte),
17533                DepError::FonteCaminhoShellBracketExpansion {
17534                    nome: nome.to_string(),
17535                    caminho: caminho.to_string(),
17536                    byte,
17537                },
17538            ),
17539            (
17540                DepError::fonte_caminho_shell_quote_grouping(nome, caminho, byte),
17541                DepError::FonteCaminhoShellQuoteGrouping {
17542                    nome: nome.to_string(),
17543                    caminho: caminho.to_string(),
17544                    byte,
17545                },
17546            ),
17547            (
17548                DepError::fonte_caminho_shell_comment(nome, caminho, byte),
17549                DepError::FonteCaminhoShellComment {
17550                    nome: nome.to_string(),
17551                    caminho: caminho.to_string(),
17552                    byte,
17553                },
17554            ),
17555            (
17556                DepError::fonte_caminho_url_percent_encoding(nome, caminho, byte),
17557                DepError::FonteCaminhoUrlPercentEncoding {
17558                    nome: nome.to_string(),
17559                    caminho: caminho.to_string(),
17560                    byte,
17561                },
17562            ),
17563            (
17564                DepError::fonte_caminho_shell_variable_expansion(nome, caminho, byte),
17565                DepError::FonteCaminhoShellVariableExpansion {
17566                    nome: nome.to_string(),
17567                    caminho: caminho.to_string(),
17568                    byte,
17569                },
17570            ),
17571            (
17572                DepError::fonte_caminho_shell_history_expansion(nome, caminho, byte),
17573                DepError::FonteCaminhoShellHistoryExpansion {
17574                    nome: nome.to_string(),
17575                    caminho: caminho.to_string(),
17576                    byte,
17577                },
17578            ),
17579            (
17580                DepError::fonte_caminho_shell_history_substitution(nome, caminho, byte),
17581                DepError::FonteCaminhoShellHistorySubstitution {
17582                    nome: nome.to_string(),
17583                    caminho: caminho.to_string(),
17584                    byte,
17585                },
17586            ),
17587        ];
17588        for (via_ctor, via_struct_literal) in cases {
17589            assert_eq!(
17590                via_ctor, via_struct_literal,
17591                "fonte_caminho_byte_ctors!-generated ctor must route \
17592                 (nome, caminho, byte) through `.to_string()` / byte-\
17593                 identity in declared field order — a field-swap or \
17594                 silent-conversion regression surfaces here rather than \
17595                 at a downstream diagnostic-shape mismatch",
17596            );
17597        }
17598    }
17599
17600    #[test]
17601    fn dep_list_as_ref_str_routes_through_as_str_accessor() {
17602        // Fail-before-pass-after byte-parity pin on the lifted
17603        // `impl AsRef<str> for DepList` — asserts the standard-
17604        // library trait impl and the substrate-primitive
17605        // [`super::DepList::as_str`] `pub const fn` accessor resolve
17606        // to the same `&str` per instance across the two-arm closed
17607        // set, so any future silent detour that routes the impl
17608        // through a divergent projection (a per-arm inline
17609        // `match self { DepList::Prod => ":deps", … }` re-inlining
17610        // that opens a compile-time link to the un-lifted arm-literal,
17611        // a swap onto a second projection axis) trips at caixa-core
17612        // test time under `PartialEq` rather than at a downstream
17613        // `impl AsRef<str>`-bound consumer's silent split. Sweeps
17614        // every one of the two arms [`super::DepList::ALL`] carries
17615        // so no arm's projection is covered only by the sibling
17616        // `Display` path. Peer of the sibling
17617        // `caixa_dialeto_as_ref_str_routes_through_as_str_accessor`
17618        // (1723611) on the top-level dialect-classification closed-
17619        // set typed enum, and the peer
17620        // `rate_limit_unit_as_ref_str_routes_through_as_suffix_accessor`
17621        // (d8136db) pin on the M3 `:politicas :rate-limit` closed-set
17622        // typed enum — the pins together close the substrate
17623        // primitive's `AsRef<str>` projection axis onto the seventh
17624        // (and last unlifted) closed-set typed enum on the caixa
17625        // surface.
17626        for &list in super::DepList::ALL {
17627            assert_eq!(
17628                <super::DepList as AsRef<str>>::as_ref(&list),
17629                list.as_str(),
17630                "AsRef<str> impl on DepList::{list:?} must byte-equal \
17631                 DepList::as_str on the same instance — divergence \
17632                 signals a silent detour off the substrate-primitive \
17633                 accessor"
17634            );
17635        }
17636    }
17637
17638    #[test]
17639    fn dep_list_as_ref_str_routes_through_display_via_shared_accessor() {
17640        // Fail-before-pass-after byte-parity pin on the three-path
17641        // convergence discipline the [`super::DepList`] two-list
17642        // dep-graph closed-set typed enum now carries on the `&str`-
17643        // projection axis: `<DepList as AsRef<str>>::as_ref(&v)` (the
17644        // newly lifted impl), `format!("{v}")` (the pre-existing
17645        // [`fmt::Display`] impl), and `v.as_str()` (the substrate-
17646        // primitive `pub const fn` accessor both trait impls delegate
17647        // through) must resolve to the same byte-string on every
17648        // instance across the two-arm closed set. Refuses any future
17649        // divergence between the two trait impls (a stray
17650        // [`fmt::Display::fmt`] rewrite that hand-rolls the arms
17651        // rather than delegating through the shared accessor; a
17652        // hypothetical `AsRef<str>` rewrite that inlines a per-arm
17653        // literal cascade) that would silently split the two
17654        // projection paths of the same closed-set typed enum. Mirrors
17655        // the sibling three-path-convergence discipline the peer
17656        // [`crate::CaixaDialeto`] typed enum carries
17657        // (`caixa_dialeto_as_ref_str_routes_through_display_via_shared_accessor`,
17658        // 1723611), the peer [`crate::aplicacao::RateLimitUnit`] triple
17659        // (`rate_limit_unit_as_ref_str_routes_through_display_via_shared_accessor`,
17660        // d8136db), the peer [`crate::CaixaKind`] triple
17661        // (`caixa_kind_as_ref_str_routes_through_display_via_shared_accessor`,
17662        // cd2091f), and the [`crate::CaixaVersion`] typed newtype
17663        // triple (`caixa_version_as_ref_str_routes_through_display_via_shared_accessor`,
17664        // 16d5c7e).
17665        for &list in super::DepList::ALL {
17666            let via_as_ref: &str = <super::DepList as AsRef<str>>::as_ref(&list);
17667            let via_display: String = format!("{list}");
17668            let via_accessor: &str = list.as_str();
17669            assert_eq!(via_as_ref, via_accessor);
17670            assert_eq!(via_display, via_accessor);
17671            assert_eq!(via_as_ref, via_display.as_str());
17672        }
17673    }
17674
17675    #[test]
17676    fn dep_list_try_from_str_routes_through_from_wire_accessor() {
17677        // Fail-before-pass-after byte-parity pin on the newly lifted
17678        // `impl TryFrom<&str> for DepList` — asserts the standard-
17679        // library trait impl and the substrate-primitive
17680        // [`super::DepList::from_wire`] `Option<Self>` accessor resolve
17681        // to the same two-arm accept-set across every arm the
17682        // exhaustive [`super::DepList::ALL`] slice enumerates. Peer of
17683        // the sibling
17684        // `restart_strategy_try_from_str_routes_through_from_wire_accessor`
17685        // (5b828ed), `caixa_kind_try_from_str_routes_through_from_wire_accessor`,
17686        // and the 12 other substrate-wide trait-idiomatic reverse-
17687        // projection routes-through pins — closes the campaign's
17688        // completeness gap on the two-list dep-graph closed-set enum.
17689        for &list in super::DepList::ALL {
17690            let wire = list.as_str();
17691            assert_eq!(
17692                <super::DepList as TryFrom<&str>>::try_from(wire),
17693                Ok(list),
17694                "TryFrom<&str> impl on DepList must round-trip \
17695                 DepList::{list:?}.as_str() = {wire:?} back to \
17696                 Ok(DepList::{list:?}) — divergence from \
17697                 DepList::from_wire signals a silent detour off the \
17698                 substrate-primitive accessor"
17699            );
17700            assert_eq!(
17701                <super::DepList as TryFrom<&str>>::try_from(wire).ok(),
17702                super::DepList::from_wire(wire),
17703                "TryFrom<&str> ok()-projection on {wire:?} must byte-equal \
17704                 DepList::from_wire on the same input"
17705            );
17706        }
17707    }
17708
17709    #[test]
17710    fn dep_list_try_from_str_rejects_unknown_byte_strings() {
17711        // Rejection witness on the `impl TryFrom<&str> for DepList` —
17712        // sweeps candidate byte-strings outside the two-arm accept-set
17713        // the sibling [`super::DepList::as_str`] emits (`:deps` /
17714        // `:deps-dev`) and asserts every one lands on `Err(())`, so a
17715        // future accidental widening of the trait impl's accept-set (a
17716        // stray case-fold path, a silent inclusion of a rebrand alias
17717        // like `":packages"`, an English rebrand `":dev-deps"` in
17718        // reverse arm-order that would silently swap the two arms) trips
17719        // at caixa-core test time. Peer of the sibling
17720        // `restart_strategy_try_from_str_rejects_unknown_byte_strings`
17721        // (5b828ed) rejection witness.
17722        let rejected: &[&str] = &[
17723            "",
17724            " ",
17725            "\t",
17726            "\n",
17727            ":deps ",
17728            " :deps",
17729            ":DEPS",
17730            ":Deps",
17731            ":Deps-Dev",
17732            ":deps_dev",
17733            ":deps-development",
17734            ":dev-deps",
17735            ":packages",
17736            ":packages-dev",
17737            "deps",
17738            "deps-dev",
17739            "Prod",
17740            "Dev",
17741            "prod",
17742            "dev",
17743            "\":deps\"",
17744            "\":deps-dev\"",
17745            ":deps\n",
17746            ":deps-dev\n",
17747        ];
17748        for &input in rejected {
17749            assert_eq!(
17750                <super::DepList as TryFrom<&str>>::try_from(input),
17751                Err(()),
17752                "TryFrom<&str> impl on DepList must reject unknown \
17753                 byte-string {input:?} — divergence from \
17754                 DepList::from_wire on the same input signals a silent \
17755                 accept-set widening past the two lifted \
17756                 crate::render::DEP_AUTHOR_KEY_DEPS* wire constants"
17757            );
17758            assert_eq!(
17759                <super::DepList as TryFrom<&str>>::try_from(input).ok(),
17760                super::DepList::from_wire(input),
17761                "TryFrom<&str> ok()-projection on {input:?} must byte-equal \
17762                 DepList::from_wire on the same input — divergence signals \
17763                 the two reverse-projection paths have drifted onto \
17764                 different accept-sets"
17765            );
17766        }
17767    }
17768
17769    #[test]
17770    fn dep_list_from_into_static_str_routes_through_as_str_accessor() {
17771        // Fail-before-pass-after byte-parity pin on the newly lifted
17772        // `impl From<DepList> for &'static str` — asserts the standard-
17773        // library trait impl and the substrate-primitive
17774        // [`super::DepList::as_str`] `pub const fn` accessor resolve to
17775        // the same two-arm emit-set across every arm the exhaustive
17776        // [`super::DepList::ALL`] slice enumerates. Materializes the
17777        // `<&'static str as From<DepList>>::from` output in a
17778        // `const`-shape binding to make the `'static` lifetime promise
17779        // a build-time invariant — a future accidental downgrade of
17780        // either arm to a non-`&'static str` (a `String::leak()`-
17781        // produced return, a `Box::leak`-cast) trips at caixa-core
17782        // build time rather than at a downstream `'static`-bound
17783        // consumer. Peer of the sibling
17784        // `restart_strategy_from_into_static_str_routes_through_as_str_accessor`
17785        // (523157d) and the 13 other substrate-wide forward-projection
17786        // routes-through pins.
17787        const PROD: &str = super::DepList::Prod.as_str();
17788        const DEV: &str = super::DepList::Dev.as_str();
17789        for &list in super::DepList::ALL {
17790            let via_trait: &'static str = <&'static str as From<super::DepList>>::from(list);
17791            let via_method: &'static str = list.as_str();
17792            assert_eq!(
17793                via_trait, via_method,
17794                "From<DepList> for &'static str impl must round-trip \
17795                 DepList::{list:?} to the same lifted \
17796                 crate::render::DEP_AUTHOR_KEY_DEPS* const \
17797                 DepList::as_str returns — divergence signals a silent \
17798                 detour off the substrate-primitive accessor"
17799            );
17800            let via_into: &'static str = list.into();
17801            assert_eq!(
17802                via_into, via_method,
17803                "Into<&'static str>::into on DepList::{list:?} must \
17804                 byte-equal DepList::as_str on the same input — the \
17805                 blanket-derived Into shape must resolve to the same \
17806                 as_str dispatch as the explicit From impl"
17807            );
17808        }
17809        assert_eq!(
17810            [PROD, DEV],
17811            [
17812                crate::render::DEP_AUTHOR_KEY_DEPS,
17813                crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
17814            ],
17815            "const-context DepList::as_str must resolve to the two lifted \
17816             DEP_AUTHOR_KEY_DEPS* consts — a future accidental downgrade \
17817             of either arm to a non-const or non-static byte-string breaks \
17818             the `&'static str`-lifetime promise the paired \
17819             From<DepList> for &'static str impl carries by construction"
17820        );
17821    }
17822
17823    #[test]
17824    fn dep_list_from_into_static_str_and_as_str_partition_the_emit_set() {
17825        // Cross-axis partition pin: the paired trait-idiomatic
17826        // `From<DepList> for &'static str` forward projection and the
17827        // method-named [`super::DepList::as_str`] forward projection
17828        // must resolve identically on every arm, locking the two paths
17829        // together so any future detour trips at caixa-core test time.
17830        // Then a round-trip witness: every arm's forward `From` output
17831        // re-parses through the paired trait-idiomatic reverse
17832        // `TryFrom<&str>` back to the original variant, closing the
17833        // two-way `DepList ↔ &'static str` round-trip on the trait-
17834        // idiomatic axis pair, mirroring the pre-existing method-named
17835        // `as_str` + `from_wire` round-trip. Peer of the sibling
17836        // `restart_strategy_from_into_static_str_and_as_str_partition_the_emit_set`
17837        // (523157d).
17838        for &list in super::DepList::ALL {
17839            let via_trait: &'static str = <&'static str as From<super::DepList>>::from(list);
17840            let via_method: &'static str = list.as_str();
17841            assert_eq!(
17842                via_trait, via_method,
17843                "From<DepList> for &'static str and DepList::as_str must \
17844                 resolve identically on DepList::{list:?} — divergence \
17845                 signals the two forward-projection paths have drifted \
17846                 onto different emit-sets"
17847            );
17848        }
17849        for &list in super::DepList::ALL {
17850            let emitted: &'static str = list.into();
17851            let re_parsed: Result<super::DepList, ()> =
17852                <super::DepList as TryFrom<&str>>::try_from(emitted);
17853            assert_eq!(
17854                re_parsed,
17855                Ok(list),
17856                "trait-idiomatic axis pair must round-trip \
17857                 DepList::{list:?} through `.into::<&'static str>()` and \
17858                 back through `TryFrom<&str>` — a break signals the \
17859                 forward-emit and reverse-parse axes have drifted onto \
17860                 different vocabularies"
17861            );
17862        }
17863    }
17864
17865    #[test]
17866    fn dep_list_from_borrowed_into_static_str_routes_through_as_str_accessor() {
17867        // Fail-before-pass-after byte-parity pin on the newly lifted
17868        // `impl From<&DepList> for &'static str` — asserts the borrowed-
17869        // input standard-library trait impl and the substrate-primitive
17870        // [`super::DepList::as_str`] `pub const fn` accessor resolve to
17871        // the same two-arm emit-set across every arm the exhaustive
17872        // [`super::DepList::ALL`] slice enumerates. Rust's `From` trait
17873        // does not auto-derive the borrowed-input sibling from a paired
17874        // owned-input impl (no `impl<T, U> From<&T> for U where T: Copy,
17875        // U: From<T>` blanket in `core`), so the borrowed-input axis is
17876        // a distinct trait-idiomatic surface that a `.iter().map(Into::into)`
17877        // shape over [`super::DepList::ALL`] (whose iterator yields
17878        // `&DepList`, not `DepList`) reaches through this impl and no
17879        // other — the paired owned-input [`From<DepList>`] impl requires
17880        // an explicit `.copied()` / dereference before the trait fires.
17881        // Materializes the `<&'static str as From<&DepList>>::from`
17882        // output in a `const`-shape binding to make the `'static`
17883        // lifetime promise a build-time invariant.
17884        const PROD: &str = super::DepList::Prod.as_str();
17885        const DEV: &str = super::DepList::Dev.as_str();
17886        for list in super::DepList::ALL {
17887            let via_trait: &'static str = <&'static str as From<&super::DepList>>::from(list);
17888            let via_method: &'static str = list.as_str();
17889            assert_eq!(
17890                via_trait, via_method,
17891                "From<&DepList> for &'static str impl must round-trip \
17892                 &DepList::{list:?} to the same lifted \
17893                 crate::render::DEP_AUTHOR_KEY_DEPS* const \
17894                 DepList::as_str returns — divergence signals a silent \
17895                 detour off the substrate-primitive accessor"
17896            );
17897            let via_into: &'static str = list.into();
17898            assert_eq!(
17899                via_into, via_method,
17900                "Into<&'static str>::into on &DepList::{list:?} must \
17901                 byte-equal DepList::as_str on the same input — the \
17902                 blanket-derived Into shape must resolve to the same \
17903                 as_str dispatch as the explicit From impl"
17904            );
17905        }
17906        assert_eq!(
17907            [PROD, DEV],
17908            [
17909                crate::render::DEP_AUTHOR_KEY_DEPS,
17910                crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
17911            ],
17912            "const-context DepList::as_str must resolve to the two lifted \
17913             DEP_AUTHOR_KEY_DEPS* consts — the borrowed-input \
17914             From<&DepList> for &'static str impl inherits its `'static` \
17915             lifetime promise from the same accessor the owned-input \
17916             sibling routes through"
17917        );
17918    }
17919
17920    #[test]
17921    fn dep_list_from_owned_and_borrowed_into_static_str_agree_on_every_arm() {
17922        // Cross-axis partition pin: the paired trait-idiomatic
17923        // owned-input `From<DepList> for &'static str` (523157d
17924        // campaign-shape) and borrowed-input `From<&DepList> for
17925        // &'static str` (this lift) forward projections must resolve
17926        // identically on every arm, locking the two input-shape paths
17927        // together so any future detour trips at caixa-core test time.
17928        // Then a witness that a `.iter().map(Into::into)` pipe over
17929        // [`super::DepList::ALL`] (whose iterator yields `&DepList`)
17930        // materializes the two-arm accept-set through the borrowed-
17931        // input axis alone — the exact shape a future M4 admission-
17932        // webhook rejection body composer, a future substrate-wide
17933        // per-arm diagnostic column, or a
17934        // `HashMap::<&'static str, DepList>::from_iter(DepList::ALL.iter()
17935        //     .map(|l| (l.into(), *l)))`-style per-list lookup reaches
17936        // through — closing the two-way owned/borrowed input-shape
17937        // symmetry on the forward-projection trait-idiomatic axis.
17938        for &list in super::DepList::ALL {
17939            let owned: &'static str = <&'static str as From<super::DepList>>::from(list);
17940            let borrowed: &'static str = <&'static str as From<&super::DepList>>::from(&list);
17941            assert_eq!(
17942                owned, borrowed,
17943                "From<DepList> and From<&DepList> for &'static str must \
17944                 resolve identically on DepList::{list:?} — divergence \
17945                 signals the owned-input and borrowed-input forward-\
17946                 projection paths have drifted onto different emit-sets"
17947            );
17948        }
17949        let via_iter: Vec<&'static str> = super::DepList::ALL.iter().map(Into::into).collect();
17950        let via_method: Vec<&'static str> =
17951            super::DepList::ALL.iter().map(|l| l.as_str()).collect();
17952        assert_eq!(
17953            via_iter, via_method,
17954            "`.iter().map(Into::into)` over DepList::ALL must byte-equal \
17955             `.iter().map(|l| l.as_str())` on every arm — the borrowed-\
17956             input `From<&DepList> for &'static str` axis is what makes \
17957             the `.iter().map(Into::into)` shape route through the \
17958             substrate-primitive `DepList::as_str` accessor rather than \
17959             through a per-call-site `.copied()` / dereference detour"
17960        );
17961    }
17962
17963    #[test]
17964    fn dep_list_from_into_owned_string_routes_through_as_str_accessor() {
17965        // Fail-before-pass-after byte-parity pin on the newly lifted
17966        // `impl From<DepList> for String` — asserts the owned-`String`
17967        // -returning standard-library trait impl and the substrate-
17968        // primitive [`super::DepList::as_str`] `pub const fn` accessor
17969        // resolve to the same two-arm emit-set across every arm the
17970        // exhaustive [`super::DepList::ALL`] slice enumerates. Rust's
17971        // standard library does not carry a blanket
17972        // `impl<T: AsRef<str>> From<T> for String` (nor an
17973        // `impl<T: fmt::Display> From<T> for String`), so the
17974        // owned-`String` forward-projection axis is a distinct trait-
17975        // idiomatic surface that a `let key: String = list.into();`-
17976        // shaped call site reaches through this impl and no other — the
17977        // paired sibling `From<DepList> for &'static str` impl forces
17978        // every owned-`String` call site through an explicit
17979        // `.to_owned()` / `String::from` restatement. Peer of the
17980        // first-mover
17981        // [`crate::supervisor::tests::restart_strategy_from_into_owned_string_routes_through_as_str_accessor`]
17982        // (7baa18a), the second-peer
17983        // [`crate::supervisor::tests::restart_policy_from_into_owned_string_routes_through_as_str_accessor`]
17984        // (7851725), the third-peer
17985        // [`crate::kind::tests::caixa_kind_from_into_owned_string_routes_through_as_str_accessor`]
17986        // (231a18c), and the fourth-peer
17987        // [`crate::dialeto::tests::caixa_dialeto_from_into_owned_string_routes_through_as_str_accessor`]
17988        // (88942cd) — extends the trait-idiomatic owned-`String`
17989        // forward-projection axis onto the fifth closed-set fieldless
17990        // typed enum on the caixa surface (the two-list dep-graph axis).
17991        for &variant in super::DepList::ALL {
17992            let via_trait: String = <String as From<super::DepList>>::from(variant);
17993            let via_method: &'static str = variant.as_str();
17994            assert_eq!(
17995                via_trait.as_str(),
17996                via_method,
17997                "From<DepList> for String impl must round-trip \
17998                 DepList::{variant:?} to the same lifted \
17999                 crate::render::DEP_AUTHOR_KEY_DEPS* const \
18000                 DepList::as_str returns — divergence signals a silent \
18001                 detour off the substrate-primitive accessor"
18002            );
18003            let via_into: String = variant.into();
18004            assert_eq!(
18005                via_into.as_str(),
18006                via_method,
18007                "Into<String>::into on DepList::{variant:?} must \
18008                 byte-equal DepList::as_str on the same input — the \
18009                 blanket-derived Into shape must resolve to the same \
18010                 as_str dispatch as the explicit From impl"
18011            );
18012        }
18013    }
18014
18015    #[test]
18016    fn dep_list_from_into_owned_string_and_static_str_agree_on_every_arm() {
18017        // Cross-axis partition pin: the paired trait-idiomatic
18018        // owned-`String` `From<DepList> for String` (this lift) and
18019        // owned-`&'static str` `From<DepList> for &'static str`
18020        // (523157d campaign-shape) forward projections must resolve
18021        // identically on every arm, locking the two return-type-shape
18022        // paths together so any future detour trips at caixa-core test
18023        // time. Also byte-parity witness against the sibling
18024        // [`ToString::to_string`] surface routed through
18025        // [`std::fmt::Display`] — the three owned-heap-string paths
18026        // (`.into::<String>()`, `String::from`, `.to_string()`) must
18027        // resolve identically on every arm so a future consumer that
18028        // picks any of the three lands on the same two-arm lifted
18029        // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
18030        // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] accept-set.
18031        // Then a `.iter().copied().map(String::from)` pipe witness
18032        // over [`super::DepList::ALL`] that materializes the two-arm
18033        // accept-set through the owned-`String` axis alone — the exact
18034        // shape a future M4 admission-webhook rejection body composer
18035        // or a
18036        // `HashMap::<String, DepList>::from_iter(
18037        //     DepList::ALL.iter().copied().map(|l| (l.into(), l)))`-
18038        // style owned-key per-list lookup reaches through — closing the
18039        // owned-`String` forward-projection axis's iterator-pipe shape.
18040        // Then a direct round-trip witness through the paired
18041        // trait-idiomatic reverse [`TryFrom<&str>`] axis on the
18042        // owned-`String`'s [`String::as_str`] borrow that closes the
18043        // two-way `Self → String → Self` round-trip on the trait-
18044        // idiomatic owned-`String` forward + reverse axis pair.
18045        //
18046        // Unlike the peer [`crate::CaixaKind`] axis pair (whose forward
18047        // `From` emit lands on the lowercase Portuguese `as_str`
18048        // diagnostic vocabulary while the reverse `TryFrom<&str>`
18049        // parses the `PascalCase` `wire_name` author-surface vocabulary,
18050        // forcing the round-trip through an intermediate
18051        // [`crate::CaixaKind::wire_name`] hop), [`super::DepList`]'s
18052        // [`super::DepList::as_str`] emit and [`super::DepList::from_wire`]
18053        // parse resolve through the same lifted
18054        // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
18055        // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] consts by
18056        // construction (there is no wire/diagnostic axis split on this
18057        // enum), so the owned-`String` forward axis and the reverse
18058        // axis compose directly — matching the peer
18059        // [`crate::supervisor::RestartStrategy`] /
18060        // [`crate::supervisor::RestartPolicy`] /
18061        // [`crate::CaixaDialeto`] owned-`String` axis pairs.
18062        for &list in super::DepList::ALL {
18063            let owned_string: String = <String as From<super::DepList>>::from(list);
18064            let owned_static: &'static str = <&'static str as From<super::DepList>>::from(list);
18065            assert_eq!(
18066                owned_string.as_str(),
18067                owned_static,
18068                "From<DepList> for String and From<DepList> for \
18069                 &'static str must resolve identically on \
18070                 DepList::{list:?} — divergence signals the owned-\
18071                 `String` and owned-`&'static str` forward-projection \
18072                 return-type-shape paths have drifted onto different \
18073                 emit-sets"
18074            );
18075            let via_to_string: String = list.to_string();
18076            assert_eq!(
18077                owned_string, via_to_string,
18078                "From<DepList> for String must byte-equal \
18079                 DepList::to_string on DepList::{list:?} — divergence \
18080                 signals the trait-idiomatic owned-`String` forward-\
18081                 projection axis and the ToString-through-Display axis \
18082                 have drifted onto different emit-sets"
18083            );
18084        }
18085        let via_iter: Vec<String> = super::DepList::ALL
18086            .iter()
18087            .copied()
18088            .map(String::from)
18089            .collect();
18090        let via_method: Vec<String> = super::DepList::ALL
18091            .iter()
18092            .map(|l| l.as_str().to_owned())
18093            .collect();
18094        assert_eq!(
18095            via_iter, via_method,
18096            "`.iter().copied().map(String::from)` over DepList::ALL must \
18097             byte-equal `.iter().map(|l| l.as_str().to_owned())` on \
18098             every arm — the owned-`String` `From<DepList> for String` \
18099             axis is what makes the `String::from` composition route \
18100             through the substrate-primitive `DepList::as_str` accessor \
18101             rather than through a per-call-site `.to_owned()` / \
18102             `String::from(list.as_str())` detour"
18103        );
18104        for &variant in super::DepList::ALL {
18105            let emitted: String = variant.into();
18106            let re_parsed: Result<super::DepList, ()> =
18107                <super::DepList as TryFrom<&str>>::try_from(emitted.as_str());
18108            assert_eq!(
18109                re_parsed,
18110                Ok(variant),
18111                "trait-idiomatic owned-`String` forward-projection + \
18112                 reverse-projection axis pair must round-trip \
18113                 DepList::{variant:?} through `.into::<String>()` and \
18114                 back through `TryFrom<&str>` on the owned-`String`'s \
18115                 String::as_str borrow — a break signals the owned-\
18116                 `String` forward-emit and reverse-parse axes have \
18117                 drifted onto different vocabularies (unlike the peer \
18118                 CaixaKind axis pair, DepList's forward emit and \
18119                 reverse parse share the same lifted \
18120                 DEP_AUTHOR_KEY_DEPS* consts by construction, so the \
18121                 round-trip composes directly)"
18122            );
18123        }
18124    }
18125}
18126
18127#[cfg(test)]
18128mod dep_source_is_variant_tests {
18129    use super::*;
18130
18131    fn all_variants() -> Vec<(DepSource, &'static str)> {
18132        vec![
18133            (
18134                DepSource::Git {
18135                    repo: "github:pleme-io/caixa-teia".into(),
18136                    tag: Some("v0.1.0".into()),
18137                    rev: None,
18138                    branch: None,
18139                },
18140                "Git",
18141            ),
18142            (
18143                DepSource::Path {
18144                    caminho: "../caixa-teia".into(),
18145                },
18146                "Path",
18147            ),
18148        ]
18149    }
18150
18151    fn predicate_row(s: &DepSource) -> [bool; 2] {
18152        [s.is_git(), s.is_path()]
18153    }
18154
18155    // Fail-before-pass-after pin on the [`gen_platform::IsVariant`]
18156    // derive-generated per-arm predicate partition — for every variant
18157    // in `all_variants()`, the observed 2-slot predicate row must equal
18158    // a one-hot row with the `true` at exactly the same index as the
18159    // variant's declaration order. Expected rows are generated live
18160    // from the enumeration rather than transcribed by hand, so a
18161    // copy-paste flip that reroutes one arm through the wrong predicate
18162    // lane trips at the identity-diagonal assertion the way every peer
18163    // sibling [`DepList`] / [`crate::CaixaKind`] / [`crate::CaixaDialeto`]
18164    // / [`crate::supervisor::RestartStrategy`] / [`crate::supervisor::RestartPolicy`]
18165    // / [`crate::upgrade::UpgradeInstruction`] /
18166    // [`crate::aplicacao::PlacementStrategy`] /
18167    // [`crate::aplicacao::RateLimitUnit`] /
18168    // [`crate::aplicacao::WitTarget`] /
18169    // [`crate::render::PathShapeViolation`] partition pin already does.
18170    #[test]
18171    fn dep_source_is_variant_predicates_partition_the_arm_set() {
18172        let variants = all_variants();
18173        for (idx, (variant, name)) in variants.iter().enumerate() {
18174            let observed = predicate_row(variant);
18175            let mut expected = [false; 2];
18176            expected[idx] = true;
18177            assert_eq!(
18178                observed, expected,
18179                "DepSource::{name} at declaration-order slot {idx} must \
18180                 satisfy exactly one is_* predicate (its own); observed \
18181                 row must equal the one-hot expected row — a drift \
18182                 would silently reroute one `:fonte`-arm consumer \
18183                 through the wrong predicate lane"
18184            );
18185        }
18186    }
18187
18188    // Byte-parity pin on the two field-agnostic `matches!` shapes the
18189    // per-arm arm-discriminator predicates replace at any future
18190    // consumer site (a `:fonte`-shape-only lint rule that flags path
18191    // deps outside dev-caixas via `dep.fonte().is_some_and(DepSource::is_path)`,
18192    // a future admission-webhook that rejects `:fonte` shapes outside
18193    // the `is_git()` accept-set, a caixa-lacre indexing pass that
18194    // dispatches on `s.is_git()` without extracting `repo` / `caminho`).
18195    // Refuses a future accidental split between the derived predicate
18196    // and its `matches!` shape — a hand-rolled shadow impl that
18197    // overrides one path, an accidental rebrand that leaves one
18198    // consumer on the raw `matches!` form — on the two load-bearing
18199    // `:fonte`-arm-discriminator axes every downstream substrate
18200    // consumer of the dep-source axis keys off.
18201    #[test]
18202    fn dep_source_is_git_and_is_path_byte_equal_matches_shape() {
18203        for (variant, name) in all_variants() {
18204            let via_matches_git = matches!(variant, DepSource::Git { .. });
18205            let via_predicate_git = variant.is_git();
18206            assert_eq!(
18207                via_predicate_git, via_matches_git,
18208                "DepSource::{name}.is_git() must byte-equal \
18209                 matches!(_, DepSource::Git {{ .. }}) — otherwise a \
18210                 future converged consumer site would silently \
18211                 disagree with its pre-lift shape"
18212            );
18213            let via_matches_path = matches!(variant, DepSource::Path { .. });
18214            let via_predicate_path = variant.is_path();
18215            assert_eq!(
18216                via_predicate_path, via_matches_path,
18217                "DepSource::{name}.is_path() must byte-equal \
18218                 matches!(_, DepSource::Path {{ .. }}) — otherwise a \
18219                 future converged consumer site would silently \
18220                 disagree with its pre-lift shape"
18221            );
18222        }
18223    }
18224
18225    // Cross-pin against every constructor path that materializes a
18226    // [`DepSource`] shape today (the [`DepSource::default_github`]
18227    // resolver-side fallback that materializes an unpinned
18228    // `github:<org>/<nome>` git shorthand, the [`Dep::git`] author-
18229    // surface constructor that materializes a pinned `:tag`-carrying
18230    // `DepSource::Git`, a hand-rolled `DepSource::Path` the dev-mode
18231    // fixture family builds inline). Every constructor's return must
18232    // satisfy the arm-discriminator predicate the constructor's
18233    // variant name matches — a future constructor addition (an
18234    // in-tree registry-fetch pin, a `DepSource::Feira` variant the
18235    // enclosing docstring already names as a trajectory item) surfaces
18236    // as a build-time failure that names the offending drift when its
18237    // return arm doesn't route through the paired predicate.
18238    #[test]
18239    fn dep_source_constructors_route_through_paired_is_variant_predicate() {
18240        let via_default_github = DepSource::default_github("pleme-io", "caixa-teia");
18241        assert!(
18242            via_default_github.is_git(),
18243            "DepSource::default_github must materialize a Git-arm shape — \
18244             a future constructor that routed through a non-Git arm \
18245             (a registry-fetch pin, a `DepSource::Feira` promotion) \
18246             would silently split the resolver's unpinned-shorthand \
18247             materializer from the sole_pin() precedence cascade"
18248        );
18249        assert!(
18250            !via_default_github.is_path(),
18251            "DepSource::default_github must NOT materialize a Path-arm \
18252             shape — the paired negation pin"
18253        );
18254
18255        let via_dep_git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0")
18256            .fonte
18257            .expect("Dep::git materializes a Some(fonte)");
18258        assert!(
18259            via_dep_git.is_git(),
18260            "Dep::git's `:fonte` materialization must land on the Git \
18261             arm — the author-surface pinned-git constructor's return \
18262             must route through the paired predicate"
18263        );
18264        assert!(!via_dep_git.is_path(), "paired negation pin");
18265
18266        let via_path = DepSource::Path {
18267            caminho: "../caixa-teia".into(),
18268        };
18269        assert!(
18270            via_path.is_path(),
18271            "the dev-mode Path-arm materialization must satisfy is_path()"
18272        );
18273        assert!(!via_path.is_git(), "paired negation pin");
18274    }
18275
18276    // ── `dep_nome_axis_reason_ctors!` — the `{ nome: String, <axis>:
18277    //    String, reason: String }` three-slot envelope on `DepError`,
18278    //    strict sibling of the peer `dep_nome_only_ctors!` (792aa92) on
18279    //    the one-slot `{ nome }` envelope, `dep_nome_list_ctors!`
18280    //    (6f5e0cd) on the two-slot `{ nome, list: &'static str }`
18281    //    envelope, `fonte_caminho_ctors!` (f85f145) on the two-slot
18282    //    `{ nome, caminho }` envelope, and `fonte_caminho_byte_ctors!`
18283    //    (0e35793) on the three-slot `{ nome, caminho, byte }` envelope.
18284
18285    #[test]
18286    fn versao_invalid_ctor_matches_struct_literal_wrap() {
18287        assert_eq!(
18288            DepError::versao_invalid("caixa-teia", "^0..1", "invalid comparator".to_string()),
18289            DepError::VersaoInvalid {
18290                nome: "caixa-teia".to_string(),
18291                versao: "^0..1".to_string(),
18292                reason: "invalid comparator".to_string(),
18293            },
18294            "versao_invalid ctor must produce byte-equal \
18295             `DepError::VersaoInvalid` to the pre-lift struct-literal wrap",
18296        );
18297    }
18298
18299    #[test]
18300    fn fonte_repo_shape_ctor_matches_struct_literal_wrap() {
18301        assert_eq!(
18302            DepError::fonte_repo_shape(
18303                "caixa-teia",
18304                "-upload-pack=evil",
18305                "leading dash rejected".to_string(),
18306            ),
18307            DepError::FonteRepoShape {
18308                nome: "caixa-teia".to_string(),
18309                repo: "-upload-pack=evil".to_string(),
18310                reason: "leading dash rejected".to_string(),
18311            },
18312            "fonte_repo_shape ctor must produce byte-equal \
18313             `DepError::FonteRepoShape` to the pre-lift struct-literal wrap",
18314        );
18315    }
18316
18317    #[test]
18318    fn caracteristica_invalid_ctor_matches_struct_literal_wrap() {
18319        assert_eq!(
18320            DepError::caracteristica_invalid(
18321                "caixa-teia",
18322                "bad feature!",
18323                "embedded space rejected".to_string(),
18324            ),
18325            DepError::CaracteristicaInvalid {
18326                nome: "caixa-teia".to_string(),
18327                caracteristica: "bad feature!".to_string(),
18328                reason: "embedded space rejected".to_string(),
18329            },
18330            "caracteristica_invalid ctor must produce byte-equal \
18331             `DepError::CaracteristicaInvalid` to the pre-lift struct-literal wrap",
18332        );
18333    }
18334
18335    #[test]
18336    fn dep_nome_axis_reason_ctors_route_nome_axis_and_reason_through_uniformly() {
18337        // Cross-axis routing pin: sweep the three constructor input axes
18338        // (`nome: &str`, `<axis>: &str`, `reason: String`) through
18339        // distinct-per-axis fixtures against every generated arm in the
18340        // [`dep_nome_axis_reason_ctors!`] macro, so any wrapper-side
18341        // lowercase / trim / truncate on the two `&str` axes — a silent
18342        // field swap between `nome`, the middle `<axis>` field, and
18343        // `reason`, or a `reason` axis silently rerouted through
18344        // `.to_string()` instead of forwarded owned — surfaces here rather
18345        // than at a downstream diagnostic-shape mismatch. Peer of the
18346        // sibling `fonte_caminho_byte_ctors_route_nome_caminho_and_byte_
18347        // through_to_string` (0e35793) cross-axis routing pin on the same
18348        // envelope's `{ nome, caminho, byte }` three-slot family and of
18349        // the peer `dep_nome_list_ctors_route_nome_and_list_through_
18350        // uniformly` (6f5e0cd) pin on the same envelope's two-slot family
18351        // — extended here onto the `{ nome, <axis>: String, reason:
18352        // String }` three-slot envelope so every substrate-primitive ctor
18353        // family in caixa-core's `DepError` envelope guarantees each field
18354        // routes the caller's value verbatim through `.to_string()` (or
18355        // owned-forward for `reason: String`) in declared field order.
18356        // Distinct-per-axis fixtures rule out any two-axis swap
18357        // (`nome` ↔ `<axis>`, `<axis>` ↔ `reason`) that would still pass a
18358        // same-fixture-per-axis pin.
18359        let nome = "sibling-teia";
18360        let axis = "distinct-axis-value";
18361        let reason = "distinct rejection sentence".to_string();
18362        assert_eq!(
18363            DepError::versao_invalid(nome, axis, reason.clone()),
18364            DepError::VersaoInvalid {
18365                nome: nome.to_string(),
18366                versao: axis.to_string(),
18367                reason: reason.clone(),
18368            },
18369            "versao_invalid must route `nome` → `nome`, `axis` → `versao`, \
18370             `reason` → `reason` in declared field order",
18371        );
18372        assert_eq!(
18373            DepError::fonte_repo_shape(nome, axis, reason.clone()),
18374            DepError::FonteRepoShape {
18375                nome: nome.to_string(),
18376                repo: axis.to_string(),
18377                reason: reason.clone(),
18378            },
18379            "fonte_repo_shape must route `nome` → `nome`, `axis` → `repo`, \
18380             `reason` → `reason` in declared field order",
18381        );
18382        assert_eq!(
18383            DepError::caracteristica_invalid(nome, axis, reason.clone()),
18384            DepError::CaracteristicaInvalid {
18385                nome: nome.to_string(),
18386                caracteristica: axis.to_string(),
18387                reason: reason.clone(),
18388            },
18389            "caracteristica_invalid must route `nome` → `nome`, \
18390             `axis` → `caracteristica`, `reason` → `reason` in declared \
18391             field order",
18392        );
18393    }
18394
18395    // ── `dep_nome_axis_ctors!` — the `{ nome: String, <axis>: String }`
18396    //    two-slot envelope on `DepError`, missing rung between
18397    //    `dep_nome_only_ctors!` (792aa92) on the one-slot `{ nome }`
18398    //    envelope and `dep_nome_axis_reason_ctors!` (5621f8a) on the
18399    //    three-slot `{ nome, <axis>: String, reason: String }` envelope.
18400    //    Sibling of `dep_nome_list_ctors!` (6f5e0cd) on the peer
18401    //    two-slot `{ nome, list: &'static str }` envelope (same slot
18402    //    count, `&'static str` axis instead of owned `String` axis).
18403
18404    #[test]
18405    fn fonte_pin_empty_ctor_matches_struct_literal_wrap() {
18406        assert_eq!(
18407            DepError::fonte_pin_empty("caixa-teia", ":tag"),
18408            DepError::FontePinEmpty {
18409                nome: "caixa-teia".to_string(),
18410                pin: ":tag".to_string(),
18411            },
18412            "fonte_pin_empty ctor must produce byte-equal \
18413             `DepError::FontePinEmpty` to the pre-lift struct-literal wrap \
18414             on the same `(&str, &str)` fixture",
18415        );
18416    }
18417
18418    #[test]
18419    fn fonte_pin_ambiguous_ctor_matches_struct_literal_wrap() {
18420        assert_eq!(
18421            DepError::fonte_pin_ambiguous("caixa-teia", ":tag, :rev"),
18422            DepError::FontePinAmbiguous {
18423                nome: "caixa-teia".to_string(),
18424                pins: ":tag, :rev".to_string(),
18425            },
18426            "fonte_pin_ambiguous ctor must produce byte-equal \
18427             `DepError::FontePinAmbiguous` to the pre-lift struct-literal \
18428             wrap on the same `(&str, &str)` fixture",
18429        );
18430    }
18431
18432    #[test]
18433    fn caracteristica_duplicate_ctor_matches_struct_literal_wrap() {
18434        assert_eq!(
18435            DepError::caracteristica_duplicate("caixa-teia", "http"),
18436            DepError::CaracteristicaDuplicate {
18437                nome: "caixa-teia".to_string(),
18438                caracteristica: "http".to_string(),
18439            },
18440            "caracteristica_duplicate ctor must produce byte-equal \
18441             `DepError::CaracteristicaDuplicate` to the pre-lift \
18442             struct-literal wrap on the same `(&str, &str)` fixture",
18443        );
18444    }
18445
18446    #[test]
18447    fn fonte_pin_ambiguous_ctor_matches_owned_string_join_shape() {
18448        // Owned-`String` routing pin: thread the real
18449        // `set.join(", ")` `String` carrier through the ctor's
18450        // `&str`-parameter Deref coercion, so the ambiguity-arm
18451        // wire-up site's actual `&set.join(", ")` shape stays
18452        // byte-equal to a direct `":tag, :rev"` literal. A future
18453        // parameter-shape change silently dropping the Deref
18454        // coercion route (e.g., a switch to `impl Into<String>`)
18455        // surfaces here rather than at the wire-up's compile
18456        // error far from the ctor definition.
18457        let set: Vec<&'static str> = vec![":tag", ":rev"];
18458        let joined: String = set.join(", ");
18459        assert_eq!(
18460            DepError::fonte_pin_ambiguous("caixa-teia", &joined),
18461            DepError::FontePinAmbiguous {
18462                nome: "caixa-teia".to_string(),
18463                pins: ":tag, :rev".to_string(),
18464            },
18465            "fonte_pin_ambiguous ctor must accept an owned-`String` \
18466             `&set.join(\", \")` carrier via Deref coercion — the exact \
18467             shape the ambiguity-arm wire-up site passes into it",
18468        );
18469    }
18470
18471    #[test]
18472    fn dep_nome_axis_ctors_route_nome_and_axis_through_to_string_uniformly() {
18473        // Cross-axis routing pin: sweep the two constructor input axes
18474        // (`nome: &str`, `<axis>: &str`) through distinct-per-axis
18475        // fixtures against every generated arm in the
18476        // [`dep_nome_axis_ctors!`] macro, so any wrapper-side lowercase /
18477        // trim / truncate at codegen time — a silent field swap between
18478        // `nome` and the middle `<axis>` field, or a `<axis>` axis
18479        // silently rerouted through the wrong field on any one variant
18480        // — surfaces here rather than at a downstream diagnostic-shape
18481        // mismatch. Peer of the sibling
18482        // `dep_nome_list_ctors_route_nome_and_list_through_uniformly`
18483        // (6f5e0cd) pin on the same envelope's peer two-slot family
18484        // (`{ nome, list: &'static str }`) and of the sibling
18485        // `dep_nome_axis_reason_ctors_route_nome_axis_and_reason_through_uniformly`
18486        // (5621f8a) pin on the same envelope's three-slot `{ nome,
18487        // <axis>: String, reason: String }` family — extended here onto
18488        // the `{ nome, <axis>: String }` two-slot envelope so the last
18489        // per-`DepError`-two-slot-owned-axis rung on the ctor-family
18490        // ladder guarantees each field routes the caller's value
18491        // verbatim through `.to_string()` in declared field order.
18492        // Distinct-per-axis fixtures rule out any two-axis swap
18493        // (`nome` ↔ `<axis>`) that would still pass a same-fixture-
18494        // per-axis pin.
18495        let nome = "sibling-teia";
18496        let axis = "distinct-axis-value";
18497        assert_eq!(
18498            DepError::fonte_pin_empty(nome, axis),
18499            DepError::FontePinEmpty {
18500                nome: nome.to_string(),
18501                pin: axis.to_string(),
18502            },
18503            "fonte_pin_empty must route `nome` → `nome`, `axis` → `pin` \
18504             in declared field order",
18505        );
18506        assert_eq!(
18507            DepError::fonte_pin_ambiguous(nome, axis),
18508            DepError::FontePinAmbiguous {
18509                nome: nome.to_string(),
18510                pins: axis.to_string(),
18511            },
18512            "fonte_pin_ambiguous must route `nome` → `nome`, `axis` → `pins` \
18513             in declared field order",
18514        );
18515        assert_eq!(
18516            DepError::caracteristica_duplicate(nome, axis),
18517            DepError::CaracteristicaDuplicate {
18518                nome: nome.to_string(),
18519                caracteristica: axis.to_string(),
18520            },
18521            "caracteristica_duplicate must route `nome` → `nome`, \
18522             `axis` → `caracteristica` in declared field order",
18523        );
18524    }
18525
18526    #[test]
18527    fn nome_invalid_ctor_matches_struct_literal_wrap() {
18528        // Equivalence pin: the ctor produces byte-equal
18529        // `DepError::NomeInvalid` to the pre-lift open-coded struct-
18530        // literal that cloned the offending `:deps :nome` verbatim and
18531        // forwarded the [`crate::render::is_dns_1123_label`]-shaped
18532        // owned `reason` payload at the caller site inside
18533        // [`Dep::validate`]. Guards any future field-addition /
18534        // reordering / accessor-return tweak on the variant. Sibling of
18535        // the peer four-slot `fonte_pin_shape` ctor equivalence pins
18536        // (below) and the sibling three-slot
18537        // `dep_nome_axis_reason_ctors_route_nome_axis_and_reason_through_uniformly`
18538        // pin on the same envelope's three-slot `{ nome, <axis>: String,
18539        // reason: String }` family.
18540        let nome = "Caixa-Teia";
18541        let reason = crate::render::is_dns_1123_label(nome).unwrap_err();
18542        let via_ctor = DepError::nome_invalid(nome, reason.clone());
18543        let via_literal = DepError::NomeInvalid {
18544            nome: nome.to_string(),
18545            reason,
18546        };
18547        assert_eq!(
18548            via_ctor, via_literal,
18549            "nome_invalid(nome, reason) must byte-equal the open-coded \
18550             NomeInvalid struct-literal on the same `(nome, reason)` fixture"
18551        );
18552        assert_eq!(
18553            via_ctor.to_string(),
18554            via_literal.to_string(),
18555            "Display byte-string must byte-equal the open-coded struct-literal"
18556        );
18557    }
18558
18559    #[test]
18560    fn nome_invalid_ctor_routes_nome_and_reason_through_to_string_uniformly() {
18561        // Boundary-sweep pin on the ctor's two-slot projection: sweep
18562        // the two ctor input axes (`nome: &str`, `reason: String`)
18563        // through distinct-per-axis fixtures against a representative
18564        // set of DNS-1123-refused `:deps :nome` byte-strings, so any
18565        // wrapper-side silent lowercase / trim / truncate at codegen
18566        // time — a silent field swap between `nome` and `reason`, an
18567        // accidental `nome`-side `.to_lowercase()` shim, or a `.into()`
18568        // divergence on the `reason` axis — surfaces at caixa-core
18569        // build time rather than at a downstream diagnostic consumer
18570        // that reads `err.nome` / `err.reason` back and gets a different
18571        // value than the one it stored. Peer of the sibling
18572        // `dep_nome_axis_ctors_route_nome_and_axis_through_to_string_uniformly`
18573        // (7f7c950) pin on the same envelope's peer two-slot family
18574        // (`{ nome, <axis>: String }`) — extended here onto the
18575        // `{ nome, reason: String }` two-slot rung the sole `NomeInvalid`
18576        // variant carries. Distinct-per-axis fixtures rule out any
18577        // two-axis swap (`nome` ↔ `reason`) that would still pass a
18578        // same-fixture-per-axis pin. The sweep list carries a mixed
18579        // DNS-1123-refused set (uppercase-carrying, underscore-carrying,
18580        // dot-carrying, leading-hyphen, trailing-hyphen, slash-carrying,
18581        // over-63-byte) so a future silent per-input normalization
18582        // surfaces on the arm that diverges.
18583        for nome in [
18584            "Caixa-Teia",
18585            "caixa_teia",
18586            "caixa.teia",
18587            "-caixa-teia",
18588            "caixa-teia-",
18589            "caixa/teia",
18590            &"a".repeat(64),
18591        ] {
18592            let reason = crate::render::is_dns_1123_label(nome)
18593                .expect_err("fixture must be a DNS-1123-refused label");
18594            let via_ctor = DepError::nome_invalid(nome, reason.clone());
18595            let DepError::NomeInvalid {
18596                nome: stored_nome,
18597                reason: stored_reason,
18598            } = via_ctor
18599            else {
18600                panic!("nome_invalid must construct NomeInvalid for {nome:?}");
18601            };
18602            assert_eq!(
18603                stored_nome, nome,
18604                "nome slot must round-trip verbatim through `.to_string()` for {nome:?}"
18605            );
18606            assert_eq!(
18607                stored_reason, reason,
18608                "reason slot must forward the owned `String` verbatim for {nome:?}"
18609            );
18610        }
18611    }
18612
18613    #[test]
18614    fn validate_nome_invalid_arm_routes_through_nome_invalid_ctor() {
18615        // End-to-end pin: the sole in-crate wire-up site
18616        // ([`Dep::validate`]'s DNS-1123 refusal arm) routes through
18617        // [`DepError::nome_invalid`] and the observed `Err` byte-equals
18618        // the ctor's output on the same DNS-1123-refused `:deps :nome`
18619        // fixture, with identical `Display` rendering. A future silent
18620        // de-lift of the wire-up back to the open-coded struct-literal
18621        // trips this test at caixa-core build time rather than at a
18622        // downstream diagnostic consumer far from the wire-up commit.
18623        // Sibling of the peer
18624        // `nome_invalid_diagnostic_carries_offending_name` pattern-match
18625        // pin on the same wire-up — extended here from a `matches!`
18626        // shape check to a byte-identity + Display parity route through
18627        // the ctor.
18628        let d = Dep::simple("Caixa_Teia", "^0.1");
18629        let observed = d.validate().unwrap_err();
18630        let reason = crate::render::is_dns_1123_label("Caixa_Teia")
18631            .expect_err("fixture must be DNS-1123-refused");
18632        let expected = DepError::nome_invalid("Caixa_Teia", reason);
18633        assert_eq!(
18634            observed, expected,
18635            "Dep::validate's DNS-1123 refusal arm must byte-equal \
18636             nome_invalid(nome, reason)"
18637        );
18638        assert_eq!(
18639            observed.to_string(),
18640            expected.to_string(),
18641            "Display byte-string parity"
18642        );
18643    }
18644}