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#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
59#[serde(tag = "tipo", rename_all = "lowercase")]
60pub enum DepSource {
61    /// Clone from Git. One of `:tag`, `:rev`, or `:branch` may be set.
62    /// `repo` can be a `github:org/repo` shorthand, a full `https://…` URL,
63    /// or any git-ssh URL.
64    Git {
65        repo: String,
66        #[serde(default, skip_serializing_if = "Option::is_none")]
67        tag: Option<String>,
68        #[serde(default, skip_serializing_if = "Option::is_none")]
69        rev: Option<String>,
70        #[serde(default, skip_serializing_if = "Option::is_none")]
71        branch: Option<String>,
72    },
73    /// Local filesystem path — dev only; cannot be published.
74    Path { caminho: String },
75}
76
77impl DepSource {
78    /// Build a registry-shorthand git source (`github:<org>/<nome>`).
79    ///
80    /// This is the resolver-side fallback for `dep.fonte: None`, not an
81    /// author-surface value — it carries no pin (`:tag`/`:rev`/`:branch`
82    /// all `None`) and is therefore rejected by [`Self::validate`]. The
83    /// resolver fills the pin in at fetch time from the resolved commit;
84    /// authors never serialize this shape as a `Dep::fonte` value.
85    #[must_use]
86    pub fn default_github(org: &str, nome: &str) -> Self {
87        Self::Git {
88            repo: format!("github:{org}/{nome}"),
89            tag: None,
90            rev: None,
91            branch: None,
92        }
93    }
94
95    /// Substrate-canonical per-`:fonte` sole-set git-pin scalar accessor
96    /// every consumer that reads "which single git ref does this source
97    /// resolve to?" keys off — returns the author-declared `:tag` /
98    /// `:rev` / `:branch` byte-string verbatim as an `Option<&str>`,
99    /// borrowed from the typed slot's own `Option<String>` storage; `None`
100    /// on [`Self::Path`] (a path source carries no git-ref) and on a
101    /// [`Self::Git`] variant whose `tag`, `rev`, and `branch` are all
102    /// `None` (the [`Self::default_github`] shorthand shape the resolver
103    /// materializes when the author omits `:fonte` — rejected by
104    /// [`Self::validate`], but the accessor's return is defined on this
105    /// arm too so pre-validate consumers reach for the same typed dispatch
106    /// as post-validate ones).
107    ///
108    /// **Precedence: rev > tag > branch.** The canonical precedence every
109    /// per-`:fonte` git-ref consumer already applies: caixa-resolver's
110    /// per-fetch `git checkout <ref>` reads through the same
111    /// `rev.or(tag).or(branch)` cascade at caixa-resolver/src/resolve.rs,
112    /// and caixa-crd's `dep_into_ref` `CaixaSource.git_ref` fill reads
113    /// through the same cascade at caixa-crd/src/conversion.rs. The
114    /// [`Self::validate`] gate enforces "exactly one pin set" — under
115    /// that invariant every accepted [`Self::Git`] carries exactly one
116    /// non-`None` pin and the precedence is unobservable, but the
117    /// precedence remains defined for pre-validate consumers (the
118    /// resolver's `MissingPin` diagnostic path, the caixa-crd
119    /// round-trip's default `"main"` fallback the author never sees a
120    /// diagnostic on) and defense-in-depth for a hypothetical future
121    /// state where multiple pins survive the gate. The precedence is
122    /// **rev before tag** because `:rev` (a git commit OID) is the
123    /// reproducibility-strongest identifier — an OID resolves to exactly
124    /// one commit regardless of which refname points at it, whereas
125    /// `:tag` and `:branch` are refnames the remote can silently move
126    /// (a tag re-push, a branch head advance); the resolver's freeze
127    /// step at fetch time promotes the resolved commit to `:rev` for
128    /// exactly this reason. **Tag before branch** because `:tag` is
129    /// conventionally immutable (a release tag) whereas `:branch` is
130    /// conventionally mutable (a tracking ref) — a caixa carrying both
131    /// a release tag and a tracking branch reads as "prefer the release
132    /// pin, fall through to the tracking pin only if the release is
133    /// missing". The cascade order also matches the byte-order every
134    /// per-`:tag`/`:rev`/`:branch` diagnostic tuple this crate emits
135    /// (`(":tag", tag), (":rev", rev), (":branch", branch)` — see
136    /// [`Self::validate`]'s `pins` array).
137    ///
138    /// Prior to this lift the "sole set pin" projection sat twice in the
139    /// workspace — inline at caixa-resolver's `fetch_git` (`let gitref =
140    /// rev.or(tag).or(branch).ok_or_else(|| ResolveError::MissingPin
141    /// { … })?;`) and at caixa-crd's `dep_into_ref`
142    /// (`git_ref: rev.clone().or(tag.clone()).or(branch.clone())
143    /// .unwrap_or_else(|| "main".to_string())`) — two open-coded copies
144    /// of the same precedence cascade with no compile-time link back to
145    /// the typed slot. A future extension of the pin axis to a richer
146    /// author surface (a `:commit` pin peer of `:rev` once the substrate
147    /// grows a signed-commit-verification pin, a `:ref` pin the M4
148    /// substrate operator resolves per-cluster ahead of fetch, a
149    /// promotion of the plain `Option<String>` pins to a typed
150    /// `GitPin::{Rev(Oid), Tag(RefName), Branch(RefName)}` newtype
151    /// once the sibling [`crate::render::is_git_oid`] /
152    /// [`crate::render::is_git_ref_name`] gates land as typed
153    /// constructors) would have had to be threaded through both
154    /// open-coded copies in lockstep or the resolver's `git checkout`
155    /// target would silently disagree with the CRD's `git_ref` fill —
156    /// an author's `(:fonte (:tipo git :repo "…" :rev "deadbeef" :tag
157    /// "v1"))` would ship with the resolver checking out `deadbeef`
158    /// while the CRD round-trip re-emitted a Dep pointing at `v1`, one
159    /// lacre closure disagreeing with the emitted K8s CR the operator
160    /// reads. Lifting the resolution to a typed method on the substrate
161    /// primitive means both downstream consumers reach for exactly one
162    /// typed dispatch — the resolver's accept-set migrates as a unit on
163    /// any future pin-axis addition.
164    ///
165    /// Peer of the sibling outer-`Dep` [`Dep::fonte`] (d65d1bf)
166    /// `Option<&DepSource>` composite-reference accessor on the outer-
167    /// `Dep` `:fonte`-slot axis — extended one nesting level down onto
168    /// the per-[`Self::Git`]-variant sole-set-pin projection axis every
169    /// git-fetching consumer runs after the outer `:fonte` slot resolves
170    /// to a [`Self::Git`] shape. Same "one typed dispatch on the
171    /// substrate primitive, thin projections at each consumer" discipline
172    /// the outer accessor family already carries.
173    #[must_use]
174    pub fn sole_pin(&self) -> Option<&str> {
175        match self {
176            Self::Git {
177                tag, rev, branch, ..
178            } => rev.as_deref().or(tag.as_deref()).or(branch.as_deref()),
179            Self::Path { .. } => None,
180        }
181    }
182
183    /// Validate the `:fonte` value-shape: every author-surface
184    /// `:fonte (:tipo git …)` must carry a non-empty `:repo` and
185    /// exactly one of `:tag` / `:rev` / `:branch` set to a non-empty
186    /// value; every `:fonte (:tipo path …)` must carry a non-empty
187    /// `:caminho`.
188    ///
189    /// Called from [`Dep::validate`] with the dep's `:nome` so every
190    /// diagnostic carries the offending entry verbatim — same
191    /// self-locating shape the `:deps :versao` (2420c44),
192    /// `:membros :versao` (9888b13), `:children :versao` (b38ff3a),
193    /// `:placement :clusters` (6cbb900), and `:membros :caixa`
194    /// (3f9d7a0) gates already expose.
195    ///
196    /// Until this gate landed `:fonte` was the only `:deps`-related
197    /// typed surface still untyped past `Caixa::from_lisp`:
198    /// - Empty `:repo` (`(:tipo git :repo "" :tag "v1")`) silently
199    ///   passed parse and surfaced as a git-clone failure at
200    ///   lacre-resolve time, far from the source caixa.lisp.
201    /// - A bare `(:tipo git :repo "…")` with no `:tag`/`:rev`/`:branch`
202    ///   passed parse and surfaced as the resolver's
203    ///   [`ResolveError::MissingPin`](../../caixa-resolver/src/resolve.rs)
204    ///   at fetch time, again far from the source caixa.lisp; lifting
205    ///   to validate-time gives the author the same diagnostic at the
206    ///   edit site.
207    /// - `(:tipo git :repo "…" :tag "v1" :branch "main")` — multiple
208    ///   pins set — passed parse and the resolver silently picked
209    ///   `:rev > :tag > :branch`, ignoring the other pins with no
210    ///   diagnostic; the author had no way to know their `:branch`
211    ///   was dropped. This is the canonical "pin drift" footgun.
212    /// - An empty pin value (`(:tipo git :repo "…" :tag "")`) silently
213    ///   passed parse and surfaced as `git checkout ""` at fetch time.
214    /// - Empty `:caminho` (`(:tipo path :caminho "")`) silently passed
215    ///   parse and surfaced as
216    ///   [`ResolveError::MissingPath`](../../caixa-resolver/src/resolve.rs)
217    ///   with `path: PathBuf("")` — not actionable.
218    ///
219    /// Each rejected shape maps to a typed
220    /// [`DepError::Fonte*`] variant that names the offending
221    /// dep's `:nome` and the specific axis, so the author can grep
222    /// their caixa.lisp for the `:nome "<nome>"` block and fix it in
223    /// one edit.
224    pub fn validate(&self, nome: &str) -> Result<(), DepError> {
225        match self {
226            Self::Git {
227                repo,
228                tag,
229                rev,
230                branch,
231            } => {
232                if repo.is_empty() {
233                    return Err(DepError::FonteRepoEmpty {
234                        nome: nome.to_string(),
235                    });
236                }
237                // The `:repo` value flows verbatim into the caixa-resolver's
238                // `git clone <repo>` subprocess invocation. Until this gate
239                // landed `:repo` was the last untyped `:fonte`-related axis
240                // past the empty arm: a malformed-but-non-empty repo URL
241                // (`":repo "github:p/x ""` trailing space, paste-from-doc;
242                // `":repo "-upload-pack=evil""` leading `-` — the canonical
243                // CLI-argument-injection vector at the `git clone` boundary;
244                // `":repo "pleme-io/caixa-teia""` missing scheme — `git clone`
245                // reads as a relative filesystem path rather than the
246                // GitHub-shorthand expansion; `":repo "github:p/x\n""`
247                // embedded newline; `":repo "github:café/x""` raw non-ASCII)
248                // silently passed validate and the failure surfaced at
249                // lacre-resolve time with a porcelain-quoting-confused error
250                // far from the source caixa.lisp. The lifted predicate makes
251                // the git-porcelain-URL intersection-floor a substrate-level
252                // invariant at validate time, peer with the three pin axes
253                // (`:tag` + `:branch` via [`crate::render::is_git_ref_name`],
254                // e70d213; `:rev` via [`crate::render::is_git_oid`], be07fd5)
255                // — every `:fonte (:tipo git …)` past validate is now
256                // structurally accept-shaped on every axis the resolver
257                // consumes (the `:repo` URL the `git clone` invokes against,
258                // the `:tag`/`:branch` refname `git fetch`/`git checkout`
259                // accepts, the `:rev` commit OID the lacre's content-
260                // addressing equality probe resolves), closing the
261                // `:fonte` slot's value-shape trajectory end-to-end.
262                if let Err(reason) = crate::render::is_git_repo_url(repo) {
263                    return Err(DepError::FonteRepoShape {
264                        nome: nome.to_string(),
265                        repo: repo.clone(),
266                        reason,
267                    });
268                }
269                let pins: [(&'static str, Option<&String>); 3] = [
270                    (":tag", tag.as_ref()),
271                    (":rev", rev.as_ref()),
272                    (":branch", branch.as_ref()),
273                ];
274                let set: Vec<&'static str> =
275                    pins.iter().filter_map(|(n, v)| v.map(|_| *n)).collect();
276                match set.len() {
277                    0 => {
278                        return Err(DepError::FontePinMissing {
279                            nome: nome.to_string(),
280                        });
281                    }
282                    1 => {
283                        for (pin, value) in pins {
284                            if value.is_some_and(String::is_empty) {
285                                return Err(DepError::FontePinEmpty {
286                                    nome: nome.to_string(),
287                                    pin: pin.to_string(),
288                                });
289                            }
290                        }
291                    }
292                    _ => {
293                        return Err(DepError::FontePinAmbiguous {
294                            nome: nome.to_string(),
295                            pins: set.join(", "),
296                        });
297                    }
298                }
299                // Per-pin value-shape gate. The refname-shaped axes
300                // (`:tag` + `:branch`) route through
301                // [`crate::render::is_git_ref_name`]; the hex-OID-shaped
302                // `:rev` axis routes through
303                // [`crate::render::is_git_oid`]. The two predicates
304                // partition the `:fonte` pin axes structurally — refname
305                // vs. hex commit — so a cross-axis mis-slot (the
306                // canonical "I conflated `:rev` and `:branch`" footgun:
307                // `:rev "main"` defeating the reproducibility contract,
308                // `:tag "deadbeef…"` mis-slotting a SHA into the
309                // refname-shaped axis) lands at the offending axis's
310                // predicate, not at lacre-resolve `git fetch` /
311                // `git checkout` time. Their valid sets intersect at
312                // the empty set: every refname is rejected by
313                // `is_git_oid`, every OID is rejected by
314                // `is_git_ref_name`, structurally.
315                //
316                // Until this gate landed `:tag` / `:branch` were the
317                // refname-shaped axes still untyped past the empty-pin
318                // arm: a malformed-but-non-empty refname
319                // (`:tag "v0.1.0 "` trailing space — the canonical
320                // paste-from-doc footgun; `:tag "v0.1.0.lock"` colliding
321                // with git's atomic-rename guard suffix; `:tag "../escape"`
322                // path-traversal via consecutive dots; `:branch "main "`
323                // trailing space; `:branch "feature/foo bar"` embedded
324                // space; `:branch "@"` the literal HEAD alias;
325                // `:branch "refs/heads/main"` the fully-qualified ref
326                // copied from `git show-ref` output that resolves to
327                // a literal ref named `refs/heads/refs/heads/main` on
328                // disk) silently passed validate; the `:rev` axis was
329                // the last `:fonte`-related axis still untyped past the
330                // empty-pin arm: a malformed-but-non-empty hex-OID
331                // (`:rev "main"` conflating with `:branch` — the
332                // reproducibility-contract leak; `:rev "v0.1.0"`
333                // conflating with `:tag` — the same mis-slot on the
334                // refname/OID boundary; `:rev "c0ffee"` an abbreviated
335                // 6-char prefix that's ambiguous across repo history;
336                // `:rev "DEADBEEF…"` an uppercase OID that round-trips
337                // inconsistently against `git rev-parse HEAD`'s
338                // lowercase emission) silently passed validate and the
339                // failure surfaced at lacre-resolve `git fetch` /
340                // `git checkout` time with a quoting-confused error
341                // far from the source caixa.lisp, with no field naming
342                // which `:deps` entry carried the typo. Lifting both
343                // gates to caixa-build time matches the value-shape
344                // trajectory the peer typed axes already follow
345                // (c4213a4 typed WitContract endpoint/subject/slot;
346                // eb3456d :entrada :paths; c7d05ec :entrada :host;
347                // 4f0390b :contratos :endpoint; 6226bf4 :contratos :wit;
348                // 63e18a0 :contratos :subject; 2f4316e :contratos
349                // :slot; e70d213 :fonte :tag + :branch) — the typed
350                // slot's valid set matches its downstream consumer's
351                // accepted set (here, the git porcelain's refname /
352                // commit-OID grammars at `git fetch` / `git checkout`
353                // time), structurally. Same diagnostic shape every
354                // per-axis value-shape lift already exposes
355                // (`*Invalid { axis, reason }`); the `value:` field
356                // carries the offending refname / OID verbatim so the
357                // author can grep their caixa.lisp for the
358                // `:tag "<value>"` / `:branch "<value>"` /
359                // `:rev "<value>"` literal and fix it in one edit.
360                for (pin, value) in [(":tag", tag.as_ref()), (":branch", branch.as_ref())] {
361                    if let Some(v) = value
362                        && let Err(reason) = crate::render::is_git_ref_name(v)
363                    {
364                        return Err(DepError::FontePinShape {
365                            nome: nome.to_string(),
366                            pin: pin.to_string(),
367                            value: v.clone(),
368                            reason,
369                        });
370                    }
371                }
372                if let Some(v) = rev.as_ref()
373                    && let Err(reason) = crate::render::is_git_oid(v)
374                {
375                    return Err(DepError::FontePinShape {
376                        nome: nome.to_string(),
377                        pin: ":rev".to_string(),
378                        value: v.clone(),
379                        reason,
380                    });
381                }
382                Ok(())
383            }
384            Self::Path { caminho } => Self::validate_caminho(nome, caminho),
385        }
386    }
387
388    /// Reproducibility + path-API gate on the `:fonte (:tipo path …)`
389    /// `:caminho` axis. Walks the leading-byte cascade closed by the
390    /// b94fd83 (`/`), a5c248e (`~`), and f4efe9c (`$`) arms; the
391    /// orthogonal embedded-control-byte arm (d624c8d) covering
392    /// `0x00..=0x1F` plus `0x7F` anywhere in the value; and the
393    /// embedded-`\` Windows-path-separator arm closing the
394    /// cross-host-OS-separator divergence vector on the same
395    /// THEORY.md §V.2 render-determinism axis.
396    ///
397    /// Extracted from [`Self::validate`]'s `Self::Path` arm because the
398    /// per-arm cascade now spans nine diagnostic shapes — every new
399    /// `:caminho` arm (a future `&` / `;` / `|` shell-metachar arm,
400    /// a future glob-metachar `*` / `?` arm) lands here rather than
401    /// re-inflating `Self::validate`. The
402    /// function stays a thin per-arm linear walk for one reason: each
403    /// arm's diagnostic carries a distinct typed [`DepError`] variant
404    /// rather than a parser-shaped `reason` string, so collapsing the
405    /// cascade onto a generic [`crate::render`] predicate would regress
406    /// the per-arm self-locating diagnostic that `feira lint` consumers
407    /// depend on. The wrapped predicate trajectory ([`crate::render::is_dns_1123_label`],
408    /// [`crate::render::is_git_repo_url`], etc.) lives on the
409    /// reason-string-shaped axes; the `:caminho` axis keeps its
410    /// per-arm variant shape.
411    #[allow(
412        clippy::too_many_lines,
413        reason = "the per-arm cascade is structurally flat by design — every \
414                  `:caminho` arm carries its own typed [`DepError`] variant + \
415                  per-arm Why comment, so collapsing the cascade onto a generic \
416                  [`crate::render`] predicate would regress the per-arm self-locating \
417                  diagnostic the `feira lint` consumer surface depends on"
418    )]
419    fn validate_caminho(nome: &str, caminho: &str) -> Result<(), DepError> {
420        if caminho.is_empty() {
421            return Err(DepError::FonteCaminhoEmpty {
422                nome: nome.to_string(),
423            });
424        }
425        // Reproducibility gate on the `:fonte (:tipo path …)`
426        // `:caminho` axis. The lacre pipeline embeds the value
427        // verbatim in its per-dep content-address
428        // (`conteudo: format!("path:{caminho}")`,
429        // caixa-resolver/src/resolve.rs:189) and that string
430        // folds into the BLAKE3 closure the lacre keys every
431        // downstream consumer (the substrate's reproducibility
432        // contract, CAIXA-SDLC §III.2 — the lacre is the
433        // build's content-addressed identity, peer of the Nix
434        // store path) against. Until this gate landed an
435        // absolute `:caminho` (`/home/me/work/caixa-teia` — the
436        // canonical "I dragged the folder out of Finder into
437        // my editor" footgun; `/Users/alice/dev/caixa-teia` on
438        // the macOS path-layout peer; the
439        // `${WORKSPACE}/caixa-teia` shell-expanded literal
440        // pasted from a CI manifest) silently passed validate
441        // and the failure surfaced *as a successful build with
442        // a divergent lacre*: the BLAKE3 closure on Alice's
443        // workstation differed from the closure on Bob's
444        // workstation, two CI runners with different
445        // `${HOME}` layouts emitted two distinct
446        // content-addresses for the byte-identical caixa, and
447        // the substrate's "the lacre is the build's identity"
448        // contract silently broke far from the source
449        // caixa.lisp — the most insidious failure mode the
450        // typed slot can carry (no error surfaces; the
451        // divergence is invisible until two machines compare
452        // lacres). The same THEORY.md §V.2 render-determinism
453        // discipline `is_sandboxed_relative_path` already
454        // applies on the M2 typed path-slots
455        // (`:behavior :on-*`, `:upgrade-from :state-change
456        // :script`, `:bibliotecas`, `:exe`, `:servicos`), here
457        // narrowed to the absolute-vs-relative axis only:
458        // `:fonte :caminho`'s canonical author-surface form is
459        // the `..`-traversing sibling-workspace path
460        // (`"../caixa-teia"`, the in-tree dev-dep frame), so a
461        // full `is_sandboxed_relative_path` lift would
462        // structurally reject every legitimate path-fonte
463        // dep. The narrower
464        // `std::path::Path::is_absolute` cut admits the
465        // sibling-workspace form while still rejecting the
466        // host-layout-leaking absolute shape — the
467        // reproducibility contract bites at exactly the
468        // absolute boundary, and that's the axis the
469        // substrate-level invariant is meant to hold. Same
470        // diagnostic shape every per-axis value-shape lift on
471        // the surrounding [`DepError::Fonte*`] cluster carries
472        // (the offending `:nome` + offending `:caminho`
473        // quoted verbatim so the author can grep their
474        // caixa.lisp for the `:caminho "<value>"` literal and
475        // fix it in one edit). The empty arm strictly
476        // precedes this arm so the blank-string footgun
477        // surfaces the more self-locating
478        // `FonteCaminhoEmpty` diagnostic (the empty string
479        // is not absolute under `Path::new("").is_absolute()`
480        // so the precedence is a no-op at value level — the
481        // pin matters only at the diagnostic-shape level if
482        // a future codec round-trip ever produces an empty
483        // string that probes as absolute).
484        if std::path::Path::new(caminho).is_absolute() {
485            return Err(DepError::FonteCaminhoAbsolute {
486                nome: nome.to_string(),
487                caminho: caminho.to_string(),
488            });
489        }
490        // Reproducibility gate's tilde-expansion arm. The b94fd83
491        // `FonteCaminhoAbsolute` closes the leading-`/`
492        // host-layout-leak; a `:caminho "~/work/caixa-teia"` (the
493        // canonical paste-from-shell-prompt / paste-from-`cd ~`-
494        // doc footgun) silently passed both the empty arm and
495        // the absolute arm because `Path::new("~").is_absolute()`
496        // returns `false` — `~` is a shell-expansion convention,
497        // not a POSIX path component, so `std::path::Path` treats
498        // it as a literal directory-name segment. The lacre
499        // pipeline then embedded the value verbatim
500        // (`conteudo: format!("path:~/work/caixa-teia")`) and the
501        // failure mode forked per consumer:
502        //
503        //   - The caixa-resolver's `Path` arm folds `:caminho`
504        //     through `Path::new(caminho).join(<file>)` without
505        //     `~`-expansion, so the build looked for a literal
506        //     `./~/work/caixa-teia` subdirectory and failed at
507        //     resolve time with a `No such file or directory`
508        //     error far from the source caixa.lisp (the lacre
509        //     itself, though, was already byte-identical across
510        //     machines — every machine emitted the same
511        //     `path:~/work/caixa-teia` content-address).
512        //   - A future caixa-resolver pass that *does* expand `~`
513        //     (the canonical shell-convention idiom every
514        //     resolver eventually reaches for once an author
515        //     reports the literal-`~`-directory bug) would re-
516        //     introduce the host-layout-leak the b94fd83 absolute
517        //     gate closes: Alice's `~` expands to `/home/alice`,
518        //     Bob's to `/home/bob`, two CI runners with different
519        //     `$HOME` layouts resolve to two distinct paths for
520        //     the byte-identical caixa, and the substrate's
521        //     "the lacre is the build's identity" contract
522        //     silently breaks far from the source caixa.lisp.
523        //
524        // Closing the gate at `DepSource::validate` (here at the
525        // canonical caixa-build-time boundary, peer with the
526        // absolute arm above) refuses both failure modes
527        // structurally: the typed accepted set excludes every
528        // `~`-prefixed authoring shape, so the resolver is
529        // free to grow `~`-expansion (or any other convention-
530        // expansion the substrate adopts) without re-opening
531        // the host-layout-leak at the typed boundary. Same
532        // diagnostic shape every per-axis value-shape gate on
533        // the surrounding [`DepError::Fonte*`] cluster carries
534        // (the offending `:nome` + offending `:caminho` quoted
535        // verbatim so the author can grep their caixa.lisp for
536        // the `:caminho "<value>"` literal and fix it in one
537        // edit).
538        //
539        // The cascade preserves narrower-diagnostic-first
540        // ordering: `FonteCaminhoEmpty` → `FonteCaminhoAbsolute`
541        // → `FonteCaminhoTildeExpansion`. The empty arm
542        // structurally precedes both (the bytes "" / "~" don't
543        // overlap), and the absolute arm structurally precedes
544        // the tilde arm (an absolute path can't start with `~`
545        // since absolute paths start with `/`; the bytes "/" /
546        // "~" don't overlap either). Both arms are
547        // value-disjoint, so the precedence is a no-op at value
548        // level — the pin matters only at the diagnostic-shape
549        // level if a future codec round-trip ever produces a
550        // value that probes as both absolute and tilde-prefixed.
551        if caminho.starts_with('~') {
552            return Err(DepError::FonteCaminhoTildeExpansion {
553                nome: nome.to_string(),
554                caminho: caminho.to_string(),
555            });
556        }
557        // Reproducibility gate's shell-variable-expansion arm.
558        // The b94fd83 `FonteCaminhoAbsolute` closes the leading-`/`
559        // host-layout-leak; the a5c248e `FonteCaminhoTildeExpansion`
560        // closes the leading-`~` shell-home-expansion shape; the
561        // leading-`$` is the sibling shell-variable-expansion shape
562        // — same host-layout-leaking semantic, different syntactic
563        // surface. A `:caminho "$HOME/work/caixa-teia"` (the
564        // canonical paste-from-`echo $HOME`-doc footgun) and the
565        // `${VAR}`-braced variant (`"${WORKSPACE}/caixa-teia"` —
566        // the canonical paste-from-CI-manifest footgun every
567        // GitHub Actions / GitLab CI / Drone manifest carries)
568        // silently passed every prior arm because
569        // `Path::is_absolute` returns false on `$` (the `$` is a
570        // shell convention, not a POSIX path component, so
571        // `std::path::Path` treats it as a literal directory-name
572        // segment) and the tilde arm's `starts_with('~')` doesn't
573        // fire.
574        //
575        // Same per-consumer failure-fork the tilde arm closes:
576        //
577        //   - The caixa-resolver's `Path` arm folds `:caminho`
578        //     through `Path::new(caminho).join(<file>)` without
579        //     `$`-expansion, so the build looks for a literal
580        //     `./$HOME/work/caixa-teia` subdirectory and fails at
581        //     resolve time with a `No such file or directory`
582        //     error far from the source caixa.lisp.
583        //   - A future caixa-resolver pass that *does* expand
584        //     `$VAR` (the shell-convention idiom every resolver
585        //     eventually reaches for once an author reports the
586        //     literal-`$HOME`-directory bug, especially for CI's
587        //     `${WORKSPACE}` idiom) would re-introduce the host-
588        //     layout-leak the b94fd83 absolute gate closes:
589        //     Alice's `$HOME` expands to `/home/alice`, Bob's to
590        //     `/home/bob`, two CI runners with different
591        //     `${WORKSPACE}` layouts resolve to two distinct
592        //     paths for the byte-identical caixa, and the
593        //     substrate's "the lacre is the build's identity"
594        //     contract silently breaks far from the source
595        //     caixa.lisp.
596        //
597        // Closing the gate at `DepSource::validate` (here at the
598        // canonical caixa-build-time boundary, peer with the
599        // absolute + tilde arms above) refuses both failure modes
600        // structurally. Same diagnostic shape every per-axis
601        // value-shape gate on the surrounding [`DepError::Fonte*`]
602        // cluster carries (the offending `:nome` + offending
603        // `:caminho` quoted verbatim).
604        //
605        // The cascade preserves narrower-diagnostic-first ordering:
606        // `FonteCaminhoEmpty` → `FonteCaminhoAbsolute` →
607        // `FonteCaminhoTildeExpansion` → `FonteCaminhoVarExpansion`.
608        // The empty arm structurally precedes all three subsequent
609        // arms; the absolute arm structurally precedes both the
610        // tilde and the var arms (absolute paths start with `/`,
611        // the bytes `/` / `~` / `$` don't overlap at the leading
612        // position); the tilde arm structurally precedes the var
613        // arm (`~` and `$` don't overlap at the leading position).
614        // Every pair is value-disjoint, so the precedence is a
615        // no-op at value level — the pin matters only at the
616        // diagnostic-shape level if a future codec round-trip ever
617        // produces a probe-as-both value.
618        //
619        // The gate covers every leading-`$` shape: the canonical
620        // `"$HOME/work/caixa-teia"` (POSIX shell), the braced
621        // `"${HOME}/work/caixa-teia"` (POSIX shell braces), the
622        // CI-manifest idiom `"${WORKSPACE}/caixa-teia"` (the
623        // GitHub Actions / GitLab CI / Drone paste footgun), the
624        // XDG idiom `"$XDG_CONFIG_HOME/caixa"`, and the bare `$`
625        // (degenerate "I meant `$HOME` and forgot the rest"). All
626        // shapes route through the same `caminho.starts_with('$')`
627        // byte check.
628        if caminho.starts_with('$') {
629            return Err(DepError::FonteCaminhoVarExpansion {
630                nome: nome.to_string(),
631                caminho: caminho.to_string(),
632            });
633        }
634        // Reproducibility gate's leading-space arm. The b94fd83 / a5c248e /
635        // f4efe9c arms closed the leading-byte host-layout-leak shapes
636        // (`/` / `~` / `$`); the embedded-control-byte arm below closes
637        // every byte in `0x00..=0x1F` plus `0x7F` (which already includes
638        // tab `0x09`, LF `0x0A`, CR `0x0D` — every ASCII whitespace
639        // *except* the ASCII space byte `0x20`). The bare ASCII space at
640        // the leading position is the orthogonal paste-from-aligned-doc
641        // shape that silently passed every prior arm: `Path::is_absolute`
642        // returns false on `" ../caixa-teia"` (the leading byte is `0x20`
643        // not `0x2F`), `0x20` is not `~` / `$` / `\` / a control byte, and
644        // the value's last byte is not `/`, so the canonical
645        // paste-from-aligned-`caixa.lisp`-doc footgun (every `:fonte`
646        // form in a multi-entry `:deps` block sits at the same column —
647        // an author selecting `"<sp><sp><sp>../caixa-teia"` and pasting
648        // it from the rendered alignment into a fresh entry preserves the
649        // leading whitespace verbatim) silently rendered as a path with
650        // a leading-space directory component the resolver folds through
651        // `Path::join` looking for a literal `./ ../caixa-teia`
652        // subdirectory that fails at resolve time with a non-self-
653        // locating `No such file or directory` error.
654        //
655        // The lacre pipeline's reproducibility contract bites
656        // strictly at this byte: `path:" ../caixa-teia"` and
657        // `path:"../caixa-teia"` yield distinct BLAKE3 closures
658        // (`conteudo: format!("path:{caminho}")`,
659        // caixa-resolver/src/resolve.rs:189) for the byte-divergent /
660        // semantic-identical caixa, and the substrate's "the lacre is
661        // the build's identity" contract (CAIXA-SDLC §III.2) silently
662        // breaks across two workstations whose authors differ only in
663        // paste-from-aligned-doc whitespace habits — the most insidious
664        // failure mode the typed slot can carry (no error surfaces; the
665        // divergence is invisible until two machines compare lacres).
666        //
667        // The arm fires AFTER the absolute / tilde / var leading-byte
668        // arms (each names the more self-locating shell-convention
669        // diagnostic on values that probe as that arm's leading-byte
670        // sentinel followed by a leading space — e.g.
671        // `:caminho "/  /foo"` surfaces `FonteCaminhoAbsolute` because
672        // the leading byte is `/`, not space) and BEFORE the
673        // embedded-control-byte arm (a leading-space value with an
674        // embedded control byte surfaces the broader leading-space
675        // diagnostic because the cascade walks leading-byte arms first
676        // — peer with how `FonteCaminhoAbsolute` precedes
677        // `FonteCaminhoControlChar` on `"/etc/passwd\n"`).
678        //
679        // The peer single-token-shaped axes already reject leading
680        // whitespace on the same paste-from-aligned-doc contract:
681        // [`crate::render::is_git_repo_url`] rejects leading whitespace
682        // on `:fonte :repo`, [`crate::render::is_git_ref_name`] rejects
683        // leading whitespace on `:fonte :tag`/`:branch`,
684        // [`crate::render::is_chart_description_shape`] rejects leading
685        // whitespace on `:descricao`,
686        // [`crate::render::is_spdx_expression_shape`] rejects leading
687        // whitespace on `:licenca`. Closing the same byte on
688        // `:fonte :caminho` makes the substrate-wide "no leading ASCII
689        // space anywhere in a typed string slot" invariant structurally
690        // consistent across every value-shape-gated typed surface (the
691        // `:caminho` axis was the last typed string surface still
692        // admitting a leading space byte).
693        if caminho.starts_with(' ') {
694            return Err(DepError::FonteCaminhoLeadingWhitespace {
695                nome: nome.to_string(),
696                caminho: caminho.to_string(),
697            });
698        }
699        // Reproducibility gate's leading-`-` CLI-argument-injection arm.
700        // The b94fd83 + a5c248e + f4efe9c + LeadingWhitespace arms closed
701        // the four prior leading-byte shapes (`/` / `~` / `$` / space);
702        // this arm closes the orthogonal leading-`-` axis on the same
703        // subprocess-argument-boundary the peer `is_git_repo_url` arm
704        // (render.rs:2037, `-upload-pack=…` on `:fonte :repo`) and
705        // `is_git_ref_name` arm (render.rs:1381, 5a28454, `-stable` on
706        // `:fonte :tag` / `:branch`) already reject.
707        //
708        // The lacre pipeline embeds `:caminho` verbatim in its per-dep
709        // content-address (`conteudo: format!("path:{caminho}")`,
710        // caixa-resolver/src/resolve.rs:189) and the resolver folds the
711        // value through `Path::join` looking for a literal `./{caminho}`
712        // subdirectory. Every downstream subprocess that consumes the
713        // resolved path — a `git -C {caminho} <verb>` invocation, a
714        // future `feira tofu` `terraform -chdir={caminho}` shell-out, a
715        // future operator-side `nix build --path {caminho}` spawn, an
716        // `xargs` / `find {caminho}` / `stat {caminho}` /
717        // `rm -rf {caminho}` cleanup — reinterprets a leading-`-` value
718        // as a CLI flag rather than a positional path when the
719        // subprocess invocation does not carry a `--` argument-list
720        // terminator between the flag block and the path argument. The
721        // canonical footguns:
722        //
723        //   - `:caminho "-rf"` — bare short-flag paste (`rm -rf` /
724        //     `find -rf` reinterpretation; the byte the peer
725        //     `FonteCaminhoShellSemicolon` arm's `; rm -rf build`
726        //     example paste-idiom carries as its first token).
727        //   - `:caminho "-C"` — `git -C` config-injection paste
728        //     (`git -C -C` reinterprets the second `-C` as another
729        //     `--change-directory` flag rather than the path
730        //     argument; the canonical `git -C <path>` porcelain
731        //     idiom every multi-repo workspace tool carries).
732        //   - `:caminho "--upload-pack=cat /etc/passwd"` — the
733        //     canonical long-flag CLI-arg-injection vector at every
734        //     git porcelain entry point (`git clone`, `git fetch`,
735        //     `git ls-remote`) that consumes a path or URL
736        //     argument; peer with `is_git_repo_url`'s leading-`-`
737        //     arm (render.rs:2037) on the sibling `:fonte :repo`
738        //     axis, which the arm's diagnostic explicitly cites.
739        //   - `:caminho "--config=…"` / `:caminho "-c"` — git-config
740        //     override paste-idiom (paste-from-`git -c foo=bar`
741        //     shell-history footgun that reinterprets the value as
742        //     a `[foo] bar` config injection on every git porcelain
743        //     entry point).
744        //
745        // POSIX `std::path::Path` treats a leading `-` as a literal
746        // filename byte, so the resolver folds `-rf` through `Path::join`
747        // and looks for a literal `./-rf` subdirectory — the failure
748        // surfaces at resolve time with a non-self-locating `No such
749        // file or directory` error far from the source caixa.lisp, and
750        // the value rides through the lacre content-address into every
751        // downstream shell-spawned subprocess. On any consumer that
752        // shells out without the `--` terminator (the common case at
753        // every porcelain entry-point) the reinterpretation is silent
754        // and the failure mode is arbitrary-argument-injection.
755        //
756        // The arm fires AFTER the absolute / tilde / var / leading-space
757        // leading-byte arms (each names the more self-locating shell-
758        // convention diagnostic on values that probe as that arm's
759        // leading-byte sentinel — the byte sets are pairwise disjoint at
760        // the leading position, so the precedence pin is a no-op at
761        // value level, but the ordering keeps every leading-byte arm's
762        // diagnostic-shape stable) and BEFORE the embedded-control-byte
763        // arm (a leading-`-` value with an embedded control byte
764        // surfaces the narrower leading-`-` diagnostic because the
765        // cascade walks leading-byte arms first — peer with how
766        // `FonteCaminhoAbsolute` precedes `FonteCaminhoControlChar` on
767        // `"/etc/passwd\n"`, and how `FonteCaminhoLeadingWhitespace`
768        // precedes `FonteCaminhoControlChar` on `" ../foo\n"`).
769        //
770        // The peer single-token-shaped axes already reject leading `-`
771        // on the same CLI-arg-injection contract:
772        // [`crate::render::is_git_repo_url`] rejects it on `:fonte :repo`
773        // (render.rs:2037), [`crate::render::is_git_ref_name`] rejects
774        // it on `:fonte :tag` / `:fonte :branch` (render.rs:1381,
775        // 5a28454), [`crate::render::is_dns_1123_label`] rejects it on
776        // every DNS-1123-shaped axis (top-level Caixa `:nome`, `:membros
777        // :caixa`, `:children :caixa`, `:deps :nome`, cluster names),
778        // [`crate::render::is_cargo_feature_name`] rejects it on
779        // `:caracteristicas`, and the feira `init` / `add <nome>`
780        // positional gate (868c191) rejects it on the CLI positional
781        // itself. Closing the same byte on `:fonte :caminho` makes the
782        // substrate-wide "no leading `-` anywhere in a typed single-
783        // token string slot routed through a subprocess argument"
784        // invariant structurally consistent across every value-shape-
785        // gated typed surface (the `:caminho` axis was the last typed
786        // string surface still admitting a leading `-` byte).
787        if caminho.starts_with('-') {
788            return Err(DepError::FonteCaminhoLeadingHyphen {
789                nome: nome.to_string(),
790                caminho: caminho.to_string(),
791            });
792        }
793        // Reproducibility gate's embedded-control-byte arm. The
794        // b94fd83 + a5c248e + f4efe9c arms closed the three
795        // leading-byte host-layout-leak shapes (`/` / `~` / `$`);
796        // this arm closes the orthogonal embedded-control-byte
797        // axis — any ASCII control byte (`0x00..=0x1F` plus
798        // `0x7F` DEL) appearing anywhere in `:caminho`. Same
799        // shape every peer single-token-typed-slot value-shape
800        // predicate the surrounding [`crate::render`] cluster
801        // gates against (the lifted `is_git_repo_url` arm on
802        // `:fonte :repo`, the `is_git_ref_name` arm on
803        // `:tag`/`:branch`, the `is_chart_description_shape` /
804        // `is_chart_maintainer_name_shape` /
805        // `is_chart_keyword_shape` arms on the
806        // Helm-chart-shaped axes); now consistent on the
807        // `:caminho` axis too.
808        //
809        // Until this gate landed any embedded control byte
810        // silently passed validate, the lacre pipeline embedded
811        // the value verbatim in its per-dep content-address
812        // (`conteudo: format!("path:{caminho}")`,
813        // caixa-resolver/src/resolve.rs:189), and the failure
814        // forked per byte and per consumer:
815        //
816        //   - NUL (`0x00`) the canonical "POSIX paths cannot
817        //     contain a NUL byte" shape: every `std::fs` syscall
818        //     routes the path through `CString::new`, which
819        //     fails with `NulError` on the first NUL byte; the
820        //     build would surface a `NulError` at resolve time
821        //     far from the source caixa.lisp.
822        //   - LF (`0x0A`) / CR (`0x0D`) the canonical paste-from-
823        //     multiline-doc footgun: a `:caminho
824        //     "../caixa-teia\nrm -rf /"` value (paste landed mid-
825        //     `:caminho` block from a multi-line code-fence)
826        //     silently round-trips through `Path::join` but the
827        //     embedded newline class is a sibling of the CRLF-at-
828        //     subprocess-argument injection vector
829        //     `is_git_repo_url` already closes on `:repo`.
830        //   - Tab (`0x09`) the canonical paste-from-aligned-table
831        //     footgun: the tab is invisible in most editors, and
832        //     the lacre embeds the value verbatim so two
833        //     paste-from-distinct-tables yield divergent lacres
834        //     across host editors that strip vs preserve tabs.
835        //   - DEL (`0x7F`) + every other `0x00..=0x1F` byte: the
836        //     paste-from-binary-blob shape every peer single-
837        //     token-shaped slot rejects under the same
838        //     `b < 0x20 || b == 0x7F` predicate.
839        //
840        // Mirrors the cascade discipline every prior `:caminho`
841        // arm establishes: `FonteCaminhoEmpty` →
842        // `FonteCaminhoAbsolute` → `FonteCaminhoTildeExpansion`
843        // → `FonteCaminhoVarExpansion` →
844        // `FonteCaminhoLeadingWhitespace` →
845        // `FonteCaminhoLeadingHyphen` → `FonteCaminhoControlChar`.
846        // The six leading-byte arms structurally precede the
847        // embedded-byte arm because the leading-byte shapes are
848        // the more self-locating diagnostic on values that probe
849        // as both (e.g. `:caminho "/etc/passwd\n"` surfaces the
850        // narrower `FonteCaminhoAbsolute` rather than the broader
851        // embedded-control-byte arm); the precedence pin matters
852        // at the diagnostic-shape level even though the empty /
853        // absolute / tilde / var arms are value-disjoint from a
854        // bare control byte (which would itself be a leading
855        // byte under the empty / absolute / tilde / var arms'
856        // leading-position semantics, but those arms guard the
857        // specific shell-convention characters `/` / `~` / `$`
858        // — a leading `0x01` byte falls through to this arm).
859        for &b in caminho.as_bytes() {
860            if b < 0x20 || b == 0x7F {
861                return Err(DepError::FonteCaminhoControlChar {
862                    nome: nome.to_string(),
863                    caminho: caminho.to_string(),
864                    byte: b,
865                });
866            }
867        }
868        // Reproducibility gate's Windows-path-separator arm. The four
869        // leading-byte arms (`/` / `~` / `$`) and the embedded-
870        // control-byte arm close the host-layout-leaking + paste-from-
871        // multiline-doc shapes; the leading-`\` / embedded-`\` byte is
872        // the orthogonal cross-host-OS-separator shape — same render-
873        // determinism axis, different semantic mechanism. POSIX
874        // [`std::path::Path`] treats `\` (0x5C) as a literal byte
875        // inside a single path component (so `..\caixa-teia` is one
876        // directory named literally `..\caixa-teia`, sibling of `.`
877        // and `..`); Windows [`std::path::Path`] treats `\` as a
878        // primary path separator equal to `/` (so `..\caixa-teia` is
879        // the parent's sibling directory `caixa-teia`). The lacre
880        // pipeline embeds the value verbatim in its per-dep content-
881        // address (`conteudo: format!("path:{caminho}")`, caixa-
882        // resolver/src/resolve.rs:189), so byte-identical caixa.lisp
883        // values resolve to two distinct directories across runner
884        // OSes — the same THEORY.md §V.2 render-determinism contract
885        // the absolute / tilde / var arms protect, here against the
886        // cross-host-OS-separator divergence vector. Even on POSIX-
887        // only resolvers (the canonical pleme-io substrate posture),
888        // a `..\caixa-teia` (the Windows-Explorer "copy as path" /
889        // PowerShell `Get-Location` paste-idiom footgun) silently
890        // passes every prior arm because `Path::is_absolute` returns
891        // false on `..` and `\` is neither a leading-byte sentinel
892        // nor a control byte, then the resolver folds the value
893        // through `Path::new(caminho).join(<file>)` looking for a
894        // literal `./..\caixa-teia` subdirectory and fails at
895        // resolve time with a non-self-locating `No such file or
896        // directory` error far from the source caixa.lisp.
897        //
898        // The peer single-token-shaped axes on the same git-CLI /
899        // path-CLI consumer cluster already reject `\` under the same
900        // Windows-path-leak banner: [`crate::render::is_git_ref_name`]
901        // line 1441 (`"must not contain \\ … the canonical Windows-
902        // path-leak footgun; use / for hierarchical refs"`) gates
903        // `:fonte :tag` / `:fonte :branch` against the same byte,
904        // and [`crate::render::is_gateway_api_http_path`] line 506
905        // includes `\` in the eleven-byte RFC-3986-reserved rejection
906        // set on `:entrada :paths`. Closing the same byte on `:fonte
907        // :caminho` makes the substrate-wide "no Windows path
908        // separator anywhere in a typed string slot" invariant
909        // structurally consistent across every path-shaped typed
910        // surface (the `:caminho` axis was the last typed string
911        // surface still admitting `\`).
912        //
913        // The arm fires AFTER the control-char arm because the
914        // control-char diagnostic is the more self-locating axis on
915        // values that probe as both (`"..\caixa\0teia"` carries both
916        // a `\` and a NUL — NUL is the load-bearing POSIX-syscall-
917        // rejected byte, so `FonteCaminhoControlChar` wins). Same
918        // narrower-diagnostic-first cascade discipline every prior
919        // arm establishes. A pure-`\` value
920        // (`"..\caixa-teia"` with no control bytes) falls through
921        // every prior arm and lands here.
922        for &b in caminho.as_bytes() {
923            if b == b'\\' {
924                return Err(DepError::FonteCaminhoBackslash {
925                    nome: nome.to_string(),
926                    caminho: caminho.to_string(),
927                });
928            }
929        }
930        // Reproducibility gate's shell-redirection arm. The 3a4e1d7 backslash
931        // arm closes the cross-host-OS-separator vector; `<` (`0x3C`) and `>`
932        // (`0x3E`) are the orthogonal shell-redirection sentinels — same
933        // paste-from-shell-prompt footgun class, different syntactic surface.
934        // POSIX `std::path::Path` treats `<` / `>` as literal bytes inside a
935        // single path component (so `../caixa-teia>output` is one directory
936        // named literally `../caixa-teia>output`, sibling of `.` and `..`),
937        // but every interactive shell (bash / zsh / fish / nushell) lexes
938        // `<` / `>` as input / output redirection operators — a `:caminho
939        // "../caixa-teia>build.log"` (the canonical "I pasted a shell
940        // pipeline that wrote build output and forgot to trim the redirect"
941        // footgun) or `:caminho "../<input.lisp"` (the symmetric input-
942        // redirection paste idiom) silently passes every prior arm because
943        // `Path::is_absolute` returns false, `<` / `>` are neither leading-
944        // byte sentinels nor control bytes nor `\`, and the value's last byte
945        // isn't `/`. The resolver folds the value through
946        // `Path::new(caminho).join(<file>)` looking for a literal
947        // `./..\caixa-teia>build.log` subdirectory and fails at resolve time
948        // with a non-self-locating `No such file or directory` error far
949        // from the source caixa.lisp.
950        //
951        // The lacre pipeline embeds the value verbatim in its per-dep
952        // content-address (`conteudo: format!("path:{caminho}")`,
953        // caixa-resolver/src/resolve.rs:189), so a `<` / `>` byte lands in
954        // the BLAKE3 closure and rides downstream as part of the build's
955        // identity. The bytes carry a second class of hazard the prior
956        // separator-shaped arms don't: every typed-string slot whose value
957        // ever flows verbatim into a shell-spawned subprocess (the caixa-
958        // resolver's `git clone` invocation, a future `feira tofu` shell-
959        // out, a future operator-side `nix flake check` spawn) is the
960        // canonical CRLF-at-subprocess-argument / shell-metachar injection
961        // surface that every peer single-token-shaped typed slot already
962        // closes. The peer path-shaped axis `[crate::render::is_gateway_api_http_path]`
963        // (caixa-core/src/render.rs:506) rejects `<` / `>` as part of its
964        // eleven-byte RFC-3986-reserved set on `:entrada :paths`, and the
965        // peer git-ref-shaped axis `[crate::render::is_git_ref_name]` rejects
966        // `<` / `>` on `:fonte :tag` / `:fonte :branch` under the same
967        // shell-metachar-injection banner. The `:caminho` axis was the last
968        // typed string surface still admitting these two bytes; this arm
969        // closes the gap so the substrate-wide "no shell-redirection
970        // metacharacter anywhere in a typed string slot" invariant is now
971        // structurally consistent across every path-shaped typed surface.
972        //
973        // The arm fires AFTER the control-char arm + backslash arm because
974        // both prior arms carry more self-locating diagnostics on values
975        // that probe as both (`"..\foo<bar"` carries both `\` and `<` — the
976        // cross-OS-separator divergence is the load-bearing axis, so the
977        // backslash arm wins; `"../foo\n<bar"` carries both LF and `<` —
978        // the POSIX-syscall-rejected byte is the load-bearing axis, so the
979        // control-char arm wins). The arm fires BEFORE the trailing-`/` arm
980        // because the embedded redirection byte is the more semantic-
981        // locating axis on probe-as-both values (`"../foo</"` ends in `/`
982        // but the load-bearing diagnostic is the embedded `<` shell-
983        // redirection — the trailing `/` is the secondary observation, and
984        // an author who removes the `<` is likely to also tab-strip the
985        // trailing separator).
986        for &b in caminho.as_bytes() {
987            if b == b'<' || b == b'>' {
988                return Err(DepError::FonteCaminhoShellRedirection {
989                    nome: nome.to_string(),
990                    caminho: caminho.to_string(),
991                    byte: b,
992                });
993            }
994        }
995        // Reproducibility gate's shell-pipe arm. The e457141 shell-redirection
996        // arm closes the `<` / `>` input/output redirection sentinels; `|`
997        // (`0x7C`) is the orthogonal shell-pipe sentinel — same paste-from-
998        // shell-prompt footgun class, different syntactic surface. POSIX
999        // `std::path::Path` treats `|` as a literal path-component byte (so
1000        // `../caixa-teia|tee` is one directory named literally
1001        // `../caixa-teia|tee`, sibling of `.` and `..`), but every interactive
1002        // shell (bash / zsh / fish / nushell) lexes `|` as the pipe operator
1003        // — a `:caminho "../caixa-teia | grep foo"` (the canonical "I copied a
1004        // `ls ../caixa-teia | grep` line out of a shell-history block and
1005        // forgot to trim the pipeline tail" footgun) or `:caminho
1006        // "../foo||bar"` (the symmetric "I copied a `cmd-a || cmd-b` short-
1007        // circuit OR line" idiom) silently passes every prior arm because
1008        // `Path::is_absolute` returns false on `..`, `|` is neither a leading-
1009        // byte sentinel nor a control byte nor `\` nor `<` / `>`, and the
1010        // value's last byte isn't `/`. The resolver folds the value through
1011        // `Path::new(caminho).join(<file>)` looking for a literal
1012        // `./../caixa-teia | grep foo` subdirectory and fails at resolve time
1013        // with a non-self-locating `No such file or directory` error far
1014        // from the source caixa.lisp.
1015        //
1016        // The lacre pipeline embeds the value verbatim in its per-dep
1017        // content-address (`conteudo: format!("path:{caminho}")`,
1018        // caixa-resolver/src/resolve.rs:189), so a `|` byte lands in the
1019        // BLAKE3 closure and rides downstream as part of the build's identity
1020        // into every shell-spawned subprocess (the caixa-resolver's `git
1021        // clone` invocation, a future `feira tofu` shell-out, a future
1022        // operator-side `nix flake check` spawn) as the canonical CRLF-at-
1023        // subprocess-argument / shell-metachar injection surface every peer
1024        // single-token-shaped typed slot already closes. The peer path-shaped
1025        // axis [`crate::render::is_gateway_api_http_path`]
1026        // (caixa-core/src/render.rs:506) rejects `|` as part of its eleven-
1027        // byte RFC-3986-reserved set on `:entrada :paths`. The `:caminho`
1028        // axis was the last typed path-string surface still admitting this
1029        // byte; this arm closes the gap so the substrate-wide "no shell-
1030        // composition metacharacter anywhere in a typed string slot that
1031        // flows verbatim into a shell-spawned subprocess" invariant extends
1032        // from shell-redirection (`<` / `>`) to shell-pipe (`|`) on the
1033        // `:caminho` axis.
1034        //
1035        // The arm fires AFTER the shell-redirection arm because the prior
1036        // arm's two-byte `byte: u8` payload is the more self-locating axis on
1037        // values that probe as both (`"../caixa-teia<input|tee"` carries both
1038        // `<` and `|` — the input-redirection-paste idiom is the load-bearing
1039        // root-cause edit, so `FonteCaminhoShellRedirection` wins; same
1040        // cascade discipline every prior `:caminho` arm establishes). The arm
1041        // fires BEFORE the trailing-`/` arm because the embedded pipe byte is
1042        // the more semantic-locating axis on probe-as-both values
1043        // (`"../foo|tee/"` ends in `/` but the load-bearing diagnostic is the
1044        // embedded `|` shell-pipe — the trailing `/` is the secondary
1045        // observation, and an author who removes the `|` is likely to also
1046        // tab-strip the trailing separator).
1047        for &b in caminho.as_bytes() {
1048            if b == b'|' {
1049                return Err(DepError::FonteCaminhoShellPipe {
1050                    nome: nome.to_string(),
1051                    caminho: caminho.to_string(),
1052                });
1053            }
1054        }
1055        // Reproducibility gate's shell-command-separator arm. The 124106f
1056        // shell-pipe arm closes the `|` byte; `;` (`0x3B`) is the orthogonal
1057        // shell-command-separator sentinel — same paste-from-shell-prompt
1058        // footgun class, different syntactic surface. POSIX `std::path::Path`
1059        // treats `;` as a literal path-component byte (so
1060        // `../caixa-teia;rm -rf /` is one directory named literally
1061        // `../caixa-teia;rm -rf /`, sibling of `.` and `..`), but every
1062        // interactive shell (bash / zsh / fish / nushell) lexes `;` as the
1063        // sequential-command terminator that fires the next command
1064        // regardless of the prior command's exit status — a `:caminho
1065        // "../caixa-teia; rm -rf build"` (the canonical "I pasted a shell
1066        // one-liner that chained a cleanup tail after the directory name"
1067        // footgun) or `:caminho "../foo;;bar"` (the symmetric "I copied a
1068        // POSIX `case` arm's `;;` terminator into the middle of a path"
1069        // idiom) silently passes every prior arm because `Path::is_absolute`
1070        // returns false on `..`, `;` is neither a leading-byte sentinel nor a
1071        // control byte nor `\` nor `<` / `>` nor `|`, and the value's last
1072        // byte isn't `/`. The resolver folds the value through
1073        // `Path::new(caminho).join(<file>)` looking for a literal
1074        // `./../caixa-teia; rm -rf build` subdirectory and fails at resolve
1075        // time with a non-self-locating `No such file or directory` error far
1076        // from the source caixa.lisp.
1077        //
1078        // The lacre pipeline embeds the value verbatim in its per-dep
1079        // content-address (`conteudo: format!("path:{caminho}")`,
1080        // caixa-resolver/src/resolve.rs:189), so a `;` byte lands in the
1081        // BLAKE3 closure and rides downstream as part of the build's identity
1082        // into every shell-spawned subprocess (the caixa-resolver's `git
1083        // clone` invocation, a future `feira tofu` shell-out, a future
1084        // operator-side `nix flake check` spawn) as the canonical
1085        // shell-metachar injection surface every peer single-token-shaped
1086        // typed slot already closes. The peer path-shaped axis
1087        // [`crate::render::is_gateway_api_http_path`]
1088        // (caixa-core/src/render.rs:506) rejects `;` as part of its eleven-
1089        // byte RFC-3986-reserved set on `:entrada :paths`. The `:caminho`
1090        // axis was the last typed path-string surface still admitting this
1091        // byte; this arm closes the gap so the substrate-wide "no shell-
1092        // composition metacharacter anywhere in a typed string slot that
1093        // flows verbatim into a shell-spawned subprocess" invariant extends
1094        // from shell-pipe (`|`) to shell-command-separator (`;`) on the
1095        // `:caminho` axis.
1096        //
1097        // The arm fires AFTER the shell-pipe arm because the prior arm's
1098        // canonical-cmd-a-|-cmd-b shape is the more common shell-history
1099        // paste idiom on values that probe as both (`"../caixa-teia | tee;
1100        // rm"` carries both `|` and `;` — the pipeline-tail paste is the
1101        // load-bearing root-cause edit, so `FonteCaminhoShellPipe` wins; same
1102        // cascade discipline every prior `:caminho` arm establishes). The arm
1103        // fires BEFORE the trailing-`/` arm because the embedded
1104        // command-separator byte is the more semantic-locating axis on
1105        // probe-as-both values (`"../foo;rm/"` ends in `/` but the
1106        // load-bearing diagnostic is the embedded `;` shell-command-
1107        // separator — the trailing `/` is the secondary observation, and an
1108        // author who removes the `;` is likely to also tab-strip the trailing
1109        // separator).
1110        for &b in caminho.as_bytes() {
1111            if b == b';' {
1112                return Err(DepError::FonteCaminhoShellSemicolon {
1113                    nome: nome.to_string(),
1114                    caminho: caminho.to_string(),
1115                });
1116            }
1117        }
1118        // Reproducibility gate's shell-background / logical-AND arm. The
1119        // 05c358e shell-command-separator arm closes the `;` byte; `&`
1120        // (`0x26`) is the orthogonal shell-background / list-AND sentinel
1121        // — same paste-from-shell-prompt footgun class, different
1122        // syntactic surface. POSIX `std::path::Path` treats `&` as a
1123        // literal path-component byte (so `../caixa-teia & sleep 1` is
1124        // one directory named literally `../caixa-teia & sleep 1`,
1125        // sibling of `.` and `..`), but every interactive shell
1126        // (bash / zsh / fish / nushell) lexes `&` two ways:
1127        //
1128        //   - Single `&` as the background-task terminator that detaches
1129        //     the prior command into the background and returns control
1130        //     to the prompt immediately (the canonical `cmd &` idiom
1131        //     every long-running pipeline uses);
1132        //   - Double `&&` as the logical-AND list operator that fires
1133        //     the next command only if the prior command succeeded (the
1134        //     canonical `make && make install` idiom every build script
1135        //     carries).
1136        //
1137        // A `:caminho "../caixa-teia & sleep 1"` (the canonical "I
1138        // pasted a `cd path & sleep 1` background-launch into the
1139        // `:caminho` slot" footgun) or `:caminho "../caixa-teia && make"`
1140        // (the symmetric "I copied a `cd path && make` build chain"
1141        // idiom) silently passes every prior arm because
1142        // `Path::is_absolute` returns false on `..`, `&` is neither a
1143        // leading-byte sentinel nor a control byte nor `\` nor
1144        // `<` / `>` nor `|` nor `;`, and the value's last byte isn't `/`.
1145        // The resolver folds the value through
1146        // `Path::new(caminho).join(<file>)` looking for a literal
1147        // `./../caixa-teia & sleep 1` subdirectory and fails at resolve
1148        // time with a non-self-locating `No such file or directory`
1149        // error far from the source caixa.lisp.
1150        //
1151        // The lacre pipeline embeds the value verbatim in its per-dep
1152        // content-address (`conteudo: format!("path:{caminho}")`,
1153        // caixa-resolver/src/resolve.rs:189), so an `&` byte lands in
1154        // the BLAKE3 closure and rides downstream as part of the build's
1155        // identity into every shell-spawned subprocess (the
1156        // caixa-resolver's `git clone` invocation, a future `feira tofu`
1157        // shell-out, a future operator-side `nix flake check` spawn) as
1158        // the canonical shell-metachar injection surface every peer
1159        // single-token-shaped typed slot already closes. The peer
1160        // path-shaped axis [`crate::render::is_gateway_api_http_path`]
1161        // (caixa-core/src/render.rs:506) rejects `&` as part of its
1162        // eleven-byte RFC-3986-reserved set on `:entrada :paths`. The
1163        // `:caminho` axis was the last typed path-string surface still
1164        // admitting this byte; this arm closes the gap so the
1165        // substrate-wide "no shell-composition metacharacter anywhere
1166        // in a typed string slot that flows verbatim into a
1167        // shell-spawned subprocess" invariant extends from
1168        // shell-command-separator (`;`) to shell-background /
1169        // logical-AND (`&`) on the `:caminho` axis.
1170        //
1171        // The arm fires AFTER the shell-command-separator arm because
1172        // the prior arm's `cmd-a; cmd-b` shape is the more common
1173        // shell-history paste idiom on values that probe as both
1174        // (`"../caixa-teia; rm & sleep"` carries both `;` and `&` — the
1175        // command-separator-tail paste is the load-bearing root-cause
1176        // edit, so `FonteCaminhoShellSemicolon` wins; same cascade
1177        // discipline every prior `:caminho` arm establishes). The arm
1178        // fires BEFORE the trailing-`/` arm because the embedded
1179        // background / list-AND byte is the more semantic-locating axis
1180        // on probe-as-both values (`"../foo&bar/"` ends in `/` but the
1181        // load-bearing diagnostic is the embedded `&` shell-background
1182        // / logical-AND metachar — the trailing `/` is the secondary
1183        // observation, and an author who removes the `&` is likely to
1184        // also tab-strip the trailing separator).
1185        for &b in caminho.as_bytes() {
1186            if b == b'&' {
1187                return Err(DepError::FonteCaminhoShellBackground {
1188                    nome: nome.to_string(),
1189                    caminho: caminho.to_string(),
1190                });
1191            }
1192        }
1193        // Reproducibility gate's shell-command-substitution arm. The
1194        // e12e4f3 shell-background / logical-AND arm closes the `&`
1195        // byte; the backtick (`0x60`) is the orthogonal POSIX legacy
1196        // command-substitution sentinel — every POSIX shell (sh /
1197        // bash / zsh / dash / ksh / fish / nushell) lexes the byte as
1198        // the canonical legacy wrapper that runs the enclosed command
1199        // and substitutes its standard-output verbatim into the
1200        // surrounding word (a `whoami` wrapped in backticks expands
1201        // to the current user's name; a `cat /etc/passwd` wrapped in
1202        // backticks expands to the file's contents — the canonical
1203        // CWE-78 shell-command-injection vector every shell-side
1204        // hardening guide enumerates first). POSIX
1205        // `std::path::Path` treats backtick as a literal path-
1206        // component byte (so `../caixa-teia/<backtick>whoami<backtick>`
1207        // is one directory named literally that, sibling of `.` and
1208        // `..`).
1209        //
1210        // A `:caminho "../caixa-teia/<backtick>whoami<backtick>"` (the
1211        // canonical "I pasted a shell one-liner carrying a backticked
1212        // `whoami` command-substitution expansion into the `:caminho`
1213        // slot" footgun) or `:caminho "<backtick>pwd<backtick>/caixa-
1214        // teia"` (the symmetric "I copied a `<backtick>pwd<backtick>/
1215        // path` working-directory expansion") silently passes every
1216        // prior arm because `Path::is_absolute` returns false on
1217        // `..`, the backtick byte is neither a leading-byte sentinel
1218        // (the f4efe9c `FonteCaminhoVarExpansion` arm catches the
1219        // modern `$()` form at leading position only; backtick is
1220        // the orthogonal legacy form) nor a control byte nor `\` nor
1221        // `<` / `>` nor `|` nor `;` nor `&`, and the value's last
1222        // byte isn't `/`. The resolver folds the value through
1223        // `Path::new(caminho).join(<file>)` looking for a literal
1224        // subdirectory whose name embeds the backticked token and
1225        // fails at resolve time with a non-self-locating `No such
1226        // file or directory` error far from the source caixa.lisp.
1227        //
1228        // The lacre pipeline embeds the value verbatim in its per-
1229        // dep content-address (`conteudo: format!("path:{caminho}")`,
1230        // caixa-resolver/src/resolve.rs:189), so a backtick byte
1231        // lands in the BLAKE3 closure and rides downstream as part
1232        // of the build's identity into every shell-spawned
1233        // subprocess (the caixa-resolver's `git clone` invocation, a
1234        // future `feira tofu` shell-out, a future operator-side
1235        // `nix flake check` spawn) as the canonical shell-metachar
1236        // injection surface every peer single-token-shaped typed
1237        // slot already closes. The peer path-shaped axis
1238        // [`crate::render::is_gateway_api_http_path`]
1239        // (caixa-core/src/render.rs:506) rejects backtick as part of
1240        // its eleven-byte RFC-3986-reserved set on `:entrada
1241        // :paths`. The `:caminho` axis was the last typed path-
1242        // string surface still admitting this byte; this arm closes
1243        // the gap so the substrate-wide "no shell-composition
1244        // metacharacter anywhere in a typed string slot that flows
1245        // verbatim into a shell-spawned subprocess" invariant
1246        // extends from shell-background / logical-AND (`&`) to
1247        // shell-command-substitution (backtick) on the `:caminho`
1248        // axis.
1249        //
1250        // The arm fires AFTER the shell-background arm because the
1251        // prior arm's `cmd & sleep` shape is the more common shell-
1252        // history paste idiom on values that probe as both (a
1253        // `"../caixa-teia & <backtick>whoami<backtick>"` carries
1254        // both `&` and a backtick — the background-launch tail is
1255        // the load-bearing root-cause edit, so
1256        // `FonteCaminhoShellBackground` wins; same cascade
1257        // discipline every prior `:caminho` arm establishes). The
1258        // arm fires BEFORE the trailing-`/` arm because the
1259        // embedded command-substitution byte is the more semantic-
1260        // locating axis on probe-as-both values (a
1261        // `"../<backtick>whoami<backtick>/"` ends in `/` but the
1262        // load-bearing diagnostic is the embedded backtick shell-
1263        // command-substitution metachar — the trailing `/` is the
1264        // secondary observation, and an author who removes the
1265        // backtick is likely to also tab-strip the trailing
1266        // separator).
1267        for &b in caminho.as_bytes() {
1268            if b == b'`' {
1269                return Err(DepError::FonteCaminhoShellCommandSubstitution {
1270                    nome: nome.to_string(),
1271                    caminho: caminho.to_string(),
1272                });
1273            }
1274        }
1275        // Reproducibility gate's shell-glob arm. The c4d62b3 shell-command-
1276        // substitution arm closes the backtick byte; `*` (`0x2A`) and `?`
1277        // (`0x3F`) are the orthogonal POSIX glob-expansion sentinels — same
1278        // paste-from-shell-prompt footgun class, different syntactic surface.
1279        // Every POSIX shell (sh / bash / zsh / dash / ksh / fish / nushell)
1280        // lexes `*` and `?` as pathname-expansion wildcards: `*` matches any
1281        // sequence of characters in a path component (including the empty
1282        // sequence), `?` matches exactly one character. POSIX
1283        // `std::path::Path` treats both bytes as literal path-component bytes
1284        // (so `../caixa-teia/*.lisp` is one directory named literally
1285        // `../caixa-teia/*.lisp`, sibling of `.` and `..`).
1286        //
1287        // A `:caminho "../caixa-teia/*"` (the canonical "I pasted a
1288        // `ls ../caixa-teia/*` shell-listing one-liner into the `:caminho`
1289        // slot" footgun) or `:caminho "../foo?"` (the symmetric "I copied a
1290        // `rm foo?` single-char-wildcard removal idiom") silently passes
1291        // every prior arm because `Path::is_absolute` returns false on `..`,
1292        // `*` / `?` are neither leading-byte sentinels nor control bytes nor
1293        // `\` nor `<` / `>` nor `|` nor `;` nor `&` nor backtick, and the
1294        // value's last byte isn't `/`. The resolver folds the value through
1295        // `Path::new(caminho).join(<file>)` looking for a literal
1296        // `./../caixa-teia/*` subdirectory and fails at resolve time with a
1297        // non-self-locating `No such file or directory` error far from the
1298        // source caixa.lisp.
1299        //
1300        // The lacre pipeline embeds the value verbatim in its per-dep
1301        // content-address (`conteudo: format!("path:{caminho}")`,
1302        // caixa-resolver/src/resolve.rs:189), so a `*` or `?` byte lands in
1303        // the BLAKE3 closure and rides downstream as part of the build's
1304        // identity into every shell-spawned subprocess (the caixa-resolver's
1305        // `git clone` invocation, a future `feira tofu` shell-out, a future
1306        // operator-side `nix flake check` spawn) as the canonical
1307        // shell-metachar / pathname-expansion surface every peer
1308        // single-token-shaped typed slot already closes. The peer path-shaped
1309        // axis [`crate::render::is_gateway_api_http_path`]
1310        // (caixa-core/src/render.rs:506) rejects `*` and `?` as part of its
1311        // eleven-byte RFC-3986-reserved set on `:entrada :paths`. The
1312        // `:caminho` axis was the last typed path-string surface still
1313        // admitting these two bytes; this arm closes the gap so the
1314        // substrate-wide "no shell-composition / glob-expansion
1315        // metacharacter anywhere in a typed string slot that flows verbatim
1316        // into a shell-spawned subprocess" invariant extends from
1317        // shell-command-substitution (backtick) to glob-expansion
1318        // (`*` / `?`) on the `:caminho` axis.
1319        //
1320        // The arm fires AFTER the backtick arm because the prior arm's
1321        // CWE-78 shell-command-injection vector is the load-bearing
1322        // diagnostic on values that probe as both (a `"../`whoami`/*"`
1323        // carries both backtick and `*` — the command-substitution paste
1324        // is the load-bearing root-cause edit, so
1325        // `FonteCaminhoShellCommandSubstitution` wins; same cascade
1326        // discipline every prior `:caminho` arm establishes). The arm
1327        // fires BEFORE the trailing-`/` arm because the embedded glob
1328        // byte is the more semantic-locating axis on probe-as-both values
1329        // (`"../foo*/"` ends in `/` but the load-bearing diagnostic is the
1330        // embedded `*` glob metachar — the trailing `/` is the secondary
1331        // observation, and an author who removes the `*` is likely to
1332        // also tab-strip the trailing separator).
1333        for &b in caminho.as_bytes() {
1334            if b == b'*' || b == b'?' {
1335                return Err(DepError::FonteCaminhoShellGlob {
1336                    nome: nome.to_string(),
1337                    caminho: caminho.to_string(),
1338                    byte: b,
1339                });
1340            }
1341        }
1342        // Reproducibility gate's shell-subshell-grouping arm. The cf9034b
1343        // shell-glob arm closes the `*` / `?` pathname-expansion sentinels;
1344        // `(` (`0x28`) and `)` (`0x29`) are the orthogonal POSIX subshell-
1345        // grouping sentinels — same paste-from-shell-prompt footgun class,
1346        // different syntactic surface. Every POSIX shell (sh / bash / zsh /
1347        // dash / ksh / fish / nushell) lexes the parenthesis pair as the
1348        // subshell-grouping operator: `(<cmd>)` runs `<cmd>` in a child
1349        // shell with a fresh environment scope (the canonical sandboxing
1350        // idiom every shell-history `(cd <path> && <cmd>)` one-liner uses
1351        // to scope a `cd` to one subshell without disturbing the parent's
1352        // working directory), and `$(<cmd>)` is the modern Bourne
1353        // command-substitution shape the upstream f4efe9c
1354        // `FonteCaminhoVarExpansion` arm closes the leading `$` byte of —
1355        // the closing `)` byte completes that substitution shape and must
1356        // be refused on the same axis (peer with the
1357        // [`crate::render::is_git_repo_url`] 3b99147 arm that closes the
1358        // same byte-pair on the sibling `:fonte :repo` axis under the
1359        // same shell-subshell-grouping + RFC-3986-sub-delims banner).
1360        // POSIX `std::path::Path` treats both bytes as literal path-
1361        // component bytes (so `../caixa-teia/(date)` is one directory
1362        // named literally `../caixa-teia/(date)`, sibling of `.` and
1363        // `..`).
1364        //
1365        // A `:caminho "../caixa-teia/$(date)/build"` (the canonical "I
1366        // pasted a `cd ../caixa-teia/$(date)/build` shell-history one-
1367        // liner whose modern command-substitution expansion lands the
1368        // current date as a subdirectory name" footgun) or `:caminho
1369        // "../(cd foo && pwd)/caixa-teia"` (the symmetric "I copied a
1370        // `(cd foo && pwd)` subshell-grouping working-directory probe
1371        // idiom") silently passes every prior arm because
1372        // `Path::is_absolute` returns false on `..`, `(` / `)` are
1373        // neither leading-byte sentinels nor control bytes nor `\` nor
1374        // `<` / `>` nor `|` nor `;` nor `&` nor backtick nor `*` / `?`,
1375        // and the value's last byte isn't `/`. The resolver folds the
1376        // value through `Path::new(caminho).join(<file>)` looking for a
1377        // literal `./../caixa-teia/$(date)/build` subdirectory and fails
1378        // at resolve time with a non-self-locating `No such file or
1379        // directory` error far from the source caixa.lisp.
1380        //
1381        // The lacre pipeline embeds the value verbatim in its per-dep
1382        // content-address (`conteudo: format!("path:{caminho}")`,
1383        // caixa-resolver/src/resolve.rs:189), so a `(` or `)` byte lands
1384        // in the BLAKE3 closure and rides downstream as part of the
1385        // build's identity into every shell-spawned subprocess (the
1386        // caixa-resolver's `git clone` invocation, a future `feira tofu`
1387        // shell-out, a future operator-side `nix flake check` spawn) as
1388        // the canonical shell-metachar / subshell-grouping surface every
1389        // peer single-token-shaped typed slot already closes. The peer
1390        // git-source axis [`crate::render::is_git_repo_url`] (3b99147)
1391        // rejects the same byte pair on `:fonte :repo` under the same
1392        // shell-subshell-grouping / RFC-3986-sub-delims banner. The
1393        // `:caminho` axis was the last typed path-string surface still
1394        // admitting these two bytes;
1395        // this arm closes the gap so the substrate-wide "no shell-
1396        // composition metacharacter anywhere in a typed string slot that
1397        // flows verbatim into a shell-spawned subprocess" invariant
1398        // extends from shell-glob (`*` / `?`) to shell-subshell-grouping
1399        // (`(` / `)`) on the `:caminho` axis. Together with the f4efe9c
1400        // leading-`$` arm, the typed `:caminho` accepted set now
1401        // structurally excludes the entire modern Bourne
1402        // command-substitution surface — leading `$` closes the
1403        // leading byte of every `$(<cmd>)` shape, this arm closes the
1404        // trailing `)` boundary.
1405        //
1406        // The arm fires AFTER the shell-glob arm because the prior arm's
1407        // `*` / `?` pathname-expansion shape is the more common shell-
1408        // history paste idiom on values that probe as both
1409        // (`"../caixa-teia/*(date)"` carries both `*` and `(` — the
1410        // glob-paste-tail is the load-bearing root-cause edit, so
1411        // `FonteCaminhoShellGlob` wins; same cascade discipline every
1412        // prior `:caminho` arm establishes). The arm fires BEFORE the
1413        // trailing-`/` arm because the embedded subshell-grouping byte
1414        // is the more semantic-locating axis on probe-as-both values
1415        // (`"../foo(date)/"` ends in `/` but the load-bearing diagnostic
1416        // is the embedded `(` shell-subshell-grouping metachar — the
1417        // trailing `/` is the secondary observation, and an author who
1418        // removes the `(` is likely to also tab-strip the trailing
1419        // separator).
1420        for &b in caminho.as_bytes() {
1421            if b == b'(' || b == b')' {
1422                return Err(DepError::FonteCaminhoShellSubshellGrouping {
1423                    nome: nome.to_string(),
1424                    caminho: caminho.to_string(),
1425                    byte: b,
1426                });
1427            }
1428        }
1429        // Reproducibility gate's shell-brace-expansion arm. The 0633c91
1430        // shell-subshell-grouping arm closes `(` / `)`; `{` (`0x7b`) and
1431        // `}` (`0x7d`) are the orthogonal shell-brace-expansion /
1432        // URI-Template-placeholder byte pair — same paste-from-shell-
1433        // prompt + paste-from-templated-doc footgun class, different
1434        // syntactic surface. Every POSIX-derived shell that implements
1435        // brace expansion (bash / zsh / ksh / fish; the canonical
1436        // `mkdir -p ../{caixa-teia,caixa-helm,caixa-flux}` /
1437        // `cp file{,.bak}` idiom every shell-history block carries)
1438        // expands `{a,b,c}` to the cross-product of its comma-separated
1439        // members and `{1..10}` to the integer range; RFC 6570 reserves
1440        // the matched pair for URI Template placeholders (the canonical
1441        // `https://{host}/{org}/{repo}` substitution shape every
1442        // OpenAPI / Swagger / Postman / GitHub Octokit client /
1443        // Helm chart-URL fragment / Mustache `{{org}}` doubled-brace
1444        // form carries), and Tera / Jinja2 / Handlebars / Go html/template
1445        // every IaC tool (Helm, Kustomize, Terraform's `${var}` cousin
1446        // shape) emit. POSIX `std::path::Path` treats both bytes as
1447        // literal path-component bytes (so `../{caixa-teia,caixa-helm}`
1448        // is one directory named literally `../{caixa-teia,caixa-helm}`,
1449        // sibling of `.` and `..`).
1450        //
1451        // A `:caminho "../{caixa-teia,caixa-helm}/build"` (the canonical
1452        // "I pasted a `cd ../{caixa-teia,caixa-helm}` shell brace-
1453        // expansion one-liner that fans across two siblings" footgun)
1454        // or `:caminho "../{{org}}/caixa-teia"` (the symmetric "I copied
1455        // a `{{org}}` Mustache / Helm template placeholder out of a
1456        // README quick-start and forgot to substitute") silently passes
1457        // every prior arm because `Path::is_absolute` returns false on
1458        // `..`, `{` / `}` are neither leading-byte sentinels nor control
1459        // bytes nor `\` nor `<` / `>` nor `|` nor `;` nor `&` nor
1460        // backtick nor `*` / `?` nor `(` / `)`, and the value's last
1461        // byte isn't `/`. The resolver folds the value through
1462        // `Path::new(caminho).join(<file>)` looking for a literal
1463        // `./../{caixa-teia,caixa-helm}/build` subdirectory and fails
1464        // at resolve time with a non-self-locating `No such file or
1465        // directory` error far from the source caixa.lisp.
1466        //
1467        // The lacre pipeline embeds the value verbatim in its per-dep
1468        // content-address (`conteudo: format!("path:{caminho}")`,
1469        // caixa-resolver/src/resolve.rs:189), so a `{` or `}` byte
1470        // lands in the BLAKE3 closure and rides downstream as part of
1471        // the build's identity into every shell-spawned subprocess
1472        // (the caixa-resolver's `git clone` invocation, a future
1473        // `feira tofu` shell-out, a future operator-side `nix flake
1474        // check` spawn) as the canonical shell-metachar / brace-
1475        // expansion surface every peer single-token-shaped typed
1476        // slot already closes. The peer git-source axis
1477        // [`crate::render::is_git_repo_url`] (42d8f9d — the URI Template
1478        // placeholder arm) rejects the same byte pair on `:fonte :repo`
1479        // under the same RFC-3986-'delims' / RFC-6570-URI-Template /
1480        // shell-brace-expansion banner. The `:caminho` axis was the last
1481        // typed path-string surface still admitting these two bytes;
1482        // this arm closes the gap so the substrate-wide "no shell-
1483        // composition metacharacter anywhere in a typed string slot
1484        // that flows verbatim into a shell-spawned subprocess"
1485        // invariant extends from shell-subshell-grouping (`(` / `)`)
1486        // to shell-brace-expansion (`{` / `}`) on the `:caminho` axis,
1487        // and the typed `:caminho` accepted set now also structurally
1488        // excludes the URI Template / templating-engine placeholder
1489        // surface that would silently round-trip through any
1490        // downstream IaC templating-engine layer.
1491        //
1492        // The arm fires AFTER the shell-subshell-grouping arm because
1493        // the prior arm's `(` / `)` shape is the more semantic-locating
1494        // axis on values that probe as both (`"../{cd foo}(date)"`
1495        // carries both `{` and `(` — the parenthesis-pair is the
1496        // load-bearing modern-Bourne-command-substitution surface the
1497        // prior arm closes; same cascade discipline every prior
1498        // `:caminho` arm establishes). The arm fires BEFORE the
1499        // trailing-`/` arm because the embedded brace-expansion byte
1500        // is the more semantic-locating axis on probe-as-both values
1501        // (`"../{caixa-teia,caixa-helm}/"` ends in `/` but the
1502        // load-bearing diagnostic is the embedded `{` brace-expansion
1503        // metachar — the trailing `/` is the secondary observation,
1504        // and an author who removes the `{` is likely to also tab-
1505        // strip the trailing separator).
1506        for &b in caminho.as_bytes() {
1507            if b == b'{' || b == b'}' {
1508                return Err(DepError::FonteCaminhoShellBraceExpansion {
1509                    nome: nome.to_string(),
1510                    caminho: caminho.to_string(),
1511                    byte: b,
1512                });
1513            }
1514        }
1515        // Reproducibility gate's shell-bracket-expansion arm. The 598b770
1516        // shell-brace-expansion arm closes `{` / `}`; `[` (`0x5b`) and
1517        // `]` (`0x5d`) are the orthogonal POSIX glob-character-class /
1518        // shell-`test`-builtin byte pair — same paste-from-shell-prompt
1519        // footgun class, different syntactic surface. Every POSIX shell
1520        // (sh / bash / zsh / dash / ksh / fish / nushell) lexes the
1521        // bracket pair as the glob character-class operator: `[abc]`
1522        // matches one of `a`, `b`, `c`; `[a-z]` matches any lowercase
1523        // ASCII letter; `[^x]` negates (the canonical
1524        // `ls *.[ch]` C-source-file glob and the `cd ../[a-z]*`
1525        // lowercase-sibling glob every shell-history block carries —
1526        // the orthogonal axis to the cf9034b `*` / `?` shell-glob arm
1527        // closing the unbounded pathname-expansion sentinels). The
1528        // bracket pair additionally carries the POSIX `test` /
1529        // `[` builtin command (`[ -d ../caixa-teia ] && cd ...` —
1530        // the canonical idiom every shell-script conditional uses) and
1531        // bash's `[[ ... ]]` extended-test grammar. Beyond shell, the
1532        // bracket pair is the TOML inline-array delimiter
1533        // (`features = ["a", "b"]` — the canonical paste-from-Cargo-
1534        // manifest cross-idiom-leak vector), the YAML flow-sequence
1535        // delimiter (`paths: [/a, /b]` — the canonical paste-from-
1536        // values.yaml cross-idiom leak), the JSON array delimiter,
1537        // and the POSIX-ERE / PCRE bracket-expression / character-
1538        // class anchor (the canonical paste-from-regex-doc shape).
1539        // POSIX `std::path::Path` treats both bytes as literal path-
1540        // component bytes (so `../[caixa-teia]` is one directory
1541        // named literally `../[caixa-teia]`, sibling of `.` and
1542        // `..`).
1543        //
1544        // A `:caminho "../caixa-[a-z]/build"` (the canonical "I
1545        // pasted a `cd ../caixa-[a-z]/build` glob-character-class
1546        // one-liner that matches every lowercase-sibling-suffix
1547        // sibling directory" footgun), `:caminho "../[caixa-teia]/
1548        // build"` (the symmetric "I pasted a TOML inline-array /
1549        // YAML flow-sequence shape out of an aligned manifest"
1550        // idiom), or `:caminho "../caixa-[ch]"` (the canonical
1551        // `*.[ch]` C-source character-class paste-from-shell-history
1552        // shape) silently passes every prior arm because
1553        // `Path::is_absolute` returns false on `..`, `[` / `]` are
1554        // neither leading-byte sentinels nor control bytes nor `\`
1555        // nor `<` / `>` nor `|` nor `;` nor `&` nor backtick nor
1556        // `*` / `?` nor `(` / `)` nor `{` / `}`, and the value's
1557        // last byte isn't `/`. The resolver folds the value through
1558        // `Path::new(caminho).join(<file>)` looking for a literal
1559        // `./../caixa-[a-z]/build` subdirectory and fails at resolve
1560        // time with a non-self-locating `No such file or directory`
1561        // error far from the source caixa.lisp.
1562        //
1563        // The lacre pipeline embeds the value verbatim in its per-dep
1564        // content-address (`conteudo: format!("path:{caminho}")`,
1565        // caixa-resolver/src/resolve.rs:189), so a `[` or `]` byte
1566        // lands in the BLAKE3 closure and rides downstream as part of
1567        // the build's identity into every shell-spawned subprocess
1568        // (the caixa-resolver's `git clone` invocation, a future
1569        // `feira tofu` shell-out, a future operator-side `nix flake
1570        // check` spawn) as the canonical shell-metachar / glob-
1571        // character-class / TOML-array surface every peer single-
1572        // token-shaped typed slot already closes. The `:caminho` axis
1573        // was the last typed path-string surface still admitting
1574        // these two bytes; this arm closes the gap so the substrate-
1575        // wide "no shell-composition metacharacter anywhere in a
1576        // typed string slot that flows verbatim into a shell-spawned
1577        // subprocess" invariant extends from shell-brace-expansion
1578        // (`{` / `}`) to shell-bracket-expansion (`[` / `]`) on the
1579        // `:caminho` axis. Together with the cf9034b `*` / `?` arm,
1580        // the typed `:caminho` accepted set now structurally excludes
1581        // the entire POSIX pathname-expansion / glob surface —
1582        // unbounded glob (`*` / `?`) AND bounded character-class
1583        // (`[abc]` / `[a-z]`).
1584        //
1585        // The arm fires AFTER the shell-brace-expansion arm because
1586        // the prior arm's `{` / `}` shape is the more semantic-
1587        // locating axis on values that probe as both
1588        // (`"../{a,b}[ch]"` carries both `{` and `[` — the brace-
1589        // expansion fan is the load-bearing root-cause edit, so
1590        // `FonteCaminhoShellBraceExpansion` wins; same cascade
1591        // discipline every prior `:caminho` arm establishes). The arm
1592        // fires BEFORE the trailing-`/` arm because the embedded
1593        // bracket-expansion byte is the more semantic-locating axis
1594        // on probe-as-both values (`"../[a-z]/"` ends in `/` but the
1595        // load-bearing diagnostic is the embedded `[` glob-character-
1596        // class metachar — the trailing `/` is the secondary
1597        // observation, and an author who removes the `[` is likely
1598        // to also tab-strip the trailing separator).
1599        for &b in caminho.as_bytes() {
1600            if b == b'[' || b == b']' {
1601                return Err(DepError::FonteCaminhoShellBracketExpansion {
1602                    nome: nome.to_string(),
1603                    caminho: caminho.to_string(),
1604                    byte: b,
1605                });
1606            }
1607        }
1608        // Reproducibility gate's shell-quote-grouping arm. The 986963b
1609        // shell-bracket-expansion arm closes `[` / `]`; `'` (`0x27`) and
1610        // `"` (`0x22`) are the orthogonal POSIX shell-string-literal
1611        // delimiter pair — same paste-from-shell-prompt footgun class,
1612        // different syntactic surface. Every POSIX shell (sh / bash /
1613        // zsh / dash / ksh / fish / nushell) lexes the pair as the
1614        // string-literal quoting operator: `'…'` is the strong
1615        // (no-expansion) single-quoted string and `"…"` is the weak
1616        // (variable-/command-substitution-preserving) double-quoted
1617        // string — the canonical `cd '../caixa-teia'` shell-history
1618        // idiom every path-with-embedded-whitespace paste block carries,
1619        // and the symmetric `git clone "$REPO"` weak-quoted CI-manifest
1620        // shape. Beyond shell, the two bytes carry the JSON string-literal
1621        // delimiter (`"key": "value"` — the canonical paste-from-JSON-
1622        // config cross-idiom-leak vector), the YAML double-quoted +
1623        // single-quoted flow-scalar delimiters (`path: "../caixa-teia"`
1624        // — the canonical paste-from-values.yaml / paste-from-K8s-YAML-
1625        // manifest cross-idiom leak), the TOML basic + literal string
1626        // delimiters (`path = "../caixa-teia"` — the canonical paste-
1627        // from-Cargo-manifest cross-idiom-leak vector), the tatara-lisp
1628        // string-literal delimiter itself (`(:caminho "../caixa-teia")`
1629        // — the canonical "I copied the entire `:caminho "..."` slot
1630        // rather than just the string body" author-surface footgun),
1631        // and RFC 3986 §2.2's `gen-delims` / `sub-delims` grammar which
1632        // excludes both bytes from the `unreserved / pct-encoded /
1633        // sub-delims / ":" / "@"` `pchar` production. POSIX
1634        // `std::path::Path` treats both bytes as literal path-component
1635        // bytes (so `../"caixa-teia"` is one directory named literally
1636        // `../"caixa-teia"`, sibling of `.` and `..`).
1637        //
1638        // A `:caminho "'../caixa-teia'"` (the canonical "I pasted a
1639        // `cd '../caixa-teia'` shell-history one-liner whose strong-
1640        // quoting preserved the sibling-workspace path verbatim across
1641        // the whitespace paste boundary" footgun), `:caminho
1642        // "\"../caixa-teia\""` (the symmetric weak-quoted paste-from-
1643        // JSON / paste-from-YAML flow-scalar / paste-from-TOML basic-
1644        // string / paste-from-tatara-lisp string-literal cross-idiom-
1645        // leak shape), or `:caminho "../\"caixa-teia\""` (the embedded-
1646        // quote "I pasted a JSON key-value pair fragment into the
1647        // middle of the path" idiom) silently passes every prior arm
1648        // because `Path::is_absolute` returns false on `..` / `'` /
1649        // `"`, `'` / `"` are neither leading-byte sentinels nor
1650        // control bytes nor `\` nor `<` / `>` nor `|` nor `;` nor `&`
1651        // nor backtick nor `*` / `?` nor `(` / `)` nor `{` / `}` nor
1652        // `[` / `]`, and the value's last byte isn't `/`. The resolver
1653        // folds the value through `Path::new(caminho).join(<file>)`
1654        // looking for a literal `./'../caixa-teia'` subdirectory and
1655        // fails at resolve time with a non-self-locating `No such file
1656        // or directory` error far from the source caixa.lisp.
1657        //
1658        // The lacre pipeline embeds the value verbatim in its per-dep
1659        // content-address (`conteudo: format!("path:{caminho}")`,
1660        // caixa-resolver/src/resolve.rs:189), so a `'` or `"` byte
1661        // lands in the BLAKE3 closure and rides downstream as part of
1662        // the build's identity into every shell-spawned subprocess
1663        // (the caixa-resolver's `git clone` invocation, a future
1664        // `feira tofu` shell-out, a future operator-side `nix flake
1665        // check` spawn) as the canonical shell-metachar / string-
1666        // literal-delimiter surface every peer single-token-shaped
1667        // typed slot already closes. The peer `:fonte :repo` axis
1668        // closes both bytes under the same shell-quote-grouping /
1669        // RFC-3986-sub-delims banner (e7a109f `'` shell-single-quote
1670        // + 4267d8b `"` shell-double-quote on `is_git_repo_url`). The
1671        // `:caminho` axis was the last typed path-string surface
1672        // still admitting these two bytes; this arm closes the gap
1673        // so the substrate-wide "no shell-composition metacharacter
1674        // anywhere in a typed string slot that flows verbatim into a
1675        // shell-spawned subprocess" invariant extends from shell-
1676        // bracket-expansion (`[` / `]`) to shell-quote-grouping (`'`
1677        // / `"`) on the `:caminho` axis. Together with the peer
1678        // JSON / YAML / TOML string-literal delimiters closing at
1679        // this arm and the 598b770 `{` / `}` brace-expansion arm
1680        // closing the templating-engine-placeholder boundary, the
1681        // typed `:caminho` accepted set now structurally excludes
1682        // the entire cross-config-DSL string-literal / templating
1683        // paste-from-aligned-manifest cross-idiom-leak surface that
1684        // would silently round-trip through any downstream JSON /
1685        // YAML / TOML / HCL / tatara-lisp parsing layer.
1686        //
1687        // The arm fires AFTER the shell-bracket-expansion arm because
1688        // the prior arm's `[` / `]` shape is the more semantic-
1689        // locating axis on values that probe as both (`"../[a-z]'x'"`
1690        // carries both `[` and `'` — the glob-character-class
1691        // expansion is the load-bearing root-cause edit, so
1692        // `FonteCaminhoShellBracketExpansion` wins; same cascade
1693        // discipline every prior `:caminho` arm establishes). The arm
1694        // fires BEFORE the trailing-`/` arm because the embedded
1695        // quote-grouping byte is the more semantic-locating axis on
1696        // probe-as-both values (`"../'caixa-teia'/"` ends in `/` but
1697        // the load-bearing diagnostic is the embedded `'` shell-
1698        // string-literal metachar — the trailing `/` is the secondary
1699        // observation, and an author who removes the `'` is likely to
1700        // also tab-strip the trailing separator).
1701        for &b in caminho.as_bytes() {
1702            if b == b'\'' || b == b'"' {
1703                return Err(DepError::FonteCaminhoShellQuoteGrouping {
1704                    nome: nome.to_string(),
1705                    caminho: caminho.to_string(),
1706                    byte: b,
1707                });
1708            }
1709        }
1710        // Reproducibility gate's shell-comment / URL-fragment / YAML-comment arm.
1711        // The d14cbc5 shell-quote-grouping arm closes `'` / `"`; `#` (`0x23`) is
1712        // the orthogonal "byte at which four distinct downstream parsers all
1713        // truncate the value at the first occurrence" surface, and no prior arm
1714        // has covered it on the `:caminho` axis. Every POSIX shell (sh / bash /
1715        // zsh / dash / ksh / fish / nushell) lexes an unquoted `#` at the head
1716        // of a word (or after unquoted whitespace) as the comment-lead: from
1717        // that byte to the end of the physical line is a comment discarded
1718        // before command parsing (`cd ../caixa-teia  # legacy sibling` — the
1719        // canonical paste-from-shell-history-with-trailing-annotation shape
1720        // every operator-notebook and CI-manifest carries; POSIX.1-2017 §2.3
1721        // Token Recognition step 6). YAML 1.2 §6.6 makes `#` the comment lead
1722        // at any position preceded by whitespace or at line-start (`path:
1723        // ../caixa-teia  # pin` — the canonical paste-from-values.yaml /
1724        // paste-from-K8s-manifest cross-idiom-leak shape). tatara-lisp itself
1725        // treats `;` as the comment-lead but a growing number of consumer
1726        // config-DSL layers (HCL, Terraform, Nix flake attributes, .env
1727        // dotenv-style files, gitconfig / .gitignore, ini / TOML) use `#` as
1728        // the comment-lead too — the pair extends the cross-config-DSL
1729        // paste-idiom surface the d14cbc5 quote-grouping arm and the 598b770
1730        // brace-expansion arm already cover on adjacent axes. RFC 3986 §3.5
1731        // reserves `#` as the URL fragment-identifier delimiter (the canonical
1732        // paste-from-browser-address-bar `github.com/foo/bar#readme` /
1733        // `github.com/foo/bar#L42` permalink shape, and the symmetric
1734        // Nix-flake-ref cross-idiom leak `github:foo/bar#packageName` where
1735        // `#` selects a flake output — the same axis the peer
1736        // [`crate::render::is_git_repo_url`] closes on the `:fonte :repo`
1737        // surface at a68f818 with the same downstream-drops-the-tail
1738        // rationale).
1739        //
1740        // POSIX `std::path::Path` treats `#` as a literal path-component byte,
1741        // so a `:caminho "../caixa-teia # legacy sibling"` (the canonical
1742        // paste-from-shell-history-with-trailing-annotation footgun),
1743        // `:caminho "../caixa-teia  # pin"` (the symmetric YAML flow-scalar
1744        // paste-with-trailing-comment shape), or `:caminho "../caixa-teia
1745        // #readme"` (the URL fragment paste-from-browser-address-bar shape)
1746        // silently passes every prior arm because `Path::is_absolute` returns
1747        // false on `..`, `#` is neither a leading-byte sentinel nor a control
1748        // byte nor `\` nor `<` / `>` nor `|` nor `;` nor `&` nor backtick nor
1749        // `*` / `?` nor `(` / `)` nor `{` / `}` nor `[` / `]` nor `'` / `"`,
1750        // and the value's last byte isn't `/`. The resolver folds the value
1751        // through `Path::new(caminho).join(<file>)` looking for a literal
1752        // subdirectory named `../caixa-teia # legacy sibling` and fails at
1753        // resolve time with a non-self-locating `No such file or directory`
1754        // error far from the source caixa.lisp — while every downstream
1755        // shell / YAML / URL parser silently truncates the value at the `#`
1756        // byte to `../caixa-teia`, so a `feira tofu` shell-out to a
1757        // `cd '{caminho}'` command line and a `nix flake check` invocation on
1758        // an emitted YAML `path:` scalar disagree with the resolver on which
1759        // directory the value names. Two workstations whose downstream
1760        // shell / YAML / URL parsing layers differ in unquoted-`#`
1761        // recognition emit divergent build artifacts for the byte-identical
1762        // caixa.lisp value.
1763        //
1764        // The lacre pipeline embeds the value verbatim in its per-dep
1765        // content-address (`conteudo: format!("path:{caminho}")`,
1766        // caixa-resolver/src/resolve.rs:189), so the byte lands in the BLAKE3
1767        // closure and rides downstream as part of the build's identity into
1768        // every shell-spawned subprocess (the caixa-resolver's `git clone`
1769        // invocation, a future `feira tofu` shell-out, a future operator-side
1770        // `nix flake check` spawn) as the canonical shell-metachar /
1771        // comment-lead / URL-fragment-delimiter surface every peer
1772        // single-token-shaped typed slot already closes. The peer `:fonte
1773        // :repo` axis closes the byte under the URL-fragment-identifier
1774        // banner (a68f818 `#` on `is_git_repo_url`); the `:caminho` axis was
1775        // the last typed path-string surface still admitting the byte. This
1776        // arm closes the gap so the substrate-wide "no shell-composition
1777        // metacharacter / comment-lead / URL-fragment-delimiter anywhere in a
1778        // typed string slot that flows verbatim into a shell-spawned
1779        // subprocess or downstream YAML / URL parser" invariant extends from
1780        // shell-quote-grouping (`'` / `"`) to shell-comment / URL-fragment
1781        // (`#`) on the `:caminho` axis. Together with the peer JSON / YAML /
1782        // TOML string-literal delimiters the d14cbc5 quote-grouping arm
1783        // closes and the 598b770 `{` / `}` brace-expansion arm closes on the
1784        // templating-engine-placeholder boundary, the typed `:caminho`
1785        // accepted set now structurally excludes the entire
1786        // paste-with-trailing-annotation / paste-from-URL-permalink /
1787        // paste-from-YAML-comment cross-idiom-leak surface that would
1788        // silently round-trip through any downstream shell / YAML / URL /
1789        // dotenv / gitconfig / HCL parsing layer to a different value than
1790        // the resolver's `Path::join` sees.
1791        //
1792        // The arm fires AFTER the shell-quote-grouping arm because the prior
1793        // arm's `'` / `"` shape is the more semantic-locating axis on values
1794        // that probe as both (`"../'x'#pin"` carries both `'` and `#` — the
1795        // shell-string-literal-delimiter is the load-bearing root-cause edit,
1796        // so `FonteCaminhoShellQuoteGrouping` wins; same cascade discipline
1797        // every prior `:caminho` arm establishes). The arm fires BEFORE the
1798        // trailing-`/` arm because the embedded comment-lead / fragment-
1799        // delimiter byte is the more semantic-locating axis on probe-as-both
1800        // values (`"../caixa-teia#pin/"` ends in `/` but the load-bearing
1801        // diagnostic is the embedded `#` — the trailing `/` is the secondary
1802        // observation, and an author who removes the `#pin` fragment is
1803        // likely to also tab-strip the trailing separator).
1804        for &b in caminho.as_bytes() {
1805            if b == b'#' {
1806                return Err(DepError::FonteCaminhoShellComment {
1807                    nome: nome.to_string(),
1808                    caminho: caminho.to_string(),
1809                    byte: b,
1810                });
1811            }
1812        }
1813        // Reproducibility gate's URL-percent-encoding-escape arm. The 6622063
1814        // shell-comment arm closes the `#` URL-fragment-identifier byte; `%`
1815        // (`0x25`) is the orthogonal RFC 3986 §2.1 URL percent-encoding-escape
1816        // byte — the mandatory encoding mechanism for every byte outside the
1817        // `unreserved` alphanumeric / `-` / `.` / `_` / `~` set, and `%`
1818        // itself must be percent-encoded as `%25` to appear literally inside
1819        // a URL value. The byte carries three distinct render-determinism
1820        // hazards on the `:caminho` axis, no prior arm has covered it, and
1821        // the peer `:fonte :repo` axis (a323db8 `%` on `is_git_repo_url`)
1822        // already closes the same byte under the same URL-percent-encoding
1823        // banner — the `:caminho` axis was the last typed path-string surface
1824        // still admitting the byte.
1825        //
1826        // First, the paste-from-browser-address-bar percent-encoded-space
1827        // footgun: an author copies `../caixa%20teia` out of a URL-encoded
1828        // README hyperlink / a browser address bar / a percent-encoded
1829        // permalink expecting `%20` to decode to a literal space at the
1830        // filesystem layer. POSIX `std::path::Path` treats the byte as a
1831        // literal path-component byte, so `Path::join` looks for a literal
1832        // `./../caixa%20teia` subdirectory and fails at resolve time with a
1833        // non-self-locating `No such file or directory` error far from the
1834        // source caixa.lisp — while the author's mental model was
1835        // `../caixa teia`, the decoded shape. Two authors whose only
1836        // difference is percent-encoding presence resolve to two distinct
1837        // BLAKE3 closures (`path:../caixa%20teia` vs `path:../caixa teia`)
1838        // for what they intended as the byte-identical sibling-workspace
1839        // dep. The lacre pipeline embeds the value verbatim in its per-dep
1840        // content-address (`conteudo: format!("path:{caminho}")`,
1841        // caixa-resolver/src/resolve.rs:189), so the divergence rides
1842        // downstream into the BLAKE3 closure and locks the substrate's
1843        // "the lacre is the build's identity" contract (CAIXA-SDLC §III.2)
1844        // to the wrong encoding — the same THEORY.md §V.2 render-
1845        // determinism vector every prior `:caminho` arm protects.
1846        //
1847        // Second, the printf-format-specifier lead footgun: `%` is the C /
1848        // POSIX printf format-directive lead-in (`%s`, `%d`, `%02x`, the
1849        // canonical `printf "path=%s\n" ../caixa-teia` invocation every
1850        // shell-diagnostic one-liner carries) and the printf builtin is
1851        // wired into every POSIX shell (bash / zsh / dash / ksh / busybox
1852        // ash) as the format-string lead. A `:caminho "../caixa-%s-teia"`
1853        // value flowing into any future `feira` verb that shells out with a
1854        // printf-formatted path template silently gets reinterpreted as a
1855        // format-directive rather than a literal byte — the canonical
1856        // CWE-134 format-string-injection vector.
1857        //
1858        // Third, the bash-job-control-specifier lead footgun: bash / zsh /
1859        // ksh reserve `%N` at word-start as the job-control specifier —
1860        // `%1` names "job 1", `%%` names "the current job", `%foo` names
1861        // "the most recent job whose command started with `foo`". A future
1862        // `feira` verb that invokes `kill %1` on a caminho-scoped
1863        // subprocess would silently redirect the signal to a wrong target.
1864        //
1865        // Beyond the three shell-side hazards, `%` is a first-class parser
1866        // byte in three cross-config-DSL layers the substrate's paste-idiom
1867        // surface routinely crosses: YAML 1.2 §6.8.1 lexes `%` at
1868        // line-start as the directive lead (`%YAML 1.2` / `%TAG` — a
1869        // `:caminho "%YAML/1.2/../caixa-teia"` paste from a top-of-doc
1870        // YAML directive block silently trips the YAML directive parser on
1871        // any downstream emitted YAML manifest); Prometheus / Grafana
1872        // template syntax uses `%(var)s` as the substitution lead; and Nix
1873        // interpolation uses `${var}` (not `%`) but Envsubst /
1874        // Kubernetes / OpenShift template layers use `%VAR%` as the
1875        // Windows-shell env-var-reference lead — the paste-from-`.bat` /
1876        // paste-from-PowerShell-`%env:PATH%` cross-idiom leak.
1877        //
1878        // The three malformed-`%HH` classes documented on the peer
1879        // `is_git_repo_url` `%` arm (a323db8) apply here too:
1880        //
1881        //   - The lone-`%` malformed-escape shape (`"../caixa-teia%foo"`
1882        //     where `%` isn't followed by two hex digits) — every WHATWG-
1883        //     conformant URL parser rejects the value at parse time per
1884        //     RFC 3986 §2.1, but the byte rides into the lacre before
1885        //     the resolver subprocess crosses the URL-parser boundary.
1886        //   - The over-encoded path-separator shape (`"../caixa%2Fteia"`
1887        //     intending the `%2F` as the URL encoding of `/`) locks a
1888        //     `path:../caixa%2Fteia` BLAKE3 closure that diverges from
1889        //     the byte-identical `path:../caixa/teia` form.
1890        //   - The double-encoded shape (`"../caixa%2520teia"` — the `%25`
1891        //     already itself an encoded `%`, so the intent was likely a
1892        //     literal `%20` that survived one round-trip through a
1893        //     URL-encoder that shouldn't have run) locks a triply-
1894        //     divergent closure across the encoded / once-decoded /
1895        //     twice-decoded chain.
1896        //
1897        // POSIX `std::path::Path` treats the byte as a literal path-
1898        // component byte, so a `:caminho "../caixa%20teia"` (the canonical
1899        // paste-from-browser-address-bar percent-encoded-space footgun),
1900        // `:caminho "%YAML/../caixa-teia"` (the symmetric paste-from-YAML-
1901        // directive-block cross-idiom leak), or `:caminho
1902        // "../caixa-%s-teia"` (the printf-format-specifier paste-from-
1903        // shell-diagnostic-one-liner shape) silently passes every prior arm
1904        // because `Path::is_absolute` returns false on `..`, `%` is neither
1905        // a leading-byte sentinel nor a control byte nor `\` nor `<` / `>`
1906        // nor `|` nor `;` nor `&` nor backtick nor `*` / `?` nor `(` / `)`
1907        // nor `{` / `}` nor `[` / `]` nor `'` / `"` nor `#`, and the
1908        // value's last byte isn't `/`. The resolver folds the value through
1909        // `Path::new(caminho).join(<file>)` looking for a literal
1910        // subdirectory named `../caixa%20teia` and fails at resolve time
1911        // with a non-self-locating `No such file or directory` error far
1912        // from the source caixa.lisp — while every downstream URL parser /
1913        // shell printf builtin / YAML directive parser silently
1914        // reinterprets the byte to a different value than the resolver's
1915        // `Path::join` sees. Two workstations whose downstream URL / shell
1916        // / YAML layers differ in `%HH` recognition emit divergent build
1917        // artifacts for the byte-identical caixa.lisp value.
1918        //
1919        // The lacre pipeline embeds the value verbatim in its per-dep
1920        // content-address (`conteudo: format!("path:{caminho}")`, caixa-
1921        // resolver/src/resolve.rs:189), so the byte lands in the BLAKE3
1922        // closure and rides into every shell-spawned subprocess (the
1923        // resolver's `git clone`, a future `feira tofu` shell-out, a
1924        // future operator-side `nix flake check` spawn) as the canonical
1925        // URL-percent-encoding-escape / printf-format-specifier / bash-
1926        // job-control-specifier surface every peer single-token-shaped
1927        // typed slot already closes. This arm closes the gap so the
1928        // substrate-wide "no URL-percent-encoding-escape / printf-format-
1929        // specifier / job-control-specifier / YAML-directive-lead byte
1930        // anywhere in a typed string slot that flows verbatim into a
1931        // shell-spawned subprocess or downstream URL / printf / YAML
1932        // parser" invariant extends from shell-comment / URL-fragment
1933        // (`#` — 6622063) to URL-percent-encoding-escape (`%`) on the
1934        // `:caminho` axis.
1935        //
1936        // The arm fires AFTER the shell-comment arm because the prior
1937        // arm's `#` shape is the more semantic-locating axis on values
1938        // that probe as both (`"../caixa%20teia#pin"` carries both `%`
1939        // and `#` — the URL-fragment-identifier is the load-bearing
1940        // downstream-truncation edit, so `FonteCaminhoShellComment` wins;
1941        // same cascade discipline every prior `:caminho` arm establishes).
1942        // The arm fires BEFORE the trailing-`/` arm because the embedded
1943        // percent-encoding-escape byte is the more semantic-locating axis
1944        // on probe-as-both values (`"../caixa%20teia/"` ends in `/` but
1945        // the load-bearing diagnostic is the embedded `%` percent-
1946        // encoding-escape — the trailing `/` is the secondary observation,
1947        // and an author who decodes the `%20` to a literal space is
1948        // likely to also tab-strip the trailing separator).
1949        for &b in caminho.as_bytes() {
1950            if b == b'%' {
1951                return Err(DepError::FonteCaminhoUrlPercentEncoding {
1952                    nome: nome.to_string(),
1953                    caminho: caminho.to_string(),
1954                    byte: b,
1955                });
1956            }
1957        }
1958        // Reproducibility gate's embedded-`$` shell-variable-expansion /
1959        // command-substitution / arithmetic-expansion arm. The f4efe9c
1960        // leading-`$` arm at line 540 routes `caminho.starts_with('$')`
1961        // through `FonteCaminhoVarExpansion` under the leading-byte-
1962        // sentinel host-layout-leak banner (peer with the b94fd83
1963        // absolute / a5c248e tilde leading-byte arms), but the arm
1964        // fires only at position 0 — a `:caminho "../foo$HOME/bar"`
1965        // (embedded `$HOME` in a nested path segment — the canonical
1966        // paste-from-`ls ../foo$HOME/bar`-shell-one-liner footgun where
1967        // an author copies a partially-substituted shell one-liner and
1968        // the leading segment is a literal `../foo` while the mid
1969        // segment carries the un-substituted `$HOME` template), a
1970        // `:caminho "../foo${WORKSPACE}/bar"` (the symmetric braced-CI-
1971        // manifest paste-from-`.gitlab-ci.yml` / paste-from-GitHub-
1972        // Actions-workflow shape), a `:caminho "../foo$(whoami)/bar"`
1973        // (the paste-from-shell-prompt command-substitution idiom), or
1974        // a `:caminho "../foo$((1+2))/bar"` (the arithmetic-expansion
1975        // idiom) silently passes every prior arm because
1976        // `Path::is_absolute` returns false on `..`, `$` is neither a
1977        // leading-byte sentinel (the f4efe9c arm fires only at position
1978        // 0) nor a control byte nor `\` nor `<` / `>` nor `|` nor `;`
1979        // nor `&` nor backtick nor `*` / `?` nor `(` / `)` nor `{` /
1980        // `}` nor `[` / `]` nor `'` / `"` nor `#` nor `%`, and the
1981        // value's last byte isn't `/`. Note that `$(...)` command-
1982        // substitution and `$((...))` arithmetic-expansion each carry
1983        // an embedded `(` byte that the 0633c91 shell-subshell-grouping
1984        // arm catches structurally at the earlier `(` position — but
1985        // an author who reaches for the sh-brace-substitution
1986        // `${VAR}` or the bare `$VAR` shape carries only the `$` byte,
1987        // which no prior arm covers. This arm closes the last
1988        // positional gap on the `$` byte on the `:caminho` axis so
1989        // every position — leading (`FonteCaminhoVarExpansion`) and
1990        // embedded (`FonteCaminhoShellVariableExpansion`) — is
1991        // structurally rejected.
1992        //
1993        // Every POSIX shell (sh / bash / zsh / dash / ksh / busybox
1994        // ash / fish / nushell) lexes `$` as the variable-expansion /
1995        // command-substitution / arithmetic-expansion operator per
1996        // POSIX.1-2017 §2.6 (Word Expansions): `$<name>` (Parameter
1997        // Expansion) expands a named variable, `${<name>}` (Parameter
1998        // Expansion braced form) does the same with an explicit token
1999        // boundary, `$(<cmd>)` (Command Substitution modern form,
2000        // `` `<cmd>` `` legacy form which the c370458 backtick arm
2001        // already closes) runs a subshell and substitutes its stdout,
2002        // and `$((<expr>))` (Arithmetic Expansion) evaluates an
2003        // arithmetic expression. Every form is a host-layout /
2004        // environment-state / shell-subprocess-side-effect leak when
2005        // the byte lands in a value the resolver passes to a shell-
2006        // spawned subprocess. Beyond the POSIX shell layer, `$` is
2007        // the Nix `${var}` string-interpolation lead (the paste-from-
2008        // `flake.nix` / paste-from-`.nix`-attribute cross-idiom leak
2009        // where an author copies `"${pkgs.hello}/bin/hello"` out of a
2010        // nix expression), the Make `$(var)` / `$@` / `$<` automatic-
2011        // variable lead (the paste-from-`Makefile` shape), the
2012        // JavaScript / TypeScript template-literal `${expr}` interp
2013        // lead (the paste-from-JS-template-string idiom in a
2014        // multi-lang-monorepo where a `path` attribute gets copied out
2015        // of a `package.json` script or a Vite config), the envsubst /
2016        // Kubernetes / OpenShift template `${VAR}` interp lead (the
2017        // paste-from-Helm-values / paste-from-K8s-manifest cross-idiom
2018        // leak), the PHP variable lead (`$_GET`, `$_ENV` — the paste-
2019        // from-`.php`-config footgun), the Perl scalar-variable lead
2020        // (`$foo`), the SASS / SCSS variable lead (`$primary-color`),
2021        // and the SQL bind-parameter lead in PostgreSQL / SQLite
2022        // (`$1`, `$2` — the paste-from-`.sql`-migration idiom). The
2023        // cross-idiom paste-footgun surface is broader than any single
2024        // shell layer — `$` is a first-class parser byte in nearly
2025        // every config / templating / build-system DSL the substrate's
2026        // paste-idiom surface routinely crosses. The peer `:fonte
2027        // :repo` axis closes the byte under the shell-variable-
2028        // expansion / URL-sub-delim banner (b9d187c `$` on
2029        // `is_git_repo_url`), the peer `:fonte :tag` / `:fonte :branch`
2030        // axes close `$` as part of `is_git_ref_name`'s printable-
2031        // ASCII-restricted grammar (`git check-ref-format` rejects the
2032        // byte outright), and the peer `:entrada :paths` axis closes
2033        // `$` via `is_gateway_api_http_path`'s eleven-byte RFC-3986-
2034        // reserved set. The `:caminho` axis was the last typed path-
2035        // string surface still admitting `$` at positions other than 0.
2036        //
2037        // POSIX `std::path::Path` treats `$` as a literal path-
2038        // component byte, so `:caminho "../foo$HOME/bar"` silently
2039        // routes through `Path::new(caminho).join(<file>)` looking for
2040        // a literal `./{caminho}` subdirectory that fails at resolve
2041        // time with a non-self-locating `No such file or directory`
2042        // error far from the source caixa.lisp. But every downstream
2043        // shell / envsubst / Nix / Make / K8s-template parser silently
2044        // reinterprets the byte to a different value than the
2045        // resolver's `Path::join` sees — so a `feira tofu` shell-out
2046        // to a `cd '{caminho}'` command line, a `nix flake check`
2047        // invocation on an emitted YAML `path:` scalar folded through
2048        // envsubst, or a `helm template` invocation with a
2049        // `values.yaml` `path: {caminho}` embedded in a `{{`-quoted
2050        // template all disagree with the resolver on which directory
2051        // the value names. Two workstations whose downstream shell /
2052        // envsubst / Nix / Make / K8s-template parsing layers differ
2053        // in `$VAR` recognition (or, worse, expand the byte against
2054        // divergent environments — Alice's `$HOME=/home/alice`, Bob's
2055        // `$HOME=/home/bob`) emit divergent build artifacts for the
2056        // byte-identical caixa.lisp value. Even in the case where the
2057        // resolver strictly does NOT expand `$VAR` (the current
2058        // implementation) the divergence still bites at the lacre-
2059        // identity axis: the lacre pipeline embeds the value verbatim
2060        // in its per-dep content-address (`conteudo:
2061        // format!("path:{caminho}")`, caixa-resolver/src/resolve.rs:189),
2062        // so `path:../foo$HOME/bar` locks a BLAKE3 closure distinct
2063        // from the byte-identical-semantic `path:../foo/home/alice/bar`
2064        // one author would have produced by substituting the literal
2065        // value at author time, defeating the THEORY.md §V.2 render-
2066        // determinism contract on the same axis every prior `:caminho`
2067        // arm protects.
2068        //
2069        // Beyond the render-determinism / host-layout-leak vectors,
2070        // `$` at any position in a value flowing verbatim into a
2071        // shell-spawned subprocess is the canonical CWE-78 shell-
2072        // command-injection surface every peer single-token-shaped
2073        // typed slot already closes. A `:caminho "../foo$(whoami)/bar"`
2074        // that rides into a future `feira tofu` shell-out as `cd
2075        // '../foo$(whoami)/bar'` gets substituted by the shell at
2076        // subprocess-argument-expansion time even inside single quotes
2077        // in fewer positions than one might expect (the substitution
2078        // fires only outside single-quoting per POSIX §2.2.2, but
2079        // eval-style wrappers and `sh -c` layers that route the value
2080        // through re-parsing round-trip the substitution — the same
2081        // vector the c370458 backtick arm closes at the sibling
2082        // command-substitution-legacy-form surface). Every future
2083        // `feira` verb that shells out with a `caminho`-formatted
2084        // subprocess argument silently inherits this substitution
2085        // vector unless the typed slot's accepted set structurally
2086        // excludes the byte.
2087        //
2088        // Frontier inspiration: OTP's `gen_server` return-value grammar
2089        // rejects mid-tuple shell-metachar bytes by construction —
2090        // `{noreply, State}` never carries a raw `$` because the
2091        // Erlang term type system has no notion of "string that gets
2092        // shelled out"; caixa's typed slots inherit the same
2093        // structural discipline (types-are-theorems, the compounding
2094        // mandate's leverage-point-1) by refusing values that would
2095        // silently reinterpret at any downstream layer. Peer with
2096        // Unison's content-addressed code (no ambient environment —
2097        // every reference is a hash, no `$VAR` substitution possible)
2098        // and Pony's capabilities (a path capability that carries a
2099        // `$` would be ill-typed at the reference layer).
2100        //
2101        // The arm fires AFTER the URL-percent-encoding-escape arm (the
2102        // e3558fa `%` arm) because a value carrying both `%` and `$`
2103        // (`"../foo%20$HOME/bar"` — the canonical "I pasted a percent-
2104        // encoded space next to a `$HOME` template") surfaces the
2105        // narrower URL-encoding diagnostic first — the paste-from-
2106        // browser-address-bar shape is the load-bearing self-locating
2107        // edit on every probe-as-both value; same cascade discipline
2108        // every prior `:caminho` arm establishes (a323db8 %  before
2109        // this arm, this arm before trailing-`/`). The arm fires
2110        // BEFORE the trailing-`/` arm because the embedded shell-
2111        // variable-expansion byte is the more semantic-locating axis
2112        // on probe-as-both values (`"../foo$HOME/bar/"` ends in `/`
2113        // but the load-bearing diagnostic is the embedded `$` — the
2114        // trailing `/` is the secondary observation, and an author
2115        // who substitutes the `$HOME` template with a literal value is
2116        // likely to also tab-strip the trailing separator).
2117        for &b in caminho.as_bytes() {
2118            if b == b'$' {
2119                return Err(DepError::FonteCaminhoShellVariableExpansion {
2120                    nome: nome.to_string(),
2121                    caminho: caminho.to_string(),
2122                    byte: b,
2123                });
2124            }
2125        }
2126        // Reproducibility gate's shell-history-expansion / RFC-3986-sub-delims
2127        // arm. The immediate-predecessor `$` embedded arm closes the shell-
2128        // variable-expansion / command-substitution byte; `!` (`0x21`) is the
2129        // orthogonal POSIX shell-history-expansion sentinel every interactive
2130        // shell with history enabled (bash / ksh / zsh's `bashcompat` /
2131        // csh / tcsh) lexes as the history-expansion prefix: `!command`
2132        // re-runs the most recent history entry beginning with `command`,
2133        // `!!` re-runs the prior command verbatim, `!$` substitutes the
2134        // last word of the prior command, `!:N` substitutes the Nth word,
2135        // `^old^new` rewrites the prior command's `old` to `new` (the
2136        // canonical set of `set -o histexpand` operators bash's default
2137        // interactive session enables). Beyond the shell-history layer,
2138        // RFC 3986 §2.2 lists `!` in the `sub-delims` set (the URL grammar
2139        // admits the byte inside a path segment, but every WHATWG-conformant
2140        // special-scheme URL parser percent-encodes it inside a query
2141        // component via the 'special-query percent-encode set' the peer
2142        // `is_git_repo_url` `*` / `(` / `)` / `'` arms close on); the byte
2143        // is also the C / C++ / Rust / JavaScript / Python bang-operator
2144        // (logical-negation prefix — the paste-from-source-code idiom where
2145        // an author copies `!path.exists()` out of a Rust snippet and the
2146        // trailing punctuation crosses the string-literal boundary); the
2147        // canonical English-typography emphasis / exclamation mark (the
2148        // paste-from-prose enthusiasm-form idiom where an author writes
2149        // `:caminho "../caixa-teia!"` expecting the substrate to coerce it
2150        // to a kebab-case slug); and the Nix flake-ref import-attribute
2151        // `import ./foo.nix { … }` sibling operator surface.
2152        //
2153        // POSIX `std::path::Path` treats `!` as a literal path-component
2154        // byte, so a `:caminho "../caixa-teia!sudo"` (the canonical paste-
2155        // from-shell-history footgun where the author copies a `cd
2156        // ../caixa-teia && !sudo make install` one-liner from a quick-
2157        // start README and the trailing `!sudo` rides in verbatim as a
2158        // history-expansion reference), a `:caminho "../foo!!/bar"` (the
2159        // `!!` repeat-prior-command paste idiom), a `:caminho
2160        // "../caixa-teia!"` (the English-typography enthusiasm-form
2161        // paste-from-prose footgun), or a `:caminho "../foo!$"` (the
2162        // last-word-substitution shape) silently pass every prior arm
2163        // because `Path::is_absolute` returns false on `..`, `!` is neither
2164        // a leading-byte sentinel nor a control byte nor `\` nor `<` / `>`
2165        // nor `|` nor `;` nor `&` nor backtick nor `*` / `?` nor `(` / `)`
2166        // nor `{` / `}` nor `[` / `]` nor `'` / `"` nor `#` nor `%` nor `$`,
2167        // and the value's last byte isn't `/`. The resolver folds the value
2168        // through `Path::new(caminho).join(<file>)` looking for a literal
2169        // `./../caixa-teia!sudo` subdirectory and fails at resolve time
2170        // with a non-self-locating `No such file or directory` error far
2171        // from the source caixa.lisp — while every downstream interactive
2172        // shell with `set -o histexpand` reinterprets the byte as the
2173        // history-expansion prefix, and the failure mode forks per
2174        // consumer: a `feira tofu` shell-out to a `cd '{caminho}'` command
2175        // line executed under `bash -i` (the operator-notebook interactive
2176        // shell) substitutes the `!sudo` reference to the most recent
2177        // history entry starting with `sudo`, silently invoking whatever
2178        // privileged command that entry named.
2179        //
2180        // The lacre pipeline embeds the value verbatim in its per-dep
2181        // content-address (`conteudo: format!("path:{caminho}")`,
2182        // caixa-resolver/src/resolve.rs:189), so the byte lands in the
2183        // BLAKE3 closure and rides into every shell-spawned subprocess
2184        // (the resolver's `git clone`, a future `feira tofu` shell-out,
2185        // a future operator-side `nix flake check` spawn) as the
2186        // canonical shell-history-expansion / RFC-3986-sub-delims surface
2187        // every peer single-token-shaped typed slot already closes. The
2188        // peer `:fonte :repo` axis closes the byte under the same shell-
2189        // history-expansion / RFC-3986-sub-delims banner (7d53c68 `!` on
2190        // `is_git_repo_url`); the `:caminho` axis was the last typed
2191        // path-string surface still admitting the byte. This arm closes
2192        // the gap so the substrate-wide "no shell-composition
2193        // metacharacter / history-expansion sentinel anywhere in a typed
2194        // string slot that flows verbatim into a shell-spawned subprocess"
2195        // invariant extends from shell-variable-expansion (`$`) to shell-
2196        // history-expansion (`!`) on the `:caminho` axis. Together with
2197        // the peer c370458 backtick command-substitution-legacy-form arm
2198        // and the b9d187c-`$`-embedded-variable-expansion arm on the
2199        // sibling `:repo` axis, the typed `:caminho` accepted set now
2200        // structurally excludes every byte the POSIX shell §2.6 Word
2201        // Expansions section, §2.3 Token Recognition step 6, and every
2202        // history-expansion / brace-expansion / pathname-expansion /
2203        // parameter-expansion / command-substitution / arithmetic-
2204        // expansion operator lexes as a first-class parser byte.
2205        //
2206        // Frontier inspiration: Unison's content-addressed code (no
2207        // ambient environment — every reference is a hash, no `!<num>`
2208        // history-index substitution possible; the caixa substrate's
2209        // lacre discipline arrives at the same guarantee by refusing
2210        // bytes at manifest-parse time that would reinterpret against
2211        // ambient shell history state); Pony's capabilities (a path
2212        // capability that carries a `!` would be ill-typed at the
2213        // reference layer).
2214        //
2215        // The arm fires AFTER the shell-variable-expansion arm because a
2216        // value carrying both `$` and `!` (`"../foo$HOME/bar!sudo"` — the
2217        // canonical "I pasted a `$HOME`-templated path adjacent to a
2218        // trailing `!sudo` history-expansion") surfaces the narrower
2219        // shell-variable-expansion diagnostic first — the paste-from-CI-
2220        // manifest-with-`$VAR`-template shape is the load-bearing self-
2221        // locating edit on every probe-as-both value; same cascade
2222        // discipline every prior `:caminho` arm establishes. The arm
2223        // fires BEFORE the trailing-`/` arm because the embedded shell-
2224        // history-expansion byte is the more semantic-locating axis on
2225        // probe-as-both values (`"../foo!sudo/"` ends in `/` but the
2226        // load-bearing diagnostic is the embedded `!` — the trailing `/`
2227        // is the secondary observation, and an author who removes the
2228        // `!sudo` history reference is likely to also tab-strip the
2229        // trailing separator).
2230        for &b in caminho.as_bytes() {
2231            if b == b'!' {
2232                return Err(DepError::FonteCaminhoShellHistoryExpansion {
2233                    nome: nome.to_string(),
2234                    caminho: caminho.to_string(),
2235                    byte: b,
2236                });
2237            }
2238        }
2239        // Reproducibility gate's shell-history-substitution / RFC-3986-unwise
2240        // / regex-anchor arm. The immediate-predecessor `!` arm closes the
2241        // POSIX `!command` / `!!` / `!$` history-expansion prefix; `^`
2242        // (`0x5E`) is the paired-operator half of the same bash-reference
2243        // §9.3 histexpand feature — the `^old^new^` "quick substitution"
2244        // form (POSIX bash rewrites the prior command's `old` string to
2245        // `new` and re-executes it, the canonical typo-correction one-
2246        // liner idiom `git clone <bad-url>` → `^bad^good` that pastes the
2247        // trailing substitution fragment verbatim into a `:caminho` value
2248        // when the author trims only the leading `git clone` prefix). The
2249        // peer `:fonte :repo` axis closes the byte under the same
2250        // shell-history-substitution / RFC-3986-unwise banner (49e142f `^`
2251        // on `is_git_repo_url`); the `:caminho` axis was the last typed
2252        // path-string surface still admitting the byte after 6a04767
2253        // landed the `!` arm.
2254        //
2255        // Beyond bash history-substitution, `^` carries five distinct
2256        // downstream-reinterpretation surfaces the typed slot's accepted
2257        // set must structurally exclude:
2258        //
2259        // 1. **RFC 3986 §2 'unwise' set** — the four-byte cross-transport
2260        //    layer set (`{`, `}`, `|`, `\`) plus `^` every URL parser is
2261        //    required to percent-encode-or-refuse at the wire boundary.
2262        //    The WHATWG URL spec's 'fragment percent-encode set' maps
2263        //    `^` → `%5E` at the query / fragment component transition;
2264        //    libcurl silently percent-encodes the byte on the wire, so a
2265        //    `:caminho "../foo^bar"` value the resolver's `Path::join`
2266        //    sees as a literal `./../foo^bar` subdirectory diverges from
2267        //    the byte-transformed `%5E` shape any downstream `feira tofu`
2268        //    curl-invocation or artifact-registry-fetch would emit — the
2269        //    canonical wire-boundary divergence vector the peer
2270        //    `{`, `}`, `|`, `\` `:caminho` arms already close (
2271        //    `FonteCaminhoShellBraceExpansion` at 598b770,
2272        //    `FonteCaminhoShellPipe` at the pipe arm,
2273        //    `FonteCaminhoBackslash` at the backslash arm).
2274        // 2. **Regex character-class negation prefix `[^abc]`** — the
2275        //    canonical paste-from-doc-regex-pipeline footgun where an
2276        //    author copies a `grep '[^abc]'` idiom from a docs quick-
2277        //    listing and the character-class negation byte rides in
2278        //    verbatim.
2279        // 3. **Bitwise XOR operator** in C / C++ / Rust / Python /
2280        //    JavaScript / Nix / Go — the paste-from-source-code idiom
2281        //    where an author copies an `x ^ y`-shaped expression out of
2282        //    a source snippet and the operator crosses the string-
2283        //    literal boundary.
2284        // 4. **Windows `cmd.exe` escape metacharacter** — the byte
2285        //    escapes the next character in a `cmd.exe` batch context (a
2286        //    peer of the backslash arm's Windows-separator-leak vector).
2287        //    A `:caminho "..^&whoami"` cross-platform paste-from-batch-
2288        //    file footgun reinterprets at every `cmd.exe`-spawned
2289        //    subprocess (the resolver's future Windows-runner shell-out,
2290        //    the operator's WinRM path, a future PowerShell-embedded
2291        //    invocation).
2292        // 5. **LaTeX / Markdown / BibTeX superscript operator** — the
2293        //    paste-from-typeset-doc footgun where a mathematical
2294        //    superscript notation (`x^2` / `M^T`) leaks from prose.
2295        //
2296        // POSIX `std::path::Path` treats `^` as a literal path-component
2297        // byte, so `:caminho "../foo^bar/baz"` (embedded quick-
2298        // substitution), `:caminho "../foo^"` (trailing history-
2299        // substitution-open shape), `:caminho "../[^a-z]/foo"` (regex-
2300        // negation-prefix paste from a grep pipeline; note the `[` / `]`
2301        // arm at 986963b fires first on this shape), or `:caminho
2302        // "../x^y"` (XOR-expression paste-from-source) all silently pass
2303        // every prior arm (`^` isn't `\` / `<` / `>` / `|` / `;` / `&` /
2304        // backtick / `*` / `?` / `(` / `)` / `{` / `}` / `[` / `]` / `'`
2305        // / `"` / `#` / `%` / `$` / `!`) and route through
2306        // `Path::new(caminho).join(<file>)` looking for a literal
2307        // `./{caminho}` subdirectory that fails at resolve time with a
2308        // non-self-locating `No such file or directory` error far from
2309        // the source caixa.lisp — while every downstream shell / curl /
2310        // regex / `cmd.exe` layer reinterprets the byte to its own
2311        // semantic.
2312        //
2313        // The lacre pipeline embeds the value verbatim in its per-dep
2314        // content-address (`conteudo: format!("path:{caminho}")`,
2315        // caixa-resolver/src/resolve.rs:189), so the byte lands in the
2316        // BLAKE3 closure and rides into every shell-spawned subprocess
2317        // (the resolver's `git clone`, a future `feira tofu` shell-out,
2318        // a future operator-side `nix flake check` spawn) as the
2319        // canonical shell-history-substitution / RFC-3986-unwise /
2320        // regex-negation surface every peer single-token-shaped typed
2321        // slot already closes. This arm together with the immediate-
2322        // predecessor `!` arm (6a04767) closes the full `set -o
2323        // histexpand` operator surface on the `:caminho` axis — the
2324        // `!command` / `!!` / `!$` prefix form via `!`, the `^old^new^`
2325        // quick-substitution form via `^` — so the substrate-wide "no
2326        // shell-history operator anywhere in a typed string slot that
2327        // flows verbatim into a shell-spawned subprocess" invariant
2328        // extends from the `!` prefix half to the `^` quick-substitution
2329        // half. Every peer bash-history operator now fails at manifest-
2330        // parse time with a self-locating diagnostic naming the offending
2331        // caixa.lisp rather than at resolve-time as a `Path::join`-
2332        // derived `No such file or directory` (harmless but non-self-
2333        // locating) or worse riding into a downstream `bash -i` context
2334        // that reinterprets the byte-pair against ambient history state.
2335        //
2336        // Frontier inspiration: bash reference §9.3 HISTORY EXPANSION
2337        // "Quick substitution. Repeat the previous command, replacing
2338        // string1 with string2." + RFC 3986 §2 'unwise' set
2339        // ("characters that gateways and other transport agents are
2340        // known to sometimes modify") + Pony's capabilities (a path
2341        // capability that carries a `^` would be ill-typed at the
2342        // reference layer, matching the same structural discipline the
2343        // sibling `!` history-expansion arm inherits from Unison's
2344        // content-addressed no-ambient-history discipline).
2345        //
2346        // The arm fires AFTER the shell-history-expansion `!` arm because
2347        // a value carrying both `!` and `^` (`"../foo!sudo^bad^good"` —
2348        // the canonical "I pasted a `!sudo` history-reference next to a
2349        // `^bad^good` quick-substitution") surfaces the narrower prefix-
2350        // form `!` diagnostic first — the `!` form is the load-bearing
2351        // self-locating edit on every probe-as-both value (an author who
2352        // removes the `!sudo` reference is likely to also strip the
2353        // paired `^` substitution fragment); same cascade discipline
2354        // every prior `:caminho` arm establishes. The arm fires BEFORE
2355        // the trailing-`/` arm because the embedded shell-history-
2356        // substitution byte is the more semantic-locating axis on
2357        // probe-as-both values (`"../foo^bar/"` ends in `/` but the
2358        // load-bearing diagnostic is the embedded `^` — the trailing `/`
2359        // is the secondary observation, and an author who removes the
2360        // `^bar` substitution fragment is likely to also tab-strip the
2361        // trailing separator).
2362        for &b in caminho.as_bytes() {
2363            if b == b'^' {
2364                return Err(DepError::FonteCaminhoShellHistorySubstitution {
2365                    nome: nome.to_string(),
2366                    caminho: caminho.to_string(),
2367                    byte: b,
2368                });
2369            }
2370        }
2371        // Reproducibility gate's trailing-`/` arm. The b94fd83 absolute arm
2372        // closes the leading-`/` host-layout-leak; the embedded-control-byte
2373        // arm closes any byte-in-the-`0x00..=0x1F` / `0x7F` range; the
2374        // backslash arm closes the cross-host-OS-separator vector. The
2375        // trailing-`/` is the orthogonal shell-tab-completion-on-a-directory
2376        // footgun — `Path::join("../caixa-teia")` and
2377        // `Path::join("../caixa-teia/")` resolve to the same directory
2378        // (POSIX path-component-walk treats trailing `/` as a no-op for
2379        // directory targets, which `:caminho` always names — the sibling-
2380        // workspace dep root is structurally a directory). The lacre
2381        // pipeline embeds the value verbatim in its per-dep content-address
2382        // (`conteudo: format!("path:{caminho}")`,
2383        // caixa-resolver/src/resolve.rs:189), so byte-identical caixa
2384        // semantic-meaning yields two distinct BLAKE3 closures depending on
2385        // whether the author shell-tab-completed the path (every interactive
2386        // shell appends `/` on tab-completing a directory, idiomatic in
2387        // bash / zsh / fish / nushell), pasted from `pwd` (which on most
2388        // shells emits without trailing `/`, but `realpath -e -m` on a
2389        // directory with trailing `/` preserves it), or copied a Cargo
2390        // `path = "../caixa-teia/"` entry from cross-substrate documentation
2391        // (Cargo accepts both shapes and folds them the same way). Two
2392        // workstations whose authors differ only in tab-completion habits
2393        // emit byte-divergent lacres for the byte-identical-semantic caixa,
2394        // and the substrate's "the lacre is the build's identity" contract
2395        // (CAIXA-SDLC §III.2) silently breaks far from the source caixa.lisp.
2396        //
2397        // Same THEORY.md §V.2 render-determinism axis every prior `:caminho`
2398        // arm protects, here against the trailing-separator divergence
2399        // vector: every typed slot's accepted set excludes byte-divergent
2400        // values that round-trip to the same downstream semantic. The peer
2401        // path-shaped axes already reject trailing separators on the same
2402        // contract: [`crate::render::is_gateway_api_http_path`] gates
2403        // `:entrada :paths` against any non-canonical normalization, and
2404        // [`crate::render::is_sandboxed_relative_path`] gates the M2 typed
2405        // path-slots (`:behavior :on-*`, `:upgrade-from :state-change
2406        // :script`, `:bibliotecas`, `:exe`, `:servicos`) against shapes
2407        // whose canonical form would re-introduce determinism divergence.
2408        //
2409        // The arm fires last in the cascade because every prior arm carries
2410        // a more self-locating diagnostic on values that probe as both
2411        // (e.g. `:caminho "../foo/\0/"` ends in `/` but the load-bearing
2412        // diagnostic is the NUL byte's POSIX-syscall-rejection — the
2413        // control-char arm wins; `:caminho "/etc/passwd/"` ends in `/` but
2414        // the load-bearing diagnostic is the absolute host-layout-leak —
2415        // the absolute arm wins; `:caminho "..\caixa-teia/"` ends in `/`
2416        // but the load-bearing diagnostic is the Windows-separator cross-
2417        // OS divergence — the backslash arm wins). The arm covers every
2418        // shape where the last byte is `/` regardless of length, including
2419        // the degenerate single-`/` (which the absolute arm catches first)
2420        // and the consecutive-`//` (where every prior arm passes on the
2421        // bytes other than the trailing `/`).
2422        if caminho.as_bytes().last() == Some(&b'/') {
2423            return Err(DepError::FonteCaminhoTrailingSlash {
2424                nome: nome.to_string(),
2425                caminho: caminho.to_string(),
2426            });
2427        }
2428        Ok(())
2429    }
2430}
2431
2432impl Dep {
2433    /// Substrate-canonical per-`:deps` / `:deps-dev` entry `:nome` scalar
2434    /// accessor every consumer of the dep-graph identity axis keys off —
2435    /// returns the author-declared `:nome` byte-string verbatim as a
2436    /// `&str`, borrowed from the typed slot's own [`String`] storage.
2437    ///
2438    /// The `:deps :nome` / `:deps-dev :nome` slot carries the DNS-1123
2439    /// label that names the target caixa (validated by [`Self::validate`]
2440    /// through the shared [`crate::render::is_dns_1123_label`] predicate,
2441    /// same accept-set the peer caixa-identifier axes carry — top-level
2442    /// [`crate::Caixa::nome`], per-`:membros` [`crate::Membro::nome`],
2443    /// per-`:children` [`crate::supervisor::ChildSpec::nome`]). Every
2444    /// downstream consumer that fans on the dep's name-identity keys off
2445    /// this scalar: the [`crate::Caixa::validate_deps`] per-list
2446    /// [`crate::render::insert_first_seen`] dedup key + the paired
2447    /// [`DepError::DuplicateNome`] carrier the walk raises on collision,
2448    /// the cross-list [`validate_no_self_dep`] parent-name equality gate
2449    /// on both `:deps` and `:deps-dev` traversals, the `caixa-resolver`
2450    /// pipeline's `HashSet<String>` seen-set the closure walker gates
2451    /// requeueing off (`caixa-resolver/src/resolve.rs:55`), the resolver's
2452    /// per-transitive-target requeue path (`resolve.rs:63,66`), the
2453    /// [`crate::DepSource::default_github`]-shaped resolver-side shorthand
2454    /// fill-in that folds `:nome` into the fetched-git-URL (`resolve.rs:147`),
2455    /// every `caixa-resolver` `ResolveError::MissingPath` /
2456    /// `ResolveError::MissingPin` carrier that names the offending dep
2457    /// (`resolve.rs:177,206`), each resolved
2458    /// `caixa-lacre::LacreEntry` `nome:` field the closure hash keys off
2459    /// (`resolve.rs:108,113`), and the peer `feira lock` stub-resolver's
2460    /// `LacreEntry` emitter (`caixa-feira/src/cmd/lock.rs:59,61,64`).
2461    ///
2462    /// Prior to this lift the `.nome` byte-string was read inline at every
2463    /// production site — the [`crate::Caixa::validate_deps`] paired
2464    /// `dep.nome.as_str()` / `dep.nome.clone()` accesses on both `:deps`
2465    /// and `:deps-dev` traversals, the [`validate_no_self_dep`] pair of
2466    /// parent-equality checks, and every caixa-resolver / caixa-feira
2467    /// site enumerated above — open-coded field-accesses that expressed
2468    /// no compile-time link back to the typed slot. A future extension of
2469    /// the `:deps :nome` axis to a richer author surface (a per-scope
2470    /// alias table the resolver folds through the `~/.config/caixa/config.yaml`
2471    /// entry the [`crate::dep::Dep`] docstring already acknowledges, a
2472    /// namespace-qualified rewrite the future M4 lacre-federation layer
2473    /// applies per-cluster, a promotion of the plain [`String`] byte-string
2474    /// to a richer scoped-identifier newtype once cross-registry federation
2475    /// lands) would have had to be threaded through every open-coded copy
2476    /// in lockstep or two consumers would silently disagree on which caixa
2477    /// a given dep resolves to — the [`crate::Caixa::validate_deps`] dedup
2478    /// set treating the name as `"caixa-teia"` while the caixa-resolver
2479    /// closure walker treated it as `"tenant-a/caixa-teia"` would silently
2480    /// split the [`DepError::DuplicateNome`] refusal from the resolver's
2481    /// requeue-suppression seen-set, one build-time diagnostic
2482    /// disagreeing with the run-time closure the substrate's lacre
2483    /// pipeline actually materializes. Lifting the resolution rule to a
2484    /// typed method on the substrate primitive means every downstream
2485    /// consumer of the caixa's per-`:deps` identity surface reaches for
2486    /// exactly one typed dispatch — the resolver's accept-set migrates as
2487    /// a unit on any future axis addition.
2488    ///
2489    /// First accessor on the outer `Dep` type — opens the outer-`Dep`
2490    /// `&str`-return required-scalar projection pattern the sibling
2491    /// per-`Dep` `:versao` future lift folds on. Peer of the sibling
2492    /// per-`:membros` [`crate::Membro::nome`] (4a32abf) /
2493    /// per-`:children` [`crate::supervisor::ChildSpec::nome`] (dfb4a81)
2494    /// / top-level [`crate::Caixa::nome`] (e6b7d97) caixa-identity scalar
2495    /// accessors — same "one typed dispatch on the substrate primitive,
2496    /// thin projections at each consumer" discipline extended onto the
2497    /// third named-caixa-referencing axis (`:deps` / `:deps-dev`), the
2498    /// remaining unlifted caixa-name-referencing accessor family in the
2499    /// substrate. Named `nome()` to match the tatara-lisp author-surface
2500    /// term the field's docstring already reaches for ("Caixa name — must
2501    /// match the target caixa's `:nome`") and the peer caixa-identity
2502    /// accessor family the substrate already carries.
2503    #[must_use]
2504    pub fn nome(&self) -> &str {
2505        self.nome.as_str()
2506    }
2507
2508    /// Substrate-canonical per-`:deps` / `:deps-dev` entry `:versao`
2509    /// Cargo-shaped semver-requirement scalar accessor every consumer of
2510    /// the dep-graph version-pin axis keys off — returns the author-
2511    /// declared `:versao` requirement byte-string verbatim as a `&str`,
2512    /// borrowed from the typed slot's own [`String`] storage.
2513    ///
2514    /// The `:deps :versao` / `:deps-dev :versao` slot carries the
2515    /// Cargo-shaped semver requirement string (`"^0.1"`, `"~0.1.2"`,
2516    /// `"0.1.0"`, `"*"`) the shared [`crate::version::parse_requirement`]
2517    /// entry-point consumes — same accept-set the peer requirement-
2518    /// carrying axes carry (per-`:membros`
2519    /// [`crate::Membro::versao_requirement`], per-`:children`
2520    /// [`crate::supervisor::ChildSpec::versao_requirement`]), validated
2521    /// through the shared
2522    /// [`crate::render::require_valid_versao_requirement`] cascade in
2523    /// [`Self::validate`]. Every downstream consumer that fans on the
2524    /// dep's version-pin keys off this scalar: the [`Self::validate`]
2525    /// `require_valid_versao_requirement` gate + the paired
2526    /// [`DepError::VersaoInvalid`] carrier the cascade raises on
2527    /// requirement-shape rejection, the `feira lock` stub-resolver's
2528    /// `format!("{}@{}", dep.nome(), dep.versao_requirement())`
2529    /// `conteudo` hash-input interpolation and the paired
2530    /// `LacreEntry.versao:` `String`-carry fill (`caixa-feira/src/cmd/lock.rs`),
2531    /// and the peer `feira lock` end-to-end fixture in `caixa-feira/tests/feira_e2e.rs`.
2532    ///
2533    /// Prior to this lift the `.versao` byte-string was read inline at
2534    /// every production site — the [`Self::validate`] paired
2535    /// `&self.versao` requirement-gate reference and `self.versao.clone()`
2536    /// error-body carrier, the `caixa-feira/src/cmd/lock.rs` paired
2537    /// `format!("{}@{}", dep.nome(), dep.versao)` `conteudo` interpolation
2538    /// and `versao: dep.versao.clone()` `LacreEntry` fill, and the
2539    /// `caixa-feira/tests/feira_e2e.rs` end-to-end fixture's pair of the
2540    /// same shapes — open-coded field-accesses that expressed no
2541    /// compile-time link back to the typed slot. A future extension of
2542    /// the `:deps :versao` axis to a richer author surface (a per-scope
2543    /// version-lock overlay the resolver folds through the
2544    /// `~/.config/caixa/config.yaml` entry the [`crate::dep::Dep`]
2545    /// docstring already acknowledges, a per-cluster canary-version
2546    /// overlay per MESH-COMPOSITION §III.2, a promotion of the plain
2547    /// [`String`] requirement to a richer parsed-`VersionReq` newtype
2548    /// once cross-registry federation lands) would have had to be
2549    /// threaded through every open-coded copy in lockstep or two
2550    /// consumers would silently disagree on which release constraint a
2551    /// given dep resolves to — the [`Self::validate`] requirement-gate
2552    /// call reading `"^0.1"` while the `feira lock` stub-resolver's
2553    /// `conteudo` hash-input read `"tenant-a-pin/^0.1"` would silently
2554    /// split the [`DepError::VersaoInvalid`] refusal from the lacre's
2555    /// content-addressed hash the substrate's fetch pipeline actually
2556    /// materializes, one build-time diagnostic disagreeing with the
2557    /// run-time closure. Lifting the resolution rule to a typed method
2558    /// on the substrate primitive means every downstream consumer of
2559    /// the caixa's per-`:deps` version-pin surface reaches for exactly
2560    /// one typed dispatch — the resolver's accept-set migrates as a
2561    /// unit on any future axis addition.
2562    ///
2563    /// Second accessor on the outer `Dep` type — folds on the outer-
2564    /// `Dep` `&str`-return required-scalar projection pattern the
2565    /// sibling per-`Dep` [`Self::nome`] (eba2cde) accessor opened. Peer
2566    /// of the per-`:membros` [`crate::Membro::versao_requirement`]
2567    /// (a40b0e3) / per-`:children`
2568    /// [`crate::supervisor::ChildSpec::versao_requirement`] (7844f4e
2569    /// family) member/child version-pin accessors — the three
2570    /// requirement-carrying axes (`Dep::versao_requirement` on the
2571    /// per-caixa dep-graph edge, `Membro::versao_requirement` on the M3
2572    /// Aplicacao side, `ChildSpec::versao_requirement` on the M2
2573    /// Supervisor side) now share one accessor discipline for the
2574    /// shared substrate concept "another caixa referenced by a
2575    /// Cargo-shaped semver requirement". The pair
2576    /// `(nome(), versao_requirement())` jointly projects the
2577    /// `(nome, versao)` field pair every dep-graph consumer that fans
2578    /// on per-dep identity + version pin keys off. Named
2579    /// `versao_requirement()` rather than `versao()` because the field's
2580    /// storage-side `.versao` label is already the author-surface term
2581    /// (`:versao`); the accessor's name carries the semantic role — the
2582    /// semver *requirement* string the shared
2583    /// [`crate::version::parse_requirement`] entry-point consumes — so a
2584    /// raw field access and a typed dispatch read differently at every
2585    /// consumer site. Matches the peer
2586    /// [`crate::Membro::versao_requirement`] /
2587    /// [`crate::supervisor::ChildSpec::versao_requirement`] naming
2588    /// discipline verbatim.
2589    #[must_use]
2590    pub fn versao_requirement(&self) -> &str {
2591        self.versao.as_str()
2592    }
2593
2594    /// Substrate-canonical per-`:deps` / `:deps-dev` entry `:fonte`
2595    /// Zig-store-model per-dep source-tuple optional-composite-reference
2596    /// accessor every consumer of the dep-graph fetch-source axis keys
2597    /// off — returns the author-declared `:fonte` typed [`DepSource`]
2598    /// verbatim as an `Option<&DepSource>` borrowed from the typed slot's
2599    /// own `Option<DepSource>` storage, with `None` naming the "author
2600    /// omitted `:fonte`" shorthand every resolver-side default-fill
2601    /// (`caixa-feira/src/cmd/lock.rs`'s stub, `caixa-resolver/src/resolve.rs`'s
2602    /// canonical fetcher, per the [`DepSource::default_github`] fallback
2603    /// the [`Dep::fonte`] field docstring already documents) treats as
2604    /// the "resolve through the configured default host / org
2605    /// (`github:<default-org>/<nome>`)" partition.
2606    ///
2607    /// The `:deps :fonte` / `:deps-dev :fonte` slot carries the two-
2608    /// arm typed [`DepSource`] the `Zig-style git-only store model` the
2609    /// enclosing [`Dep`] docstring names — `DepSource::Git { repo, tag,
2610    /// rev, branch }` for the git-clone arm every published caixa
2611    /// resolves through, `DepSource::Path { caminho }` for the dev-only
2612    /// local-filesystem arm every unpublishable in-tree checkout
2613    /// resolves through. Every downstream consumer that fans on the
2614    /// dep's fetch-source keys off this accessor: [`Self::validate`]'s
2615    /// per-`:fonte` [`DepSource::validate`] delegation (which raises
2616    /// the empty-`:repo` / missing-pin / multiple-pin / empty-`:caminho`
2617    /// diagnostics through the [`DepError::Fonte*`] carrier family
2618    /// naming the offending `Dep::nome`), the caixa-crd conversion
2619    /// crate's `dep_into_ref` two-arm projection into the `CaixaSource`
2620    /// `{repo, git_ref}` pair the K8s-CR side consumes
2621    /// (`caixa-crd/src/conversion.rs`), and — through the paired
2622    /// resolver-side default-fill's `Option::unwrap_or_else` — every
2623    /// `caixa-feira` / `caixa-resolver` fetch site that requires a
2624    /// concrete `DepSource` at run time.
2625    ///
2626    /// Prior to this lift the `.fonte` typed slot was read inline at
2627    /// every production site — the [`Self::validate`]
2628    /// `if let Some(ref fonte) = self.fonte` bracket the per-`:fonte`
2629    /// gate delegates through, the caixa-crd `dep_into_ref`
2630    /// `d.fonte.as_ref().and_then(...)` two-arm `CaixaSource` projector,
2631    /// the resolver-side `caixa-feira/src/cmd/lock.rs` / `caixa-resolver/src/resolve.rs`
2632    /// `dep.fonte.clone().unwrap_or_else(...)` default-fill pair — open-
2633    /// coded field-accesses that expressed no compile-time link back to
2634    /// the typed slot. A future extension of the `:deps :fonte` axis
2635    /// to a richer author surface (a per-scope source-override table
2636    /// the resolver folds through the `~/.config/caixa/config.yaml`
2637    /// entry the [`Dep`] docstring already acknowledges, a per-org
2638    /// mirror-fallback list the future M4 lacre-federation resolver
2639    /// consults ahead of the `default_github` fallback, a promotion of
2640    /// the plain `Option<DepSource>` to a richer
2641    /// `{primary, mirrors, integrity}` triple once cross-registry
2642    /// federation lands, a per-dep `sri:sha256-…` integrity slot the
2643    /// M4 lacre gate binds against ahead of the git-fetch) would have
2644    /// had to be threaded through every open-coded copy in lockstep or
2645    /// two consumers would silently disagree on which fetch source a
2646    /// given dep resolves to — the [`Self::validate`] per-`:fonte`
2647    /// gate reading the author-declared source while the caixa-crd
2648    /// projector read a per-scope-override-resolved source would
2649    /// silently split the build-time refusal from the CR the
2650    /// substrate's admission pipeline actually materializes, one
2651    /// build-time diagnostic disagreeing with the run-time closure.
2652    /// Lifting the resolution rule to a typed method on the substrate
2653    /// primitive means every downstream consumer of the caixa's per-
2654    /// `:deps` fetch-source surface reaches for exactly one typed
2655    /// dispatch — the resolver's accept-set migrates as a unit on any
2656    /// future axis addition.
2657    ///
2658    /// First outer-`Dep` `Option<&Composite>`-return composite-reference
2659    /// accessor — opens the outer-`Dep` `Option<&Composite>` composite-
2660    /// reference projection pattern the sibling per-`Dep` `:opcional`
2661    /// (`Option<Copy>` — the plain-bool axis) / `:caracteristicas`
2662    /// (`&[String]` — the feature-flag list) future outer scalar / slice
2663    /// lifts fold on. Peer of the outer-top-level [`crate::Caixa`]
2664    /// `Option<&Composite>` composite-reference sub-family the
2665    /// [`crate::Caixa::limits`] (b2bd9d7) / [`crate::Caixa::behavior`]
2666    /// (35d8b52) / [`crate::Caixa::politicas`] (5d23d29) /
2667    /// [`crate::Caixa::placement`] (4fb8074) / [`crate::Caixa::entrada`]
2668    /// (e4128e4) accessors already close on the outer [`crate::Caixa`]
2669    /// altitude, and of the outer M3 mesh-slot [`crate::AplicacaoSpec`]
2670    /// altitude the sibling [`crate::AplicacaoSpec::entrada`] (d32111c)
2671    /// accessor already carries — extends that "one typed dispatch on
2672    /// the substrate primitive, thin projections at each consumer"
2673    /// discipline onto the third outer typed-slot altitude that carries
2674    /// an `Option<Composite>` axis (`Dep`, the outer per-dep-list-entry
2675    /// slot). Returns `Option<&DepSource>` (not the owning composite by
2676    /// copy or clone) because every downstream consumer of the fonte
2677    /// composite treats it as a read-only per-arm dispatch source — the
2678    /// reference-view is the narrowest borrow that supports every
2679    /// present + roadmapped consumer (per-arm match projection at the
2680    /// caixa-crd `CaixaSource` two-arm emitter, presence-probe early
2681    /// return on the "author-omitted `:fonte` ⇒ resolver-side
2682    /// `default_github` fill applies" partition every resolver
2683    /// consults, `.cloned()`-on-demand for the two resolver-side
2684    /// default-fill call sites that require an owned `DepSource` for
2685    /// `Option::unwrap_or_else`) without cloning the composite through
2686    /// every consumer's fast path. The `Option` half of the return-type
2687    /// preserves the load-bearing "author-omitted `:fonte` ⇒ resolver-
2688    /// side default applies" partition (not a default composite the
2689    /// downstream must reject on emptiness) — the accessor projects the
2690    /// raw `Option<DepSource>` slot's presence bit through the
2691    /// reference-return unchanged. Named `fonte()` to match the storage
2692    /// field's name verbatim and the tatara-lisp author-surface term
2693    /// (`:fonte`) the field's own docstring already carries.
2694    #[must_use]
2695    pub fn fonte(&self) -> Option<&DepSource> {
2696        self.fonte.as_ref()
2697    }
2698
2699    /// Substrate-canonical per-`:deps` / `:deps-dev` entry
2700    /// `:caracteristicas` Cargo-shaped feature-toggle-set slice accessor
2701    /// every consumer of the dep-graph feature-flag axis keys off —
2702    /// returns the author-declared `:caracteristicas` feature-name list
2703    /// verbatim as a `&[String]` slice-view over the same backing buffer
2704    /// the raw `self.caracteristicas.as_slice()` field access borrows
2705    /// from. Empty-list-carrying (`:caracteristicas` is a default-empty
2706    /// axis every `Dep` supplies with `Vec::new()` when the author omits
2707    /// the slot; the [`crate::Caixa::from_lisp`] derive folds an omitted
2708    /// `:caracteristicas` through `#[serde(default)]` to `Vec::new()`,
2709    /// so a `Dep` past parse definitionally carries a `Vec<String>` slot
2710    /// — possibly empty — and the returned `&[String]` degenerates to
2711    /// an empty slice on that arm without any silent `None` collapse).
2712    ///
2713    /// The `:deps :caracteristicas` / `:deps-dev :caracteristicas` slot
2714    /// carries the set-shaped feature-toggle list the substrate walks
2715    /// through the [`Self::validate_caracteristicas`] per-entry shape +
2716    /// duplicate cascade — same Cargo `[dependencies.<dep>.features]`
2717    /// accept-set (per-entry Cargo-feature-name grammar via the shared
2718    /// [`crate::render::is_cargo_feature_name`] predicate, cross-entry
2719    /// uniqueness via the shared [`crate::render::insert_first_seen`]
2720    /// walk, empty-first / value-shape-second / duplicate-third
2721    /// precedence via the peer per-axis two-arm cascade discipline every
2722    /// substrate-blessed Vec-keyed-by-name slot already follows).
2723    /// Every downstream consumer that fans on the dep's feature-toggle
2724    /// keys off this accessor: [`Self::validate_caracteristicas`]'s
2725    /// per-entry linear walk that gates each feature-name byte-string
2726    /// through the empty / value-shape / duplicate arms (raising the
2727    /// [`DepError::CaracteristicaEmpty`] / [`DepError::CaracteristicaInvalid`]
2728    /// / [`DepError::CaracteristicaDuplicate`] carrier family naming the
2729    /// offending `Dep::nome`), and every future
2730    /// per-`Caixa`-manifest / caixa-resolver / caixa-crd feature-toggle-
2731    /// facing consumer the CAIXA-SDLC §I roadmap acknowledges (the
2732    /// future caixa-resolver per-dep feature-projection walk that folds
2733    /// the toggle set into the resolved [`crate::Caixa`]'s activated
2734    /// [`crate::render::CARGO_FEATURE_NAME_MAX_LEN`]-bounded feature
2735    /// closure ahead of the lacre hash, the future caixa-crd per-`spec.deps`
2736    /// features slice the K8s-CR admission gate consumes, the future
2737    /// per-cluster feature-overlay the M4 lacre-federation resolver
2738    /// composes ahead of the substrate-wide feature-name accept-set).
2739    ///
2740    /// Prior to this lift the `.caracteristicas` byte-string list was
2741    /// read inline at the [`Self::validate_caracteristicas`] `for c in
2742    /// &self.caracteristicas` walk — the only in-crate consumer of the
2743    /// raw field beyond the per-`Dep` constructor pair
2744    /// ([`Self::simple`] / [`Self::git`]) and the paired serde
2745    /// round-trip / per-test fixture-mutation paths — an open-coded
2746    /// field-access that expressed no compile-time link back to the
2747    /// typed slot. A future extension of the `:caracteristicas` axis to
2748    /// a richer author surface (a per-scope feature-overlay the resolver
2749    /// folds through the `~/.config/caixa/config.yaml` entry the
2750    /// [`Dep`] docstring already acknowledges, a per-cluster feature-
2751    /// activation overlay the future M4 lacre-federation layer applies
2752    /// per-CR, a promotion of the plain `Vec<String>` byte-string list
2753    /// to a richer parsed-feature-set newtype once the Cargo-shaped
2754    /// namespaced-dep `dep/feat` syntax the value-shape gate's
2755    /// docstring anticipates lands) would have had to be threaded
2756    /// through every open-coded copy in lockstep or two consumers
2757    /// would silently disagree on which feature closure a given dep
2758    /// activates — the [`Self::validate_caracteristicas`] gate walking
2759    /// the author-declared list while a downstream caixa-resolver
2760    /// consumer walked a per-scope-override-resolved list would
2761    /// silently split the build-time refusal from the lacre closure
2762    /// the substrate's fetch pipeline actually materializes, one
2763    /// build-time diagnostic disagreeing with the run-time closure.
2764    /// Lifting the resolution rule to a typed method on the substrate
2765    /// primitive means every downstream consumer of the caixa's per-
2766    /// `:deps` feature-toggle surface reaches for exactly one typed
2767    /// dispatch — the resolver's accept-set migrates as a unit on any
2768    /// future axis addition.
2769    ///
2770    /// First outer-`Dep` `&[T]`-return slice accessor — opens the
2771    /// outer-`Dep` `&[String]` slice projection pattern the sibling
2772    /// per-`Dep` `:opcional` (`bool` — the plain-`Copy`-scalar axis)
2773    /// future outer scalar lift folds on and closes the outer-`Dep`
2774    /// slot-family the sibling [`Self::nome`] (eba2cde) /
2775    /// [`Self::versao_requirement`] (05529b1) / [`Self::fonte`] (d65d1bf)
2776    /// accessors already open, leaving the `:opcional` `Copy`-scalar arm
2777    /// as the sole remaining unlifted outer-`Dep` slot. Peer of the
2778    /// outer top-level [`crate::Caixa`] `&[String]`-return foreign-code-
2779    /// slot sub-family ([`crate::Caixa::bibliotecas`] 8a36c23,
2780    /// [`crate::Caixa::exe`] 65d9527, [`crate::Caixa::servicos`]
2781    /// 611f78b) and the outer top-level [`crate::Caixa`] universal-axis
2782    /// text-tag family ([`crate::Caixa::autores`] b5d813f,
2783    /// [`crate::Caixa::etiquetas`] 78c7d3c) that already carry the
2784    /// `&[String]` slice-projection discipline on the outer-`Caixa`
2785    /// altitude — extends the "one typed dispatch on the substrate
2786    /// primitive, thin projections at each consumer" discipline onto the
2787    /// outer per-dep-list-entry [`Dep`] altitude's set-shaped byte-
2788    /// string list slot. Returns `&[String]` (not `&Vec<String>`)
2789    /// because every downstream consumer of the feature-toggle list
2790    /// treats it as a read-only sequence — the slice-view is the
2791    /// narrowest borrow that supports every present + roadmapped
2792    /// consumer (`.iter()`, `.len()`, `.is_empty()`) without leaking
2793    /// the backing `Vec`'s grow/push/reserve surface no consumer of
2794    /// the typed view reaches for (the storage-side `Vec` remains
2795    /// reachable through the `pub caracteristicas` field for the
2796    /// mutation-carrying serde round-trip and per-test fixture-mutation
2797    /// paths). Named `caracteristicas()` to match the storage field's
2798    /// name verbatim and the tatara-lisp author-surface term
2799    /// (`:caracteristicas`) the field's own docstring already carries.
2800    #[must_use]
2801    pub fn caracteristicas(&self) -> &[String] {
2802        self.caracteristicas.as_slice()
2803    }
2804
2805    /// Substrate-canonical per-`:deps` / `:deps-dev` entry `:opcional`
2806    /// missing-source-tolerance flag scalar accessor every consumer of
2807    /// the dep-graph opt-in-fetch axis keys off — returns the author-
2808    /// declared `:opcional` `bool` verbatim, `Copy`-projected from the
2809    /// typed slot's own `bool` storage (no borrow of `&self` past the
2810    /// call; the `Copy`-return arm matches the peer
2811    /// [`crate::Caixa::max_restarts`] (eba5211) `Option<u32>` `Copy`-
2812    /// projected sibling discipline the outer flat-spread family
2813    /// already carries). Default-`false` (`#[serde(default,
2814    /// skip_serializing_if = "is_false")]` on the storage slot, so a
2815    /// `Dep` past parse definitionally carries a `bool` — `false` when
2816    /// the author omits `:opcional` — and the returned value degenerates
2817    /// to `false` on that arm without any silent `None` collapse).
2818    ///
2819    /// The `:deps :opcional` / `:deps-dev :opcional` slot carries the
2820    /// per-entry "if this dep's `:fonte` cannot be resolved, treat the
2821    /// missing-source arm as a soft-fail rather than a build refusal"
2822    /// bit — the same Cargo-shaped `[dependencies.<dep>.optional = true]`
2823    /// accept-set (an opcional dep whose `:fonte` fails to resolve is
2824    /// dropped from the resolved dep-graph rather than tripping the
2825    /// build-refusal edge that a mandatory `:opcional false` entry
2826    /// would). Every downstream consumer that fans on the dep's
2827    /// missing-source-tolerance keys off this accessor: the future
2828    /// caixa-resolver's per-`:fonte` resolve-fail arm (drop-vs-error
2829    /// dispatch on the opcional bit ahead of the lacre closure
2830    /// materialization), the future caixa-crd per-`spec.deps`
2831    /// `optional` boolean the K8s-CR admission gate consumes on the
2832    /// per-dep partition, and the future feira / caixa-resolver /
2833    /// caixa-crd feature-projection walk that folds the opcional bit
2834    /// into the resolved feature-closure the future M4 lacre-federation
2835    /// layer emits.
2836    ///
2837    /// Prior to this lift the `.opcional` `bool` slot was read inline
2838    /// at the sole in-crate consumer site — the tests-module
2839    /// `registry_dep_is_minimal` fixture's `assert!(!d.opcional)` gate
2840    /// pinning the [`Self::simple`] constructor's default-`false` fill
2841    /// (the only in-crate read of the raw field beyond the per-`Dep`
2842    /// constructor pair [`Self::simple`] / [`Self::git`] and the paired
2843    /// serde round-trip / per-test fixture-mutation paths) — an open-
2844    /// coded field-access that expressed no compile-time link back to
2845    /// the typed slot. A future extension of the `:opcional` axis to a
2846    /// richer author surface (a per-scope opcional-override the resolver
2847    /// folds through the `~/.config/caixa/config.yaml` entry the [`Dep`]
2848    /// docstring already acknowledges, a per-cluster opcional-override
2849    /// the future M4 lacre-federation layer applies per-CR, a promotion
2850    /// of the plain `bool` to a richer `OpcionalPolicy { drop, warn,
2851    /// error }` tri-state once the CAIXA-SDLC §II opcional-policy
2852    /// roadmap lands) would have had to be threaded through every open-
2853    /// coded copy in lockstep or two consumers would silently disagree
2854    /// on which missing-source arm a given dep resolves to — the
2855    /// [`Self::simple`] constructor's default-`false` fill reading
2856    /// verbatim while a downstream caixa-resolver consumer read a per-
2857    /// scope-override-resolved bit would silently split the build-time
2858    /// arm from the lacre closure the substrate's fetch pipeline
2859    /// actually materializes, one build-time diagnostic disagreeing
2860    /// with the run-time closure. Lifting the resolution rule to a
2861    /// typed method on the substrate primitive means every downstream
2862    /// consumer of the caixa's per-`:deps` opcional-tolerance surface
2863    /// reaches for exactly one typed dispatch — the resolver's accept-
2864    /// set migrates as a unit on any future axis addition.
2865    ///
2866    /// Fifth and final outer-`Dep` accessor — closes the outer-`Dep`
2867    /// slot-family the sibling per-`Dep` [`Self::nome`] (eba2cde) /
2868    /// [`Self::versao_requirement`] (05529b1) / [`Self::fonte`] (d65d1bf)
2869    /// / [`Self::caracteristicas`] (9197944) accessors opened, so every
2870    /// outer-`Dep` slot (`:nome`, `:versao`, `:fonte`, `:opcional`,
2871    /// `:caracteristicas`) now routes through exactly one typed
2872    /// dispatch on the substrate primitive. First outer-`Dep`
2873    /// `bool`-return / plain-`Copy`-scalar accessor — opens the
2874    /// outer-`Dep` `Copy`-scalar projection pattern that folds on the
2875    /// peer outer-top-level [`crate::Caixa`] `Option<Copy>`
2876    /// flat-spread sub-family ([`crate::Caixa::max_restarts`] eba5211,
2877    /// [`crate::Caixa::estrategia`] ed04d3c) the outer-`Caixa` altitude
2878    /// already carries — extends the "one typed dispatch on the
2879    /// substrate primitive, thin projections at each consumer"
2880    /// discipline onto the outer per-dep-list-entry [`Dep`] altitude's
2881    /// bool-shaped missing-source-tolerance slot. Returns `bool` by
2882    /// `Copy` (not by `&bool` reference) because `bool` is `Copy` and
2883    /// every downstream consumer treats it as a plain discriminant
2884    /// value — the by-value return is the narrowest return-shape that
2885    /// supports every present + roadmapped consumer (`.then(…)` early
2886    /// return on the resolver-side drop-vs-error partition, direct
2887    /// bool composition with a per-scope-override projector, plain
2888    /// `if dep.opcional() { … }` early return at every future admission
2889    /// gate) without leaking the storage field's `bool`-in-`&self`
2890    /// lifetime the by-value return elides. Marked `pub const fn` so
2891    /// the accessor is `const`-callable — same discipline the peer
2892    /// [`crate::Caixa::max_restarts`] `Option<u32>` `Copy`-return
2893    /// accessor carries. Named `opcional()` to match the storage
2894    /// field's name verbatim and the tatara-lisp author-surface term
2895    /// (`:opcional`) the field's own docstring already carries.
2896    #[must_use]
2897    pub const fn opcional(&self) -> bool {
2898        self.opcional
2899    }
2900
2901    /// Build a minimal registry-sourced dep.
2902    #[must_use]
2903    pub fn simple(nome: impl Into<String>, versao: impl Into<String>) -> Self {
2904        Self {
2905            nome: nome.into(),
2906            versao: versao.into(),
2907            fonte: None,
2908            opcional: false,
2909            caracteristicas: Vec::new(),
2910        }
2911    }
2912
2913    /// Build a Git-sourced dep (tag-based).
2914    #[must_use]
2915    pub fn git(
2916        nome: impl Into<String>,
2917        versao: impl Into<String>,
2918        repo: impl Into<String>,
2919        tag: impl Into<String>,
2920    ) -> Self {
2921        Self {
2922            nome: nome.into(),
2923            versao: versao.into(),
2924            fonte: Some(DepSource::Git {
2925                repo: repo.into(),
2926                tag: Some(tag.into()),
2927                rev: None,
2928                branch: None,
2929            }),
2930            opcional: false,
2931            caracteristicas: Vec::new(),
2932        }
2933    }
2934
2935    /// Reject dependency entries whose `:nome` or `:versao` are empty,
2936    /// whose `:nome` is non-empty but not a valid DNS-1123 label,
2937    /// or whose `:versao` is non-empty but not a valid Cargo-shaped
2938    /// semver requirement.
2939    ///
2940    /// The author surface for `:deps :versao` (and `:deps-dev :versao`)
2941    /// is the same Cargo-shaped requirement string `:membros :versao`
2942    /// (validated at [`crate::AplicacaoSpec::validate`] since 9888b13)
2943    /// and `:children :versao` (validated at
2944    /// [`crate::SupervisorSpec::validate`] since b38ff3a) carry — and
2945    /// the lacre pipeline resolves all three axes through the same
2946    /// [`crate::parse_requirement`] entry-point. Until 2420c44 landed
2947    /// `:deps :versao` was the last `:versao` axis untyped past
2948    /// `Caixa::from_lisp`: a malformed-but-non-empty requirement
2949    /// (`"^bad-version"`, `"^^0.1"`, the canonical git-tag-shape-
2950    /// leaking-into-:versao `"v0.1"` typo, the accidental
2951    /// `"not-a-req"`) silently passed parse and the `semver::Error`
2952    /// surfaced at lacre-resolve time, far from the source
2953    /// caixa.lisp, with no field naming which `:deps` entry carried
2954    /// the typo. The diagnostic [`DepError::VersaoInvalid`] carries
2955    /// the offending entry's `:nome` + the offending `:versao`
2956    /// verbatim + the parser's own wording in `reason`, so the
2957    /// author's grep target is unambiguous.
2958    ///
2959    /// The author surface for `:deps :nome` is the same DNS-1123 label
2960    /// the peer caixa-identifier axes carry — top-level Caixa `:nome`
2961    /// (validated at [`crate::Caixa::validate_nome`] since 6c992f8),
2962    /// `:membros :caixa` (validated at
2963    /// [`crate::AplicacaoSpec::validate_membros`] since 3f9d7a0),
2964    /// `:children :caixa` (validated at
2965    /// [`crate::SupervisorSpec::validate`] since 31bfa43). A `:deps
2966    /// :nome` value flows verbatim through the lacre pipeline as the
2967    /// target caixa's `:nome` (which the gate at the *target* side now
2968    /// rejects if non-DNS-1123) and lands as the rendered caixa's
2969    /// `lareira-<nome>` Helm chart name segment, the per-dep
2970    /// `LABEL_PROGRAM` label value, and the `caixa-resolver`'s
2971    /// `~/.cache/caixa/<org>/<nome>` checkout-directory leaf. Until
2972    /// this gate landed `:deps :nome` was the fourth and last
2973    /// DNS-1123-shaped caixa-identifier axis still untyped past
2974    /// `Caixa::from_lisp`: a syntactically wrong dep name (`"Caixa-
2975    /// Teia"` uppercase — the canonical "I copied the README header"
2976    /// typo; `"caixa_teia"` underscore — the Go module / Python
2977    /// identifier leak; `"caixa-teia."` trailing dot — the FQDN
2978    /// confusion; `"-caixa-teia"` leading hyphen; a 64-byte slug)
2979    /// silently passed parse and surfaced at lacre-resolve time when
2980    /// the resolved target caixa's `:nome` failed *its* DNS-1123 gate
2981    /// — far from the source `:deps` entry, with a diagnostic naming
2982    /// the *target's* `:nome` rather than the dep entry that referenced
2983    /// it. Mirroring the 3f9d7a0 / 31bfa43 / 6c992f8 trajectory through
2984    /// the lifted [`crate::render::is_dns_1123_label`] predicate (the
2985    /// "before its third occurrence" PRIME DIRECTIVE boundary, THEORY.md
2986    /// §I.3.5): every `Dep::nome` past validate is DNS-1123-label-shaped,
2987    /// so every downstream consumer (caixa-resolver's lacre fetch,
2988    /// caixa-helm's `lareira-<nome>` chart name, the future M4 per-dep
2989    /// fan-out emitter) reaches for the name knowing the value is
2990    /// apiserver-valid without re-validating.
2991    ///
2992    /// Empty checks fire first (narrower diagnostic), parse last —
2993    /// same ordering discipline as
2994    /// [`crate::AplicacaoSpec::validate_membros`] and
2995    /// [`crate::SupervisorSpec::validate`]. `parse_requirement("")`
2996    /// returns `Ok(VersionReq::STAR)`, so the empty-`:versao` arm is
2997    /// structurally necessary even with the parse arm in place. The
2998    /// `:nome` shape gate runs after the `:nome` empty gate and before
2999    /// the `:versao` checks so a one-entry caixa.lisp with both wrong
3000    /// sees the name-side diagnostic first (the name is the
3001    /// self-locating axis — without it, the parse diagnostic can't
3002    /// quote `:nome "<bad>"`).
3003    pub fn validate(&self) -> Result<(), DepError> {
3004        if self.nome.is_empty() {
3005            return Err(DepError::NomeEmpty);
3006        }
3007        if let Err(reason) = crate::render::is_dns_1123_label(&self.nome) {
3008            return Err(DepError::NomeInvalid {
3009                nome: self.nome.clone(),
3010                reason,
3011            });
3012        }
3013        // Delegate the empty-first + `parse_requirement` cascade to the
3014        // shared [`crate::render::require_valid_versao_requirement`]
3015        // helper — same two-arm shape the peer
3016        // [`crate::AplicacaoSpec::validate_membros`] on `:membros
3017        // :versao` and [`crate::SupervisorSpec::validate`] on `:children
3018        // :versao` route through, so drift between the three axes'
3019        // accepted requirement sets is structurally impossible and the
3020        // parse-side no-op the empty-first arm closes (semver's empty
3021        // parse yields an implicit `*`) lives in exactly one predicate.
3022        crate::render::require_valid_versao_requirement(
3023            self.versao_requirement(),
3024            || DepError::VersaoEmpty {
3025                nome: self.nome.clone(),
3026            },
3027            |reason| DepError::VersaoInvalid {
3028                nome: self.nome.clone(),
3029                versao: self.versao_requirement().to_string(),
3030                reason,
3031            },
3032        )?;
3033        if let Some(fonte) = self.fonte() {
3034            fonte.validate(&self.nome)?;
3035        }
3036        self.validate_caracteristicas()?;
3037        Ok(())
3038    }
3039
3040    /// Reject per-entry `:caracteristicas` (feature-flag) values that
3041    /// are operationally meaningless. The `:caracteristicas` slot is
3042    /// a set of feature toggles to enable on the target caixa — same
3043    /// shape as Cargo's `[dependencies.<dep>.features]` list — and
3044    /// two structural footguns close here:
3045    ///
3046    ///   - empty-string entry (`(:caracteristicas (""))`): the future
3047    ///     caixa-resolver lacre pipeline would consume the empty
3048    ///     identifier as a no-op feature enable, silently dropping the
3049    ///     author's intent far from the source `caixa.lisp`;
3050    ///   - duplicate entry within one dep (`(:caracteristicas ("http"
3051    ///     "http"))`): the feature-toggle slot is set-shaped (enabling
3052    ///     a feature twice has no additional semantic — there is no
3053    ///     `feature × 2`), so two entries naming the same feature are
3054    ///     a silent miscount, the same set-not-multiset distinction
3055    ///     every peer Vec-keyed-by-name axis already closes
3056    ///     ([`crate::SupervisorError::DuplicateChildCaixa`] on
3057    ///     `:children :caixa`, [`crate::AplicacaoError::MembroDuplicate`]
3058    ///     on `:membros :caixa`, [`crate::AplicacaoError::ContratoDuplicate`]
3059    ///     on `:contratos`, [`crate::AplicacaoError::PlacementClusterDuplicate`]
3060    ///     on `:placement :clusters`, [`crate::AplicacaoError::EntradaPathDuplicate`]
3061    ///     on `:entrada :paths`, [`crate::UpgradeError::DuplicateFrom`]
3062    ///     on `:upgrade-from :from`, [`crate::UpgradeError::DuplicateLoadModule`]
3063    ///     / [`crate::UpgradeError::DuplicateStateChange`] /
3064    ///     [`crate::UpgradeError::DuplicateCleanup`] on the within-
3065    ///     entry `:upgrade-from` axes, and [`DepError::DuplicateNome`]
3066    ///     on the cross-entry `:deps`/`:deps-dev` `:nome` axis the
3067    ///     immediate-predecessor 359fba5 closed).
3068    ///
3069    /// Same linear-walk + `HashSet` + first-collision diagnostic shape
3070    /// every peer set-not-multiset gate uses; the empty arm fires
3071    /// before the duplicate arm so an entry with both an empty feature
3072    /// *and* a duplicate of some later feature surfaces the empty-
3073    /// shape diagnostic first (the empty-feature axis is the
3074    /// more-actionable defect since the missing-name renders the
3075    /// duplicate-key arm ambiguous: two `""` entries would both report
3076    /// `caracteristica: ""` with no way to distinguish the offending
3077    /// site). Empty-first cascade discipline mirrors every peer per-
3078    /// entry shape + duplicate gate
3079    /// (`SupervisorSpec::validate`'s `EmptyChildName` before
3080    /// `DuplicateChildCaixa`; `validate_membros`'s `MembroCaixaEmpty`
3081    /// before `MembroDuplicate`).
3082    ///
3083    /// The per-entry value-shape gate (Cargo-feature-name grammar via
3084    /// the lifted [`crate::render::is_cargo_feature_name`] predicate)
3085    /// fires between the empty arm and the duplicate arm — the
3086    /// canonical per-entry-shape-before-cross-entry-uniqueness
3087    /// precedence every peer two-arm + value-shape gate establishes
3088    /// ([`crate::SupervisorSpec::validate`]'s `EmptyChildName` →
3089    /// `ChildCaixaInvalid` → `DuplicateChildCaixa`,
3090    /// [`crate::AplicacaoSpec::validate_membros`]'s `MembroCaixaEmpty`
3091    /// → `MembroCaixaInvalid` → `MembroDuplicate`, [`Dep::validate`]'s
3092    /// `NomeEmpty` → `NomeInvalid` → cross-list `DuplicateNome`).
3093    /// Until the value-shape arm landed `:caracteristicas` accepted
3094    /// every non-empty distinct string — a structurally invalid
3095    /// feature name (`"http feature"` whitespace, `"+http"` the
3096    /// canonical paste-from-`+optional-feature` doc activation-form
3097    /// footgun, `"-flag"` leading hyphen, `".feat"` leading dot,
3098    /// `"http/json"` Cargo's `dep/feat` namespaced-dep syntax that
3099    /// only applies inside list-grammar contexts, `"http,json"`
3100    /// list-separator-belongs-to-the-list-grammar miscomprehension,
3101    /// `"café"` un-percent-encoded non-ASCII silently round-tripping
3102    /// inconsistently across NFC/NFD normalization, the 65-byte
3103    /// paste-from-binary slug) silently passed validate and the
3104    /// failure surfaced at `cargo metadata` time as the
3105    /// `restricted_names::validate_feature_name` parser's rejection,
3106    /// far from the source `caixa.lisp`, with no field naming which
3107    /// `:deps` entry's `:caracteristicas` carried the typo. The
3108    /// lifted predicate makes the Cargo-feature-name-grammar
3109    /// intersection-floor a substrate-level invariant at validate
3110    /// time — same trajectory as the eight peer
3111    /// [`crate::render`] value-shape predicates each typed surface
3112    /// downstream of a structured grammar already follows
3113    /// ([`is_dns_1123_label`](crate::render::is_dns_1123_label),
3114    /// [`is_gateway_api_http_path`](crate::render::is_gateway_api_http_path),
3115    /// [`is_wit_world_ref`](crate::render::is_wit_world_ref),
3116    /// [`is_nats_subject`](crate::render::is_nats_subject),
3117    /// [`is_wasi_keyvalue_slot`](crate::render::is_wasi_keyvalue_slot),
3118    /// [`is_git_ref_name`](crate::render::is_git_ref_name),
3119    /// [`is_git_oid`](crate::render::is_git_oid),
3120    /// [`is_git_repo_url`](crate::render::is_git_repo_url)).
3121    fn validate_caracteristicas(&self) -> Result<(), DepError> {
3122        let mut seen = std::collections::HashSet::new();
3123        for c in self.caracteristicas() {
3124            if c.is_empty() {
3125                return Err(DepError::CaracteristicaEmpty {
3126                    nome: self.nome.clone(),
3127                });
3128            }
3129            if let Err(reason) = crate::render::is_cargo_feature_name(c) {
3130                return Err(DepError::CaracteristicaInvalid {
3131                    nome: self.nome.clone(),
3132                    caracteristica: c.clone(),
3133                    reason,
3134                });
3135            }
3136            crate::render::insert_first_seen(&mut seen, c.as_str(), || {
3137                DepError::CaracteristicaDuplicate {
3138                    nome: self.nome.clone(),
3139                    caracteristica: c.clone(),
3140                }
3141            })?;
3142        }
3143        Ok(())
3144    }
3145}
3146
3147/// Cross-slot coherence gate on the dep-graph axis: no `:deps` or
3148/// `:deps-dev` entry may name the caixa's own `:nome`.
3149///
3150/// A caixa that lists itself as a dep is a degenerate self-edge in the
3151/// lacre closure's dep-graph — the closure is a DAG rooted at the
3152/// caixa's `:nome`, and the caixa-resolver's lacre pipeline traverses
3153/// every `:deps` / `:deps-dev` entry's target by name. A self-dep
3154/// hands the resolver a node that is its own parent: a one-node cycle
3155/// it either rejects mid-traversal far from the source `caixa.lisp`
3156/// (the resolver detecting infinite recursion on the closure walk) or,
3157/// worse, recurses on until it exhausts its stack. Because every
3158/// `:nome` is a globally-unique substrate identity (DNS-1123 label +
3159/// lacre closure root), a dep entry whose `:nome` equals the caixa's
3160/// own `:nome` *is* the caixa itself, not a coincidentally-named peer.
3161///
3162/// Lives outside [`Caixa::validate_deps`] because the dep-list view
3163/// carries the entries but not the parent `:nome`; mirrors the
3164/// cross-slot self-edge gates [`crate::supervisor::validate_no_self_supervision`]
3165/// (ad4abf1) on the `:children :caixa` axis and
3166/// [`crate::aplicacao::validate_no_self_membership`] on the
3167/// `:membros :caixa` axis — the same "an edge from a graph node to
3168/// itself is structurally not a tree/graph edge" discipline, here on
3169/// the third typed-name-graph axis (the dep closure; the supervision
3170/// tree and the Aplicacao membership set were the prior two).
3171///
3172/// Walks `:deps` first then `:deps-dev` so the diagnostic for a caixa
3173/// that self-references on both axes surfaces the `:deps` arm first —
3174/// the load-bearing axis the lacre closure resolves at every build,
3175/// peer with the canonical [`Caixa::validate_deps`] walk order
3176/// (`:deps` → `:deps-dev`).
3177///
3178/// Carries the offending list tag (`":deps"` or `":deps-dev"`)
3179/// verbatim into the diagnostic so the author can grep their
3180/// `caixa.lisp` for the offending block in one edit — same
3181/// `list: &'static str` shape [`DepError::DuplicateNome`] (359fba5)
3182/// uses on the cross-list duplicate-name axis.
3183///
3184/// `Code paths` (`:bibliotecas` / `:exe` / `:servicos`) are the
3185/// substrate-blessed shape for referencing the caixa's *own* code, so
3186/// the diagnostic names them as the corrective surface — every
3187/// legitimate "I want to use code from this caixa" authoring intent
3188/// routes through one of those three slots, not a self-dep.
3189pub fn validate_no_self_dep(
3190    deps: &[Dep],
3191    deps_dev: &[Dep],
3192    parent_nome: &str,
3193) -> Result<(), DepError> {
3194    for dep in deps {
3195        if dep.nome() == parent_nome {
3196            return Err(DepError::DepIsSelf {
3197                nome: parent_nome.to_string(),
3198                list: crate::render::DEP_AUTHOR_KEY_DEPS,
3199            });
3200        }
3201    }
3202    for dep in deps_dev {
3203        if dep.nome() == parent_nome {
3204            return Err(DepError::DepIsSelf {
3205                nome: parent_nome.to_string(),
3206                list: crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
3207            });
3208        }
3209    }
3210    Ok(())
3211}
3212
3213/// Closed-set typed enum for the two dep-list author-surface axes every
3214/// top-level [`crate::Caixa`] carries — the runtime-closure `:deps` slot
3215/// (`Prod`) and the dev-only-closure `:deps-dev` slot (`Dev`). Every
3216/// substrate consumer that dispatches on "which of the two dep-lists"
3217/// (the `feira add` mutation head, the future per-cluster dev-closure-
3218/// audit overlay the M4 CR materializer resolves per-CR, the future
3219/// `caixa app graph` per-list dep summary, every future
3220/// `Caixa::push_dep` / `Caixa::deps_by_list` typed-method dispatch a
3221/// caller reaches for) reads through this enum rather than through a
3222/// bare `&'static str` — the closed-set is expressed at the type layer,
3223/// so a future third dep-list axis (a `:deps-build` build-only closure
3224/// once the substrate grows cross-artifact heterogeneous dep-graphs,
3225/// per CAIXA-SDLC §I) is one variant plus one arm per method and the
3226/// compiler enforces exhaustiveness on every consumer's `match` arms.
3227///
3228/// The wire byte-string [`Self::as_str`] returns is the same author-
3229/// surface tag the sibling [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3230/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] constants carry — the
3231/// [`DepError::DuplicateNome`] / [`DepError::DepIsSelf`] `list:
3232/// &'static str` payload family the substrate already emits routes
3233/// through the same source of truth (an author reading a
3234/// [`DepError::DuplicateNome`] refusal can grep their `caixa.lisp`
3235/// for the offending `:deps` / `:deps-dev` block in one edit whether
3236/// the diagnostic came from a `Caixa::validate_deps` walk or a
3237/// `Caixa::push_dep` mutation).
3238///
3239/// Same "closed-set typed-enum discriminator with canonical
3240/// projections per axis" discipline the sibling closed-set typed enums
3241/// on the caixa typed surface carry
3242/// ([`crate::aplicacao::PlacementStrategy`] cc8f749,
3243/// [`crate::aplicacao::RateLimitUnit`] 6bce03d,
3244/// [`crate::supervisor::RestartStrategy`],
3245/// [`crate::supervisor::RestartPolicy`],
3246/// [`crate::upgrade::UpgradeInstruction`], [`crate::CaixaKind`])
3247/// — extended onto the outer-`Caixa` two-list dep-graph axis, the
3248/// substrate's last unlifted closed-set-shaped `&'static str`-carrying
3249/// axis on the top-level manifest surface.
3250#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, gen_platform::IsVariant)]
3251pub enum DepList {
3252    /// Runtime-closure `:deps` axis — the load-bearing dep-list the
3253    /// lacre closure resolves at every build. Wire-format
3254    /// [`crate::render::DEP_AUTHOR_KEY_DEPS`].
3255    Prod,
3256    /// Dev-only-closure `:deps-dev` axis — Cargo's `[dev-dependencies]`
3257    /// table's dev-time-only visibility contract per CAIXA-SDLC §I.
3258    /// Wire-format [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`].
3259    Dev,
3260}
3261
3262impl DepList {
3263    /// Exhaustive iteration surface for every consumer that reads the
3264    /// full closed-set (the future M4 admission webhook's per-list
3265    /// summary rejection body, any future round-trip pin harness). A
3266    /// future variant addition extends this slice as a single edit and
3267    /// every consumer picks up the new entry by construction — the
3268    /// compiler-checked exhaustiveness on the sibling method `match`
3269    /// arms is the build-time guarantee that no arm forgets to grow.
3270    pub const ALL: &'static [Self] = &[Self::Prod, Self::Dev];
3271
3272    /// Canonical author-surface tag every substrate consumer that
3273    /// names the offending dep-list in a diagnostic reaches for —
3274    /// [`crate::render::DEP_AUTHOR_KEY_DEPS`] for [`Self::Prod`] and
3275    /// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] for [`Self::Dev`],
3276    /// the same `&'static str` payload the sibling
3277    /// [`DepError::DuplicateNome`] and [`DepError::DepIsSelf`] variants
3278    /// already carry. Routing every dep-list diagnostic through the
3279    /// closed-set enum's `as_str` closes the last `&'static str`-shape
3280    /// literal-carry axis on the two-list dep-graph surface — a
3281    /// future kebab-case rebrand (`":deps"` → `":packages"`) or a
3282    /// wire-format promotion (a distinct diagnostic form for the
3283    /// `Dev` arm) reaches every consumer through one edit on the
3284    /// canonical constant, not a coordinated rewrite across the
3285    /// substrate's dep-graph consumers.
3286    #[must_use]
3287    pub const fn as_str(self) -> &'static str {
3288        match self {
3289            Self::Prod => crate::render::DEP_AUTHOR_KEY_DEPS,
3290            Self::Dev => crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
3291        }
3292    }
3293
3294    /// Substrate-canonical reverse projection on the two-list dep-graph
3295    /// axis — parses the author-surface wire tag back to the typed
3296    /// variant, or `None` when `s` is outside the closed-set arm-string
3297    /// set [`Self::as_str`] emits. Dispatches on the same lifted
3298    /// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3299    /// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] constants the
3300    /// [`Self::as_str`] emitter walks, so the parse and emit halves of
3301    /// the round-trip migrate through one caixa-core edit on any future
3302    /// list-axis addition.
3303    ///
3304    /// Prior to this lift the substrate carried only the forward
3305    /// `Self → &str` projection on the two-list dep-graph axis (the
3306    /// [`Self::as_str`] emitter, the [`std::fmt::Display`] impl routed
3307    /// through it, the two [`DepError::DuplicateNome`] /
3308    /// [`DepError::DepIsSelf`] variants that carry the wire tag verbatim
3309    /// as a `&'static str` `list:` field). Every future consumer that
3310    /// wanted to promote the wire tag back to the typed enum (a future
3311    /// `feira dep --list <deps|deps-dev>` CLI arg-parse that binds the
3312    /// wire form into the typed enum before dispatching to
3313    /// [`crate::Caixa::deps_of`] / [`crate::Caixa::push_dep`], the M4
3314    /// `mesh.pleme.io/v1alpha1/Caixa` CR materializer's admission-time
3315    /// wire re-parse of the per-list diagnostic body, a future
3316    /// [`DepError`] widening that promotes the two `list: &'static str`
3317    /// fields to a typed `list: DepList` carry so downstream consumers
3318    /// dispatch on the enum rather than string-comparing the wire
3319    /// scalar) would have had to re-inline a two-arm `match s { ":deps"
3320    /// => …, ":deps-dev" => …, _ => … }` cascade that expressed no
3321    /// compile-time link back to the typed [`DepList`] enum. A future
3322    /// variant addition (a `:build-dep` or `:test-dep` third list once
3323    /// the substrate grows Cargo-style split-graphs, a `:tool-dep` for
3324    /// build-time-only tooling per the peer Cargo `[build-dependencies]`
3325    /// / `[target.<cfg>.dev-dependencies]` future admission surface)
3326    /// would silently split the wire byte-string the emitter walks from
3327    /// the parser's arm-set — the round-trip would carry the new list
3328    /// through the forward projection but land on the fallback silently
3329    /// at every non-updated reverse parser, far from the arm-addition
3330    /// commit that caused the drift. Lifting the resolver to a typed
3331    /// method on the substrate primitive closes the drift footgun by
3332    /// construction: the parser's accept-set is the same set the
3333    /// [`Self::as_str`] emitter walks (routed through the same lifted
3334    /// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3335    /// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] consts), so both halves
3336    /// of the round-trip migrate through one caixa-core edit on any
3337    /// future list-axis addition.
3338    ///
3339    /// Same closed-set-reverse-projection discipline the sibling
3340    /// [`crate::CaixaKind::from_wire`] (2aa6d23) /
3341    /// [`crate::supervisor::RestartStrategy::from_wire`] (4eec29c) /
3342    /// [`crate::supervisor::RestartPolicy::from_wire`] (dd32ccf) /
3343    /// [`crate::aplicacao::PlacementStrategy::from_wire`] (18c7342) /
3344    /// [`crate::aplicacao::RateLimitUnit::from_suffix`] typed enums
3345    /// carry on the peer wire-side `str → Self` axes — extended onto
3346    /// the two-list dep-graph closed-set axis, the sixth substrate-side
3347    /// closed-set typed enum on the caixa surface to converge on the
3348    /// two-way `str ↔ Self` round-trip. Method-named `from_wire` (not
3349    /// `from_str`) to match the peer shapes verbatim and side-step the
3350    /// derived [`std::str::FromStr`] impls the sibling
3351    /// [`gen_platform::FromStrKind`]-carrying axes install on their
3352    /// kebab-case dispatcher-catalog identity. Returns `Option<Self>`
3353    /// (rather than `Result<Self, _>`) to match the peer shapes: the
3354    /// caller picks the diagnostic form appropriate for its use site —
3355    /// a future `feira dep --list …` arg-parse that surfaces
3356    /// `unknown list: <arg>` at the CLI builds one on top by iterating
3357    /// [`Self::ALL`], while the future M4 admission-webhook's rejection
3358    /// path folds `None` onto its per-CR structured refusal body.
3359    #[must_use]
3360    pub fn from_wire(s: &str) -> Option<Self> {
3361        match s {
3362            crate::render::DEP_AUTHOR_KEY_DEPS => Some(Self::Prod),
3363            crate::render::DEP_AUTHOR_KEY_DEPS_DEV => Some(Self::Dev),
3364            _ => None,
3365        }
3366    }
3367}
3368
3369/// Route [`std::fmt::Display`] through [`DepList::as_str`], so every
3370/// consumer that formats the axis as user-facing text (a future
3371/// `feira app graph` per-list summary, a future M4 admission-webhook
3372/// rejection body naming the offending list, this crate's own
3373/// [`DepError`] `#[error(...)]` templates when they widen to carry a
3374/// typed [`DepList`]) lands on the same author-surface tag the
3375/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3376/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] constants carry. Same
3377/// as-str-through-Display convergence discipline the sibling
3378/// [`crate::aplicacao::PlacementStrategy`],
3379/// [`crate::aplicacao::RateLimitUnit`],
3380/// [`crate::supervisor::RestartStrategy`],
3381/// [`crate::supervisor::RestartPolicy`], and [`crate::CaixaKind`]
3382/// closed-set typed enums carry.
3383impl std::fmt::Display for DepList {
3384    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3385        f.write_str(self.as_str())
3386    }
3387}
3388
3389/// Errors raised by [`Dep::validate`].
3390///
3391/// Mirrors the per-axis error families the other `:versao`-carrying
3392/// typed surfaces expose
3393/// ([`crate::AplicacaoError::MembroVersaoEmpty`] /
3394/// [`crate::AplicacaoError::MembroVersaoInvalid`],
3395/// [`crate::SupervisorError::EmptyChildVersion`] /
3396/// [`crate::SupervisorError::ChildVersaoInvalid`]) so a future top-
3397/// level `CaixaError` (M4) sums these without reshaping the diagnostic.
3398#[derive(Debug, Error, PartialEq, Eq)]
3399pub enum DepError {
3400    #[error(
3401        ":deps entry has empty :nome (every dep must name a target caixa; \
3402         omit the entry instead of carrying an empty name)"
3403    )]
3404    NomeEmpty,
3405    #[error(
3406        ":deps entry :nome {nome:?} is not a valid DNS-1123 label: {reason} \
3407         (the value flows verbatim as the target caixa's `:nome`, the rendered \
3408         `lareira-<nome>` Helm chart name segment, the `LABEL_PROGRAM` label \
3409         value, and the resolver's checkout-directory leaf — each apiserver-side \
3410         schema rejects non-DNS-1123 names at admission time; use a lowercase \
3411         RFC 1123 label like `\"caixa-teia\"` or `\"pleme-mesh\"`, 1..=63 bytes, \
3412         pattern `^[a-z0-9]([-a-z0-9]*[a-z0-9])?$`)"
3413    )]
3414    NomeInvalid { nome: String, reason: String },
3415    #[error(
3416        ":deps entry {nome:?} has empty :versao (every dep must pin a semver \
3417         constraint that resolves through the lacre pipeline)"
3418    )]
3419    VersaoEmpty { nome: String },
3420    #[error(
3421        ":deps entry {nome:?} :versao {versao:?} is not a valid semver \
3422         requirement: {reason} (use Cargo-shaped forms like `\"^0.1\"`, \
3423         `\"~0.1.2\"`, `\"0.1.0\"`, or `\"*\"` — the same shape `:membros :versao` \
3424         and `:children :versao` carry; the lacre pipeline resolves all three \
3425         through the same parser)"
3426    )]
3427    VersaoInvalid {
3428        nome: String,
3429        versao: String,
3430        reason: String,
3431    },
3432    #[error(
3433        ":deps entry {nome:?} :fonte (:tipo git …) has empty :repo \
3434         (every git source must name a repo — use a `github:org/repo` \
3435         shorthand, an `https://…` URL, or an ssh-git URL; omit the \
3436         entire :fonte block to fall back to the default-host resolver \
3437         convention)"
3438    )]
3439    FonteRepoEmpty { nome: String },
3440    #[error(
3441        ":deps entry {nome:?} :fonte (:tipo git …) :repo {repo:?} has \
3442         invalid value-shape: {reason} (the value flows verbatim into the \
3443         caixa-resolver's `git clone <repo>` subprocess invocation; every \
3444         documented form carries a `:` separator and no whitespace / \
3445         control / non-ASCII bytes — use a `github:org/repo` shorthand, \
3446         an `https://host/path` / `ssh://[user@]host/path` / \
3447         `git://host/path` / `file:///path` URL, or the `git@host:path` \
3448         scp-style SSH form)"
3449    )]
3450    FonteRepoShape {
3451        nome: String,
3452        repo: String,
3453        reason: String,
3454    },
3455    #[error(
3456        ":deps entry {nome:?} :fonte (:tipo git …) has no pin set \
3457         (set exactly one of :tag, :rev, or :branch so the resolver \
3458         can pick a reproducible commit; omit the entire :fonte block \
3459         to fall back to the default-host resolver convention, which \
3460         resolves the latest tag matching :versao)"
3461    )]
3462    FontePinMissing { nome: String },
3463    #[error(
3464        ":deps entry {nome:?} :fonte (:tipo git …) has multiple pins \
3465         set ({pins}); exactly one of :tag, :rev, or :branch must be \
3466         set so the resolver's checkout target is unambiguous (the \
3467         resolver's silent precedence is :rev > :tag > :branch — if \
3468         you intended one specifically, drop the others)"
3469    )]
3470    FontePinAmbiguous { nome: String, pins: String },
3471    #[error(
3472        ":deps entry {nome:?} :fonte (:tipo git …) has empty {pin} \
3473         (a set pin must name a non-empty git ref; drop the {pin} key \
3474         entirely to fall through to another pin axis)"
3475    )]
3476    FontePinEmpty { nome: String, pin: String },
3477    #[error(
3478        ":deps entry {nome:?} :fonte (:tipo git …) {pin} {value:?} has invalid \
3479         value-shape: {reason} (the git porcelain enforces the same shape at \
3480         `git fetch` / `git checkout` time on every pin; use a leaf refname \
3481         like `\"v0.1.0\"` for `:tag` or `\"main\"` / `\"feature/foo\"` for \
3482         `:branch`, or a full 40/64 lowercase-hex commit OID for `:rev` — \
3483         drop any `refs/heads/` or `refs/tags/` prefix the caixa-resolver \
3484         prepends at clone time, and avoid abbreviated SHAs which are \
3485         ambiguous across repository history)"
3486    )]
3487    FontePinShape {
3488        nome: String,
3489        pin: String,
3490        value: String,
3491        reason: String,
3492    },
3493    #[error(
3494        ":deps entry {nome:?} :fonte (:tipo path …) has empty :caminho \
3495         (every path source must name a non-empty filesystem path; \
3496         omit the entire :fonte block to fall back to the default-host \
3497         resolver convention)"
3498    )]
3499    FonteCaminhoEmpty { nome: String },
3500    #[error(
3501        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} is \
3502         absolute (the lacre pipeline embeds the value verbatim in its \
3503         per-dep content-address `path:{caminho}` at \
3504         caixa-resolver/src/resolve.rs:189, so an absolute path makes the \
3505         BLAKE3 closure differ across machines — defeating the \
3506         reproducibility contract that's load-bearing for CSE; express \
3507         the path relative to the caixa.lisp location, e.g. \
3508         \"../caixa-teia\" for a sibling workspace dep)"
3509    )]
3510    FonteCaminhoAbsolute { nome: String, caminho: String },
3511    #[error(
3512        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
3513         with `~` (the leading-tilde is a shell-expansion convention, not a \
3514         POSIX path component — `Path::is_absolute` returns false on it, so \
3515         the b94fd83 absolute-path gate doesn't catch it, but the lacre \
3516         pipeline embeds the value verbatim in its per-dep content-address \
3517         `path:{caminho}` at caixa-resolver/src/resolve.rs:189 and the \
3518         caixa-resolver folds it through `Path::join` without `~`-expansion, \
3519         so the build looks for a literal `./{caminho}` subdirectory and \
3520         fails at resolve time far from the source caixa.lisp; even worse, a \
3521         future caixa-resolver pass that *does* expand `~` would silently \
3522         re-open the host-layout-leak the b94fd83 absolute gate closes — \
3523         Alice's `~` resolves to `/home/alice`, Bob's to `/home/bob`, two CI \
3524         runners with different `$HOME` layouts resolve to two distinct paths \
3525         for the byte-identical caixa, defeating the THEORY.md §V.2 render-\
3526         determinism contract; express the path relative to the caixa.lisp \
3527         location, e.g. \"../caixa-teia\" for a sibling workspace dep, or \
3528         spell out the full relative path explicitly if a workstation-rooted \
3529         dep is genuinely intended)"
3530    )]
3531    FonteCaminhoTildeExpansion { nome: String, caminho: String },
3532    #[error(
3533        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
3534         with `$` (the leading-`$` is a shell-variable-expansion convention, \
3535         not a POSIX path component — `Path::is_absolute` returns false on it \
3536         and the a5c248e tilde gate doesn't catch it, but the lacre pipeline \
3537         embeds the value verbatim in its per-dep content-address \
3538         `path:{caminho}` at caixa-resolver/src/resolve.rs:189 and the \
3539         caixa-resolver folds it through `Path::join` without `$`-expansion, \
3540         so the build looks for a literal `./{caminho}` subdirectory and \
3541         fails at resolve time far from the source caixa.lisp; even worse, a \
3542         future caixa-resolver pass that *does* expand `$VAR` (the canonical \
3543         shell-convention idiom that CI's `${{WORKSPACE}}` paste-idiom \
3544         invites) would silently re-open the host-layout-leak the b94fd83 \
3545         absolute gate closes — Alice's `$HOME` resolves to `/home/alice`, \
3546         Bob's to `/home/bob`, two CI runners with different `${{WORKSPACE}}` \
3547         layouts resolve to two distinct paths for the byte-identical caixa, \
3548         defeating the THEORY.md §V.2 render-determinism contract; express \
3549         the path relative to the caixa.lisp location, e.g. \"../caixa-teia\" \
3550         for a sibling workspace dep, or spell out the full relative path \
3551         explicitly if a workstation-rooted dep is genuinely intended)"
3552    )]
3553    FonteCaminhoVarExpansion { nome: String, caminho: String },
3554    #[error(
3555        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
3556         with a space (the leading ASCII space `0x20` is the orthogonal \
3557         paste-from-aligned-doc footgun that silently passes \
3558         `Path::is_absolute` and every prior leading-byte arm — \
3559         `\" ../caixa-teia\"` resolves via `Path::join` to a literal \
3560         `./ ../caixa-teia` subdirectory the resolver fails to find at \
3561         resolve time with a non-self-locating `No such file or directory` \
3562         error far from the source caixa.lisp; the lacre pipeline embeds \
3563         the value verbatim in its per-dep content-address `path:{caminho}` \
3564         at caixa-resolver/src/resolve.rs:189, so byte-divergent / \
3565         semantic-identical caixa values (` ../caixa-teia` vs \
3566         `../caixa-teia`) yield two distinct BLAKE3 closures across two \
3567         workstations whose authors differ only in paste-from-aligned- \
3568         caixa.lisp-doc whitespace habits — the most insidious failure \
3569         mode the typed slot can carry (no error surfaces; the divergence \
3570         is invisible until two machines compare lacres), defeating the \
3571         THEORY.md §V.2 render-determinism contract. The canonical \
3572         paste-from-aligned-`:deps`-block footgun (every `:fonte` form in \
3573         a multi-entry `:deps` block sits at the same column — an author \
3574         selecting `\"<sp><sp><sp>../caixa-teia\"` and pasting it from \
3575         the rendered alignment into a fresh entry preserves the leading \
3576         whitespace verbatim); peer `:fonte :repo` axis already rejects \
3577         leading whitespace via `is_git_repo_url`, `:fonte :tag` / \
3578         `:fonte :branch` via `is_git_ref_name`, `:descricao` via \
3579         `is_chart_description_shape`, `:licenca` via \
3580         `is_spdx_expression_shape`. Drop the leading space; express the \
3581         path as a bare relative single-token like \"../caixa-teia\")"
3582    )]
3583    FonteCaminhoLeadingWhitespace { nome: String, caminho: String },
3584    #[error(
3585        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
3586         with `-` (the canonical CLI-argument-injection footgun on the \
3587         `:caminho` axis — the lacre pipeline embeds the value verbatim in \
3588         its per-dep content-address `path:{caminho}` at \
3589         caixa-resolver/src/resolve.rs:189 and the caixa-resolver folds it \
3590         through `Path::join` looking for a literal `./{caminho}` \
3591         subdirectory. Every downstream subprocess that consumes the resolved \
3592         path — `git -C {caminho} <verb>`, `terraform -chdir={caminho}`, \
3593         `nix build --path {caminho}`, `find {caminho}`, `stat {caminho}`, \
3594         `cp -r {caminho} …`, `rm -rf {caminho}` — reinterprets a leading-`-` \
3595         value as a CLI flag rather than a positional path when the invocation \
3596         does not carry a `--` argument-list terminator between the flag block \
3597         and the path (the common case at every porcelain entry point). The \
3598         canonical footguns: `:caminho \"-rf\"` (bare short-flag paste), \
3599         `:caminho \"-C\"` (`git -C -C` config-injection paste), \
3600         `:caminho \"--upload-pack=cat /etc/passwd\"` (the canonical long-flag \
3601         CLI-arg-injection vector at every git porcelain entry point that \
3602         consumes a path or URL argument, peer with is_git_repo_url's \
3603         leading-`-` arm on the sibling `:fonte :repo` axis), \
3604         `:caminho \"--config=…\"` (`git -c foo=bar` config-override paste). \
3605         POSIX `std::path::Path` treats a leading `-` as a literal filename \
3606         byte so the resolver folds `\"-rf\"` through `Path::join` and looks \
3607         for a literal `./-rf` subdirectory that fails at resolve time with a \
3608         non-self-locating `No such file or directory` error far from the \
3609         source caixa.lisp — but on any downstream shell-out without `--` the \
3610         reinterpretation is silent and the failure mode is arbitrary-\
3611         argument-injection. Peer arms: `is_git_repo_url` (render.rs:2037) \
3612         rejects leading `-` on `:fonte :repo` for `git clone <repo>` CLI-\
3613         arg-injection; `is_git_ref_name` (render.rs:1381, 5a28454) rejects \
3614         leading `-` on `:fonte :tag` / `:branch` for `git checkout <ref>` \
3615         CLI-arg-injection; `is_dns_1123_label` rejects leading `-` on every \
3616         DNS-1123-shaped axis (top-level Caixa `:nome`, `:membros :caixa`, \
3617         `:children :caixa`, `:deps :nome`, cluster names); \
3618         `is_cargo_feature_name` rejects leading `-` on `:caracteristicas`; \
3619         the feira `init` / `add <nome>` positional gate (868c191) rejects \
3620         leading `-` on the CLI positional itself. Express the path as a bare \
3621         relative single-token like \"../caixa-teia\" — the sibling-workspace \
3622         directory name carries no leading-hyphen semantic, and `./` / `../` \
3623         prefixes structurally partition the leading-byte set to safe values.)"
3624    )]
3625    FonteCaminhoLeadingHyphen { nome: String, caminho: String },
3626    #[error(
3627        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains \
3628         ASCII control byte 0x{byte:02x} (POSIX paths reject NUL `0x00` outright — \
3629         every `std::fs` syscall routes the path through `CString::new` which \
3630         fails with `NulError` at resolve time; the lacre pipeline embeds the \
3631         value verbatim in its per-dep content-address `path:{caminho}` at \
3632         caixa-resolver/src/resolve.rs:189 so a control byte anywhere in the \
3633         value lands in the BLAKE3 closure and breaks the THEORY.md §V.2 render-\
3634         determinism contract — the canonical paste-from-multiline-doc \
3635         (`\\n`/`\\r`), paste-from-aligned-table (`\\t`), or paste-from-binary-\
3636         blob (`0x00`-DEL) footgun every peer single-token-shaped axis \
3637         (`:fonte :repo`, `:fonte :tag`/`:branch`, the Helm chart-string axes) \
3638         already gates against. Express the path as a relative single-line ASCII \
3639         string, e.g. \"../caixa-teia\" for a sibling workspace dep)"
3640    )]
3641    FonteCaminhoControlChar {
3642        nome: String,
3643        caminho: String,
3644        byte: u8,
3645    },
3646    #[error(
3647        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains `\\` \
3648         (POSIX `std::path::Path` treats `\\` as a literal byte inside a single path \
3649         component, so `..\\caixa-teia` is one directory named literally `..\\caixa-teia` — \
3650         not the parent's sibling — and the caixa-resolver folds the value through \
3651         `Path::join` looking for a literal `./{caminho}` subdirectory that fails at \
3652         resolve time with a non-self-locating `No such file or directory` error far \
3653         from the source caixa.lisp; Windows `std::path::Path` treats `\\` as a \
3654         primary path separator equal to `/`, so byte-identical caixa.lisp values \
3655         resolve to two distinct directories across runner OSes — the lacre pipeline \
3656         embeds the value verbatim in its per-dep content-address `path:{caminho}` at \
3657         caixa-resolver/src/resolve.rs:189, defeating the THEORY.md §V.2 render-\
3658         determinism contract via the cross-host-OS-separator divergence vector. The \
3659         canonical Windows-Explorer `Copy as path` / PowerShell `Get-Location` \
3660         paste-idiom footgun; peer `:fonte :tag` / `:fonte :branch` axis already \
3661         rejects `\\` via `is_git_ref_name` for the same Windows-path-leak reason, \
3662         and `:entrada :paths` rejects `\\` via `is_gateway_api_http_path`'s eleven-\
3663         byte RFC-3986-reserved set. Express the path with `/` as the separator, e.g. \
3664         \"../caixa-teia\" for a sibling workspace dep)"
3665    )]
3666    FonteCaminhoBackslash { nome: String, caminho: String },
3667    #[error(
3668        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3669         redirection metacharacter 0x{byte:02x} `{ch}` (every interactive shell — bash / \
3670         zsh / fish / nushell — lexes `<` and `>` as input / output redirection \
3671         operators, so `:caminho \"../caixa-teia>build.log\"` is the canonical \
3672         paste-from-shell-pipeline footgun where an author copies a `command > log` \
3673         tail without trimming the redirect; POSIX `std::path::Path` treats both bytes \
3674         as literal path-component bytes, so the resolver folds the value through \
3675         `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
3676         subdirectory and fails at resolve time with a non-self-locating `No such \
3677         file or directory` error far from the source caixa.lisp. The lacre pipeline \
3678         embeds the value verbatim in its per-dep content-address `path:{caminho}` at \
3679         caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure \
3680         and rides into every shell-spawned subprocess (the resolver's `git clone`, a \
3681         future `feira tofu` shell-out, a future operator-side `nix` spawn) as the \
3682         canonical CRLF-at-subprocess-argument / shell-metachar injection surface every \
3683         peer single-token-shaped typed slot already closes. The peer `:fonte :tag` / \
3684         `:fonte :branch` axis already rejects `<` / `>` via `is_git_ref_name`, and \
3685         `:entrada :paths` rejects them via `is_gateway_api_http_path`'s eleven-byte \
3686         RFC-3986-reserved set. Express the path as a bare relative single-token like \
3687         \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
3688         redirection semantic.",
3689        ch = *byte as char
3690    )]
3691    FonteCaminhoShellRedirection {
3692        nome: String,
3693        caminho: String,
3694        byte: u8,
3695    },
3696    #[error(
3697        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-pipe \
3698         metacharacter `|` (every interactive shell — bash / zsh / fish / nushell — lexes \
3699         `|` as the pipe operator that wires one command's stdout to the next command's \
3700         stdin, so `:caminho \"../caixa-teia | grep foo\"` is the canonical paste-from-\
3701         shell-history footgun where an author copies a `ls ../caixa-teia | grep` line \
3702         without trimming the pipeline tail, and `:caminho \"../foo||bar\"` is the \
3703         symmetric `cmd-a || cmd-b` short-circuit-OR paste shape; POSIX `std::path::Path` \
3704         treats `|` as a literal path-component byte, so the resolver folds the value \
3705         through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
3706         subdirectory and fails at resolve time with a non-self-locating `No such file or \
3707         directory` error far from the source caixa.lisp. The lacre pipeline embeds the \
3708         value verbatim in its per-dep content-address `path:{caminho}` at caixa-resolver/\
3709         src/resolve.rs:189, so the byte lands in the BLAKE3 closure and rides into every \
3710         shell-spawned subprocess (the resolver's `git clone`, a future `feira tofu` \
3711         shell-out, a future operator-side `nix` spawn) as the canonical CRLF-at-\
3712         subprocess-argument / shell-metachar injection surface every peer single-token-\
3713         shaped typed slot already closes. The peer `:entrada :paths` axis rejects `|` \
3714         via `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the \
3715         path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
3716         workspace directory name carries no shell-pipe semantic."
3717    )]
3718    FonteCaminhoShellPipe { nome: String, caminho: String },
3719    #[error(
3720        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3721         command-separator metacharacter `;` (every interactive shell — bash / zsh / fish \
3722         / nushell — lexes `;` as the sequential-command terminator that fires the next \
3723         command regardless of the prior command's exit status, so `:caminho \
3724         \"../caixa-teia; rm -rf build\"` is the canonical paste-from-shell-one-liner \
3725         footgun where an author copies a `cd path; do-thing` chain without trimming \
3726         the cleanup tail, and `:caminho \"../foo;;bar\"` is the symmetric POSIX `case` \
3727         arm `;;` terminator paste shape; POSIX `std::path::Path` treats `;` as a \
3728         literal path-component byte, so the resolver folds the value through \
3729         `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
3730         subdirectory and fails at resolve time with a non-self-locating `No such file \
3731         or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
3732         the value verbatim in its per-dep content-address `path:{caminho}` at \
3733         caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
3734         rides into every shell-spawned subprocess (the resolver's `git clone`, a \
3735         future `feira tofu` shell-out, a future operator-side `nix` spawn) as the \
3736         canonical shell-metachar injection surface every peer single-token-shaped \
3737         typed slot already closes. The peer `:entrada :paths` axis rejects `;` via \
3738         `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the \
3739         path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
3740         workspace directory name carries no shell-command-separator semantic."
3741    )]
3742    FonteCaminhoShellSemicolon { nome: String, caminho: String },
3743    #[error(
3744        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3745         background / list-AND metacharacter `&` (every interactive shell — bash / zsh \
3746         / fish / nushell — lexes `&` two ways: single `&` as the background-task \
3747         terminator detaching the prior command and returning control immediately to \
3748         the prompt, double `&&` as the logical-AND list operator firing the next \
3749         command only if the prior succeeded; POSIX `std::path::Path` treats it as a \
3750         literal byte. The canonical paste-from-shell-prompt footgun is a `cd path & \
3751         sleep 1` background-launch one-liner or a `cd path && make install` build-\
3752         chain idiom selected whole into the `:caminho` slot — the prior `;` arm at \
3753         05c358e closed the sequential-command-separator vector, this arm closes the \
3754         orthogonal background-task / logical-AND vector on the same paste-from-shell-\
3755         prompt class. The lacre pipeline embeds the value verbatim in its per-dep \
3756         content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the \
3757         byte lands in the BLAKE3 closure and rides into every shell-spawned \
3758         subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a \
3759         future operator-side `nix` spawn) as the canonical shell-metachar injection \
3760         surface every peer single-token-shaped typed slot already closes. The peer \
3761         `:entrada :paths` axis rejects `&` via `is_gateway_api_http_path`'s eleven-\
3762         byte RFC-3986-reserved set. Express the path as a bare relative single-token \
3763         like \"../caixa-teia\" — the sibling-workspace directory name carries no \
3764         shell-background / logical-AND semantic."
3765    )]
3766    FonteCaminhoShellBackground { nome: String, caminho: String },
3767    #[error(
3768        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3769         command-substitution metacharacter `` ` `` (every POSIX shell — sh / bash / zsh / \
3770         dash / ksh / fish / nushell — lexes the byte as the legacy command-substitution \
3771         wrapper that runs the enclosed command and substitutes its standard-output \
3772         verbatim into the surrounding word, so a backticked `whoami` expands to the \
3773         current user's name and a backticked `cat /etc/passwd` expands to the file's \
3774         contents — the canonical CWE-78 shell-command-injection vector; POSIX \
3775         `std::path::Path` treats the byte as a literal path-component byte. The canonical \
3776         paste-from-shell-prompt footgun is a `cd ../path/<backtick>whoami<backtick>` legacy substitution \
3777         one-liner or a `cd <backtick>pwd<backtick>/path` working-directory expansion idiom selected whole \
3778         into the `:caminho` slot — the prior `&` arm at e12e4f3 closed the shell-\
3779         background / logical-AND vector, this arm closes the orthogonal command-\
3780         substitution vector on the same paste-from-shell-prompt class (the modern `$()` \
3781         form is gated at leading position by the f4efe9c `FonteCaminhoVarExpansion` arm; \
3782         the legacy backtick form is the orthogonal axis). The lacre pipeline embeds the \
3783         value verbatim in its per-dep content-address `path:{caminho}` at \
3784         caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
3785         rides into every shell-spawned subprocess (the resolver's `git clone`, a future \
3786         `feira tofu` shell-out, a future operator-side `nix` spawn) as the canonical \
3787         shell-metachar injection surface every peer single-token-shaped typed slot \
3788         already closes. The peer `:entrada :paths` axis rejects the byte via \
3789         `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the path \
3790         as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
3791         directory name carries no shell-command-substitution semantic."
3792    )]
3793    FonteCaminhoShellCommandSubstitution { nome: String, caminho: String },
3794    #[error(
3795        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3796         glob / pathname-expansion metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — \
3797         sh / bash / zsh / dash / ksh / fish / nushell — lexes `*` and `?` as pathname-\
3798         expansion wildcards: `*` matches any sequence of characters in a path component \
3799         and `?` matches exactly one character, so a `:caminho \"../caixa-teia/*\"` is the \
3800         canonical paste-from-shell-listing footgun where an author copies a \
3801         `ls ../caixa-teia/*` listing without trimming the wildcard, and `:caminho \
3802         \"../foo?\"` is the symmetric single-char-wildcard paste shape; POSIX \
3803         `std::path::Path` treats both bytes as literal path-component bytes, so the \
3804         resolver folds the value through `Path::new(caminho).join(<file>)` looking for \
3805         a literal `./{caminho}` subdirectory and fails at resolve time with a non-self-\
3806         locating `No such file or directory` error far from the source caixa.lisp. The \
3807         lacre pipeline embeds the value verbatim in its per-dep content-address \
3808         `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in the \
3809         BLAKE3 closure and rides into every shell-spawned subprocess (the resolver's \
3810         `git clone`, a future `feira tofu` shell-out, a future operator-side `nix` \
3811         spawn) as the canonical shell-metachar / glob-expansion surface every peer \
3812         single-token-shaped typed slot already closes. The peer `:entrada :paths` axis \
3813         rejects `*` and `?` via `is_gateway_api_http_path`'s eleven-byte RFC-3986-\
3814         reserved set. Express the path as a bare relative single-token like \
3815         \"../caixa-teia\" — the sibling-workspace directory name carries no shell-glob \
3816         / pathname-expansion semantic.",
3817        ch = *byte as char
3818    )]
3819    FonteCaminhoShellGlob {
3820        nome: String,
3821        caminho: String,
3822        byte: u8,
3823    },
3824    #[error(
3825        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3826         subshell-grouping metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / \
3827         zsh / dash / ksh / fish / nushell — lexes `(` and `)` as the subshell-grouping \
3828         operator: `(<cmd>)` runs `<cmd>` in a child shell with a fresh environment scope \
3829         (the canonical `(cd <path> && <cmd>)` shell-history one-liner scopes a `cd` to one \
3830         subshell without disturbing the parent's working directory), and `$(<cmd>)` is the \
3831         modern Bourne command-substitution shape the leading-`$` `FonteCaminhoVarExpansion` \
3832         arm closes the leading byte of — together the two arms now structurally exclude the \
3833         entire `$(<cmd>)` substitution surface from the typed `:caminho` accepted set. \
3834         POSIX `std::path::Path` treats the byte as a literal path-component byte, so a \
3835         `:caminho \"../caixa-teia/$(date)/build\"` (the canonical paste-from-shell-history \
3836         modern-command-substitution footgun) or `:caminho \"../(cd foo && pwd)/caixa-teia\"` \
3837         (the symmetric subshell-grouping working-directory-probe paste idiom) silently passes \
3838         every prior arm and the resolver folds the value through `Path::new(caminho).join(\
3839         <file>)` looking for a literal subdirectory and fails at resolve time with a non-\
3840         self-locating `No such file or directory` error far from the source caixa.lisp. The \
3841         lacre pipeline embeds the value verbatim in its per-dep content-address `path:\
3842         {caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 \
3843         closure and rides into every shell-spawned subprocess (the resolver's `git clone`, a \
3844         future `feira tofu` shell-out, a future operator-side `nix` spawn) as the canonical \
3845         shell-metachar / subshell-grouping surface every peer single-token-shaped typed slot \
3846         already closes. The peer `:fonte :repo` axis (3b99147) closes the same byte under the \
3847         same shell-subshell-grouping / RFC-3986-sub-delims banner on `is_git_repo_url`, \
3848         together with the leading-`$` `FonteCaminhoVarExpansion` arm closing the leading byte \
3849         of every `$(<cmd>)` shape. Express the path as a bare relative single-token \
3850         like \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
3851         subshell-grouping semantic.",
3852        ch = *byte as char
3853    )]
3854    FonteCaminhoShellSubshellGrouping {
3855        nome: String,
3856        caminho: String,
3857        byte: u8,
3858    },
3859    #[error(
3860        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3861         brace-expansion / URI-Template placeholder metacharacter 0x{byte:02x} `{ch}` \
3862         (every POSIX-derived brace-expanding shell — bash / zsh / ksh / fish — lexes `{{` / \
3863         `}}` as the brace-expansion operator: `{{a,b,c}}` expands to the cross-product of \
3864         comma-separated members and `{{1..10}}` expands to the integer range — the \
3865         canonical `mkdir -p ../{{caixa-teia,caixa-helm,caixa-flux}}` / `cp file{{,.bak}}` \
3866         idiom every shell-history block carries; RFC 6570 reserves the matched pair for \
3867         URI Template placeholders (the canonical `https://{{host}}/{{org}}/{{repo}}` \
3868         substitution shape every OpenAPI / Swagger / Postman / GitHub Octokit client \
3869         library / Helm chart-URL fragment carries) and the Mustache / Handlebars / \
3870         Tera / Jinja2 / Go html/template doubled-brace substitution form every IaC \
3871         templating engine (Helm, Kustomize, Terraform's `${{var}}` cousin) emits. POSIX \
3872         `std::path::Path` treats the byte as a literal path-component byte, so a \
3873         `:caminho \"../{{caixa-teia,caixa-helm}}/build\"` (the canonical paste-from-\
3874         shell-history brace-expansion fan-across-siblings footgun) or `:caminho \"../{{{{org}}}}/\
3875         caixa-teia\"` (the symmetric paste-from-templated-doc URI-Template placeholder \
3876         idiom every README quick-start / OpenAPI spec / Helm chart `home:` field carries) \
3877         silently passes every prior arm and the resolver folds the value through \
3878         `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
3879         resolve time with a non-self-locating `No such file or directory` error far from \
3880         the source caixa.lisp. The lacre pipeline embeds the value verbatim in its \
3881         per-dep content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, \
3882         so the byte lands in the BLAKE3 closure and rides into every shell-spawned \
3883         subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a \
3884         future operator-side `nix` spawn) as the canonical shell-metachar / brace-\
3885         expansion / URI-Template-placeholder surface every peer single-token-shaped \
3886         typed slot already closes. The peer `:fonte :repo` axis (42d8f9d) closes the \
3887         same byte pair on `is_git_repo_url` under the same RFC-3986-'delims' / \
3888         RFC-6570-URI-Template / shell-brace-expansion banner. Express the path as a \
3889         bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
3890         directory name carries no shell-brace-expansion / URI-Template-placeholder \
3891         semantic; if two siblings actually need pinning, author two separate `:deps` \
3892         entries rather than one brace-expanded `:caminho` value.",
3893        ch = *byte as char
3894    )]
3895    FonteCaminhoShellBraceExpansion {
3896        nome: String,
3897        caminho: String,
3898        byte: u8,
3899    },
3900    #[error(
3901        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3902         bracket-expansion / POSIX glob-character-class / shell-`test`-builtin metacharacter \
3903         0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / nushell \
3904         — lexes the bracket pair as the glob character-class operator: `[abc]` matches one of \
3905         `a` / `b` / `c`, `[a-z]` matches any lowercase ASCII letter, `[^x]` negates — the \
3906         canonical `ls *.[ch]` C-source-file glob and `cd ../caixa-[a-z]*` lowercase-sibling \
3907         glob every shell-history block carries; the bracket pair additionally carries the \
3908         POSIX `test` / `[` builtin command (`[ -d ../caixa-teia ] && cd ...` every shell-\
3909         script conditional uses) and bash's `[[ ... ]]` extended-test grammar; beyond shell \
3910         the pair is the TOML inline-array delimiter (`features = [\"a\", \"b\"]` — the \
3911         canonical paste-from-Cargo-manifest cross-idiom-leak vector), the YAML flow-sequence \
3912         delimiter (`paths: [/a, /b]` — the canonical paste-from-values.yaml cross-idiom \
3913         leak), the JSON array delimiter, and the POSIX-ERE / PCRE bracket-expression anchor. \
3914         POSIX `std::path::Path` treats the byte as a literal path-component byte, so a \
3915         `:caminho \"../caixa-[a-z]/build\"` (the canonical paste-from-shell-history glob-\
3916         character-class fan-across-siblings footgun) or `:caminho \"../[caixa-teia]/build\"` \
3917         (the symmetric paste-from-TOML-array / paste-from-YAML-flow-sequence cross-idiom \
3918         leak) silently passes every prior arm and the resolver folds the value through \
3919         `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
3920         resolve time with a non-self-locating `No such file or directory` error far from \
3921         the source caixa.lisp. The lacre pipeline embeds the value verbatim in its per-dep \
3922         content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte \
3923         lands in the BLAKE3 closure and rides into every shell-spawned subprocess (the \
3924         resolver's `git clone`, a future `feira tofu` shell-out, a future operator-side \
3925         `nix` spawn) as the canonical shell-metachar / glob-character-class / TOML-array \
3926         surface every peer single-token-shaped typed slot already closes. Express the path \
3927         as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
3928         directory name carries no shell-bracket-expansion / glob-character-class / array-\
3929         literal semantic; if a family of sibling caixas actually needs pinning, author \
3930         separate `:deps` entries rather than one character-class-expanded `:caminho` value.",
3931        ch = *byte as char
3932    )]
3933    FonteCaminhoShellBracketExpansion {
3934        nome: String,
3935        caminho: String,
3936        byte: u8,
3937    },
3938    #[error(
3939        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3940         quote-grouping / cross-config-DSL string-literal-delimiter metacharacter \
3941         0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / \
3942         nushell — lexes `'` as the strong string-literal delimiter (`'…'` — no expansion) \
3943         and `\"` as the weak string-literal delimiter (`\"…\"` — variable- / command-\
3944         substitution-preserving); the canonical `cd '../caixa-teia'` shell-history idiom \
3945         every path-with-embedded-whitespace paste block carries and the symmetric \
3946         `git clone \"$REPO\"` weak-quoted CI-manifest shape both leak the pair verbatim. \
3947         Beyond shell the pair is the JSON string-literal delimiter (`\"key\": \"value\"` — \
3948         the canonical paste-from-JSON-config cross-idiom-leak vector), the YAML double- \
3949         and single-quoted flow-scalar delimiter (`path: \"../caixa-teia\"` — the canonical \
3950         paste-from-values.yaml / paste-from-K8s-YAML-manifest cross-idiom leak), the TOML \
3951         basic and literal string delimiter (`path = \"../caixa-teia\"` — the canonical \
3952         paste-from-Cargo-manifest cross-idiom leak), the tatara-lisp string-literal \
3953         delimiter itself (`(:caminho \"../caixa-teia\")` — the canonical \"I copied the \
3954         entire `:caminho \"...\"` slot rather than just the string body\" author-surface \
3955         footgun), and RFC 3986 §2.2's `gen-delims` / `sub-delims` grammar which excludes \
3956         both bytes from the `pchar = unreserved / pct-encoded / sub-delims / \":\" / \"@\"` \
3957         production. POSIX `std::path::Path` treats the byte as a literal path-component \
3958         byte, so a `:caminho \"'../caixa-teia'\"` (the canonical paste-from-shell-history \
3959         strong-quoted sibling-workspace path footgun) or `:caminho \"\\\"../caixa-teia\\\"\"` \
3960         (the symmetric weak-quoted paste-from-JSON / paste-from-YAML flow-scalar / paste-\
3961         from-TOML basic-string / paste-from-tatara-lisp string-literal cross-idiom-leak \
3962         shape) silently passes every prior arm and the resolver folds the value through \
3963         `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
3964         resolve time with a non-self-locating `No such file or directory` error far from \
3965         the source caixa.lisp. The lacre pipeline embeds the value verbatim in its per-dep \
3966         content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte \
3967         lands in the BLAKE3 closure and rides into every shell-spawned subprocess (the \
3968         resolver's `git clone`, a future `feira tofu` shell-out, a future operator-side \
3969         `nix` spawn) as the canonical shell-metachar / string-literal-delimiter surface \
3970         every peer single-token-shaped typed slot already closes. The peer `:fonte :repo` \
3971         axis closes both bytes under the same shell-quote-grouping / RFC-3986-sub-delims \
3972         banner (e7a109f `'` shell-single-quote + 4267d8b `\"` shell-double-quote on \
3973         `is_git_repo_url`). Express the path as a bare relative single-token like \
3974         \"../caixa-teia\" — the sibling-workspace directory name carries no shell-quote-\
3975         grouping / string-literal-delimiter semantic; strip the outer quote pair from the \
3976         paste (the tatara-lisp `:caminho \"...\"` slot already carries the string-literal \
3977         quoting on the outer syntactic layer, so an inner quote pair would nest and \
3978         desugar to a broken layer).",
3979        ch = *byte as char
3980    )]
3981    FonteCaminhoShellQuoteGrouping {
3982        nome: String,
3983        caminho: String,
3984        byte: u8,
3985    },
3986    #[error(
3987        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3988         comment / URL-fragment-identifier / YAML-comment cross-config-DSL metacharacter \
3989         0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / \
3990         nushell — lexes an unquoted `#` at the head of a word or after unquoted \
3991         whitespace as the comment-lead per POSIX.1-2017 §2.3 Token Recognition step 6, \
3992         discarding the byte and everything after it to the end of the physical line \
3993         before command parsing (`cd ../caixa-teia  # legacy sibling` — the canonical \
3994         paste-from-shell-history-with-trailing-annotation shape every operator-notebook \
3995         and CI-manifest carries); YAML 1.2 §6.6 makes `#` the comment-lead at any \
3996         position preceded by whitespace or at line-start (`path: ../caixa-teia  # pin` \
3997         — the canonical paste-from-values.yaml / paste-from-K8s-manifest cross-idiom-\
3998         leak); RFC 3986 §3.5 reserves `#` as the URL fragment-identifier delimiter (the \
3999         canonical paste-from-browser-address-bar `github.com/foo/bar#readme` / \
4000         `github.com/foo/bar#L42` permalink shape, and the symmetric Nix-flake-ref \
4001         cross-idiom leak `github:foo/bar#packageName` where `#` selects a flake \
4002         output); the same cross-config-DSL surface extends to HCL / Terraform / Nix \
4003         flake attributes / dotenv `.env` / gitconfig / .gitignore / ini / TOML where \
4004         `#` is likewise the comment-lead. POSIX `std::path::Path` treats the byte as a \
4005         literal path-component byte, so a `:caminho \"../caixa-teia # legacy sibling\"` \
4006         (the canonical paste-from-shell-history-with-trailing-annotation footgun), \
4007         `:caminho \"../caixa-teia  # pin\"` (the symmetric YAML flow-scalar paste-with-\
4008         trailing-comment shape), or `:caminho \"../caixa-teia#readme\"` (the URL \
4009         fragment paste-from-browser-address-bar shape) silently passes every prior arm \
4010         and the resolver folds the value through `Path::new(caminho).join(<file>)` \
4011         looking for a literal subdirectory named `../caixa-teia # legacy sibling` and \
4012         fails at resolve time with a non-self-locating `No such file or directory` \
4013         error far from the source caixa.lisp — while every downstream shell / YAML / \
4014         URL parser silently truncates the value at the `#` byte to `../caixa-teia`, so \
4015         a `feira tofu` shell-out and a `nix flake check` on an emitted YAML `path:` \
4016         scalar disagree with the resolver on which directory the value names. The \
4017         lacre pipeline embeds the value verbatim in its per-dep content-address \
4018         `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in \
4019         the BLAKE3 closure and rides into every shell-spawned subprocess (the \
4020         resolver's `git clone`, a future `feira tofu` shell-out, a future operator-\
4021         side `nix` spawn) as the canonical shell-metachar / comment-lead / URL-\
4022         fragment-delimiter surface every peer single-token-shaped typed slot already \
4023         closes. The peer `:fonte :repo` axis closes the byte under the same URL-\
4024         fragment-identifier banner (a68f818 `#` on `is_git_repo_url`). Express the \
4025         path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
4026         workspace directory name carries no shell-comment / URL-fragment / YAML-\
4027         comment semantic; move any trailing annotation to a tatara-lisp `;`-comment \
4028         on the surrounding form (`;; legacy sibling` above the `(:caminho ...)` slot) \
4029         and drop any `#fragment` tail entirely (fragment identifiers select \
4030         renderings, not directories, and `:caminho` names a directory).",
4031        ch = *byte as char
4032    )]
4033    FonteCaminhoShellComment {
4034        nome: String,
4035        caminho: String,
4036        byte: u8,
4037    },
4038    #[error(
4039        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains URL-\
4040         percent-encoding-escape / printf-format-specifier / bash-job-control-specifier \
4041         / YAML-directive-lead metacharacter 0x{byte:02x} `{ch}` (RFC 3986 §2.1 reserves \
4042         `%` as the URL percent-encoding-escape — `%HH` is the mandatory encoding \
4043         mechanism for every byte outside the `unreserved` alphanumeric / `-` / `.` / \
4044         `_` / `~` set, and `%` itself must be percent-encoded as `%25` to appear \
4045         literally inside a URL value. The canonical paste-from-browser-address-bar \
4046         percent-encoded-space footgun (an author copies `../caixa%20teia` out of a URL-\
4047         encoded README hyperlink / browser address bar / percent-encoded permalink \
4048         expecting `%20` to decode to a literal space at the filesystem layer) locks two \
4049         distinct BLAKE3 closures (`path:../caixa%20teia` vs `path:../caixa teia`) for \
4050         what the author intended as the byte-identical sibling-workspace dep. POSIX \
4051         `std::path::Path` treats the byte as a literal path-component byte, so \
4052         `Path::join` looks for a literal `./{caminho}` subdirectory and fails at \
4053         resolve time with a non-self-locating `No such file or directory` error far \
4054         from the source caixa.lisp — while every downstream URL parser / shell printf \
4055         builtin / YAML directive parser silently reinterprets the byte to a different \
4056         value than the resolver's `Path::join` sees. Beyond the URL-encoding hazard, \
4057         `%` is the C / POSIX printf format-directive lead-in (`%s`, `%d`, `%02x` — \
4058         wired into every POSIX shell's `printf` builtin, the canonical CWE-134 format-\
4059         string-injection vector); the bash / zsh / ksh job-control-specifier lead-in \
4060         (`%1` names \"job 1\", `%%` names \"the current job\", `%foo` names \"the most \
4061         recent job whose command started with `foo`\" — a future `kill %1` invocation \
4062         silently redirects the signal to a wrong target); the YAML 1.2 §6.8.1 \
4063         directive lead-in (`%YAML 1.2` / `%TAG` — the paste-from-top-of-doc YAML \
4064         directive block cross-idiom leak); and the Windows-shell env-var-reference \
4065         lead-in (`%PATH%` — the paste-from-`.bat` / paste-from-PowerShell-`%env:PATH%` \
4066         cross-idiom leak). The lacre pipeline embeds the value verbatim in its per-dep \
4067         content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the \
4068         byte lands in the BLAKE3 closure and rides into every shell-spawned subprocess \
4069         (the resolver's `git clone`, a future `feira tofu` shell-out, a future \
4070         operator-side `nix` spawn) as the canonical URL-percent-encoding-escape / \
4071         printf-format-specifier / job-control-specifier surface every peer single-\
4072         token-shaped typed slot already closes. The peer `:fonte :repo` axis closes \
4073         the byte under the same URL-percent-encoding-escape banner (a323db8 `%` on \
4074         `is_git_repo_url`). Express the path as a bare relative single-token like \
4075         \"../caixa-teia\" — the sibling-workspace directory name carries no URL-\
4076         percent-encoding-escape / format-specifier / job-control semantic; substitute \
4077         any `%20` percent-encoded-space with a literal space then reject the whole \
4078         value at the leading-whitespace / embedded-`?` arm on the same axis (a caixa \
4079         directory name never carries an embedded space in practice); drop any \
4080         `%2F`-encoded path separator in favor of a literal `/`; and drop any leading \
4081         `%YAML` / `%PATH%` cross-idiom-leak prefix entirely.",
4082        ch = *byte as char
4083    )]
4084    FonteCaminhoUrlPercentEncoding {
4085        nome: String,
4086        caminho: String,
4087        byte: u8,
4088    },
4089    #[error(
4090        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4091         variable-expansion / command-substitution / arithmetic-expansion / cross-config-\
4092         DSL-interpolation metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — sh / \
4093         bash / zsh / dash / ksh / busybox ash / fish / nushell — lexes `$` per \
4094         POSIX.1-2017 §2.6 as the variable-expansion `$<name>` / braced-form `${{<name>}}` \
4095         / command-substitution `$(<cmd>)` / arithmetic-expansion `$((<expr>))` operator; \
4096         Nix uses `${{var}}` as the string-interpolation lead, Make uses `$(var)` / `$@` \
4097         / `$<` for variables and automatic-variables, JavaScript / TypeScript template \
4098         literals use `${{expr}}` for interpolation, envsubst / Kubernetes / OpenShift \
4099         templates use `${{VAR}}` for env-var-reference, PHP uses `$_GET` / `$_ENV` for \
4100         superglobals, Perl uses `$foo` for scalars, SASS / SCSS uses `$primary-color` \
4101         for variables, and PostgreSQL / SQLite use `$1` / `$2` for bind parameters — \
4102         the byte is a first-class parser byte in nearly every config / templating / \
4103         build-system DSL the substrate's paste-idiom surface routinely crosses. POSIX \
4104         `std::path::Path` treats the byte as a literal path-component byte, so the \
4105         canonical paste-from-shell-one-liner `:caminho \"../foo$HOME/bar\"` / paste-\
4106         from-CI-manifest `:caminho \"../foo${{WORKSPACE}}/bar\"` / paste-from-shell-\
4107         prompt `:caminho \"../foo$(whoami)/bar\"` footguns silently pass every prior \
4108         cascade arm (`$` isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / \
4109         `?` / `(` / `)` / `{{` / `}}` / `[` / `]` / `'` / `\"` / `#` / `%`) and route \
4110         through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
4111         subdirectory that fails at resolve time with a non-self-locating `No such file \
4112         or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
4113         the value verbatim in its per-dep content-address `path:{caminho}` at \
4114         caixa-resolver/src/resolve.rs:189, so byte-identical caixa.lisp values differing \
4115         only in whether the author substituted `$HOME` / `${{WORKSPACE}}` at author \
4116         time lock to two distinct BLAKE3 closures across two workstations whose \
4117         downstream envsubst / Nix / Make / K8s-template layers differ in `$VAR` \
4118         recognition — defeating the THEORY.md §V.2 render-determinism contract on the \
4119         same axis every prior `:caminho` arm protects. Beyond the determinism vector, \
4120         `$` at any position in a value flowing verbatim into a shell-spawned subprocess \
4121         is the canonical CWE-78 shell-command-injection surface every peer single-\
4122         token-shaped typed slot already closes: peer `:fonte :repo` axis rejects `$` \
4123         under the shell-variable-expansion / URL-sub-delim banner via `is_git_repo_url` \
4124         (b9d187c), peer `:fonte :tag` / `:fonte :branch` axes reject `$` as part of \
4125         `is_git_ref_name`'s printable-ASCII-restricted grammar (`git check-ref-format` \
4126         rejects the byte outright), and peer `:entrada :paths` axis rejects `$` via \
4127         `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. The leading-`$` \
4128         position on the same axis routes through `FonteCaminhoVarExpansion` at the \
4129         f4efe9c leading-byte arm; this arm closes the last positional gap on the byte \
4130         so every position — leading and embedded — is structurally rejected. Substitute \
4131         the `$VAR` / `${{VAR}}` / `$(cmd)` template with the literal value at author \
4132         time, or express the path as a bare relative single-token like \
4133         \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
4134         variable-expansion / command-substitution / arithmetic-expansion semantic.",
4135        ch = *byte as char
4136    )]
4137    FonteCaminhoShellVariableExpansion {
4138        nome: String,
4139        caminho: String,
4140        byte: u8,
4141    },
4142    #[error(
4143        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4144         history-expansion / RFC-3986-sub-delims / bang-operator metacharacter 0x{byte:02x} \
4145         `{ch}` (every interactive POSIX shell with history enabled — bash / ksh / zsh's \
4146         `bashcompat` / csh / tcsh — lexes `!` as the history-expansion prefix per bash \
4147         reference §9.3: `!command` re-runs the most recent history entry beginning with \
4148         `command`, `!!` re-runs the prior command verbatim, `!$` substitutes the last \
4149         word of the prior command, `!:N` substitutes the Nth word of the prior command, \
4150         and the substitution fires at every history-expansion-enabled shell context — \
4151         `set -o histexpand` is bash's default for interactive sessions and the layer \
4152         every `feira tofu` / `git clone` / `nix flake check` subprocess-argument \
4153         invocation crosses when spawned under `bash -i`. Beyond shell history, RFC 3986 \
4154         §2.2 lists `!` in the `sub-delims` set (the URL grammar admits the byte inside \
4155         a path segment, but every WHATWG-conformant special-scheme URL parser percent-\
4156         encodes it inside a query component via the 'special-query percent-encode set' \
4157         the peer `is_git_repo_url` `*` / `(` / `)` / `'` arms close on); the byte is \
4158         also the C / C++ / Rust / JavaScript / Python bang-operator (logical-negation \
4159         prefix — the paste-from-source-code idiom where an author copies \
4160         `!path.exists()` out of a Rust snippet and the trailing punctuation crosses \
4161         the string-literal boundary); the canonical English-typography emphasis / \
4162         exclamation mark (the paste-from-prose enthusiasm-form idiom where an author \
4163         writes `:caminho \"../caixa-teia!\"` expecting the substrate to coerce it to a \
4164         kebab-case slug); and the Nix flake-ref attribute-selection operator surface. \
4165         POSIX `std::path::Path` treats `!` as a literal path-component byte, so the \
4166         canonical paste-from-shell-history footgun `:caminho \"../caixa-teia!sudo\"` \
4167         (an author copies a `cd ../caixa-teia && !sudo make install` one-liner from a \
4168         quick-start README and the trailing `!sudo` rides in verbatim as a history-\
4169         expansion reference), the symmetric `:caminho \"../foo!!/bar\"` (the `!!` \
4170         repeat-prior-command paste idiom), the English-typography `:caminho \
4171         \"../caixa-teia!\"` (paste-from-prose enthusiasm-form), and the last-word-\
4172         substitution `:caminho \"../foo!$\"` shape silently pass every prior cascade \
4173         arm (`!` isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / `?` / `(` \
4174         / `)` / `{{` / `}}` / `[` / `]` / `'` / `\"` / `#` / `%` / `$`) and route \
4175         through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
4176         subdirectory that fails at resolve time with a non-self-locating `No such file \
4177         or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
4178         the value verbatim in its per-dep content-address `path:{caminho}` at \
4179         caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
4180         rides into every shell-spawned subprocess (the resolver's `git clone`, a \
4181         future `feira tofu` shell-out, a future operator-side `nix flake check` spawn) \
4182         as the canonical shell-history-expansion / RFC-3986-sub-delims surface every \
4183         peer single-token-shaped typed slot already closes. The peer `:fonte :repo` \
4184         axis closes the byte under the same shell-history-expansion / RFC-3986-sub-\
4185         delims banner (7d53c68 `!` on `is_git_repo_url`). Express the path as a bare \
4186         relative single-token like \"../caixa-teia\" — the sibling-workspace directory \
4187         name carries no shell-history-expansion / bang-operator semantic; drop any \
4188         `!sudo` / `!!` / `!$` history-expansion trailing paste-from-shell-history \
4189         idiom; and drop any trailing English-typography exclamation mark that pasted \
4190         from prose.",
4191        ch = *byte as char
4192    )]
4193    FonteCaminhoShellHistoryExpansion {
4194        nome: String,
4195        caminho: String,
4196        byte: u8,
4197    },
4198    #[error(
4199        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4200         history-substitution / RFC-3986-'unwise' / regex-negation metacharacter 0x{byte:02x} \
4201         `{ch}` (POSIX bash's `set -o histexpand` mode — the default for every interactive \
4202         session and every `bash -i` subprocess-argument context `feira tofu` / `git clone` / \
4203         `nix flake check` cross — lexes `^old^new^` per bash reference §9.3 as the 'quick \
4204         substitution' history operator that rewrites the prior command's `old` string to \
4205         `new` and re-executes it verbatim, the canonical typo-correction one-liner idiom \
4206         (`git clone <bad-url>` → `^bad^good` typo-fix-and-rerun the paste-from-shell-\
4207         history author trims only the leading `git clone` prefix from). RFC 3986 §2 lists \
4208         `^` in the 'unwise' set every URL parser is required to percent-encode-or-refuse at \
4209         the wire boundary, and the WHATWG URL spec's 'fragment percent-encode set' maps \
4210         `^` → `%5E` at the query / fragment component transition, so `Path::join` on the \
4211         literal value diverges from every downstream `feira tofu` curl-invocation / \
4212         artifact-registry-fetch that percent-encodes the byte before the wire. `^` is also \
4213         the regex character-class negation prefix (`[^abc]`), the bitwise XOR operator in \
4214         C / C++ / Rust / Python / JavaScript / Nix / Go, the Windows `cmd.exe` escape \
4215         metacharacter, and the LaTeX / Markdown / BibTeX superscript operator. POSIX \
4216         `std::path::Path` treats `^` as a literal path-component byte, so \
4217         `:caminho \"../foo^bar/baz\"` (embedded quick-substitution), `:caminho \
4218         \"../foo^\"` (trailing history-substitution-open shape), or `:caminho \"../x^y\"` \
4219         (XOR-expression paste-from-source) silently pass every prior cascade arm (`^` \
4220         isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / `?` / `(` / `)` / `{{` \
4221         / `}}` / `[` / `]` / `'` / `\"` / `#` / `%` / `$` / `!`) and route through \
4222         `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` subdirectory \
4223         that fails at resolve time with a non-self-locating `No such file or directory` \
4224         error far from the source caixa.lisp. The lacre pipeline embeds the value verbatim \
4225         in its per-dep content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, \
4226         so the byte lands in the BLAKE3 closure and rides into every shell-spawned \
4227         subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a future \
4228         operator-side `nix flake check` spawn) as the canonical shell-history-substitution \
4229         / RFC-3986-unwise surface every peer single-token-shaped typed slot already closes. \
4230         The peer `:fonte :repo` axis closes the byte under the same shell-history-\
4231         substitution / RFC-3986-unwise banner (49e142f `^` on `is_git_repo_url`). Together \
4232         with the immediate-predecessor `!` arm (6a04767) this arm closes the full `set -o \
4233         histexpand` operator surface on the `:caminho` axis — the `!command` / `!!` / `!$` \
4234         prefix form via `!`, the `^old^new^` quick-substitution form via `^`. Express the \
4235         path as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
4236         directory name carries no shell-history-substitution / regex-negation / XOR-operator \
4237         semantic; drop any `^old^new` history-substitution paste-from-shell-history idiom; \
4238         drop any trailing `^` history-substitution-open fragment.",
4239        ch = *byte as char
4240    )]
4241    FonteCaminhoShellHistorySubstitution {
4242        nome: String,
4243        caminho: String,
4244        byte: u8,
4245    },
4246    #[error(
4247        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} has a trailing \
4248         `/` (the resolver's `Path::join` resolves `\"../caixa-teia\"` and \
4249         `\"../caixa-teia/\"` to the same directory, but the lacre pipeline embeds the \
4250         value verbatim in its per-dep content-address `path:{caminho}` at \
4251         caixa-resolver/src/resolve.rs:189, so two authors whose only difference is \
4252         shell tab-completion emit byte-divergent BLAKE3 closures for the same caixa — \
4253         defeating the THEORY.md §V.2 render-determinism contract via the trailing-\
4254         separator vector (the canonical paste-from-shell-tab-completion + paste-from-\
4255         `pwd`-with-`/`-suffix footgun, and the canonical Cargo-style `path = \
4256         \"../caixa-teia/\"` paste-from-Cargo-manifest cross-idiom leak). Drop the \
4257         trailing `/`; every `:caminho` value names a sibling-workspace directory \
4258         already, so the trailing separator carries no information. Use \
4259         `\"../caixa-teia\"` rather than `\"../caixa-teia/\"`)"
4260    )]
4261    FonteCaminhoTrailingSlash { nome: String, caminho: String },
4262    #[error(
4263        "{list} carries duplicate entry :nome {nome:?} — every dep list keys its \
4264         entries by caixa name (Cargo's [dependencies] / [dev-dependencies] tables \
4265         apply the same set-not-multiset discipline; one package per table), and \
4266         two entries naming the same caixa carry two version constraints / source \
4267         pins / feature sets for one identity. The caixa-resolver's lacre pipeline \
4268         consumes the list as a `HashMap`-keyed-by-`:nome` lookup: the second entry \
4269         silently overwrites the first at the resolver-side `concrete_versao` step, \
4270         and the dropped entry's pin / features never reach the closure — far from \
4271         the source caixa.lisp, with no field naming which `:deps` entry was the \
4272         silent loser. If two version constraints are genuinely needed (the rare \
4273         multi-version closure case the lacre pipeline doesn't yet support), the \
4274         author surface is two distinct caixa names (e.g. a `caixa-teia-v01` / \
4275         `caixa-teia-v02` aliased pair); within one list, one entry per caixa name."
4276    )]
4277    DuplicateNome { nome: String, list: &'static str },
4278    #[error(
4279        ":deps entry {nome:?} has empty :caracteristicas entry — every feature flag must \
4280         name a non-empty identifier on the target caixa (Cargo's [dependencies.<dep>.features] \
4281         applies the same per-entry non-empty discipline). An empty feature flag reaches the \
4282         caixa-resolver's lacre pipeline as a no-op feature enable, silently dropping the \
4283         author's intent far from the source caixa.lisp; drop the empty entry, or replace it \
4284         with the canonical kebab-case feature name the target caixa declares."
4285    )]
4286    CaracteristicaEmpty { nome: String },
4287    #[error(
4288        ":deps entry {nome:?} :caracteristicas entry {caracteristica:?} is not a valid Cargo \
4289         feature name: {reason} (the value flows verbatim into Cargo's \
4290         [dependencies.<dep>.features] list and Cargo's `restricted_names::validate_feature_name` \
4291         parser enforces the same shape at `cargo metadata` time; use a single-token \
4292         identifier like `\"http\"`, `\"derive\"`, or `\"runtime-tokio\"` — kebab-case ASCII \
4293         alphanumeric with `-`, `_`, `+`, or `.` as continuation characters, starting with \
4294         an ASCII alphanumeric or `_`)"
4295    )]
4296    CaracteristicaInvalid {
4297        nome: String,
4298        caracteristica: String,
4299        reason: String,
4300    },
4301    #[error(
4302        ":deps entry {nome:?} :caracteristicas carries duplicate feature {caracteristica:?} — \
4303         every feature-flag list keys its entries by name (Cargo's \
4304         [dependencies.<dep>.features] applies the same set-not-multiset discipline; one entry \
4305         per feature per dep), and two entries naming the same feature are a redundant \
4306         set-membership declaration for one identity (the feature-toggle slot is set-shaped; \
4307         enabling a feature twice has no additional semantic). The caixa-resolver's lacre \
4308         pipeline consumes the list as a set-shaped feature toggle — the resolver enables the \
4309         feature once regardless of declaration count, so the duplicate's pin / position never \
4310         reaches the closure with no field naming the silent loser. One entry per feature per \
4311         dep; if two distinct features are intended, name each verbatim."
4312    )]
4313    CaracteristicaDuplicate {
4314        nome: String,
4315        caracteristica: String,
4316    },
4317    #[error(
4318        "{list} entry :nome {nome:?} names the caixa itself — a caixa cannot depend \
4319         on itself (the lacre closure's dep-graph traversal is rooted at the caixa's \
4320         :nome, and a self-dep would be a one-node cycle the caixa-resolver either \
4321         rejects mid-traversal far from the source caixa.lisp or recurses on until \
4322         it exhausts its stack). Every :nome is globally-unique substrate identity, \
4323         so a :deps / :deps-dev entry whose :nome equals the parent caixa's :nome \
4324         *is* the parent itself, not a coincidentally-named peer. Drop the \
4325         self-referential dep entry — to reference code from this caixa, use \
4326         :bibliotecas / :exe / :servicos (the substrate-blessed shape for \
4327         referencing the caixa's own code surface) instead."
4328    )]
4329    DepIsSelf { nome: String, list: &'static str },
4330}
4331
4332#[allow(clippy::trivially_copy_pass_by_ref)]
4333fn is_false(b: &bool) -> bool {
4334    !*b
4335}
4336
4337#[cfg(test)]
4338mod tests {
4339    use super::*;
4340
4341    #[test]
4342    fn registry_dep_is_minimal() {
4343        let d = Dep::simple("caixa-teia", "^0.1");
4344        assert_eq!(d.nome, "caixa-teia");
4345        assert_eq!(d.versao, "^0.1");
4346        assert!(d.fonte.is_none());
4347        assert!(!d.opcional());
4348        assert!(d.caracteristicas().is_empty());
4349    }
4350
4351    #[test]
4352    fn git_dep_carries_tag() {
4353        let d = Dep::git("t", "*", "github:o/r", "v1");
4354        match d.fonte {
4355            Some(DepSource::Git {
4356                ref repo, ref tag, ..
4357            }) => {
4358                assert_eq!(repo, "github:o/r");
4359                assert_eq!(tag.as_deref(), Some("v1"));
4360            }
4361            _ => panic!("expected Git source"),
4362        }
4363    }
4364
4365    #[test]
4366    fn validate_accepts_simple_dep() {
4367        Dep::simple("caixa-teia", "^0.1").validate().unwrap();
4368    }
4369
4370    #[test]
4371    fn validate_rejects_empty_nome() {
4372        // The fail-before-pass-after pin for `:nome ""`: the empty-name
4373        // arm fires first so the per-entry parse-side diagnostic doesn't
4374        // emit a useless `nome: ""` reference.
4375        let mut d = Dep::simple("placeholder", "^0.1");
4376        d.nome = String::new();
4377        assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
4378    }
4379
4380    #[test]
4381    fn validate_rejects_empty_versao() {
4382        // `parse_requirement("")` returns `Ok(VersionReq::STAR)` (the
4383        // semver crate accepts the empty string as a wildcard match),
4384        // so the empty-`:versao` arm is structurally necessary even
4385        // with the parse arm in place — mirrors `MembroVersaoEmpty` /
4386        // `EmptyChildVersion` ordering on the other two `:versao` axes.
4387        let mut d = Dep::simple("caixa-teia", "ignored");
4388        d.versao = String::new();
4389        let err = d.validate().unwrap_err();
4390        assert!(
4391            matches!(err, DepError::VersaoEmpty { ref nome } if nome == "caixa-teia"),
4392            "got {err:?}"
4393        );
4394    }
4395
4396    // ── value-shape: DNS-1123 label on :deps :nome ────────────────────────
4397
4398    #[test]
4399    fn validate_rejects_nome_with_uppercase() {
4400        // The fail-before-pass-after pin: a non-empty but uppercase
4401        // `:nome` silently passed `validate()` on every pre-gate
4402        // codebase because the prior shape only refused the empty
4403        // string. The DNS-1123 violation surfaced far downstream at
4404        // lacre-resolve time when the *target* caixa's `:nome` failed
4405        // its own gate — far from the `:deps` entry, with a diagnostic
4406        // naming the target rather than the dep entry that referenced
4407        // it. Same fail-before-pass-after fixture pinned for
4408        // `:membros :caixa` (3f9d7a0), `:children :caixa` (31bfa43),
4409        // and Caixa `:nome` (6c992f8).
4410        let d = Dep::simple("Caixa-Teia", "^0.1");
4411        let err = d.validate().unwrap_err();
4412        assert!(
4413            matches!(
4414                err,
4415                DepError::NomeInvalid { ref nome, ref reason }
4416                    if nome == "Caixa-Teia" && reason.contains("uppercase")
4417            ),
4418            "got {err:?}"
4419        );
4420    }
4421
4422    #[test]
4423    fn validate_rejects_nome_with_underscore() {
4424        // RFC 1123 allows `[a-z0-9-]` only; underscore is the canonical
4425        // "I'm thinking of Go module names / Python identifiers" leak.
4426        // Same fixture pinned for the peer caixa-identifier axes.
4427        let d = Dep::simple("caixa_teia", "^0.1");
4428        let err = d.validate().unwrap_err();
4429        assert!(
4430            matches!(
4431                err,
4432                DepError::NomeInvalid { ref nome, ref reason }
4433                    if nome == "caixa_teia" && reason.contains('_')
4434            ),
4435            "got {err:?}"
4436        );
4437    }
4438
4439    #[test]
4440    fn validate_rejects_nome_with_dot() {
4441        // A `:deps :nome` is a single DNS-1123 *label*, not a
4442        // subdomain — dots are rejected. The `"caixa.teia"` shape is
4443        // the canonical "I confused the dep name with the FQDN /
4444        // namespace" footgun, distinct from the legitimate
4445        // `:fonte :repo "github:org/caixa-teia"` axis.
4446        let d = Dep::simple("caixa.teia", "^0.1");
4447        let err = d.validate().unwrap_err();
4448        assert!(
4449            matches!(
4450                err,
4451                DepError::NomeInvalid { ref nome, ref reason }
4452                    if nome == "caixa.teia" && reason.contains('.')
4453            ),
4454            "got {err:?}"
4455        );
4456    }
4457
4458    #[test]
4459    fn validate_rejects_nome_with_leading_hyphen() {
4460        // RFC 1123 requires alphanumeric at both label boundaries.
4461        // Pinned in parity with the peer DNS-1123 fixtures.
4462        let d = Dep::simple("-caixa-teia", "^0.1");
4463        let err = d.validate().unwrap_err();
4464        assert!(
4465            matches!(
4466                err,
4467                DepError::NomeInvalid { ref nome, ref reason }
4468                    if nome == "-caixa-teia" && reason.contains("alphanumeric")
4469            ),
4470            "got {err:?}"
4471        );
4472    }
4473
4474    #[test]
4475    fn validate_rejects_nome_with_trailing_hyphen() {
4476        let d = Dep::simple("caixa-teia-", "^0.1");
4477        let err = d.validate().unwrap_err();
4478        assert!(
4479            matches!(
4480                err,
4481                DepError::NomeInvalid { ref nome, ref reason }
4482                    if nome == "caixa-teia-" && reason.contains("alphanumeric")
4483            ),
4484            "got {err:?}"
4485        );
4486    }
4487
4488    #[test]
4489    fn validate_rejects_nome_with_slash() {
4490        // The canonical "I copied the GitHub repo path into `:nome`
4491        // instead of `:fonte :repo`" typo. A `/` in the name leaks the
4492        // lacre-side `:repositorio` shape (`pleme-io/caixa-teia`) into
4493        // the local-name slot. Same fixture pinned for `:membros
4494        // :caixa` (3f9d7a0).
4495        let d = Dep::simple("pleme-io/caixa-teia", "^0.1");
4496        let err = d.validate().unwrap_err();
4497        assert!(
4498            matches!(
4499                err,
4500                DepError::NomeInvalid { ref nome, ref reason }
4501                    if nome == "pleme-io/caixa-teia" && reason.contains('/')
4502            ),
4503            "got {err:?}"
4504        );
4505    }
4506
4507    #[test]
4508    fn validate_rejects_nome_too_long() {
4509        // 64-byte label — one over the RFC 1035 / RFC 1123 label cap.
4510        // Built from a valid character set so the length-bound
4511        // diagnostic surfaces before any per-character check (the
4512        // order pin parallel to the per-character predicates inside
4513        // [`crate::render::is_dns_1123_label`]).
4514        let long = "a".repeat(64);
4515        let d = Dep::simple(&long, "^0.1");
4516        let err = d.validate().unwrap_err();
4517        assert!(
4518            matches!(
4519                err,
4520                DepError::NomeInvalid { ref nome, ref reason }
4521                    if nome.len() == 64 && reason.contains("max length of 63")
4522            ),
4523            "got {err:?}"
4524        );
4525    }
4526
4527    #[test]
4528    fn validate_accepts_canonical_nome_labels() {
4529        // Positive-control sweep — every form the K8s apiserver
4530        // accepts as a DNS-1123 label must round-trip through
4531        // validate. Covers a hyphen-bearing label, a numeric-suffix
4532        // label, a leading-digit label, a single-character label, and
4533        // a 63-byte (exactly the cap) label — the same fixture set
4534        // the peer `:membros :caixa` / `:children :caixa` positive
4535        // controls pin.
4536        for nome in [
4537            "caixa-teia",
4538            "caixa-resolver2",
4539            "2nd-tier-cache",
4540            "x",
4541            "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0",
4542        ] {
4543            Dep::simple(nome, "^0.1")
4544                .validate()
4545                .unwrap_or_else(|e| panic!("canonical label {nome:?} must validate, got {e:?}"));
4546        }
4547    }
4548
4549    #[test]
4550    fn nome_empty_takes_precedence_over_nome_invalid() {
4551        // Ordering pin: `NomeEmpty` is the more self-locating
4552        // diagnostic on `""` and must lead — `is_dns_1123_label` is
4553        // only reached after the empty-check fires at the call site.
4554        // Mirrors `membro_caixa_empty_takes_precedence_over_invalid`
4555        // (3f9d7a0) on the peer caixa-identifier axis.
4556        let mut d = Dep::simple("placeholder", "^0.1");
4557        d.nome = String::new();
4558        assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
4559    }
4560
4561    #[test]
4562    fn nome_invalid_fires_before_versao_empty() {
4563        // Ordering pin: a malformed `:nome` fires before any `:versao`
4564        // axis check on the *same* entry — the per-entry shape gates
4565        // run top-to-bottom (nome empty → nome shape → versao empty →
4566        // versao parse → fonte shape), so a one-entry caixa.lisp with
4567        // both wrong sees the name-side diagnostic first (the name is
4568        // the self-locating axis — without a valid name, the parse
4569        // diagnostic can't quote `:nome "<bad>"`). Same ordering
4570        // discipline as `membro_caixa_invalid_fires_before_versao_check`
4571        // (3f9d7a0).
4572        let mut d = Dep::simple("Caixa-Teia", "^0.1");
4573        d.versao = String::new();
4574        let err = d.validate().unwrap_err();
4575        assert!(
4576            matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
4577            "got {err:?}"
4578        );
4579    }
4580
4581    #[test]
4582    fn nome_invalid_fires_before_versao_invalid() {
4583        // Ordering pin: a malformed `:nome` fires before the `:versao`
4584        // parse-side check on the *same* entry. Pin separately from
4585        // the empty-versao ordering so a future re-ordering surfaces
4586        // here, parallel to the b0c8389 / c4213a4 trajectory.
4587        let d = Dep::simple("Caixa-Teia", "^^0.1");
4588        let err = d.validate().unwrap_err();
4589        assert!(
4590            matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
4591            "got {err:?}"
4592        );
4593    }
4594
4595    #[test]
4596    fn nome_invalid_fires_before_fonte_invalid() {
4597        // Ordering pin: a malformed `:nome` fires before the `:fonte`
4598        // shape check on the *same* entry. The `:fonte` diagnostic
4599        // names the offending dep's `:nome` verbatim (via
4600        // `DepSource::validate(&self.nome)`), so a non-self-locating
4601        // name would taint the downstream diagnostic too — the gate
4602        // ordering keeps both diagnostics individually self-locating.
4603        let mut d = Dep::simple("Caixa-Teia", "^0.1");
4604        d.fonte = Some(DepSource::Git {
4605            repo: String::new(),
4606            tag: None,
4607            rev: None,
4608            branch: None,
4609        });
4610        let err = d.validate().unwrap_err();
4611        assert!(
4612            matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
4613            "got {err:?}"
4614        );
4615    }
4616
4617    #[test]
4618    fn nome_invalid_diagnostic_carries_offending_name() {
4619        // The diagnostic-shape pin: the error names the offending
4620        // `:nome` value verbatim so the author can grep their
4621        // caixa.lisp without re-running the build, and carries a
4622        // non-empty `reason` from `is_dns_1123_label` so the
4623        // predicate's own wording flows through to the diagnostic.
4624        // Same shape as `MembroCaixaInvalid` (3f9d7a0),
4625        // `ChildCaixaInvalid` (31bfa43), `ManifestError::NomeInvalid`
4626        // (6c992f8) — the four DNS-1123 caixa-identifier axes now
4627        // share a structurally-equivalent diagnostic family.
4628        let d = Dep::simple("Caixa_Teia", "^0.1");
4629        let err = d.validate().unwrap_err();
4630        let DepError::NomeInvalid { nome, reason } = err else {
4631            panic!("expected NomeInvalid, got other variant");
4632        };
4633        assert_eq!(nome, "Caixa_Teia");
4634        assert!(
4635            !reason.is_empty(),
4636            "NomeInvalid `reason` must carry the predicate's wording verbatim"
4637        );
4638    }
4639
4640    #[test]
4641    fn validate_rejects_invalid_versao_requirement() {
4642        // The fail-before-pass-after pin: a non-empty but malformed
4643        // requirement (`"^bad-version"`) silently passed every pre-gate
4644        // codebase because `:deps :versao` wasn't validated. The parse
4645        // failure surfaced far downstream at lacre-resolve time with a
4646        // `semver::Error` that didn't name which `:deps` entry carried
4647        // the typo. The new gate moves the check to caixa-build time
4648        // at the source caixa.lisp.
4649        let d = Dep::simple("caixa-teia", "^bad-version");
4650        let err = d.validate().unwrap_err();
4651        assert!(
4652            matches!(
4653                err,
4654                DepError::VersaoInvalid { ref nome, ref versao, .. }
4655                    if nome == "caixa-teia" && versao == "^bad-version"
4656            ),
4657            "got {err:?}"
4658        );
4659    }
4660
4661    #[test]
4662    fn validate_rejects_versao_with_double_caret_typo() {
4663        // `"^^0.1"` is the canonical doubled-caret typo — looks like a
4664        // Cargo-shaped requirement on first glance but fails the parser
4665        // because semver doesn't accept stacked operators. Pin this
4666        // adjacent-shape footgun explicitly so a future relaxation that
4667        // accepts "looks-canonical-but-isn't" forms surfaces here, in
4668        // parity with the `:membros` / `:children` fixtures.
4669        let d = Dep::simple("caixa-teia", "^^0.1");
4670        let err = d.validate().unwrap_err();
4671        assert!(
4672            matches!(
4673                err,
4674                DepError::VersaoInvalid { ref nome, ref versao, .. }
4675                    if nome == "caixa-teia" && versao == "^^0.1"
4676            ),
4677            "got {err:?}"
4678        );
4679    }
4680
4681    #[test]
4682    fn validate_rejects_versao_with_v_prefixed_tag() {
4683        // `"v0.1"` is the canonical "git-tag-shape leaking into the
4684        // semver requirement slot" typo — an author copies the
4685        // publish-side git-tag string verbatim into `:versao`, but
4686        // Cargo's semver parser rejects the leading `v`. Same fixture
4687        // pinned for `:membros :versao` (9888b13) and `:children
4688        // :versao` (b38ff3a). (Bare `x`-glob shorthands like `^0.1.x`
4689        // are *accepted* by the semver crate as an `*` wildcard on the
4690        // patch axis — they're a Cargo-side valid shape, not a typo.)
4691        let d = Dep::simple("caixa-teia", "v0.1");
4692        let err = d.validate().unwrap_err();
4693        assert!(
4694            matches!(
4695                err,
4696                DepError::VersaoInvalid { ref nome, ref versao, .. }
4697                    if nome == "caixa-teia" && versao == "v0.1"
4698            ),
4699            "got {err:?}"
4700        );
4701    }
4702
4703    #[test]
4704    fn validate_accepts_canonical_versao_forms() {
4705        // The five Cargo-shaped requirement forms `:membros :versao`
4706        // and `:children :versao` already accept via
4707        // `crate::parse_requirement` must pass the deps gate without
4708        // re-validating at the resolver layer. Pin every leg so a
4709        // future tightening of the canonical set surfaces here as a
4710        // test failure.
4711        for form in [
4712            "^0.1",      // caret — minor-range pin (the most common shape)
4713            "~0.1.2",    // tilde — patch-range pin
4714            "0.1.0",     // exact — single-version pin
4715            "*",         // wildcard — explicitly any-version
4716            ">=0.1, <2", // multi-range — comma-separated comparators
4717        ] {
4718            Dep::simple("caixa-teia", form)
4719                .validate()
4720                .unwrap_or_else(|e| panic!("canonical form {form:?} must validate, got {e:?}"));
4721        }
4722    }
4723
4724    #[test]
4725    fn versao_empty_takes_precedence_over_invalid() {
4726        // Order pin: the existing `VersaoEmpty` diagnostic (which
4727        // doesn't try to parse) fires before the new `VersaoInvalid`
4728        // parse-side diagnostic, so an empty `:versao` keeps its
4729        // narrower error message — `parse_requirement("")` would
4730        // otherwise return `Ok(STAR)` and silently pass, but the empty
4731        // arm catches it first.
4732        let mut d = Dep::simple("caixa-teia", "ignored");
4733        d.versao = String::new();
4734        let err = d.validate().unwrap_err();
4735        assert!(
4736            matches!(err, DepError::VersaoEmpty { ref nome } if nome == "caixa-teia"),
4737            "got {err:?}"
4738        );
4739    }
4740
4741    #[test]
4742    fn nome_empty_takes_precedence_over_versao_invalid() {
4743        // Order pin: even when `:versao` is malformed and would raise
4744        // its own diagnostic, `:nome ""` fires first because the
4745        // per-entry parse diagnostic needs a non-empty name to be
4746        // self-locating. Mirrors the
4747        // `membros_validation_runs_before_contratos_membership_check`
4748        // ordering on the typed-graph layer.
4749        let mut d = Dep::simple("placeholder", "^bad");
4750        d.nome = String::new();
4751        let err = d.validate().unwrap_err();
4752        assert_eq!(err, DepError::NomeEmpty);
4753    }
4754
4755    #[test]
4756    fn versao_invalid_diagnostic_carries_offending_versao() {
4757        // The diagnostic-shape pin: the error names the offending
4758        // `:versao` value verbatim so the author can grep their
4759        // caixa.lisp without re-running the build, and carries a
4760        // non-empty `reason` from `semver::VersionReq::parse` so the
4761        // parser's own wording flows through to the diagnostic.
4762        let d = Dep::simple("caixa-teia", "not-a-req");
4763        let err = d.validate().unwrap_err();
4764        let DepError::VersaoInvalid {
4765            nome,
4766            versao,
4767            reason,
4768        } = err
4769        else {
4770            panic!("expected VersaoInvalid, got other variant");
4771        };
4772        assert_eq!(nome, "caixa-teia");
4773        assert_eq!(versao, "not-a-req");
4774        assert!(
4775            !reason.is_empty(),
4776            "VersaoInvalid `reason` must carry the parser's wording verbatim"
4777        );
4778    }
4779
4780    // -- :fonte value-shape gate ------------------------------------------
4781
4782    fn dep_with_fonte(fonte: DepSource) -> Dep {
4783        let mut d = Dep::simple("caixa-teia", "^0.1");
4784        d.fonte = Some(fonte);
4785        d
4786    }
4787
4788    #[test]
4789    fn validate_accepts_git_fonte_with_tag() {
4790        // The positive-control pin on the canonical git source — exactly
4791        // one of :tag/:rev/:branch set, non-empty :repo. Mirrors the
4792        // shape every existing caixa-resolver integration test uses.
4793        let d = dep_with_fonte(DepSource::Git {
4794            repo: "github:pleme-io/caixa-teia".into(),
4795            tag: Some("v0.1.0".into()),
4796            rev: None,
4797            branch: None,
4798        });
4799        d.validate().unwrap();
4800    }
4801
4802    #[test]
4803    fn validate_accepts_git_fonte_with_rev() {
4804        // Each of the three pin axes is independently a valid single-pin
4805        // shape; pin the :rev arm so a future relaxation that only
4806        // accepts :tag surfaces here. The value is a full 40-hex SHA-1
4807        // OID — the canonical `git rev-parse HEAD` emission shape the
4808        // `crate::render::is_git_oid` value-shape gate now requires;
4809        // abbreviated OIDs are ambiguous across repo history and
4810        // rejected at this gate (pinned separately by
4811        // `validate_rejects_git_fonte_with_rev_abbreviated_prefix`).
4812        let d = dep_with_fonte(DepSource::Git {
4813            repo: "github:pleme-io/caixa-teia".into(),
4814            tag: None,
4815            rev: Some("c0ffee0123abcdef0123456789abcdef01234567".into()),
4816            branch: None,
4817        });
4818        d.validate().unwrap();
4819    }
4820
4821    #[test]
4822    fn validate_accepts_git_fonte_with_branch() {
4823        // The :branch arm is the third valid single-pin shape — pinned
4824        // separately so the gate-accepts-all-three-pin-axes contract is
4825        // a build-error to relax.
4826        let d = dep_with_fonte(DepSource::Git {
4827            repo: "github:pleme-io/caixa-teia".into(),
4828            tag: None,
4829            rev: None,
4830            branch: Some("main".into()),
4831        });
4832        d.validate().unwrap();
4833    }
4834
4835    #[test]
4836    fn validate_accepts_path_fonte() {
4837        // The positive-control pin on the path source — non-empty
4838        // :caminho, no pin axes (paths have no commit identity). Pinned
4839        // so a future "paths must also pin a rev" tightening surfaces
4840        // here as a structural decision, not a silent break.
4841        let d = dep_with_fonte(DepSource::Path {
4842            caminho: "../caixa-teia".into(),
4843        });
4844        d.validate().unwrap();
4845    }
4846
4847    #[test]
4848    fn validate_rejects_git_fonte_with_empty_repo() {
4849        // The fail-before-pass-after pin for `(:tipo git :repo "" :tag
4850        // "v1")`: the empty-repo shape silently passed every pre-gate
4851        // codebase because `:fonte` wasn't validated. The git-clone
4852        // failure surfaced far downstream at lacre-resolve time with no
4853        // field naming which `:deps` entry carried the typo. The new
4854        // gate moves the check to caixa-build time at the source
4855        // caixa.lisp.
4856        let d = dep_with_fonte(DepSource::Git {
4857            repo: String::new(),
4858            tag: Some("v0.1.0".into()),
4859            rev: None,
4860            branch: None,
4861        });
4862        let err = d.validate().unwrap_err();
4863        assert!(
4864            matches!(err, DepError::FonteRepoEmpty { ref nome } if nome == "caixa-teia"),
4865            "got {err:?}"
4866        );
4867    }
4868
4869    // -- :repo value-shape gate -------------------------------------------
4870    //
4871    // The `:fonte (:tipo git :repo …)` value flows verbatim into the
4872    // caixa-resolver's `git clone <repo>` subprocess. The pre-gate
4873    // codebase admitted any non-empty string; the new
4874    // [`crate::render::is_git_repo_url`] predicate gates the git-porcelain
4875    // URL intersection-floor at validate time, peer with the three pin
4876    // axes (`:tag` + `:branch` via `is_git_ref_name`, `:rev` via
4877    // `is_git_oid`). Every test in this section is a fail-before /
4878    // pass-after pin on a specific authoring footgun.
4879
4880    #[test]
4881    fn validate_rejects_git_fonte_with_repo_carrying_trailing_space() {
4882        // The canonical paste-from-doc footgun on `:repo` — an author
4883        // copies `"github:pleme-io/caixa-teia "` (trailing space) out of
4884        // a doc paragraph. Until this gate landed the empty-repo arm
4885        // passed (the string isn't empty), the resolver issued
4886        // `git clone 'github:pleme-io/caixa-teia '`, and the failure
4887        // surfaced at clone time with a quoting-confused error far from
4888        // the source caixa.lisp. Same paste-from-doc footgun the
4889        // `:tag "v0.1.0 "` gate (e70d213) closes on the peer refname
4890        // axis — now closed on the `:repo` URL axis too.
4891        let d = dep_with_fonte(DepSource::Git {
4892            repo: "github:pleme-io/caixa-teia ".into(),
4893            tag: Some("v0.1.0".into()),
4894            rev: None,
4895            branch: None,
4896        });
4897        let err = d.validate().unwrap_err();
4898        let DepError::FonteRepoShape { nome, repo, reason } = err else {
4899            panic!("expected FonteRepoShape, got other variant");
4900        };
4901        assert_eq!(nome, "caixa-teia");
4902        assert_eq!(repo, "github:pleme-io/caixa-teia ");
4903        assert!(
4904            reason.contains("whitespace"),
4905            "reason must surface the whitespace arm, got {reason:?}"
4906        );
4907    }
4908
4909    #[test]
4910    fn validate_rejects_git_fonte_with_repo_starting_with_dash() {
4911        // The canonical CLI-argument-injection footgun at the `git clone`
4912        // subprocess boundary — `:repo "-upload-pack=evil"` makes git's
4913        // argv parser read the value as a CLI flag, escaping the
4914        // subprocess argument boundary. The `--` separator workaround
4915        // does not fix the typed slot's accepted set; the gate rejects
4916        // the shape upstream at validate time so the resolver never
4917        // invokes a `git clone -…` subprocess.
4918        let d = dep_with_fonte(DepSource::Git {
4919            repo: "-upload-pack=evil".into(),
4920            tag: Some("v0.1.0".into()),
4921            rev: None,
4922            branch: None,
4923        });
4924        let err = d.validate().unwrap_err();
4925        let DepError::FonteRepoShape { repo, reason, .. } = err else {
4926            panic!("expected FonteRepoShape, got other variant");
4927        };
4928        assert_eq!(repo, "-upload-pack=evil");
4929        assert!(
4930            reason.contains("must not start with `-`"),
4931            "reason must surface the leading-`-` arm, got {reason:?}"
4932        );
4933    }
4934
4935    #[test]
4936    fn validate_rejects_git_fonte_with_repo_carrying_embedded_newline() {
4937        // The canonical paste-from-multiline-doc footgun — a `:repo`
4938        // string with an embedded `\n` silently breaks git's URL parser
4939        // and is a class of CRLF-injection at the subprocess-argument
4940        // boundary. Caught by the control-char arm (0x0A < 0x20).
4941        let d = dep_with_fonte(DepSource::Git {
4942            repo: "github:pleme-io/caixa-teia\nrm -rf /".into(),
4943            tag: Some("v0.1.0".into()),
4944            rev: None,
4945            branch: None,
4946        });
4947        let err = d.validate().unwrap_err();
4948        let DepError::FonteRepoShape { reason, .. } = err else {
4949            panic!("expected FonteRepoShape, got other variant");
4950        };
4951        assert!(
4952            reason.contains("control character"),
4953            "reason must surface the control-char arm, got {reason:?}"
4954        );
4955    }
4956
4957    #[test]
4958    fn validate_rejects_git_fonte_with_repo_carrying_tab() {
4959        // Tab is the sibling whitespace footgun (the canonical
4960        // copy-from-aligned-table paste); pinned separately from the
4961        // space arm so a future relaxation that only catches one
4962        // surfaces here.
4963        let d = dep_with_fonte(DepSource::Git {
4964            repo: "github:pleme-io/caixa-teia\t".into(),
4965            tag: Some("v0.1.0".into()),
4966            rev: None,
4967            branch: None,
4968        });
4969        let err = d.validate().unwrap_err();
4970        assert!(
4971            matches!(
4972                err,
4973                DepError::FonteRepoShape { ref reason, .. }
4974                    if reason.contains("whitespace")
4975            ),
4976            "got {err:?}"
4977        );
4978    }
4979
4980    #[test]
4981    fn validate_rejects_git_fonte_with_repo_carrying_non_ascii() {
4982        // IDN hosts must be pre-encoded as Punycode (`xn--…`) — raw
4983        // non-ASCII silently breaks at git's URL parser and round-trips
4984        // inconsistently across NFC/NFD normalization on APFS /
4985        // case-folding filesystems. Same intersection-floor
4986        // [`is_git_ref_name`] enforces on the refname axes.
4987        let d = dep_with_fonte(DepSource::Git {
4988            repo: "https://github.com/pleme-io/café".into(),
4989            tag: Some("v0.1.0".into()),
4990            rev: None,
4991            branch: None,
4992        });
4993        let err = d.validate().unwrap_err();
4994        assert!(
4995            matches!(
4996                err,
4997                DepError::FonteRepoShape { ref reason, .. }
4998                    if reason.contains("non-ASCII")
4999            ),
5000            "got {err:?}"
5001        );
5002    }
5003
5004    #[test]
5005    fn validate_rejects_git_fonte_with_repo_carrying_fragment_anchor() {
5006        // The fail-before-pass-after pin for the canonical paste-from-
5007        // browser-address-bar footgun on `:repo`: an author copies a
5008        // GitHub permalink to a README anchor / line-permalink and
5009        // forgets to trim the `#fragment` tail. Until this arm landed
5010        // `:repo "https://github.com/pleme-io/caixa-teia#readme"`
5011        // silently passed every prior arm (no whitespace, no control
5012        // chars, no non-ASCII, contains a `:`, doesn't start with `-`
5013        // or `:`), libcurl's URL parser stripped the `#readme` tail
5014        // before opening the HTTPS transport, and the lacre embedded
5015        // the value verbatim in its per-dep BLAKE3 closure — two
5016        // authors whose values differ only in their fragment anchor
5017        // (`#readme` vs `#L42`) resolve to the byte-identical upstream
5018        // `git clone` but lock to two distinct lacres, defeating the
5019        // THEORY.md §V.2 render-determinism contract. Same value-shape
5020        // axis-floor every peer typed surface enforces; peer `:fonte
5021        // :tag` / `:fonte :branch` already reject the byte-class through
5022        // `is_git_ref_name`'s alphabet (refs are leaf identifiers, no
5023        // URL grammar admitted) and `:entrada :paths` rejects `#` as
5024        // part of `is_gateway_api_http_path`'s RFC-3986-reserved set.
5025        let d = dep_with_fonte(DepSource::Git {
5026            repo: "https://github.com/pleme-io/caixa-teia#readme".into(),
5027            tag: Some("v0.1.0".into()),
5028            rev: None,
5029            branch: None,
5030        });
5031        let err = d.validate().unwrap_err();
5032        let DepError::FonteRepoShape { nome, repo, reason } = err else {
5033            panic!("expected FonteRepoShape, got other variant");
5034        };
5035        assert_eq!(nome, "caixa-teia");
5036        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia#readme");
5037        assert!(
5038            reason.contains("must not contain `#`"),
5039            "reason must surface the fragment-`#` arm, got {reason:?}"
5040        );
5041        assert!(
5042            reason.contains("fragment"),
5043            "reason must name the URL fragment grammar, got {reason:?}"
5044        );
5045    }
5046
5047    #[test]
5048    fn validate_rejects_git_fonte_with_repo_carrying_flake_ref_fragment() {
5049        // The symmetric paste-from-Nix-flake-ref footgun — an author
5050        // confuses the Nix flake-reference idiom (`github:foo/
5051        // bar#packageName`, where `#packageName` selects a flake
5052        // output) with the bare git `:repo` shape. The pleme-io
5053        // substrate authors compose flakes downstream of caixa
5054        // (caixa-flake renders a flake.nix), so the cross-idiom leak
5055        // is the canonical near-miss: the author writes the
5056        // flake-ref shape into a git `:repo` slot. Pinned separately
5057        // from the HTTPS-anchor arm so a future relaxation that
5058        // narrows to one URL scheme surfaces here.
5059        let d = dep_with_fonte(DepSource::Git {
5060            repo: "github:pleme-io/caixa-teia#caixa-teia".into(),
5061            tag: Some("v0.1.0".into()),
5062            rev: None,
5063            branch: None,
5064        });
5065        let err = d.validate().unwrap_err();
5066        let DepError::FonteRepoShape { reason, .. } = err else {
5067            panic!("expected FonteRepoShape, got other variant");
5068        };
5069        assert!(
5070            reason.contains("must not contain `#`"),
5071            "reason must surface the fragment-`#` arm, got {reason:?}"
5072        );
5073        assert!(
5074            reason.contains("Nix flake"),
5075            "reason must name the Nix-flake-ref cross-idiom footgun, got {reason:?}"
5076        );
5077    }
5078
5079    #[test]
5080    fn validate_rejects_git_fonte_with_repo_carrying_query_string() {
5081        // The fail-before-pass-after pin for the canonical paste-from-
5082        // browser-address-bar footgun on `:repo` (peer with the
5083        // a68f818 fragment-`#` arm on the same axis). An author
5084        // copies a GitHub tab deep-link out of the address bar and
5085        // forgets to trim the `?tab=…` query tail. Until this arm
5086        // landed `:repo "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file"`
5087        // silently passed every prior arm (no whitespace, no control
5088        // chars, no non-ASCII, no `#` fragment, contains a `:`,
5089        // doesn't start with `-` or `:`); GitHub silently ignored
5090        // the `?query` tail and served the same repo regardless;
5091        // the lacre embedded the value verbatim in its per-dep
5092        // BLAKE3 closure — two authors whose values differ only in
5093        // their query tail (`?tab=readme-ov-file` vs `?ref=main` vs
5094        // `?utm_source=twitter`) resolve to the byte-identical
5095        // upstream `git clone` but lock to two distinct lacres,
5096        // defeating the THEORY.md §V.2 render-determinism contract
5097        // on the same axis the `#` fragment arm closes. Same value-
5098        // shape axis-floor every peer typed surface enforces; peer
5099        // `:fonte :tag` / `:fonte :branch` already reject the byte-
5100        // class through `is_git_ref_name`'s alphabet (refspec glob
5101        // wildcards, caixa-core/src/render.rs:1426) and `:entrada
5102        // :paths` rejects `?` as the query separator in
5103        // `is_gateway_api_http_path` (caixa-core/src/render.rs:473).
5104        let d = dep_with_fonte(DepSource::Git {
5105            repo: "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file".into(),
5106            tag: Some("v0.1.0".into()),
5107            rev: None,
5108            branch: None,
5109        });
5110        let err = d.validate().unwrap_err();
5111        let DepError::FonteRepoShape { nome, repo, reason } = err else {
5112            panic!("expected FonteRepoShape, got other variant");
5113        };
5114        assert_eq!(nome, "caixa-teia");
5115        assert_eq!(
5116            repo,
5117            "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file"
5118        );
5119        assert!(
5120            reason.contains("must not contain `?`"),
5121            "reason must surface the query-`?` arm, got {reason:?}"
5122        );
5123        assert!(
5124            reason.contains("query"),
5125            "reason must name the URL query grammar, got {reason:?}"
5126        );
5127    }
5128
5129    #[test]
5130    fn validate_rejects_git_fonte_with_repo_carrying_utm_tracker() {
5131        // The symmetric paste-from-social-share footgun — an author
5132        // copies a repo URL out of a Slack unfurl / Twitter share /
5133        // newsletter link / Discord embed and forgets to trim the
5134        // `?utm_source=…` / `?utm_medium=…` / `?utm_campaign=…`
5135        // campaign-tracker tail. Every major social-share / unfurl /
5136        // newsletter platform appends these UTM parameters; the
5137        // canonical near-miss on the `:repo` axis. Pinned separately
5138        // from the GitHub-tab-deep-link arm so a future relaxation
5139        // that narrows to one query-parameter class surfaces here.
5140        let d = dep_with_fonte(DepSource::Git {
5141            repo: "https://github.com/pleme-io/caixa-teia?utm_source=twitter&utm_campaign=launch"
5142                .into(),
5143            tag: Some("v0.1.0".into()),
5144            rev: None,
5145            branch: None,
5146        });
5147        let err = d.validate().unwrap_err();
5148        let DepError::FonteRepoShape { reason, .. } = err else {
5149            panic!("expected FonteRepoShape, got other variant");
5150        };
5151        assert!(
5152            reason.contains("must not contain `?`"),
5153            "reason must surface the query-`?` arm, got {reason:?}"
5154        );
5155        assert!(
5156            reason.contains("campaign-tracker"),
5157            "reason must name the campaign-tracker paste footgun, got {reason:?}"
5158        );
5159    }
5160
5161    #[test]
5162    fn fonte_repo_fragment_fires_before_query_when_fragment_first() {
5163        // Cascade pin: the fragment-`#` arm and the query-`?` arm are
5164        // both per-byte arms inside the same `for &b in s.as_bytes()`
5165        // loop, so the byte that appears first in the value's byte
5166        // order wins. A `:repo "https://github.com/p/x#readme?ref=main"`
5167        // (fragment before query — unusual URL-grammar but value-
5168        // disjoint at byte level) carries both `#` and `?`; the `#`
5169        // byte appears first, so the fragment-`#` arm fires, surfacing
5170        // the more self-locating diagnostic on the byte the author
5171        // pasted earliest in the URL. Mirrors the peer cascade
5172        // discipline `fonte_repo_control_char_fires_before_fragment`
5173        // pins on the prior `:repo` byte-class arm.
5174        let d = dep_with_fonte(DepSource::Git {
5175            repo: "https://github.com/pleme-io/caixa-teia#readme?ref=main".into(),
5176            tag: Some("v0.1.0".into()),
5177            rev: None,
5178            branch: None,
5179        });
5180        let err = d.validate().unwrap_err();
5181        let DepError::FonteRepoShape { reason, .. } = err else {
5182            panic!("expected FonteRepoShape, got other variant");
5183        };
5184        assert!(
5185            reason.contains("must not contain `#`"),
5186            "reason must surface the fragment-`#` arm (fires before query-`?` when \
5187             `#` byte appears first in value), got {reason:?}"
5188        );
5189    }
5190
5191    #[test]
5192    fn fonte_repo_control_char_fires_before_fragment() {
5193        // Cascade pin: the control-char arm structurally precedes the
5194        // fragment-`#` arm. A value like `"github:p/x\n#readme"` probes
5195        // positive on both arms (contains LF and `#`), but the narrower
5196        // POSIX-syscall-rejected / CRLF-injection-class diagnostic
5197        // (`control character`) wins so the author sees the more
5198        // self-locating arm first. Mirrors the peer cascade discipline
5199        // every prior `:repo` byte-class arm establishes.
5200        let d = dep_with_fonte(DepSource::Git {
5201            repo: "github:pleme-io/caixa-teia\n#readme".into(),
5202            tag: Some("v0.1.0".into()),
5203            rev: None,
5204            branch: None,
5205        });
5206        let err = d.validate().unwrap_err();
5207        let DepError::FonteRepoShape { reason, .. } = err else {
5208            panic!("expected FonteRepoShape, got other variant");
5209        };
5210        assert!(
5211            reason.contains("control character"),
5212            "reason must surface the control-char arm, got {reason:?}"
5213        );
5214    }
5215
5216    #[test]
5217    fn validate_rejects_git_fonte_with_repo_carrying_embedded_backslash() {
5218        // The fail-before-pass-after pin for the canonical Windows-
5219        // file-path-confusion footgun on `:repo` (peer with the 3a4e1d7
5220        // backslash arm on the sibling `:caminho` path-fonte axis).
5221        // An author pastes a Windows Explorer address-bar / PowerShell
5222        // `Get-Location` output into a `file://` URL slot, producing
5223        // `file:///C:\Users\me\caixa-teia`. Until this arm landed the
5224        // value silently passed every prior arm (no whitespace, no
5225        // control chars, no non-ASCII, no `#`, no `?`, doesn't start
5226        // with `-` or `:`); libcurl's URL parser silently translates
5227        // `\` → `/` on some platforms and refuses it on others, so
5228        // the byte rides verbatim into the lacre's per-dep content-
5229        // address but is silently rewritten / rejected at the wire —
5230        // two authors whose `:repo` values differ only in backslash-
5231        // vs-forward-slash (`file:///C:\path` vs `file:///C:/path`)
5232        // resolve to the byte-identical local clone but lock to two
5233        // distinct BLAKE3 closures, defeating the THEORY.md §V.2
5234        // render-determinism contract on the same axis the `#`
5235        // fragment and `?` query arms close. Same value-shape axis-
5236        // floor every peer typed surface enforces; the `:caminho`
5237        // 3a4e1d7 arm closes the same byte on the path-fonte axis.
5238        let d = dep_with_fonte(DepSource::Git {
5239            repo: "file:///C:\\Users\\me\\caixa-teia".into(),
5240            tag: Some("v0.1.0".into()),
5241            rev: None,
5242            branch: None,
5243        });
5244        let err = d.validate().unwrap_err();
5245        let DepError::FonteRepoShape { nome, repo, reason } = err else {
5246            panic!("expected FonteRepoShape, got other variant");
5247        };
5248        assert_eq!(nome, "caixa-teia");
5249        assert_eq!(repo, "file:///C:\\Users\\me\\caixa-teia");
5250        assert!(
5251            reason.contains("must not contain `\\`"),
5252            "reason must surface the backslash-`\\` arm, got {reason:?}"
5253        );
5254        assert!(
5255            reason.contains("Windows"),
5256            "reason must name the Windows-path-confusion footgun, got {reason:?}"
5257        );
5258    }
5259
5260    #[test]
5261    fn validate_rejects_git_fonte_with_repo_carrying_mangled_https_backslashes() {
5262        // The symmetric Win32-shell-mangled-slashes footgun — an author
5263        // copies `https://github.com/foo/bar` into a Win32 shell that
5264        // rewrites every `/` to `\` (the canonical `cmd.exe` path-
5265        // separator-coercion bug), pastes the result into a `:repo`
5266        // slot, and produces `https:\\github.com\foo\bar`. Pinned
5267        // separately from the `file://` Explorer-paste arm so a future
5268        // relaxation that narrows to one URL scheme surfaces here.
5269        let d = dep_with_fonte(DepSource::Git {
5270            repo: "https:\\\\github.com\\pleme-io\\caixa-teia".into(),
5271            tag: Some("v0.1.0".into()),
5272            rev: None,
5273            branch: None,
5274        });
5275        let err = d.validate().unwrap_err();
5276        let DepError::FonteRepoShape { reason, .. } = err else {
5277            panic!("expected FonteRepoShape, got other variant");
5278        };
5279        assert!(
5280            reason.contains("must not contain `\\`"),
5281            "reason must surface the backslash-`\\` arm, got {reason:?}"
5282        );
5283        assert!(
5284            reason.contains("path separator") || reason.contains("path-segment separator"),
5285            "reason must name the URL path-segment separator grammar, got {reason:?}"
5286        );
5287    }
5288
5289    #[test]
5290    fn fonte_repo_fragment_fires_before_backslash_when_fragment_first() {
5291        // Cascade pin: the fragment-`#` arm and the backslash-`\` arm
5292        // are both per-byte arms inside the same `for &b in s.as_bytes()`
5293        // loop, so the byte that appears first in the value's byte order
5294        // wins. A `:repo "https://github.com/p/x#readme\\foo"` carries
5295        // both `#` and `\`; the `#` byte appears first, so the fragment-
5296        // `#` arm fires, surfacing the more self-locating diagnostic on
5297        // the byte the author pasted earliest in the URL. Mirrors the
5298        // peer cascade discipline `fonte_repo_fragment_fires_before_query_when_fragment_first`
5299        // pins on the prior `:repo` byte-class arm.
5300        let d = dep_with_fonte(DepSource::Git {
5301            repo: "https://github.com/pleme-io/caixa-teia#readme\\foo".into(),
5302            tag: Some("v0.1.0".into()),
5303            rev: None,
5304            branch: None,
5305        });
5306        let err = d.validate().unwrap_err();
5307        let DepError::FonteRepoShape { reason, .. } = err else {
5308            panic!("expected FonteRepoShape, got other variant");
5309        };
5310        assert!(
5311            reason.contains("must not contain `#`"),
5312            "reason must surface the fragment-`#` arm (fires before backslash-`\\` when \
5313             `#` byte appears first in value), got {reason:?}"
5314        );
5315    }
5316
5317    #[test]
5318    fn validate_rejects_git_fonte_with_repo_carrying_uri_template_placeholder() {
5319        // The fail-before-pass-after pin for the canonical URI Template
5320        // (RFC 6570) placeholder footgun on `:repo`. An author copies a
5321        // README quick-start snippet / OpenAPI `servers:` URL / Helm
5322        // chart `home:` template that carries unresolved
5323        // `{org}` / `{repo}` placeholders and pastes the raw template
5324        // into the `:repo` slot, expecting the substrate to resolve the
5325        // placeholder downstream. Until this arm landed the value
5326        // silently passed every prior arm (no whitespace, no control
5327        // chars, no non-ASCII, no `#`, no `?`, no `\`, doesn't start
5328        // with `-` or `:`); libcurl percent-encodes `{` / `}` to `%7B`
5329        // / `%7D` on the wire, so the byte rides verbatim into the
5330        // lacre's per-dep content-address but round-trips inconsistently
5331        // between the lacre's per-dep content-address and the
5332        // resolver's `git clone <repo>` invocation, defeating the
5333        // THEORY.md §V.2 render-determinism contract on the same axis
5334        // the `#` fragment, `?` query, and `\` backslash arms close;
5335        // every git porcelain entry-point additionally fetches a
5336        // nonexistent literal-`{placeholder}`-named path far from the
5337        // source caixa.lisp.
5338        let d = dep_with_fonte(DepSource::Git {
5339            repo: "https://github.com/{org}/caixa-teia".into(),
5340            tag: Some("v0.1.0".into()),
5341            rev: None,
5342            branch: None,
5343        });
5344        let err = d.validate().unwrap_err();
5345        let DepError::FonteRepoShape { nome, repo, reason } = err else {
5346            panic!("expected FonteRepoShape, got other variant");
5347        };
5348        assert_eq!(nome, "caixa-teia");
5349        assert_eq!(repo, "https://github.com/{org}/caixa-teia");
5350        assert!(
5351            reason.contains("must not contain `{`"),
5352            "reason must surface the open-brace `{{` arm, got {reason:?}"
5353        );
5354        assert!(
5355            reason.contains("URI Template") || reason.contains("RFC 6570"),
5356            "reason must name the RFC 6570 URI Template grammar, got {reason:?}"
5357        );
5358    }
5359
5360    #[test]
5361    fn validate_rejects_git_fonte_with_repo_carrying_handlebars_doubled_brace() {
5362        // The symmetric Mustache / Handlebars doubled-brace
5363        // substitution-form footgun every CI / IaC templating engine
5364        // (Argo Workflows, Jinja2, Liquid, Vue / Angular interpolation,
5365        // GitHub Actions `${{ … }}` even though Actions uses `${{`) /
5366        // chart README quick-start snippet emits. Pinned separately
5367        // from the single-`{` `{org}` arm so a future relaxation that
5368        // narrows to one substitution-form surfaces here.
5369        let d = dep_with_fonte(DepSource::Git {
5370            repo: "https://github.com/{{org}}/caixa-teia".into(),
5371            tag: Some("v0.1.0".into()),
5372            rev: None,
5373            branch: None,
5374        });
5375        let err = d.validate().unwrap_err();
5376        let DepError::FonteRepoShape { reason, .. } = err else {
5377            panic!("expected FonteRepoShape, got other variant");
5378        };
5379        assert!(
5380            reason.contains("must not contain `{`"),
5381            "reason must surface the open-brace `{{` arm, got {reason:?}"
5382        );
5383    }
5384
5385    #[test]
5386    fn validate_rejects_git_fonte_with_repo_carrying_closing_brace_only() {
5387        // Asymmetric `}`-only shape — covers the closing-brace-by-
5388        // itself footgun (an author truncated `{org}/{repo}` mid-edit
5389        // and left a trailing `}` from the prior template fragment,
5390        // or pasted a value that included a closing brace from a
5391        // surrounding shell context). Pinned to ensure the predicate
5392        // refuses each brace independently rather than only when both
5393        // appear — a future regression that ANDs the two byte tests
5394        // surfaces here.
5395        let d = dep_with_fonte(DepSource::Git {
5396            repo: "https://github.com/pleme-io/caixa-teia}".into(),
5397            tag: Some("v0.1.0".into()),
5398            rev: None,
5399            branch: None,
5400        });
5401        let err = d.validate().unwrap_err();
5402        let DepError::FonteRepoShape { reason, .. } = err else {
5403            panic!("expected FonteRepoShape, got other variant");
5404        };
5405        assert!(
5406            reason.contains("must not contain `}`"),
5407            "reason must surface the close-brace `}}` arm, got {reason:?}"
5408        );
5409    }
5410
5411    #[test]
5412    fn fonte_repo_fragment_fires_before_template_placeholder_when_fragment_first() {
5413        // Cascade pin: the fragment-`#` arm and the template-`{` /
5414        // `}` arm are both per-byte arms inside the same
5415        // `for &b in s.as_bytes()` loop, so the byte that appears
5416        // first in the value's byte order wins. A `:repo
5417        // "https://github.com/p/x#readme{org}"` carries both `#` and
5418        // `{`; the `#` byte appears first, so the fragment-`#` arm
5419        // fires, surfacing the more self-locating diagnostic on the
5420        // byte the author pasted earliest in the URL. Mirrors the
5421        // peer cascade discipline `fonte_repo_fragment_fires_before_backslash_when_fragment_first`
5422        // pins on the prior `:repo` byte-class arm.
5423        let d = dep_with_fonte(DepSource::Git {
5424            repo: "https://github.com/pleme-io/caixa-teia#readme{org}".into(),
5425            tag: Some("v0.1.0".into()),
5426            rev: None,
5427            branch: None,
5428        });
5429        let err = d.validate().unwrap_err();
5430        let DepError::FonteRepoShape { reason, .. } = err else {
5431            panic!("expected FonteRepoShape, got other variant");
5432        };
5433        assert!(
5434            reason.contains("must not contain `#`"),
5435            "reason must surface the fragment-`#` arm (fires before template-`{{` when \
5436             `#` byte appears first in value), got {reason:?}"
5437        );
5438    }
5439
5440    #[test]
5441    fn validate_rejects_git_fonte_with_repo_carrying_output_redirection() {
5442        // The fail-before-pass-after pin for the canonical
5443        // shell-output-redirection footgun on `:repo`: an author
5444        // pastes a shell-pipeline tail (`git clone <repo> > build.log`
5445        // / `… >output.txt`) into the `:repo` slot without trimming
5446        // the redirect. Until this arm landed the value silently
5447        // passed every prior arm (no whitespace, no control chars,
5448        // no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, doesn't
5449        // start with `-` or `:`); RFC 3986 §2 lists `<` / `>` in the
5450        // 'delims' / 'unwise' set and the WHATWG URL spec's fragment
5451        // percent-encode set maps `>` → `%3E` on the wire, so the
5452        // byte rides verbatim into the lacre's per-dep BLAKE3 closure
5453        // but is silently rewritten or rejected at libcurl's URL-
5454        // parser layer — two authors whose values differ only in
5455        // their redirect tail (`>build.log` vs nothing) resolve to
5456        // the byte-identical upstream `git clone` but lock to two
5457        // distinct lacres, defeating the THEORY.md §V.2 render-
5458        // determinism contract. Peer with the `:caminho` axis's
5459        // `FonteCaminhoShellRedirection` arm (e457141) on the sibling
5460        // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
5461        // byte RFC-3986-reserved set on `:entrada :paths`.
5462        let d = dep_with_fonte(DepSource::Git {
5463            repo: "https://github.com/pleme-io/caixa-teia>build.log".into(),
5464            tag: Some("v0.1.0".into()),
5465            rev: None,
5466            branch: None,
5467        });
5468        let err = d.validate().unwrap_err();
5469        let DepError::FonteRepoShape { nome, repo, reason } = err else {
5470            panic!("expected FonteRepoShape, got other variant");
5471        };
5472        assert_eq!(nome, "caixa-teia");
5473        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia>build.log");
5474        assert!(
5475            reason.contains("must not contain `>`"),
5476            "reason must surface the output-redirection `>` arm, got {reason:?}"
5477        );
5478        assert!(
5479            reason.contains("redirection") || reason.contains("'delims'"),
5480            "reason must name the shell-redirection / RFC-3986-unwise rationale, got {reason:?}"
5481        );
5482    }
5483
5484    #[test]
5485    fn validate_rejects_git_fonte_with_repo_carrying_input_redirection() {
5486        // The symmetric shell-input-redirection footgun — an author
5487        // pastes a shell-pipeline head (`git clone <input.url` /
5488        // `cat <README.md`) into the `:repo` slot. Pinned separately
5489        // from the `>`-output arm so a future relaxation that only
5490        // catches one of the two redirect bytes surfaces here. Peer
5491        // with the `:caminho` axis's `FonteCaminhoShellRedirection`
5492        // arm which closes both `<` and `>` under the same banner.
5493        let d = dep_with_fonte(DepSource::Git {
5494            repo: "https://github.com/pleme-io/caixa-teia<input.url".into(),
5495            tag: Some("v0.1.0".into()),
5496            rev: None,
5497            branch: None,
5498        });
5499        let err = d.validate().unwrap_err();
5500        let DepError::FonteRepoShape { reason, .. } = err else {
5501            panic!("expected FonteRepoShape, got other variant");
5502        };
5503        assert!(
5504            reason.contains("must not contain `<`"),
5505            "reason must surface the input-redirection `<` arm, got {reason:?}"
5506        );
5507        assert!(
5508            reason.contains("RFC 3986") || reason.contains("'unwise'"),
5509            "reason must name the RFC 3986 'unwise' grammar, got {reason:?}"
5510        );
5511    }
5512
5513    #[test]
5514    fn validate_rejects_git_fonte_with_repo_carrying_backtick_command_substitution() {
5515        // The fail-before-pass-after pin for the canonical
5516        // paste-from-shell-prompt-with-backticked-substitution footgun
5517        // on `:repo` (peer with the c4d62b3 backtick arm on the sibling
5518        // `:caminho` path-fonte axis). An author pastes a URL whose
5519        // segment carries a backticked command-substitution wrapper
5520        // (`` `whoami` ``, `` `git config user.name` ``, `` `pwd` ``)
5521        // from a doc / README quick-start snippet that expected the
5522        // substrate to substitute the value downstream. Until this arm
5523        // landed the value silently passed every prior arm (no
5524        // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
5525        // no `\`, no `{`/`}`, no `<`/`>`, doesn't start with `-` or
5526        // `:`); RFC 3986 §2 lists the backtick byte in the 'delims' /
5527        // 'unwise' set and the WHATWG URL spec's fragment percent-
5528        // encode set maps `` ` `` → `%60` on the wire, so the byte
5529        // rides verbatim into the lacre's per-dep BLAKE3 closure but
5530        // is silently rewritten or rejected at libcurl's URL-parser
5531        // layer — two authors whose values differ only in their
5532        // backtick wrapper (`` `whoami` `` vs nothing) resolve to the
5533        // byte-identical upstream `git clone` but lock to two distinct
5534        // lacres, defeating the THEORY.md §V.2 render-determinism
5535        // contract. Peer with the `:caminho` axis's
5536        // `FonteCaminhoShellCommandSubstitution` arm (c4d62b3) on the
5537        // sibling path-fonte axis, and `is_gateway_api_http_path`'s
5538        // eleven-byte RFC-3986-reserved set on `:entrada :paths`.
5539        let d = dep_with_fonte(DepSource::Git {
5540            repo: "https://github.com/pleme-io/`whoami`/caixa-teia".into(),
5541            tag: Some("v0.1.0".into()),
5542            rev: None,
5543            branch: None,
5544        });
5545        let err = d.validate().unwrap_err();
5546        let DepError::FonteRepoShape { nome, repo, reason } = err else {
5547            panic!("expected FonteRepoShape, got other variant");
5548        };
5549        assert_eq!(nome, "caixa-teia");
5550        assert_eq!(repo, "https://github.com/pleme-io/`whoami`/caixa-teia");
5551        assert!(
5552            reason.contains("must not contain `` ` ``"),
5553            "reason must surface the backtick command-substitution arm, got {reason:?}"
5554        );
5555        assert!(
5556            reason.contains("command-substitution") || reason.contains("'unwise'"),
5557            "reason must name the shell-command-substitution / RFC-3986-unwise rationale, \
5558             got {reason:?}"
5559        );
5560    }
5561
5562    #[test]
5563    fn fonte_repo_fragment_fires_before_backtick_when_fragment_first() {
5564        // Cascade pin: the fragment-`#` arm and the backtick command-
5565        // substitution arm are both per-byte arms inside the same
5566        // `for &b in s.as_bytes()` loop, so the byte that appears first
5567        // in the value's byte order wins. A `:repo
5568        // "https://github.com/p/x#readme/`whoami`"` carries both `#`
5569        // and backtick; the `#` byte appears first, so the fragment-
5570        // `#` arm fires, surfacing the more self-locating diagnostic
5571        // on the byte the author pasted earliest in the URL. Mirrors
5572        // the peer cascade discipline
5573        // `fonte_repo_fragment_fires_before_shell_redirection_when_fragment_first`
5574        // pins on the prior `:repo` byte-class arm.
5575        let d = dep_with_fonte(DepSource::Git {
5576            repo: "https://github.com/pleme-io/caixa-teia#readme/`whoami`".into(),
5577            tag: Some("v0.1.0".into()),
5578            rev: None,
5579            branch: None,
5580        });
5581        let err = d.validate().unwrap_err();
5582        let DepError::FonteRepoShape { reason, .. } = err else {
5583            panic!("expected FonteRepoShape, got other variant");
5584        };
5585        assert!(
5586            reason.contains("must not contain `#`"),
5587            "reason must surface the fragment-`#` arm (fires before backtick when `#` byte \
5588             appears first in value), got {reason:?}"
5589        );
5590    }
5591
5592    #[test]
5593    fn fonte_repo_shell_redirection_fires_before_backtick_when_redirection_first() {
5594        // Cascade pin: the shell-redirection `<` / `>` arm and the
5595        // backtick command-substitution arm are both per-byte arms
5596        // inside the same `for &b in s.as_bytes()` loop, so the byte
5597        // that appears first in the value's byte order wins. A `:repo
5598        // "https://github.com/p/x>build.log/`whoami`"` carries both
5599        // `>` and backtick; the `>` byte appears first, so the
5600        // shell-redirection arm fires, surfacing the more self-
5601        // locating diagnostic on the byte the author pasted earliest
5602        // in the URL. Pins the natural-order cascade so a future
5603        // reorder of the per-byte arms surfaces here.
5604        let d = dep_with_fonte(DepSource::Git {
5605            repo: "https://github.com/pleme-io/caixa-teia>build.log/`whoami`".into(),
5606            tag: Some("v0.1.0".into()),
5607            rev: None,
5608            branch: None,
5609        });
5610        let err = d.validate().unwrap_err();
5611        let DepError::FonteRepoShape { reason, .. } = err else {
5612            panic!("expected FonteRepoShape, got other variant");
5613        };
5614        assert!(
5615            reason.contains("must not contain `>`"),
5616            "reason must surface the shell-redirection `>` arm (fires before backtick when \
5617             `>` byte appears first in value), got {reason:?}"
5618        );
5619    }
5620
5621    #[test]
5622    fn fonte_repo_fragment_fires_before_shell_redirection_when_fragment_first() {
5623        // Cascade pin: the fragment-`#` arm and the shell-redirection
5624        // `<` / `>` arm are both per-byte arms inside the same
5625        // `for &b in s.as_bytes()` loop, so the byte that appears
5626        // first in the value's byte order wins. A `:repo
5627        // "https://github.com/p/x#readme>build.log"` carries both
5628        // `#` and `>`; the `#` byte appears first, so the fragment-
5629        // `#` arm fires, surfacing the more self-locating diagnostic
5630        // on the byte the author pasted earliest in the URL. Mirrors
5631        // the peer cascade discipline
5632        // `fonte_repo_fragment_fires_before_template_placeholder_when_fragment_first`
5633        // pins on the prior `:repo` byte-class arm.
5634        let d = dep_with_fonte(DepSource::Git {
5635            repo: "https://github.com/pleme-io/caixa-teia#readme>build.log".into(),
5636            tag: Some("v0.1.0".into()),
5637            rev: None,
5638            branch: None,
5639        });
5640        let err = d.validate().unwrap_err();
5641        let DepError::FonteRepoShape { reason, .. } = err else {
5642            panic!("expected FonteRepoShape, got other variant");
5643        };
5644        assert!(
5645            reason.contains("must not contain `#`"),
5646            "reason must surface the fragment-`#` arm (fires before shell-redirection `>` when \
5647             `#` byte appears first in value), got {reason:?}"
5648        );
5649    }
5650
5651    #[test]
5652    fn validate_rejects_git_fonte_with_repo_carrying_shell_pipe() {
5653        // The fail-before-pass-after pin for the canonical
5654        // paste-from-shell-prompt-with-piped-pipeline footgun on
5655        // `:repo` (peer with the 124106f pipe arm on the sibling
5656        // `:caminho` path-fonte axis). An author pastes a shell
5657        // pipeline (`git clone <url> | tee build.log`,
5658        // `git ls-remote <url> | head`) into the `:repo` slot,
5659        // forgetting to trim the `| <consumer>` tail. Until this arm
5660        // landed the value silently passed every prior arm (no
5661        // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
5662        // no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, doesn't start
5663        // with `-` or `:`); RFC 3986 §2 lists the pipe byte in the
5664        // 'unwise' set and the WHATWG URL spec's fragment percent-
5665        // encode set maps `|` → `%7C` on the wire, so the byte rides
5666        // verbatim into the lacre's per-dep BLAKE3 closure but is
5667        // silently rewritten or rejected at libcurl's URL-parser
5668        // layer — two authors whose values differ only in their pipe
5669        // tail (`|tee build.log` vs nothing) resolve to the byte-
5670        // identical upstream `git clone` but lock to two distinct
5671        // lacres, defeating the THEORY.md §V.2 render-determinism
5672        // contract. Peer with the `:caminho` axis's
5673        // `FonteCaminhoShellPipe` arm (124106f) on the sibling path-
5674        // fonte axis, and `is_gateway_api_http_path`'s eleven-byte
5675        // RFC-3986-reserved set on `:entrada :paths`.
5676        let d = dep_with_fonte(DepSource::Git {
5677            repo: "https://github.com/pleme-io/caixa-teia|tee build.log".into(),
5678            tag: Some("v0.1.0".into()),
5679            rev: None,
5680            branch: None,
5681        });
5682        let err = d.validate().unwrap_err();
5683        let DepError::FonteRepoShape { nome, repo, reason } = err else {
5684            panic!("expected FonteRepoShape, got other variant");
5685        };
5686        assert_eq!(nome, "caixa-teia");
5687        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia|tee build.log");
5688        assert!(
5689            reason.contains("must not contain `|`"),
5690            "reason must surface the shell-pipe arm, got {reason:?}"
5691        );
5692        assert!(
5693            reason.contains("pipe") || reason.contains("'unwise'"),
5694            "reason must name the shell-pipe / RFC-3986-unwise rationale, got {reason:?}"
5695        );
5696    }
5697
5698    #[test]
5699    fn fonte_repo_fragment_fires_before_pipe_when_fragment_first() {
5700        // Cascade pin: the fragment-`#` arm and the pipe arm are both
5701        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
5702        // so the byte that appears first in the value's byte order
5703        // wins. A `:repo "https://github.com/p/x#readme|tee"` carries
5704        // both `#` and `|`; the `#` byte appears first, so the
5705        // fragment-`#` arm fires, surfacing the more self-locating
5706        // diagnostic on the byte the author pasted earliest in the
5707        // URL. Mirrors the peer cascade discipline
5708        // `fonte_repo_fragment_fires_before_backtick_when_fragment_first`
5709        // pins on the prior `:repo` byte-class arm.
5710        let d = dep_with_fonte(DepSource::Git {
5711            repo: "https://github.com/pleme-io/caixa-teia#readme|tee".into(),
5712            tag: Some("v0.1.0".into()),
5713            rev: None,
5714            branch: None,
5715        });
5716        let err = d.validate().unwrap_err();
5717        let DepError::FonteRepoShape { reason, .. } = err else {
5718            panic!("expected FonteRepoShape, got other variant");
5719        };
5720        assert!(
5721            reason.contains("must not contain `#`"),
5722            "reason must surface the fragment-`#` arm (fires before pipe when `#` byte \
5723             appears first in value), got {reason:?}"
5724        );
5725    }
5726
5727    #[test]
5728    fn fonte_repo_backtick_fires_before_pipe_when_backtick_first() {
5729        // Cascade pin: the backtick arm and the pipe arm are both per-
5730        // byte arms inside the same `for &b in s.as_bytes()` loop, so
5731        // the byte that appears first in the value's byte order wins.
5732        // A `:repo "https://github.com/p/x/`whoami`|tee"` carries both
5733        // `` ` `` and `|`; the backtick byte appears first, so the
5734        // backtick arm fires, surfacing the more self-locating
5735        // diagnostic on the byte the author pasted earliest in the
5736        // URL. Pins the natural-order cascade so a future reorder of
5737        // the per-byte arms surfaces here.
5738        let d = dep_with_fonte(DepSource::Git {
5739            repo: "https://github.com/pleme-io/caixa-teia/`whoami`|tee".into(),
5740            tag: Some("v0.1.0".into()),
5741            rev: None,
5742            branch: None,
5743        });
5744        let err = d.validate().unwrap_err();
5745        let DepError::FonteRepoShape { reason, .. } = err else {
5746            panic!("expected FonteRepoShape, got other variant");
5747        };
5748        assert!(
5749            reason.contains("must not contain `` ` ``"),
5750            "reason must surface the backtick arm (fires before pipe when `` ` `` byte \
5751             appears first in value), got {reason:?}"
5752        );
5753    }
5754
5755    #[test]
5756    fn validate_rejects_git_fonte_with_repo_carrying_shell_command_separator() {
5757        // The fail-before-pass-after pin for the canonical
5758        // paste-from-shell-prompt-with-sequential-command-tail footgun
5759        // on `:repo` (peer with the 05c358e `;` arm on the sibling
5760        // `:caminho` path-fonte axis). An author pastes a shell
5761        // one-liner that chained a cleanup tail after the URL
5762        // (`git clone <url>; rm -rf build`, `git ls-remote <url>;
5763        // echo done`) into the `:repo` slot, forgetting to trim the
5764        // `; <cmd>` tail. Until this arm landed the value silently
5765        // passed every prior `is_git_repo_url` arm (no whitespace, no
5766        // control chars, no non-ASCII, no `#`, no `?`, no `\`, no
5767        // `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, doesn't start with
5768        // `-` or `:`); RFC 3986 §2 lists `;` in the 'sub-delims' /
5769        // reserved set and the WHATWG URL spec's fragment percent-
5770        // encode set maps `;` → `%3B` on the wire, so the byte rides
5771        // verbatim into the lacre's per-dep BLAKE3 closure but is
5772        // silently rewritten at libcurl's URL-parser layer — two
5773        // authors whose values differ only in their sequential-command
5774        // tail (`; rm -rf build` vs nothing) resolve to the byte-
5775        // identical upstream `git clone` but lock to two distinct
5776        // lacres, defeating the THEORY.md §V.2 render-determinism
5777        // contract. Peer with the `:caminho` axis's
5778        // `FonteCaminhoShellSemicolon` arm (05c358e) on the sibling
5779        // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
5780        // byte RFC-3986-reserved set on `:entrada :paths`.
5781        let d = dep_with_fonte(DepSource::Git {
5782            repo: "https://github.com/pleme-io/caixa-teia; rm -rf build".into(),
5783            tag: Some("v0.1.0".into()),
5784            rev: None,
5785            branch: None,
5786        });
5787        let err = d.validate().unwrap_err();
5788        let DepError::FonteRepoShape { nome, repo, reason } = err else {
5789            panic!("expected FonteRepoShape, got other variant");
5790        };
5791        assert_eq!(nome, "caixa-teia");
5792        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia; rm -rf build");
5793        assert!(
5794            reason.contains("must not contain `;`"),
5795            "reason must surface the shell-command-separator arm, got {reason:?}"
5796        );
5797        assert!(
5798            reason.contains("sequential-command") || reason.contains("'sub-delims'"),
5799            "reason must name the shell-command-separator / RFC-3986-sub-delims \
5800             rationale, got {reason:?}"
5801        );
5802    }
5803
5804    #[test]
5805    fn fonte_repo_fragment_fires_before_semicolon_when_fragment_first() {
5806        // Cascade pin: the fragment-`#` arm and the semicolon arm are
5807        // both per-byte arms inside the same `for &b in s.as_bytes()`
5808        // loop, so the byte that appears first in the value's byte
5809        // order wins. A `:repo "https://github.com/p/x#readme; rm"`
5810        // carries both `#` and `;`; the `#` byte appears first, so the
5811        // fragment-`#` arm fires, surfacing the more self-locating
5812        // diagnostic on the byte the author pasted earliest in the URL.
5813        // Mirrors the peer cascade discipline
5814        // `fonte_repo_fragment_fires_before_pipe_when_fragment_first`
5815        // pins on the prior `:repo` byte-class arm.
5816        let d = dep_with_fonte(DepSource::Git {
5817            repo: "https://github.com/pleme-io/caixa-teia#readme; rm".into(),
5818            tag: Some("v0.1.0".into()),
5819            rev: None,
5820            branch: None,
5821        });
5822        let err = d.validate().unwrap_err();
5823        let DepError::FonteRepoShape { reason, .. } = err else {
5824            panic!("expected FonteRepoShape, got other variant");
5825        };
5826        assert!(
5827            reason.contains("must not contain `#`"),
5828            "reason must surface the fragment-`#` arm (fires before semicolon when `#` \
5829             byte appears first in value), got {reason:?}"
5830        );
5831    }
5832
5833    #[test]
5834    fn fonte_repo_pipe_fires_before_semicolon_when_pipe_first() {
5835        // Cascade pin: the pipe arm and the semicolon arm are both
5836        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
5837        // so the byte that appears first in the value's byte order
5838        // wins. A `:repo "https://github.com/p/x|tee; rm"` carries
5839        // both `|` and `;`; the `|` byte appears first, so the
5840        // pipe arm fires, surfacing the more self-locating diagnostic
5841        // on the byte the author pasted earliest in the URL. Pins the
5842        // natural-order cascade so a future reorder of the per-byte
5843        // arms surfaces here.
5844        let d = dep_with_fonte(DepSource::Git {
5845            repo: "https://github.com/pleme-io/caixa-teia|tee; rm".into(),
5846            tag: Some("v0.1.0".into()),
5847            rev: None,
5848            branch: None,
5849        });
5850        let err = d.validate().unwrap_err();
5851        let DepError::FonteRepoShape { reason, .. } = err else {
5852            panic!("expected FonteRepoShape, got other variant");
5853        };
5854        assert!(
5855            reason.contains("must not contain `|`"),
5856            "reason must surface the pipe arm (fires before semicolon when `|` byte \
5857             appears first in value), got {reason:?}"
5858        );
5859    }
5860
5861    #[test]
5862    fn validate_rejects_git_fonte_with_repo_carrying_shell_background() {
5863        // The fail-before-pass-after pin for the canonical
5864        // paste-from-shell-prompt-with-background-launch-tail footgun
5865        // on `:repo` (peer with the e12e4f3 `&` arm on the sibling
5866        // `:caminho` path-fonte axis). An author pastes a shell one-
5867        // liner that detached the clone into the background
5868        // (`git clone <url> & sleep 1`, `git clone <url> && cd …`)
5869        // into the `:repo` slot, forgetting to trim the `& <cmd>` /
5870        // `&& <cmd>` tail. Until this arm landed the value silently
5871        // passed every prior `is_git_repo_url` arm (no whitespace,
5872        // no control chars, no non-ASCII, no `#`, no `?`, no `\`,
5873        // no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no `;`,
5874        // doesn't start with `-` or `:`); RFC 3986 §2 lists `&` in
5875        // the 'sub-delims' / reserved set and the WHATWG URL spec's
5876        // fragment percent-encode set maps `&` → `%26` on the wire,
5877        // so the byte rides verbatim into the lacre's per-dep
5878        // BLAKE3 closure but is silently rewritten at libcurl's
5879        // URL-parser layer — two authors whose values differ only
5880        // in their background-launch tail (`& sleep 1` vs nothing)
5881        // resolve to the byte-identical upstream `git clone` but
5882        // lock to two distinct lacres, defeating the THEORY.md
5883        // §V.2 render-determinism contract. Peer with the
5884        // `:caminho` axis's `FonteCaminhoShellBackground` arm
5885        // (e12e4f3) on the sibling path-fonte axis, and
5886        // `is_gateway_api_http_path`'s eleven-byte RFC-3986-
5887        // reserved set on `:entrada :paths`.
5888        let d = dep_with_fonte(DepSource::Git {
5889            repo: "https://github.com/pleme-io/caixa-teia&sleep".into(),
5890            tag: Some("v0.1.0".into()),
5891            rev: None,
5892            branch: None,
5893        });
5894        let err = d.validate().unwrap_err();
5895        let DepError::FonteRepoShape { nome, repo, reason } = err else {
5896            panic!("expected FonteRepoShape, got other variant");
5897        };
5898        assert_eq!(nome, "caixa-teia");
5899        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia&sleep");
5900        assert!(
5901            reason.contains("must not contain `&`"),
5902            "reason must surface the shell-background / logical-AND arm, got {reason:?}"
5903        );
5904        assert!(
5905            reason.contains("background-task") || reason.contains("'sub-delims'"),
5906            "reason must name the shell-background / RFC-3986-sub-delims rationale, \
5907             got {reason:?}"
5908        );
5909    }
5910
5911    #[test]
5912    fn validate_rejects_git_fonte_with_repo_carrying_logical_and() {
5913        // The fail-before-pass-after pin for the symmetric `&&`
5914        // logical-AND build-chain paste footgun: an author pastes
5915        // a `git clone <url> && cd <repo>` build-chain one-liner
5916        // and forgets to trim the `&& <cmd>` tail. The `&&` shape
5917        // is the same `&` byte twice in a row; the per-byte arm
5918        // fires on the first `&` it sees. Pinned separately from
5919        // the single-`&` background-launch shape so a future
5920        // diagnostic-surface change that special-cased the
5921        // doubled-byte form surfaces here.
5922        let d = dep_with_fonte(DepSource::Git {
5923            repo: "github:pleme-io/caixa-teia&&echo".into(),
5924            tag: Some("v0.1.0".into()),
5925            rev: None,
5926            branch: None,
5927        });
5928        let err = d.validate().unwrap_err();
5929        let DepError::FonteRepoShape { reason, .. } = err else {
5930            panic!("expected FonteRepoShape, got other variant");
5931        };
5932        assert!(
5933            reason.contains("must not contain `&`"),
5934            "reason must surface the shell-background / logical-AND arm on the doubled-`&&` \
5935             shape too, got {reason:?}"
5936        );
5937    }
5938
5939    #[test]
5940    fn fonte_repo_fragment_fires_before_background_when_fragment_first() {
5941        // Cascade pin: the fragment-`#` arm and the background-`&`
5942        // arm are both per-byte arms inside the same `for &b in
5943        // s.as_bytes()` loop, so the byte that appears first in the
5944        // value's byte order wins. A `:repo
5945        // "https://github.com/p/x#readme & sleep"` carries both `#`
5946        // and `&`; the `#` byte appears first, so the fragment-`#`
5947        // arm fires, surfacing the more self-locating diagnostic on
5948        // the byte the author pasted earliest in the URL. Mirrors
5949        // the peer cascade discipline
5950        // `fonte_repo_fragment_fires_before_semicolon_when_fragment_first`
5951        // on the prior `:repo` byte-class arm.
5952        let d = dep_with_fonte(DepSource::Git {
5953            repo: "https://github.com/pleme-io/caixa-teia#readme&sleep".into(),
5954            tag: Some("v0.1.0".into()),
5955            rev: None,
5956            branch: None,
5957        });
5958        let err = d.validate().unwrap_err();
5959        let DepError::FonteRepoShape { reason, .. } = err else {
5960            panic!("expected FonteRepoShape, got other variant");
5961        };
5962        assert!(
5963            reason.contains("must not contain `#`"),
5964            "reason must surface the fragment-`#` arm (fires before background-`&` when `#` \
5965             byte appears first in value), got {reason:?}"
5966        );
5967    }
5968
5969    #[test]
5970    fn fonte_repo_semicolon_fires_before_background_when_semicolon_first() {
5971        // Cascade pin: the semicolon arm and the background-`&` arm
5972        // are both per-byte arms inside the same `for &b in
5973        // s.as_bytes()` loop, so the byte that appears first in the
5974        // value's byte order wins. A `:repo
5975        // "https://github.com/p/x; rm & sleep"` carries both `;` and
5976        // `&`; the `;` byte appears first, so the semicolon arm
5977        // fires, surfacing the more self-locating diagnostic on the
5978        // byte the author pasted earliest in the URL. Pins the
5979        // natural-order cascade so a future reorder of the per-byte
5980        // arms surfaces here.
5981        let d = dep_with_fonte(DepSource::Git {
5982            repo: "https://github.com/pleme-io/caixa-teia;rm&sleep".into(),
5983            tag: Some("v0.1.0".into()),
5984            rev: None,
5985            branch: None,
5986        });
5987        let err = d.validate().unwrap_err();
5988        let DepError::FonteRepoShape { reason, .. } = err else {
5989            panic!("expected FonteRepoShape, got other variant");
5990        };
5991        assert!(
5992            reason.contains("must not contain `;`"),
5993            "reason must surface the semicolon arm (fires before background-`&` when `;` \
5994             byte appears first in value), got {reason:?}"
5995        );
5996    }
5997
5998    #[test]
5999    fn validate_rejects_git_fonte_with_repo_carrying_shell_variable_expansion() {
6000        // The fail-before-pass-after pin for the canonical
6001        // paste-from-shell-prompt-with-unsubstituted-variable footgun
6002        // on `:repo` (peer with the f4efe9c `$` arm on the sibling
6003        // `:caminho` path-fonte axis). An author pastes a shell one-
6004        // liner that referenced an environment variable
6005        // (`git clone https://github.com/$ORG/x`, `git clone
6006        // github:$USER/repo`) into the `:repo` slot, forgetting to
6007        // substitute the literal value at author time. Until this arm
6008        // landed the value silently passed every prior
6009        // `is_git_repo_url` arm (no whitespace, no control chars, no
6010        // non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no `<`/`>`,
6011        // no `` ` ``, no `|`, no `;`, no `&`, doesn't start with `-`
6012        // or `:`); RFC 3986 §2 lists `$` in the 'sub-delims' /
6013        // reserved set and the WHATWG URL spec's fragment percent-
6014        // encode set maps `$` → `%24` on the wire, so the byte rides
6015        // verbatim into the lacre's per-dep BLAKE3 closure but is
6016        // silently rewritten at libcurl's URL-parser layer — two
6017        // authors whose values differ only in their `$VAR` /
6018        // `${VAR}` / `$(cmd)` expansion tail resolve to the byte-
6019        // identical upstream `git clone` but lock to two distinct
6020        // lacres, defeating the THEORY.md §V.2 render-determinism
6021        // contract. Beyond determinism, the value is a structural
6022        // host-layout leak: two authors with the same `:repo` slot
6023        // but different `$ORG` / `$HOME` / `$WORKSPACE` resolve
6024        // different upstreams. Peer with the `:caminho` axis's
6025        // `FonteCaminhoVarExpansion` arm (f4efe9c) on the sibling
6026        // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
6027        // byte RFC-3986-reserved set on `:entrada :paths`.
6028        let d = dep_with_fonte(DepSource::Git {
6029            repo: "https://github.com/$ORG/caixa-teia".into(),
6030            tag: Some("v0.1.0".into()),
6031            rev: None,
6032            branch: None,
6033        });
6034        let err = d.validate().unwrap_err();
6035        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6036            panic!("expected FonteRepoShape, got other variant");
6037        };
6038        assert_eq!(nome, "caixa-teia");
6039        assert_eq!(repo, "https://github.com/$ORG/caixa-teia");
6040        assert!(
6041            reason.contains("must not contain `$`"),
6042            "reason must surface the shell-variable-expansion arm, got {reason:?}"
6043        );
6044        assert!(
6045            reason.contains("variable-expansion") || reason.contains("'sub-delims'"),
6046            "reason must name the shell-variable-expansion / RFC-3986-sub-delims \
6047             rationale, got {reason:?}"
6048        );
6049    }
6050
6051    #[test]
6052    fn validate_rejects_git_fonte_with_repo_carrying_braced_variable_expansion() {
6053        // The fail-before-pass-after pin for the symmetric POSIX-
6054        // shell braced `${VAR}` expansion paste footgun: an author
6055        // pastes a CI-manifest line `git clone
6056        // https://github.com/${WORKSPACE}/x` (the canonical GitHub
6057        // Actions / GitLab CI / Drone shape) and forgets to
6058        // substitute the literal value. The `${...}` shape is the
6059        // same `$` byte at the leading position of the expansion;
6060        // the per-byte arm fires on the `$`. Pinned separately from
6061        // the bare-`$VAR` shape so a future diagnostic-surface
6062        // change that special-cased the braced form surfaces here.
6063        let d = dep_with_fonte(DepSource::Git {
6064            repo: "https://github.com/${WORKSPACE}/caixa-teia".into(),
6065            tag: Some("v0.1.0".into()),
6066            rev: None,
6067            branch: None,
6068        });
6069        let err = d.validate().unwrap_err();
6070        let DepError::FonteRepoShape { reason, .. } = err else {
6071            panic!("expected FonteRepoShape, got other variant");
6072        };
6073        assert!(
6074            reason.contains("must not contain `$`"),
6075            "reason must surface the shell-variable-expansion arm on the braced `${{...}}` \
6076             shape too, got {reason:?}"
6077        );
6078    }
6079
6080    #[test]
6081    fn fonte_repo_fragment_fires_before_var_expansion_when_fragment_first() {
6082        // Cascade pin: the fragment-`#` arm and the var-expansion-`$`
6083        // arm are both per-byte arms inside the same `for &b in
6084        // s.as_bytes()` loop, so the byte that appears first in the
6085        // value's byte order wins. A `:repo
6086        // "https://github.com/p/x#readme$HOME"` carries both `#` and
6087        // `$`; the `#` byte appears first, so the fragment-`#` arm
6088        // fires, surfacing the more self-locating diagnostic on the
6089        // byte the author pasted earliest in the URL. Mirrors the
6090        // peer cascade discipline
6091        // `fonte_repo_fragment_fires_before_background_when_fragment_first`
6092        // on the prior `:repo` byte-class arm.
6093        let d = dep_with_fonte(DepSource::Git {
6094            repo: "https://github.com/pleme-io/caixa-teia#readme$HOME".into(),
6095            tag: Some("v0.1.0".into()),
6096            rev: None,
6097            branch: None,
6098        });
6099        let err = d.validate().unwrap_err();
6100        let DepError::FonteRepoShape { reason, .. } = err else {
6101            panic!("expected FonteRepoShape, got other variant");
6102        };
6103        assert!(
6104            reason.contains("must not contain `#`"),
6105            "reason must surface the fragment-`#` arm (fires before var-expansion-`$` when \
6106             `#` byte appears first in value), got {reason:?}"
6107        );
6108    }
6109
6110    #[test]
6111    fn fonte_repo_background_fires_before_var_expansion_when_background_first() {
6112        // Cascade pin: the background-`&` arm and the
6113        // var-expansion-`$` arm are both per-byte arms inside the
6114        // same `for &b in s.as_bytes()` loop, so the byte that
6115        // appears first in the value's byte order wins. A `:repo
6116        // "https://github.com/p/x&sleep$HOME"` carries both `&` and
6117        // `$`; the `&` byte appears first, so the background arm
6118        // fires, surfacing the more self-locating diagnostic on the
6119        // byte the author pasted earliest in the URL. Pins the
6120        // natural-order cascade so a future reorder of the per-byte
6121        // arms surfaces here — `$` is the most recent byte-class arm,
6122        // so the cascade-pin sweep extends to cover every immediately
6123        // prior byte arm (`#`, `&`) firing first when ordered ahead
6124        // of `$` in the value.
6125        let d = dep_with_fonte(DepSource::Git {
6126            repo: "https://github.com/pleme-io/caixa-teia&sleep$HOME".into(),
6127            tag: Some("v0.1.0".into()),
6128            rev: None,
6129            branch: None,
6130        });
6131        let err = d.validate().unwrap_err();
6132        let DepError::FonteRepoShape { reason, .. } = err else {
6133            panic!("expected FonteRepoShape, got other variant");
6134        };
6135        assert!(
6136            reason.contains("must not contain `&`"),
6137            "reason must surface the background-`&` arm (fires before var-expansion-`$` when \
6138             `&` byte appears first in value), got {reason:?}"
6139        );
6140    }
6141
6142    #[test]
6143    fn validate_rejects_git_fonte_with_repo_carrying_shell_glob_wildcard() {
6144        // The fail-before-pass-after pin for the canonical
6145        // paste-from-shell-prompt glob footgun on `:repo` (peer with
6146        // the cf9034b `*` / `?` arm on the sibling `:caminho`
6147        // path-fonte axis). An author pastes a shell one-liner that
6148        // referenced a glob expansion (`ls
6149        // github.com/pleme-io/caixa-*`, `git clone
6150        // github:pleme-io/caixa-*`) into the `:repo` slot, forgetting
6151        // to substitute the literal repo name. Until this arm landed
6152        // the `*` byte silently passed every prior `is_git_repo_url`
6153        // arm (no whitespace, no control chars, no non-ASCII, no `#`,
6154        // no `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`,
6155        // no `;`, no `&`, no `$`, doesn't start with `-` or `:`); RFC
6156        // 3986 §2 lists `*` in the 'sub-delims' / reserved set and
6157        // the WHATWG URL spec's special-query percent-encode set maps
6158        // `*` → `%2A` on the wire, so the byte rides verbatim into
6159        // the lacre's per-dep BLAKE3 closure but is silently
6160        // rewritten at libcurl's URL-parser layer — two authors
6161        // whose values differ only in their asterisk presence
6162        // resolve to the byte-identical upstream `git clone` but
6163        // lock to two distinct lacres, defeating the THEORY.md §V.2
6164        // render-determinism contract. Peer with the `:caminho`
6165        // axis's `FonteCaminhoShellGlob` arm (cf9034b) on the
6166        // sibling path-fonte axis, and the `is_git_ref_name`
6167        // refspec-wildcard cascade on the `:fonte :tag` / `:branch`
6168        // axes.
6169        let d = dep_with_fonte(DepSource::Git {
6170            repo: "https://github.com/pleme-io/caixa-*".into(),
6171            tag: Some("v0.1.0".into()),
6172            rev: None,
6173            branch: None,
6174        });
6175        let err = d.validate().unwrap_err();
6176        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6177            panic!("expected FonteRepoShape, got other variant");
6178        };
6179        assert_eq!(nome, "caixa-teia");
6180        assert_eq!(repo, "https://github.com/pleme-io/caixa-*");
6181        assert!(
6182            reason.contains("must not contain `*`"),
6183            "reason must surface the shell-glob arm, got {reason:?}"
6184        );
6185        assert!(
6186            reason.contains("pathname-expansion") || reason.contains("'sub-delims'"),
6187            "reason must name the shell-glob / pathname-expansion / \
6188             RFC-3986-sub-delims rationale, got {reason:?}"
6189        );
6190    }
6191
6192    #[test]
6193    fn validate_rejects_git_fonte_with_repo_carrying_recursive_shell_glob() {
6194        // The fail-before-pass-after pin for the symmetric bash
6195        // `globstar` recursive-glob paste footgun: an author pastes
6196        // a `ls github.com/pleme-io/**/x` (the canonical
6197        // `globstar`-shopt-enabled recursive-listing tail) into the
6198        // `:repo` slot. The `**` shape is two `*` bytes adjacent;
6199        // the per-byte arm fires on the first `*`. Pinned
6200        // separately from the single-`*` shape so a future
6201        // diagnostic-surface change that special-cased the
6202        // double-`*` form surfaces here.
6203        let d = dep_with_fonte(DepSource::Git {
6204            repo: "https://github.com/pleme-io/**/caixa-teia".into(),
6205            tag: Some("v0.1.0".into()),
6206            rev: None,
6207            branch: None,
6208        });
6209        let err = d.validate().unwrap_err();
6210        let DepError::FonteRepoShape { reason, .. } = err else {
6211            panic!("expected FonteRepoShape, got other variant");
6212        };
6213        assert!(
6214            reason.contains("must not contain `*`"),
6215            "reason must surface the shell-glob arm on the `**` recursive-glob shape too, \
6216             got {reason:?}"
6217        );
6218    }
6219
6220    #[test]
6221    fn fonte_repo_fragment_fires_before_glob_when_fragment_first() {
6222        // Cascade pin: the fragment-`#` arm and the glob-`*` arm are
6223        // both per-byte arms inside the same `for &b in s.as_bytes()`
6224        // loop, so the byte that appears first in the value's byte
6225        // order wins. A `:repo
6226        // "https://github.com/p/x#readme*tail"` carries both `#` and
6227        // `*`; the `#` byte appears first, so the fragment-`#` arm
6228        // fires, surfacing the more self-locating diagnostic on the
6229        // byte the author pasted earliest in the URL. Mirrors the
6230        // peer cascade discipline
6231        // `fonte_repo_fragment_fires_before_var_expansion_when_fragment_first`
6232        // on the prior `:repo` byte-class arm.
6233        let d = dep_with_fonte(DepSource::Git {
6234            repo: "https://github.com/pleme-io/caixa-teia#readme*tail".into(),
6235            tag: Some("v0.1.0".into()),
6236            rev: None,
6237            branch: None,
6238        });
6239        let err = d.validate().unwrap_err();
6240        let DepError::FonteRepoShape { reason, .. } = err else {
6241            panic!("expected FonteRepoShape, got other variant");
6242        };
6243        assert!(
6244            reason.contains("must not contain `#`"),
6245            "reason must surface the fragment-`#` arm (fires before glob-`*` when `#` byte \
6246             appears first in value), got {reason:?}"
6247        );
6248    }
6249
6250    #[test]
6251    fn fonte_repo_var_expansion_fires_before_glob_when_var_expansion_first() {
6252        // Cascade pin: the var-expansion-`$` arm and the glob-`*`
6253        // arm are both per-byte arms inside the same `for &b in
6254        // s.as_bytes()` loop, so the byte that appears first in the
6255        // value's byte order wins. A `:repo
6256        // "https://github.com/p/$ORG-*"` carries both `$` and `*`;
6257        // the `$` byte appears first, so the var-expansion arm
6258        // fires, surfacing the more self-locating diagnostic on the
6259        // byte the author pasted earliest in the URL. Pins the
6260        // natural-order cascade so a future reorder of the per-byte
6261        // arms surfaces here — `*` is the most recent byte-class
6262        // arm, so the cascade-pin sweep extends to cover the
6263        // immediately prior `$` byte arm firing first when ordered
6264        // ahead of `*` in the value.
6265        let d = dep_with_fonte(DepSource::Git {
6266            repo: "https://github.com/pleme-io/$ORG-caixa-*".into(),
6267            tag: Some("v0.1.0".into()),
6268            rev: None,
6269            branch: None,
6270        });
6271        let err = d.validate().unwrap_err();
6272        let DepError::FonteRepoShape { reason, .. } = err else {
6273            panic!("expected FonteRepoShape, got other variant");
6274        };
6275        assert!(
6276            reason.contains("must not contain `$`"),
6277            "reason must surface the var-expansion-`$` arm (fires before glob-`*` when `$` \
6278             byte appears first in value), got {reason:?}"
6279        );
6280    }
6281
6282    #[test]
6283    fn validate_rejects_git_fonte_with_repo_carrying_subshell_open_paren() {
6284        // The fail-before-pass-after pin for the canonical paste-from-
6285        // shell-prompt subshell-grouping footgun on `:repo`. An author
6286        // pastes a doc / README snippet carrying a regex-alternation
6287        // grouping shape (`https://github.com/(foo|bar)/repo`) or a
6288        // dynamic-config-substitution wrapper (`$(<cmd>)`) into the
6289        // `:repo` slot, forgetting to substitute one literal org name.
6290        // Until this arm landed the `(` byte silently passed every
6291        // prior `is_git_repo_url` arm (no whitespace, no control
6292        // chars, no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no
6293        // `<`/`>`, no `` ` ``, no `|`, no `;`, no `&`, no `$`, no
6294        // `*`, doesn't start with `-` or `:`); RFC 3986 §2 lists `(`
6295        // / `)` in the 'sub-delims' / reserved set, and the WHATWG
6296        // URL spec's special-query percent-encode set maps `(` →
6297        // `%28` and `)` → `%29` on the wire, so the byte rides
6298        // verbatim into the lacre's per-dep BLAKE3 closure but is
6299        // silently rewritten at libcurl's URL-parser layer —
6300        // defeating the THEORY.md §V.2 render-determinism contract on
6301        // the same axis the prior twelve byte-class arms close.
6302        let d = dep_with_fonte(DepSource::Git {
6303            repo: "https://github.com/(foo|bar)/caixa-teia".into(),
6304            tag: Some("v0.1.0".into()),
6305            rev: None,
6306            branch: None,
6307        });
6308        let err = d.validate().unwrap_err();
6309        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6310            panic!("expected FonteRepoShape, got other variant");
6311        };
6312        assert_eq!(nome, "caixa-teia");
6313        assert_eq!(repo, "https://github.com/(foo|bar)/caixa-teia");
6314        assert!(
6315            reason.contains("must not contain `(`"),
6316            "reason must surface the subshell-open-paren arm, got {reason:?}"
6317        );
6318        assert!(
6319            reason.contains("subshell-grouping") || reason.contains("'sub-delims'"),
6320            "reason must name the shell-subshell-grouping / RFC-3986-sub-delims rationale, \
6321             got {reason:?}"
6322        );
6323    }
6324
6325    #[test]
6326    fn validate_rejects_git_fonte_with_repo_carrying_subshell_close_paren() {
6327        // The symmetric arm pin on the closing `)` byte: an author
6328        // pastes a `$(date)` command-substitution wrapper or a
6329        // regex-alternation `(foo|bar)` tail into the `:repo` slot.
6330        // Pinned separately from the opening `(` shape so a future
6331        // diagnostic-surface change that only checked one boundary
6332        // surfaces here. The `(` byte appears earlier in the
6333        // canonical regex / subshell wrapper so the per-byte loop
6334        // fires on `(` first; this test exercises a `:repo` value
6335        // carrying only the closing `)` byte (no opening paren) so
6336        // the `)` arm fires directly — pinning the byte-class arm
6337        // independent of order.
6338        let d = dep_with_fonte(DepSource::Git {
6339            repo: "github:pleme-io/caixa-teia)tail".into(),
6340            tag: Some("v0.1.0".into()),
6341            rev: None,
6342            branch: None,
6343        });
6344        let err = d.validate().unwrap_err();
6345        let DepError::FonteRepoShape { reason, .. } = err else {
6346            panic!("expected FonteRepoShape, got other variant");
6347        };
6348        assert!(
6349            reason.contains("must not contain `)`"),
6350            "reason must surface the subshell-close-paren arm on the bare `)` shape, \
6351             got {reason:?}"
6352        );
6353    }
6354
6355    #[test]
6356    fn fonte_repo_fragment_fires_before_subshell_when_fragment_first() {
6357        // Cascade pin: the fragment-`#` arm and the subshell-`(` arm
6358        // are both per-byte arms inside the same `for &b in
6359        // s.as_bytes()` loop, so the byte that appears first in the
6360        // value's byte order wins. A `:repo
6361        // "https://github.com/p/x#readme(tail)"` carries both `#` and
6362        // `(`; the `#` byte appears first, so the fragment-`#` arm
6363        // fires, surfacing the more self-locating diagnostic on the
6364        // byte the author pasted earliest in the URL. Mirrors the
6365        // peer cascade discipline
6366        // `fonte_repo_fragment_fires_before_glob_when_fragment_first`
6367        // on the prior `:repo` byte-class arm.
6368        let d = dep_with_fonte(DepSource::Git {
6369            repo: "https://github.com/pleme-io/caixa-teia#readme(tail)".into(),
6370            tag: Some("v0.1.0".into()),
6371            rev: None,
6372            branch: None,
6373        });
6374        let err = d.validate().unwrap_err();
6375        let DepError::FonteRepoShape { reason, .. } = err else {
6376            panic!("expected FonteRepoShape, got other variant");
6377        };
6378        assert!(
6379            reason.contains("must not contain `#`"),
6380            "reason must surface the fragment-`#` arm (fires before subshell-`(` when `#` \
6381             byte appears first in value), got {reason:?}"
6382        );
6383    }
6384
6385    #[test]
6386    fn fonte_repo_glob_fires_before_subshell_when_glob_first() {
6387        // Cascade pin: the glob-`*` arm (the immediate-predecessor
6388        // byte-class arm, 3902a9a) and the subshell-`(` arm are both
6389        // per-byte arms inside the same `for &b in s.as_bytes()`
6390        // loop, so the byte that appears first in the value's byte
6391        // order wins. A `:repo
6392        // "https://github.com/p/x-*-(date)"` carries both `*` and
6393        // `(`; the `*` byte appears first, so the glob arm fires,
6394        // surfacing the more self-locating diagnostic on the byte
6395        // the author pasted earliest in the URL. Pins the natural-
6396        // order cascade so a future reorder of the per-byte arms
6397        // surfaces here — `(` is the most recent byte-class arm,
6398        // so the cascade-pin sweep extends to cover the immediately
6399        // prior `*` byte arm firing first when ordered ahead of `(`
6400        // in the value.
6401        let d = dep_with_fonte(DepSource::Git {
6402            repo: "https://github.com/pleme-io/caixa-teia-*-(date)".into(),
6403            tag: Some("v0.1.0".into()),
6404            rev: None,
6405            branch: None,
6406        });
6407        let err = d.validate().unwrap_err();
6408        let DepError::FonteRepoShape { reason, .. } = err else {
6409            panic!("expected FonteRepoShape, got other variant");
6410        };
6411        assert!(
6412            reason.contains("must not contain `*`"),
6413            "reason must surface the glob-`*` arm (fires before subshell-`(` when `*` byte \
6414             appears first in value), got {reason:?}"
6415        );
6416    }
6417
6418    #[test]
6419    fn validate_rejects_git_fonte_with_repo_carrying_shell_double_quote() {
6420        // The fail-before-pass-after pin for the canonical paste-from-
6421        // doc-shell-quoting footgun on `:repo`. An author copies a
6422        // README quick-start snippet (`$ git clone "https://github.com/
6423        // foo/bar"`) and keeps the surrounding double-quote bytes when
6424        // pasting into the `:repo` slot — the doc wraps the URL in
6425        // double quotes so the shell doesn't re-lex metachars inside,
6426        // but the typed slot is itself a byte-level string parser, not
6427        // a shell context, so the quote bytes ride into the value
6428        // verbatim. Until this arm landed the `"` byte silently passed
6429        // every prior `is_git_repo_url` arm (no whitespace, no control
6430        // chars, no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no
6431        // `<`/`>`, no `` ` ``, no `|`, no `;`, no `&`, no `$`, no `*`,
6432        // no `(`/`)`, doesn't start with `-` or `:`); RFC 3986 §2 lists
6433        // `"` in the strict four-byte 'delims' subset (with `<`, `>`,
6434        // `` ` ``) every URL parser is required to refuse or percent-
6435        // encode, and the WHATWG URL spec's 'C0 control percent-encode
6436        // set' maps `"` → `%22` on the wire, so the byte rides verbatim
6437        // into the lacre's per-dep BLAKE3 closure but is silently
6438        // rewritten at libcurl's URL-parser layer, defeating the
6439        // THEORY.md §V.2 render-determinism contract.
6440        let d = dep_with_fonte(DepSource::Git {
6441            repo: "\"https://github.com/pleme-io/caixa-teia\"".into(),
6442            tag: Some("v0.1.0".into()),
6443            rev: None,
6444            branch: None,
6445        });
6446        let err = d.validate().unwrap_err();
6447        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6448            panic!("expected FonteRepoShape, got other variant");
6449        };
6450        assert_eq!(nome, "caixa-teia");
6451        assert_eq!(repo, "\"https://github.com/pleme-io/caixa-teia\"");
6452        assert!(
6453            reason.contains("must not contain `\"`"),
6454            "reason must surface the shell-double-quote arm, got {reason:?}"
6455        );
6456        assert!(
6457            reason.contains("double-quote") || reason.contains("'delims'"),
6458            "reason must name the shell-double-quote / RFC-3986-delims rationale, \
6459             got {reason:?}"
6460        );
6461    }
6462
6463    #[test]
6464    fn validate_rejects_git_fonte_with_repo_carrying_stray_trailing_double_quote() {
6465        // The symmetric stray-quote tail pin: an author pastes only a
6466        // closing `"` from a shell-history line like `git clone
6467        // "https://github.com/foo/bar" && cd …` (the trim went too
6468        // far in one direction but not the other) into the `:repo`
6469        // slot. Pinned separately from the wrapped-quote shape so a
6470        // future diagnostic-surface change that only checked one
6471        // boundary (only leading, only trailing, only paired) surfaces
6472        // here — the per-byte arm fires anywhere `"` appears.
6473        let d = dep_with_fonte(DepSource::Git {
6474            repo: "github:pleme-io/caixa-teia\"".into(),
6475            tag: Some("v0.1.0".into()),
6476            rev: None,
6477            branch: None,
6478        });
6479        let err = d.validate().unwrap_err();
6480        let DepError::FonteRepoShape { reason, .. } = err else {
6481            panic!("expected FonteRepoShape, got other variant");
6482        };
6483        assert!(
6484            reason.contains("must not contain `\"`"),
6485            "reason must surface the shell-double-quote arm on the trailing-`\"` shape, \
6486             got {reason:?}"
6487        );
6488    }
6489
6490    #[test]
6491    fn fonte_repo_fragment_fires_before_double_quote_when_fragment_first() {
6492        // Cascade pin: the fragment-`#` arm and the double-quote arm
6493        // are both per-byte arms inside the same `for &b in
6494        // s.as_bytes()` loop, so the byte that appears first in the
6495        // value's byte order wins. A `:repo
6496        // "https://github.com/p/x#readme\"tail"` carries both `#` and
6497        // `"`; the `#` byte appears first, so the fragment-`#` arm
6498        // fires, surfacing the more self-locating diagnostic on the
6499        // byte the author pasted earliest in the URL.
6500        let d = dep_with_fonte(DepSource::Git {
6501            repo: "https://github.com/pleme-io/caixa-teia#readme\"tail".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 fragment-`#` arm (fires before double-quote when `#` \
6513             byte appears first in value), got {reason:?}"
6514        );
6515    }
6516
6517    #[test]
6518    fn fonte_repo_subshell_fires_before_double_quote_when_subshell_first() {
6519        // Cascade pin: the subshell-`(` arm (the immediate-predecessor
6520        // byte-class arm, 3b99147) and the double-quote arm are both
6521        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
6522        // so the byte that appears first in the value's byte order
6523        // wins. A `:repo "github:p/x(date)\"tail"` carries both `(`
6524        // and `"`; the `(` byte appears first, so the subshell arm
6525        // fires, surfacing the more self-locating diagnostic on the
6526        // byte the author pasted earliest in the URL. Pins the natural-
6527        // order cascade so a future reorder of the per-byte arms
6528        // surfaces here — `"` is the most recent byte-class arm, so
6529        // the cascade-pin sweep extends to cover the immediately prior
6530        // `(` byte arm firing first when ordered ahead of `"` in the
6531        // value.
6532        let d = dep_with_fonte(DepSource::Git {
6533            repo: "github:pleme-io/caixa-teia(date)\"tail".into(),
6534            tag: Some("v0.1.0".into()),
6535            rev: None,
6536            branch: None,
6537        });
6538        let err = d.validate().unwrap_err();
6539        let DepError::FonteRepoShape { reason, .. } = err else {
6540            panic!("expected FonteRepoShape, got other variant");
6541        };
6542        assert!(
6543            reason.contains("must not contain `(`"),
6544            "reason must surface the subshell-`(` arm (fires before double-quote when `(` \
6545             byte appears first in value), got {reason:?}"
6546        );
6547    }
6548
6549    #[test]
6550    fn validate_rejects_git_fonte_with_repo_carrying_shell_single_quote() {
6551        // The fail-before-pass-after pin for the canonical paste-from-
6552        // doc-strong-quoting footgun on `:repo`. An author copies a
6553        // security-conscious README quick-start snippet (`$ git clone
6554        // 'https://github.com/foo/bar'`) and keeps the surrounding
6555        // single-quote bytes when pasting into the `:repo` slot — the
6556        // doc strong-quotes the URL so the shell suppresses every form
6557        // of expansion on the bytes inside (no `$`, no backtick, no
6558        // glob, no word-splitting), but the typed slot is itself a
6559        // byte-level string parser, not a shell context, so the quote
6560        // bytes ride into the value verbatim. Until this arm landed the
6561        // `'` byte silently passed every prior `is_git_repo_url` arm
6562        // (no whitespace, no control chars, no non-ASCII, no `#`, no
6563        // `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no
6564        // `;`, no `&`, no `$`, no `*`, no `(`/`)`, no `"`, doesn't start
6565        // with `-` or `:`); RFC 3986 §2.2 lists `'` in the 'sub-delims'
6566        // set, peer with the `\"` 'delims' double-quote arm and the
6567        // partner ASCII shell-string-delimiter byte every byte-level
6568        // string parser sharing a value-shape with a shell argument
6569        // must refuse on a URL-shaped slot.
6570        let d = dep_with_fonte(DepSource::Git {
6571            repo: "'https://github.com/pleme-io/caixa-teia'".into(),
6572            tag: Some("v0.1.0".into()),
6573            rev: None,
6574            branch: None,
6575        });
6576        let err = d.validate().unwrap_err();
6577        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6578            panic!("expected FonteRepoShape, got other variant");
6579        };
6580        assert_eq!(nome, "caixa-teia");
6581        assert_eq!(repo, "'https://github.com/pleme-io/caixa-teia'");
6582        assert!(
6583            reason.contains("must not contain `'`"),
6584            "reason must surface the shell-single-quote arm, got {reason:?}"
6585        );
6586        assert!(
6587            reason.contains("single-quote") || reason.contains("strong-quote"),
6588            "reason must name the shell-single-quote / strong-quote rationale, \
6589             got {reason:?}"
6590        );
6591    }
6592
6593    #[test]
6594    fn validate_rejects_git_fonte_with_repo_carrying_english_apostrophe() {
6595        // The symmetric English-typography pin: an author writes
6596        // `:repo "github:p/repo's-fork"` (the possessive-form paste-
6597        // from-prose idiom every README / commit-message / chat-thread
6598        // reference to a repo carries) expecting the substrate to
6599        // coerce it to a kebab-case slug — but the byte rides into the
6600        // lacre verbatim. Pinned separately from the wrapped-quote
6601        // shape so a future diagnostic-surface change that only checked
6602        // the boundary positions (only leading, only trailing, only
6603        // paired) surfaces here — the per-byte arm fires anywhere `'`
6604        // appears in the value.
6605        let d = dep_with_fonte(DepSource::Git {
6606            repo: "github:pleme-io/repo's-fork".into(),
6607            tag: Some("v0.1.0".into()),
6608            rev: None,
6609            branch: None,
6610        });
6611        let err = d.validate().unwrap_err();
6612        let DepError::FonteRepoShape { reason, .. } = err else {
6613            panic!("expected FonteRepoShape, got other variant");
6614        };
6615        assert!(
6616            reason.contains("must not contain `'`"),
6617            "reason must surface the shell-single-quote arm on the mid-string \
6618             apostrophe shape, got {reason:?}"
6619        );
6620    }
6621
6622    #[test]
6623    fn fonte_repo_fragment_fires_before_single_quote_when_fragment_first() {
6624        // Cascade pin: the fragment-`#` arm and the single-quote arm
6625        // are both per-byte arms inside the same `for &b in
6626        // s.as_bytes()` loop, so the byte that appears first in the
6627        // value's byte order wins. A `:repo
6628        // "https://github.com/p/x#readme'tail"` carries both `#` and
6629        // `'`; the `#` byte appears first, so the fragment-`#` arm
6630        // fires, surfacing the more self-locating diagnostic on the
6631        // byte the author pasted earliest in the URL.
6632        let d = dep_with_fonte(DepSource::Git {
6633            repo: "https://github.com/pleme-io/caixa-teia#readme'tail".into(),
6634            tag: Some("v0.1.0".into()),
6635            rev: None,
6636            branch: None,
6637        });
6638        let err = d.validate().unwrap_err();
6639        let DepError::FonteRepoShape { reason, .. } = err else {
6640            panic!("expected FonteRepoShape, got other variant");
6641        };
6642        assert!(
6643            reason.contains("must not contain `#`"),
6644            "reason must surface the fragment-`#` arm (fires before single-quote when `#` \
6645             byte appears first in value), got {reason:?}"
6646        );
6647    }
6648
6649    #[test]
6650    fn fonte_repo_double_quote_fires_before_single_quote_when_double_quote_first() {
6651        // Cascade pin: the double-quote-`"` arm (the immediate-predecessor
6652        // byte-class arm, 4267d8b) and the single-quote arm are both
6653        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
6654        // so the byte that appears first in the value's byte order
6655        // wins. A `:repo "github:p/x\"mid'tail"` carries both `"` and
6656        // `'`; the `"` byte appears first, so the double-quote arm
6657        // fires, surfacing the more self-locating diagnostic on the
6658        // byte the author pasted earliest in the URL. Pins the natural-
6659        // order cascade so a future reorder of the per-byte arms
6660        // surfaces here — `'` is the most recent byte-class arm, so
6661        // the cascade-pin sweep extends to cover the immediately prior
6662        // `"` byte arm firing first when ordered ahead of `'` in the
6663        // value.
6664        let d = dep_with_fonte(DepSource::Git {
6665            repo: "github:pleme-io/caixa-teia\"mid'tail".into(),
6666            tag: Some("v0.1.0".into()),
6667            rev: None,
6668            branch: None,
6669        });
6670        let err = d.validate().unwrap_err();
6671        let DepError::FonteRepoShape { reason, .. } = err else {
6672            panic!("expected FonteRepoShape, got other variant");
6673        };
6674        assert!(
6675            reason.contains("must not contain `\"`"),
6676            "reason must surface the double-quote arm (fires before single-quote when `\"` \
6677             byte appears first in value), got {reason:?}"
6678        );
6679    }
6680
6681    #[test]
6682    fn validate_rejects_git_fonte_with_repo_carrying_shell_history_expansion() {
6683        // The fail-before-pass-after pin for the canonical paste-from-
6684        // shell-history footgun on `:repo`. An author copies a `git
6685        // clone <url>!sudo make install` one-liner from a README's
6686        // quick-start snippet, intending the trailing `!sudo` as a
6687        // shell-history-expansion reference but the typed slot is itself
6688        // a byte-level string parser, not a shell context, so the byte
6689        // rides into the value verbatim. Until this arm landed the `!`
6690        // byte silently passed every prior `is_git_repo_url` arm (no
6691        // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
6692        // no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no `;`,
6693        // no `&`, no `$`, no `*`, no `(`/`)`, no `"`, no `'`, doesn't
6694        // start with `-` or `:`); bash with the default `histexpand`
6695        // mode rewrites `!command` to the most recent history entry
6696        // beginning with `command`, the canonical RCE-class injection
6697        // vector when the byte rides into a shell argument.
6698        let d = dep_with_fonte(DepSource::Git {
6699            repo: "https://github.com/pleme-io/caixa-teia!sudo".into(),
6700            tag: Some("v0.1.0".into()),
6701            rev: None,
6702            branch: None,
6703        });
6704        let err = d.validate().unwrap_err();
6705        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6706            panic!("expected FonteRepoShape, got other variant");
6707        };
6708        assert_eq!(nome, "caixa-teia");
6709        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia!sudo");
6710        assert!(
6711            reason.contains("must not contain `!`"),
6712            "reason must surface the shell-history-expansion arm, got {reason:?}"
6713        );
6714        assert!(
6715            reason.contains("history-expansion") || reason.contains("bang"),
6716            "reason must name the shell-history-expansion / bang rationale, got {reason:?}"
6717        );
6718    }
6719
6720    #[test]
6721    fn validate_rejects_git_fonte_with_repo_carrying_double_bang_history_reference() {
6722        // The symmetric `!!` repeat-prior-command pin: an author paste-
6723        // trims a `git clone <url>` retry idiom from shell history that
6724        // expands to the previous command via `!!`. Pinned separately
6725        // from the wrapped `!command` shape so a future diagnostic-
6726        // surface change that only checked the leading or paired-bang
6727        // position surfaces here — the per-byte arm fires anywhere `!`
6728        // appears in the value.
6729        let d = dep_with_fonte(DepSource::Git {
6730            repo: "github:pleme-io/caixa-teia!!".into(),
6731            tag: Some("v0.1.0".into()),
6732            rev: None,
6733            branch: None,
6734        });
6735        let err = d.validate().unwrap_err();
6736        let DepError::FonteRepoShape { reason, .. } = err else {
6737            panic!("expected FonteRepoShape, got other variant");
6738        };
6739        assert!(
6740            reason.contains("must not contain `!`"),
6741            "reason must surface the shell-history-expansion arm on the trailing-`!!` shape, \
6742             got {reason:?}"
6743        );
6744    }
6745
6746    #[test]
6747    fn fonte_repo_fragment_fires_before_bang_when_fragment_first() {
6748        // Cascade pin: the fragment-`#` arm and the bang arm are both
6749        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
6750        // so the byte that appears first in the value's byte order
6751        // wins. A `:repo "https://github.com/p/x#readme!tail"` carries
6752        // both `#` and `!`; the `#` byte appears first, so the
6753        // fragment-`#` arm fires, surfacing the more self-locating
6754        // diagnostic on the byte the author pasted earliest in the URL.
6755        let d = dep_with_fonte(DepSource::Git {
6756            repo: "https://github.com/pleme-io/caixa-teia#readme!tail".into(),
6757            tag: Some("v0.1.0".into()),
6758            rev: None,
6759            branch: None,
6760        });
6761        let err = d.validate().unwrap_err();
6762        let DepError::FonteRepoShape { reason, .. } = err else {
6763            panic!("expected FonteRepoShape, got other variant");
6764        };
6765        assert!(
6766            reason.contains("must not contain `#`"),
6767            "reason must surface the fragment-`#` arm (fires before bang when `#` byte \
6768             appears first in value), got {reason:?}"
6769        );
6770    }
6771
6772    #[test]
6773    fn fonte_repo_single_quote_fires_before_bang_when_single_quote_first() {
6774        // Cascade pin: the single-quote-`'` arm (the immediate-predecessor
6775        // byte-class arm, e7a109f) and the bang arm are both per-byte
6776        // arms inside the same `for &b in s.as_bytes()` loop, so the
6777        // byte that appears first in the value's byte order wins. A
6778        // `:repo "github:p/x'mid!tail"` carries both `'` and `!`; the
6779        // `'` byte appears first, so the single-quote arm fires,
6780        // surfacing the more self-locating diagnostic on the byte the
6781        // author pasted earliest in the URL. Pins the natural-order
6782        // cascade so a future reorder of the per-byte arms surfaces
6783        // here — `!` is the most recent byte-class arm, so the
6784        // cascade-pin sweep extends to cover the immediately prior `'`
6785        // byte arm firing first when ordered ahead of `!` in the value.
6786        let d = dep_with_fonte(DepSource::Git {
6787            repo: "github:pleme-io/caixa-teia'mid!tail".into(),
6788            tag: Some("v0.1.0".into()),
6789            rev: None,
6790            branch: None,
6791        });
6792        let err = d.validate().unwrap_err();
6793        let DepError::FonteRepoShape { reason, .. } = err else {
6794            panic!("expected FonteRepoShape, got other variant");
6795        };
6796        assert!(
6797            reason.contains("must not contain `'`"),
6798            "reason must surface the single-quote arm (fires before bang when `'` byte \
6799             appears first in value), got {reason:?}"
6800        );
6801    }
6802
6803    #[test]
6804    fn validate_rejects_git_fonte_with_repo_carrying_list_separator_comma() {
6805        // The fail-before-pass-after pin for the canonical
6806        // list-separator-belongs-to-list-grammar footgun on `:repo`.
6807        // An author copies a `git clone <a>, <b>, <c>` paste-from-CSV
6808        // one-liner from a multi-repo bootstrap doc, intending the
6809        // comma to separate multiple repo entries but the typed
6810        // `:repo` slot names *one* repo (the list-separator belongs
6811        // to the `:deps` list grammar, not to the value). Until this
6812        // arm landed the `,` byte silently passed every prior
6813        // `is_git_repo_url` arm (no whitespace, no control chars, no
6814        // non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no `<`/`>`,
6815        // no `` ` ``, no `|`, no `;`, no `&`, no `$`, no `*`, no
6816        // `(`/`)`, no `"`, no `'`, no `!`, doesn't start with `-` or
6817        // `:`); the byte rode into the lacre's per-dep content-
6818        // address and the resolver's `git clone <repo>` subprocess
6819        // invocation, where no host's repo registry resolved the
6820        // comma-bearing slug.
6821        let d = dep_with_fonte(DepSource::Git {
6822            repo: "github:pleme-io/caixa-teia,github:pleme-io/caixa-feira".into(),
6823            tag: Some("v0.1.0".into()),
6824            rev: None,
6825            branch: None,
6826        });
6827        let err = d.validate().unwrap_err();
6828        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6829            panic!("expected FonteRepoShape, got other variant");
6830        };
6831        assert_eq!(nome, "caixa-teia");
6832        assert_eq!(
6833            repo,
6834            "github:pleme-io/caixa-teia,github:pleme-io/caixa-feira"
6835        );
6836        assert!(
6837            reason.contains("must not contain `,`"),
6838            "reason must surface the list-separator-comma arm, got {reason:?}"
6839        );
6840        assert!(
6841            reason.contains("list-separator") || reason.contains("sub-delims"),
6842            "reason must name the list-separator / RFC-3986-sub-delims rationale, \
6843             got {reason:?}"
6844        );
6845    }
6846
6847    #[test]
6848    fn validate_rejects_git_fonte_with_repo_carrying_trailing_comma() {
6849        // The symmetric trailing-`,` paste-from-prose pin: an author
6850        // writes `:repo "github:pleme-io/caixa-feira,"` (the trailing
6851        // comma every README-prose list-of-projects sentence carries,
6852        // mistakenly retained when the slug is pasted mid-sentence)
6853        // expecting the substrate to coerce it to a kebab-case slug.
6854        // Pinned separately from the wrapped mid-token shape so a
6855        // future diagnostic-surface change that only checked the
6856        // leading or paired-comma position surfaces here — the
6857        // per-byte arm fires anywhere `,` appears in the value.
6858        let d = dep_with_fonte(DepSource::Git {
6859            repo: "github:pleme-io/caixa-feira,".into(),
6860            tag: Some("v0.1.0".into()),
6861            rev: None,
6862            branch: None,
6863        });
6864        let err = d.validate().unwrap_err();
6865        let DepError::FonteRepoShape { reason, .. } = err else {
6866            panic!("expected FonteRepoShape, got other variant");
6867        };
6868        assert!(
6869            reason.contains("must not contain `,`"),
6870            "reason must surface the list-separator-comma arm on the trailing-`,` shape, \
6871             got {reason:?}"
6872        );
6873    }
6874
6875    #[test]
6876    fn fonte_repo_fragment_fires_before_comma_when_fragment_first() {
6877        // Cascade pin: the fragment-`#` arm and the comma arm are
6878        // both per-byte arms inside the same `for &b in s.as_bytes()`
6879        // loop, so the byte that appears first in the value's byte
6880        // order wins. A `:repo "https://github.com/p/x#readme,tail"`
6881        // carries both `#` and `,`; the `#` byte appears first, so
6882        // the fragment-`#` arm fires, surfacing the more self-
6883        // locating diagnostic on the byte the author pasted earliest
6884        // in the URL.
6885        let d = dep_with_fonte(DepSource::Git {
6886            repo: "https://github.com/pleme-io/caixa-teia#readme,tail".into(),
6887            tag: Some("v0.1.0".into()),
6888            rev: None,
6889            branch: None,
6890        });
6891        let err = d.validate().unwrap_err();
6892        let DepError::FonteRepoShape { reason, .. } = err else {
6893            panic!("expected FonteRepoShape, got other variant");
6894        };
6895        assert!(
6896            reason.contains("must not contain `#`"),
6897            "reason must surface the fragment-`#` arm (fires before comma when `#` byte \
6898             appears first in value), got {reason:?}"
6899        );
6900    }
6901
6902    #[test]
6903    fn fonte_repo_bang_fires_before_comma_when_bang_first() {
6904        // Cascade pin: the bang-`!` arm (the immediate-predecessor
6905        // byte-class arm, 7d53c68) and the comma arm are both
6906        // per-byte arms inside the same `for &b in s.as_bytes()`
6907        // loop, so the byte that appears first in the value's byte
6908        // order wins. A `:repo "github:p/x!mid,tail"` carries both
6909        // `!` and `,`; the `!` byte appears first, so the bang arm
6910        // fires, surfacing the more self-locating diagnostic on the
6911        // byte the author pasted earliest in the URL. Pins the
6912        // natural-order cascade so a future reorder of the per-byte
6913        // arms surfaces here — `,` is the most recent byte-class
6914        // arm, so the cascade-pin sweep extends to cover the
6915        // immediately prior `!` byte arm firing first when ordered
6916        // ahead of `,` in the value.
6917        let d = dep_with_fonte(DepSource::Git {
6918            repo: "github:pleme-io/caixa-teia!mid,tail".into(),
6919            tag: Some("v0.1.0".into()),
6920            rev: None,
6921            branch: None,
6922        });
6923        let err = d.validate().unwrap_err();
6924        let DepError::FonteRepoShape { reason, .. } = err else {
6925            panic!("expected FonteRepoShape, got other variant");
6926        };
6927        assert!(
6928            reason.contains("must not contain `!`"),
6929            "reason must surface the bang arm (fires before comma when `!` byte \
6930             appears first in value), got {reason:?}"
6931        );
6932    }
6933
6934    #[test]
6935    fn validate_rejects_git_fonte_with_repo_carrying_shell_env_var_assignment() {
6936        // The fail-before-pass-after pin for the canonical
6937        // shell-env-var-assignment-belongs-to-shell-grammar footgun
6938        // on `:repo`. An author copies
6939        // `GIT_TERMINAL_PROMPT=0 git clone <url>` (or
6940        // `GIT_SSL_NO_VERIFY=1 git clone <url>`, `HTTPS_PROXY=…
6941        // git clone <url>`, etc. — the canonical
6942        // git-troubleshooting README idiom for a one-shot env-var
6943        // scoped to the `git clone` invocation) from a shell-prompt
6944        // one-liner, intending the `KEY=VALUE` prefix as a shell-
6945        // grammar env-var assignment but the typed `:repo` slot is
6946        // a value parser, not a shell context, so the bytes ride
6947        // into the value verbatim. Until this arm landed the `=`
6948        // byte silently passed every prior `is_git_repo_url` arm
6949        // (no whitespace, no control chars, no non-ASCII, no `#`,
6950        // no `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no
6951        // `|`, no `;`, no `&`, no `$`, no `*`, no `(`/`)`, no `"`,
6952        // no `'`, no `!`, no `,`, doesn't start with `-` or `:`);
6953        // the byte rode into the lacre's per-dep content-address
6954        // and the resolver's `git clone <repo>` subprocess
6955        // invocation, where the upstream host's git porcelain
6956        // fetched a literal `GIT_TERMINAL_PROMPT=0 https://…`-shaped
6957        // path that no host's repo registry resolves.
6958        let d = dep_with_fonte(DepSource::Git {
6959            repo: "GIT_TERMINAL_PROMPT=0 https://github.com/pleme-io/caixa-teia".into(),
6960            tag: Some("v0.1.0".into()),
6961            rev: None,
6962            branch: None,
6963        });
6964        let err = d.validate().unwrap_err();
6965        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6966            panic!("expected FonteRepoShape, got other variant");
6967        };
6968        assert_eq!(nome, "caixa-teia");
6969        assert_eq!(
6970            repo,
6971            "GIT_TERMINAL_PROMPT=0 https://github.com/pleme-io/caixa-teia"
6972        );
6973        // The `=` byte at position 19 of `GIT_TERMINAL_PROMPT=0 …`
6974        // appears before the ` ` byte at position 21, so the `=`
6975        // arm fires (not the whitespace arm) — both arms guard
6976        // the slot, but the per-byte for-loop scans left-to-right
6977        // and the first matching byte wins.
6978        assert!(
6979            reason.contains("must not contain `=`"),
6980            "reason must surface the equals-`=` arm on the env-var-assignment \
6981             paste shape, got {reason:?}"
6982        );
6983        assert!(
6984            reason.contains("env-var-assignment") || reason.contains("KEY=VALUE"),
6985            "reason must name the shell-env-var-assignment rationale, got {reason:?}"
6986        );
6987    }
6988
6989    #[test]
6990    fn validate_rejects_git_fonte_with_repo_carrying_gitconfig_url_key_prefix() {
6991        // The symmetric paste-from-gitconfig pin: an author copies
6992        // `url=https://github.com/p/x` from `git config --get-all
6993        // remote.origin.url` output, a `.gitconfig` `[remote
6994        // "origin"] url = https://…` ini-stanza paste, or a
6995        // `git config remote.origin.url <value>` doc snippet,
6996        // intending the `url=` prefix as the ini-key but the typed
6997        // `:repo` slot is a URL value parser, not a gitconfig
6998        // grammar. With no leading whitespace and no earlier-arm
6999        // bytes in the value, the `=` arm itself fires (rather
7000        // than cascading to the whitespace arm as in the env-var
7001        // paste shape). Pinned separately so a future diagnostic-
7002        // surface change that only checked the whitespace-leading
7003        // shape surfaces here — the per-byte arm fires anywhere
7004        // `=` appears in the value.
7005        let d = dep_with_fonte(DepSource::Git {
7006            repo: "url=https://github.com/pleme-io/caixa-feira".into(),
7007            tag: Some("v0.1.0".into()),
7008            rev: None,
7009            branch: None,
7010        });
7011        let err = d.validate().unwrap_err();
7012        let DepError::FonteRepoShape { reason, .. } = err else {
7013            panic!("expected FonteRepoShape, got other variant");
7014        };
7015        assert!(
7016            reason.contains("must not contain `=`"),
7017            "reason must surface the equals-`=` arm on the `url=…` gitconfig \
7018             paste shape, got {reason:?}"
7019        );
7020        assert!(
7021            reason.contains("key-value-separator") || reason.contains("sub-delims"),
7022            "reason must name the key-value-separator / RFC-3986-sub-delims \
7023             rationale, got {reason:?}"
7024        );
7025    }
7026
7027    #[test]
7028    fn fonte_repo_fragment_fires_before_equals_when_fragment_first() {
7029        // Cascade pin: the fragment-`#` arm and the `=` arm are
7030        // both per-byte arms inside the same `for &b in s.as_bytes()`
7031        // loop, so the byte that appears first in the value's byte
7032        // order wins. A `:repo "https://github.com/p/x#readme=tail"`
7033        // carries both `#` and `=`; the `#` byte appears first, so
7034        // the fragment-`#` arm fires, surfacing the more self-
7035        // locating diagnostic on the byte the author pasted earliest
7036        // in the URL.
7037        let d = dep_with_fonte(DepSource::Git {
7038            repo: "https://github.com/pleme-io/caixa-teia#readme=tail".into(),
7039            tag: Some("v0.1.0".into()),
7040            rev: None,
7041            branch: None,
7042        });
7043        let err = d.validate().unwrap_err();
7044        let DepError::FonteRepoShape { reason, .. } = err else {
7045            panic!("expected FonteRepoShape, got other variant");
7046        };
7047        assert!(
7048            reason.contains("must not contain `#`"),
7049            "reason must surface the fragment-`#` arm (fires before equals when \
7050             `#` byte appears first in value), got {reason:?}"
7051        );
7052    }
7053
7054    #[test]
7055    fn fonte_repo_comma_fires_before_equals_when_comma_first() {
7056        // Cascade pin: the comma-`,` arm (the immediate-predecessor
7057        // byte-class arm, 775b80e) and the `=` arm are both per-byte
7058        // arms inside the same `for &b in s.as_bytes()` loop, so
7059        // the byte that appears first in the value's byte order
7060        // wins. A `:repo "github:p/x,mid=tail"` carries both `,`
7061        // and `=`; the `,` byte appears first, so the comma arm
7062        // fires, surfacing the more self-locating diagnostic on
7063        // the byte the author pasted earliest in the URL. Pins the
7064        // natural-order cascade so a future reorder of the per-byte
7065        // arms surfaces here — `=` is the most recent byte-class
7066        // arm, so the cascade-pin sweep extends to cover the
7067        // immediately prior `,` byte arm firing first when ordered
7068        // ahead of `=` in the value.
7069        let d = dep_with_fonte(DepSource::Git {
7070            repo: "github:pleme-io/caixa-teia,mid=tail".into(),
7071            tag: Some("v0.1.0".into()),
7072            rev: None,
7073            branch: None,
7074        });
7075        let err = d.validate().unwrap_err();
7076        let DepError::FonteRepoShape { reason, .. } = err else {
7077            panic!("expected FonteRepoShape, got other variant");
7078        };
7079        assert!(
7080            reason.contains("must not contain `,`"),
7081            "reason must surface the comma arm (fires before equals when `,` byte \
7082             appears first in value), got {reason:?}"
7083        );
7084    }
7085
7086    #[test]
7087    fn validate_rejects_git_fonte_with_repo_carrying_percent_encoded_space() {
7088        // The fail-before-pass-after pin for the canonical paste-from-
7089        // browser-address-bar percent-encoded-space footgun on `:repo`.
7090        // An author copies `https://github.com/p/x%20test` from a
7091        // browser address bar (or a percent-encoded README hyperlink,
7092        // or a `curl --data-urlencode` shell-pipeline output)
7093        // intending `%20` as the URL encoding of a literal space; the
7094        // typed `:repo` slot already rejects the literal space byte
7095        // (the whitespace arm at the top of `is_git_repo_url`), so an
7096        // author trying to express "I really meant a space" reaches
7097        // for percent-encoding. Until this arm landed the `%` byte
7098        // silently passed every prior `is_git_repo_url` arm and rode
7099        // verbatim into the lacre's per-dep content-address — but
7100        // libcurl re-percent-encodes `%` to `%25` on the wire (since
7101        // `%` is reserved as the escape-sequence lead-in), so the
7102        // wire request becomes `https://github.com/p/x%2520test`, a
7103        // path the lacre's content-address never names. The classic
7104        // render-determinism violation on the encoding-mechanism axis
7105        // itself.
7106        let d = dep_with_fonte(DepSource::Git {
7107            repo: "https://github.com/pleme-io/caixa-teia%20test".into(),
7108            tag: Some("v0.1.0".into()),
7109            rev: None,
7110            branch: None,
7111        });
7112        let err = d.validate().unwrap_err();
7113        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7114            panic!("expected FonteRepoShape, got other variant");
7115        };
7116        assert_eq!(nome, "caixa-teia");
7117        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia%20test");
7118        assert!(
7119            reason.contains("must not contain `%`"),
7120            "reason must surface the percent-`%` arm on the percent-encoded-space \
7121             paste shape, got {reason:?}"
7122        );
7123        assert!(
7124            reason.contains("percent-encoding") || reason.contains("%25"),
7125            "reason must name the percent-encoding / `%25` re-encoding rationale, \
7126             got {reason:?}"
7127        );
7128    }
7129
7130    #[test]
7131    fn validate_rejects_git_fonte_with_repo_carrying_percent_encoded_slash() {
7132        // The symmetric over-encoded-path-separator pin: an author
7133        // writes `:repo "https://github.com/p%2Fx"` intending the
7134        // `%2F` as the URL encoding of `/` (the canonical
7135        // paste-from-OpenAPI-spec / paste-from-percent-encoded-template
7136        // footgun every API client library and OAuth redirect-URI
7137        // documentation surfaces — the `/` is the URL-path-separator
7138        // and some templates percent-encode it to escape interpretation
7139        // as a path separator). The GitHub Smart-HTTP transport
7140        // resolves the URL's path-segment grammar before the
7141        // percent-decoding pass, so the value identifies a different
7142        // resource on the wire than the literal-`/` form the lacre's
7143        // content-address must agree with — two authors whose `:repo`
7144        // values differ only in their `/` vs `%2F` presence lock to
7145        // two distinct BLAKE3 closures for the byte-identical upstream
7146        // `git clone`. Pinned separately so a future diagnostic
7147        // surface that only catches the `%20` shape surfaces here too.
7148        let d = dep_with_fonte(DepSource::Git {
7149            repo: "https://github.com/pleme-io%2Fcaixa-teia".into(),
7150            tag: Some("v0.1.0".into()),
7151            rev: None,
7152            branch: None,
7153        });
7154        let err = d.validate().unwrap_err();
7155        let DepError::FonteRepoShape { reason, .. } = err else {
7156            panic!("expected FonteRepoShape, got other variant");
7157        };
7158        assert!(
7159            reason.contains("must not contain `%`"),
7160            "reason must surface the percent-`%` arm on the over-encoded-path \
7161             shape, got {reason:?}"
7162        );
7163        assert!(
7164            reason.contains("render-determinism") || reason.contains("BLAKE3"),
7165            "reason must name the render-determinism / BLAKE3-closure rationale, \
7166             got {reason:?}"
7167        );
7168    }
7169
7170    #[test]
7171    fn fonte_repo_fragment_fires_before_percent_when_fragment_first() {
7172        // Cascade pin: the fragment-`#` arm and the `%` arm are both
7173        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
7174        // so the byte that appears first in the value's byte order
7175        // wins. A `:repo "https://github.com/p/x#sec%20tail"` carries
7176        // both `#` and `%`; the `#` byte appears first, so the
7177        // fragment-`#` arm fires, surfacing the more self-locating
7178        // diagnostic on the byte the author pasted earliest in the URL.
7179        let d = dep_with_fonte(DepSource::Git {
7180            repo: "https://github.com/pleme-io/caixa-teia#sec%20tail".into(),
7181            tag: Some("v0.1.0".into()),
7182            rev: None,
7183            branch: None,
7184        });
7185        let err = d.validate().unwrap_err();
7186        let DepError::FonteRepoShape { reason, .. } = err else {
7187            panic!("expected FonteRepoShape, got other variant");
7188        };
7189        assert!(
7190            reason.contains("must not contain `#`"),
7191            "reason must surface the fragment-`#` arm (fires before percent when \
7192             `#` byte appears first in value), got {reason:?}"
7193        );
7194    }
7195
7196    #[test]
7197    fn fonte_repo_equals_fires_before_percent_when_equals_first() {
7198        // Cascade pin: the equals-`=` arm (the immediate-predecessor
7199        // byte-class arm, acf99af) and the `%` arm are both per-byte
7200        // arms inside the same `for &b in s.as_bytes()` loop, so the
7201        // byte that appears first in the value's byte order wins.
7202        // A `:repo "github:p/x=mid%20tail"` carries both `=` and `%`;
7203        // the `=` byte appears first, so the equals arm fires,
7204        // surfacing the more self-locating diagnostic on the byte the
7205        // author pasted earliest in the URL. Pins the natural-order
7206        // cascade so a future reorder of the per-byte arms surfaces
7207        // here — `%` is the most recent byte-class arm, so the
7208        // cascade-pin sweep extends to cover the immediately prior
7209        // `=` byte arm firing first when ordered ahead of `%` in the
7210        // value.
7211        let d = dep_with_fonte(DepSource::Git {
7212            repo: "github:pleme-io/caixa-teia=mid%20tail".into(),
7213            tag: Some("v0.1.0".into()),
7214            rev: None,
7215            branch: None,
7216        });
7217        let err = d.validate().unwrap_err();
7218        let DepError::FonteRepoShape { reason, .. } = err else {
7219            panic!("expected FonteRepoShape, got other variant");
7220        };
7221        assert!(
7222            reason.contains("must not contain `=`"),
7223            "reason must surface the equals arm (fires before percent when `=` byte \
7224             appears first in value), got {reason:?}"
7225        );
7226    }
7227
7228    #[test]
7229    fn validate_rejects_git_fonte_with_repo_carrying_caret_history_substitution() {
7230        // The fail-before-pass-after pin for the canonical paste-from-
7231        // shell-history footgun on `:repo`. An author copies a
7232        // `git clone <url>` line from their terminal followed by a
7233        // bash / ksh / zsh `^typo^fix^` quick-edit-and-rerun shell-
7234        // history shorthand (the `^old^new^` form re-runs the prior
7235        // history entry with the first `old` substituted by `new`,
7236        // bash's default behavior on interactive sessions with
7237        // `set -o histexpand`), forgetting to trim the trailing
7238        // `^...^...` shell-history fragment from the URL value. The
7239        // `^` byte sits in the RFC 3986 §2 'unwise' set (peer with
7240        // `{`, `}`, `|`, `\\` — the strictest of the §2 reserved
7241        // classes), the WHATWG URL spec's 'fragment percent-encode
7242        // set' maps `^` → `%5E` on the wire, so the byte rides
7243        // verbatim into the lacre's per-dep content-address but
7244        // libcurl re-encodes it to `%5E` at `git clone` time — the
7245        // classic render-determinism violation on the same axis the
7246        // peer `%`, `=`, `,`, `!`, `'`, `"`, `(`, `)`, `*`, `$`,
7247        // `&`, `;`, `|`, backtick, `<`, `>`, `{`, `}`, `\\`, `?`,
7248        // `#` arms close.
7249        let d = dep_with_fonte(DepSource::Git {
7250            repo: "https://github.com/pleme-io/caixa-teia^typo^fix".into(),
7251            tag: Some("v0.1.0".into()),
7252            rev: None,
7253            branch: None,
7254        });
7255        let err = d.validate().unwrap_err();
7256        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7257            panic!("expected FonteRepoShape, got other variant");
7258        };
7259        assert_eq!(nome, "caixa-teia");
7260        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia^typo^fix");
7261        assert!(
7262            reason.contains("must not contain `^`"),
7263            "reason must surface the caret-`^` arm on the paste-from-shell-history \
7264             shape, got {reason:?}"
7265        );
7266        assert!(
7267            reason.contains("history-substitution") || reason.contains("%5E"),
7268            "reason must name the shell-history-substitution / `%5E` wire-encoding \
7269             rationale, got {reason:?}"
7270        );
7271    }
7272
7273    #[test]
7274    fn validate_rejects_git_fonte_with_repo_carrying_caret_regex_anchor() {
7275        // The symmetric paste-from-doc-grep-pipeline footgun: an
7276        // author writes `:repo "github:p/^archived"` after copying a
7277        // `grep '^archived'` regex-anchor / negation idiom from a
7278        // doc / README quick-listing snippet, expecting the substrate
7279        // to coerce it to a literal repo name. The byte rides
7280        // verbatim into the lacre's per-dep content-address and
7281        // diverges from the byte-identical literal `archived` form
7282        // every other author authored — the canonical render-
7283        // determinism violation pin on the second footgun shape the
7284        // caret-`^` arm closes.
7285        let d = dep_with_fonte(DepSource::Git {
7286            repo: "github:pleme-io/^archived".into(),
7287            tag: Some("v0.1.0".into()),
7288            rev: None,
7289            branch: None,
7290        });
7291        let err = d.validate().unwrap_err();
7292        let DepError::FonteRepoShape { reason, .. } = err else {
7293            panic!("expected FonteRepoShape, got other variant");
7294        };
7295        assert!(
7296            reason.contains("must not contain `^`"),
7297            "reason must surface the caret-`^` arm on the regex-anchor shape, \
7298             got {reason:?}"
7299        );
7300        assert!(
7301            reason.contains("render-determinism") || reason.contains("BLAKE3"),
7302            "reason must name the render-determinism / BLAKE3-closure rationale, \
7303             got {reason:?}"
7304        );
7305    }
7306
7307    #[test]
7308    fn fonte_repo_percent_fires_before_caret_when_percent_first() {
7309        // Cascade pin: the `%` arm (the immediate-predecessor byte-
7310        // class arm, a323db8) and the `^` arm are both per-byte arms
7311        // inside the same `for &b in s.as_bytes()` loop, so the byte
7312        // that appears first in the value's byte order wins. A
7313        // `:repo "https://github.com/p/x%20mid^tail"` carries both
7314        // `%` and `^`; the `%` byte appears first, so the percent
7315        // arm fires, surfacing the more self-locating diagnostic on
7316        // the byte the author pasted earliest in the URL. Pins the
7317        // natural-order cascade so a future reorder of the per-byte
7318        // arms surfaces here — `^` is the most recent byte-class arm,
7319        // so the cascade-pin sweep extends to cover the immediately
7320        // prior `%` byte arm firing first when ordered ahead of `^`
7321        // in the value.
7322        let d = dep_with_fonte(DepSource::Git {
7323            repo: "https://github.com/pleme-io/caixa-teia%20mid^tail".into(),
7324            tag: Some("v0.1.0".into()),
7325            rev: None,
7326            branch: None,
7327        });
7328        let err = d.validate().unwrap_err();
7329        let DepError::FonteRepoShape { reason, .. } = err else {
7330            panic!("expected FonteRepoShape, got other variant");
7331        };
7332        assert!(
7333            reason.contains("must not contain `%`"),
7334            "reason must surface the percent arm (fires before caret when `%` byte \
7335             appears first in value), got {reason:?}"
7336        );
7337    }
7338
7339    #[test]
7340    fn validate_rejects_git_fonte_with_repo_missing_colon_separator() {
7341        // The "I dropped the scheme" footgun — `:repo "pleme-io/caixa-teia"`
7342        // (no `github:` prefix, no scheme). Every documented form
7343        // carries a `:` (`github:`, `https://`, `ssh://`, `git://`,
7344        // `file://`, or `git@host:path`); a bare `org/repo` is
7345        // ambiguous (`git clone` reads as a relative filesystem path
7346        // rather than the GitHub-shorthand expansion the author
7347        // probably intended) and the gate rejects the shape upstream.
7348        let d = dep_with_fonte(DepSource::Git {
7349            repo: "pleme-io/caixa-teia".into(),
7350            tag: Some("v0.1.0".into()),
7351            rev: None,
7352            branch: None,
7353        });
7354        let err = d.validate().unwrap_err();
7355        let DepError::FonteRepoShape { reason, .. } = err else {
7356            panic!("expected FonteRepoShape, got other variant");
7357        };
7358        assert!(
7359            reason.contains("must contain a `:`"),
7360            "reason must surface the missing-`:` arm, got {reason:?}"
7361        );
7362        assert!(
7363            reason.contains("github:"),
7364            "reason must name the canonical `github:` shorthand prefix, got {reason:?}"
7365        );
7366    }
7367
7368    #[test]
7369    fn validate_rejects_git_fonte_with_repo_leading_colon() {
7370        // The "empty scheme" footgun — `:repo ":foo"` has a zero-length
7371        // scheme that no git porcelain entry-point accepts. Pinned
7372        // separately from the missing-`:` arm because a value with a
7373        // leading `:` does technically contain a `:` separator; the
7374        // shape gate rejects on a dedicated arm so the diagnostic
7375        // names the specific footgun.
7376        let d = dep_with_fonte(DepSource::Git {
7377            repo: ":pleme-io/caixa-teia".into(),
7378            tag: Some("v0.1.0".into()),
7379            rev: None,
7380            branch: None,
7381        });
7382        let err = d.validate().unwrap_err();
7383        let DepError::FonteRepoShape { reason, .. } = err else {
7384            panic!("expected FonteRepoShape, got other variant");
7385        };
7386        assert!(
7387            reason.contains("must not start with `:`"),
7388            "reason must surface the leading-`:` arm, got {reason:?}"
7389        );
7390    }
7391
7392    #[test]
7393    fn validate_rejects_git_fonte_with_repo_too_long() {
7394        // The cap arm — a `:repo` value longer than
7395        // [`crate::render::GIT_REPO_URL_MAX_LEN`] (2048) bytes is
7396        // structurally untenable on every realistic landing site (the
7397        // resolver's `git clone` invocation, the future M4 CR
7398        // materializer's per-dep `repo:` axis); a value of that length
7399        // is almost certainly a paste-from-binary slug.
7400        let too_long = format!(
7401            "github:pleme-io/{}",
7402            "x".repeat(crate::render::GIT_REPO_URL_MAX_LEN)
7403        );
7404        let d = dep_with_fonte(DepSource::Git {
7405            repo: too_long.clone(),
7406            tag: Some("v0.1.0".into()),
7407            rev: None,
7408            branch: None,
7409        });
7410        let err = d.validate().unwrap_err();
7411        let DepError::FonteRepoShape { reason, .. } = err else {
7412            panic!("expected FonteRepoShape, got other variant");
7413        };
7414        assert!(
7415            reason.contains("2048"),
7416            "reason must name the cap, got {reason:?}"
7417        );
7418    }
7419
7420    #[test]
7421    fn validate_accepts_canonical_git_fonte_repo_shapes() {
7422        // The positive-control sweep: every documented author shape on
7423        // the `:fonte :repo` axis ([`crate::DepSource::Git`] doc comment)
7424        // must pass the value-shape gate. Pinned so a future tightening
7425        // (e.g. forbidding `http://` in favor of `https://`-only) surfaces
7426        // here as a structural decision. Each form is exercised with the
7427        // same canonical `:tag` pin so only the `:repo` axis varies.
7428        for repo in [
7429            // The pleme-io registry-shorthand convention — `github:org/repo`.
7430            "github:pleme-io/caixa-teia",
7431            // Other host-aliased shorthands (the resolver's pluggable
7432            // host-prefix table).
7433            "gitlab:pleme-io/caixa-teia",
7434            "codeberg:pleme-io/caixa-teia",
7435            "sourcehut:~pleme-io/caixa-teia",
7436            // Full HTTPS URL with and without `.git` suffix.
7437            "https://github.com/pleme-io/caixa-teia",
7438            "https://github.com/pleme-io/caixa-teia.git",
7439            // HTTP (rare; dev / mirror).
7440            "http://example.com/pleme-io/caixa-teia.git",
7441            // SSH URL.
7442            "ssh://git@github.com/pleme-io/caixa-teia.git",
7443            "ssh://git@git.example.com:2222/pleme-io/caixa-teia.git",
7444            // Scp-style SSH — the canonical `git@host:path` short form.
7445            "git@github.com:pleme-io/caixa-teia.git",
7446            "git@git.example.com:team/private.git",
7447            // Anonymous git protocol.
7448            "git://git.example.com/pleme-io/caixa-teia.git",
7449            // Local file URL (dev path).
7450            "file:///tmp/caixa-teia",
7451        ] {
7452            let d = dep_with_fonte(DepSource::Git {
7453                repo: repo.into(),
7454                tag: Some("v0.1.0".into()),
7455                rev: None,
7456                branch: None,
7457            });
7458            d.validate()
7459                .unwrap_or_else(|e| panic!("canonical repo {repo:?} must validate, got {e:?}"));
7460        }
7461    }
7462
7463    #[test]
7464    fn fonte_repo_empty_takes_precedence_over_shape() {
7465        // Order pin: the existing `FonteRepoEmpty` diagnostic (narrower
7466        // diagnostic; doesn't try to parse the URL shape) fires before
7467        // the new `FonteRepoShape` per-axis gate, so an empty `:repo`
7468        // keeps its narrower error message. Mirrors
7469        // `fonte_repo_empty_fires_before_pin_missing` (already pinned)
7470        // on the ordering layer.
7471        let d = dep_with_fonte(DepSource::Git {
7472            repo: String::new(),
7473            tag: Some("v0.1.0".into()),
7474            rev: None,
7475            branch: None,
7476        });
7477        let err = d.validate().unwrap_err();
7478        assert!(
7479            matches!(err, DepError::FonteRepoEmpty { .. }),
7480            "got {err:?}"
7481        );
7482    }
7483
7484    #[test]
7485    fn fonte_repo_shape_fires_before_pin_missing() {
7486        // Order pin: a malformed `:repo` value on a dep with no pin set
7487        // surfaces the `:repo` shape diagnostic (the more self-locating
7488        // axis — the `:repo` is the load-bearing identity of the source;
7489        // a missing pin is downstream from "do we even know the repo")
7490        // rather than collapsing onto the pin-missing diagnostic. The
7491        // shape gate runs inline before the pin enumeration in
7492        // `DepSource::validate`.
7493        let d = dep_with_fonte(DepSource::Git {
7494            repo: "pleme-io/caixa-teia".into(), // missing `:` separator
7495            tag: None,
7496            rev: None,
7497            branch: None,
7498        });
7499        let err = d.validate().unwrap_err();
7500        assert!(
7501            matches!(err, DepError::FonteRepoShape { .. }),
7502            "got {err:?}"
7503        );
7504    }
7505
7506    #[test]
7507    fn fonte_repo_shape_diagnostic_carries_offending_repo_verbatim() {
7508        // The diagnostic-shape pin: the error names the offending
7509        // `:repo` value verbatim plus a non-empty parser-shaped `reason`
7510        // so the author can grep their caixa.lisp without re-running
7511        // the build. Mirrors the diagnostic-shape sweep on every prior
7512        // value-shape gate (3f9d7a0, 6cbb900, c7d05ec, e70d213, be07fd5).
7513        let d = dep_with_fonte(DepSource::Git {
7514            repo: "pleme-io/caixa-teia".into(),
7515            tag: Some("v0.1.0".into()),
7516            rev: None,
7517            branch: None,
7518        });
7519        let err = d.validate().unwrap_err();
7520        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7521            panic!("expected FonteRepoShape, got other variant");
7522        };
7523        assert_eq!(nome, "caixa-teia");
7524        assert_eq!(repo, "pleme-io/caixa-teia");
7525        assert!(
7526            !reason.is_empty(),
7527            "FonteRepoShape `reason` must carry the predicate's wording verbatim"
7528        );
7529    }
7530
7531    #[test]
7532    fn validate_rejects_git_fonte_with_no_pin() {
7533        // The fail-before-pass-after pin for the canonical
7534        // `(:tipo git :repo "github:pleme-io/x")` shape with no
7535        // :tag/:rev/:branch — until this gate landed the resolver's
7536        // ResolveError::MissingPin surfaced at fetch time, far from the
7537        // source caixa.lisp. The new gate moves the check to validate
7538        // time and names the offending dep.
7539        let d = dep_with_fonte(DepSource::Git {
7540            repo: "github:pleme-io/caixa-teia".into(),
7541            tag: None,
7542            rev: None,
7543            branch: None,
7544        });
7545        let err = d.validate().unwrap_err();
7546        assert!(
7547            matches!(err, DepError::FontePinMissing { ref nome } if nome == "caixa-teia"),
7548            "got {err:?}"
7549        );
7550    }
7551
7552    #[test]
7553    fn validate_rejects_git_fonte_with_ambiguous_tag_and_branch() {
7554        // The canonical "pin drift" footgun: an author writes
7555        // `:tag "v1"` and later adds `:branch "main"` without removing
7556        // the :tag, and the resolver silently picks :tag (precedence
7557        // :rev > :tag > :branch). The :branch was dropped with no
7558        // diagnostic. The gate now rejects multi-pin shapes so the
7559        // author makes the precedence explicit at the source.
7560        let d = dep_with_fonte(DepSource::Git {
7561            repo: "github:pleme-io/caixa-teia".into(),
7562            tag: Some("v0.1.0".into()),
7563            rev: None,
7564            branch: Some("main".into()),
7565        });
7566        let err = d.validate().unwrap_err();
7567        let DepError::FontePinAmbiguous { nome, pins } = err else {
7568            panic!("expected FontePinAmbiguous");
7569        };
7570        assert_eq!(nome, "caixa-teia");
7571        assert!(pins.contains(":tag"));
7572        assert!(pins.contains(":branch"));
7573        assert!(!pins.contains(":rev"));
7574    }
7575
7576    #[test]
7577    fn validate_rejects_git_fonte_with_ambiguous_tag_and_rev() {
7578        // Sibling arm of the pin-drift footgun: :tag + :rev set
7579        // simultaneously. Pinned separately so a future relaxation
7580        // that only catches the (:tag, :branch) pair surfaces here.
7581        let d = dep_with_fonte(DepSource::Git {
7582            repo: "github:pleme-io/caixa-teia".into(),
7583            tag: Some("v0.1.0".into()),
7584            rev: Some("c0ffee".into()),
7585            branch: None,
7586        });
7587        let err = d.validate().unwrap_err();
7588        let DepError::FontePinAmbiguous { nome, pins } = err else {
7589            panic!("expected FontePinAmbiguous");
7590        };
7591        assert_eq!(nome, "caixa-teia");
7592        assert!(pins.contains(":tag"));
7593        assert!(pins.contains(":rev"));
7594    }
7595
7596    #[test]
7597    fn validate_rejects_git_fonte_with_all_three_pins() {
7598        // The maximal ambiguity case — every pin axis set. Pinned so a
7599        // future relaxation that only catches pairs surfaces here. The
7600        // diagnostic must enumerate every offending axis so the author
7601        // sees the full set, not just the first match.
7602        let d = dep_with_fonte(DepSource::Git {
7603            repo: "github:pleme-io/caixa-teia".into(),
7604            tag: Some("v0.1.0".into()),
7605            rev: Some("c0ffee".into()),
7606            branch: Some("main".into()),
7607        });
7608        let err = d.validate().unwrap_err();
7609        let DepError::FontePinAmbiguous { nome, pins } = err else {
7610            panic!("expected FontePinAmbiguous");
7611        };
7612        assert_eq!(nome, "caixa-teia");
7613        assert!(pins.contains(":tag"));
7614        assert!(pins.contains(":rev"));
7615        assert!(pins.contains(":branch"));
7616    }
7617
7618    #[test]
7619    fn validate_rejects_git_fonte_with_empty_tag_pin() {
7620        // The empty-pin arm: exactly one pin axis is `Some(_)`, but its
7621        // inner string is empty. Distinct from FontePinMissing (where
7622        // every axis is None) — pinned separately so a future
7623        // tightening collapsing them surfaces here as a structural
7624        // decision.
7625        let d = dep_with_fonte(DepSource::Git {
7626            repo: "github:pleme-io/caixa-teia".into(),
7627            tag: Some(String::new()),
7628            rev: None,
7629            branch: None,
7630        });
7631        let err = d.validate().unwrap_err();
7632        let DepError::FontePinEmpty { nome, pin } = err else {
7633            panic!("expected FontePinEmpty");
7634        };
7635        assert_eq!(nome, "caixa-teia");
7636        assert_eq!(pin, ":tag");
7637    }
7638
7639    #[test]
7640    fn validate_rejects_git_fonte_with_empty_rev_pin() {
7641        // Sibling arm — the empty-pin diagnostic names which axis
7642        // carries the empty value, so the author's grep target is
7643        // unambiguous.
7644        let d = dep_with_fonte(DepSource::Git {
7645            repo: "github:pleme-io/caixa-teia".into(),
7646            tag: None,
7647            rev: Some(String::new()),
7648            branch: None,
7649        });
7650        let err = d.validate().unwrap_err();
7651        let DepError::FontePinEmpty { nome, pin } = err else {
7652            panic!("expected FontePinEmpty");
7653        };
7654        assert_eq!(nome, "caixa-teia");
7655        assert_eq!(pin, ":rev");
7656    }
7657
7658    #[test]
7659    fn validate_rejects_path_fonte_with_empty_caminho() {
7660        // The fail-before-pass-after pin for `(:tipo path :caminho "")`:
7661        // until this gate landed the resolver's
7662        // ResolveError::MissingPath surfaced with `path: PathBuf("")` at
7663        // fetch time — not actionable. The new gate moves the check to
7664        // validate time and names the offending dep.
7665        let d = dep_with_fonte(DepSource::Path {
7666            caminho: String::new(),
7667        });
7668        let err = d.validate().unwrap_err();
7669        assert!(
7670            matches!(err, DepError::FonteCaminhoEmpty { ref nome } if nome == "caixa-teia"),
7671            "got {err:?}"
7672        );
7673    }
7674
7675    #[test]
7676    fn validate_rejects_path_fonte_with_absolute_caminho() {
7677        // The fail-before-pass-after pin for the absolute-`:caminho`
7678        // shape: `(:tipo path :caminho "/home/me/work/caixa-teia")`.
7679        // Until this gate landed an absolute `:caminho` silently
7680        // passed validate; the lacre pipeline embedded the
7681        // host-specific filesystem path verbatim in its
7682        // content-address (`conteudo: format!("path:{caminho}")`,
7683        // caixa-resolver/src/resolve.rs:189), so the BLAKE3 closure
7684        // differed per machine — the build succeeded but two CI
7685        // runners with different `${HOME}` layouts emitted two
7686        // distinct lacres for the byte-identical caixa, silently
7687        // breaking the THEORY.md §V.2 render-determinism contract
7688        // far from the source caixa.lisp. The new gate moves the
7689        // check to validate time and names the offending dep +
7690        // caminho verbatim.
7691        let d = dep_with_fonte(DepSource::Path {
7692            caminho: "/home/me/work/caixa-teia".into(),
7693        });
7694        let err = d.validate().unwrap_err();
7695        let DepError::FonteCaminhoAbsolute { nome, caminho } = err else {
7696            panic!("expected FonteCaminhoAbsolute, got other variant");
7697        };
7698        assert_eq!(nome, "caixa-teia");
7699        assert_eq!(caminho, "/home/me/work/caixa-teia");
7700    }
7701
7702    #[test]
7703    fn validate_accepts_path_fonte_with_parent_escape_caminho() {
7704        // The canonical sibling-workspace dep form
7705        // (`:caminho "../caixa-teia"`) remains accepted. The
7706        // absolute-path gate above is specifically narrower than the
7707        // shared [`crate::render::is_sandboxed_relative_path`]
7708        // predicate (which additionally forbids `..` traversal): a
7709        // local-path dep's canonical author surface is the in-tree
7710        // sibling-workspace path, so a full sandboxed-relative-path
7711        // lift would structurally reject every legitimate path-fonte
7712        // dep. Pinned so a future tightening to the full predicate
7713        // surfaces here as a structural decision, not a silent break.
7714        let d = dep_with_fonte(DepSource::Path {
7715            caminho: "../caixa-teia".into(),
7716        });
7717        d.validate().unwrap();
7718    }
7719
7720    #[test]
7721    fn validate_accepts_path_fonte_with_deeply_nested_relative_caminho() {
7722        // A multi-segment relative `:caminho`
7723        // (`"vendor/forks/caixa-teia"`) remains accepted — the
7724        // absolute-path gate brackets the host-layout-leaking shape
7725        // at the leading-`/` boundary only; every relative shape past
7726        // the empty arm continues to pass. Pinned alongside the
7727        // `..`-traversal positive control so a future tightening
7728        // surfaces the full set of legitimate relative forms here
7729        // rather than at a downstream consumer.
7730        let d = dep_with_fonte(DepSource::Path {
7731            caminho: "vendor/forks/caixa-teia".into(),
7732        });
7733        d.validate().unwrap();
7734    }
7735
7736    #[test]
7737    fn validate_rejects_path_fonte_with_tilde_prefix_caminho() {
7738        // The fail-before-pass-after pin for the tilde-expansion
7739        // `:caminho` shape: `(:tipo path :caminho "~/work/caixa-teia")`.
7740        // Until this gate landed the b94fd83 absolute arm let `~/foo`
7741        // through (`Path::is_absolute` returns false on a leading `~`
7742        // — the tilde is a shell-expansion convention, not a POSIX
7743        // path component), so the lacre embedded the value verbatim
7744        // and the resolver folded it through `Path::join` without
7745        // expansion, looking for a literal `./~/work/caixa-teia`
7746        // subdirectory and failing at resolve time with a
7747        // `No such file or directory` error far from the source
7748        // caixa.lisp. The new gate moves the check to validate time
7749        // and names the offending dep + caminho verbatim.
7750        let d = dep_with_fonte(DepSource::Path {
7751            caminho: "~/work/caixa-teia".into(),
7752        });
7753        let err = d.validate().unwrap_err();
7754        let DepError::FonteCaminhoTildeExpansion { nome, caminho } = err else {
7755            panic!("expected FonteCaminhoTildeExpansion, got {err:?}");
7756        };
7757        assert_eq!(nome, "caixa-teia");
7758        assert_eq!(caminho, "~/work/caixa-teia");
7759    }
7760
7761    #[test]
7762    fn validate_rejects_path_fonte_with_bare_tilde_caminho() {
7763        // The bare `~` form (canonical "I meant `$HOME` and forgot
7764        // the rest"): both the leading-tilde arm catches it and the
7765        // canonical-user-tilde shell idiom (`~alice/dev/caixa-teia`)
7766        // sweeps through the same arm. Pinned both to ensure the
7767        // gate doesn't narrow to `~/` only.
7768        for s in ["~", "~alice/dev/caixa-teia", "~/", "~root/work"] {
7769            let d = dep_with_fonte(DepSource::Path { caminho: s.into() });
7770            let err = d.validate().unwrap_err();
7771            assert!(
7772                matches!(err, DepError::FonteCaminhoTildeExpansion { .. }),
7773                "{s:?} → {err:?}",
7774            );
7775        }
7776    }
7777
7778    #[test]
7779    fn validate_accepts_path_fonte_with_mid_path_tilde_caminho() {
7780        // The leading-`~` is the canonical shell-expansion footgun —
7781        // a tilde mid-path (`"../foo~bar/caixa-teia"` — the canonical
7782        // backup-file-suffix idiom) is a legitimate POSIX path byte
7783        // with no shell-expansion semantic at the leading position.
7784        // Pinned so the gate doesn't widen to a full no-tilde-anywhere
7785        // sweep that would break every legitimate-shape backup-file
7786        // path.
7787        let d = dep_with_fonte(DepSource::Path {
7788            caminho: "../foo~bar/caixa-teia".into(),
7789        });
7790        d.validate().unwrap();
7791    }
7792
7793    #[test]
7794    fn fonte_caminho_empty_fires_before_tilde_expansion() {
7795        // Cascade pin: the empty arm structurally precedes the
7796        // tilde arm (the bytes `""` and `"~"` don't overlap), but the
7797        // pin establishes the precedence at the diagnostic-shape
7798        // level should a future codec round-trip ever produce a
7799        // probe-as-both value. Mirrors the peer
7800        // `fonte_repo_empty_fires_before_pin_missing` cascade
7801        // discipline.
7802        let d = dep_with_fonte(DepSource::Path {
7803            caminho: String::new(),
7804        });
7805        let err = d.validate().unwrap_err();
7806        assert!(
7807            matches!(err, DepError::FonteCaminhoEmpty { .. }),
7808            "got {err:?}",
7809        );
7810    }
7811
7812    #[test]
7813    fn fonte_caminho_tilde_diagnostic_carries_offending_dep_and_caminho() {
7814        // Diagnostic-shape pin (peer with
7815        // `validate_rejects_path_fonte_with_absolute_caminho`'s
7816        // payload assertion): the error's Display surfaces both the
7817        // offending `:nome` and the offending `:caminho` verbatim
7818        // so a `feira lint` run can render the diagnostic without
7819        // re-parsing.
7820        let d = dep_with_fonte(DepSource::Path {
7821            caminho: "~alice/dev/caixa-teia".into(),
7822        });
7823        let rendered = d.validate().unwrap_err().to_string();
7824        assert!(
7825            rendered.contains("caixa-teia"),
7826            "diagnostic must name the offending dep: {rendered}",
7827        );
7828        assert!(
7829            rendered.contains("~alice/dev/caixa-teia"),
7830            "diagnostic must quote the offending caminho: {rendered}",
7831        );
7832        assert!(
7833            rendered.contains('~'),
7834            "diagnostic must reference the tilde footgun: {rendered}",
7835        );
7836    }
7837
7838    #[test]
7839    fn validate_rejects_path_fonte_with_dollar_prefix_caminho() {
7840        // The fail-before-pass-after pin for the shell-variable-
7841        // expansion `:caminho` shape: `(:tipo path :caminho
7842        // "$HOME/work/caixa-teia")`. Until this gate landed the
7843        // b94fd83 absolute arm + the a5c248e tilde arm both let
7844        // `$HOME/foo` through (`Path::is_absolute` returns false on
7845        // a leading `$` — the `$` is a shell convention, not a POSIX
7846        // path component; `starts_with('~')` returns false too), so
7847        // the lacre embedded the value verbatim and the resolver
7848        // folded it through `Path::join` without `$`-expansion,
7849        // looking for a literal `./$HOME/work/caixa-teia`
7850        // subdirectory and failing at resolve time with a
7851        // `No such file or directory` error far from the source
7852        // caixa.lisp. The new gate moves the check to validate time
7853        // and names the offending dep + caminho verbatim.
7854        let d = dep_with_fonte(DepSource::Path {
7855            caminho: "$HOME/work/caixa-teia".into(),
7856        });
7857        let err = d.validate().unwrap_err();
7858        let DepError::FonteCaminhoVarExpansion { nome, caminho } = err else {
7859            panic!("expected FonteCaminhoVarExpansion, got {err:?}");
7860        };
7861        assert_eq!(nome, "caixa-teia");
7862        assert_eq!(caminho, "$HOME/work/caixa-teia");
7863    }
7864
7865    #[test]
7866    fn validate_rejects_path_fonte_with_dollar_brace_prefix_caminho() {
7867        // Sweep over every leading-`$` shape: the `${VAR}`-braced
7868        // form (canonical "paste-from-CI-manifest" footgun every
7869        // GitHub Actions / GitLab CI / Drone manifest carries on
7870        // `${WORKSPACE}`), the XDG idiom (`$XDG_CONFIG_HOME/caixa`,
7871        // canonical "I'm referencing a per-user config dir"),
7872        // and the bare `$` (canonical "I meant `$HOME` and forgot
7873        // the rest"). All shapes route through the same gate's
7874        // byte check. Pinned so the gate doesn't narrow to a
7875        // single shape (e.g. `$HOME/` only).
7876        for s in [
7877            "${HOME}/work/caixa-teia",
7878            "${WORKSPACE}/caixa-teia",
7879            "$XDG_CONFIG_HOME/caixa",
7880            "$",
7881        ] {
7882            let d = dep_with_fonte(DepSource::Path { caminho: s.into() });
7883            let err = d.validate().unwrap_err();
7884            assert!(
7885                matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
7886                "{s:?} → {err:?}",
7887            );
7888        }
7889    }
7890
7891    #[test]
7892    fn validate_rejects_path_fonte_with_mid_path_dollar_caminho() {
7893        // The `$` byte is the canonical shell-variable-expansion /
7894        // command-substitution / arithmetic-expansion sentinel and
7895        // is rejected at *every* position on the `:caminho` axis: the
7896        // leading arm surfaces `FonteCaminhoVarExpansion`, the
7897        // embedded arm surfaces `FonteCaminhoShellVariableExpansion`
7898        // (6620f39). Pinned so a future arm doesn't narrow the gate
7899        // back to the leading position and re-open the paste-from-
7900        // shell-one-liner `"../foo$HOME/bar"` / paste-from-CI-
7901        // manifest `"../foo${WORKSPACE}/bar"` / paste-from-shell-
7902        // prompt `"../foo$(whoami)/bar"` cross-idiom-leak surface on
7903        // the lacre content-address (`path:{caminho}`,
7904        // caixa-resolver/src/resolve.rs:189).
7905        let d = dep_with_fonte(DepSource::Path {
7906            caminho: "../foo$bar/caixa-teia".into(),
7907        });
7908        let err = d.validate().unwrap_err();
7909        assert!(
7910            matches!(
7911                err,
7912                DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
7913            ),
7914            "got {err:?}",
7915        );
7916    }
7917
7918    #[test]
7919    fn fonte_caminho_tilde_fires_before_var_expansion() {
7920        // Cascade pin: the tilde arm structurally precedes the var
7921        // arm (the bytes `~` and `$` don't overlap at the leading
7922        // position), but the pin establishes the precedence at the
7923        // diagnostic-shape level should a future codec round-trip
7924        // ever produce a probe-as-both value. Mirrors the peer
7925        // `fonte_caminho_empty_fires_before_tilde_expansion` cascade
7926        // discipline on the immediate-predecessor arm.
7927        let d = dep_with_fonte(DepSource::Path {
7928            caminho: "~/work/caixa-teia".into(),
7929        });
7930        let err = d.validate().unwrap_err();
7931        assert!(
7932            matches!(err, DepError::FonteCaminhoTildeExpansion { .. }),
7933            "got {err:?}",
7934        );
7935    }
7936
7937    #[test]
7938    fn fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho() {
7939        // Diagnostic-shape pin (peer with
7940        // `fonte_caminho_tilde_diagnostic_carries_offending_dep_and_caminho`'s
7941        // payload assertion on the immediate-predecessor arm): the
7942        // error's Display surfaces both the offending `:nome` and
7943        // the offending `:caminho` verbatim plus the `$` footgun
7944        // character itself so a `feira lint` run can render the
7945        // diagnostic without re-parsing.
7946        let d = dep_with_fonte(DepSource::Path {
7947            caminho: "${WORKSPACE}/caixa-teia".into(),
7948        });
7949        let rendered = d.validate().unwrap_err().to_string();
7950        assert!(
7951            rendered.contains("caixa-teia"),
7952            "diagnostic must name the offending dep: {rendered}",
7953        );
7954        assert!(
7955            rendered.contains("${WORKSPACE}/caixa-teia"),
7956            "diagnostic must quote the offending caminho: {rendered}",
7957        );
7958        assert!(
7959            rendered.contains('$'),
7960            "diagnostic must reference the dollar footgun: {rendered}",
7961        );
7962    }
7963
7964    #[test]
7965    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_nul() {
7966        // The fail-before-pass-after pin for the load-bearing NUL byte:
7967        // POSIX paths cannot contain `0x00` (every `std::fs` syscall
7968        // routes the path through `CString::new` which fails with
7969        // `NulError`); until this gate landed a `:caminho
7970        // "../caixa\0teia"` silently passed validate, the lacre
7971        // pipeline embedded the value verbatim, and the failure
7972        // surfaced at the resolver's `Path::join` → `CString::new`
7973        // boundary with a non-self-locating `NulError` far from the
7974        // source caixa.lisp. The new gate moves the check to validate
7975        // time and names the offending dep + caminho + offending byte
7976        // verbatim.
7977        let d = dep_with_fonte(DepSource::Path {
7978            caminho: "../caixa\0teia".into(),
7979        });
7980        let err = d.validate().unwrap_err();
7981        let DepError::FonteCaminhoControlChar {
7982            nome,
7983            caminho,
7984            byte,
7985        } = err
7986        else {
7987            panic!("expected FonteCaminhoControlChar, got {err:?}");
7988        };
7989        assert_eq!(nome, "caixa-teia");
7990        assert_eq!(caminho, "../caixa\0teia");
7991        assert_eq!(byte, 0x00);
7992    }
7993
7994    #[test]
7995    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_newline() {
7996        // The canonical paste-from-multiline-doc footgun on `:caminho`
7997        // — author copies `"../caixa-teia\n"` (trailing newline) out
7998        // of a multi-line code-fence or, worse, a `:caminho
7999        // "../caixa-teia\nrm -rf /"` value (CRLF-at-subprocess-argument
8000        // injection sibling on the path axis the `is_git_repo_url`
8001        // control-char arm already closes on `:repo`). Pinned
8002        // separately from the NUL arm so a future relaxation that
8003        // catches one but not the other surfaces here.
8004        let d = dep_with_fonte(DepSource::Path {
8005            caminho: "../caixa-teia\n".into(),
8006        });
8007        let err = d.validate().unwrap_err();
8008        let DepError::FonteCaminhoControlChar { byte, .. } = err else {
8009            panic!("expected FonteCaminhoControlChar, got {err:?}");
8010        };
8011        assert_eq!(byte, 0x0A);
8012    }
8013
8014    #[test]
8015    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_carriage_return() {
8016        // The CRLF sibling of the LF arm — Windows-line-ending
8017        // paste-from-multiline-doc on a `\r\n`-terminated buffer
8018        // leaves a stray `\r` mid-string after the LF strip. Pinned
8019        // separately from the LF arm so a future relaxation that
8020        // only catches LF surfaces here.
8021        let d = dep_with_fonte(DepSource::Path {
8022            caminho: "../caixa-teia\r".into(),
8023        });
8024        let err = d.validate().unwrap_err();
8025        let DepError::FonteCaminhoControlChar { byte, .. } = err else {
8026            panic!("expected FonteCaminhoControlChar, got {err:?}");
8027        };
8028        assert_eq!(byte, 0x0D);
8029    }
8030
8031    #[test]
8032    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_tab() {
8033        // The canonical paste-from-aligned-table footgun — a `\t`
8034        // mid-`:caminho` is invisible in most editors but rides
8035        // through the lacre's content-address verbatim, so two
8036        // paste-from-distinct-tables (one editor strips tabs, one
8037        // preserves them) yield divergent lacres for the byte-
8038        // identical-looking caixa. Pinned separately from the
8039        // whitespace-shaped LF/CR arms so a future relaxation that
8040        // narrows to line-terminator-only surfaces here.
8041        let d = dep_with_fonte(DepSource::Path {
8042            caminho: "../caixa\tteia".into(),
8043        });
8044        let err = d.validate().unwrap_err();
8045        let DepError::FonteCaminhoControlChar { byte, .. } = err else {
8046            panic!("expected FonteCaminhoControlChar, got {err:?}");
8047        };
8048        assert_eq!(byte, 0x09);
8049    }
8050
8051    #[test]
8052    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_del() {
8053        // The DEL byte (`0x7F`) closes the upper-end paste-from-
8054        // binary-blob footgun — the gate's contract is `b < 0x20 ||
8055        // b == 0x7F`, matching the `is_git_repo_url` /
8056        // `is_git_ref_name` predicates' control-char arms. Pinned
8057        // separately from the lower-range arms so a future narrowing
8058        // to `< 0x20` only surfaces here.
8059        let d = dep_with_fonte(DepSource::Path {
8060            caminho: "../caixa\x7fteia".into(),
8061        });
8062        let err = d.validate().unwrap_err();
8063        let DepError::FonteCaminhoControlChar { byte, .. } = err else {
8064            panic!("expected FonteCaminhoControlChar, got {err:?}");
8065        };
8066        assert_eq!(byte, 0x7F);
8067    }
8068
8069    #[test]
8070    fn validate_accepts_path_fonte_with_caminho_carrying_high_bit_utf8() {
8071        // The control-byte arm targets `0x00..=0x1F` + `0x7F` only —
8072        // high-bit / non-ASCII UTF-8 bytes are not gated. POSIX paths
8073        // are opaque byte sequences and UTF-8 multi-byte sequences
8074        // are a legitimate filename shape (the `café-teia/foo` idiom).
8075        // Pinned so the gate doesn't widen to a full ASCII-only sweep
8076        // that would break every legitimate-shape UTF-8 path.
8077        let d = dep_with_fonte(DepSource::Path {
8078            caminho: "../café-teia/foo".into(),
8079        });
8080        d.validate().unwrap();
8081    }
8082
8083    #[test]
8084    fn fonte_caminho_var_fires_before_control_char() {
8085        // Cascade pin: the var-expansion arm structurally precedes the
8086        // control-char arm. A value like `"$\n"` probes positive on
8087        // both arms (`starts_with('$')` and contains LF), but the
8088        // narrower leading-byte diagnostic (`FonteCaminhoVarExpansion`)
8089        // wins so the author sees the more self-locating shell-
8090        // expansion arm first. Mirrors the
8091        // `fonte_caminho_tilde_fires_before_var_expansion` cascade
8092        // discipline on the immediate-predecessor arm.
8093        let d = dep_with_fonte(DepSource::Path {
8094            caminho: "$HOME\n".into(),
8095        });
8096        let err = d.validate().unwrap_err();
8097        assert!(
8098            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
8099            "got {err:?}",
8100        );
8101    }
8102
8103    #[test]
8104    fn validate_rejects_path_fonte_with_leading_space_caminho() {
8105        // The fail-before-pass-after pin for the leading ASCII space
8106        // `:caminho` shape: `(:tipo path :caminho " ../caixa-teia")`.
8107        // Until this gate landed the b94fd83 absolute arm + the a5c248e
8108        // tilde arm + the f4efe9c var arm + the d624c8d control-byte arm
8109        // all let `" ../caixa-teia"` through: `Path::is_absolute` returns
8110        // false on a leading space (the leading byte is `0x20`, not `0x2F`),
8111        // `starts_with('~')` / `starts_with('$')` return false, and `0x20`
8112        // is not in the `0x00..=0x1F` plus `0x7F` control-byte set (the
8113        // four ASCII whitespace bytes `0x09` tab, `0x0A` LF, `0x0D` CR
8114        // are caught, but the most common whitespace `0x20` space is
8115        // not). The lacre embedded the value verbatim and the resolver
8116        // folded it through `Path::join` looking for a literal `./ ../
8117        // caixa-teia` subdirectory and failing at resolve time with a
8118        // non-self-locating `No such file or directory` error far from
8119        // the source caixa.lisp. The new gate moves the check to
8120        // validate time and names the offending dep + caminho verbatim.
8121        let d = dep_with_fonte(DepSource::Path {
8122            caminho: " ../caixa-teia".into(),
8123        });
8124        let err = d.validate().unwrap_err();
8125        let DepError::FonteCaminhoLeadingWhitespace { nome, caminho } = err else {
8126            panic!("expected FonteCaminhoLeadingWhitespace, got {err:?}");
8127        };
8128        assert_eq!(nome, "caixa-teia");
8129        assert_eq!(caminho, " ../caixa-teia");
8130    }
8131
8132    #[test]
8133    fn validate_rejects_path_fonte_with_multiple_leading_spaces_caminho() {
8134        // The aligned-doc paste footgun sweep: more than one leading
8135        // space (`"   ../caixa-teia"` — the canonical "I selected the
8136        // aligned column from a four-`:fonte`-entry `:deps` block"
8137        // paste) routes through the same gate's `starts_with(' ')`
8138        // byte check. Pinned so the gate doesn't narrow to a
8139        // single-space prefix.
8140        let d = dep_with_fonte(DepSource::Path {
8141            caminho: "   ../caixa-teia".into(),
8142        });
8143        let err = d.validate().unwrap_err();
8144        assert!(
8145            matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
8146            "got {err:?}",
8147        );
8148    }
8149
8150    #[test]
8151    fn validate_accepts_path_fonte_with_mid_path_space_caminho() {
8152        // The leading-space is the canonical paste-from-aligned-doc
8153        // footgun — a space mid-path (`"../my dir/caixa-teia"` — the
8154        // canonical "I have a directory with a space in its name"
8155        // idiom; ASCII `0x20` is a valid POSIX filename byte) is a
8156        // legitimate path with no whitespace-leak semantic at the
8157        // non-leading position. Pinned so the gate doesn't widen to a
8158        // full no-space-anywhere sweep that would break every
8159        // legitimate-shape space-in-filename path.
8160        let d = dep_with_fonte(DepSource::Path {
8161            caminho: "../my dir/caixa-teia".into(),
8162        });
8163        d.validate().unwrap();
8164    }
8165
8166    #[test]
8167    fn fonte_caminho_var_fires_before_leading_whitespace() {
8168        // Cascade pin: the var-expansion arm structurally precedes the
8169        // leading-whitespace arm. A value like `"$ "` would probe positive
8170        // on var (`starts_with('$')`) but the leading-byte arms walk
8171        // left-to-right so the var arm fires on the leading `$` before
8172        // the leading-whitespace arm probes. Mirrors the
8173        // `fonte_caminho_tilde_fires_before_var_expansion` cascade
8174        // discipline on the immediate-predecessor arms.
8175        let d = dep_with_fonte(DepSource::Path {
8176            caminho: "$VAR".into(),
8177        });
8178        let err = d.validate().unwrap_err();
8179        assert!(
8180            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
8181            "got {err:?}",
8182        );
8183    }
8184
8185    #[test]
8186    fn fonte_caminho_leading_whitespace_fires_before_control_char() {
8187        // Cascade pin: the leading-whitespace arm structurally precedes
8188        // the control-char arm. A value like `" ../foo\n"` probes
8189        // positive on both (starts with space AND contains LF), but
8190        // the narrower leading-byte diagnostic
8191        // (`FonteCaminhoLeadingWhitespace`) wins so the author sees the
8192        // more self-locating paste-from-aligned-doc arm first. Mirrors
8193        // the `fonte_caminho_var_fires_before_control_char` cascade
8194        // discipline on the immediate-predecessor arm.
8195        let d = dep_with_fonte(DepSource::Path {
8196            caminho: " ../foo\n".into(),
8197        });
8198        let err = d.validate().unwrap_err();
8199        assert!(
8200            matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
8201            "got {err:?}",
8202        );
8203    }
8204
8205    #[test]
8206    fn fonte_caminho_leading_whitespace_diagnostic_carries_offending_dep_and_caminho() {
8207        // Diagnostic-shape pin (peer with
8208        // `fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho`'s
8209        // payload assertion on the immediate-predecessor arm): the
8210        // error's Display surfaces both the offending `:nome` and the
8211        // offending `:caminho` verbatim, so a `feira lint` run can
8212        // render the diagnostic without re-parsing and the author can
8213        // grep their caixa.lisp for `:caminho "<value>"` and fix it in
8214        // one edit.
8215        let d = dep_with_fonte(DepSource::Path {
8216            caminho: " ../caixa-teia".into(),
8217        });
8218        let rendered = d.validate().unwrap_err().to_string();
8219        assert!(
8220            rendered.contains("caixa-teia"),
8221            "diagnostic must name the offending dep: {rendered}",
8222        );
8223        assert!(
8224            rendered.contains(" ../caixa-teia"),
8225            "diagnostic must quote the offending caminho: {rendered}",
8226        );
8227        assert!(
8228            rendered.contains("space"),
8229            "diagnostic must name the space footgun: {rendered}",
8230        );
8231    }
8232
8233    #[test]
8234    fn fonte_caminho_absolute_fires_before_control_char() {
8235        // Cascade pin on the sibling leading-byte arm: a leading `/`
8236        // value with embedded control byte (`"/etc/passwd\n"`) routes
8237        // through `FonteCaminhoAbsolute` not `FonteCaminhoControlChar`
8238        // — the host-layout-leak diagnostic is the load-bearing axis,
8239        // the control byte is the secondary observation. Same precedence
8240        // logic on every prior leading-byte arm.
8241        let d = dep_with_fonte(DepSource::Path {
8242            caminho: "/etc/passwd\n".into(),
8243        });
8244        let err = d.validate().unwrap_err();
8245        assert!(
8246            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
8247            "got {err:?}",
8248        );
8249    }
8250
8251    #[test]
8252    fn validate_rejects_path_fonte_with_leading_hyphen_caminho() {
8253        // The fail-before-pass-after pin for the leading-`-` CLI-arg-
8254        // injection `:caminho` shape sweep. Until this gate landed
8255        // every prior leading-byte arm passed a leading-`-` value
8256        // through: `Path::is_absolute` returns false on `-` (the
8257        // leading byte is `0x2D`, not `0x2F`), `starts_with('~')` /
8258        // `starts_with('$')` / `starts_with(' ')` all return false,
8259        // and `0x2D` sits outside the control-byte set. The lacre
8260        // embedded the value verbatim and the resolver folded it
8261        // through `Path::join` looking for a literal `./-rf` /
8262        // `./-C` / `./--upload-pack=…` subdirectory; the failure at
8263        // `Path::join` time is non-self-locating but harmless, while
8264        // the failure at every downstream `git -C {caminho}` /
8265        // `terraform -chdir={caminho}` / `find {caminho}` shell-out
8266        // is arbitrary-CLI-arg-injection because none of those
8267        // porcelains carry a `--` argument-list terminator between
8268        // the flag block and the path argument. The new arm moves the
8269        // rejection to `Caixa::from_lisp` boundary time and names
8270        // the offending dep + caminho verbatim.
8271        //
8272        // Sweep spans the canonical CLI-arg-injection shapes matching
8273        // the peer sweep on the sibling `is_git_ref_name` /
8274        // `is_git_repo_url` axes: short-flag `-rf` (the `rm -rf` /
8275        // `find -rf` reinterpretation vector), `-C` (the `git -C`
8276        // change-directory-config-injection paste), long-flag
8277        // `--upload-pack=cat /etc/passwd` (the canonical
8278        // arbitrary-command-execution vector on every git porcelain
8279        // entry point), git-config-injection `--config=core.merge=ours`,
8280        // and the degenerate single-byte `-` value.
8281        for caminho in [
8282            "-rf",
8283            "-C",
8284            "--upload-pack=cat /etc/passwd",
8285            "--config=core.merge=ours",
8286            "-",
8287        ] {
8288            let d = dep_with_fonte(DepSource::Path {
8289                caminho: caminho.into(),
8290            });
8291            let err = d.validate().unwrap_err();
8292            let DepError::FonteCaminhoLeadingHyphen { nome, caminho: got } = err else {
8293                panic!("expected FonteCaminhoLeadingHyphen for {caminho:?}, got {err:?}");
8294            };
8295            assert_eq!(nome, "caixa-teia");
8296            assert_eq!(got, caminho);
8297        }
8298    }
8299
8300    #[test]
8301    fn validate_accepts_path_fonte_with_mid_path_hyphen_caminho() {
8302        // The leading-`-` is the canonical CLI-arg-injection footgun
8303        // — a `-` anywhere else in the path (`"../caixa-teia"` — the
8304        // canonical kebab-separator-between-alphanumeric-segments
8305        // shape every DNS-1123-shaped caixa name carries; `"../-hidden"`
8306        // — a mid-path segment starting with `-`, still a legitimate
8307        // POSIX filename byte at that non-leading position because the
8308        // subprocess reads the whole `{caminho}` value as one positional
8309        // argument, so only the very first byte of the composite path
8310        // string is at the CLI-arg-injection boundary) is a legitimate
8311        // path with no CLI-flag-reinterpretation semantic at the non-
8312        // leading position of the top-level value. Pinned so the gate
8313        // doesn't widen to a full no-`-`-anywhere sweep that would
8314        // break every legitimate-shape kebab-in-filename path (i.e.
8315        // essentially every sibling-workspace caixa dep).
8316        for caminho in [
8317            "../caixa-teia",
8318            "../caixa-teia/-hidden",
8319            "./my-lib",
8320            "../foo-bar/baz",
8321        ] {
8322            let d = dep_with_fonte(DepSource::Path {
8323                caminho: caminho.into(),
8324            });
8325            d.validate()
8326                .unwrap_or_else(|e| panic!("mid-path `-` caminho {caminho:?} must pass: {e:?}"));
8327        }
8328    }
8329
8330    #[test]
8331    fn fonte_caminho_leading_whitespace_fires_before_leading_hyphen() {
8332        // Cascade pin: the leading-whitespace arm structurally precedes
8333        // the leading-hyphen arm. A value like `" -rf"` probes positive
8334        // on both (leading space AND, one byte in, a `-` — though the
8335        // leading-hyphen arm probes only the very first byte so it
8336        // wouldn't fire on this value; the pin instead documents the
8337        // arm order on the more common "leading space then a hyphen"
8338        // paste-from-aligned-doc paste-flag-shell-one-liner idiom).
8339        // The narrower leading-space diagnostic (the paste-from-aligned-
8340        // doc footgun) wins so the author sees the more self-locating
8341        // whitespace arm first. Mirrors the
8342        // `fonte_caminho_var_fires_before_leading_whitespace` cascade
8343        // discipline on the immediate-predecessor arm.
8344        let d = dep_with_fonte(DepSource::Path {
8345            caminho: " -rf".into(),
8346        });
8347        let err = d.validate().unwrap_err();
8348        assert!(
8349            matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
8350            "got {err:?}",
8351        );
8352    }
8353
8354    #[test]
8355    fn fonte_caminho_leading_hyphen_fires_before_control_char() {
8356        // Cascade pin: the leading-hyphen arm structurally precedes
8357        // the control-char arm. A value like `"-rf\n"` probes positive
8358        // on both (starts with `-` AND contains LF), but the narrower
8359        // leading-byte diagnostic (`FonteCaminhoLeadingHyphen`) wins so
8360        // the author sees the more self-locating CLI-arg-injection arm
8361        // first. Mirrors the
8362        // `fonte_caminho_leading_whitespace_fires_before_control_char`
8363        // cascade discipline on the immediate-predecessor arm.
8364        let d = dep_with_fonte(DepSource::Path {
8365            caminho: "-rf\n".into(),
8366        });
8367        let err = d.validate().unwrap_err();
8368        assert!(
8369            matches!(err, DepError::FonteCaminhoLeadingHyphen { .. }),
8370            "got {err:?}",
8371        );
8372    }
8373
8374    #[test]
8375    fn fonte_caminho_leading_hyphen_diagnostic_carries_offending_dep_and_caminho() {
8376        // Diagnostic-shape pin (peer with
8377        // `fonte_caminho_leading_whitespace_diagnostic_carries_offending_dep_and_caminho`'s
8378        // payload assertion on the immediate-predecessor arm): the
8379        // error's Display surfaces both the offending `:nome` and the
8380        // offending `:caminho` verbatim plus the CLI-argument-injection
8381        // vocabulary, so a `feira lint` run can render the diagnostic
8382        // without re-parsing and the author can grep their caixa.lisp
8383        // for `:caminho "<value>"` and fix it in one edit.
8384        let d = dep_with_fonte(DepSource::Path {
8385            caminho: "--upload-pack=cat /etc/passwd".into(),
8386        });
8387        let rendered = d.validate().unwrap_err().to_string();
8388        assert!(
8389            rendered.contains("caixa-teia"),
8390            "diagnostic must name the offending dep: {rendered}",
8391        );
8392        assert!(
8393            rendered.contains("--upload-pack=cat /etc/passwd"),
8394            "diagnostic must quote the offending caminho: {rendered}",
8395        );
8396        assert!(
8397            rendered.contains("CLI-argument-injection"),
8398            "diagnostic must name the CLI-argument-injection vector: {rendered}",
8399        );
8400        assert!(
8401            rendered.contains("`-`"),
8402            "diagnostic must name the offending byte: {rendered}",
8403        );
8404    }
8405
8406    #[test]
8407    fn fonte_caminho_control_diagnostic_carries_offending_dep_caminho_byte() {
8408        // Diagnostic-shape pin (peer with
8409        // `fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho`'s
8410        // payload assertion on the immediate-predecessor arm): the
8411        // error's Display surfaces the offending `:nome`, the
8412        // offending `:caminho` verbatim, and the offending byte in
8413        // hex form (`0x09` for tab) so a `feira lint` run can render
8414        // the diagnostic without re-parsing.
8415        let d = dep_with_fonte(DepSource::Path {
8416            caminho: "../caixa\tteia".into(),
8417        });
8418        let rendered = d.validate().unwrap_err().to_string();
8419        assert!(
8420            rendered.contains("caixa-teia"),
8421            "diagnostic must name the offending dep: {rendered}",
8422        );
8423        assert!(
8424            rendered.contains("../caixa\tteia"),
8425            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
8426        );
8427        assert!(
8428            rendered.contains("0x09"),
8429            "diagnostic must name the offending byte in hex: {rendered:?}",
8430        );
8431    }
8432
8433    #[test]
8434    fn validate_rejects_path_fonte_with_caminho_carrying_backslash() {
8435        // The fail-before-pass-after pin for the canonical Windows-
8436        // path-separator paste footgun: an author who pastes a path
8437        // from Windows-Explorer's `Copy as path`, PowerShell's
8438        // `Get-Location`, or any CMD/Cygwin/MSYS shell prompt
8439        // produces `..\caixa-teia`-shape values that silently passed
8440        // every prior arm (`Path::is_absolute("..\\caixa-teia")` is
8441        // false; `\` is neither a leading-byte sentinel nor a
8442        // control byte). On POSIX resolvers the value rides through
8443        // `Path::join` as a literal directory name and fails at
8444        // resolve time with `No such file or directory`; on Windows
8445        // resolvers the value resolves to the parent's sibling — two
8446        // distinct directories for the byte-identical caixa.lisp.
8447        // The new arm moves the rejection to validate time and names
8448        // the offending dep + caminho verbatim.
8449        let d = dep_with_fonte(DepSource::Path {
8450            caminho: "..\\caixa-teia".into(),
8451        });
8452        let err = d.validate().unwrap_err();
8453        let DepError::FonteCaminhoBackslash { nome, caminho } = err else {
8454            panic!("expected FonteCaminhoBackslash, got {err:?}");
8455        };
8456        assert_eq!(nome, "caixa-teia");
8457        assert_eq!(caminho, "..\\caixa-teia");
8458    }
8459
8460    #[test]
8461    fn validate_rejects_path_fonte_with_caminho_carrying_windows_drive_letter() {
8462        // The Windows drive-letter paste shape (`C:\work\caixa-teia`
8463        // out of Explorer / `cd`-and-`pwd`-on-Windows). On POSIX
8464        // hosts `Path::is_absolute("C:\\work\\caixa-teia")` returns
8465        // false (POSIX absolute paths start with `/`, drive letters
8466        // are not a POSIX concept), so the b94fd83 absolute arm
8467        // doesn't fire; the value contains `\` bytes that this arm
8468        // now catches with the more self-locating Windows-path-
8469        // separator diagnostic. Pinned separately from the bare
8470        // `..\caixa-teia` shape so a future arm that targets only
8471        // leading-`..\` doesn't regress the drive-letter coverage.
8472        let d = dep_with_fonte(DepSource::Path {
8473            caminho: "C:\\work\\caixa-teia".into(),
8474        });
8475        let err = d.validate().unwrap_err();
8476        assert!(
8477            matches!(err, DepError::FonteCaminhoBackslash { .. }),
8478            "got {err:?}",
8479        );
8480    }
8481
8482    #[test]
8483    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_backslash() {
8484        // The trailing-`\` shape (`..\caixa-teia\` — the canonical
8485        // PowerShell tab-completion-on-a-directory append). Pinned
8486        // separately from the embedded-`\` shape so the gate's
8487        // contract is "any `\` anywhere", not "any `\` not at end".
8488        let d = dep_with_fonte(DepSource::Path {
8489            caminho: "..\\caixa-teia\\".into(),
8490        });
8491        let err = d.validate().unwrap_err();
8492        assert!(
8493            matches!(err, DepError::FonteCaminhoBackslash { .. }),
8494            "got {err:?}",
8495        );
8496    }
8497
8498    #[test]
8499    fn validate_accepts_path_fonte_with_caminho_carrying_legitimate_forward_slash() {
8500        // The positive-control pin: the gate targets `\` only,
8501        // never `/`. The canonical relative POSIX path
8502        // (`../caixa-teia/foo/bar`) must continue to validate cleanly
8503        // so legitimate nested-directory deps aren't broken. Pinned
8504        // so the gate doesn't accidentally widen to a "no path
8505        // separators at all" sweep.
8506        let d = dep_with_fonte(DepSource::Path {
8507            caminho: "../caixa-teia/foo/bar".into(),
8508        });
8509        d.validate().unwrap();
8510    }
8511
8512    #[test]
8513    fn fonte_caminho_control_char_fires_before_backslash() {
8514        // Cascade pin: the control-char arm structurally precedes the
8515        // backslash arm. A value like `"..\caixa\0teia"` probes
8516        // positive on both (`\` byte + NUL byte), but the control-
8517        // char diagnostic wins so the author sees the more self-
8518        // locating POSIX-syscall-rejected-byte diagnostic first
8519        // (NUL outright breaks `CString::new` at every `std::fs`
8520        // syscall boundary; the `\` divergence is the cross-OS-
8521        // separator axis). Mirrors the
8522        // `fonte_caminho_var_fires_before_control_char` cascade
8523        // discipline on the immediate-predecessor arm.
8524        let d = dep_with_fonte(DepSource::Path {
8525            caminho: "..\\caixa\0teia".into(),
8526        });
8527        let err = d.validate().unwrap_err();
8528        assert!(
8529            matches!(err, DepError::FonteCaminhoControlChar { .. }),
8530            "got {err:?}",
8531        );
8532    }
8533
8534    #[test]
8535    fn fonte_caminho_absolute_fires_before_backslash() {
8536        // Cascade pin on the load-bearing leading-byte arm: a leading
8537        // `/` value with embedded `\` (`/etc/passwd\foo`) routes
8538        // through `FonteCaminhoAbsolute` not `FonteCaminhoBackslash`
8539        // — the host-layout-leak diagnostic is the load-bearing
8540        // axis, the `\` byte is the secondary observation. Same
8541        // precedence logic as every prior leading-byte arm.
8542        let d = dep_with_fonte(DepSource::Path {
8543            caminho: "/etc/passwd\\foo".into(),
8544        });
8545        let err = d.validate().unwrap_err();
8546        assert!(
8547            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
8548            "got {err:?}",
8549        );
8550    }
8551
8552    #[test]
8553    fn fonte_caminho_var_fires_before_backslash() {
8554        // Cascade pin on the var-expansion arm: a leading-`$` value
8555        // with embedded `\` (`$WORKSPACE\caixa-teia` — the canonical
8556        // PowerShell-env-var paste-from-CI-manifest footgun) routes
8557        // through `FonteCaminhoVarExpansion` not `FonteCaminhoBackslash`.
8558        // The shell-expansion diagnostic is the more self-locating
8559        // axis since both the leading `$` and the embedded `\`
8560        // are Windows-shell artifacts but the `$` is the root-cause
8561        // surface (an author who removes the `$` is likely to leave
8562        // the `\` too).
8563        let d = dep_with_fonte(DepSource::Path {
8564            caminho: "$WORKSPACE\\caixa-teia".into(),
8565        });
8566        let err = d.validate().unwrap_err();
8567        assert!(
8568            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
8569            "got {err:?}",
8570        );
8571    }
8572
8573    #[test]
8574    fn fonte_caminho_backslash_diagnostic_carries_offending_dep_and_caminho() {
8575        // Diagnostic-shape pin (peer with the prior
8576        // `fonte_caminho_*_diagnostic_carries_*` payload assertions
8577        // on every preceding arm): the error's Display surfaces the
8578        // offending `:nome` and the offending `:caminho` verbatim
8579        // so a `feira lint` run can render the diagnostic without
8580        // re-parsing.
8581        let d = dep_with_fonte(DepSource::Path {
8582            caminho: "..\\caixa-teia".into(),
8583        });
8584        let rendered = d.validate().unwrap_err().to_string();
8585        assert!(
8586            rendered.contains("caixa-teia"),
8587            "diagnostic must name the offending dep: {rendered}",
8588        );
8589        assert!(
8590            rendered.contains("..\\caixa-teia"),
8591            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
8592        );
8593        assert!(
8594            rendered.contains('\\'),
8595            "diagnostic must reference the backslash footgun: {rendered:?}",
8596        );
8597    }
8598
8599    #[test]
8600    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_slash() {
8601        // The fail-before-pass-after pin for the canonical trailing-`/`
8602        // paste footgun: an author who shell-tab-completes a sibling
8603        // directory (every interactive shell — bash/zsh/fish/nushell —
8604        // appends `/` on tab-completing a directory) produces
8605        // `"../caixa-teia/"`-shape values that silently passed every
8606        // prior arm (the leading byte is `.`, no control bytes, no
8607        // backslash). `Path::join` resolves both shapes to the same
8608        // directory at the resolver, but the lacre embeds the value
8609        // verbatim and the BLAKE3 closures diverge across two
8610        // workstations whose authors differ only in tab-completion
8611        // habits.
8612        let d = dep_with_fonte(DepSource::Path {
8613            caminho: "../caixa-teia/".into(),
8614        });
8615        let err = d.validate().unwrap_err();
8616        let DepError::FonteCaminhoTrailingSlash { nome, caminho } = err else {
8617            panic!("expected FonteCaminhoTrailingSlash, got {err:?}");
8618        };
8619        assert_eq!(nome, "caixa-teia");
8620        assert_eq!(caminho, "../caixa-teia/");
8621    }
8622
8623    #[test]
8624    fn validate_rejects_path_fonte_with_caminho_carrying_bare_dot_slash() {
8625        // The `"./"` shape (the canonical "I meant the caixa.lisp's own
8626        // directory and tab-completed it" footgun). Pinned separately
8627        // from the canonical `"../caixa-teia/"` shape so the gate's
8628        // contract is "any trailing `/`", not "trailing `/` after a leaf
8629        // name".
8630        let d = dep_with_fonte(DepSource::Path {
8631            caminho: "./".into(),
8632        });
8633        let err = d.validate().unwrap_err();
8634        assert!(
8635            matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
8636            "got {err:?}",
8637        );
8638    }
8639
8640    #[test]
8641    fn validate_rejects_path_fonte_with_caminho_carrying_consecutive_trailing_slashes() {
8642        // The `"foo//"` shape (the canonical "I pasted from a CI manifest
8643        // that double-templated `${VAR}/` over an already-`/`-suffixed
8644        // path" footgun). The gate fires on the last byte being `/`
8645        // regardless of how many `/` precede it; the arm contract is
8646        // "the value ends with `/`", structurally.
8647        let d = dep_with_fonte(DepSource::Path {
8648            caminho: "../caixa-teia//".into(),
8649        });
8650        let err = d.validate().unwrap_err();
8651        assert!(
8652            matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
8653            "got {err:?}",
8654        );
8655    }
8656
8657    #[test]
8658    fn validate_rejects_path_fonte_with_caminho_carrying_dotdot_trailing_slash() {
8659        // The `"../"` shape (the canonical "I want the parent" tab-
8660        // completion footgun on a bare `..` path). Pinned separately so
8661        // the gate doesn't accidentally narrow to "trailing `/` only on
8662        // multi-segment paths".
8663        let d = dep_with_fonte(DepSource::Path {
8664            caminho: "../".into(),
8665        });
8666        let err = d.validate().unwrap_err();
8667        assert!(
8668            matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
8669            "got {err:?}",
8670        );
8671    }
8672
8673    #[test]
8674    fn validate_accepts_path_fonte_with_caminho_carrying_internal_slashes() {
8675        // The positive-control pin: the gate targets the trailing byte
8676        // only, never internal `/` separators. The canonical nested
8677        // relative POSIX path (`"../caixa-teia/foo/bar"`) must continue
8678        // to validate cleanly so legitimate deeply-nested deps aren't
8679        // broken. Pinned so the gate doesn't accidentally widen to a
8680        // "no `/` separators anywhere" sweep that would defeat the
8681        // entire path-fonte author surface.
8682        let d = dep_with_fonte(DepSource::Path {
8683            caminho: "../caixa-teia/foo/bar".into(),
8684        });
8685        d.validate().unwrap();
8686    }
8687
8688    #[test]
8689    fn validate_accepts_path_fonte_with_caminho_carrying_bare_dot() {
8690        // The positive-control pin on the degenerate single-`.` shape
8691        // (the canonical "the caixa.lisp's own directory" idiom). The
8692        // gate fires on the trailing byte being `/`, not on the path
8693        // being short, so `"."` (one byte, not `/`) must continue to
8694        // validate cleanly.
8695        let d = dep_with_fonte(DepSource::Path {
8696            caminho: ".".into(),
8697        });
8698        d.validate().unwrap();
8699    }
8700
8701    #[test]
8702    fn fonte_caminho_control_char_fires_before_trailing_slash() {
8703        // Cascade pin: the control-char arm structurally precedes the
8704        // trailing-slash arm. A value like `"../foo\n/"` ends in `/`
8705        // but the embedded LF (`0x0A`) is the load-bearing diagnostic
8706        // (control bytes are the paste-from-multiline-doc footgun the
8707        // d624c8d arm already closes). Mirrors the
8708        // `fonte_caminho_control_char_fires_before_backslash` cascade
8709        // discipline on the immediate-predecessor arm.
8710        let d = dep_with_fonte(DepSource::Path {
8711            caminho: "../foo\n/".into(),
8712        });
8713        let err = d.validate().unwrap_err();
8714        assert!(
8715            matches!(err, DepError::FonteCaminhoControlChar { .. }),
8716            "got {err:?}",
8717        );
8718    }
8719
8720    #[test]
8721    fn fonte_caminho_backslash_fires_before_trailing_slash() {
8722        // Cascade pin on the backslash arm: a value like `"..\foo/"`
8723        // ends in `/` but the embedded `\` is the load-bearing
8724        // diagnostic (the cross-host-OS-separator divergence vector
8725        // the 3a4e1d7 arm closes). Same precedence logic as the prior
8726        // narrower-diagnostic-first cascade.
8727        let d = dep_with_fonte(DepSource::Path {
8728            caminho: "..\\caixa-teia/".into(),
8729        });
8730        let err = d.validate().unwrap_err();
8731        assert!(
8732            matches!(err, DepError::FonteCaminhoBackslash { .. }),
8733            "got {err:?}",
8734        );
8735    }
8736
8737    #[test]
8738    fn fonte_caminho_absolute_fires_before_trailing_slash() {
8739        // Cascade pin on the load-bearing leading-byte arm: a leading
8740        // `/` value with a trailing `/` (`"/etc/passwd/"`) routes
8741        // through `FonteCaminhoAbsolute` not `FonteCaminhoTrailingSlash`
8742        // — the host-layout-leak diagnostic is the load-bearing axis,
8743        // the trailing `/` is the secondary observation. Same
8744        // precedence logic as every prior leading-byte arm.
8745        let d = dep_with_fonte(DepSource::Path {
8746            caminho: "/etc/passwd/".into(),
8747        });
8748        let err = d.validate().unwrap_err();
8749        assert!(
8750            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
8751            "got {err:?}",
8752        );
8753    }
8754
8755    #[test]
8756    fn fonte_caminho_trailing_slash_diagnostic_carries_offending_dep_and_caminho() {
8757        // Diagnostic-shape pin (peer with the prior
8758        // `fonte_caminho_*_diagnostic_carries_*` payload assertions on
8759        // every preceding arm): the error's Display surfaces the
8760        // offending `:nome` and the offending `:caminho` verbatim so a
8761        // `feira lint` run can render the diagnostic without re-parsing.
8762        let d = dep_with_fonte(DepSource::Path {
8763            caminho: "../caixa-teia/".into(),
8764        });
8765        let rendered = d.validate().unwrap_err().to_string();
8766        assert!(
8767            rendered.contains("caixa-teia"),
8768            "diagnostic must name the offending dep: {rendered}",
8769        );
8770        assert!(
8771            rendered.contains("../caixa-teia/"),
8772            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
8773        );
8774        assert!(
8775            rendered.contains("trailing"),
8776            "diagnostic must reference the trailing-slash footgun: {rendered:?}",
8777        );
8778    }
8779
8780    // -- :caminho shell-redirection metacharacter arm -----------------------
8781
8782    #[test]
8783    fn validate_rejects_path_fonte_with_caminho_carrying_gt_redirection() {
8784        // The fail-before-pass-after pin for the canonical output-redirection
8785        // paste footgun: an author copies a shell pipeline tail
8786        // (`"../caixa-teia>build.log"` — the canonical "I selected the whole
8787        // line including the `> build.log` redirect" idiom) and silently
8788        // passed every prior arm (`Path::is_absolute` false on `..`, no
8789        // control bytes, no backslash, doesn't end in `/`). The lacre
8790        // embedded the value verbatim, the resolver folded it through
8791        // `Path::join` looking for a literal `./../caixa-teia>build.log`
8792        // subdirectory, and the failure surfaced at resolve time with a
8793        // non-self-locating `No such file or directory` error. The new arm
8794        // moves the rejection to validate time and names the offending dep
8795        // + caminho + byte verbatim.
8796        let d = dep_with_fonte(DepSource::Path {
8797            caminho: "../caixa-teia>build.log".into(),
8798        });
8799        let err = d.validate().unwrap_err();
8800        let DepError::FonteCaminhoShellRedirection {
8801            nome,
8802            caminho,
8803            byte,
8804        } = err
8805        else {
8806            panic!("expected FonteCaminhoShellRedirection, got {err:?}");
8807        };
8808        assert_eq!(nome, "caixa-teia");
8809        assert_eq!(caminho, "../caixa-teia>build.log");
8810        assert_eq!(byte, b'>');
8811    }
8812
8813    #[test]
8814    fn validate_rejects_path_fonte_with_caminho_carrying_lt_redirection() {
8815        // The symmetric input-redirection paste shape
8816        // (`"../caixa-teia<input.lisp"` — the canonical "I copied a
8817        // `command < input.lisp` line from a tatara-lisp REPL log"
8818        // idiom). Pinned separately from the `>` shape so the gate's
8819        // contract is "any `<` or `>` anywhere", not single-byte coverage.
8820        let d = dep_with_fonte(DepSource::Path {
8821            caminho: "../caixa-teia<input.lisp".into(),
8822        });
8823        let err = d.validate().unwrap_err();
8824        let DepError::FonteCaminhoShellRedirection { byte, .. } = err else {
8825            panic!("expected FonteCaminhoShellRedirection, got {err:?}");
8826        };
8827        assert_eq!(byte, b'<');
8828    }
8829
8830    #[test]
8831    fn validate_rejects_path_fonte_with_caminho_carrying_leading_gt_redirection() {
8832        // Leading-position `>` shape (`">../caixa-teia"` — the degenerate
8833        // "I forgot the source side of the redirect" idiom). Pinned
8834        // separately from the embedded-byte shapes so the gate covers
8835        // every position, not only mid-path.
8836        let d = dep_with_fonte(DepSource::Path {
8837            caminho: ">../caixa-teia".into(),
8838        });
8839        let err = d.validate().unwrap_err();
8840        assert!(
8841            matches!(
8842                err,
8843                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
8844            ),
8845            "got {err:?}",
8846        );
8847    }
8848
8849    #[test]
8850    fn validate_rejects_path_fonte_with_caminho_carrying_double_gt_append() {
8851        // The bash append-redirection shape (`"../caixa-teia>>build.log"` —
8852        // the canonical "I copied a `>>` append redirect" idiom). The arm
8853        // fires on the first `>` encountered; pinned so a future arm that
8854        // tries to distinguish `>` from `>>` doesn't break the broader
8855        // contract.
8856        let d = dep_with_fonte(DepSource::Path {
8857            caminho: "../caixa-teia>>build.log".into(),
8858        });
8859        let err = d.validate().unwrap_err();
8860        assert!(
8861            matches!(
8862                err,
8863                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
8864            ),
8865            "got {err:?}",
8866        );
8867    }
8868
8869    #[test]
8870    fn validate_accepts_path_fonte_with_caminho_carrying_no_redirection() {
8871        // The positive-control pin: the gate targets only `<` / `>`,
8872        // never adjacent printable ASCII or POSIX-valid bytes. The
8873        // canonical relative POSIX path (`"../caixa-teia"`) and a
8874        // nested deeply-pathed variant (`"../caixa-teia/foo/bar"`) must
8875        // continue to validate cleanly so the gate doesn't widen to a
8876        // "no printable punctuation anywhere" sweep that would defeat
8877        // the entire path-fonte author surface.
8878        let d = dep_with_fonte(DepSource::Path {
8879            caminho: "../caixa-teia/foo/bar".into(),
8880        });
8881        d.validate().unwrap();
8882    }
8883
8884    #[test]
8885    fn fonte_caminho_backslash_fires_before_shell_redirection() {
8886        // Cascade pin on the immediate-predecessor arm: a value carrying
8887        // both `\` and `<` / `>` (`"..\caixa-teia>build.log"` — the
8888        // canonical "I pasted a Windows-shell command with output
8889        // redirect" footgun) routes through `FonteCaminhoBackslash` not
8890        // `FonteCaminhoShellRedirection`. The cross-host-OS-separator
8891        // divergence is the load-bearing axis (an author who removes
8892        // the `\` is the root-cause edit; the `>` falls away in the
8893        // same edit since it's downstream of the Windows-shell
8894        // convention).
8895        let d = dep_with_fonte(DepSource::Path {
8896            caminho: "..\\caixa-teia>build.log".into(),
8897        });
8898        let err = d.validate().unwrap_err();
8899        assert!(
8900            matches!(err, DepError::FonteCaminhoBackslash { .. }),
8901            "got {err:?}",
8902        );
8903    }
8904
8905    #[test]
8906    fn fonte_caminho_control_char_fires_before_shell_redirection() {
8907        // Cascade pin on the embedded-control-byte arm: a value carrying
8908        // both a control byte and `<` / `>` (`"../foo\n>bar"` — the
8909        // canonical paste-from-multiline-doc footgun where a newline
8910        // landed mid-caminho) routes through `FonteCaminhoControlChar`
8911        // not `FonteCaminhoShellRedirection`. The POSIX-syscall-
8912        // rejected-byte / NUL-`CString::new`-fail diagnostic is the
8913        // load-bearing axis on every value that probes positive for
8914        // both — mirrors the cascade discipline on every prior arm.
8915        let d = dep_with_fonte(DepSource::Path {
8916            caminho: "../foo\n>bar".into(),
8917        });
8918        let err = d.validate().unwrap_err();
8919        assert!(
8920            matches!(err, DepError::FonteCaminhoControlChar { .. }),
8921            "got {err:?}",
8922        );
8923    }
8924
8925    #[test]
8926    fn fonte_caminho_absolute_fires_before_shell_redirection() {
8927        // Cascade pin on the load-bearing leading-byte arm: a leading
8928        // `/` value with embedded `<` / `>` (`"/etc/passwd>out"`)
8929        // routes through `FonteCaminhoAbsolute` not
8930        // `FonteCaminhoShellRedirection` — the host-layout-leak
8931        // diagnostic is the load-bearing axis, the `>` byte is the
8932        // secondary observation. Same precedence logic as every prior
8933        // leading-byte arm.
8934        let d = dep_with_fonte(DepSource::Path {
8935            caminho: "/etc/passwd>out".into(),
8936        });
8937        let err = d.validate().unwrap_err();
8938        assert!(
8939            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
8940            "got {err:?}",
8941        );
8942    }
8943
8944    #[test]
8945    fn fonte_caminho_shell_redirection_fires_before_trailing_slash() {
8946        // Cascade pin on the immediate-successor arm: a value carrying
8947        // both `<` / `>` and a trailing `/` (`"../foo></"` — the
8948        // canonical "I tab-completed a path that already had a
8949        // redirect" footgun) routes through `FonteCaminhoShellRedirection`
8950        // not `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
8951        // the more semantic-locating axis (an author who removes the
8952        // `<` / `>` typically also drops the trailing separator since
8953        // both are paste-from-shell artifacts).
8954        let d = dep_with_fonte(DepSource::Path {
8955            caminho: "../foo></".into(),
8956        });
8957        let err = d.validate().unwrap_err();
8958        assert!(
8959            matches!(
8960                err,
8961                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
8962            ),
8963            "got {err:?}",
8964        );
8965    }
8966
8967    #[test]
8968    fn fonte_caminho_shell_redirection_diagnostic_carries_offending_dep_caminho_byte() {
8969        // Diagnostic-shape pin (peer with
8970        // `fonte_caminho_control_diagnostic_carries_offending_dep_caminho_byte`'s
8971        // payload assertion on the closest peer arm that also carries a
8972        // `byte` field): the error's Display surfaces the offending
8973        // `:nome`, the offending `:caminho` verbatim, and the offending
8974        // byte in hex (`0x3c` for `<`, `0x3e` for `>`) so a `feira lint`
8975        // run can render the diagnostic without re-parsing.
8976        let d = dep_with_fonte(DepSource::Path {
8977            caminho: "../caixa-teia>build.log".into(),
8978        });
8979        let rendered = d.validate().unwrap_err().to_string();
8980        assert!(
8981            rendered.contains("caixa-teia"),
8982            "diagnostic must name the offending dep: {rendered}",
8983        );
8984        assert!(
8985            rendered.contains("../caixa-teia>build.log"),
8986            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
8987        );
8988        assert!(
8989            rendered.contains("0x3e"),
8990            "diagnostic must name the offending byte in hex: {rendered:?}",
8991        );
8992        assert!(
8993            rendered.contains("redirection"),
8994            "diagnostic must name the shell-redirection footgun: {rendered:?}",
8995        );
8996    }
8997
8998    // -- :caminho shell-pipe metacharacter arm ----------------------------
8999
9000    #[test]
9001    fn validate_rejects_path_fonte_with_caminho_carrying_pipe() {
9002        // The fail-before-pass-after pin for the canonical shell-pipe
9003        // paste footgun: an author copies a shell-history line
9004        // (`"../caixa-teia | grep foo"` — the canonical "I selected
9005        // the whole `ls dir | grep` line out of zsh history") and
9006        // silently passed every prior arm (`Path::is_absolute` false
9007        // on `..`, no control bytes, no backslash, no `<` / `>`,
9008        // doesn't end in `/`). The lacre embedded the value verbatim,
9009        // the resolver folded it through `Path::join` looking for a
9010        // literal `./../caixa-teia | grep foo` subdirectory, and the
9011        // failure surfaced at resolve time with a non-self-locating
9012        // `No such file or directory` error. The new arm moves the
9013        // rejection to validate time and names the offending dep +
9014        // caminho verbatim.
9015        let d = dep_with_fonte(DepSource::Path {
9016            caminho: "../caixa-teia | grep foo".into(),
9017        });
9018        let err = d.validate().unwrap_err();
9019        let DepError::FonteCaminhoShellPipe { nome, caminho } = err else {
9020            panic!("expected FonteCaminhoShellPipe, got {err:?}");
9021        };
9022        assert_eq!(nome, "caixa-teia");
9023        assert_eq!(caminho, "../caixa-teia | grep foo");
9024    }
9025
9026    #[test]
9027    fn validate_rejects_path_fonte_with_caminho_carrying_leading_pipe() {
9028        // Leading-position `|` shape (`"|../caixa-teia"` — the
9029        // degenerate "I forgot the source side of the pipe" idiom).
9030        // Pinned separately from the embedded-byte shape so the gate
9031        // covers every position, not only mid-path.
9032        let d = dep_with_fonte(DepSource::Path {
9033            caminho: "|../caixa-teia".into(),
9034        });
9035        let err = d.validate().unwrap_err();
9036        assert!(
9037            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
9038            "got {err:?}",
9039        );
9040    }
9041
9042    #[test]
9043    fn validate_rejects_path_fonte_with_caminho_carrying_double_pipe_or() {
9044        // The bash short-circuit-OR shape (`"../caixa-teia||fallback"`
9045        // — the canonical "I copied a `cmd-a || cmd-b` fallback line"
9046        // idiom). The arm fires on the first `|` encountered; pinned
9047        // so a future arm that tries to distinguish `|` from `||`
9048        // doesn't break the broader contract.
9049        let d = dep_with_fonte(DepSource::Path {
9050            caminho: "../caixa-teia||fallback".into(),
9051        });
9052        let err = d.validate().unwrap_err();
9053        assert!(
9054            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
9055            "got {err:?}",
9056        );
9057    }
9058
9059    #[test]
9060    fn validate_accepts_path_fonte_with_caminho_carrying_no_pipe() {
9061        // The positive-control pin: the gate targets only `|`, never
9062        // adjacent printable ASCII or POSIX-valid bytes. The canonical
9063        // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
9064        // pathed variant with adjacent printable punctuation
9065        // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
9066        // cleanly so the gate doesn't widen to a "no printable
9067        // punctuation anywhere" sweep that would defeat the entire
9068        // path-fonte author surface.
9069        let d = dep_with_fonte(DepSource::Path {
9070            caminho: "../caixa-teia/sub-dir.v2".into(),
9071        });
9072        d.validate().unwrap();
9073    }
9074
9075    #[test]
9076    fn fonte_caminho_shell_redirection_fires_before_shell_pipe() {
9077        // Cascade pin on the immediate-predecessor arm: a value carrying
9078        // both `<` / `>` and `|` (`"../caixa-teia<input|tee"` — the
9079        // canonical "I pasted a `cmd < input | tee` pipeline tail"
9080        // footgun) routes through `FonteCaminhoShellRedirection` not
9081        // `FonteCaminhoShellPipe`. The input/output redirection
9082        // metachar carries the more self-locating `byte: u8` payload
9083        // (it names which of `<` or `>` triggered), so the prior arm
9084        // wins on every probe-as-both value — same cascade discipline
9085        // every prior `:caminho` arm establishes.
9086        let d = dep_with_fonte(DepSource::Path {
9087            caminho: "../caixa-teia<input|tee".into(),
9088        });
9089        let err = d.validate().unwrap_err();
9090        assert!(
9091            matches!(
9092                err,
9093                DepError::FonteCaminhoShellRedirection { byte: b'<', .. }
9094            ),
9095            "got {err:?}",
9096        );
9097    }
9098
9099    #[test]
9100    fn fonte_caminho_backslash_fires_before_shell_pipe() {
9101        // Cascade pin on the upstream backslash arm: a value carrying
9102        // both `\` and `|` (`"..\caixa-teia|tee"` — the canonical
9103        // "I pasted a Windows-shell command with pipe to tee"
9104        // footgun) routes through `FonteCaminhoBackslash` not
9105        // `FonteCaminhoShellPipe`. The cross-host-OS-separator
9106        // divergence is the load-bearing axis on every probe-as-both
9107        // value (an author who removes the `\` is the root-cause edit;
9108        // the `|` falls away in the same edit since it's downstream of
9109        // the Windows-shell convention).
9110        let d = dep_with_fonte(DepSource::Path {
9111            caminho: "..\\caixa-teia|tee".into(),
9112        });
9113        let err = d.validate().unwrap_err();
9114        assert!(
9115            matches!(err, DepError::FonteCaminhoBackslash { .. }),
9116            "got {err:?}",
9117        );
9118    }
9119
9120    #[test]
9121    fn fonte_caminho_control_char_fires_before_shell_pipe() {
9122        // Cascade pin on the embedded-control-byte arm: a value
9123        // carrying both a control byte and `|` (`"../foo\n|bar"` —
9124        // the canonical paste-from-multiline-doc footgun where a
9125        // newline landed mid-caminho) routes through
9126        // `FonteCaminhoControlChar` not `FonteCaminhoShellPipe`. The
9127        // POSIX-syscall-rejected-byte / NUL-`CString::new`-fail
9128        // diagnostic is the load-bearing axis on every value that
9129        // probes positive for both — mirrors the cascade discipline
9130        // on every prior arm.
9131        let d = dep_with_fonte(DepSource::Path {
9132            caminho: "../foo\n|bar".into(),
9133        });
9134        let err = d.validate().unwrap_err();
9135        assert!(
9136            matches!(err, DepError::FonteCaminhoControlChar { .. }),
9137            "got {err:?}",
9138        );
9139    }
9140
9141    #[test]
9142    fn fonte_caminho_absolute_fires_before_shell_pipe() {
9143        // Cascade pin on the load-bearing leading-byte arm: a leading
9144        // `/` value with embedded `|` (`"/etc/passwd|tee"`) routes
9145        // through `FonteCaminhoAbsolute` not `FonteCaminhoShellPipe`
9146        // — the host-layout-leak diagnostic is the load-bearing axis,
9147        // the `|` byte is the secondary observation. Same precedence
9148        // logic as every prior leading-byte arm.
9149        let d = dep_with_fonte(DepSource::Path {
9150            caminho: "/etc/passwd|tee".into(),
9151        });
9152        let err = d.validate().unwrap_err();
9153        assert!(
9154            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
9155            "got {err:?}",
9156        );
9157    }
9158
9159    #[test]
9160    fn fonte_caminho_shell_pipe_fires_before_trailing_slash() {
9161        // Cascade pin on the immediate-successor arm: a value carrying
9162        // both `|` and a trailing `/` (`"../foo|tee/"` — the canonical
9163        // "I tab-completed a path that already had a pipeline tail"
9164        // footgun) routes through `FonteCaminhoShellPipe` not
9165        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
9166        // the more semantic-locating axis (an author who removes the
9167        // `|` typically also drops the trailing separator since both
9168        // are paste-from-shell artifacts).
9169        let d = dep_with_fonte(DepSource::Path {
9170            caminho: "../foo|tee/".into(),
9171        });
9172        let err = d.validate().unwrap_err();
9173        assert!(
9174            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
9175            "got {err:?}",
9176        );
9177    }
9178
9179    #[test]
9180    fn fonte_caminho_shell_pipe_diagnostic_carries_offending_dep_and_caminho() {
9181        // Diagnostic-shape pin (peer with
9182        // `fonte_caminho_backslash_diagnostic_carries_offending_dep_and_caminho`
9183        // on the closest single-byte peer arm): the error's Display
9184        // surfaces the offending `:nome` and the offending `:caminho`
9185        // verbatim, and names the shell-pipe footgun explicitly so a
9186        // `feira lint` run can render the diagnostic without
9187        // re-parsing.
9188        let d = dep_with_fonte(DepSource::Path {
9189            caminho: "../caixa-teia | grep foo".into(),
9190        });
9191        let rendered = d.validate().unwrap_err().to_string();
9192        assert!(
9193            rendered.contains("caixa-teia"),
9194            "diagnostic must name the offending dep: {rendered}",
9195        );
9196        assert!(
9197            rendered.contains("../caixa-teia | grep foo"),
9198            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
9199        );
9200        assert!(
9201            rendered.contains('|'),
9202            "diagnostic must reference the pipe footgun: {rendered:?}",
9203        );
9204        assert!(
9205            rendered.contains("pipe"),
9206            "diagnostic must name the shell-pipe footgun: {rendered:?}",
9207        );
9208    }
9209
9210    // -- :caminho shell-command-separator metacharacter arm ---------------
9211
9212    #[test]
9213    fn validate_rejects_path_fonte_with_caminho_carrying_semicolon() {
9214        // The fail-before-pass-after pin for the canonical shell-command-
9215        // separator paste footgun: an author copies a shell one-liner
9216        // (`"../caixa-teia; rm -rf build"` — the canonical "I selected the
9217        // whole `cd path; do-thing` chain out of a shell-history block")
9218        // and silently passed every prior arm (`Path::is_absolute` false
9219        // on `..`, no control bytes, no backslash, no `<` / `>`, no `|`,
9220        // doesn't end in `/`). The lacre embedded the value verbatim, the
9221        // resolver folded it through `Path::join` looking for a literal
9222        // `./../caixa-teia; rm -rf build` subdirectory, and the failure
9223        // surfaced at resolve time with a non-self-locating `No such file
9224        // or directory` error. The new arm moves the rejection to validate
9225        // time and names the offending dep + caminho verbatim.
9226        let d = dep_with_fonte(DepSource::Path {
9227            caminho: "../caixa-teia; rm -rf build".into(),
9228        });
9229        let err = d.validate().unwrap_err();
9230        let DepError::FonteCaminhoShellSemicolon { nome, caminho } = err else {
9231            panic!("expected FonteCaminhoShellSemicolon, got {err:?}");
9232        };
9233        assert_eq!(nome, "caixa-teia");
9234        assert_eq!(caminho, "../caixa-teia; rm -rf build");
9235    }
9236
9237    #[test]
9238    fn validate_rejects_path_fonte_with_caminho_carrying_leading_semicolon() {
9239        // Leading-position `;` shape (`";../caixa-teia"` — the degenerate
9240        // "I forgot the prior command side of the separator" idiom).
9241        // Pinned separately from the embedded-byte shape so the gate
9242        // covers every position, not only mid-path.
9243        let d = dep_with_fonte(DepSource::Path {
9244            caminho: ";../caixa-teia".into(),
9245        });
9246        let err = d.validate().unwrap_err();
9247        assert!(
9248            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
9249            "got {err:?}",
9250        );
9251    }
9252
9253    #[test]
9254    fn validate_rejects_path_fonte_with_caminho_carrying_double_semicolon() {
9255        // The POSIX `case` arm `;;` terminator shape
9256        // (`"../caixa-teia;;next"` — the canonical "I copied a `case`
9257        // arm tail" idiom). The arm fires on the first `;` encountered;
9258        // pinned so a future arm that tries to distinguish `;` from `;;`
9259        // doesn't break the broader contract.
9260        let d = dep_with_fonte(DepSource::Path {
9261            caminho: "../caixa-teia;;next".into(),
9262        });
9263        let err = d.validate().unwrap_err();
9264        assert!(
9265            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
9266            "got {err:?}",
9267        );
9268    }
9269
9270    #[test]
9271    fn validate_accepts_path_fonte_with_caminho_carrying_no_semicolon() {
9272        // The positive-control pin: the gate targets only `;`, never
9273        // adjacent printable ASCII or POSIX-valid bytes. The canonical
9274        // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
9275        // pathed variant with adjacent printable punctuation
9276        // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
9277        // cleanly so the gate doesn't widen to a "no printable
9278        // punctuation anywhere" sweep that would defeat the entire
9279        // path-fonte author surface.
9280        let d = dep_with_fonte(DepSource::Path {
9281            caminho: "../caixa-teia/sub-dir.v2".into(),
9282        });
9283        d.validate().unwrap();
9284    }
9285
9286    #[test]
9287    fn fonte_caminho_shell_pipe_fires_before_shell_semicolon() {
9288        // Cascade pin on the immediate-predecessor arm: a value carrying
9289        // both `|` and `;` (`"../caixa-teia | tee; rm"` — the canonical
9290        // "I pasted a `cmd | tee; cleanup` chain" footgun) routes through
9291        // `FonteCaminhoShellPipe` not `FonteCaminhoShellSemicolon`. The
9292        // pipeline-tail paste is the load-bearing root-cause edit on
9293        // every probe-as-both value (an author who removes the `|`
9294        // typically also drops the trailing `; cleanup` since both are
9295        // the same paste-from-shell-history artifact) — same cascade
9296        // discipline every prior `:caminho` arm establishes.
9297        let d = dep_with_fonte(DepSource::Path {
9298            caminho: "../caixa-teia | tee; rm".into(),
9299        });
9300        let err = d.validate().unwrap_err();
9301        assert!(
9302            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
9303            "got {err:?}",
9304        );
9305    }
9306
9307    #[test]
9308    fn fonte_caminho_shell_redirection_fires_before_shell_semicolon() {
9309        // Cascade pin on the upstream shell-redirection arm: a value
9310        // carrying both `<` / `>` and `;` (`"../caixa-teia>log; rm"` —
9311        // the canonical "I pasted a `cmd > log; cleanup` chain"
9312        // footgun) routes through `FonteCaminhoShellRedirection` not
9313        // `FonteCaminhoShellSemicolon`. The input/output redirection
9314        // metachar carries the more self-locating `byte: u8` payload
9315        // (it names which of `<` or `>` triggered), so the prior arm
9316        // wins on every probe-as-both value.
9317        let d = dep_with_fonte(DepSource::Path {
9318            caminho: "../caixa-teia>log; rm".into(),
9319        });
9320        let err = d.validate().unwrap_err();
9321        assert!(
9322            matches!(
9323                err,
9324                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
9325            ),
9326            "got {err:?}",
9327        );
9328    }
9329
9330    #[test]
9331    fn fonte_caminho_backslash_fires_before_shell_semicolon() {
9332        // Cascade pin on the upstream backslash arm: a value carrying
9333        // both `\` and `;` (`"..\caixa-teia;rm"` — the canonical "I
9334        // pasted a Windows-shell `cd ..\path; cleanup` chain") routes
9335        // through `FonteCaminhoBackslash` not `FonteCaminhoShellSemicolon`.
9336        // The cross-host-OS-separator divergence is the load-bearing axis
9337        // on every probe-as-both value (an author who removes the `\` is
9338        // the root-cause edit; the `;` falls away in the same edit since
9339        // it's downstream of the Windows-shell convention).
9340        let d = dep_with_fonte(DepSource::Path {
9341            caminho: "..\\caixa-teia;rm".into(),
9342        });
9343        let err = d.validate().unwrap_err();
9344        assert!(
9345            matches!(err, DepError::FonteCaminhoBackslash { .. }),
9346            "got {err:?}",
9347        );
9348    }
9349
9350    #[test]
9351    fn fonte_caminho_control_char_fires_before_shell_semicolon() {
9352        // Cascade pin on the embedded-control-byte arm: a value carrying
9353        // both a control byte and `;` (`"../foo\n;bar"` — the canonical
9354        // paste-from-multiline-doc footgun where a newline landed mid-
9355        // caminho) routes through `FonteCaminhoControlChar` not
9356        // `FonteCaminhoShellSemicolon`. The POSIX-syscall-rejected-byte
9357        // / NUL-`CString::new`-fail diagnostic is the load-bearing axis
9358        // on every value that probes positive for both — mirrors the
9359        // cascade discipline on every prior arm.
9360        let d = dep_with_fonte(DepSource::Path {
9361            caminho: "../foo\n;bar".into(),
9362        });
9363        let err = d.validate().unwrap_err();
9364        assert!(
9365            matches!(err, DepError::FonteCaminhoControlChar { .. }),
9366            "got {err:?}",
9367        );
9368    }
9369
9370    #[test]
9371    fn fonte_caminho_absolute_fires_before_shell_semicolon() {
9372        // Cascade pin on the load-bearing leading-byte arm: a leading
9373        // `/` value with embedded `;` (`"/etc/passwd;rm"`) routes
9374        // through `FonteCaminhoAbsolute` not `FonteCaminhoShellSemicolon`
9375        // — the host-layout-leak diagnostic is the load-bearing axis,
9376        // the `;` byte is the secondary observation. Same precedence
9377        // logic as every prior leading-byte arm.
9378        let d = dep_with_fonte(DepSource::Path {
9379            caminho: "/etc/passwd;rm".into(),
9380        });
9381        let err = d.validate().unwrap_err();
9382        assert!(
9383            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
9384            "got {err:?}",
9385        );
9386    }
9387
9388    #[test]
9389    fn fonte_caminho_shell_semicolon_fires_before_trailing_slash() {
9390        // Cascade pin on the immediate-successor arm: a value carrying
9391        // both `;` and a trailing `/` (`"../foo;rm/"` — the canonical
9392        // "I tab-completed a path that already had a `; cleanup` tail"
9393        // footgun) routes through `FonteCaminhoShellSemicolon` not
9394        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
9395        // the more semantic-locating axis (an author who removes the
9396        // `;` typically also drops the trailing separator since both
9397        // are paste-from-shell artifacts).
9398        let d = dep_with_fonte(DepSource::Path {
9399            caminho: "../foo;rm/".into(),
9400        });
9401        let err = d.validate().unwrap_err();
9402        assert!(
9403            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
9404            "got {err:?}",
9405        );
9406    }
9407
9408    #[test]
9409    fn fonte_caminho_shell_semicolon_diagnostic_carries_offending_dep_and_caminho() {
9410        // Diagnostic-shape pin (peer with
9411        // `fonte_caminho_shell_pipe_diagnostic_carries_offending_dep_and_caminho`
9412        // on the closest single-byte peer arm): the error's Display
9413        // surfaces the offending `:nome` and the offending `:caminho`
9414        // verbatim, and names the shell-command-separator footgun
9415        // explicitly so a `feira lint` run can render the diagnostic
9416        // without re-parsing.
9417        let d = dep_with_fonte(DepSource::Path {
9418            caminho: "../caixa-teia; rm -rf build".into(),
9419        });
9420        let rendered = d.validate().unwrap_err().to_string();
9421        assert!(
9422            rendered.contains("caixa-teia"),
9423            "diagnostic must name the offending dep: {rendered}",
9424        );
9425        assert!(
9426            rendered.contains("../caixa-teia; rm -rf build"),
9427            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
9428        );
9429        assert!(
9430            rendered.contains(';'),
9431            "diagnostic must reference the semicolon footgun: {rendered:?}",
9432        );
9433        assert!(
9434            rendered.contains("command-separator"),
9435            "diagnostic must name the shell-command-separator footgun: {rendered:?}",
9436        );
9437    }
9438
9439    #[test]
9440    fn validate_rejects_path_fonte_with_caminho_carrying_ampersand() {
9441        // The fail-before-pass-after pin for the canonical shell-
9442        // background-task paste footgun: an author copies a shell one-
9443        // liner (`"../caixa-teia & sleep 1"` — the canonical "I selected
9444        // the whole `cd path & sleep 1` background-launch out of a
9445        // shell-history block") and silently passed every prior arm
9446        // (`Path::is_absolute` false on `..`, no control bytes, no
9447        // backslash, no `<` / `>`, no `|`, no `;`, doesn't end in `/`).
9448        // The lacre embedded the value verbatim, the resolver folded it
9449        // through `Path::join` looking for a literal `./../caixa-teia &
9450        // sleep 1` subdirectory, and the failure surfaced at resolve
9451        // time with a non-self-locating `No such file or directory`
9452        // error. The new arm moves the rejection to validate time and
9453        // names the offending dep + caminho verbatim.
9454        let d = dep_with_fonte(DepSource::Path {
9455            caminho: "../caixa-teia & sleep 1".into(),
9456        });
9457        let err = d.validate().unwrap_err();
9458        let DepError::FonteCaminhoShellBackground { nome, caminho } = err else {
9459            panic!("expected FonteCaminhoShellBackground, got {err:?}");
9460        };
9461        assert_eq!(nome, "caixa-teia");
9462        assert_eq!(caminho, "../caixa-teia & sleep 1");
9463    }
9464
9465    #[test]
9466    fn validate_rejects_path_fonte_with_caminho_carrying_leading_ampersand() {
9467        // Leading-position `&` shape (`"&../caixa-teia"` — the
9468        // degenerate "I forgot the prior command side of the
9469        // background terminator" idiom). Pinned separately from the
9470        // embedded-byte shape so the gate covers every position, not
9471        // only mid-path.
9472        let d = dep_with_fonte(DepSource::Path {
9473            caminho: "&../caixa-teia".into(),
9474        });
9475        let err = d.validate().unwrap_err();
9476        assert!(
9477            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
9478            "got {err:?}",
9479        );
9480    }
9481
9482    #[test]
9483    fn validate_rejects_path_fonte_with_caminho_carrying_double_ampersand() {
9484        // The logical-AND `&&` shape (`"../caixa-teia && make"` — the
9485        // canonical "I copied a `cd path && make` build chain" idiom
9486        // every Makefile / shell-script wraps). The arm fires on the
9487        // first `&` encountered; pinned so a future arm that tries to
9488        // distinguish `&` from `&&` doesn't break the broader contract.
9489        let d = dep_with_fonte(DepSource::Path {
9490            caminho: "../caixa-teia && make".into(),
9491        });
9492        let err = d.validate().unwrap_err();
9493        assert!(
9494            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
9495            "got {err:?}",
9496        );
9497    }
9498
9499    #[test]
9500    fn validate_accepts_path_fonte_with_caminho_carrying_no_ampersand() {
9501        // The positive-control pin: the gate targets only `&`, never
9502        // adjacent printable ASCII or POSIX-valid bytes. The canonical
9503        // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
9504        // pathed variant with adjacent printable punctuation
9505        // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
9506        // cleanly so the gate doesn't widen to a "no printable
9507        // punctuation anywhere" sweep that would defeat the entire
9508        // path-fonte author surface.
9509        let d = dep_with_fonte(DepSource::Path {
9510            caminho: "../caixa-teia/sub-dir.v2".into(),
9511        });
9512        d.validate().unwrap();
9513    }
9514
9515    #[test]
9516    fn fonte_caminho_shell_semicolon_fires_before_shell_background() {
9517        // Cascade pin on the immediate-predecessor arm: a value carrying
9518        // both `;` and `&` (`"../caixa-teia; rm & sleep"` — the
9519        // canonical "I pasted a `cmd; cleanup & sleep` chain" footgun)
9520        // routes through `FonteCaminhoShellSemicolon` not
9521        // `FonteCaminhoShellBackground`. The sequential-command-
9522        // separator paste is the more common shell-history paste idiom
9523        // on every probe-as-both value (an author who removes the `;`
9524        // typically also drops the trailing `& sleep` since both are
9525        // paste-from-shell-history artifacts) — same cascade discipline
9526        // every prior `:caminho` arm establishes.
9527        let d = dep_with_fonte(DepSource::Path {
9528            caminho: "../caixa-teia; rm & sleep".into(),
9529        });
9530        let err = d.validate().unwrap_err();
9531        assert!(
9532            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
9533            "got {err:?}",
9534        );
9535    }
9536
9537    #[test]
9538    fn fonte_caminho_shell_pipe_fires_before_shell_background() {
9539        // Cascade pin on the upstream shell-pipe arm: a value carrying
9540        // both `|` and `&` (`"../caixa-teia | tee & sleep"` — the
9541        // canonical "I pasted a `cmd | tee & sleep` background-pipeline
9542        // chain" footgun) routes through `FonteCaminhoShellPipe` not
9543        // `FonteCaminhoShellBackground`. The pipeline-tail paste is the
9544        // load-bearing root-cause edit on every probe-as-both value.
9545        let d = dep_with_fonte(DepSource::Path {
9546            caminho: "../caixa-teia | tee & sleep".into(),
9547        });
9548        let err = d.validate().unwrap_err();
9549        assert!(
9550            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
9551            "got {err:?}",
9552        );
9553    }
9554
9555    #[test]
9556    fn fonte_caminho_shell_redirection_fires_before_shell_background() {
9557        // Cascade pin on the upstream shell-redirection arm: a value
9558        // carrying both `>` and `&` (`"../caixa-teia>log & sleep"` —
9559        // the canonical "I pasted a `cmd > log & sleep` background-
9560        // redirect chain" footgun) routes through
9561        // `FonteCaminhoShellRedirection` not
9562        // `FonteCaminhoShellBackground`. The input/output redirection
9563        // metachar carries the more self-locating `byte: u8` payload
9564        // (it names which of `<` or `>` triggered), so the prior arm
9565        // wins on every probe-as-both value.
9566        let d = dep_with_fonte(DepSource::Path {
9567            caminho: "../caixa-teia>log & sleep".into(),
9568        });
9569        let err = d.validate().unwrap_err();
9570        assert!(
9571            matches!(
9572                err,
9573                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
9574            ),
9575            "got {err:?}",
9576        );
9577    }
9578
9579    #[test]
9580    fn fonte_caminho_backslash_fires_before_shell_background() {
9581        // Cascade pin on the upstream backslash arm: a value carrying
9582        // both `\` and `&` (`"..\caixa-teia & sleep"` — the canonical
9583        // "I pasted a Windows-shell `cd ..\path & sleep` background-
9584        // launch chain") routes through `FonteCaminhoBackslash` not
9585        // `FonteCaminhoShellBackground`. The cross-host-OS-separator
9586        // divergence is the load-bearing axis on every probe-as-both
9587        // value (an author who removes the `\` is the root-cause edit;
9588        // the `&` falls away in the same edit since it's downstream of
9589        // the Windows-shell convention).
9590        let d = dep_with_fonte(DepSource::Path {
9591            caminho: "..\\caixa-teia & sleep".into(),
9592        });
9593        let err = d.validate().unwrap_err();
9594        assert!(
9595            matches!(err, DepError::FonteCaminhoBackslash { .. }),
9596            "got {err:?}",
9597        );
9598    }
9599
9600    #[test]
9601    fn fonte_caminho_control_char_fires_before_shell_background() {
9602        // Cascade pin on the embedded-control-byte arm: a value
9603        // carrying both a control byte and `&` (`"../foo\n&sleep"` —
9604        // the canonical paste-from-multiline-doc footgun where a
9605        // newline landed mid-caminho) routes through
9606        // `FonteCaminhoControlChar` not `FonteCaminhoShellBackground`.
9607        // The POSIX-syscall-rejected-byte / NUL-`CString::new`-fail
9608        // diagnostic is the load-bearing axis on every value that
9609        // probes positive for both — mirrors the cascade discipline on
9610        // every prior arm.
9611        let d = dep_with_fonte(DepSource::Path {
9612            caminho: "../foo\n&sleep".into(),
9613        });
9614        let err = d.validate().unwrap_err();
9615        assert!(
9616            matches!(err, DepError::FonteCaminhoControlChar { .. }),
9617            "got {err:?}",
9618        );
9619    }
9620
9621    #[test]
9622    fn fonte_caminho_absolute_fires_before_shell_background() {
9623        // Cascade pin on the load-bearing leading-byte arm: a leading
9624        // `/` value with embedded `&` (`"/etc/passwd & sleep"`) routes
9625        // through `FonteCaminhoAbsolute` not
9626        // `FonteCaminhoShellBackground` — the host-layout-leak
9627        // diagnostic is the load-bearing axis, the `&` byte is the
9628        // secondary observation. Same precedence logic as every prior
9629        // leading-byte arm.
9630        let d = dep_with_fonte(DepSource::Path {
9631            caminho: "/etc/passwd & sleep".into(),
9632        });
9633        let err = d.validate().unwrap_err();
9634        assert!(
9635            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
9636            "got {err:?}",
9637        );
9638    }
9639
9640    #[test]
9641    fn fonte_caminho_shell_background_fires_before_trailing_slash() {
9642        // Cascade pin on the immediate-successor arm: a value carrying
9643        // both `&` and a trailing `/` (`"../foo&sleep/"` — the
9644        // canonical "I tab-completed a path that already had a `&
9645        // sleep` background-launch tail" footgun) routes through
9646        // `FonteCaminhoShellBackground` not `FonteCaminhoTrailingSlash`.
9647        // The embedded shell-metachar is the more semantic-locating
9648        // axis (an author who removes the `&` typically also drops
9649        // the trailing separator since both are paste-from-shell
9650        // artifacts).
9651        let d = dep_with_fonte(DepSource::Path {
9652            caminho: "../foo&sleep/".into(),
9653        });
9654        let err = d.validate().unwrap_err();
9655        assert!(
9656            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
9657            "got {err:?}",
9658        );
9659    }
9660
9661    #[test]
9662    fn fonte_caminho_shell_background_diagnostic_carries_offending_dep_and_caminho() {
9663        // Diagnostic-shape pin (peer with
9664        // `fonte_caminho_shell_semicolon_diagnostic_carries_offending_dep_and_caminho`
9665        // on the closest single-byte peer arm): the error's Display
9666        // surfaces the offending `:nome` and the offending `:caminho`
9667        // verbatim, and names the shell-background / logical-AND
9668        // footgun explicitly so a `feira lint` run can render the
9669        // diagnostic without re-parsing.
9670        let d = dep_with_fonte(DepSource::Path {
9671            caminho: "../caixa-teia & sleep 1".into(),
9672        });
9673        let rendered = d.validate().unwrap_err().to_string();
9674        assert!(
9675            rendered.contains("caixa-teia"),
9676            "diagnostic must name the offending dep: {rendered}",
9677        );
9678        assert!(
9679            rendered.contains("../caixa-teia & sleep 1"),
9680            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
9681        );
9682        assert!(
9683            rendered.contains('&'),
9684            "diagnostic must reference the ampersand footgun: {rendered:?}",
9685        );
9686        assert!(
9687            rendered.contains("background") || rendered.contains("list-AND"),
9688            "diagnostic must name the shell-background / logical-AND footgun: {rendered:?}",
9689        );
9690    }
9691
9692    #[test]
9693    fn validate_rejects_path_fonte_with_caminho_carrying_backtick() {
9694        // The fail-before-pass-after pin for the canonical shell-
9695        // command-substitution paste footgun: an author copies a
9696        // POSIX legacy backticked one-liner (`"../caixa-teia/`whoami`"`
9697        // — the canonical "I pasted a path that included a `pwd`
9698        // / `whoami` / `date` legacy command-substitution expansion
9699        // out of a shell-history block") and silently passed every
9700        // prior arm (`Path::is_absolute` false on `..`, no control
9701        // bytes, no `\`, no `<` / `>`, no `|`, no `;`, no `&`, doesn't
9702        // end in `/`). The lacre embedded the value verbatim, the
9703        // resolver folded it through `Path::join` looking for a
9704        // literal `./../caixa-teia/`whoami`` subdirectory, and the
9705        // failure surfaced at resolve time with a non-self-locating
9706        // `No such file or directory` error. The new arm moves the
9707        // rejection to validate time and names the offending dep +
9708        // caminho verbatim.
9709        let d = dep_with_fonte(DepSource::Path {
9710            caminho: "../caixa-teia/`whoami`".into(),
9711        });
9712        let err = d.validate().unwrap_err();
9713        let DepError::FonteCaminhoShellCommandSubstitution { nome, caminho } = err else {
9714            panic!("expected FonteCaminhoShellCommandSubstitution, got {err:?}");
9715        };
9716        assert_eq!(nome, "caixa-teia");
9717        assert_eq!(caminho, "../caixa-teia/`whoami`");
9718    }
9719
9720    #[test]
9721    fn validate_rejects_path_fonte_with_caminho_carrying_leading_backtick() {
9722        // Leading-position backtick shape (``"`pwd`/caixa-teia"`` —
9723        // the canonical `<backtick>pwd<backtick>/path` working-
9724        // directory expansion shape every shell-side path-composition
9725        // idiom carries). Pinned separately from the embedded-byte
9726        // shape so the gate covers every position, not only mid-path.
9727        let d = dep_with_fonte(DepSource::Path {
9728            caminho: "`pwd`/caixa-teia".into(),
9729        });
9730        let err = d.validate().unwrap_err();
9731        assert!(
9732            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
9733            "got {err:?}",
9734        );
9735    }
9736
9737    #[test]
9738    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_backtick() {
9739        // Trailing-position backtick shape (`"../caixa-teia`"` — the
9740        // degenerate "I selected an unbalanced backtick out of a
9741        // shell-history block" idiom that probes for the cascade's
9742        // last-byte handling). The trailing-`/` arm fires only on
9743        // last-byte `/`; an unbalanced trailing backtick must route
9744        // through this arm regardless of position.
9745        let d = dep_with_fonte(DepSource::Path {
9746            caminho: "../caixa-teia`".into(),
9747        });
9748        let err = d.validate().unwrap_err();
9749        assert!(
9750            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
9751            "got {err:?}",
9752        );
9753    }
9754
9755    #[test]
9756    fn validate_rejects_path_fonte_with_caminho_carrying_balanced_backtick_pair() {
9757        // The canonical balanced-pair shape (``"../<backtick>cat
9758        // /etc/passwd<backtick>"`` — the canonical CWE-78 shell-
9759        // command-injection paste idiom every shell-side hardening
9760        // guide enumerates first). The arm fires on the first
9761        // backtick encountered; pinned so a future arm that tries to
9762        // distinguish the opening from the closing byte doesn't break
9763        // the broader contract.
9764        let d = dep_with_fonte(DepSource::Path {
9765            caminho: "../`cat /etc/passwd`".into(),
9766        });
9767        let err = d.validate().unwrap_err();
9768        assert!(
9769            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
9770            "got {err:?}",
9771        );
9772    }
9773
9774    #[test]
9775    fn validate_accepts_path_fonte_with_caminho_carrying_no_backtick() {
9776        // The positive-control pin: the gate targets only the
9777        // backtick byte, never adjacent printable ASCII or POSIX-
9778        // valid bytes. The canonical relative POSIX path
9779        // (`"../caixa-teia"`) and a nested deeply-pathed variant with
9780        // adjacent printable punctuation
9781        // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
9782        // cleanly so the gate doesn't widen to a "no printable
9783        // punctuation anywhere" sweep that would defeat the entire
9784        // path-fonte author surface.
9785        let d = dep_with_fonte(DepSource::Path {
9786            caminho: "../caixa-teia/sub-dir.v2".into(),
9787        });
9788        d.validate().unwrap();
9789    }
9790
9791    #[test]
9792    fn fonte_caminho_shell_background_fires_before_shell_command_substitution() {
9793        // Cascade pin on the immediate-predecessor arm: a value
9794        // carrying both `&` and a backtick (``"../caixa-teia &
9795        // <backtick>sleep 1<backtick>"`` — the canonical "I pasted a
9796        // `cmd & <backtick>sleep N<backtick>` background-launch +
9797        // command-substitution chain" footgun) routes through
9798        // `FonteCaminhoShellBackground` not
9799        // `FonteCaminhoShellCommandSubstitution`. The background-
9800        // launch tail is the more common shell-history paste idiom
9801        // on every probe-as-both value — same cascade discipline
9802        // every prior `:caminho` arm establishes.
9803        let d = dep_with_fonte(DepSource::Path {
9804            caminho: "../caixa-teia & `sleep 1`".into(),
9805        });
9806        let err = d.validate().unwrap_err();
9807        assert!(
9808            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
9809            "got {err:?}",
9810        );
9811    }
9812
9813    #[test]
9814    fn fonte_caminho_shell_semicolon_fires_before_shell_command_substitution() {
9815        // Cascade pin on the upstream shell-semicolon arm: a value
9816        // carrying both `;` and a backtick (``"../caixa-teia;
9817        // <backtick>whoami<backtick>"`` — the canonical "I pasted a
9818        // `cmd; <backtick>follow-up<backtick>` sequential-chain
9819        // footgun) routes through `FonteCaminhoShellSemicolon` not
9820        // `FonteCaminhoShellCommandSubstitution`. The sequential-
9821        // command-separator paste is the load-bearing root-cause
9822        // edit on every probe-as-both value.
9823        let d = dep_with_fonte(DepSource::Path {
9824            caminho: "../caixa-teia; `whoami`".into(),
9825        });
9826        let err = d.validate().unwrap_err();
9827        assert!(
9828            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
9829            "got {err:?}",
9830        );
9831    }
9832
9833    #[test]
9834    fn fonte_caminho_shell_pipe_fires_before_shell_command_substitution() {
9835        // Cascade pin on the upstream shell-pipe arm: a value
9836        // carrying both `|` and a backtick (``"../caixa-teia |
9837        // <backtick>tee log<backtick>"`` — the canonical pipeline-to-
9838        // command-substitution paste idiom) routes through
9839        // `FonteCaminhoShellPipe` not
9840        // `FonteCaminhoShellCommandSubstitution`. The pipeline-tail
9841        // paste is the load-bearing root-cause edit on every
9842        // probe-as-both value.
9843        let d = dep_with_fonte(DepSource::Path {
9844            caminho: "../caixa-teia | `tee log`".into(),
9845        });
9846        let err = d.validate().unwrap_err();
9847        assert!(
9848            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
9849            "got {err:?}",
9850        );
9851    }
9852
9853    #[test]
9854    fn fonte_caminho_shell_redirection_fires_before_shell_command_substitution() {
9855        // Cascade pin on the upstream shell-redirection arm: a value
9856        // carrying both `>` and a backtick (``"../caixa-teia>log
9857        // <backtick>date<backtick>"`` — the canonical "I pasted a
9858        // `cmd > log <backtick>date<backtick>` redirect-plus-
9859        // substitution chain" footgun) routes through
9860        // `FonteCaminhoShellRedirection` not
9861        // `FonteCaminhoShellCommandSubstitution`. The input/output
9862        // redirection metachar carries the more self-locating `byte`
9863        // payload (it names which of `<` or `>` triggered), so the
9864        // prior arm wins on every probe-as-both value.
9865        let d = dep_with_fonte(DepSource::Path {
9866            caminho: "../caixa-teia>log `date`".into(),
9867        });
9868        let err = d.validate().unwrap_err();
9869        assert!(
9870            matches!(
9871                err,
9872                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
9873            ),
9874            "got {err:?}",
9875        );
9876    }
9877
9878    #[test]
9879    fn fonte_caminho_backslash_fires_before_shell_command_substitution() {
9880        // Cascade pin on the upstream backslash arm: a value
9881        // carrying both `\` and a backtick (``"..\caixa-teia
9882        // <backtick>whoami<backtick>"`` — the canonical "I pasted a
9883        // Windows-shell `cd ..\path <backtick>whoami<backtick>`
9884        // chain") routes through `FonteCaminhoBackslash` not
9885        // `FonteCaminhoShellCommandSubstitution`. The cross-host-OS-
9886        // separator divergence is the load-bearing axis on every
9887        // probe-as-both value (an author who removes the `\` is the
9888        // root-cause edit; the backtick falls away in the same edit
9889        // since it's downstream of the Windows-shell convention).
9890        let d = dep_with_fonte(DepSource::Path {
9891            caminho: "..\\caixa-teia `whoami`".into(),
9892        });
9893        let err = d.validate().unwrap_err();
9894        assert!(
9895            matches!(err, DepError::FonteCaminhoBackslash { .. }),
9896            "got {err:?}",
9897        );
9898    }
9899
9900    #[test]
9901    fn fonte_caminho_control_char_fires_before_shell_command_substitution() {
9902        // Cascade pin on the embedded-control-byte arm: a value
9903        // carrying both a control byte and a backtick (`"../foo\n
9904        // `whoami`"` — the canonical paste-from-multiline-doc
9905        // footgun where a newline landed mid-caminho between two
9906        // paste fragments) routes through `FonteCaminhoControlChar`
9907        // not `FonteCaminhoShellCommandSubstitution`. The POSIX-
9908        // syscall-rejected-byte / NUL-`CString::new`-fail diagnostic
9909        // is the load-bearing axis on every value that probes
9910        // positive for both — mirrors the cascade discipline on
9911        // every prior arm.
9912        let d = dep_with_fonte(DepSource::Path {
9913            caminho: "../foo\n`whoami`".into(),
9914        });
9915        let err = d.validate().unwrap_err();
9916        assert!(
9917            matches!(err, DepError::FonteCaminhoControlChar { .. }),
9918            "got {err:?}",
9919        );
9920    }
9921
9922    #[test]
9923    fn fonte_caminho_absolute_fires_before_shell_command_substitution() {
9924        // Cascade pin on the load-bearing leading-byte arm: a
9925        // leading `/` value with embedded backtick (``"/etc/passwd
9926        // <backtick>whoami<backtick>"``) routes through
9927        // `FonteCaminhoAbsolute` not
9928        // `FonteCaminhoShellCommandSubstitution` — the host-layout-
9929        // leak diagnostic is the load-bearing axis, the backtick
9930        // byte is the secondary observation. Same precedence logic
9931        // as every prior leading-byte arm.
9932        let d = dep_with_fonte(DepSource::Path {
9933            caminho: "/etc/passwd `whoami`".into(),
9934        });
9935        let err = d.validate().unwrap_err();
9936        assert!(
9937            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
9938            "got {err:?}",
9939        );
9940    }
9941
9942    #[test]
9943    fn fonte_caminho_shell_command_substitution_fires_before_trailing_slash() {
9944        // Cascade pin on the immediate-successor arm: a value
9945        // carrying both a backtick and a trailing `/`
9946        // (``"../`whoami`/"`` — the canonical "I tab-completed a
9947        // path that already had a backticked `whoami` substitution
9948        // tail" footgun) routes through
9949        // `FonteCaminhoShellCommandSubstitution` not
9950        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
9951        // is the more semantic-locating axis (an author who removes
9952        // the backtick typically also drops the trailing separator
9953        // since both are paste-from-shell artifacts).
9954        let d = dep_with_fonte(DepSource::Path {
9955            caminho: "../`whoami`/".into(),
9956        });
9957        let err = d.validate().unwrap_err();
9958        assert!(
9959            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
9960            "got {err:?}",
9961        );
9962    }
9963
9964    #[test]
9965    fn fonte_caminho_shell_command_substitution_diagnostic_carries_offending_dep_and_caminho() {
9966        // Diagnostic-shape pin (peer with
9967        // `fonte_caminho_shell_background_diagnostic_carries_offending_dep_and_caminho`
9968        // on the closest single-byte peer arm): the error's Display
9969        // surfaces the offending `:nome` and the offending `:caminho`
9970        // verbatim, and names the shell-command-substitution footgun
9971        // explicitly so a `feira lint` run can render the diagnostic
9972        // without re-parsing.
9973        let d = dep_with_fonte(DepSource::Path {
9974            caminho: "../caixa-teia/`whoami`".into(),
9975        });
9976        let rendered = d.validate().unwrap_err().to_string();
9977        assert!(
9978            rendered.contains("caixa-teia"),
9979            "diagnostic must name the offending dep: {rendered}",
9980        );
9981        assert!(
9982            rendered.contains("../caixa-teia/`whoami`"),
9983            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
9984        );
9985        assert!(
9986            rendered.contains('`'),
9987            "diagnostic must reference the backtick footgun: {rendered:?}",
9988        );
9989        assert!(
9990            rendered.contains("command-substitution"),
9991            "diagnostic must name the shell-command-substitution footgun: {rendered:?}",
9992        );
9993    }
9994
9995    #[test]
9996    fn validate_rejects_path_fonte_with_caminho_carrying_star_glob() {
9997        // The fail-before-pass-after pin for the canonical pathname-
9998        // expansion paste footgun: an author copies an `ls
9999        // ../caixa-teia/*` shell-listing tail into the `:caminho`
10000        // slot and silently passes every prior arm
10001        // (`Path::is_absolute` false on `..`, no control bytes, no
10002        // `\`, no `<` / `>`, no `|`, no `;`, no `&`, no backtick,
10003        // doesn't end in `/`). The lacre embedded the value
10004        // verbatim, the resolver folded it through `Path::join`
10005        // looking for a literal `./../caixa-teia/*` subdirectory,
10006        // and the failure surfaced at resolve time with a non-self-
10007        // locating `No such file or directory` error. The new arm
10008        // moves the rejection to validate time and names the
10009        // offending dep + caminho + byte verbatim.
10010        let d = dep_with_fonte(DepSource::Path {
10011            caminho: "../caixa-teia/*".into(),
10012        });
10013        let err = d.validate().unwrap_err();
10014        let DepError::FonteCaminhoShellGlob {
10015            nome,
10016            caminho,
10017            byte,
10018        } = err
10019        else {
10020            panic!("expected FonteCaminhoShellGlob, got {err:?}");
10021        };
10022        assert_eq!(nome, "caixa-teia");
10023        assert_eq!(caminho, "../caixa-teia/*");
10024        assert_eq!(byte, b'*');
10025    }
10026
10027    #[test]
10028    fn validate_rejects_path_fonte_with_caminho_carrying_question_glob() {
10029        // The symmetric single-char-wildcard paste shape
10030        // (`"../foo?"` — the canonical "I copied a `rm foo?` line
10031        // out of shell history" idiom). Pinned separately from the
10032        // `*` shape so the gate's contract is "any `*` or `?`
10033        // anywhere", not single-byte coverage.
10034        let d = dep_with_fonte(DepSource::Path {
10035            caminho: "../foo?".into(),
10036        });
10037        let err = d.validate().unwrap_err();
10038        let DepError::FonteCaminhoShellGlob { byte, .. } = err else {
10039            panic!("expected FonteCaminhoShellGlob, got {err:?}");
10040        };
10041        assert_eq!(byte, b'?');
10042    }
10043
10044    #[test]
10045    fn validate_rejects_path_fonte_with_caminho_carrying_leading_star_glob() {
10046        // Leading-position `*` shape (`"*/caixa-teia"` — the
10047        // degenerate "I selected only the wildcard prefix out of a
10048        // shell-glob expression" idiom). Pinned separately from the
10049        // embedded-byte shapes so the gate covers every position,
10050        // not only mid-path.
10051        let d = dep_with_fonte(DepSource::Path {
10052            caminho: "*/caixa-teia".into(),
10053        });
10054        let err = d.validate().unwrap_err();
10055        assert!(
10056            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
10057            "got {err:?}",
10058        );
10059    }
10060
10061    #[test]
10062    fn validate_rejects_path_fonte_with_caminho_carrying_double_star_recursive_glob() {
10063        // The bash/zsh `globstar` recursive-glob shape
10064        // (`"../caixa-teia/**/foo"` — the canonical "I copied a
10065        // `find ../caixa-teia/**/foo` recursive expansion" idiom).
10066        // The arm fires on the first `*` encountered; pinned so a
10067        // future arm that tries to distinguish single `*` from
10068        // double `**` doesn't break the broader contract.
10069        let d = dep_with_fonte(DepSource::Path {
10070            caminho: "../caixa-teia/**/foo".into(),
10071        });
10072        let err = d.validate().unwrap_err();
10073        assert!(
10074            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
10075            "got {err:?}",
10076        );
10077    }
10078
10079    #[test]
10080    fn validate_rejects_path_fonte_with_caminho_carrying_dotted_extension_glob() {
10081        // The canonical extension-glob shape (`"../caixa-teia/*.lisp"`
10082        // — the "I selected `*.lisp` to mean every Lisp source file
10083        // in the dep root" footgun the prior arms structurally
10084        // cannot catch since `.` is a POSIX-valid path-component
10085        // byte). Pinned so the gate's contract covers the most
10086        // idiomatic glob-paste shape every author meets first.
10087        let d = dep_with_fonte(DepSource::Path {
10088            caminho: "../caixa-teia/*.lisp".into(),
10089        });
10090        let err = d.validate().unwrap_err();
10091        assert!(
10092            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
10093            "got {err:?}",
10094        );
10095    }
10096
10097    #[test]
10098    fn validate_accepts_path_fonte_with_caminho_carrying_no_glob() {
10099        // The positive-control pin: the gate targets only `*` /
10100        // `?`, never adjacent printable ASCII or POSIX-valid bytes.
10101        // The canonical relative POSIX path (`"../caixa-teia"`) and
10102        // a nested deeply-pathed variant with adjacent printable
10103        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
10104        // to validate cleanly so the gate doesn't widen to a "no
10105        // printable punctuation anywhere" sweep that would defeat
10106        // the entire path-fonte author surface.
10107        let d = dep_with_fonte(DepSource::Path {
10108            caminho: "../caixa-teia/sub-dir.v2".into(),
10109        });
10110        d.validate().unwrap();
10111    }
10112
10113    #[test]
10114    fn fonte_caminho_shell_command_substitution_fires_before_shell_glob() {
10115        // Cascade pin on the immediate-predecessor arm: a value
10116        // carrying both a backtick and `*` (``"../`whoami`/*"`` —
10117        // the canonical "I pasted a `cd <backtick>whoami<backtick>/*`
10118        // command-substitution + glob chain") routes through
10119        // `FonteCaminhoShellCommandSubstitution` not
10120        // `FonteCaminhoShellGlob`. The CWE-78 shell-command-
10121        // injection vector is the load-bearing root-cause edit on
10122        // every probe-as-both value — same cascade discipline every
10123        // prior `:caminho` arm establishes.
10124        let d = dep_with_fonte(DepSource::Path {
10125            caminho: "../`whoami`/*".into(),
10126        });
10127        let err = d.validate().unwrap_err();
10128        assert!(
10129            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
10130            "got {err:?}",
10131        );
10132    }
10133
10134    #[test]
10135    fn fonte_caminho_shell_background_fires_before_shell_glob() {
10136        // Cascade pin on the upstream shell-background arm: a value
10137        // carrying both `&` and `*` (`"../caixa-teia & ls /*"` — the
10138        // canonical "I pasted a `cmd & ls /*` background + glob
10139        // chain" footgun) routes through `FonteCaminhoShellBackground`
10140        // not `FonteCaminhoShellGlob`. The background-launch tail is
10141        // the load-bearing root-cause edit on every probe-as-both
10142        // value.
10143        let d = dep_with_fonte(DepSource::Path {
10144            caminho: "../caixa-teia & ls /*".into(),
10145        });
10146        let err = d.validate().unwrap_err();
10147        assert!(
10148            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
10149            "got {err:?}",
10150        );
10151    }
10152
10153    #[test]
10154    fn fonte_caminho_shell_semicolon_fires_before_shell_glob() {
10155        // Cascade pin on the upstream shell-semicolon arm: a value
10156        // carrying both `;` and `*` (`"../caixa-teia; rm *"` — the
10157        // canonical sequential-cleanup + glob paste idiom) routes
10158        // through `FonteCaminhoShellSemicolon` not
10159        // `FonteCaminhoShellGlob`. The sequential-command-separator
10160        // paste is the load-bearing root-cause edit on every
10161        // probe-as-both value.
10162        let d = dep_with_fonte(DepSource::Path {
10163            caminho: "../caixa-teia; rm *".into(),
10164        });
10165        let err = d.validate().unwrap_err();
10166        assert!(
10167            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
10168            "got {err:?}",
10169        );
10170    }
10171
10172    #[test]
10173    fn fonte_caminho_shell_pipe_fires_before_shell_glob() {
10174        // Cascade pin on the upstream shell-pipe arm: a value
10175        // carrying both `|` and `*` (`"../caixa-teia | ls *"` — the
10176        // canonical pipeline-to-glob paste idiom) routes through
10177        // `FonteCaminhoShellPipe` not `FonteCaminhoShellGlob`. The
10178        // pipeline-tail paste is the load-bearing root-cause edit
10179        // on every probe-as-both value.
10180        let d = dep_with_fonte(DepSource::Path {
10181            caminho: "../caixa-teia | ls *".into(),
10182        });
10183        let err = d.validate().unwrap_err();
10184        assert!(
10185            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10186            "got {err:?}",
10187        );
10188    }
10189
10190    #[test]
10191    fn fonte_caminho_shell_redirection_fires_before_shell_glob() {
10192        // Cascade pin on the upstream shell-redirection arm: a value
10193        // carrying both `>` and `*` (`"../caixa-teia>log *"` — the
10194        // canonical "I pasted a `cmd > log *` redirect-plus-glob
10195        // chain" footgun) routes through
10196        // `FonteCaminhoShellRedirection` not `FonteCaminhoShellGlob`.
10197        // The input/output redirection metachar carries the more
10198        // self-locating `byte` payload (it names which of `<` or `>`
10199        // triggered), so the prior arm wins on every probe-as-both
10200        // value.
10201        let d = dep_with_fonte(DepSource::Path {
10202            caminho: "../caixa-teia>log *".into(),
10203        });
10204        let err = d.validate().unwrap_err();
10205        assert!(
10206            matches!(
10207                err,
10208                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
10209            ),
10210            "got {err:?}",
10211        );
10212    }
10213
10214    #[test]
10215    fn fonte_caminho_backslash_fires_before_shell_glob() {
10216        // Cascade pin on the upstream backslash arm: a value
10217        // carrying both `\` and `*` (`"..\caixa-teia\*"` — the
10218        // canonical "I pasted a Windows-shell `cd ..\path\*` glob
10219        // expression" footgun) routes through
10220        // `FonteCaminhoBackslash` not `FonteCaminhoShellGlob`. The
10221        // cross-host-OS-separator divergence is the load-bearing
10222        // axis on every probe-as-both value (an author who removes
10223        // the `\` is the root-cause edit; the `*` falls away in the
10224        // same edit since it's downstream of the Windows-shell
10225        // convention).
10226        let d = dep_with_fonte(DepSource::Path {
10227            caminho: "..\\caixa-teia\\*".into(),
10228        });
10229        let err = d.validate().unwrap_err();
10230        assert!(
10231            matches!(err, DepError::FonteCaminhoBackslash { .. }),
10232            "got {err:?}",
10233        );
10234    }
10235
10236    #[test]
10237    fn fonte_caminho_control_char_fires_before_shell_glob() {
10238        // Cascade pin on the embedded-control-byte arm: a value
10239        // carrying both a control byte and `*` (`"../foo\n*"` — the
10240        // canonical paste-from-multiline-doc footgun where a
10241        // newline landed mid-caminho between two paste fragments)
10242        // routes through `FonteCaminhoControlChar` not
10243        // `FonteCaminhoShellGlob`. The POSIX-syscall-rejected-byte /
10244        // NUL-`CString::new`-fail diagnostic is the load-bearing
10245        // axis on every value that probes positive for both —
10246        // mirrors the cascade discipline on every prior arm.
10247        let d = dep_with_fonte(DepSource::Path {
10248            caminho: "../foo\n*".into(),
10249        });
10250        let err = d.validate().unwrap_err();
10251        assert!(
10252            matches!(err, DepError::FonteCaminhoControlChar { .. }),
10253            "got {err:?}",
10254        );
10255    }
10256
10257    #[test]
10258    fn fonte_caminho_absolute_fires_before_shell_glob() {
10259        // Cascade pin on the load-bearing leading-byte arm: a
10260        // leading `/` value with embedded `*` (`"/etc/*"`) routes
10261        // through `FonteCaminhoAbsolute` not `FonteCaminhoShellGlob`
10262        // — the host-layout-leak diagnostic is the load-bearing
10263        // axis, the glob byte is the secondary observation. Same
10264        // precedence logic as every prior leading-byte arm.
10265        let d = dep_with_fonte(DepSource::Path {
10266            caminho: "/etc/*".into(),
10267        });
10268        let err = d.validate().unwrap_err();
10269        assert!(
10270            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10271            "got {err:?}",
10272        );
10273    }
10274
10275    #[test]
10276    fn fonte_caminho_shell_glob_fires_before_trailing_slash() {
10277        // Cascade pin on the immediate-successor arm: a value
10278        // carrying both `*` and a trailing `/` (`"../foo*/"` — the
10279        // canonical "I tab-completed a path that already had a
10280        // glob-expansion tail" footgun) routes through
10281        // `FonteCaminhoShellGlob` not `FonteCaminhoTrailingSlash`.
10282        // The embedded shell-metachar is the more semantic-locating
10283        // axis (an author who removes the `*` typically also drops
10284        // the trailing separator since both are paste-from-shell
10285        // artifacts).
10286        let d = dep_with_fonte(DepSource::Path {
10287            caminho: "../foo*/".into(),
10288        });
10289        let err = d.validate().unwrap_err();
10290        assert!(
10291            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
10292            "got {err:?}",
10293        );
10294    }
10295
10296    #[test]
10297    fn fonte_caminho_shell_glob_diagnostic_carries_offending_dep_caminho_and_byte() {
10298        // Diagnostic-shape pin (peer with
10299        // `fonte_caminho_shell_redirection_diagnostic_*` on the
10300        // closest two-byte peer arm): the error's Display surfaces
10301        // the offending `:nome`, the offending `:caminho` verbatim,
10302        // the offending byte's hex / character form, and names the
10303        // shell-glob / pathname-expansion footgun explicitly so a
10304        // `feira lint` run can render the diagnostic without
10305        // re-parsing.
10306        let d = dep_with_fonte(DepSource::Path {
10307            caminho: "../caixa-teia/*.lisp".into(),
10308        });
10309        let rendered = d.validate().unwrap_err().to_string();
10310        assert!(
10311            rendered.contains("caixa-teia"),
10312            "diagnostic must name the offending dep: {rendered}",
10313        );
10314        assert!(
10315            rendered.contains("../caixa-teia/*.lisp"),
10316            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10317        );
10318        assert!(
10319            rendered.contains("0x2a"),
10320            "diagnostic must surface the offending byte hex: {rendered:?}",
10321        );
10322        assert!(
10323            rendered.contains("glob"),
10324            "diagnostic must name the shell-glob footgun: {rendered:?}",
10325        );
10326        assert!(
10327            rendered.contains("pathname-expansion"),
10328            "diagnostic must reference the POSIX pathname-expansion vocabulary: {rendered:?}",
10329        );
10330    }
10331
10332    #[test]
10333    fn validate_rejects_path_fonte_with_caminho_carrying_modern_command_substitution() {
10334        // The fail-before-pass-after pin for the canonical modern-Bourne
10335        // command-substitution paste footgun: an author copies a
10336        // `cd ../caixa-teia/$(date)/build` shell-history one-liner whose
10337        // `$(<cmd>)` expansion would land the current date as a
10338        // subdirectory name and silently passed every prior arm
10339        // (`Path::is_absolute` false on `..`, no control bytes, no `\`,
10340        // no `<` / `>`, no `|`, no `;`, no `&`, no backtick, no `*` /
10341        // `?`, doesn't end in `/`; the leading-`$` f4efe9c
10342        // `FonteCaminhoVarExpansion` arm doesn't fire because the `$`
10343        // sits mid-path). The lacre embedded the value verbatim, the
10344        // resolver folded it through `Path::join` looking for a literal
10345        // `./../caixa-teia/$(date)/build` subdirectory, and the failure
10346        // surfaced at resolve time with a non-self-locating `No such
10347        // file or directory` error. The new arm moves the rejection to
10348        // validate time and names the offending dep + caminho + byte
10349        // verbatim. The arm fires on the first `(` encountered (the
10350        // opening byte of `$(date)`).
10351        let d = dep_with_fonte(DepSource::Path {
10352            caminho: "../caixa-teia/$(date)/build".into(),
10353        });
10354        let err = d.validate().unwrap_err();
10355        let DepError::FonteCaminhoShellSubshellGrouping {
10356            nome,
10357            caminho,
10358            byte,
10359        } = err
10360        else {
10361            panic!("expected FonteCaminhoShellSubshellGrouping, got {err:?}");
10362        };
10363        assert_eq!(nome, "caixa-teia");
10364        assert_eq!(caminho, "../caixa-teia/$(date)/build");
10365        assert_eq!(byte, b'(');
10366    }
10367
10368    #[test]
10369    fn validate_rejects_path_fonte_with_caminho_carrying_close_paren() {
10370        // The symmetric close-paren paste shape (`"../caixa-teia)"` —
10371        // the degenerate "I selected an unbalanced closing paren out of
10372        // a shell-history block" idiom that probes for the cascade's
10373        // last-byte handling on a value carrying only the closing byte).
10374        // Pinned separately from the open-paren shape so the gate's
10375        // contract is "any `(` or `)` anywhere", not single-byte
10376        // coverage. Mirrors the peer `validate_rejects_path_fonte_with_\
10377        // caminho_carrying_question_glob` shape on the immediate-
10378        // predecessor `FonteCaminhoShellGlob` arm.
10379        let d = dep_with_fonte(DepSource::Path {
10380            caminho: "../caixa-teia)".into(),
10381        });
10382        let err = d.validate().unwrap_err();
10383        let DepError::FonteCaminhoShellSubshellGrouping { byte, .. } = err else {
10384            panic!("expected FonteCaminhoShellSubshellGrouping, got {err:?}");
10385        };
10386        assert_eq!(byte, b')');
10387    }
10388
10389    #[test]
10390    fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_paren() {
10391        // Leading-position `(` shape (`"(cd foo)/caixa-teia"` — the
10392        // canonical "I selected a `(cd foo)` subshell-grouping prefix
10393        // out of a `(cd foo) && cmd` shell-history one-liner" idiom).
10394        // Pinned separately from the embedded-byte shape so the gate
10395        // covers every position, not only mid-path.
10396        let d = dep_with_fonte(DepSource::Path {
10397            caminho: "(cd foo)/caixa-teia".into(),
10398        });
10399        let err = d.validate().unwrap_err();
10400        assert!(
10401            matches!(
10402                err,
10403                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
10404            ),
10405            "got {err:?}",
10406        );
10407    }
10408
10409    #[test]
10410    fn validate_rejects_path_fonte_with_caminho_carrying_balanced_subshell_grouping_pair() {
10411        // The canonical balanced-pair shape (`"../(pwd)/caixa-teia"`
10412        // — the canonical "I copied a `(pwd)` working-directory-probe
10413        // subshell-grouping idiom every shell-history block carries"
10414        // footgun). The value carries no other cascade-preceding
10415        // shell metachar (`&` / `;` / `|` / `<` / `>` / backtick /
10416        // `*` / `?`) so the arm fires on the first `(` encountered;
10417        // pinned so a future arm that tries to distinguish the
10418        // opening from the closing byte doesn't break the broader
10419        // contract. Mirrors the peer
10420        // `validate_rejects_path_fonte_with_caminho_carrying_balanced_\
10421        // backtick_pair` shape on the upstream `FonteCaminhoShell\
10422        // CommandSubstitution` arm.
10423        let d = dep_with_fonte(DepSource::Path {
10424            caminho: "../(pwd)/caixa-teia".into(),
10425        });
10426        let err = d.validate().unwrap_err();
10427        assert!(
10428            matches!(
10429                err,
10430                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
10431            ),
10432            "got {err:?}",
10433        );
10434    }
10435
10436    #[test]
10437    fn validate_accepts_path_fonte_with_caminho_carrying_no_subshell_grouping() {
10438        // The positive-control pin: the gate targets only `(` / `)`,
10439        // never adjacent printable ASCII or POSIX-valid bytes. The
10440        // canonical relative POSIX path (`"../caixa-teia"`) and a
10441        // nested deeply-pathed variant with adjacent printable
10442        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue to
10443        // validate cleanly so the gate doesn't widen to a "no printable
10444        // punctuation anywhere" sweep that would defeat the entire
10445        // path-fonte author surface.
10446        let d = dep_with_fonte(DepSource::Path {
10447            caminho: "../caixa-teia/sub-dir.v2".into(),
10448        });
10449        d.validate().unwrap();
10450    }
10451
10452    #[test]
10453    fn fonte_caminho_shell_glob_fires_before_shell_subshell_grouping() {
10454        // Cascade pin on the immediate-predecessor arm: a value
10455        // carrying both `*` and `(` (`"../caixa-teia/*(date)"` — the
10456        // canonical "I pasted a glob expansion followed by a
10457        // subshell-grouping tail" footgun) routes through
10458        // `FonteCaminhoShellGlob` not
10459        // `FonteCaminhoShellSubshellGrouping`. The pathname-expansion
10460        // shape is the more common shell-history paste idiom on every
10461        // probe-as-both value — same cascade discipline every prior
10462        // `:caminho` arm establishes.
10463        let d = dep_with_fonte(DepSource::Path {
10464            caminho: "../caixa-teia/*(date)".into(),
10465        });
10466        let err = d.validate().unwrap_err();
10467        assert!(
10468            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
10469            "got {err:?}",
10470        );
10471    }
10472
10473    #[test]
10474    fn fonte_caminho_shell_command_substitution_fires_before_shell_subshell_grouping() {
10475        // Cascade pin on the upstream shell-command-substitution arm: a
10476        // value carrying both a backtick and `(` (``"../`whoami`/$(date)"``
10477        // — the canonical "I pasted a legacy-backtick + modern-paren
10478        // command-substitution chain" footgun) routes through
10479        // `FonteCaminhoShellCommandSubstitution` not
10480        // `FonteCaminhoShellSubshellGrouping`. The CWE-78 shell-
10481        // command-injection vector is the load-bearing root-cause edit
10482        // on every probe-as-both value.
10483        let d = dep_with_fonte(DepSource::Path {
10484            caminho: "../`whoami`/$(date)".into(),
10485        });
10486        let err = d.validate().unwrap_err();
10487        assert!(
10488            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
10489            "got {err:?}",
10490        );
10491    }
10492
10493    #[test]
10494    fn fonte_caminho_shell_background_fires_before_shell_subshell_grouping() {
10495        // Cascade pin on the upstream shell-background arm: a value
10496        // carrying both `&` and `(` (`"../caixa-teia & (cd foo)"` —
10497        // the canonical "I pasted a `cmd & (cd foo)` background-launch
10498        // + subshell-grouping chain" footgun) routes through
10499        // `FonteCaminhoShellBackground` not
10500        // `FonteCaminhoShellSubshellGrouping`. The background-launch
10501        // tail is the load-bearing root-cause edit on every probe-as-
10502        // both value.
10503        let d = dep_with_fonte(DepSource::Path {
10504            caminho: "../caixa-teia & (cd foo)".into(),
10505        });
10506        let err = d.validate().unwrap_err();
10507        assert!(
10508            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
10509            "got {err:?}",
10510        );
10511    }
10512
10513    #[test]
10514    fn fonte_caminho_shell_semicolon_fires_before_shell_subshell_grouping() {
10515        // Cascade pin on the upstream shell-semicolon arm: a value
10516        // carrying both `;` and `(` (`"../caixa-teia; (cd foo)"` —
10517        // the canonical sequential-cleanup + subshell-grouping paste
10518        // idiom) routes through `FonteCaminhoShellSemicolon` not
10519        // `FonteCaminhoShellSubshellGrouping`. The sequential-command-
10520        // separator paste is the load-bearing root-cause edit on
10521        // every probe-as-both value.
10522        let d = dep_with_fonte(DepSource::Path {
10523            caminho: "../caixa-teia; (cd foo)".into(),
10524        });
10525        let err = d.validate().unwrap_err();
10526        assert!(
10527            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
10528            "got {err:?}",
10529        );
10530    }
10531
10532    #[test]
10533    fn fonte_caminho_shell_pipe_fires_before_shell_subshell_grouping() {
10534        // Cascade pin on the upstream shell-pipe arm: a value carrying
10535        // both `|` and `(` (`"../caixa-teia | (tee log)"` — the
10536        // canonical pipeline-to-subshell-grouping paste idiom) routes
10537        // through `FonteCaminhoShellPipe` not
10538        // `FonteCaminhoShellSubshellGrouping`. The pipeline-tail paste
10539        // is the load-bearing root-cause edit on every probe-as-both
10540        // value.
10541        let d = dep_with_fonte(DepSource::Path {
10542            caminho: "../caixa-teia | (tee log)".into(),
10543        });
10544        let err = d.validate().unwrap_err();
10545        assert!(
10546            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10547            "got {err:?}",
10548        );
10549    }
10550
10551    #[test]
10552    fn fonte_caminho_shell_redirection_fires_before_shell_subshell_grouping() {
10553        // Cascade pin on the upstream shell-redirection arm: a value
10554        // carrying both `>` and `(` (`"../caixa-teia>log (cd foo)"` —
10555        // the canonical "I pasted a `cmd > log (cd foo)` redirect-
10556        // plus-subshell-grouping chain" footgun) routes through
10557        // `FonteCaminhoShellRedirection` not
10558        // `FonteCaminhoShellSubshellGrouping`. The input/output
10559        // redirection metachar carries the more self-locating `byte`
10560        // payload (it names which of `<` or `>` triggered), so the
10561        // prior arm wins on every probe-as-both value.
10562        let d = dep_with_fonte(DepSource::Path {
10563            caminho: "../caixa-teia>log (cd foo)".into(),
10564        });
10565        let err = d.validate().unwrap_err();
10566        assert!(
10567            matches!(
10568                err,
10569                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
10570            ),
10571            "got {err:?}",
10572        );
10573    }
10574
10575    #[test]
10576    fn fonte_caminho_backslash_fires_before_shell_subshell_grouping() {
10577        // Cascade pin on the upstream backslash arm: a value carrying
10578        // both `\` and `(` (`"..\caixa-teia\(cd foo)"` — the canonical
10579        // "I pasted a Windows-shell `cd ..\path\(cmd)` chain") routes
10580        // through `FonteCaminhoBackslash` not
10581        // `FonteCaminhoShellSubshellGrouping`. The cross-host-OS-
10582        // separator divergence is the load-bearing axis on every
10583        // probe-as-both value (an author who removes the `\` is the
10584        // root-cause edit; the `(` falls away in the same edit since
10585        // it's downstream of the Windows-shell convention).
10586        let d = dep_with_fonte(DepSource::Path {
10587            caminho: "..\\caixa-teia\\(cd foo)".into(),
10588        });
10589        let err = d.validate().unwrap_err();
10590        assert!(
10591            matches!(err, DepError::FonteCaminhoBackslash { .. }),
10592            "got {err:?}",
10593        );
10594    }
10595
10596    #[test]
10597    fn fonte_caminho_control_char_fires_before_shell_subshell_grouping() {
10598        // Cascade pin on the embedded-control-byte arm: a value
10599        // carrying both a control byte and `(` (`"../foo\n(cd bar)"` —
10600        // the canonical paste-from-multiline-doc footgun where a
10601        // newline landed mid-caminho between two paste fragments)
10602        // routes through `FonteCaminhoControlChar` not
10603        // `FonteCaminhoShellSubshellGrouping`. The POSIX-syscall-
10604        // rejected-byte / NUL-`CString::new`-fail diagnostic is the
10605        // load-bearing axis on every value that probes positive for
10606        // both — mirrors the cascade discipline on every prior arm.
10607        let d = dep_with_fonte(DepSource::Path {
10608            caminho: "../foo\n(cd bar)".into(),
10609        });
10610        let err = d.validate().unwrap_err();
10611        assert!(
10612            matches!(err, DepError::FonteCaminhoControlChar { .. }),
10613            "got {err:?}",
10614        );
10615    }
10616
10617    #[test]
10618    fn fonte_caminho_absolute_fires_before_shell_subshell_grouping() {
10619        // Cascade pin on the load-bearing leading-byte arm: a leading
10620        // `/` value with embedded `(` (`"/etc/(cd foo)"`) routes
10621        // through `FonteCaminhoAbsolute` not
10622        // `FonteCaminhoShellSubshellGrouping` — the host-layout-leak
10623        // diagnostic is the load-bearing axis, the subshell-grouping
10624        // byte is the secondary observation. Same precedence logic as
10625        // every prior leading-byte arm.
10626        let d = dep_with_fonte(DepSource::Path {
10627            caminho: "/etc/(cd foo)".into(),
10628        });
10629        let err = d.validate().unwrap_err();
10630        assert!(
10631            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10632            "got {err:?}",
10633        );
10634    }
10635
10636    #[test]
10637    fn fonte_caminho_var_expansion_fires_before_shell_subshell_grouping() {
10638        // Cascade pin on the upstream leading-`$` var-expansion arm: a
10639        // value carrying both a leading `$` and a `(` (`"$(date)/\
10640        // caixa-teia"` — the canonical "I pasted a `$(date)` modern-
10641        // command-substitution at the head of a sibling-workspace
10642        // path" footgun) routes through `FonteCaminhoVarExpansion` not
10643        // `FonteCaminhoShellSubshellGrouping`. The leading-byte
10644        // shell-variable-expansion is the more self-locating diagnostic
10645        // on values that probe as both — same load-bearing-leading-
10646        // byte cascade discipline every prior `:caminho` arm
10647        // establishes. Closing both halves of `$(<cmd>)` structurally
10648        // (leading `$` here, trailing `)` on the new arm) excludes the
10649        // entire modern Bourne command-substitution surface from the
10650        // typed `:caminho` accepted set; the cascade preserves the
10651        // narrower leading-byte diagnostic on values that probe both
10652        // halves at the canonical leading position.
10653        let d = dep_with_fonte(DepSource::Path {
10654            caminho: "$(date)/caixa-teia".into(),
10655        });
10656        let err = d.validate().unwrap_err();
10657        assert!(
10658            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
10659            "got {err:?}",
10660        );
10661    }
10662
10663    #[test]
10664    fn fonte_caminho_shell_subshell_grouping_fires_before_trailing_slash() {
10665        // Cascade pin on the immediate-successor arm: a value carrying
10666        // both `(` and a trailing `/` (`"../(cd foo)/"` — the canonical
10667        // "I tab-completed a path that already had a subshell-grouping
10668        // expansion tail" footgun) routes through
10669        // `FonteCaminhoShellSubshellGrouping` not
10670        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
10671        // the more semantic-locating axis (an author who removes the
10672        // `(` typically also drops the trailing separator since both
10673        // are paste-from-shell artifacts).
10674        let d = dep_with_fonte(DepSource::Path {
10675            caminho: "../(cd foo)/".into(),
10676        });
10677        let err = d.validate().unwrap_err();
10678        assert!(
10679            matches!(
10680                err,
10681                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
10682            ),
10683            "got {err:?}",
10684        );
10685    }
10686
10687    #[test]
10688    fn fonte_caminho_shell_subshell_grouping_diagnostic_carries_offending_dep_caminho_and_byte() {
10689        // Diagnostic-shape pin (peer with
10690        // `fonte_caminho_shell_glob_diagnostic_carries_offending_dep_caminho_and_byte`
10691        // on the closest two-byte peer arm): the error's Display
10692        // surfaces the offending `:nome`, the offending `:caminho`
10693        // verbatim, the offending byte's hex / character form, and
10694        // names the shell-subshell-grouping footgun explicitly so a
10695        // `feira lint` run can render the diagnostic without re-
10696        // parsing.
10697        let d = dep_with_fonte(DepSource::Path {
10698            caminho: "../caixa-teia/$(date)/build".into(),
10699        });
10700        let rendered = d.validate().unwrap_err().to_string();
10701        assert!(
10702            rendered.contains("caixa-teia"),
10703            "diagnostic must name the offending dep: {rendered}",
10704        );
10705        assert!(
10706            rendered.contains("../caixa-teia/$(date)/build"),
10707            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10708        );
10709        assert!(
10710            rendered.contains("0x28"),
10711            "diagnostic must surface the offending byte hex: {rendered:?}",
10712        );
10713        assert!(
10714            rendered.contains("subshell-grouping"),
10715            "diagnostic must name the shell-subshell-grouping footgun: {rendered:?}",
10716        );
10717        assert!(
10718            rendered.contains("command-substitution"),
10719            "diagnostic must reference the `$(<cmd>)` command-substitution vocabulary: \
10720             {rendered:?}",
10721        );
10722    }
10723
10724    // ── shell-brace-expansion / URI-Template-placeholder arm ───────────
10725    //
10726    // Peer with the prior `FonteCaminhoShellSubshellGrouping` (`(` /
10727    // `)`) byte-pair arm: the same per-byte cascade with the same
10728    // self-locating `byte: u8` diagnostic on the orthogonal `{` /
10729    // `}` brace-expansion / URI-Template placeholder axis. The peer
10730    // [`crate::render::is_git_repo_url`] (42d8f9d) closes the same
10731    // byte pair on the sibling `:fonte :repo` axis under the same
10732    // banner.
10733
10734    #[test]
10735    fn validate_rejects_path_fonte_with_caminho_carrying_brace_expansion_fan_across_siblings() {
10736        // The fail-before-pass-after pin for the canonical paste-from-
10737        // shell-history brace-expansion footgun: an author copies a
10738        // `cd ../{caixa-teia,caixa-helm}/build` shell-history one-
10739        // liner whose `{a,b}` brace expansion fans across two siblings
10740        // and silently passed every prior arm (`Path::is_absolute`
10741        // false on `..`, no control bytes, no `\`, no `<` / `>`, no
10742        // `|`, no `;`, no `&`, no backtick, no `*` / `?`, no `(` /
10743        // `)`, doesn't end in `/`; the leading-`$` f4efe9c
10744        // `FonteCaminhoVarExpansion` arm doesn't fire because the
10745        // value starts with `..` not `$`). The lacre embedded the
10746        // value verbatim, the resolver folded it through `Path::join`
10747        // looking for a literal `./../{caixa-teia,caixa-helm}/build`
10748        // subdirectory, and the failure surfaced at resolve time with
10749        // a non-self-locating `No such file or directory` error. The
10750        // new arm moves the rejection to validate time and names the
10751        // offending dep + caminho + byte verbatim. The arm fires on
10752        // the first `{` encountered.
10753        let d = dep_with_fonte(DepSource::Path {
10754            caminho: "../{caixa-teia,caixa-helm}/build".into(),
10755        });
10756        let err = d.validate().unwrap_err();
10757        let DepError::FonteCaminhoShellBraceExpansion {
10758            nome,
10759            caminho,
10760            byte,
10761        } = err
10762        else {
10763            panic!("expected FonteCaminhoShellBraceExpansion, got {err:?}");
10764        };
10765        assert_eq!(nome, "caixa-teia");
10766        assert_eq!(caminho, "../{caixa-teia,caixa-helm}/build");
10767        assert_eq!(byte, b'{');
10768    }
10769
10770    #[test]
10771    fn validate_rejects_path_fonte_with_caminho_carrying_close_brace() {
10772        // The symmetric close-brace paste shape (`"../caixa-teia}"` —
10773        // the degenerate "I selected an unbalanced closing brace out
10774        // of a shell-history block" idiom that probes for the
10775        // cascade's last-byte handling on a value carrying only the
10776        // closing byte). Pinned separately from the open-brace shape
10777        // so the gate's contract is "any `{` or `}` anywhere", not
10778        // single-byte coverage. Mirrors the peer
10779        // `validate_rejects_path_fonte_with_caminho_carrying_close_paren`
10780        // shape on the immediate-predecessor `FonteCaminhoShellSubshellGrouping`
10781        // arm.
10782        let d = dep_with_fonte(DepSource::Path {
10783            caminho: "../caixa-teia}".into(),
10784        });
10785        let err = d.validate().unwrap_err();
10786        let DepError::FonteCaminhoShellBraceExpansion { byte, .. } = err else {
10787            panic!("expected FonteCaminhoShellBraceExpansion, got {err:?}");
10788        };
10789        assert_eq!(byte, b'}');
10790    }
10791
10792    #[test]
10793    fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_brace() {
10794        // Leading-position `{` shape (`"{caixa-teia,caixa-helm}/build"`
10795        // — the canonical "I selected a `{a,b}` brace-expansion prefix
10796        // out of a shell-history one-liner" idiom). Pinned separately
10797        // from the embedded-byte shape so the gate covers every
10798        // position, not only mid-path.
10799        let d = dep_with_fonte(DepSource::Path {
10800            caminho: "{caixa-teia,caixa-helm}/build".into(),
10801        });
10802        let err = d.validate().unwrap_err();
10803        assert!(
10804            matches!(
10805                err,
10806                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
10807            ),
10808            "got {err:?}",
10809        );
10810    }
10811
10812    #[test]
10813    fn validate_rejects_path_fonte_with_caminho_carrying_uri_template_placeholder() {
10814        // The canonical URI-Template / Mustache / Helm doubled-brace
10815        // placeholder shape (`"../{{org}}/caixa-teia"` — the canonical
10816        // "I copied a `https://github.com/{{org}}/caixa-teia` README
10817        // quick-start / OpenAPI spec / Helm chart `home:` template
10818        // and forgot to substitute the placeholder" footgun). The arm
10819        // fires on the first `{` encountered; pinned so the gate's
10820        // coverage extends from the bare-brace shell-history shape to
10821        // the doubled-brace URI-Template / templating-engine shape.
10822        // Mirrors the peer 42d8f9d `is_git_repo_url` arm on the
10823        // sibling `:fonte :repo` axis.
10824        let d = dep_with_fonte(DepSource::Path {
10825            caminho: "../{{org}}/caixa-teia".into(),
10826        });
10827        let err = d.validate().unwrap_err();
10828        assert!(
10829            matches!(
10830                err,
10831                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
10832            ),
10833            "got {err:?}",
10834        );
10835    }
10836
10837    #[test]
10838    fn validate_rejects_path_fonte_with_caminho_carrying_brace_range_expansion() {
10839        // The canonical bash brace-range-expansion shape (`"../caixa-
10840        // v{1..10}"` — the `{1..10}` sequence expansion every bash /
10841        // zsh `for i in {1..10}; do …; done` idiom uses, the symmetric
10842        // sequence-range form to the `{a,b,c}` comma-separated form).
10843        // The arm fires on the first `{` encountered; pinned so the
10844        // gate's coverage extends from the comma-separated form to
10845        // the integer-range form.
10846        let d = dep_with_fonte(DepSource::Path {
10847            caminho: "../caixa-v{1..10}".into(),
10848        });
10849        let err = d.validate().unwrap_err();
10850        assert!(
10851            matches!(
10852                err,
10853                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
10854            ),
10855            "got {err:?}",
10856        );
10857    }
10858
10859    #[test]
10860    fn validate_accepts_path_fonte_with_caminho_carrying_no_brace_expansion() {
10861        // The positive-control pin: the gate targets only `{` / `}`,
10862        // never adjacent printable ASCII or POSIX-valid bytes. The
10863        // canonical relative POSIX path (`"../caixa-teia"`) and a
10864        // nested deeply-pathed variant with adjacent printable
10865        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue to
10866        // validate cleanly so the gate doesn't widen to a "no
10867        // printable punctuation anywhere" sweep that would defeat
10868        // the entire path-fonte author surface. Peer with
10869        // `validate_accepts_path_fonte_with_caminho_carrying_no_subshell_grouping`
10870        // on the immediate-predecessor arm.
10871        let d = dep_with_fonte(DepSource::Path {
10872            caminho: "../caixa-teia/sub-dir.v2".into(),
10873        });
10874        d.validate().unwrap();
10875    }
10876
10877    #[test]
10878    fn fonte_caminho_shell_subshell_grouping_fires_before_shell_brace_expansion() {
10879        // Cascade pin on the immediate-predecessor arm: a value
10880        // carrying both `(` and `{` (`"../(cd foo)/{a,b}"` — the
10881        // canonical "I pasted a subshell-grouping followed by a
10882        // brace-expansion tail" footgun) routes through
10883        // `FonteCaminhoShellSubshellGrouping` not
10884        // `FonteCaminhoShellBraceExpansion`. The subshell-grouping
10885        // shape is the more semantic-locating axis on every probe-
10886        // as-both value because it closes both halves of the modern
10887        // Bourne `$(<cmd>)` command-substitution surface — same
10888        // cascade discipline every prior `:caminho` arm establishes.
10889        let d = dep_with_fonte(DepSource::Path {
10890            caminho: "../(cd foo)/{a,b}".into(),
10891        });
10892        let err = d.validate().unwrap_err();
10893        assert!(
10894            matches!(
10895                err,
10896                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
10897            ),
10898            "got {err:?}",
10899        );
10900    }
10901
10902    #[test]
10903    fn fonte_caminho_shell_glob_fires_before_shell_brace_expansion() {
10904        // Cascade pin on the upstream shell-glob arm: a value carrying
10905        // both `*` and `{` (`"../caixa-teia/*{a,b}"` — the canonical
10906        // "I pasted a glob expansion followed by a brace-expansion
10907        // tail" footgun) routes through `FonteCaminhoShellGlob` not
10908        // `FonteCaminhoShellBraceExpansion`. The pathname-expansion
10909        // shape is the load-bearing root-cause edit on every
10910        // probe-as-both value.
10911        let d = dep_with_fonte(DepSource::Path {
10912            caminho: "../caixa-teia/*{a,b}".into(),
10913        });
10914        let err = d.validate().unwrap_err();
10915        assert!(
10916            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
10917            "got {err:?}",
10918        );
10919    }
10920
10921    #[test]
10922    fn fonte_caminho_shell_command_substitution_fires_before_shell_brace_expansion() {
10923        // Cascade pin on the upstream shell-command-substitution arm:
10924        // a value carrying both a backtick and `{` (``"../`whoami`/{a,b}"``
10925        // — the canonical "I pasted a legacy-backtick command-
10926        // substitution followed by a brace-expansion fan-out" footgun)
10927        // routes through `FonteCaminhoShellCommandSubstitution` not
10928        // `FonteCaminhoShellBraceExpansion`. The CWE-78 shell-
10929        // command-injection vector is the load-bearing root-cause
10930        // edit on every probe-as-both value.
10931        let d = dep_with_fonte(DepSource::Path {
10932            caminho: "../`whoami`/{a,b}".into(),
10933        });
10934        let err = d.validate().unwrap_err();
10935        assert!(
10936            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
10937            "got {err:?}",
10938        );
10939    }
10940
10941    #[test]
10942    fn fonte_caminho_shell_background_fires_before_shell_brace_expansion() {
10943        // Cascade pin on the upstream shell-background arm: a value
10944        // carrying both `&` and `{` (`"../caixa-teia & {a,b}"` — the
10945        // canonical "I pasted a `cmd & {fork-fan}` background-launch
10946        // + brace-expansion chain" footgun) routes through
10947        // `FonteCaminhoShellBackground` not
10948        // `FonteCaminhoShellBraceExpansion`. The background-launch
10949        // tail is the load-bearing root-cause edit on every
10950        // probe-as-both value.
10951        let d = dep_with_fonte(DepSource::Path {
10952            caminho: "../caixa-teia & {a,b}".into(),
10953        });
10954        let err = d.validate().unwrap_err();
10955        assert!(
10956            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
10957            "got {err:?}",
10958        );
10959    }
10960
10961    #[test]
10962    fn fonte_caminho_shell_semicolon_fires_before_shell_brace_expansion() {
10963        // Cascade pin on the upstream shell-semicolon arm: a value
10964        // carrying both `;` and `{` (`"../caixa-teia; {a,b}"` — the
10965        // canonical sequential-cleanup + brace-expansion paste
10966        // idiom) routes through `FonteCaminhoShellSemicolon` not
10967        // `FonteCaminhoShellBraceExpansion`. The sequential-command-
10968        // separator paste is the load-bearing root-cause edit on
10969        // every probe-as-both value.
10970        let d = dep_with_fonte(DepSource::Path {
10971            caminho: "../caixa-teia; {a,b}".into(),
10972        });
10973        let err = d.validate().unwrap_err();
10974        assert!(
10975            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
10976            "got {err:?}",
10977        );
10978    }
10979
10980    #[test]
10981    fn fonte_caminho_shell_pipe_fires_before_shell_brace_expansion() {
10982        // Cascade pin on the upstream shell-pipe arm: a value
10983        // carrying both `|` and `{` (`"../caixa-teia | {tee,cat}"`
10984        // — the canonical pipeline-to-brace-expansion paste idiom)
10985        // routes through `FonteCaminhoShellPipe` not
10986        // `FonteCaminhoShellBraceExpansion`. The pipeline-tail paste
10987        // is the load-bearing root-cause edit on every probe-as-
10988        // both value.
10989        let d = dep_with_fonte(DepSource::Path {
10990            caminho: "../caixa-teia | {tee,cat}".into(),
10991        });
10992        let err = d.validate().unwrap_err();
10993        assert!(
10994            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10995            "got {err:?}",
10996        );
10997    }
10998
10999    #[test]
11000    fn fonte_caminho_shell_redirection_fires_before_shell_brace_expansion() {
11001        // Cascade pin on the upstream shell-redirection arm: a value
11002        // carrying both `>` and `{` (`"../caixa-teia>log {a,b}"` —
11003        // the canonical "I pasted a `cmd > log {a,b}` redirect-
11004        // plus-brace-expansion chain" footgun) routes through
11005        // `FonteCaminhoShellRedirection` not
11006        // `FonteCaminhoShellBraceExpansion`. The input/output
11007        // redirection metachar carries the more self-locating
11008        // `byte` payload, so the prior arm wins on every probe-
11009        // as-both value.
11010        let d = dep_with_fonte(DepSource::Path {
11011            caminho: "../caixa-teia>log {a,b}".into(),
11012        });
11013        let err = d.validate().unwrap_err();
11014        assert!(
11015            matches!(
11016                err,
11017                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11018            ),
11019            "got {err:?}",
11020        );
11021    }
11022
11023    #[test]
11024    fn fonte_caminho_backslash_fires_before_shell_brace_expansion() {
11025        // Cascade pin on the upstream backslash arm: a value
11026        // carrying both `\` and `{` (`"..\caixa-teia\{a,b}"` — the
11027        // canonical "I pasted a Windows-shell `cd ..\path\{a,b}`
11028        // chain") routes through `FonteCaminhoBackslash` not
11029        // `FonteCaminhoShellBraceExpansion`. The cross-host-OS-
11030        // separator divergence is the load-bearing axis on every
11031        // probe-as-both value.
11032        let d = dep_with_fonte(DepSource::Path {
11033            caminho: "..\\caixa-teia\\{a,b}".into(),
11034        });
11035        let err = d.validate().unwrap_err();
11036        assert!(
11037            matches!(err, DepError::FonteCaminhoBackslash { .. }),
11038            "got {err:?}",
11039        );
11040    }
11041
11042    #[test]
11043    fn fonte_caminho_control_char_fires_before_shell_brace_expansion() {
11044        // Cascade pin on the embedded-control-byte arm: a value
11045        // carrying both a control byte and `{` (`"../foo\n{a,b}"` —
11046        // the canonical paste-from-multiline-doc footgun where a
11047        // newline landed mid-caminho between two paste fragments)
11048        // routes through `FonteCaminhoControlChar` not
11049        // `FonteCaminhoShellBraceExpansion`. The POSIX-syscall-
11050        // rejected-byte / NUL-`CString::new`-fail diagnostic is the
11051        // load-bearing axis on every value that probes positive for
11052        // both — mirrors the cascade discipline on every prior arm.
11053        let d = dep_with_fonte(DepSource::Path {
11054            caminho: "../foo\n{a,b}".into(),
11055        });
11056        let err = d.validate().unwrap_err();
11057        assert!(
11058            matches!(err, DepError::FonteCaminhoControlChar { .. }),
11059            "got {err:?}",
11060        );
11061    }
11062
11063    #[test]
11064    fn fonte_caminho_absolute_fires_before_shell_brace_expansion() {
11065        // Cascade pin on the load-bearing leading-byte arm: a
11066        // leading `/` value with embedded `{` (`"/etc/{a,b}"`)
11067        // routes through `FonteCaminhoAbsolute` not
11068        // `FonteCaminhoShellBraceExpansion` — the host-layout-leak
11069        // diagnostic is the load-bearing axis, the brace-expansion
11070        // byte is the secondary observation. Same precedence logic
11071        // as every prior leading-byte arm.
11072        let d = dep_with_fonte(DepSource::Path {
11073            caminho: "/etc/{a,b}".into(),
11074        });
11075        let err = d.validate().unwrap_err();
11076        assert!(
11077            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11078            "got {err:?}",
11079        );
11080    }
11081
11082    #[test]
11083    fn fonte_caminho_var_expansion_fires_before_shell_brace_expansion() {
11084        // Cascade pin on the upstream leading-`$` var-expansion
11085        // arm: a value carrying both a leading `$` and a `{`
11086        // (`"${ORG}/caixa-teia"` — the canonical "I pasted a
11087        // `${ORG}` shell-variable + curly-brace expansion at the
11088        // head of a sibling-workspace path" footgun) routes through
11089        // `FonteCaminhoVarExpansion` not
11090        // `FonteCaminhoShellBraceExpansion`. The leading-byte
11091        // shell-variable-expansion is the more self-locating
11092        // diagnostic on values that probe as both — same
11093        // load-bearing-leading-byte cascade discipline every prior
11094        // `:caminho` arm establishes.
11095        let d = dep_with_fonte(DepSource::Path {
11096            caminho: "${ORG}/caixa-teia".into(),
11097        });
11098        let err = d.validate().unwrap_err();
11099        assert!(
11100            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
11101            "got {err:?}",
11102        );
11103    }
11104
11105    #[test]
11106    fn fonte_caminho_shell_brace_expansion_fires_before_trailing_slash() {
11107        // Cascade pin on the immediate-successor arm: a value
11108        // carrying both `{` and a trailing `/`
11109        // (`"../{caixa-teia,caixa-helm}/"` — the canonical "I
11110        // tab-completed a path that already had a brace-expansion
11111        // expansion tail" footgun) routes through
11112        // `FonteCaminhoShellBraceExpansion` not
11113        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
11114        // is the more semantic-locating axis (an author who removes
11115        // the `{` typically also drops the trailing separator since
11116        // both are paste-from-shell artifacts).
11117        let d = dep_with_fonte(DepSource::Path {
11118            caminho: "../{caixa-teia,caixa-helm}/".into(),
11119        });
11120        let err = d.validate().unwrap_err();
11121        assert!(
11122            matches!(
11123                err,
11124                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
11125            ),
11126            "got {err:?}",
11127        );
11128    }
11129
11130    #[test]
11131    fn fonte_caminho_shell_brace_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
11132        // Diagnostic-shape pin (peer with
11133        // `fonte_caminho_shell_subshell_grouping_diagnostic_carries_offending_dep_caminho_and_byte`
11134        // on the closest two-byte peer arm): the error's Display
11135        // surfaces the offending `:nome`, the offending `:caminho`
11136        // verbatim, the offending byte's hex / character form, and
11137        // names the shell-brace-expansion / URI-Template footgun
11138        // explicitly so a `feira lint` run can render the diagnostic
11139        // without re-parsing.
11140        let d = dep_with_fonte(DepSource::Path {
11141            caminho: "../{caixa-teia,caixa-helm}/build".into(),
11142        });
11143        let rendered = d.validate().unwrap_err().to_string();
11144        assert!(
11145            rendered.contains("caixa-teia"),
11146            "diagnostic must name the offending dep: {rendered}",
11147        );
11148        assert!(
11149            rendered.contains("../{caixa-teia,caixa-helm}/build"),
11150            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11151        );
11152        assert!(
11153            rendered.contains("0x7b"),
11154            "diagnostic must surface the offending byte hex: {rendered:?}",
11155        );
11156        assert!(
11157            rendered.contains("brace-expansion"),
11158            "diagnostic must name the shell-brace-expansion footgun: {rendered:?}",
11159        );
11160        assert!(
11161            rendered.contains("URI Template"),
11162            "diagnostic must reference the RFC-6570 URI-Template-placeholder vocabulary: \
11163             {rendered:?}",
11164        );
11165    }
11166
11167    #[test]
11168    fn validate_rejects_path_fonte_with_caminho_carrying_bracket_glob_character_class() {
11169        // The canonical paste-from-shell-history bracket-glob /
11170        // character-class footgun: an author copies a
11171        // `cd ../caixa-[a-z]/build` shell-history one-liner whose
11172        // `[a-z]` POSIX glob character-class matches every lowercase-
11173        // ASCII-suffix sibling caixa directory and silently passed
11174        // every prior arm (`Path::is_absolute` false on `..`, no
11175        // control bytes, no `\`, no `<` / `>`, no `|`, no `;`, no
11176        // `&`, no backtick, no `*` / `?`, no `(` / `)`, no `{` /
11177        // `}`, doesn't end in `/`; the leading-`$` f4efe9c
11178        // `FonteCaminhoVarExpansion` arm doesn't fire because the
11179        // value starts with `..` not `$`). The lacre embedded the
11180        // value verbatim, the resolver folded it through
11181        // `Path::join` looking for a literal `./../caixa-[a-z]/
11182        // build` subdirectory, and the failure surfaced at resolve
11183        // time with a non-self-locating `No such file or directory`
11184        // error. The new arm moves the rejection to validate time
11185        // and names the offending dep + caminho + byte verbatim.
11186        // The arm fires on the first `[` encountered.
11187        let d = dep_with_fonte(DepSource::Path {
11188            caminho: "../caixa-[a-z]/build".into(),
11189        });
11190        let err = d.validate().unwrap_err();
11191        let DepError::FonteCaminhoShellBracketExpansion {
11192            nome,
11193            caminho,
11194            byte,
11195        } = err
11196        else {
11197            panic!("expected FonteCaminhoShellBracketExpansion, got {err:?}");
11198        };
11199        assert_eq!(nome, "caixa-teia");
11200        assert_eq!(caminho, "../caixa-[a-z]/build");
11201        assert_eq!(byte, b'[');
11202    }
11203
11204    #[test]
11205    fn validate_rejects_path_fonte_with_caminho_carrying_close_bracket() {
11206        // The symmetric close-bracket paste shape (`"../caixa-teia]"`
11207        // — the degenerate "I selected an unbalanced closing bracket
11208        // out of a glob character-class block" idiom that probes for
11209        // the cascade's last-byte handling on a value carrying only
11210        // the closing byte). Pinned separately from the open-bracket
11211        // shape so the gate's contract is "any `[` or `]` anywhere",
11212        // not single-byte coverage. Mirrors the peer
11213        // `validate_rejects_path_fonte_with_caminho_carrying_close_brace`
11214        // shape on the immediate-predecessor
11215        // `FonteCaminhoShellBraceExpansion` arm.
11216        let d = dep_with_fonte(DepSource::Path {
11217            caminho: "../caixa-teia]".into(),
11218        });
11219        let err = d.validate().unwrap_err();
11220        let DepError::FonteCaminhoShellBracketExpansion { byte, .. } = err else {
11221            panic!("expected FonteCaminhoShellBracketExpansion, got {err:?}");
11222        };
11223        assert_eq!(byte, b']');
11224    }
11225
11226    #[test]
11227    fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_bracket() {
11228        // Leading-position `[` shape (`"[caixa-teia]/build"` — the
11229        // canonical "I selected a `[caixa-teia]` TOML-table-header /
11230        // glob-character-class prefix out of an aligned config /
11231        // shell-history one-liner" idiom). Pinned separately from
11232        // the embedded-byte shape so the gate covers every position,
11233        // not only mid-path.
11234        let d = dep_with_fonte(DepSource::Path {
11235            caminho: "[caixa-teia]/build".into(),
11236        });
11237        let err = d.validate().unwrap_err();
11238        assert!(
11239            matches!(
11240                err,
11241                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
11242            ),
11243            "got {err:?}",
11244        );
11245    }
11246
11247    #[test]
11248    fn validate_rejects_path_fonte_with_caminho_carrying_toml_inline_array() {
11249        // The canonical TOML inline-array / YAML flow-sequence
11250        // paste shape (`"../[\"a\", \"b\"]/caixa-teia"` — the
11251        // canonical "I copied a `features = [\"a\", \"b\"]` TOML
11252        // inline-array out of a sibling-Cargo manifest" cross-idiom
11253        // leak; the symmetric YAML flow-sequence form `paths: [/a,
11254        // /b]` paste-from-values.yaml shape carries the same
11255        // bracket pair). The arm fires on the first `[` encountered;
11256        // pinned so the gate's coverage extends from the bare-
11257        // bracket glob-character-class shape to the TOML / YAML /
11258        // JSON array-literal shape.
11259        let d = dep_with_fonte(DepSource::Path {
11260            caminho: "../[\"a\", \"b\"]/caixa-teia".into(),
11261        });
11262        let err = d.validate().unwrap_err();
11263        assert!(
11264            matches!(
11265                err,
11266                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
11267            ),
11268            "got {err:?}",
11269        );
11270    }
11271
11272    #[test]
11273    fn validate_rejects_path_fonte_with_caminho_carrying_shell_test_builtin() {
11274        // The canonical POSIX `test` / `[` builtin command paste
11275        // shape (`"../[ -d caixa-teia ]"` — the `[ <expr> ]` shell-
11276        // script conditional every paste-from-shell-script idiom
11277        // carries; bash's `[[ <expr> ]]` extended-test grammar
11278        // would surface the same byte pair). The arm fires on the
11279        // first `[` encountered; pinned so the gate's coverage
11280        // extends from the embedded-glob-character-class shape to
11281        // the leading-`test`-builtin / extended-test form.
11282        let d = dep_with_fonte(DepSource::Path {
11283            caminho: "../[ -d caixa-teia ]".into(),
11284        });
11285        let err = d.validate().unwrap_err();
11286        assert!(
11287            matches!(
11288                err,
11289                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
11290            ),
11291            "got {err:?}",
11292        );
11293    }
11294
11295    #[test]
11296    fn validate_accepts_path_fonte_with_caminho_carrying_no_bracket_expansion() {
11297        // The positive-control pin: the gate targets only `[` /
11298        // `]`, never adjacent printable ASCII or POSIX-valid bytes.
11299        // The canonical relative POSIX path (`"../caixa-teia"`) and
11300        // a nested deeply-pathed variant with adjacent printable
11301        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
11302        // to validate cleanly so the gate doesn't widen to a "no
11303        // printable punctuation anywhere" sweep that would defeat
11304        // the entire path-fonte author surface. Peer with
11305        // `validate_accepts_path_fonte_with_caminho_carrying_no_brace_expansion`
11306        // on the immediate-predecessor arm.
11307        let d = dep_with_fonte(DepSource::Path {
11308            caminho: "../caixa-teia/sub-dir.v2".into(),
11309        });
11310        d.validate().unwrap();
11311    }
11312
11313    #[test]
11314    fn fonte_caminho_shell_brace_expansion_fires_before_shell_bracket_expansion() {
11315        // Cascade pin on the immediate-predecessor arm: a value
11316        // carrying both `{` and `[` (`"../{a,b}[ch]"` — the
11317        // canonical "I pasted a brace-expansion fan followed by a
11318        // glob-character-class tail" footgun) routes through
11319        // `FonteCaminhoShellBraceExpansion` not
11320        // `FonteCaminhoShellBracketExpansion`. The brace-expansion
11321        // fan is the load-bearing root-cause edit on every
11322        // probe-as-both value because the bracket-class tail
11323        // typically rides on a prior brace-expansion expansion;
11324        // same cascade discipline every prior `:caminho` arm
11325        // establishes.
11326        let d = dep_with_fonte(DepSource::Path {
11327            caminho: "../{a,b}[ch]".into(),
11328        });
11329        let err = d.validate().unwrap_err();
11330        assert!(
11331            matches!(
11332                err,
11333                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
11334            ),
11335            "got {err:?}",
11336        );
11337    }
11338
11339    #[test]
11340    fn fonte_caminho_shell_subshell_grouping_fires_before_shell_bracket_expansion() {
11341        // Cascade pin on the upstream shell-subshell-grouping arm:
11342        // a value carrying both `(` and `[` (`"../(cd foo)/[ch]"` —
11343        // the canonical "I pasted a subshell-grouping followed by
11344        // a glob-character-class tail" footgun) routes through
11345        // `FonteCaminhoShellSubshellGrouping` not
11346        // `FonteCaminhoShellBracketExpansion`. The modern Bourne
11347        // `$(<cmd>)` command-substitution boundary is the load-
11348        // bearing axis on every probe-as-both value.
11349        let d = dep_with_fonte(DepSource::Path {
11350            caminho: "../(cd foo)/[ch]".into(),
11351        });
11352        let err = d.validate().unwrap_err();
11353        assert!(
11354            matches!(
11355                err,
11356                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
11357            ),
11358            "got {err:?}",
11359        );
11360    }
11361
11362    #[test]
11363    fn fonte_caminho_shell_glob_fires_before_shell_bracket_expansion() {
11364        // Cascade pin on the upstream shell-glob arm: a value
11365        // carrying both `*` and `[` (`"../caixa-teia/*[ch]"` — the
11366        // canonical "I pasted a `*.[ch]` C-source-file glob whose
11367        // unbounded `*` precedes the bracket character-class"
11368        // footgun) routes through `FonteCaminhoShellGlob` not
11369        // `FonteCaminhoShellBracketExpansion`. The unbounded
11370        // pathname-expansion sentinel is the load-bearing root-
11371        // cause edit on every probe-as-both value — the unbounded
11372        // `*` carries the more aggressive expansion vector than
11373        // the bounded `[ch]` class, so the prior arm wins.
11374        let d = dep_with_fonte(DepSource::Path {
11375            caminho: "../caixa-teia/*[ch]".into(),
11376        });
11377        let err = d.validate().unwrap_err();
11378        assert!(
11379            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
11380            "got {err:?}",
11381        );
11382    }
11383
11384    #[test]
11385    fn fonte_caminho_shell_command_substitution_fires_before_shell_bracket_expansion() {
11386        // Cascade pin on the upstream shell-command-substitution
11387        // arm: a value carrying both a backtick and `[`
11388        // (``"../`whoami`/[ch]"`` — the canonical "I pasted a
11389        // legacy-backtick command-substitution followed by a
11390        // glob-character-class tail" footgun) routes through
11391        // `FonteCaminhoShellCommandSubstitution` not
11392        // `FonteCaminhoShellBracketExpansion`. The CWE-78 shell-
11393        // command-injection vector is the load-bearing root-cause
11394        // edit on every probe-as-both value.
11395        let d = dep_with_fonte(DepSource::Path {
11396            caminho: "../`whoami`/[ch]".into(),
11397        });
11398        let err = d.validate().unwrap_err();
11399        assert!(
11400            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11401            "got {err:?}",
11402        );
11403    }
11404
11405    #[test]
11406    fn fonte_caminho_shell_background_fires_before_shell_bracket_expansion() {
11407        // Cascade pin on the upstream shell-background arm: a
11408        // value carrying both `&` and `[` (`"../caixa-teia & [ch]"`
11409        // — the canonical "I pasted a `cmd & [glob]` background-
11410        // launch + bracket-class chain" footgun) routes through
11411        // `FonteCaminhoShellBackground` not
11412        // `FonteCaminhoShellBracketExpansion`. The background-
11413        // launch tail is the load-bearing root-cause edit on
11414        // every probe-as-both value.
11415        let d = dep_with_fonte(DepSource::Path {
11416            caminho: "../caixa-teia & [ch]".into(),
11417        });
11418        let err = d.validate().unwrap_err();
11419        assert!(
11420            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11421            "got {err:?}",
11422        );
11423    }
11424
11425    #[test]
11426    fn fonte_caminho_shell_semicolon_fires_before_shell_bracket_expansion() {
11427        // Cascade pin on the upstream shell-semicolon arm: a value
11428        // carrying both `;` and `[` (`"../caixa-teia; [ch]"` — the
11429        // canonical sequential-cleanup + bracket-class paste
11430        // idiom) routes through `FonteCaminhoShellSemicolon` not
11431        // `FonteCaminhoShellBracketExpansion`. The sequential-
11432        // command-separator paste is the load-bearing root-cause
11433        // edit on every probe-as-both value.
11434        let d = dep_with_fonte(DepSource::Path {
11435            caminho: "../caixa-teia; [ch]".into(),
11436        });
11437        let err = d.validate().unwrap_err();
11438        assert!(
11439            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11440            "got {err:?}",
11441        );
11442    }
11443
11444    #[test]
11445    fn fonte_caminho_shell_pipe_fires_before_shell_bracket_expansion() {
11446        // Cascade pin on the upstream shell-pipe arm: a value
11447        // carrying both `|` and `[` (`"../caixa-teia | [tee]"` —
11448        // the canonical pipeline-to-bracket-class paste idiom)
11449        // routes through `FonteCaminhoShellPipe` not
11450        // `FonteCaminhoShellBracketExpansion`. The pipeline-tail
11451        // paste is the load-bearing root-cause edit on every
11452        // probe-as-both value.
11453        let d = dep_with_fonte(DepSource::Path {
11454            caminho: "../caixa-teia | [tee]".into(),
11455        });
11456        let err = d.validate().unwrap_err();
11457        assert!(
11458            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11459            "got {err:?}",
11460        );
11461    }
11462
11463    #[test]
11464    fn fonte_caminho_shell_redirection_fires_before_shell_bracket_expansion() {
11465        // Cascade pin on the upstream shell-redirection arm: a
11466        // value carrying both `>` and `[` (`"../caixa-teia>log
11467        // [ch]"` — the canonical "I pasted a `cmd > log [glob]`
11468        // redirect-plus-bracket chain" footgun) routes through
11469        // `FonteCaminhoShellRedirection` not
11470        // `FonteCaminhoShellBracketExpansion`. The input/output
11471        // redirection metachar carries the more self-locating
11472        // `byte` payload, so the prior arm wins on every
11473        // probe-as-both value.
11474        let d = dep_with_fonte(DepSource::Path {
11475            caminho: "../caixa-teia>log [ch]".into(),
11476        });
11477        let err = d.validate().unwrap_err();
11478        assert!(
11479            matches!(
11480                err,
11481                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11482            ),
11483            "got {err:?}",
11484        );
11485    }
11486
11487    #[test]
11488    fn fonte_caminho_backslash_fires_before_shell_bracket_expansion() {
11489        // Cascade pin on the upstream backslash arm: a value
11490        // carrying both `\` and `[` (`"..\caixa-teia\[ch]"` — the
11491        // canonical "I pasted a Windows-shell `cd ..\path\[glob]`
11492        // chain") routes through `FonteCaminhoBackslash` not
11493        // `FonteCaminhoShellBracketExpansion`. The cross-host-OS-
11494        // separator divergence is the load-bearing axis on every
11495        // probe-as-both value.
11496        let d = dep_with_fonte(DepSource::Path {
11497            caminho: "..\\caixa-teia\\[ch]".into(),
11498        });
11499        let err = d.validate().unwrap_err();
11500        assert!(
11501            matches!(err, DepError::FonteCaminhoBackslash { .. }),
11502            "got {err:?}",
11503        );
11504    }
11505
11506    #[test]
11507    fn fonte_caminho_control_char_fires_before_shell_bracket_expansion() {
11508        // Cascade pin on the embedded-control-byte arm: a value
11509        // carrying both a control byte and `[` (`"../foo\n[ch]"` —
11510        // the canonical paste-from-multiline-doc footgun where a
11511        // newline landed mid-caminho between two paste fragments)
11512        // routes through `FonteCaminhoControlChar` not
11513        // `FonteCaminhoShellBracketExpansion`. The POSIX-syscall-
11514        // rejected-byte / NUL-`CString::new`-fail diagnostic is
11515        // the load-bearing axis on every value that probes
11516        // positive for both — mirrors the cascade discipline on
11517        // every prior arm.
11518        let d = dep_with_fonte(DepSource::Path {
11519            caminho: "../foo\n[ch]".into(),
11520        });
11521        let err = d.validate().unwrap_err();
11522        assert!(
11523            matches!(err, DepError::FonteCaminhoControlChar { .. }),
11524            "got {err:?}",
11525        );
11526    }
11527
11528    #[test]
11529    fn fonte_caminho_absolute_fires_before_shell_bracket_expansion() {
11530        // Cascade pin on the load-bearing leading-byte arm: a
11531        // leading `/` value with embedded `[` (`"/etc/[ch]"`)
11532        // routes through `FonteCaminhoAbsolute` not
11533        // `FonteCaminhoShellBracketExpansion` — the host-layout-
11534        // leak diagnostic is the load-bearing axis, the bracket-
11535        // expansion byte is the secondary observation. Same
11536        // precedence logic as every prior leading-byte arm.
11537        let d = dep_with_fonte(DepSource::Path {
11538            caminho: "/etc/[ch]".into(),
11539        });
11540        let err = d.validate().unwrap_err();
11541        assert!(
11542            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11543            "got {err:?}",
11544        );
11545    }
11546
11547    #[test]
11548    fn fonte_caminho_var_expansion_fires_before_shell_bracket_expansion() {
11549        // Cascade pin on the upstream leading-`$` var-expansion
11550        // arm: a value carrying both a leading `$` and a `[`
11551        // (`"$DIR/[ch]"` — the canonical "I pasted a `$DIR` shell-
11552        // variable + bracket-class at the head of a sibling-
11553        // workspace path" footgun) routes through
11554        // `FonteCaminhoVarExpansion` not
11555        // `FonteCaminhoShellBracketExpansion`. The leading-byte
11556        // shell-variable-expansion is the more self-locating
11557        // diagnostic on values that probe as both — same
11558        // load-bearing-leading-byte cascade discipline every
11559        // prior `:caminho` arm establishes.
11560        let d = dep_with_fonte(DepSource::Path {
11561            caminho: "$DIR/[ch]".into(),
11562        });
11563        let err = d.validate().unwrap_err();
11564        assert!(
11565            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
11566            "got {err:?}",
11567        );
11568    }
11569
11570    #[test]
11571    fn fonte_caminho_shell_bracket_expansion_fires_before_trailing_slash() {
11572        // Cascade pin on the immediate-successor arm: a value
11573        // carrying both `[` and a trailing `/` (`"../[a-z]/"` —
11574        // the canonical "I tab-completed a path that already had
11575        // a bracket-glob-character-class expansion tail" footgun)
11576        // routes through `FonteCaminhoShellBracketExpansion` not
11577        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
11578        // is the more semantic-locating axis (an author who
11579        // removes the `[` typically also drops the trailing
11580        // separator since both are paste-from-shell artifacts).
11581        let d = dep_with_fonte(DepSource::Path {
11582            caminho: "../[a-z]/".into(),
11583        });
11584        let err = d.validate().unwrap_err();
11585        assert!(
11586            matches!(
11587                err,
11588                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
11589            ),
11590            "got {err:?}",
11591        );
11592    }
11593
11594    #[test]
11595    fn fonte_caminho_shell_bracket_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
11596        // Diagnostic-shape pin (peer with
11597        // `fonte_caminho_shell_brace_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
11598        // on the closest two-byte peer arm): the error's Display
11599        // surfaces the offending `:nome`, the offending `:caminho`
11600        // verbatim, the offending byte's hex / character form, and
11601        // names the shell-bracket-expansion / glob-character-class
11602        // footgun explicitly so a `feira lint` run can render the
11603        // diagnostic without re-parsing.
11604        let d = dep_with_fonte(DepSource::Path {
11605            caminho: "../caixa-[a-z]/build".into(),
11606        });
11607        let rendered = d.validate().unwrap_err().to_string();
11608        assert!(
11609            rendered.contains("caixa-teia"),
11610            "diagnostic must name the offending dep: {rendered}",
11611        );
11612        assert!(
11613            rendered.contains("../caixa-[a-z]/build"),
11614            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11615        );
11616        assert!(
11617            rendered.contains("0x5b"),
11618            "diagnostic must surface the offending byte hex: {rendered:?}",
11619        );
11620        assert!(
11621            rendered.contains("bracket-expansion"),
11622            "diagnostic must name the shell-bracket-expansion footgun: {rendered:?}",
11623        );
11624        assert!(
11625            rendered.contains("glob-character-class"),
11626            "diagnostic must reference the POSIX glob-character-class vocabulary: \
11627             {rendered:?}",
11628        );
11629    }
11630
11631    #[test]
11632    fn validate_rejects_path_fonte_with_caminho_carrying_single_quote_grouping() {
11633        // The canonical paste-from-shell-history strong-quoted
11634        // sibling-workspace-path footgun: an author copies a
11635        // `cd '../caixa-teia'` shell-history one-liner whose strong-
11636        // quoting preserved the path across a whitespace paste
11637        // boundary and silently passed every prior arm
11638        // (`Path::is_absolute` false on `'..`, no control bytes, no
11639        // `\`, no `<` / `>`, no `|`, no `;`, no `&`, no backtick, no
11640        // `*` / `?`, no `(` / `)`, no `{` / `}`, no `[` / `]`,
11641        // doesn't end in `/`; the leading-`$` f4efe9c
11642        // `FonteCaminhoVarExpansion` arm doesn't fire because the
11643        // value starts with `'` not `$`). The lacre embedded the
11644        // value verbatim, the resolver folded it through
11645        // `Path::join` looking for a literal `./'../caixa-teia'`
11646        // subdirectory, and the failure surfaced at resolve time
11647        // with a non-self-locating `No such file or directory`
11648        // error. The new arm moves the rejection to validate time
11649        // and names the offending dep + caminho + byte verbatim.
11650        // The arm fires on the first `'` encountered.
11651        let d = dep_with_fonte(DepSource::Path {
11652            caminho: "'../caixa-teia'".into(),
11653        });
11654        let err = d.validate().unwrap_err();
11655        let DepError::FonteCaminhoShellQuoteGrouping {
11656            nome,
11657            caminho,
11658            byte,
11659        } = err
11660        else {
11661            panic!("expected FonteCaminhoShellQuoteGrouping, got {err:?}");
11662        };
11663        assert_eq!(nome, "caixa-teia");
11664        assert_eq!(caminho, "'../caixa-teia'");
11665        assert_eq!(byte, b'\'');
11666    }
11667
11668    #[test]
11669    fn validate_rejects_path_fonte_with_caminho_carrying_double_quote_grouping() {
11670        // The symmetric weak-quoted paste shape (`"\"../caixa-teia\""`
11671        // — the canonical paste-from-JSON-config / paste-from-YAML-
11672        // flow-scalar / paste-from-TOML-basic-string / paste-from-
11673        // tatara-lisp-string-literal cross-idiom leak). Pinned
11674        // separately from the single-quote shape so the gate's
11675        // contract is "any `'` or `\"` anywhere", not single-byte
11676        // coverage. Mirrors the peer
11677        // `validate_rejects_path_fonte_with_caminho_carrying_close_bracket`
11678        // shape on the immediate-predecessor
11679        // `FonteCaminhoShellBracketExpansion` arm.
11680        let d = dep_with_fonte(DepSource::Path {
11681            caminho: "\"../caixa-teia\"".into(),
11682        });
11683        let err = d.validate().unwrap_err();
11684        let DepError::FonteCaminhoShellQuoteGrouping { byte, .. } = err else {
11685            panic!("expected FonteCaminhoShellQuoteGrouping, got {err:?}");
11686        };
11687        assert_eq!(byte, b'"');
11688    }
11689
11690    #[test]
11691    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_double_quote() {
11692        // Embedded-position `"` shape (`"../\"caixa-teia\""` — the
11693        // canonical "I pasted a JSON key-value pair fragment into
11694        // the middle of the path" idiom). Pinned separately from
11695        // the leading-byte shape so the gate covers every position,
11696        // not only leading.
11697        let d = dep_with_fonte(DepSource::Path {
11698            caminho: "../\"caixa-teia\"".into(),
11699        });
11700        let err = d.validate().unwrap_err();
11701        assert!(
11702            matches!(
11703                err,
11704                DepError::FonteCaminhoShellQuoteGrouping { byte: b'"', .. },
11705            ),
11706            "got {err:?}",
11707        );
11708    }
11709
11710    #[test]
11711    fn validate_rejects_path_fonte_with_caminho_carrying_yaml_flow_scalar_paste() {
11712        // The canonical YAML double-quoted flow-scalar cross-idiom
11713        // leak shape (`"path: \"../caixa-teia\""` — the "I copied a
11714        // `path: \"...\"` YAML flow-scalar entry out of an aligned
11715        // values.yaml / K8s manifest and dropped it verbatim into
11716        // the `:caminho` slot including the `path: ` key prefix"
11717        // paste-idiom). The arm fires on the first `"` encountered;
11718        // pinned so the gate's coverage extends from the bare-quote
11719        // paste shape to the aligned-YAML-manifest cross-idiom-leak
11720        // shape.
11721        let d = dep_with_fonte(DepSource::Path {
11722            caminho: "path: \"../caixa-teia\"".into(),
11723        });
11724        let err = d.validate().unwrap_err();
11725        assert!(
11726            matches!(
11727                err,
11728                DepError::FonteCaminhoShellQuoteGrouping { byte: b'"', .. },
11729            ),
11730            "got {err:?}",
11731        );
11732    }
11733
11734    #[test]
11735    fn validate_accepts_path_fonte_with_caminho_carrying_no_quote_grouping() {
11736        // The positive-control pin: the gate targets only `'` /
11737        // `"`, never adjacent printable ASCII or POSIX-valid bytes.
11738        // The canonical relative POSIX path (`"../caixa-teia"`) and
11739        // a nested deeply-pathed variant with adjacent printable
11740        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
11741        // to validate cleanly so the gate doesn't widen to a "no
11742        // printable punctuation anywhere" sweep that would defeat
11743        // the entire path-fonte author surface. Peer with
11744        // `validate_accepts_path_fonte_with_caminho_carrying_no_bracket_expansion`
11745        // on the immediate-predecessor arm.
11746        let d = dep_with_fonte(DepSource::Path {
11747            caminho: "../caixa-teia/sub-dir.v2".into(),
11748        });
11749        d.validate().unwrap();
11750    }
11751
11752    #[test]
11753    fn fonte_caminho_shell_bracket_expansion_fires_before_shell_quote_grouping() {
11754        // Cascade pin on the immediate-predecessor arm: a value
11755        // carrying both `[` and `'` (`"../[a-z]'x'"` — the canonical
11756        // "I pasted a glob-character-class followed by a strong-
11757        // quoted literal tail" footgun) routes through
11758        // `FonteCaminhoShellBracketExpansion` not
11759        // `FonteCaminhoShellQuoteGrouping`. The glob-character-class
11760        // expansion is the load-bearing root-cause edit on every
11761        // probe-as-both value; same cascade discipline every prior
11762        // `:caminho` arm establishes.
11763        let d = dep_with_fonte(DepSource::Path {
11764            caminho: "../[a-z]'x'".into(),
11765        });
11766        let err = d.validate().unwrap_err();
11767        assert!(
11768            matches!(
11769                err,
11770                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
11771            ),
11772            "got {err:?}",
11773        );
11774    }
11775
11776    #[test]
11777    fn fonte_caminho_shell_brace_expansion_fires_before_shell_quote_grouping() {
11778        // Cascade pin on the upstream shell-brace-expansion arm: a
11779        // value carrying both `{` and `'` (`"../{a,b}'x'"` — the
11780        // canonical "I pasted a brace-expansion fan followed by a
11781        // strong-quoted literal tail" footgun) routes through
11782        // `FonteCaminhoShellBraceExpansion` not
11783        // `FonteCaminhoShellQuoteGrouping`. The brace-expansion fan
11784        // is the load-bearing root-cause edit on every probe-as-
11785        // both value.
11786        let d = dep_with_fonte(DepSource::Path {
11787            caminho: "../{a,b}'x'".into(),
11788        });
11789        let err = d.validate().unwrap_err();
11790        assert!(
11791            matches!(
11792                err,
11793                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
11794            ),
11795            "got {err:?}",
11796        );
11797    }
11798
11799    #[test]
11800    fn fonte_caminho_shell_subshell_grouping_fires_before_shell_quote_grouping() {
11801        // Cascade pin on the upstream shell-subshell-grouping arm:
11802        // a value carrying both `(` and `'` (`"../(cd foo)/'x'"` —
11803        // the canonical "I pasted a subshell-grouping followed by
11804        // a strong-quoted literal tail" footgun) routes through
11805        // `FonteCaminhoShellSubshellGrouping` not
11806        // `FonteCaminhoShellQuoteGrouping`. The modern Bourne
11807        // `$(<cmd>)` command-substitution boundary is the load-
11808        // bearing axis on every probe-as-both value.
11809        let d = dep_with_fonte(DepSource::Path {
11810            caminho: "../(cd foo)/'x'".into(),
11811        });
11812        let err = d.validate().unwrap_err();
11813        assert!(
11814            matches!(
11815                err,
11816                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
11817            ),
11818            "got {err:?}",
11819        );
11820    }
11821
11822    #[test]
11823    fn fonte_caminho_shell_glob_fires_before_shell_quote_grouping() {
11824        // Cascade pin on the upstream shell-glob arm: a value
11825        // carrying both `*` and `'` (`"../caixa-teia/*'x'"` — the
11826        // canonical "I pasted a `*` unbounded pathname-expansion
11827        // followed by a strong-quoted literal tail" footgun) routes
11828        // through `FonteCaminhoShellGlob` not
11829        // `FonteCaminhoShellQuoteGrouping`. The unbounded pathname-
11830        // expansion sentinel is the load-bearing root-cause edit
11831        // on every probe-as-both value.
11832        let d = dep_with_fonte(DepSource::Path {
11833            caminho: "../caixa-teia/*'x'".into(),
11834        });
11835        let err = d.validate().unwrap_err();
11836        assert!(
11837            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
11838            "got {err:?}",
11839        );
11840    }
11841
11842    #[test]
11843    fn fonte_caminho_shell_command_substitution_fires_before_shell_quote_grouping() {
11844        // Cascade pin on the upstream shell-command-substitution
11845        // arm: a value carrying both a backtick and `'`
11846        // (``"../`whoami`/'x'"`` — the canonical "I pasted a
11847        // legacy-backtick command-substitution followed by a
11848        // strong-quoted literal tail" footgun) routes through
11849        // `FonteCaminhoShellCommandSubstitution` not
11850        // `FonteCaminhoShellQuoteGrouping`. The CWE-78 shell-
11851        // command-injection vector is the load-bearing root-cause
11852        // edit on every probe-as-both value.
11853        let d = dep_with_fonte(DepSource::Path {
11854            caminho: "../`whoami`/'x'".into(),
11855        });
11856        let err = d.validate().unwrap_err();
11857        assert!(
11858            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11859            "got {err:?}",
11860        );
11861    }
11862
11863    #[test]
11864    fn fonte_caminho_shell_background_fires_before_shell_quote_grouping() {
11865        // Cascade pin on the upstream shell-background arm: a value
11866        // carrying both `&` and `'` (`"../caixa-teia & 'x'"` — the
11867        // canonical "I pasted a `cmd & 'literal'` background-launch
11868        // + quote chain" footgun) routes through
11869        // `FonteCaminhoShellBackground` not
11870        // `FonteCaminhoShellQuoteGrouping`. The background-launch
11871        // tail is the load-bearing root-cause edit on every
11872        // probe-as-both value.
11873        let d = dep_with_fonte(DepSource::Path {
11874            caminho: "../caixa-teia & 'x'".into(),
11875        });
11876        let err = d.validate().unwrap_err();
11877        assert!(
11878            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11879            "got {err:?}",
11880        );
11881    }
11882
11883    #[test]
11884    fn fonte_caminho_shell_semicolon_fires_before_shell_quote_grouping() {
11885        // Cascade pin on the upstream shell-semicolon arm: a value
11886        // carrying both `;` and `'` (`"../caixa-teia; 'x'"` — the
11887        // canonical sequential-cleanup + quote paste idiom) routes
11888        // through `FonteCaminhoShellSemicolon` not
11889        // `FonteCaminhoShellQuoteGrouping`. The sequential-command-
11890        // separator paste is the load-bearing root-cause edit on
11891        // every probe-as-both value.
11892        let d = dep_with_fonte(DepSource::Path {
11893            caminho: "../caixa-teia; 'x'".into(),
11894        });
11895        let err = d.validate().unwrap_err();
11896        assert!(
11897            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11898            "got {err:?}",
11899        );
11900    }
11901
11902    #[test]
11903    fn fonte_caminho_shell_pipe_fires_before_shell_quote_grouping() {
11904        // Cascade pin on the upstream shell-pipe arm: a value
11905        // carrying both `|` and `'` (`"../caixa-teia | 'x'"` — the
11906        // canonical pipeline-to-quoted-literal paste idiom) routes
11907        // through `FonteCaminhoShellPipe` not
11908        // `FonteCaminhoShellQuoteGrouping`. The pipeline-tail paste
11909        // is the load-bearing root-cause edit on every probe-as-
11910        // both value.
11911        let d = dep_with_fonte(DepSource::Path {
11912            caminho: "../caixa-teia | 'x'".into(),
11913        });
11914        let err = d.validate().unwrap_err();
11915        assert!(
11916            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11917            "got {err:?}",
11918        );
11919    }
11920
11921    #[test]
11922    fn fonte_caminho_shell_redirection_fires_before_shell_quote_grouping() {
11923        // Cascade pin on the upstream shell-redirection arm: a
11924        // value carrying both `>` and `'` (`"../caixa-teia>log 'x'"`
11925        // — the canonical "I pasted a `cmd > log 'literal'`
11926        // redirect-plus-quote chain" footgun) routes through
11927        // `FonteCaminhoShellRedirection` not
11928        // `FonteCaminhoShellQuoteGrouping`. The input/output
11929        // redirection metachar carries the more self-locating
11930        // `byte` payload, so the prior arm wins on every probe-as-
11931        // both value.
11932        let d = dep_with_fonte(DepSource::Path {
11933            caminho: "../caixa-teia>log 'x'".into(),
11934        });
11935        let err = d.validate().unwrap_err();
11936        assert!(
11937            matches!(
11938                err,
11939                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11940            ),
11941            "got {err:?}",
11942        );
11943    }
11944
11945    #[test]
11946    fn fonte_caminho_backslash_fires_before_shell_quote_grouping() {
11947        // Cascade pin on the upstream backslash arm: a value
11948        // carrying both `\` and `'` (`"..\caixa-teia\'x'"` — the
11949        // canonical "I pasted a Windows-shell `cd ..\path\'literal'`
11950        // chain" footgun) routes through `FonteCaminhoBackslash`
11951        // not `FonteCaminhoShellQuoteGrouping`. The cross-host-OS-
11952        // separator divergence is the load-bearing axis on every
11953        // probe-as-both value.
11954        let d = dep_with_fonte(DepSource::Path {
11955            caminho: "..\\caixa-teia\\'x'".into(),
11956        });
11957        let err = d.validate().unwrap_err();
11958        assert!(
11959            matches!(err, DepError::FonteCaminhoBackslash { .. }),
11960            "got {err:?}",
11961        );
11962    }
11963
11964    #[test]
11965    fn fonte_caminho_control_char_fires_before_shell_quote_grouping() {
11966        // Cascade pin on the embedded-control-byte arm: a value
11967        // carrying both a control byte and `'` (`"../foo\n'x'"` —
11968        // the canonical paste-from-multiline-doc footgun where a
11969        // newline landed mid-caminho between two paste fragments)
11970        // routes through `FonteCaminhoControlChar` not
11971        // `FonteCaminhoShellQuoteGrouping`. The POSIX-syscall-
11972        // rejected-byte / NUL-`CString::new`-fail diagnostic is
11973        // the load-bearing axis on every value that probes
11974        // positive for both — mirrors the cascade discipline on
11975        // every prior arm.
11976        let d = dep_with_fonte(DepSource::Path {
11977            caminho: "../foo\n'x'".into(),
11978        });
11979        let err = d.validate().unwrap_err();
11980        assert!(
11981            matches!(err, DepError::FonteCaminhoControlChar { .. }),
11982            "got {err:?}",
11983        );
11984    }
11985
11986    #[test]
11987    fn fonte_caminho_absolute_fires_before_shell_quote_grouping() {
11988        // Cascade pin on the load-bearing leading-byte arm: a
11989        // leading `/` value with embedded `'` (`"/etc/'x'"`) routes
11990        // through `FonteCaminhoAbsolute` not
11991        // `FonteCaminhoShellQuoteGrouping` — the host-layout-leak
11992        // diagnostic is the load-bearing axis, the quote byte is
11993        // the secondary observation. Same precedence logic as every
11994        // prior leading-byte arm.
11995        let d = dep_with_fonte(DepSource::Path {
11996            caminho: "/etc/'x'".into(),
11997        });
11998        let err = d.validate().unwrap_err();
11999        assert!(
12000            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
12001            "got {err:?}",
12002        );
12003    }
12004
12005    #[test]
12006    fn fonte_caminho_var_expansion_fires_before_shell_quote_grouping() {
12007        // Cascade pin on the upstream leading-`$` var-expansion
12008        // arm: a value carrying both a leading `$` and a `'`
12009        // (`"$DIR/'x'"` — the canonical "I pasted a `$DIR` shell-
12010        // variable + quoted literal at the head of a sibling-
12011        // workspace path" footgun) routes through
12012        // `FonteCaminhoVarExpansion` not
12013        // `FonteCaminhoShellQuoteGrouping`. The leading-byte
12014        // shell-variable-expansion is the more self-locating
12015        // diagnostic on values that probe as both — same
12016        // load-bearing-leading-byte cascade discipline every
12017        // prior `:caminho` arm establishes.
12018        let d = dep_with_fonte(DepSource::Path {
12019            caminho: "$DIR/'x'".into(),
12020        });
12021        let err = d.validate().unwrap_err();
12022        assert!(
12023            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
12024            "got {err:?}",
12025        );
12026    }
12027
12028    #[test]
12029    fn fonte_caminho_shell_quote_grouping_fires_before_trailing_slash() {
12030        // Cascade pin on the immediate-successor arm: a value
12031        // carrying both `'` and a trailing `/` (`"../'caixa-teia'/"`
12032        // — the canonical "I tab-completed a path whose strong-
12033        // quoted body already carried the quoting from a shell-
12034        // history paste" footgun) routes through
12035        // `FonteCaminhoShellQuoteGrouping` not
12036        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
12037        // is the more semantic-locating axis (an author who removes
12038        // the `'` typically also drops the trailing separator since
12039        // both are paste-from-shell artifacts).
12040        let d = dep_with_fonte(DepSource::Path {
12041            caminho: "../'caixa-teia'/".into(),
12042        });
12043        let err = d.validate().unwrap_err();
12044        assert!(
12045            matches!(
12046                err,
12047                DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
12048            ),
12049            "got {err:?}",
12050        );
12051    }
12052
12053    #[test]
12054    fn fonte_caminho_shell_quote_grouping_diagnostic_carries_offending_dep_caminho_and_byte() {
12055        // Diagnostic-shape pin (peer with
12056        // `fonte_caminho_shell_bracket_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
12057        // on the closest two-byte peer arm): the error's Display
12058        // surfaces the offending `:nome`, the offending `:caminho`
12059        // verbatim, the offending byte's hex / character form, and
12060        // names the shell-quote-grouping / cross-config-DSL-string-
12061        // literal-delimiter footgun explicitly so a `feira lint`
12062        // run can render the diagnostic without re-parsing.
12063        let d = dep_with_fonte(DepSource::Path {
12064            caminho: "'../caixa-teia'".into(),
12065        });
12066        let rendered = d.validate().unwrap_err().to_string();
12067        assert!(
12068            rendered.contains("caixa-teia"),
12069            "diagnostic must name the offending dep: {rendered}",
12070        );
12071        assert!(
12072            rendered.contains("'../caixa-teia'"),
12073            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
12074        );
12075        assert!(
12076            rendered.contains("0x27"),
12077            "diagnostic must surface the offending byte hex: {rendered:?}",
12078        );
12079        assert!(
12080            rendered.contains("quote-grouping"),
12081            "diagnostic must name the shell-quote-grouping footgun: {rendered:?}",
12082        );
12083        assert!(
12084            rendered.contains("string-literal"),
12085            "diagnostic must reference the cross-config-DSL string-literal-delimiter \
12086             vocabulary: {rendered:?}",
12087        );
12088    }
12089
12090    #[test]
12091    fn validate_rejects_path_fonte_with_caminho_carrying_shell_comment_lead() {
12092        // The canonical paste-from-shell-history-with-trailing-
12093        // annotation footgun: an author pastes a `cd ../caixa-teia
12094        // # legacy sibling` shell-history one-liner whose unquoted `#`
12095        // comment-lead separates the path from an inline annotation.
12096        // The POSIX shell trims the annotation to `../caixa-teia`
12097        // (POSIX.1-2017 §2.3 Token Recognition step 6), but
12098        // `Path::is_absolute` returns false on `..`, `#` is neither
12099        // a leading-byte sentinel nor a control byte nor `\` nor
12100        // `<` / `>` nor `|` nor `;` nor `&` nor backtick nor `*` /
12101        // `?` nor `(` / `)` nor `{` / `}` nor `[` / `]` nor `'` /
12102        // `"`, and the value's last byte isn't `/` — so the value
12103        // silently passed every prior arm. The resolver folded the
12104        // value through `Path::join` looking for a literal
12105        // `./../caixa-teia # legacy sibling` subdirectory and the
12106        // failure surfaced at resolve time with a non-self-locating
12107        // `No such file or directory` error. The new arm moves the
12108        // rejection to validate time and names the offending dep +
12109        // caminho + byte verbatim.
12110        let d = dep_with_fonte(DepSource::Path {
12111            caminho: "../caixa-teia # legacy sibling".into(),
12112        });
12113        let err = d.validate().unwrap_err();
12114        let DepError::FonteCaminhoShellComment {
12115            nome,
12116            caminho,
12117            byte,
12118        } = err
12119        else {
12120            panic!("expected FonteCaminhoShellComment, got {err:?}");
12121        };
12122        assert_eq!(nome, "caixa-teia");
12123        assert_eq!(caminho, "../caixa-teia # legacy sibling");
12124        assert_eq!(byte, b'#');
12125    }
12126
12127    #[test]
12128    fn validate_rejects_path_fonte_with_caminho_carrying_yaml_comment_paste() {
12129        // The symmetric YAML flow-scalar / values.yaml / K8s-manifest
12130        // cross-idiom-leak shape (`"../caixa-teia  # pin"` — the
12131        // canonical "I copied a `path: ../caixa-teia  # pin` YAML
12132        // scalar-plus-comment entry out of an aligned values.yaml and
12133        // dropped it verbatim into the `:caminho` slot" paste-idiom).
12134        // Pinned separately from the shell-history shape so the
12135        // gate's coverage extends from the single-space `#` shape to
12136        // the YAML-canonical double-space `  #` shape. YAML 1.2 §6.6
12137        // requires the `#` to be preceded by whitespace to lex as a
12138        // comment (bare `foo#bar` is a single scalar); the double-
12139        // space paste from an aligned manifest is the canonical
12140        // shape.
12141        let d = dep_with_fonte(DepSource::Path {
12142            caminho: "../caixa-teia  # pin".into(),
12143        });
12144        let err = d.validate().unwrap_err();
12145        assert!(
12146            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
12147            "got {err:?}",
12148        );
12149    }
12150
12151    #[test]
12152    fn validate_rejects_path_fonte_with_caminho_carrying_url_fragment_anchor() {
12153        // The URL-fragment-identifier paste shape
12154        // (`"../caixa-teia#readme"` — the canonical
12155        // paste-from-browser-address-bar permalink shape where the
12156        // browser preserved the `#anchor` tail on the copy). Pinned
12157        // separately from the whitespace-separated shell / YAML
12158        // comment shapes so the gate covers the unpadded RFC 3986
12159        // §3.5 fragment-delimiter position too, not only positions
12160        // preceded by unquoted whitespace. Peer with the immediate-
12161        // sibling `is_git_repo_url` arm on the `:fonte :repo` axis
12162        // (a68f818) which closes the same byte under the same URL-
12163        // fragment-identifier banner.
12164        let d = dep_with_fonte(DepSource::Path {
12165            caminho: "../caixa-teia#readme".into(),
12166        });
12167        let err = d.validate().unwrap_err();
12168        assert!(
12169            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
12170            "got {err:?}",
12171        );
12172    }
12173
12174    #[test]
12175    fn validate_rejects_path_fonte_with_caminho_carrying_leading_shell_comment() {
12176        // Leading-position `#` shape (`"#../caixa-teia"` — the
12177        // "I copied a shell-comment-out entry from a commented-out
12178        // dep row" footgun). Pinned separately from the embedded
12179        // shapes so the gate covers every position, not only
12180        // whitespace-preceded / mid-value.
12181        let d = dep_with_fonte(DepSource::Path {
12182            caminho: "#../caixa-teia".into(),
12183        });
12184        let err = d.validate().unwrap_err();
12185        assert!(
12186            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
12187            "got {err:?}",
12188        );
12189    }
12190
12191    #[test]
12192    fn validate_accepts_path_fonte_with_caminho_carrying_no_shell_comment() {
12193        // The positive-control pin: the gate targets only `#`,
12194        // never adjacent printable ASCII or POSIX-valid bytes. The
12195        // canonical relative POSIX path (`"../caixa-teia"`) and a
12196        // nested deeply-pathed variant with adjacent printable
12197        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
12198        // to validate cleanly so the gate doesn't widen to a "no
12199        // printable punctuation anywhere" sweep that would defeat
12200        // the entire path-fonte author surface. Peer with
12201        // `validate_accepts_path_fonte_with_caminho_carrying_no_quote_grouping`
12202        // on the immediate-predecessor arm.
12203        let d = dep_with_fonte(DepSource::Path {
12204            caminho: "../caixa-teia/sub-dir.v2".into(),
12205        });
12206        d.validate().unwrap();
12207    }
12208
12209    #[test]
12210    fn fonte_caminho_shell_quote_grouping_fires_before_shell_comment() {
12211        // Cascade pin on the immediate-predecessor arm: a value
12212        // carrying both `'` and `#` (`"../'x'#pin"` — the canonical
12213        // "I pasted a strong-quoted literal followed by a URL-
12214        // fragment permalink tail" footgun) routes through
12215        // `FonteCaminhoShellQuoteGrouping` not
12216        // `FonteCaminhoShellComment`. The shell-string-literal-
12217        // delimiter is the load-bearing root-cause edit on every
12218        // probe-as-both value; same cascade discipline every prior
12219        // `:caminho` arm establishes.
12220        let d = dep_with_fonte(DepSource::Path {
12221            caminho: "../'x'#pin".into(),
12222        });
12223        let err = d.validate().unwrap_err();
12224        assert!(
12225            matches!(
12226                err,
12227                DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
12228            ),
12229            "got {err:?}",
12230        );
12231    }
12232
12233    #[test]
12234    fn fonte_caminho_shell_bracket_expansion_fires_before_shell_comment() {
12235        // Cascade pin on the upstream shell-bracket-expansion arm:
12236        // a value carrying both `[` and `#` (`"../[a-z]#pin"` — the
12237        // canonical "I pasted a glob-character-class followed by a
12238        // URL-fragment tail" footgun) routes through
12239        // `FonteCaminhoShellBracketExpansion` not
12240        // `FonteCaminhoShellComment`. The glob-character-class
12241        // expansion is the load-bearing root-cause edit on every
12242        // probe-as-both value.
12243        let d = dep_with_fonte(DepSource::Path {
12244            caminho: "../[a-z]#pin".into(),
12245        });
12246        let err = d.validate().unwrap_err();
12247        assert!(
12248            matches!(
12249                err,
12250                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
12251            ),
12252            "got {err:?}",
12253        );
12254    }
12255
12256    #[test]
12257    fn fonte_caminho_shell_brace_expansion_fires_before_shell_comment() {
12258        // Cascade pin on the upstream shell-brace-expansion arm: a
12259        // value carrying both `{` and `#` (`"../{a,b}#pin"` — the
12260        // canonical "I pasted a brace-expansion fan followed by a
12261        // URL-fragment tail" footgun) routes through
12262        // `FonteCaminhoShellBraceExpansion` not
12263        // `FonteCaminhoShellComment`. The brace-expansion fan is the
12264        // load-bearing root-cause edit on every probe-as-both value.
12265        let d = dep_with_fonte(DepSource::Path {
12266            caminho: "../{a,b}#pin".into(),
12267        });
12268        let err = d.validate().unwrap_err();
12269        assert!(
12270            matches!(
12271                err,
12272                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
12273            ),
12274            "got {err:?}",
12275        );
12276    }
12277
12278    #[test]
12279    fn fonte_caminho_shell_subshell_grouping_fires_before_shell_comment() {
12280        // Cascade pin on the upstream shell-subshell-grouping arm:
12281        // a value carrying both `(` and `#` (`"../(cd foo)#pin"` —
12282        // the canonical "I pasted a subshell-grouping followed by a
12283        // URL-fragment tail" footgun) routes through
12284        // `FonteCaminhoShellSubshellGrouping` not
12285        // `FonteCaminhoShellComment`. The modern Bourne `$(<cmd>)`
12286        // command-substitution boundary is the load-bearing axis on
12287        // every probe-as-both value.
12288        let d = dep_with_fonte(DepSource::Path {
12289            caminho: "../(cd foo)#pin".into(),
12290        });
12291        let err = d.validate().unwrap_err();
12292        assert!(
12293            matches!(
12294                err,
12295                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
12296            ),
12297            "got {err:?}",
12298        );
12299    }
12300
12301    #[test]
12302    fn fonte_caminho_shell_glob_fires_before_shell_comment() {
12303        // Cascade pin on the upstream shell-glob arm: a value
12304        // carrying both `*` and `#` (`"../caixa-teia/*#pin"` — the
12305        // canonical "I pasted a `*` unbounded pathname-expansion
12306        // followed by a URL-fragment tail" footgun) routes through
12307        // `FonteCaminhoShellGlob` not `FonteCaminhoShellComment`.
12308        // The unbounded pathname-expansion sentinel is the load-
12309        // bearing root-cause edit on every probe-as-both value.
12310        let d = dep_with_fonte(DepSource::Path {
12311            caminho: "../caixa-teia/*#pin".into(),
12312        });
12313        let err = d.validate().unwrap_err();
12314        assert!(
12315            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12316            "got {err:?}",
12317        );
12318    }
12319
12320    #[test]
12321    fn fonte_caminho_shell_command_substitution_fires_before_shell_comment() {
12322        // Cascade pin on the upstream shell-command-substitution
12323        // arm: a value carrying both a backtick and `#`
12324        // (``"../`whoami`#pin"`` — the canonical "I pasted a
12325        // legacy-backtick command-substitution followed by a URL-
12326        // fragment tail" footgun) routes through
12327        // `FonteCaminhoShellCommandSubstitution` not
12328        // `FonteCaminhoShellComment`. The CWE-78 shell-command-
12329        // injection vector is the load-bearing root-cause edit on
12330        // every probe-as-both value.
12331        let d = dep_with_fonte(DepSource::Path {
12332            caminho: "../`whoami`#pin".into(),
12333        });
12334        let err = d.validate().unwrap_err();
12335        assert!(
12336            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
12337            "got {err:?}",
12338        );
12339    }
12340
12341    #[test]
12342    fn fonte_caminho_shell_background_fires_before_shell_comment() {
12343        // Cascade pin on the upstream shell-background arm: a value
12344        // carrying both `&` and `#` (`"../caixa-teia&pin#tail"` —
12345        // the canonical "I pasted a `cmd &` background-launch
12346        // followed by a URL-fragment tail" footgun) routes through
12347        // `FonteCaminhoShellBackground` not
12348        // `FonteCaminhoShellComment`. The background-launch tail is
12349        // the load-bearing root-cause edit on every probe-as-both
12350        // value.
12351        let d = dep_with_fonte(DepSource::Path {
12352            caminho: "../caixa-teia&pin#tail".into(),
12353        });
12354        let err = d.validate().unwrap_err();
12355        assert!(
12356            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
12357            "got {err:?}",
12358        );
12359    }
12360
12361    #[test]
12362    fn fonte_caminho_shell_semicolon_fires_before_shell_comment() {
12363        // Cascade pin on the upstream shell-semicolon arm: a value
12364        // carrying both `;` and `#` (`"../caixa-teia;pin#tail"` —
12365        // the canonical sequential-cleanup + URL-fragment paste
12366        // idiom) routes through `FonteCaminhoShellSemicolon` not
12367        // `FonteCaminhoShellComment`. The sequential-command-
12368        // separator paste is the load-bearing root-cause edit on
12369        // every probe-as-both value.
12370        let d = dep_with_fonte(DepSource::Path {
12371            caminho: "../caixa-teia;pin#tail".into(),
12372        });
12373        let err = d.validate().unwrap_err();
12374        assert!(
12375            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
12376            "got {err:?}",
12377        );
12378    }
12379
12380    #[test]
12381    fn fonte_caminho_shell_pipe_fires_before_shell_comment() {
12382        // Cascade pin on the upstream shell-pipe arm: a value
12383        // carrying both `|` and `#` (`"../caixa-teia|pin#tail"` —
12384        // the canonical pipeline-to-URL-fragment paste idiom) routes
12385        // through `FonteCaminhoShellPipe` not
12386        // `FonteCaminhoShellComment`. The pipeline-tail paste is
12387        // the load-bearing root-cause edit on every probe-as-both
12388        // value.
12389        let d = dep_with_fonte(DepSource::Path {
12390            caminho: "../caixa-teia|pin#tail".into(),
12391        });
12392        let err = d.validate().unwrap_err();
12393        assert!(
12394            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
12395            "got {err:?}",
12396        );
12397    }
12398
12399    #[test]
12400    fn fonte_caminho_shell_redirection_fires_before_shell_comment() {
12401        // Cascade pin on the upstream shell-redirection arm: a
12402        // value carrying both `>` and `#` (`"../caixa-teia>log#pin"`
12403        // — the canonical "I pasted a `cmd > log` redirect followed
12404        // by a URL-fragment tail" footgun) routes through
12405        // `FonteCaminhoShellRedirection` not
12406        // `FonteCaminhoShellComment`. The input/output redirection
12407        // metachar carries the more self-locating `byte` payload,
12408        // so the prior arm wins on every probe-as-both value.
12409        let d = dep_with_fonte(DepSource::Path {
12410            caminho: "../caixa-teia>log#pin".into(),
12411        });
12412        let err = d.validate().unwrap_err();
12413        assert!(
12414            matches!(
12415                err,
12416                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
12417            ),
12418            "got {err:?}",
12419        );
12420    }
12421
12422    #[test]
12423    fn fonte_caminho_backslash_fires_before_shell_comment() {
12424        // Cascade pin on the upstream backslash arm: a value
12425        // carrying both `\` and `#` (`"..\caixa-teia#pin"` — the
12426        // canonical "I pasted a Windows-shell path followed by a
12427        // URL-fragment tail" footgun) routes through
12428        // `FonteCaminhoBackslash` not `FonteCaminhoShellComment`.
12429        // The cross-host-OS-separator divergence is the load-
12430        // bearing axis on every probe-as-both value.
12431        let d = dep_with_fonte(DepSource::Path {
12432            caminho: "..\\caixa-teia#pin".into(),
12433        });
12434        let err = d.validate().unwrap_err();
12435        assert!(
12436            matches!(err, DepError::FonteCaminhoBackslash { .. }),
12437            "got {err:?}",
12438        );
12439    }
12440
12441    #[test]
12442    fn fonte_caminho_control_char_fires_before_shell_comment() {
12443        // Cascade pin on the embedded-control-byte arm: a value
12444        // carrying both a control byte and `#` (`"../foo\n#pin"` —
12445        // the canonical paste-from-multiline-doc footgun where a
12446        // newline landed mid-caminho between the path and an
12447        // annotation) routes through `FonteCaminhoControlChar` not
12448        // `FonteCaminhoShellComment`. The POSIX-syscall-rejected-
12449        // byte diagnostic is the load-bearing axis on every value
12450        // that probes positive for both — mirrors the cascade
12451        // discipline on every prior arm.
12452        let d = dep_with_fonte(DepSource::Path {
12453            caminho: "../foo\n#pin".into(),
12454        });
12455        let err = d.validate().unwrap_err();
12456        assert!(
12457            matches!(err, DepError::FonteCaminhoControlChar { .. }),
12458            "got {err:?}",
12459        );
12460    }
12461
12462    #[test]
12463    fn fonte_caminho_absolute_fires_before_shell_comment() {
12464        // Cascade pin on the load-bearing leading-byte arm: a
12465        // leading `/` value with embedded `#` (`"/etc/foo#pin"`)
12466        // routes through `FonteCaminhoAbsolute` not
12467        // `FonteCaminhoShellComment` — the host-layout-leak
12468        // diagnostic is the load-bearing axis, the fragment byte is
12469        // the secondary observation. Same precedence logic as every
12470        // prior leading-byte arm.
12471        let d = dep_with_fonte(DepSource::Path {
12472            caminho: "/etc/foo#pin".into(),
12473        });
12474        let err = d.validate().unwrap_err();
12475        assert!(
12476            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
12477            "got {err:?}",
12478        );
12479    }
12480
12481    #[test]
12482    fn fonte_caminho_var_expansion_fires_before_shell_comment() {
12483        // Cascade pin on the upstream leading-`$` var-expansion
12484        // arm: a value carrying both a leading `$` and a `#`
12485        // (`"$DIR/foo#pin"` — the canonical "I pasted a `$DIR`
12486        // shell-variable at the head of a sibling-workspace path
12487        // followed by a URL-fragment tail" footgun) routes through
12488        // `FonteCaminhoVarExpansion` not `FonteCaminhoShellComment`.
12489        // The leading-byte shell-variable-expansion is the more
12490        // self-locating diagnostic on values that probe as both.
12491        let d = dep_with_fonte(DepSource::Path {
12492            caminho: "$DIR/foo#pin".into(),
12493        });
12494        let err = d.validate().unwrap_err();
12495        assert!(
12496            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
12497            "got {err:?}",
12498        );
12499    }
12500
12501    #[test]
12502    fn fonte_caminho_shell_comment_fires_before_trailing_slash() {
12503        // Cascade pin on the immediate-successor arm: a value
12504        // carrying both `#` and a trailing `/`
12505        // (`"../caixa-teia#pin/"` — the canonical "I tab-completed
12506        // a URL-fragment-carrying path" footgun) routes through
12507        // `FonteCaminhoShellComment` not
12508        // `FonteCaminhoTrailingSlash`. The embedded fragment /
12509        // comment-lead byte is the more semantic-locating axis (an
12510        // author who removes the `#pin` fragment typically also
12511        // drops the trailing separator since both are paste-from-
12512        // URL / paste-from-shell-tab-completion artifacts).
12513        let d = dep_with_fonte(DepSource::Path {
12514            caminho: "../caixa-teia#pin/".into(),
12515        });
12516        let err = d.validate().unwrap_err();
12517        assert!(
12518            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. },),
12519            "got {err:?}",
12520        );
12521    }
12522
12523    #[test]
12524    fn fonte_caminho_shell_comment_diagnostic_carries_offending_dep_caminho_and_byte() {
12525        // Diagnostic-shape pin (peer with
12526        // `fonte_caminho_shell_quote_grouping_diagnostic_carries_offending_dep_caminho_and_byte`
12527        // on the immediate-predecessor arm): the error's Display
12528        // surfaces the offending `:nome`, the offending `:caminho`
12529        // verbatim, the offending byte's hex / character form, and
12530        // names the shell-comment / URL-fragment-identifier /
12531        // YAML-comment cross-config-DSL footgun explicitly so a
12532        // `feira lint` run can render the diagnostic without
12533        // re-parsing.
12534        let d = dep_with_fonte(DepSource::Path {
12535            caminho: "../caixa-teia#readme".into(),
12536        });
12537        let rendered = d.validate().unwrap_err().to_string();
12538        assert!(
12539            rendered.contains("caixa-teia"),
12540            "diagnostic must name the offending dep: {rendered}",
12541        );
12542        assert!(
12543            rendered.contains("../caixa-teia#readme"),
12544            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
12545        );
12546        assert!(
12547            rendered.contains("0x23"),
12548            "diagnostic must surface the offending byte hex: {rendered:?}",
12549        );
12550        assert!(
12551            rendered.contains("shell-comment") || rendered.contains("comment-lead"),
12552            "diagnostic must name the shell-comment footgun: {rendered:?}",
12553        );
12554        assert!(
12555            rendered.contains("fragment") || rendered.contains("URL-fragment"),
12556            "diagnostic must reference the URL-fragment-identifier vocabulary: \
12557             {rendered:?}",
12558        );
12559    }
12560
12561    #[test]
12562    fn validate_rejects_path_fonte_with_caminho_carrying_url_percent_encoded_space() {
12563        // The canonical paste-from-browser-address-bar percent-
12564        // encoded-space footgun: an author copies `../caixa%20teia`
12565        // out of a URL-encoded README hyperlink / browser address
12566        // bar / percent-encoded permalink expecting `%20` to decode
12567        // to a literal space at the filesystem layer. POSIX
12568        // `std::path::Path` treats `%` as a literal path-component
12569        // byte, so `Path::join` looks for a literal
12570        // `./../caixa%20teia` subdirectory. `Path::is_absolute`
12571        // returns false on `..`, `%` is neither a leading-byte
12572        // sentinel nor a control byte nor `\` nor `<` / `>` nor
12573        // `|` nor `;` nor `&` nor backtick nor `*` / `?` nor `(` /
12574        // `)` nor `{` / `}` nor `[` / `]` nor `'` / `"` nor `#`,
12575        // and the value's last byte isn't `/` — so the value
12576        // silently passed every prior arm. The new arm moves the
12577        // rejection to validate time and names the offending dep +
12578        // caminho + byte verbatim.
12579        let d = dep_with_fonte(DepSource::Path {
12580            caminho: "../caixa%20teia".into(),
12581        });
12582        let err = d.validate().unwrap_err();
12583        let DepError::FonteCaminhoUrlPercentEncoding {
12584            nome,
12585            caminho,
12586            byte,
12587        } = err
12588        else {
12589            panic!("expected FonteCaminhoUrlPercentEncoding, got {err:?}");
12590        };
12591        assert_eq!(nome, "caixa-teia");
12592        assert_eq!(caminho, "../caixa%20teia");
12593        assert_eq!(byte, b'%');
12594    }
12595
12596    #[test]
12597    fn validate_rejects_path_fonte_with_caminho_carrying_url_percent_encoded_slash() {
12598        // The over-encoded path-separator shape (`"../caixa%2Fteia"`
12599        // intending the `%2F` as the URL encoding of `/`) locks a
12600        // `path:../caixa%2Fteia` BLAKE3 closure that diverges from
12601        // the byte-identical `path:../caixa/teia` form. Pinned
12602        // separately from the space-encoded shape so the gate's
12603        // coverage extends past the single canonical `%20` example
12604        // to any two-hex-digit percent-encoded sequence.
12605        let d = dep_with_fonte(DepSource::Path {
12606            caminho: "../caixa%2Fteia".into(),
12607        });
12608        let err = d.validate().unwrap_err();
12609        assert!(
12610            matches!(
12611                err,
12612                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
12613            ),
12614            "got {err:?}",
12615        );
12616    }
12617
12618    #[test]
12619    fn validate_rejects_path_fonte_with_caminho_carrying_lone_percent() {
12620        // The lone-`%` malformed-escape shape (`"../caixa-teia%foo"`
12621        // where `%` isn't followed by two hex digits) — every
12622        // WHATWG-conformant URL parser rejects the value at parse
12623        // time per RFC 3986 §2.1, but the byte would silently ride
12624        // into the lacre before the resolver subprocess crosses the
12625        // URL-parser boundary. Pinned separately from the well-
12626        // formed `%HH` shapes so the gate covers every percent-
12627        // occurrence, not only strictly-conformant escapes.
12628        let d = dep_with_fonte(DepSource::Path {
12629            caminho: "../caixa-teia%foo".into(),
12630        });
12631        let err = d.validate().unwrap_err();
12632        assert!(
12633            matches!(
12634                err,
12635                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
12636            ),
12637            "got {err:?}",
12638        );
12639    }
12640
12641    #[test]
12642    fn validate_rejects_path_fonte_with_caminho_carrying_leading_yaml_directive() {
12643        // The YAML-directive-lead paste shape (`"%YAML/../caixa-teia"`
12644        // — the canonical paste-from-top-of-doc YAML directive
12645        // block cross-idiom leak per YAML 1.2 §6.8.1). Pinned
12646        // separately from embedded shapes so the gate covers the
12647        // leading-position `%` too, not only mid-value occurrences.
12648        let d = dep_with_fonte(DepSource::Path {
12649            caminho: "%YAML/../caixa-teia".into(),
12650        });
12651        let err = d.validate().unwrap_err();
12652        assert!(
12653            matches!(
12654                err,
12655                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
12656            ),
12657            "got {err:?}",
12658        );
12659    }
12660
12661    #[test]
12662    fn validate_rejects_path_fonte_with_caminho_carrying_printf_format_specifier() {
12663        // The printf-format-specifier paste shape
12664        // (`"../caixa-%s-teia"` — the canonical paste-from-shell-
12665        // diagnostic-one-liner `printf "path=%s\n" ...` idiom, CWE-
12666        // 134 format-string-injection vector). Pinned separately
12667        // from the URL-encoding shapes so the gate's rationale
12668        // extends past the RFC 3986 axis to the C / POSIX printf
12669        // format-directive-lead axis.
12670        let d = dep_with_fonte(DepSource::Path {
12671            caminho: "../caixa-%s-teia".into(),
12672        });
12673        let err = d.validate().unwrap_err();
12674        assert!(
12675            matches!(
12676                err,
12677                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
12678            ),
12679            "got {err:?}",
12680        );
12681    }
12682
12683    #[test]
12684    fn validate_accepts_path_fonte_with_caminho_carrying_no_percent() {
12685        // The positive-control pin: the gate targets only `%`,
12686        // never adjacent printable ASCII or POSIX-valid bytes. The
12687        // canonical relative POSIX path (`"../caixa-teia"`) and a
12688        // nested deeply-pathed variant with adjacent printable
12689        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
12690        // to validate cleanly so the gate doesn't widen to a "no
12691        // printable punctuation anywhere" sweep that would defeat
12692        // the entire path-fonte author surface. Peer with
12693        // `validate_accepts_path_fonte_with_caminho_carrying_no_shell_comment`
12694        // on the immediate-predecessor arm.
12695        let d = dep_with_fonte(DepSource::Path {
12696            caminho: "../caixa-teia/sub-dir.v2".into(),
12697        });
12698        d.validate().unwrap();
12699    }
12700
12701    #[test]
12702    fn fonte_caminho_shell_comment_fires_before_url_percent_encoding() {
12703        // Cascade pin on the immediate-predecessor arm: a value
12704        // carrying both `#` and `%` (`"../caixa-teia#pin%20"` — the
12705        // canonical "I pasted a URL-fragment permalink followed by a
12706        // percent-encoded space tail" footgun) routes through
12707        // `FonteCaminhoShellComment` not
12708        // `FonteCaminhoUrlPercentEncoding`. The URL-fragment-
12709        // identifier is the load-bearing downstream-truncation edit
12710        // on every probe-as-both value; same cascade discipline
12711        // every prior `:caminho` arm establishes.
12712        let d = dep_with_fonte(DepSource::Path {
12713            caminho: "../caixa-teia#pin%20".into(),
12714        });
12715        let err = d.validate().unwrap_err();
12716        assert!(
12717            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
12718            "got {err:?}",
12719        );
12720    }
12721
12722    #[test]
12723    fn fonte_caminho_shell_quote_grouping_fires_before_url_percent_encoding() {
12724        // Cascade pin on the upstream shell-quote-grouping arm: a
12725        // value carrying both `'` and `%` (`"../'x'%20teia"` — the
12726        // canonical "I pasted a strong-quoted literal followed by
12727        // a percent-encoded space" footgun) routes through
12728        // `FonteCaminhoShellQuoteGrouping` not
12729        // `FonteCaminhoUrlPercentEncoding`. The shell-string-
12730        // literal-delimiter is the load-bearing root-cause edit on
12731        // every probe-as-both value.
12732        let d = dep_with_fonte(DepSource::Path {
12733            caminho: "../'x'%20teia".into(),
12734        });
12735        let err = d.validate().unwrap_err();
12736        assert!(
12737            matches!(
12738                err,
12739                DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
12740            ),
12741            "got {err:?}",
12742        );
12743    }
12744
12745    #[test]
12746    fn fonte_caminho_backslash_fires_before_url_percent_encoding() {
12747        // Cascade pin on the upstream backslash arm: a value
12748        // carrying both `\` and `%` (`"..\\caixa%20teia"` — the
12749        // canonical "I pasted a Windows-shell path followed by a
12750        // percent-encoded space" footgun) routes through
12751        // `FonteCaminhoBackslash` not
12752        // `FonteCaminhoUrlPercentEncoding`. The cross-host-OS-
12753        // separator divergence is the load-bearing root-cause edit
12754        // on every probe-as-both value.
12755        let d = dep_with_fonte(DepSource::Path {
12756            caminho: "..\\caixa%20teia".into(),
12757        });
12758        let err = d.validate().unwrap_err();
12759        assert!(
12760            matches!(err, DepError::FonteCaminhoBackslash { .. }),
12761            "got {err:?}",
12762        );
12763    }
12764
12765    #[test]
12766    fn fonte_caminho_control_char_fires_before_url_percent_encoding() {
12767        // Cascade pin on the upstream control-char arm: a value
12768        // carrying both a NUL byte and `%` (`"../caixa\0%20teia"` —
12769        // the canonical "I pasted a paste-from-binary-blob path
12770        // followed by a percent-encoded space" footgun) routes
12771        // through `FonteCaminhoControlChar` not
12772        // `FonteCaminhoUrlPercentEncoding`. The POSIX-syscall-
12773        // rejected byte is the load-bearing root-cause edit on
12774        // every probe-as-both value.
12775        let d = dep_with_fonte(DepSource::Path {
12776            caminho: "../caixa\0%20teia".into(),
12777        });
12778        let err = d.validate().unwrap_err();
12779        assert!(
12780            matches!(err, DepError::FonteCaminhoControlChar { byte: 0x00, .. },),
12781            "got {err:?}",
12782        );
12783    }
12784
12785    #[test]
12786    fn fonte_caminho_absolute_fires_before_url_percent_encoding() {
12787        // Cascade pin on the upstream absolute-path arm: a value
12788        // that's both absolute and carries `%` (`"/etc/passwd%20"`
12789        // — the canonical "I pasted an absolute path with a
12790        // percent-encoded space tail" footgun) routes through
12791        // `FonteCaminhoAbsolute` not
12792        // `FonteCaminhoUrlPercentEncoding`. The host-layout-leak is
12793        // the load-bearing root-cause edit on every probe-as-both
12794        // value.
12795        let d = dep_with_fonte(DepSource::Path {
12796            caminho: "/etc/passwd%20".into(),
12797        });
12798        let err = d.validate().unwrap_err();
12799        assert!(
12800            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
12801            "got {err:?}",
12802        );
12803    }
12804
12805    #[test]
12806    fn fonte_caminho_var_expansion_fires_before_url_percent_encoding() {
12807        // Cascade pin on the upstream var-expansion arm: a value
12808        // starting with `$` and carrying `%` (`"$HOME/caixa%20teia"`
12809        // — the canonical "I pasted a `$HOME`-rooted path with a
12810        // percent-encoded space" footgun) routes through
12811        // `FonteCaminhoVarExpansion` not
12812        // `FonteCaminhoUrlPercentEncoding`. The shell-variable-
12813        // expansion is the load-bearing root-cause edit on every
12814        // probe-as-both value.
12815        let d = dep_with_fonte(DepSource::Path {
12816            caminho: "$HOME/caixa%20teia".into(),
12817        });
12818        let err = d.validate().unwrap_err();
12819        assert!(
12820            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
12821            "got {err:?}",
12822        );
12823    }
12824
12825    #[test]
12826    fn fonte_caminho_url_percent_encoding_fires_before_trailing_slash() {
12827        // Cascade pin on the immediate-successor arm: a value
12828        // carrying both `%` and a trailing `/`
12829        // (`"../caixa%20teia/"` — the canonical "I tab-completed a
12830        // percent-encoded-space-carrying path" footgun) routes
12831        // through `FonteCaminhoUrlPercentEncoding` not
12832        // `FonteCaminhoTrailingSlash`. The embedded percent-
12833        // encoding-escape byte is the more semantic-locating axis
12834        // (an author who decodes the `%20` to a literal space is
12835        // likely to also tab-strip the trailing separator since
12836        // both are paste-from-URL / paste-from-shell-tab-completion
12837        // artifacts).
12838        let d = dep_with_fonte(DepSource::Path {
12839            caminho: "../caixa%20teia/".into(),
12840        });
12841        let err = d.validate().unwrap_err();
12842        assert!(
12843            matches!(
12844                err,
12845                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
12846            ),
12847            "got {err:?}",
12848        );
12849    }
12850
12851    #[test]
12852    fn fonte_caminho_url_percent_encoding_diagnostic_carries_offending_dep_caminho_and_byte() {
12853        // Diagnostic-shape pin (peer with
12854        // `fonte_caminho_shell_comment_diagnostic_carries_offending_dep_caminho_and_byte`
12855        // on the immediate-predecessor arm): the error's Display
12856        // surfaces the offending `:nome`, the offending `:caminho`
12857        // verbatim, the offending byte's hex / character form, and
12858        // names the URL-percent-encoding-escape / printf-format-
12859        // specifier footgun explicitly so a `feira lint` run can
12860        // render the diagnostic without re-parsing.
12861        let d = dep_with_fonte(DepSource::Path {
12862            caminho: "../caixa%20teia".into(),
12863        });
12864        let rendered = d.validate().unwrap_err().to_string();
12865        assert!(
12866            rendered.contains("caixa-teia"),
12867            "diagnostic must name the offending dep: {rendered}",
12868        );
12869        assert!(
12870            rendered.contains("../caixa%20teia"),
12871            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
12872        );
12873        assert!(
12874            rendered.contains("0x25"),
12875            "diagnostic must surface the offending byte hex: {rendered:?}",
12876        );
12877        assert!(
12878            rendered.contains("percent-encoding") || rendered.contains("percent-encoded"),
12879            "diagnostic must name the URL-percent-encoding-escape footgun: {rendered:?}",
12880        );
12881        assert!(
12882            rendered.contains("printf") || rendered.contains("format-specifier"),
12883            "diagnostic must reference the printf-format-specifier vocabulary: \
12884             {rendered:?}",
12885        );
12886    }
12887
12888    #[test]
12889    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_var_expansion() {
12890        // The canonical embedded-`$` shell-variable-expansion paste
12891        // shape (`"../foo$HOME/bar"` — an author copies a partially-
12892        // substituted shell one-liner where the leading segment is a
12893        // literal `../foo` while the mid segment carries the un-
12894        // substituted `$HOME` template). The leading-`$` position is
12895        // already gated by the f4efe9c leading-byte arm which routes
12896        // through `FonteCaminhoVarExpansion`; this arm closes the
12897        // last positional gap on `$` — every position on the axis is
12898        // structurally rejected.
12899        let d = dep_with_fonte(DepSource::Path {
12900            caminho: "../foo$HOME/bar".into(),
12901        });
12902        let err = d.validate().unwrap_err();
12903        let DepError::FonteCaminhoShellVariableExpansion {
12904            nome,
12905            caminho,
12906            byte,
12907        } = err
12908        else {
12909            panic!("expected FonteCaminhoShellVariableExpansion, got {err:?}");
12910        };
12911        assert_eq!(nome, "caixa-teia");
12912        assert_eq!(caminho, "../foo$HOME/bar");
12913        assert_eq!(byte, b'$');
12914    }
12915
12916    #[test]
12917    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_braced_var_expansion() {
12918        // The symmetric braced-CI-manifest paste shape
12919        // (`"../foo${WORKSPACE}/bar"` — the canonical paste-from-
12920        // GitHub-Actions-workflow / paste-from-`.gitlab-ci.yml`
12921        // footgun). Pinned separately from the bare-`$VAR` shape so
12922        // the gate covers both POSIX shell §2.6 Parameter Expansion
12923        // syntactic forms, not only the unbraced variant. The
12924        // embedded `{` byte in `${...}` is also caught by the 598b770
12925        // shell-brace-expansion arm but that arm fires earlier in
12926        // the cascade — the `$` arm's coverage extends to `${...}`
12927        // structurally, so the diagnostic asserted here is the
12928        // brace-expansion one (which is a valid outcome; the point
12929        // of the pin is that the value never survives validation).
12930        let d = dep_with_fonte(DepSource::Path {
12931            caminho: "../foo${WORKSPACE}/bar".into(),
12932        });
12933        let err = d.validate().unwrap_err();
12934        assert!(
12935            matches!(
12936                err,
12937                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. }
12938                    | DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
12939            ),
12940            "got {err:?}",
12941        );
12942    }
12943
12944    #[test]
12945    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_command_substitution() {
12946        // The paste-from-shell-prompt command-substitution idiom
12947        // (`"../foo$(whoami)/bar"`). Pinned separately from the bare-
12948        // `$VAR` shape so the gate's rationale extends to POSIX shell
12949        // §2.6.3 Command Substitution (the modern `$(<cmd>)` form; the
12950        // legacy `` `<cmd>` `` form is already closed by the c370458
12951        // backtick arm). The embedded `(` byte in `$(...)` is also
12952        // caught structurally by the 0633c91 shell-subshell-grouping
12953        // arm which fires earlier in the cascade — the diagnostic
12954        // asserted here is either outcome, since both structurally
12955        // reject the value; the point of the pin is that the value
12956        // never survives validation.
12957        let d = dep_with_fonte(DepSource::Path {
12958            caminho: "../foo$(whoami)/bar".into(),
12959        });
12960        let err = d.validate().unwrap_err();
12961        assert!(
12962            matches!(
12963                err,
12964                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. }
12965                    | DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
12966            ),
12967            "got {err:?}",
12968        );
12969    }
12970
12971    #[test]
12972    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_positional_parameter() {
12973        // The paste-from-`Makefile` / paste-from-SQL-migration bare-
12974        // `$1` positional-parameter shape (`"../foo$1/bar"` — a Make
12975        // automatic-variable `$1` or a PostgreSQL bind-parameter `$1`
12976        // idiom copied into a caminho template). None of the prior
12977        // shell-metachar arms cover this shape (`1` is a bare digit;
12978        // no `(` / `{` / letter follows the `$`), so the arm is the
12979        // sole gate on the shape.
12980        let d = dep_with_fonte(DepSource::Path {
12981            caminho: "../foo$1/bar".into(),
12982        });
12983        let err = d.validate().unwrap_err();
12984        assert!(
12985            matches!(
12986                err,
12987                DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
12988            ),
12989            "got {err:?}",
12990        );
12991    }
12992
12993    #[test]
12994    fn validate_accepts_path_fonte_with_caminho_carrying_no_dollar() {
12995        // The positive-control pin (peer with
12996        // `validate_accepts_path_fonte_with_caminho_carrying_no_percent`
12997        // on the immediate-predecessor arm): the gate targets only
12998        // `$`, never adjacent printable ASCII or POSIX-valid bytes.
12999        // A relative POSIX path carrying dashes / dots / slashes /
13000        // digits (`"../caixa-teia/sub-dir.v2"`) must continue to
13001        // validate cleanly so the gate doesn't widen to a "no
13002        // printable punctuation anywhere" sweep that would defeat
13003        // the entire path-fonte author surface.
13004        let d = dep_with_fonte(DepSource::Path {
13005            caminho: "../caixa-teia/sub-dir.v2".into(),
13006        });
13007        d.validate().unwrap();
13008    }
13009
13010    #[test]
13011    fn fonte_caminho_var_expansion_fires_before_shell_variable_expansion() {
13012        // Cascade pin on the leading-`$` sibling arm at line 540: a
13013        // value starting with `$` and carrying an embedded `$` too
13014        // (`"$HOME/foo$WORKSPACE/bar"` — the canonical "I pasted a
13015        // fully-templated CI path with two un-substituted variables")
13016        // routes through `FonteCaminhoVarExpansion` not
13017        // `FonteCaminhoShellVariableExpansion`. The leading-byte
13018        // host-layout-leak is the load-bearing self-locating axis
13019        // (the leading position dominates the semantic-locating
13020        // rationale on every probe-as-both value); the embedded
13021        // arm's positional-agnostic sweep catches only values whose
13022        // leading byte doesn't route through the earlier leading-
13023        // byte arms.
13024        let d = dep_with_fonte(DepSource::Path {
13025            caminho: "$HOME/foo$WORKSPACE/bar".into(),
13026        });
13027        let err = d.validate().unwrap_err();
13028        assert!(
13029            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
13030            "got {err:?}",
13031        );
13032    }
13033
13034    #[test]
13035    fn fonte_caminho_url_percent_encoding_fires_before_shell_variable_expansion() {
13036        // Cascade pin on the immediate-predecessor arm: a value
13037        // carrying both `%` and embedded `$` (`"../foo%20$HOME/bar"`
13038        // — the canonical "I pasted a percent-encoded space adjacent
13039        // to a `$HOME` template") routes through
13040        // `FonteCaminhoUrlPercentEncoding` not
13041        // `FonteCaminhoShellVariableExpansion`. The URL-percent-
13042        // encoding-escape byte is the more semantic-locating axis
13043        // (the paste-from-browser-address-bar shape is the load-
13044        // bearing self-locating edit); same cascade discipline every
13045        // prior `:caminho` arm establishes.
13046        let d = dep_with_fonte(DepSource::Path {
13047            caminho: "../foo%20$HOME/bar".into(),
13048        });
13049        let err = d.validate().unwrap_err();
13050        assert!(
13051            matches!(
13052                err,
13053                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
13054            ),
13055            "got {err:?}",
13056        );
13057    }
13058
13059    #[test]
13060    fn fonte_caminho_shell_variable_expansion_fires_before_trailing_slash() {
13061        // Cascade pin on the immediate-successor arm: a value
13062        // carrying both embedded `$` and a trailing `/`
13063        // (`"../foo$HOME/bar/"` — the canonical "I tab-completed a
13064        // `$HOME`-template-carrying path") routes through
13065        // `FonteCaminhoShellVariableExpansion` not
13066        // `FonteCaminhoTrailingSlash`. The embedded shell-variable-
13067        // expansion byte is the more semantic-locating axis on
13068        // probe-as-both values (an author who substitutes the
13069        // `$HOME` template with a literal value is likely to also
13070        // tab-strip the trailing separator).
13071        let d = dep_with_fonte(DepSource::Path {
13072            caminho: "../foo$HOME/bar/".into(),
13073        });
13074        let err = d.validate().unwrap_err();
13075        assert!(
13076            matches!(
13077                err,
13078                DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
13079            ),
13080            "got {err:?}",
13081        );
13082    }
13083
13084    #[test]
13085    fn fonte_caminho_shell_variable_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
13086        // Diagnostic-shape pin (peer with
13087        // `fonte_caminho_url_percent_encoding_diagnostic_carries_offending_dep_caminho_and_byte`
13088        // on the immediate-predecessor arm): the error's Display
13089        // surfaces the offending `:nome`, the offending `:caminho`
13090        // verbatim, the offending byte's hex / character form, and
13091        // names the shell-variable-expansion / command-substitution
13092        // footgun explicitly so a `feira lint` run can render the
13093        // diagnostic without re-parsing.
13094        let d = dep_with_fonte(DepSource::Path {
13095            caminho: "../foo$HOME/bar".into(),
13096        });
13097        let rendered = d.validate().unwrap_err().to_string();
13098        assert!(
13099            rendered.contains("caixa-teia"),
13100            "diagnostic must name the offending dep: {rendered}",
13101        );
13102        assert!(
13103            rendered.contains("../foo$HOME/bar"),
13104            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
13105        );
13106        assert!(
13107            rendered.contains("0x24"),
13108            "diagnostic must surface the offending byte hex: {rendered:?}",
13109        );
13110        assert!(
13111            rendered.contains("variable-expansion") || rendered.contains("variable expansion"),
13112            "diagnostic must name the shell-variable-expansion footgun: {rendered:?}",
13113        );
13114        assert!(
13115            rendered.contains("command-substitution") || rendered.contains("command substitution"),
13116            "diagnostic must reference the command-substitution vocabulary: {rendered:?}",
13117        );
13118    }
13119
13120    #[test]
13121    fn validate_rejects_path_fonte_with_caminho_carrying_shell_history_expansion() {
13122        // The fail-before-pass-after pin for the canonical paste-from-
13123        // shell-history footgun on `:caminho`. An author copies a `cd
13124        // ../caixa-teia && !sudo make install` one-liner from a quick-
13125        // start README, intending the trailing `!sudo` as a shell-
13126        // history-expansion reference but the typed slot is itself a
13127        // byte-level string parser, not a shell context, so the byte
13128        // rides into the value verbatim. Until this arm landed the `!`
13129        // byte silently passed every prior `:caminho` cascade arm
13130        // (`!` isn't `\` / `<` / `>` / `|` / `;` / `&` / backtick /
13131        // `*` / `?` / `(` / `)` / `{` / `}` / `[` / `]` / `'` / `"` /
13132        // `#` / `%` / `$`); bash with the default `histexpand` mode
13133        // rewrites `!command` to the most recent history entry
13134        // beginning with `command`, the canonical RCE-class injection
13135        // vector when the byte rides into a shell argument executed
13136        // under `bash -i` (the operator-notebook interactive shell).
13137        let d = dep_with_fonte(DepSource::Path {
13138            caminho: "../caixa-teia!sudo".into(),
13139        });
13140        let err = d.validate().unwrap_err();
13141        let DepError::FonteCaminhoShellHistoryExpansion {
13142            nome,
13143            caminho,
13144            byte,
13145        } = err
13146        else {
13147            panic!("expected FonteCaminhoShellHistoryExpansion, got {err:?}");
13148        };
13149        assert_eq!(nome, "caixa-teia");
13150        assert_eq!(caminho, "../caixa-teia!sudo");
13151        assert_eq!(byte, b'!');
13152    }
13153
13154    #[test]
13155    fn validate_rejects_path_fonte_with_caminho_carrying_double_bang_history_reference() {
13156        // The symmetric `!!` repeat-prior-command paste idiom (peer with
13157        // `validate_rejects_git_fonte_with_repo_carrying_double_bang_history_reference`
13158        // on `is_git_repo_url`). Pinned separately from the wrapped
13159        // `!command` shape so a future diagnostic-surface change that
13160        // only checked the leading or paired-bang position surfaces
13161        // here — the per-byte arm fires anywhere `!` appears in the
13162        // value, including at consecutive positions in the middle.
13163        let d = dep_with_fonte(DepSource::Path {
13164            caminho: "../foo!!/bar".into(),
13165        });
13166        let err = d.validate().unwrap_err();
13167        assert!(
13168            matches!(
13169                err,
13170                DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
13171            ),
13172            "got {err:?}",
13173        );
13174    }
13175
13176    #[test]
13177    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_enthusiasm_bang() {
13178        // The English-typography enthusiasm-form paste-from-prose
13179        // idiom: an author writes `:caminho "../caixa-teia!"`
13180        // expecting the substrate to coerce it to a kebab-case slug.
13181        // Pinned separately from the `!<word>` shell-history shape so
13182        // the gate's rationale extends to the paste-from-prose surface
13183        // (the same rationale the peer `is_git_repo_url` bang arm at
13184        // 7d53c68 covers). None of the prior shell-metachar arms cover
13185        // this shape (no `!<word>` reference and no `!!` repeat), so
13186        // the arm is the sole gate on the shape.
13187        let d = dep_with_fonte(DepSource::Path {
13188            caminho: "../caixa-teia!".into(),
13189        });
13190        let err = d.validate().unwrap_err();
13191        assert!(
13192            matches!(
13193                err,
13194                DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
13195            ),
13196            "got {err:?}",
13197        );
13198    }
13199
13200    #[test]
13201    fn validate_accepts_path_fonte_with_caminho_carrying_no_bang() {
13202        // The positive-control pin (peer with
13203        // `validate_accepts_path_fonte_with_caminho_carrying_no_dollar`
13204        // on the immediate-predecessor arm): the gate targets only
13205        // `!`, never adjacent printable ASCII or POSIX-valid bytes.
13206        // A relative POSIX path carrying dashes / dots / slashes /
13207        // digits (`"../caixa-teia/sub-dir.v2"`) must continue to
13208        // validate cleanly so the gate doesn't widen to a "no
13209        // printable punctuation anywhere" sweep that would defeat
13210        // the entire path-fonte author surface.
13211        let d = dep_with_fonte(DepSource::Path {
13212            caminho: "../caixa-teia/sub-dir.v2".into(),
13213        });
13214        d.validate().unwrap();
13215    }
13216
13217    #[test]
13218    fn fonte_caminho_shell_variable_expansion_fires_before_shell_history_expansion() {
13219        // Cascade pin on the immediate-predecessor arm: a value
13220        // carrying both embedded `$` and `!` (`"../foo$HOME/bar!sudo"`
13221        // — the canonical "I pasted a `$HOME`-templated path adjacent
13222        // to a trailing `!sudo` history-expansion") routes through
13223        // `FonteCaminhoShellVariableExpansion` not
13224        // `FonteCaminhoShellHistoryExpansion`. The shell-variable-
13225        // expansion byte is the more semantic-locating axis on
13226        // probe-as-both values (the paste-from-CI-manifest-with-`$VAR`-
13227        // template shape is the load-bearing self-locating edit);
13228        // same cascade discipline every prior `:caminho` arm
13229        // establishes.
13230        let d = dep_with_fonte(DepSource::Path {
13231            caminho: "../foo$HOME/bar!sudo".into(),
13232        });
13233        let err = d.validate().unwrap_err();
13234        assert!(
13235            matches!(
13236                err,
13237                DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
13238            ),
13239            "got {err:?}",
13240        );
13241    }
13242
13243    #[test]
13244    fn fonte_caminho_shell_history_expansion_fires_before_trailing_slash() {
13245        // Cascade pin on the immediate-successor arm: a value carrying
13246        // both embedded `!` and a trailing `/` (`"../caixa-teia!sudo/"`
13247        // — the canonical "I tab-completed a `!sudo`-carrying path")
13248        // routes through `FonteCaminhoShellHistoryExpansion` not
13249        // `FonteCaminhoTrailingSlash`. The embedded shell-history-
13250        // expansion byte is the more semantic-locating axis on probe-
13251        // as-both values (an author who removes the `!sudo` history
13252        // reference is likely to also tab-strip the trailing separator).
13253        let d = dep_with_fonte(DepSource::Path {
13254            caminho: "../caixa-teia!sudo/".into(),
13255        });
13256        let err = d.validate().unwrap_err();
13257        assert!(
13258            matches!(
13259                err,
13260                DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
13261            ),
13262            "got {err:?}",
13263        );
13264    }
13265
13266    #[test]
13267    fn fonte_caminho_shell_history_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
13268        // Diagnostic-shape pin (peer with
13269        // `fonte_caminho_shell_variable_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
13270        // on the immediate-predecessor arm): the error's Display
13271        // surfaces the offending `:nome`, the offending `:caminho`
13272        // verbatim, the offending byte's hex / character form, and
13273        // names the shell-history-expansion / bang-operator footgun
13274        // explicitly so a `feira lint` run can render the diagnostic
13275        // without re-parsing.
13276        let d = dep_with_fonte(DepSource::Path {
13277            caminho: "../caixa-teia!sudo".into(),
13278        });
13279        let rendered = d.validate().unwrap_err().to_string();
13280        assert!(
13281            rendered.contains("caixa-teia"),
13282            "diagnostic must name the offending dep: {rendered}",
13283        );
13284        assert!(
13285            rendered.contains("../caixa-teia!sudo"),
13286            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
13287        );
13288        assert!(
13289            rendered.contains("0x21"),
13290            "diagnostic must surface the offending byte hex: {rendered:?}",
13291        );
13292        assert!(
13293            rendered.contains("history-expansion") || rendered.contains("history expansion"),
13294            "diagnostic must name the shell-history-expansion footgun: {rendered:?}",
13295        );
13296        assert!(
13297            rendered.contains("bang"),
13298            "diagnostic must reference the bang-operator vocabulary: {rendered:?}",
13299        );
13300    }
13301
13302    #[test]
13303    fn validate_rejects_path_fonte_with_caminho_carrying_shell_history_substitution() {
13304        // The fail-before-pass-after pin for the canonical paste-from-
13305        // shell-history-quick-substitution footgun on `:caminho`. An
13306        // author copies a `git clone <bad-url>` line from their terminal,
13307        // corrects it via bash's `^bad^good` quick-substitution history
13308        // operator (bash reference §9.3, `set -o histexpand` mode's
13309        // default for interactive sessions), and pastes the trailing
13310        // `^bad^good` substitution fragment into a `:caminho` value
13311        // without trimming the leading `git clone` prefix — the byte
13312        // rides into the manifest verbatim. Until this arm landed the
13313        // `^` byte silently passed every prior `:caminho` cascade arm
13314        // (`^` isn't `\` / `<` / `>` / `|` / `;` / `&` / backtick / `*`
13315        // / `?` / `(` / `)` / `{` / `}` / `[` / `]` / `'` / `"` / `#` /
13316        // `%` / `$` / `!`); bash with the default `histexpand` mode
13317        // rewrites the prior command's `bad` string to `good` and re-
13318        // executes it, the paired-operator half of the `set -o
13319        // histexpand` feature the peer `!` arm already closes the prefix
13320        // half of. The peer `is_git_repo_url` axis rejects the byte at
13321        // 49e142f under the same shell-history-substitution / RFC-3986-
13322        // unwise banner.
13323        let d = dep_with_fonte(DepSource::Path {
13324            caminho: "../foo^bad^good".into(),
13325        });
13326        let err = d.validate().unwrap_err();
13327        let DepError::FonteCaminhoShellHistorySubstitution {
13328            nome,
13329            caminho,
13330            byte,
13331        } = err
13332        else {
13333            panic!("expected FonteCaminhoShellHistorySubstitution, got {err:?}");
13334        };
13335        assert_eq!(nome, "caixa-teia");
13336        assert_eq!(caminho, "../foo^bad^good");
13337        assert_eq!(byte, b'^');
13338    }
13339
13340    #[test]
13341    fn validate_rejects_path_fonte_with_caminho_carrying_regex_negation_anchor() {
13342        // The symmetric paste-from-doc-grep-pipeline footgun (peer with
13343        // `validate_rejects_git_fonte_with_repo_carrying_caret_regex_anchor`
13344        // on `is_git_repo_url`). An author copies a `grep '^archived'`
13345        // regex-anchor / negation idiom from a doc snippet and the byte
13346        // rides in verbatim. Pinned separately from the `^old^new^`
13347        // quick-substitution shape so a future diagnostic-surface change
13348        // that only checked the paired-caret history-substitution
13349        // position surfaces here — the per-byte arm fires anywhere `^`
13350        // appears in the value, including at a solitary leading-of-
13351        // segment position.
13352        let d = dep_with_fonte(DepSource::Path {
13353            caminho: "../foo/^archived".into(),
13354        });
13355        let err = d.validate().unwrap_err();
13356        assert!(
13357            matches!(
13358                err,
13359                DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
13360            ),
13361            "got {err:?}",
13362        );
13363    }
13364
13365    #[test]
13366    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_history_substitution_open() {
13367        // The trailing-`^` history-substitution-open shape — an author
13368        // starts typing a `^bad^good` quick-substitution but pastes only
13369        // the leading `^` sentinel before context-switching (a bash-
13370        // reference §9.3 valid histexpand prefix on its own — even a
13371        // solitary `^` on the prior command's whole re-execution shape).
13372        // Pinned separately from the `^old^new^` full-form and the leading-
13373        // of-segment `^archived` regex-anchor shape so the gate's
13374        // rationale extends to the paste-from-shell-history-with-only-
13375        // the-first-byte-selected surface. None of the prior shell-
13376        // metachar arms cover this shape.
13377        let d = dep_with_fonte(DepSource::Path {
13378            caminho: "../caixa-teia^".into(),
13379        });
13380        let err = d.validate().unwrap_err();
13381        assert!(
13382            matches!(
13383                err,
13384                DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
13385            ),
13386            "got {err:?}",
13387        );
13388    }
13389
13390    #[test]
13391    fn validate_accepts_path_fonte_with_caminho_carrying_no_caret() {
13392        // The positive-control pin (peer with
13393        // `validate_accepts_path_fonte_with_caminho_carrying_no_bang`
13394        // on the immediate-predecessor arm): the gate targets only
13395        // `^`, never adjacent printable ASCII or POSIX-valid bytes.
13396        // A relative POSIX path carrying dashes / dots / slashes /
13397        // digits / underscore (`"../caixa-teia/sub_v2.rc"`) must
13398        // continue to validate cleanly so the gate doesn't widen to
13399        // a "no printable punctuation anywhere" sweep that would
13400        // defeat the entire path-fonte author surface.
13401        let d = dep_with_fonte(DepSource::Path {
13402            caminho: "../caixa-teia/sub_v2.rc".into(),
13403        });
13404        d.validate().unwrap();
13405    }
13406
13407    #[test]
13408    fn fonte_caminho_shell_history_expansion_fires_before_shell_history_substitution() {
13409        // Cascade pin on the immediate-predecessor arm: a value carrying
13410        // both embedded `!` and `^` (`"../foo!sudo^bad^good"` — the
13411        // canonical "I pasted a `!sudo` history-reference next to a
13412        // `^bad^good` quick-substitution") routes through
13413        // `FonteCaminhoShellHistoryExpansion` not
13414        // `FonteCaminhoShellHistorySubstitution`. The `!` prefix form is
13415        // the more semantic-locating axis on probe-as-both values (an
13416        // author who removes the `!sudo` reference is likely to also
13417        // strip the paired `^` substitution fragment); same cascade
13418        // discipline every prior `:caminho` arm establishes.
13419        let d = dep_with_fonte(DepSource::Path {
13420            caminho: "../foo!sudo^bad^good".into(),
13421        });
13422        let err = d.validate().unwrap_err();
13423        assert!(
13424            matches!(
13425                err,
13426                DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
13427            ),
13428            "got {err:?}",
13429        );
13430    }
13431
13432    #[test]
13433    fn fonte_caminho_shell_history_substitution_fires_before_trailing_slash() {
13434        // Cascade pin on the immediate-successor arm: a value carrying
13435        // both embedded `^` and a trailing `/` (`"../foo^bad^good/"` —
13436        // the canonical "I tab-completed a `^bad^good`-carrying path")
13437        // routes through `FonteCaminhoShellHistorySubstitution` not
13438        // `FonteCaminhoTrailingSlash`. The embedded shell-history-
13439        // substitution byte is the more semantic-locating axis on probe-
13440        // as-both values (an author who removes the `^bad^good`
13441        // substitution fragment is likely to also tab-strip the trailing
13442        // separator).
13443        let d = dep_with_fonte(DepSource::Path {
13444            caminho: "../foo^bad^good/".into(),
13445        });
13446        let err = d.validate().unwrap_err();
13447        assert!(
13448            matches!(
13449                err,
13450                DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
13451            ),
13452            "got {err:?}",
13453        );
13454    }
13455
13456    #[test]
13457    fn fonte_caminho_shell_history_substitution_diagnostic_carries_offending_dep_caminho_and_byte()
13458    {
13459        // Diagnostic-shape pin (peer with
13460        // `fonte_caminho_shell_history_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
13461        // on the immediate-predecessor arm): the error's Display
13462        // surfaces the offending `:nome`, the offending `:caminho`
13463        // verbatim, the offending byte's hex form, and names the
13464        // shell-history-substitution / RFC-3986-'unwise' / regex-
13465        // negation footgun explicitly so a `feira lint` run can render
13466        // the diagnostic without re-parsing.
13467        let d = dep_with_fonte(DepSource::Path {
13468            caminho: "../foo^bad^good".into(),
13469        });
13470        let rendered = d.validate().unwrap_err().to_string();
13471        assert!(
13472            rendered.contains("caixa-teia"),
13473            "diagnostic must name the offending dep: {rendered}",
13474        );
13475        assert!(
13476            rendered.contains("../foo^bad^good"),
13477            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
13478        );
13479        assert!(
13480            rendered.contains("0x5e") || rendered.contains("0x5E"),
13481            "diagnostic must surface the offending byte hex: {rendered:?}",
13482        );
13483        assert!(
13484            rendered.contains("history-substitution") || rendered.contains("history substitution"),
13485            "diagnostic must name the shell-history-substitution footgun: {rendered:?}",
13486        );
13487        assert!(
13488            rendered.contains("unwise"),
13489            "diagnostic must reference the RFC-3986 'unwise' set vocabulary: {rendered:?}",
13490        );
13491    }
13492
13493    #[test]
13494    fn fonte_repo_empty_fires_before_pin_missing() {
13495        // Order pin: empty `:repo` is the more self-locating diagnostic
13496        // (every git source needs a repo; the pin discussion is
13497        // secondary), so it fires before the pin-missing arm even when
13498        // both are violated. Mirrors the
13499        // `nome_empty_takes_precedence_over_versao_invalid` ordering
13500        // discipline on the per-entry layer.
13501        let d = dep_with_fonte(DepSource::Git {
13502            repo: String::new(),
13503            tag: None,
13504            rev: None,
13505            branch: None,
13506        });
13507        let err = d.validate().unwrap_err();
13508        assert!(
13509            matches!(err, DepError::FonteRepoEmpty { .. }),
13510            "got {err:?}"
13511        );
13512    }
13513
13514    #[test]
13515    fn fonte_pin_missing_fires_before_pin_empty() {
13516        // Order pin: a fully-None pin set is structurally distinct from
13517        // a Some(empty) pin — the first surfaces as FontePinMissing
13518        // (no axis chosen), the second as FontePinEmpty (axis chosen
13519        // but value blank). Pin the disjoint relationship so a future
13520        // unification collapses to one variant only as a structural
13521        // decision.
13522        let d = dep_with_fonte(DepSource::Git {
13523            repo: "github:pleme-io/caixa-teia".into(),
13524            tag: None,
13525            rev: None,
13526            branch: None,
13527        });
13528        assert!(matches!(
13529            d.validate().unwrap_err(),
13530            DepError::FontePinMissing { .. }
13531        ));
13532    }
13533
13534    #[test]
13535    fn nome_empty_takes_precedence_over_fonte_invalid() {
13536        // Order pin: a per-entry diagnostic without a non-empty :nome
13537        // can't be self-locating, so :nome "" fires first even when
13538        // :fonte is also malformed. Mirrors
13539        // `nome_empty_takes_precedence_over_versao_invalid` on the
13540        // adjacent axis.
13541        let mut d = dep_with_fonte(DepSource::Git {
13542            repo: String::new(),
13543            tag: None,
13544            rev: None,
13545            branch: None,
13546        });
13547        d.nome = String::new();
13548        assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
13549    }
13550
13551    #[test]
13552    fn versao_invalid_takes_precedence_over_fonte_invalid() {
13553        // Order pin: the :versao parse-side diagnostic is narrower than
13554        // the :fonte shape diagnostic — a malformed :versao always names
13555        // the parser's reason, which is more actionable than the
13556        // :fonte gate's "the pins are wrong" wording. Pin the ordering
13557        // so a re-ordering surfaces here.
13558        let mut d = dep_with_fonte(DepSource::Git {
13559            repo: String::new(),
13560            tag: None,
13561            rev: None,
13562            branch: None,
13563        });
13564        d.versao = "v0.1".into();
13565        let err = d.validate().unwrap_err();
13566        assert!(
13567            matches!(err, DepError::VersaoInvalid { ref nome, .. } if nome == "caixa-teia"),
13568            "got {err:?}"
13569        );
13570    }
13571
13572    #[test]
13573    fn fonte_invalid_diagnostic_carries_offending_nome() {
13574        // The diagnostic-shape pin: every :fonte error variant names
13575        // the offending dep's :nome verbatim, so the author can grep
13576        // caixa.lisp for the `:nome "<n>"` block and fix it in one
13577        // edit. Cover all seven variants so a future variant addition
13578        // forces a parallel diagnostic-shape decision.
13579        for (case, fonte) in [
13580            (
13581                "repo-empty",
13582                DepSource::Git {
13583                    repo: String::new(),
13584                    tag: Some("v1".into()),
13585                    rev: None,
13586                    branch: None,
13587                },
13588            ),
13589            (
13590                "repo-shape",
13591                DepSource::Git {
13592                    repo: "github:p/x ".into(),
13593                    tag: Some("v1".into()),
13594                    rev: None,
13595                    branch: None,
13596                },
13597            ),
13598            (
13599                "pin-missing",
13600                DepSource::Git {
13601                    repo: "github:p/x".into(),
13602                    tag: None,
13603                    rev: None,
13604                    branch: None,
13605                },
13606            ),
13607            (
13608                "pin-ambiguous",
13609                DepSource::Git {
13610                    repo: "github:p/x".into(),
13611                    tag: Some("v1".into()),
13612                    rev: None,
13613                    branch: Some("main".into()),
13614                },
13615            ),
13616            (
13617                "pin-empty",
13618                DepSource::Git {
13619                    repo: "github:p/x".into(),
13620                    tag: Some(String::new()),
13621                    rev: None,
13622                    branch: None,
13623                },
13624            ),
13625            (
13626                "caminho-empty",
13627                DepSource::Path {
13628                    caminho: String::new(),
13629                },
13630            ),
13631            (
13632                "caminho-absolute",
13633                DepSource::Path {
13634                    caminho: "/home/me/work/caixa-teia".into(),
13635                },
13636            ),
13637        ] {
13638            let d = dep_with_fonte(fonte);
13639            let msg = d
13640                .validate()
13641                .expect_err(&format!("{case}: expected fonte error"))
13642                .to_string();
13643            assert!(
13644                msg.contains("\"caixa-teia\""),
13645                "{case}: diagnostic must quote the offending :nome verbatim, got {msg:?}"
13646            );
13647        }
13648    }
13649
13650    // -- :tag / :branch value-shape gate ----------------------------------
13651
13652    #[test]
13653    fn validate_rejects_git_fonte_with_tag_carrying_trailing_space() {
13654        // The canonical paste-from-doc footgun on `:tag` — author
13655        // copies `"v0.1.0 "` (trailing space) out of a release-notes
13656        // paragraph. Until this gate landed the empty-pin arm passed
13657        // (the string isn't empty), the resolver issued
13658        // `git fetch <remote> tag 'v0.1.0 '`, and the failure
13659        // surfaced at clone time with a quoting-confused git error
13660        // far from the source caixa.lisp. The new gate moves the
13661        // check to caixa-build time and names the offending dep +
13662        // pin + value verbatim.
13663        let d = dep_with_fonte(DepSource::Git {
13664            repo: "github:pleme-io/caixa-teia".into(),
13665            tag: Some("v0.1.0 ".into()),
13666            rev: None,
13667            branch: None,
13668        });
13669        let err = d.validate().unwrap_err();
13670        let DepError::FontePinShape {
13671            nome,
13672            pin,
13673            value,
13674            reason,
13675        } = err
13676        else {
13677            panic!("expected FontePinShape, got other variant");
13678        };
13679        assert_eq!(nome, "caixa-teia");
13680        assert_eq!(pin, ":tag");
13681        assert_eq!(value, "v0.1.0 ");
13682        assert!(
13683            reason.contains("whitespace"),
13684            "reason must surface the whitespace arm, got {reason:?}"
13685        );
13686    }
13687
13688    #[test]
13689    fn validate_rejects_git_fonte_with_tag_carrying_lock_suffix() {
13690        // The `.lock` suffix is git's atomic-rename guard for
13691        // in-flight ref updates — a refname ending in `.lock` is
13692        // unwritable on disk. Pinned separately from the whitespace
13693        // arm so a future relaxation that admits one but not the
13694        // other surfaces here.
13695        let d = dep_with_fonte(DepSource::Git {
13696            repo: "github:pleme-io/caixa-teia".into(),
13697            tag: Some("v0.1.0.lock".into()),
13698            rev: None,
13699            branch: None,
13700        });
13701        let err = d.validate().unwrap_err();
13702        let DepError::FontePinShape {
13703            pin, value, reason, ..
13704        } = err
13705        else {
13706            panic!("expected FontePinShape, got other variant");
13707        };
13708        assert_eq!(pin, ":tag");
13709        assert_eq!(value, "v0.1.0.lock");
13710        assert!(
13711            reason.contains(".lock"),
13712            "reason must surface the .lock arm, got {reason:?}"
13713        );
13714    }
13715
13716    #[test]
13717    fn validate_rejects_git_fonte_with_branch_carrying_embedded_space() {
13718        // The canonical "branch name with spaces" footgun (`feature
13719        // foo`, `release branch`) — git's refname parser rejects raw
13720        // whitespace, and the failure surfaces at `git checkout
13721        // 'feature foo'` time with a quoting-confused error far from
13722        // the source caixa.lisp. Pinned on the `:branch` axis so the
13723        // gate-applies-to-both-:tag-and-:branch contract is a build-
13724        // error to relax.
13725        let d = dep_with_fonte(DepSource::Git {
13726            repo: "github:pleme-io/caixa-teia".into(),
13727            tag: None,
13728            rev: None,
13729            branch: Some("feature/foo bar".into()),
13730        });
13731        let err = d.validate().unwrap_err();
13732        let DepError::FontePinShape {
13733            pin, value, reason, ..
13734        } = err
13735        else {
13736            panic!("expected FontePinShape, got other variant");
13737        };
13738        assert_eq!(pin, ":branch");
13739        assert_eq!(value, "feature/foo bar");
13740        assert!(
13741            reason.contains("whitespace"),
13742            "reason must surface the whitespace arm, got {reason:?}"
13743        );
13744    }
13745
13746    #[test]
13747    fn validate_rejects_git_fonte_with_branch_carrying_qualified_prefix() {
13748        // The `refs/heads/main` shape — the canonical "I copied the
13749        // fully-qualified ref out of `git show-ref` instead of the
13750        // leaf" footgun. The caixa-resolver prepends `refs/heads/`
13751        // at clone time, so this resolves to a literal ref named
13752        // `refs/heads/refs/heads/main` on disk; the silent double-
13753        // prefix is the load-bearing reason to gate at validate.
13754        // The diagnostic must enumerate the leaf the author probably
13755        // meant (`"main"`) so the fix is one edit.
13756        let d = dep_with_fonte(DepSource::Git {
13757            repo: "github:pleme-io/caixa-teia".into(),
13758            tag: None,
13759            rev: None,
13760            branch: Some("refs/heads/main".into()),
13761        });
13762        let err = d.validate().unwrap_err();
13763        let DepError::FontePinShape {
13764            pin, value, reason, ..
13765        } = err
13766        else {
13767            panic!("expected FontePinShape, got other variant");
13768        };
13769        assert_eq!(pin, ":branch");
13770        assert_eq!(value, "refs/heads/main");
13771        assert!(
13772            reason.contains("fully-qualified"),
13773            "reason must surface the qualified-prefix arm, got {reason:?}"
13774        );
13775        assert!(
13776            reason.contains("\"main\""),
13777            "reason must quote the leaf the author probably meant, got {reason:?}"
13778        );
13779    }
13780
13781    #[test]
13782    fn validate_rejects_git_fonte_with_tag_carrying_qualified_prefix() {
13783        // Sibling arm of the qualified-prefix gate on the `:tag`
13784        // axis (`refs/tags/v0.1.0` — same `git show-ref` output-leak
13785        // footgun). Pinned separately so a future relaxation that
13786        // only catches the `:branch` arm surfaces here.
13787        let d = dep_with_fonte(DepSource::Git {
13788            repo: "github:pleme-io/caixa-teia".into(),
13789            tag: Some("refs/tags/v0.1.0".into()),
13790            rev: None,
13791            branch: None,
13792        });
13793        let err = d.validate().unwrap_err();
13794        let DepError::FontePinShape {
13795            pin, value, reason, ..
13796        } = err
13797        else {
13798            panic!("expected FontePinShape, got other variant");
13799        };
13800        assert_eq!(pin, ":tag");
13801        assert_eq!(value, "refs/tags/v0.1.0");
13802        assert!(
13803            reason.contains("fully-qualified"),
13804            "reason must surface the qualified-prefix arm, got {reason:?}"
13805        );
13806        assert!(
13807            reason.contains("\"v0.1.0\""),
13808            "reason must quote the leaf the author probably meant, got {reason:?}"
13809        );
13810    }
13811
13812    #[test]
13813    fn validate_rejects_git_fonte_with_branch_named_at() {
13814        // The bare `@` is git's alias for `HEAD`; a `:branch "@"` is
13815        // unsourceable. Pinned so a future relaxation that admits
13816        // any single-character refname surfaces here.
13817        let d = dep_with_fonte(DepSource::Git {
13818            repo: "github:pleme-io/caixa-teia".into(),
13819            tag: None,
13820            rev: None,
13821            branch: Some("@".into()),
13822        });
13823        let err = d.validate().unwrap_err();
13824        let DepError::FontePinShape { pin, value, .. } = err else {
13825            panic!("expected FontePinShape, got other variant");
13826        };
13827        assert_eq!(pin, ":branch");
13828        assert_eq!(value, "@");
13829    }
13830
13831    #[test]
13832    fn validate_rejects_git_fonte_with_tag_carrying_double_dot() {
13833        // Git's `<rev1>..<rev2>` range grammar reserves `..` —
13834        // a `:tag "../escape"` (path-traversal-shaped slug) silently
13835        // passes parse and surfaces as a refname-parse error or, on
13836        // older git, a literal `../escape` checkout that escapes the
13837        // refs/ directory tree. Pinned separately from the
13838        // qualified-prefix arm so a future relaxation that catches
13839        // one but not the other surfaces here.
13840        let d = dep_with_fonte(DepSource::Git {
13841            repo: "github:pleme-io/caixa-teia".into(),
13842            tag: Some("../escape".into()),
13843            rev: None,
13844            branch: None,
13845        });
13846        let err = d.validate().unwrap_err();
13847        let DepError::FontePinShape { pin, value, .. } = err else {
13848            panic!("expected FontePinShape, got other variant");
13849        };
13850        assert_eq!(pin, ":tag");
13851        assert_eq!(value, "../escape");
13852    }
13853
13854    #[test]
13855    fn validate_accepts_git_fonte_with_hierarchical_branch() {
13856        // The positive-control pin: hierarchical refnames with one or
13857        // more `/` separators (the `feature/foo` / `user/jdoe/feat`
13858        // canonical idiom) round-trip through the gate. Pinned
13859        // separately from the leaf-`"main"` positive control so a
13860        // future tightening that rejects all multi-component refnames
13861        // surfaces here.
13862        let d = dep_with_fonte(DepSource::Git {
13863            repo: "github:pleme-io/caixa-teia".into(),
13864            tag: None,
13865            rev: None,
13866            branch: Some("feature/checkout-rewrite".into()),
13867        });
13868        d.validate().unwrap();
13869    }
13870
13871    #[test]
13872    fn validate_accepts_git_fonte_with_prerelease_tag() {
13873        // The positive-control pin: semver pre-release shape
13874        // (`v0.1.0-alpha.1`) — the in-component dot is allowed
13875        // (only consecutive `..` and trailing `.` are rejected), the
13876        // mid-component hyphen is allowed. Pinned separately from
13877        // the bare-`"v0.1.0"` positive control so a future tightening
13878        // that rejects pre-release tags surfaces here.
13879        let d = dep_with_fonte(DepSource::Git {
13880            repo: "github:pleme-io/caixa-teia".into(),
13881            tag: Some("v0.1.0-alpha.1".into()),
13882            rev: None,
13883            branch: None,
13884        });
13885        d.validate().unwrap();
13886    }
13887
13888    #[test]
13889    fn validate_rejects_git_fonte_with_rev_carrying_refname_unfriendly_value() {
13890        // The `:rev` axis is routed through `crate::render::is_git_oid`
13891        // (a SHA's character set is `[0-9a-f]`, not a refname's), so a
13892        // value with refname-shape punctuation (here, a `:` mid-string
13893        // — would be a refname violation under `is_git_ref_name` too)
13894        // is rejected at the OID-shape gate. The two predicates
13895        // partition the `:fonte` pin axes structurally: an `:rev` value
13896        // that's a valid refname (`:rev "main"`, `:rev "v0.1.0"`) is
13897        // *still* rejected here because every refname character outside
13898        // `[0-9a-f]` fails the OID gate. Same shape as
13899        // `fonte_pin_shape_diagnostic_carries_offending_nome_pin_value`
13900        // on the refname-shaped axes — the diagnostic names the
13901        // offending dep + pin + value verbatim. The flip-from-accept
13902        // case the prior `:tag`/`:branch` gate left as a "future axis"
13903        // (e70d213) — now landed.
13904        let d = dep_with_fonte(DepSource::Git {
13905            repo: "github:pleme-io/caixa-teia".into(),
13906            tag: None,
13907            rev: Some("c0ffee:notarefname".into()),
13908            branch: None,
13909        });
13910        let err = d.validate().unwrap_err();
13911        let DepError::FontePinShape {
13912            nome,
13913            pin,
13914            value,
13915            reason,
13916        } = err
13917        else {
13918            panic!("expected FontePinShape, got other variant");
13919        };
13920        assert_eq!(nome, "caixa-teia");
13921        assert_eq!(pin, ":rev");
13922        assert_eq!(value, "c0ffee:notarefname");
13923        assert!(
13924            !reason.is_empty(),
13925            "FontePinShape `reason` must carry the predicate's wording verbatim"
13926        );
13927    }
13928
13929    #[test]
13930    fn validate_accepts_git_fonte_with_rev_full_sha1() {
13931        // The positive-control pin on the SHA-1 OID width: exactly 40
13932        // lowercase hex characters — the canonical `git rev-parse HEAD`
13933        // emission on a SHA-1-hashed repository (the default on every
13934        // pre-2.42 git and the canonical pleme-io substrate hash).
13935        // Pinned separately from the SHA-256 positive control so a
13936        // future tightening that only admits one width surfaces here.
13937        let d = dep_with_fonte(DepSource::Git {
13938            repo: "github:pleme-io/caixa-teia".into(),
13939            tag: None,
13940            rev: Some("0123456789abcdef0123456789abcdef01234567".into()),
13941            branch: None,
13942        });
13943        d.validate().unwrap();
13944    }
13945
13946    #[test]
13947    fn validate_accepts_git_fonte_with_rev_full_sha256() {
13948        // The positive-control pin on the SHA-256 OID width: exactly
13949        // 64 lowercase hex characters — `git`'s
13950        // `extensions.objectFormat = sha256` emission (GA since Git
13951        // 2.42 / Oct 2023). The substrate admits either canonical
13952        // width so an `:rev` authored against a SHA-256-hashed
13953        // upstream round-trips through the gate without per-repo
13954        // configuration. Pinned separately from the SHA-1 positive
13955        // control so a future tightening that drops one width surfaces
13956        // here as a structural decision.
13957        let d = dep_with_fonte(DepSource::Git {
13958            repo: "github:pleme-io/caixa-teia".into(),
13959            tag: None,
13960            rev: Some("0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef".into()),
13961            branch: None,
13962        });
13963        d.validate().unwrap();
13964    }
13965
13966    #[test]
13967    fn validate_rejects_git_fonte_with_rev_abbreviated_prefix() {
13968        // The canonical `git log --short` / `git rev-parse --short HEAD`
13969        // paste-from-release-notes footgun: a 7-char prefix (git's
13970        // default `core.abbrev`) silently passes string emptiness
13971        // checks and resolves to one commit today, but becomes ambiguous
13972        // tomorrow as the repo grows. Until this gate landed the empty-
13973        // pin arm passed (the string isn't empty) and the resolver
13974        // accepted the prefix through git's separate prefix-lookup pass
13975        // — defeating the reproducibility contract `:rev` carries vs.
13976        // `:tag` / `:branch`. The new gate moves the check to caixa-
13977        // build time and names the offending dep + pin + value verbatim.
13978        let d = dep_with_fonte(DepSource::Git {
13979            repo: "github:pleme-io/caixa-teia".into(),
13980            tag: None,
13981            rev: Some("c0ffee0".into()),
13982            branch: None,
13983        });
13984        let err = d.validate().unwrap_err();
13985        let DepError::FontePinShape {
13986            pin, value, reason, ..
13987        } = err
13988        else {
13989            panic!("expected FontePinShape, got other variant");
13990        };
13991        assert_eq!(pin, ":rev");
13992        assert_eq!(value, "c0ffee0");
13993        assert!(
13994            reason.contains("abbreviated") || reason.contains("ambiguous"),
13995            "reason must surface the abbreviation arm, got {reason:?}"
13996        );
13997    }
13998
13999    #[test]
14000    fn validate_rejects_git_fonte_with_rev_uppercase_hex() {
14001        // The canonical "I pasted the SHA in uppercase" footgun: `git
14002        // porcelain` emits OIDs lowercase exclusively, so an uppercase-
14003        // bearing `:rev` round-trips inconsistently across the
14004        // resolver's `git fetch <remote> <:rev>` ↔ `git rev-parse HEAD`
14005        // equality-check pipeline and fails the lacre's content-
14006        // addressing probe with a confusing case-only diff. Pinned
14007        // separately from the non-hex arm so a future relaxation that
14008        // admits one but not the other surfaces here.
14009        let d = dep_with_fonte(DepSource::Git {
14010            repo: "github:pleme-io/caixa-teia".into(),
14011            tag: None,
14012            rev: Some("DEADBEEFCAFEBABE0123456789ABCDEF01234567".into()),
14013            branch: None,
14014        });
14015        let err = d.validate().unwrap_err();
14016        let DepError::FontePinShape {
14017            pin, value, reason, ..
14018        } = err
14019        else {
14020            panic!("expected FontePinShape, got other variant");
14021        };
14022        assert_eq!(pin, ":rev");
14023        assert_eq!(value, "DEADBEEFCAFEBABE0123456789ABCDEF01234567");
14024        assert!(
14025            reason.contains("uppercase"),
14026            "reason must surface the uppercase arm, got {reason:?}"
14027        );
14028    }
14029
14030    #[test]
14031    fn validate_rejects_git_fonte_with_rev_refname_value() {
14032        // The cross-axis mis-slot footgun: `:rev "main"` — the author
14033        // conflated `:rev` (hex commit ID, immutable) and `:branch`
14034        // (mutable ref pointing at whatever HEAD is today). Until this
14035        // gate landed the resolver silently dispatched on the value
14036        // shape ("`main` doesn't look like a SHA, fall back to
14037        // refname"), defeating the `:rev` reproducibility contract.
14038        // The new gate rejects every non-hex value on the `:rev` axis,
14039        // so the `:rev`/`:branch` boundary is structurally enforced —
14040        // a refname in the `:rev` slot is a build error, not a
14041        // resolver-time silent reinterpretation.
14042        let d = dep_with_fonte(DepSource::Git {
14043            repo: "github:pleme-io/caixa-teia".into(),
14044            tag: None,
14045            rev: Some("main".into()),
14046            branch: None,
14047        });
14048        let err = d.validate().unwrap_err();
14049        let DepError::FontePinShape {
14050            pin, value, reason, ..
14051        } = err
14052        else {
14053            panic!("expected FontePinShape, got other variant");
14054        };
14055        assert_eq!(pin, ":rev");
14056        assert_eq!(value, "main");
14057        // 4 chars `main` fails the length arm before the character arm,
14058        // so the diagnostic surfaces the abbreviation wording (same
14059        // path the `c0ffee0` 7-char fixture lands on); the structural
14060        // assertion is just that the `:rev "main"` value is rejected.
14061        assert!(
14062            !reason.is_empty(),
14063            "FontePinShape reason must be non-empty for refname-shaped :rev"
14064        );
14065    }
14066
14067    #[test]
14068    fn validate_rejects_git_fonte_with_rev_tag_shaped_value() {
14069        // Sibling cross-axis mis-slot: `:rev "v0.1.0"` — the author
14070        // conflated `:rev` and `:tag`. Pinned separately from the
14071        // `:rev "main"` (`:branch` mis-slot) arm so a future relaxation
14072        // that catches one but not the other surfaces here. The
14073        // length arm fires first (6 chars ≠ 40 ≠ 64); the structural
14074        // assertion is just that the cross-axis mis-slot is a build
14075        // error, regardless of which sub-arm surfaces the diagnostic
14076        // (`is_git_oid` rejects at the first violation; longer
14077        // tag-shape values would hit the non-hex arm instead).
14078        let d = dep_with_fonte(DepSource::Git {
14079            repo: "github:pleme-io/caixa-teia".into(),
14080            tag: None,
14081            rev: Some("v0.1.0".into()),
14082            branch: None,
14083        });
14084        let err = d.validate().unwrap_err();
14085        let DepError::FontePinShape {
14086            pin, value, reason, ..
14087        } = err
14088        else {
14089            panic!("expected FontePinShape, got other variant");
14090        };
14091        assert_eq!(pin, ":rev");
14092        assert_eq!(value, "v0.1.0");
14093        assert!(
14094            !reason.is_empty(),
14095            "FontePinShape reason must be non-empty for tag-shaped :rev"
14096        );
14097    }
14098
14099    #[test]
14100    fn validate_rejects_git_fonte_with_rev_too_long() {
14101        // Boundary case on the upper end: 41 hex chars — one past the
14102        // SHA-1 width, well below the SHA-256 width. Pin so a future
14103        // relaxation that admits "long enough to be a SHA" without
14104        // matching either canonical width surfaces here. The diagnostic
14105        // names the offending length verbatim so the author's grep
14106        // target is unambiguous (either trim one char or paste the
14107        // full SHA-256).
14108        let too_long: String = "0".repeat(41);
14109        let d = dep_with_fonte(DepSource::Git {
14110            repo: "github:pleme-io/caixa-teia".into(),
14111            tag: None,
14112            rev: Some(too_long.clone()),
14113            branch: None,
14114        });
14115        let err = d.validate().unwrap_err();
14116        let DepError::FontePinShape {
14117            pin, value, reason, ..
14118        } = err
14119        else {
14120            panic!("expected FontePinShape, got other variant");
14121        };
14122        assert_eq!(pin, ":rev");
14123        assert_eq!(value, too_long);
14124        assert!(
14125            reason.contains("41"),
14126            "reason must surface the offending length verbatim, got {reason:?}"
14127        );
14128    }
14129
14130    #[test]
14131    fn validate_rejects_git_fonte_with_rev_carrying_whitespace() {
14132        // The canonical paste-from-doc footgun on `:rev` — author
14133        // copies `"deadbeefcafe…0123 "` (trailing space) out of a
14134        // commit-message paragraph. Until this gate landed the empty-
14135        // pin arm passed (the string isn't empty), the resolver issued
14136        // `git fetch <remote> 'deadbeef… '` and the failure surfaced at
14137        // clone time with a quoting-confused git error far from the
14138        // source caixa.lisp. The new gate moves the check to caixa-
14139        // build time. Length is 41 (40 hex + space) so the length arm
14140        // fires first — pinned separately from the pure-length arm to
14141        // ensure the diagnostic surfaces *some* parser wording, not
14142        // silently pass through.
14143        let with_space = "0123456789abcdef0123456789abcdef01234567 ".to_string();
14144        let d = dep_with_fonte(DepSource::Git {
14145            repo: "github:pleme-io/caixa-teia".into(),
14146            tag: None,
14147            rev: Some(with_space.clone()),
14148            branch: None,
14149        });
14150        let err = d.validate().unwrap_err();
14151        let DepError::FontePinShape {
14152            pin, value, reason, ..
14153        } = err
14154        else {
14155            panic!("expected FontePinShape, got other variant");
14156        };
14157        assert_eq!(pin, ":rev");
14158        assert_eq!(value, with_space);
14159        assert!(
14160            !reason.is_empty(),
14161            "FontePinShape reason must be non-empty for whitespace-bearing :rev"
14162        );
14163    }
14164
14165    #[test]
14166    fn fonte_pin_shape_diagnostic_carries_offending_nome_pin_value_for_rev() {
14167        // Diagnostic-shape pin on the `:rev` axis: every FontePinShape
14168        // variant on this axis names the offending dep's `:nome` + the
14169        // `:rev` axis + the offending value verbatim, so the author's
14170        // grep target is the literal `:rev "<value>"` block in
14171        // caixa.lisp. Sibling of the `fonte_pin_shape_diagnostic_
14172        // carries_offending_nome_pin_value` test on the refname-shaped
14173        // (`:tag` / `:branch`) axes.
14174        let d = dep_with_fonte(DepSource::Git {
14175            repo: "github:p/x".into(),
14176            tag: None,
14177            rev: Some("not-a-sha".into()),
14178            branch: None,
14179        });
14180        let msg = d
14181            .validate()
14182            .expect_err(":rev: expected FontePinShape")
14183            .to_string();
14184        assert!(
14185            msg.contains("\"caixa-teia\""),
14186            ":rev: diagnostic must quote the offending :nome verbatim, got {msg:?}"
14187        );
14188        assert!(
14189            msg.contains(":rev"),
14190            ":rev: diagnostic must name the offending pin axis, got {msg:?}"
14191        );
14192        assert!(
14193            msg.contains("not-a-sha"),
14194            ":rev: diagnostic must quote the offending value verbatim, got {msg:?}"
14195        );
14196    }
14197
14198    #[test]
14199    fn fonte_pin_empty_fires_before_pin_shape() {
14200        // Order pin: a `Some("")` `:tag` is the more self-locating
14201        // diagnostic (the author chose an axis but left it blank;
14202        // grep is unambiguous), so it fires before the shape gate
14203        // even when both arms would match. Pinned so a future
14204        // reordering surfaces here. Mirrors the
14205        // `fonte_repo_empty_fires_before_pin_missing` ordering
14206        // discipline on the peer per-axis arms.
14207        let d = dep_with_fonte(DepSource::Git {
14208            repo: "github:pleme-io/caixa-teia".into(),
14209            tag: Some(String::new()),
14210            rev: None,
14211            branch: None,
14212        });
14213        assert!(matches!(
14214            d.validate().unwrap_err(),
14215            DepError::FontePinEmpty { ref pin, .. } if pin == ":tag"
14216        ));
14217    }
14218
14219    #[test]
14220    fn fonte_pin_shape_fires_after_repo_empty() {
14221        // Order pin: `:repo ""` is the more self-locating axis
14222        // (every git source needs a repo; the per-pin shape gate is
14223        // secondary), so the repo-empty arm fires before the
14224        // per-pin shape arm even when both are violated. Pinned so
14225        // a future reordering surfaces here. Mirrors
14226        // `fonte_repo_empty_fires_before_pin_missing` on the
14227        // adjacent axis pair.
14228        let d = dep_with_fonte(DepSource::Git {
14229            repo: String::new(),
14230            tag: Some("v0.1.0 ".into()),
14231            rev: None,
14232            branch: None,
14233        });
14234        assert!(matches!(
14235            d.validate().unwrap_err(),
14236            DepError::FonteRepoEmpty { .. }
14237        ));
14238    }
14239
14240    #[test]
14241    fn fonte_pin_shape_diagnostic_carries_offending_nome_pin_value() {
14242        // Diagnostic-shape pin across both refname-shaped axes
14243        // (`:tag` + `:branch`): every `FontePinShape` variant names
14244        // the offending dep's `:nome` + the offending pin axis + the
14245        // offending value verbatim, so the author's grep target is
14246        // unambiguous (the literal `:tag "<value>"` / `:branch
14247        // "<value>"` lands in caixa.lisp with quotes). Cover both
14248        // pin axes so a future variant addition forces a parallel
14249        // diagnostic-shape decision.
14250        for (pin_label, fonte) in [
14251            (
14252                ":tag",
14253                DepSource::Git {
14254                    repo: "github:p/x".into(),
14255                    tag: Some("v0.1.0~1".into()),
14256                    rev: None,
14257                    branch: None,
14258                },
14259            ),
14260            (
14261                ":branch",
14262                DepSource::Git {
14263                    repo: "github:p/x".into(),
14264                    tag: None,
14265                    rev: None,
14266                    branch: Some("feature/foo*".into()),
14267                },
14268            ),
14269        ] {
14270            let d = dep_with_fonte(fonte);
14271            let msg = d
14272                .validate()
14273                .expect_err(&format!("{pin_label}: expected FontePinShape"))
14274                .to_string();
14275            assert!(
14276                msg.contains("\"caixa-teia\""),
14277                "{pin_label}: diagnostic must quote the offending :nome verbatim, got {msg:?}"
14278            );
14279            assert!(
14280                msg.contains(pin_label),
14281                "{pin_label}: diagnostic must name the offending pin axis, got {msg:?}"
14282            );
14283        }
14284    }
14285
14286    #[test]
14287    fn git_source_json_round_trip() {
14288        let src = DepSource::Git {
14289            repo: "github:pleme-io/caixa-teia".into(),
14290            tag: Some("v0.1.0".into()),
14291            rev: None,
14292            branch: None,
14293        };
14294        let s = serde_json::to_string(&src).unwrap();
14295        assert!(s.contains(&format!(
14296            r#""{tipo}":"{git}""#,
14297            tipo = crate::render::DEP_SOURCE_KEY_TIPO,
14298            git = crate::render::DEP_SOURCE_TIPO_GIT,
14299        )));
14300        assert!(s.contains(r#""repo":"github:pleme-io/caixa-teia""#));
14301        assert!(s.contains(r#""tag":"v0.1.0""#));
14302        assert!(!s.contains("rev"));
14303        assert!(!s.contains("branch"));
14304        let round: DepSource = serde_json::from_str(&s).unwrap();
14305        assert_eq!(round, src);
14306    }
14307
14308    // ── DEP_SOURCE_{KEY_TIPO,TIPO_GIT,TIPO_PATH} drift-detection ────────
14309    //
14310    // The `#[serde(tag = "tipo", rename_all = "lowercase")]` derive
14311    // attribute on [`DepSource`] pins three load-bearing byte-sequences
14312    // that flow into every serialized `Dep.fonte` block: the outer
14313    // discriminator-key `"tipo"` the `tag = "tipo"` attribute names, and
14314    // the two admitted variant-tag values `"git"` / `"path"` the
14315    // `rename_all = "lowercase"` attribute pins as the discriminator's
14316    // closed-set arms. The three pin tests below round-trip a
14317    // fully-populated variant of each arm through
14318    // [`serde_json::to_value`] and assert each canonical byte-sequence
14319    // appears at its axis — pins a hypothetical future
14320    // `tag = "type"` / `tag = "source_type"` typo, a `rename_all`
14321    // rebrand (`"UPPERCASE"` / `"snake_case"` / `"kebab-case"`), or a
14322    // Rust-side variant rename (`Git` → `Repository`, `Path` → `Local`)
14323    // at build time rather than at fetch time when the resolver's
14324    // `Dep.fonte` dispatch silently fails to match on the drifted
14325    // discriminator. Same "serialize-and-check" discipline the peer
14326    // `M2_LIMITS_KEY_*`, `M2_BEHAVIOR_KEY_ON_*`, `SUPERVISOR_KEY_*`,
14327    // and `MEMBRO_KEY_*` drift-detection pins carry — extended here
14328    // to the last `#[serde(tag = ..., rename_all = ...)]` discriminator
14329    // family in caixa-core lacking a lifted peer.
14330
14331    #[test]
14332    fn dep_source_git_serde_keys_match_lifted_dep_source_key_consts() {
14333        // Fail-before-pass-after: a future `tag = "type"` at the derive
14334        // attribute would serialize under `"type":"git"`, and this test
14335        // would trip because `"tipo"` no longer appears at the emitted
14336        // discriminator key. A future `rename_all = "kebab-case"` /
14337        // `"snake_case"` (both no-ops on `Git` since it lacks internal
14338        // word boundaries) is caught by the sibling
14339        // `dep_source_path_serde_keys_match_lifted_dep_source_key_consts`
14340        // pin below (Path has no internal boundary either but the pair
14341        // catches any per-arm inconsistency). A future variant rename
14342        // `Git` → `Repository` would emit `"tipo":"repository"` and
14343        // trip this pin.
14344        let src = DepSource::Git {
14345            repo: "github:pleme-io/caixa-teia".into(),
14346            tag: Some("v0.1.0".into()),
14347            rev: None,
14348            branch: None,
14349        };
14350        let json = serde_json::to_value(&src).unwrap();
14351        let obj = json.as_object().expect("Git serializes as a JSON object");
14352        assert_eq!(
14353            obj.get(crate::render::DEP_SOURCE_KEY_TIPO)
14354                .and_then(serde_json::Value::as_str),
14355            Some(crate::render::DEP_SOURCE_TIPO_GIT),
14356            "DepSource::Git must serialize the tipo discriminator at DEP_SOURCE_KEY_TIPO \
14357             with value DEP_SOURCE_TIPO_GIT — attribute drift or variant rename \
14358             detected in {json}"
14359        );
14360    }
14361
14362    #[test]
14363    fn dep_source_path_serde_keys_match_lifted_dep_source_key_consts() {
14364        // Fail-before-pass-after: a future variant rename `Path` →
14365        // `Local` / `Filesystem` would emit `"tipo":"local"` and trip
14366        // this pin. A per-consumer disambiguation as the `defcaixa`
14367        // macro stabilizes ("caminho" → "path" for English-uniformity)
14368        // is scoped to the inner field key, not the discriminator; this
14369        // pin is orthogonal to that and catches only the outer
14370        // discriminator drift.
14371        let src = DepSource::Path {
14372            caminho: "../caixa-teia".into(),
14373        };
14374        let json = serde_json::to_value(&src).unwrap();
14375        let obj = json.as_object().expect("Path serializes as a JSON object");
14376        assert_eq!(
14377            obj.get(crate::render::DEP_SOURCE_KEY_TIPO)
14378                .and_then(serde_json::Value::as_str),
14379            Some(crate::render::DEP_SOURCE_TIPO_PATH),
14380            "DepSource::Path must serialize the tipo discriminator at DEP_SOURCE_KEY_TIPO \
14381             with value DEP_SOURCE_TIPO_PATH — attribute drift or variant rename \
14382             detected in {json}"
14383        );
14384    }
14385
14386    #[test]
14387    fn dep_source_key_consts_are_pairwise_distinct() {
14388        // Cross-axis collapse detector: a hypothetical future edit that
14389        // accidentally set two of the three consts to the same byte
14390        // (`DEP_SOURCE_TIPO_GIT = "path"` typo matching a peer arm) would
14391        // pass every per-arm serialize pin above but silently collapse
14392        // the discriminator's closed-set arms onto one another; this pin
14393        // catches the collapse at build time.
14394        assert_ne!(
14395            crate::render::DEP_SOURCE_KEY_TIPO,
14396            crate::render::DEP_SOURCE_TIPO_GIT,
14397        );
14398        assert_ne!(
14399            crate::render::DEP_SOURCE_KEY_TIPO,
14400            crate::render::DEP_SOURCE_TIPO_PATH,
14401        );
14402        assert_ne!(
14403            crate::render::DEP_SOURCE_TIPO_GIT,
14404            crate::render::DEP_SOURCE_TIPO_PATH,
14405        );
14406    }
14407
14408    #[test]
14409    fn dep_source_tipo_variant_consts_are_ascii_lowercase_shape() {
14410        // Shape pin against `rename_all` drift: the two variant-tag
14411        // consts must be ASCII-lowercase-only to match the
14412        // `rename_all = "lowercase"` attribute the derive uses; a future
14413        // rebrand to `"UPPERCASE"` / `"PascalCase"` at the attribute
14414        // would emit `"GIT"` / `"Git"` instead and trip this pin.
14415        for (label, s) in [
14416            ("DEP_SOURCE_TIPO_GIT", crate::render::DEP_SOURCE_TIPO_GIT),
14417            ("DEP_SOURCE_TIPO_PATH", crate::render::DEP_SOURCE_TIPO_PATH),
14418        ] {
14419            assert!(!s.is_empty(), "{label} must not be empty");
14420            assert!(
14421                s.bytes().all(|b| b.is_ascii_lowercase()),
14422                "{label} must be ASCII-lowercase-only (matching \
14423                 rename_all = \"lowercase\"), got {s:?}",
14424            );
14425        }
14426    }
14427
14428    // ── per-entry :caracteristicas set-not-multiset gate ────────────
14429    //
14430    // Every Vec-keyed-by-name authoring surface on the typed Caixa
14431    // surface that identifies its entries by a name field now uniformly
14432    // closes the set-not-multiset discipline at build time (cite
14433    // `validate_caracteristicas`'s peer-axis enumeration). The
14434    // `:caracteristicas` axis is per-`Dep`: the feature-toggle slot is
14435    // set-shaped (a feature is either enabled or not — there is no
14436    // `feature × 2` semantic), so two entries naming the same feature
14437    // are a redundant declaration the caixa-resolver's lacre pipeline
14438    // would silently dedup at resolve time. The empty-feature arm
14439    // closes the parallel "operationally-meaningless value" axis on
14440    // the same slot. Same linear-walk + `HashSet` + first-collision
14441    // shape every peer set gate uses; same empty-first cascade every
14442    // peer per-entry shape + duplicate gate uses (the empty-feature
14443    // axis is the more-actionable defect since two `""` entries would
14444    // both report `caracteristica: ""` under a duplicate-first
14445    // ordering, with no way to distinguish the offending site).
14446
14447    fn dep_with_features(features: &[&str]) -> Dep {
14448        Dep {
14449            nome: "caixa-teia".into(),
14450            versao: "^0.1".into(),
14451            fonte: None,
14452            opcional: false,
14453            caracteristicas: features.iter().map(|s| (*s).into()).collect(),
14454        }
14455    }
14456
14457    #[test]
14458    fn validate_rejects_empty_caracteristica() {
14459        // Fail-before-pass-after pin: every pre-gate codebase accepted
14460        // `(:caracteristicas (""))` cleanly (the `Vec<String>` field
14461        // imposed no per-entry shape contract), the dep validated, and
14462        // the empty feature would have reached the future caixa-resolver
14463        // lacre pipeline as a no-op feature enable — silently dropping
14464        // the author's intent far from the source `caixa.lisp`. The new
14465        // gate surfaces the structural defect at the typed-validate
14466        // surface with a self-locating diagnostic naming the offending
14467        // dep's `:nome`.
14468        let d = dep_with_features(&[""]);
14469        assert!(
14470            matches!(d.validate().unwrap_err(), DepError::CaracteristicaEmpty { ref nome } if nome == "caixa-teia"),
14471            "expected CaracteristicaEmpty, got {:?}",
14472            d.validate(),
14473        );
14474    }
14475
14476    #[test]
14477    fn validate_rejects_duplicate_caracteristica() {
14478        // Fail-before-pass-after pin on the set-not-multiset arm: the
14479        // feature-toggle slot is set-shaped, so `(:caracteristicas
14480        // ("http" "http"))` is a redundant declaration the lacre
14481        // pipeline dedupes silently at resolve time. The diagnostic
14482        // names the offending dep + the colliding feature verbatim so
14483        // the author can grep their caixa.lisp for `:caracteristicas`
14484        // and fix it in one edit. First-collision determinism is
14485        // pinned separately below.
14486        let d = dep_with_features(&["http", "http"]);
14487        assert!(
14488            matches!(
14489                d.validate().unwrap_err(),
14490                DepError::CaracteristicaDuplicate { ref nome, ref caracteristica }
14491                    if nome == "caixa-teia" && caracteristica == "http"
14492            ),
14493            "expected CaracteristicaDuplicate, got {:?}",
14494            d.validate(),
14495        );
14496    }
14497
14498    #[test]
14499    fn validate_accepts_distinct_caracteristicas() {
14500        // The canonical authoring shape — every feature distinct — must
14501        // remain a clean pass (positive control sweep). Covers the
14502        // canonical kebab-case feature names a target caixa typically
14503        // declares.
14504        dep_with_features(&["http", "json", "tls"])
14505            .validate()
14506            .unwrap();
14507    }
14508
14509    #[test]
14510    fn validate_accepts_single_caracteristica() {
14511        // Single-element list is the minimum non-empty shape; passes
14512        // the gate as the identity of the duplicate check (no second
14513        // entry to collide with).
14514        dep_with_features(&["http"]).validate().unwrap();
14515    }
14516
14517    #[test]
14518    fn validate_accepts_empty_caracteristicas_list() {
14519        // The bare-dep authoring shape (`Dep::simple` / `Dep::git`)
14520        // produces `caracteristicas: Vec::new()`; the empty list is
14521        // the gate's empty-set identity and passes vacuously. Pin
14522        // this so a future tightening that requires ≥1 feature
14523        // surfaces here as a test failure rather than a silent
14524        // contract narrowing.
14525        Dep::simple("caixa-teia", "^0.1").validate().unwrap();
14526        assert!(dep_with_features(&[]).validate().is_ok());
14527    }
14528
14529    #[test]
14530    fn validate_caracteristica_empty_fires_before_duplicate() {
14531        // Empty-first cascade: an entry with an empty feature *and*
14532        // duplicate entries surfaces the empty diagnostic first. The
14533        // empty-feature axis is the more-actionable defect since
14534        // `caracteristica: ""` is unambiguous; under duplicate-first
14535        // ordering the diagnostic could report the empty string from
14536        // either of two empty entries with no way to distinguish.
14537        // Mirrors the peer empty-before-duplicate ordering
14538        // discipline every per-entry shape + duplicate gate establishes
14539        // (`SupervisorSpec::validate`'s `EmptyChildName` arm before
14540        // `DuplicateChildCaixa`, `validate_membros`'s
14541        // `MembroCaixaEmpty` arm before `MembroDuplicate`).
14542        let d = dep_with_features(&["", "http", "http"]);
14543        assert!(matches!(
14544            d.validate().unwrap_err(),
14545            DepError::CaracteristicaEmpty { .. }
14546        ));
14547    }
14548
14549    #[test]
14550    fn validate_caracteristica_duplicate_first_collision_determinism() {
14551        // Three matching entries: the second occurrence surfaces the
14552        // diagnostic (the second is the first *collision* — the first
14553        // entry is the establishing one, not a duplicate). Mirrors
14554        // every peer first-collision posture
14555        // (`SupervisorError::DuplicateChildCaixa` reports the second
14556        // collision, `AplicacaoError::MembroDuplicate` reports the
14557        // second, `DepError::DuplicateNome` reports the second).
14558        // Pinning this so a future shortcut that flips to last-
14559        // collision (or non-deterministic) surfaces here.
14560        let d = dep_with_features(&["http", "http", "http"]);
14561        assert!(matches!(
14562            d.validate().unwrap_err(),
14563            DepError::CaracteristicaDuplicate { ref caracteristica, .. } if caracteristica == "http"
14564        ));
14565    }
14566
14567    #[test]
14568    fn validate_per_entry_shape_fires_before_caracteristicas() {
14569        // Per-entry shape precedence: a dep with a malformed `:nome`
14570        // (uppercase) AND duplicate `:caracteristicas` surfaces the
14571        // narrower `NomeInvalid` diagnostic first, not the set-gate
14572        // diagnostic. The `:nome` is the self-locating axis (every
14573        // diagnostic from the caracteristicas gate quotes the
14574        // offending dep's `:nome` to anchor the grep target —
14575        // surfacing the malformed name first keeps that anchor
14576        // valid). Same precedence shape every peer per-entry-shape
14577        // arm establishes against its peer set-gate
14578        // (`validate_deps_per_entry_validate_fires_before_duplicate_in_deps`
14579        // on the cross-entry `:nome` axis).
14580        let d = Dep {
14581            nome: "Caixa-Teia".into(), // uppercase — DNS-1123 violation
14582            versao: "^0.1".into(),
14583            fonte: None,
14584            opcional: false,
14585            caracteristicas: vec!["http".into(), "http".into()],
14586        };
14587        assert!(matches!(
14588            d.validate().unwrap_err(),
14589            DepError::NomeInvalid { .. }
14590        ));
14591    }
14592
14593    // ── per-entry :caracteristicas value-shape gate ──────────────────
14594    //
14595    // Until this gate landed `:caracteristicas` only refused the empty
14596    // string and cross-entry duplicates: a non-empty distinct but
14597    // structurally invalid feature name silently passed validate and the
14598    // failure surfaced at `cargo metadata` time as Cargo's
14599    // `restricted_names::validate_feature_name` parser rejection, far from
14600    // the source `caixa.lisp` with no field naming which `:deps` entry's
14601    // `:caracteristicas` carried the typo. The lifted predicate makes the
14602    // Cargo-feature-name-grammar intersection-floor a substrate-level
14603    // invariant at validate time. Same trajectory as the eight peer
14604    // value-shape predicates each typed surface downstream of a structured
14605    // grammar already follows.
14606
14607    #[test]
14608    fn validate_rejects_caracteristica_with_leading_plus() {
14609        // Fail-before-pass-after pin on the canonical Cargo
14610        // `+<feature>` activation-form-in-feature-name-slot footgun.
14611        // Cargo's `[dependencies.<dep>.features]` list grammar accepts
14612        // `+optional-feature` as an enablement of a previously-disabled
14613        // feature; pasting that activation form into `:caracteristicas`
14614        // (which names the feature itself) silently passed pre-gate and
14615        // failed at `cargo metadata` parse time.
14616        let d = dep_with_features(&["+http"]);
14617        let err = d.validate().unwrap_err();
14618        assert!(
14619            matches!(
14620                err,
14621                DepError::CaracteristicaInvalid { ref nome, ref caracteristica, .. }
14622                    if nome == "caixa-teia" && caracteristica == "+http"
14623            ),
14624            "expected CaracteristicaInvalid, got {err:?}"
14625        );
14626    }
14627
14628    #[test]
14629    fn validate_rejects_caracteristica_with_leading_hyphen() {
14630        // Fail-before-pass-after pin on the leading-hyphen footgun. `-`
14631        // is a legitimate continuation character (kebab-case feature
14632        // names like `runtime-tokio` pass) but Cargo rejects it at the
14633        // start; the structural defect — and its CLI-argument-injection
14634        // adjacency at any downstream Cargo subprocess invocation — is
14635        // closed at validate time, not at `cargo metadata` time.
14636        let d = dep_with_features(&["-json"]);
14637        let err = d.validate().unwrap_err();
14638        assert!(
14639            matches!(
14640                err,
14641                DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "-json"
14642            ),
14643            "expected CaracteristicaInvalid, got {err:?}"
14644        );
14645    }
14646
14647    #[test]
14648    fn validate_rejects_caracteristica_with_leading_dot() {
14649        // Fail-before-pass-after pin on the leading-dot footgun. `.` is
14650        // a legitimate continuation character (version-suffix shapes
14651        // like `feat.v2` pass) but the leading-dot form is the
14652        // canonical dotted-version-suffix-as-feature-name confusion.
14653        let d = dep_with_features(&[".feat"]);
14654        let err = d.validate().unwrap_err();
14655        assert!(matches!(
14656            err,
14657            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == ".feat"
14658        ));
14659    }
14660
14661    #[test]
14662    fn validate_rejects_caracteristica_with_whitespace() {
14663        // Fail-before-pass-after pin on the embedded-whitespace footgun:
14664        // a feature name with a space inside is structurally a multi-
14665        // token blob (the canonical paste-from-doc footgun, or an
14666        // accidental `"http server"` where the author meant
14667        // `"http-server"`).
14668        let d = dep_with_features(&["http feature"]);
14669        let err = d.validate().unwrap_err();
14670        assert!(matches!(
14671            err,
14672            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http feature"
14673        ));
14674    }
14675
14676    #[test]
14677    fn validate_rejects_caracteristica_with_comma() {
14678        // Fail-before-pass-after pin on the embedded-comma footgun:
14679        // the list-separator-belongs-to-the-list-grammar
14680        // miscomprehension where the author writes
14681        // `:caracteristicas ("http,json")` intending two features but
14682        // the `Vec<String>` field consumes the bare token as one entry.
14683        let d = dep_with_features(&["http,json"]);
14684        let err = d.validate().unwrap_err();
14685        assert!(matches!(
14686            err,
14687            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http,json"
14688        ));
14689    }
14690
14691    #[test]
14692    fn validate_rejects_caracteristica_with_slash() {
14693        // Fail-before-pass-after pin on the embedded-slash footgun:
14694        // Cargo's `dep/feat` namespaced-dep syntax applies inside
14695        // `[dependencies.<dep>.features]` list entries that already
14696        // name the parent dep (so the syntax says "enable feature
14697        // `feat` on a transitive dep `dep`"); `:caracteristicas` is
14698        // per-dep already (a sibling slot on the `Dep` itself), so the
14699        // segment separator within an entry must be `-`, `_`, `+`,
14700        // or `.`. The diagnostic remediation points at the canonical
14701        // Cargo namespaced-dep discipline.
14702        let d = dep_with_features(&["http/json"]);
14703        let err = d.validate().unwrap_err();
14704        assert!(matches!(
14705            err,
14706            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http/json"
14707        ));
14708    }
14709
14710    #[test]
14711    fn validate_rejects_caracteristica_with_non_ascii() {
14712        // Fail-before-pass-after pin on the un-percent-encoded non-ASCII
14713        // byte footgun: NFC-vs-NFD normalization across filesystems
14714        // silently rewrites the feature-key, breaking the lacre's
14715        // content-addressing invariant. Pinned at a canonical
14716        // smart-quote-paste shape (`café`) where the raw `é` byte is the
14717        // documented APFS round-trip break.
14718        let d = dep_with_features(&["caf\u{e9}"]);
14719        let err = d.validate().unwrap_err();
14720        assert!(matches!(
14721            err,
14722            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "caf\u{e9}"
14723        ));
14724    }
14725
14726    #[test]
14727    fn validate_rejects_caracteristica_with_control_character() {
14728        // Fail-before-pass-after pin on the embedded-control-character
14729        // footgun: a CR/LF or any 0x00..0x1F / 0x7F byte landing in a
14730        // feature name is the canonical paste-from-multiline-doc
14731        // footgun the predicate's reason wording specifically calls out.
14732        let d = dep_with_features(&["http\njson"]);
14733        let err = d.validate().unwrap_err();
14734        assert!(matches!(err, DepError::CaracteristicaInvalid { .. }));
14735    }
14736
14737    #[test]
14738    fn validate_accepts_canonical_caracteristicas_shapes() {
14739        // Positive control sweep: every canonical Cargo feature name
14740        // shape the pleme-io ecosystem uses must still pass. Mirrors
14741        // the substrate-side `cargo_feature_name_accepts_canonical_forms`
14742        // sweep — drift between either landing site and the predicate's
14743        // accepted set is a build error visible at this pair of tests,
14744        // not a per-renderer "this passed validate but failed at
14745        // cargo metadata time" surprise on the next acceptance.
14746        for s in [
14747            "http",
14748            "json",
14749            "derive",
14750            "serde_json",
14751            "runtime-tokio",
14752            "tokio.full",
14753            "v0.1",
14754            "http+json",
14755            "_internal",
14756            "__private",
14757            "default",
14758            "rt-multi-thread",
14759            "feat.v2",
14760        ] {
14761            let d = dep_with_features(&[s]);
14762            d.validate().unwrap_or_else(|e| {
14763                panic!("canonical Cargo feature name {s:?} must pass validate: {e:?}")
14764            });
14765        }
14766    }
14767
14768    #[test]
14769    fn validate_caracteristica_empty_fires_before_invalid() {
14770        // Cascade precedence pin: an entry list with both an empty
14771        // feature AND an invalid-shape feature surfaces the
14772        // `CaracteristicaEmpty` arm first (the empty value carries no
14773        // self-locating data — `caracteristica: ""` is the diagnostic
14774        // with no way to anchor a grep target — so closing the empty
14775        // axis first preserves the per-entry-shape diagnostic's
14776        // self-locating discipline). Same empty-first cascade every
14777        // peer per-entry shape gate establishes
14778        // (`SupervisorSpec::validate`'s `EmptyChildName` before
14779        // `ChildCaixaInvalid`, `validate_membros`'s `MembroCaixaEmpty`
14780        // before `MembroCaixaInvalid`).
14781        let d = dep_with_features(&["", "+http"]);
14782        assert!(matches!(
14783            d.validate().unwrap_err(),
14784            DepError::CaracteristicaEmpty { .. }
14785        ));
14786    }
14787
14788    #[test]
14789    fn validate_caracteristica_invalid_fires_before_duplicate() {
14790        // Per-entry-shape precedence pin: an entry list with the same
14791        // invalid feature shape declared twice surfaces the
14792        // `CaracteristicaInvalid` diagnostic on the first entry, not
14793        // the `CaracteristicaDuplicate` on the second collision. The
14794        // per-entry shape gate fires before the cross-entry set gate
14795        // — same precedence shape every peer two-arm-plus-set gate
14796        // establishes (`SupervisorSpec::validate`'s
14797        // `ChildCaixaInvalid` before `DuplicateChildCaixa`,
14798        // `validate_membros`'s `MembroCaixaInvalid` before
14799        // `MembroDuplicate`, `Dep::validate`'s `NomeInvalid` before
14800        // cross-list `DuplicateNome`).
14801        let d = dep_with_features(&["+http", "+http"]);
14802        assert!(matches!(
14803            d.validate().unwrap_err(),
14804            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "+http"
14805        ));
14806    }
14807
14808    #[test]
14809    fn validate_rejects_caracteristica_at_65_byte_boundary() {
14810        // Boundary pin on the 64-byte cap — both the boundary-accepting
14811        // case and the boundary-exceeding case in one place, so a
14812        // future cap shift surfaces both arms simultaneously, mirroring
14813        // the peer `cargo_feature_name_rejects_at_65_byte_boundary`
14814        // predicate-level pin at the dep-axis landing site.
14815        let max_ok = "a".repeat(64);
14816        dep_with_features(&[&max_ok])
14817            .validate()
14818            .unwrap_or_else(|e| panic!("64-byte feature name must pass: {e:?}"));
14819        let too_long = "a".repeat(65);
14820        let d = dep_with_features(&[&too_long]);
14821        assert!(matches!(
14822            d.validate().unwrap_err(),
14823            DepError::CaracteristicaInvalid { .. }
14824        ));
14825    }
14826
14827    // ── self-dep cross-slot gate ─────────────────────────────────────
14828
14829    #[test]
14830    fn validate_no_self_dep_rejects_self_in_deps() {
14831        // A caixa whose `:deps` lists its own `:nome` is a one-node
14832        // cycle in the lacre closure's dep-graph traversal — rejected,
14833        // naming the parent and the offending list tag.
14834        let deps = vec![
14835            Dep::simple("caixa-teia", "^0.1"),
14836            Dep::simple("orquestra", "^0.1"),
14837        ];
14838        let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
14839        assert!(
14840            matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS),
14841            "got {err:?}"
14842        );
14843    }
14844
14845    #[test]
14846    fn validate_no_self_dep_rejects_self_in_deps_dev() {
14847        // Same gate on the `:deps-dev` axis — neither dep list is a
14848        // second-class citizen on the self-edge invariant.
14849        let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
14850        let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
14851        assert!(
14852            matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
14853            "got {err:?}"
14854        );
14855    }
14856
14857    #[test]
14858    fn validate_no_self_dep_deps_fires_before_deps_dev() {
14859        // Walk order pin: a caixa that self-references on both lists
14860        // surfaces the `:deps` arm first — the load-bearing axis the
14861        // lacre closure resolves at every build. Mirrors the canonical
14862        // [`Caixa::validate_deps`] cascade (`:deps` → `:deps-dev`).
14863        let deps = vec![Dep::simple("orquestra", "^0.1")];
14864        let deps_dev = vec![Dep::simple("orquestra", "^0.2")];
14865        let err = validate_no_self_dep(&deps, &deps_dev, "orquestra").unwrap_err();
14866        assert!(
14867            matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS),
14868            "got {err:?}"
14869        );
14870    }
14871
14872    #[test]
14873    fn validate_no_self_dep_accepts_distinct_names() {
14874        // Positive control: every dep names a distinct caixa. The
14875        // canonical author surface — peer of
14876        // [`validate_no_self_supervision_accepts_distinct_children`].
14877        let deps = vec![
14878            Dep::simple("caixa-teia", "^0.1"),
14879            Dep::simple("caixa-arch", "^0.1"),
14880        ];
14881        let deps_dev = vec![Dep::simple("caixa-test", "^0.1")];
14882        validate_no_self_dep(&deps, &deps_dev, "orquestra").unwrap();
14883    }
14884
14885    #[test]
14886    fn validate_no_self_dep_empty_lists_pass() {
14887        // A caixa with no declared deps has nothing to self-reference —
14888        // the gate is vacuously satisfied. Peer of
14889        // [`validate_no_self_supervision_empty_children_is_ok`].
14890        validate_no_self_dep(&[], &[], "orquestra").unwrap();
14891    }
14892
14893    #[test]
14894    fn validate_no_self_dep_diagnostic_carries_offending_list_and_nome() {
14895        // Diagnostic-shape pin (peer with
14896        // [`validate_no_self_supervision`]'s diagnostic): the error's
14897        // Display surfaces both the offending list tag and the
14898        // parent's `:nome` verbatim, so the author can grep their
14899        // caixa.lisp for the offending block in one edit. Names
14900        // `:bibliotecas` / `:exe` / `:servicos` as the corrective
14901        // surface — every legitimate "I want to use code from this
14902        // caixa" intent routes through one of those three slots.
14903        let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
14904        let rendered = validate_no_self_dep(&[], &deps_dev, "orquestra")
14905            .unwrap_err()
14906            .to_string();
14907        assert!(
14908            rendered.contains(crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
14909            "diagnostic must name the offending list tag: {rendered}",
14910        );
14911        assert!(
14912            rendered.contains("orquestra"),
14913            "diagnostic must quote the parent caixa name: {rendered}",
14914        );
14915        assert!(
14916            rendered.contains(":bibliotecas"),
14917            "diagnostic must point at the corrective code-surface slot: {rendered}",
14918        );
14919    }
14920
14921    #[test]
14922    fn validate_no_self_dep_accepts_coincidental_substring_match() {
14923        // Identity is exact-string equality, not substring — a dep
14924        // named `"orquestra-helper"` is a distinct caixa even when the
14925        // parent is `"orquestra"`. Pin the exact-match discipline so a
14926        // future relaxation that uses `contains` surfaces here, peer
14927        // with the supervision-tree and Aplicacao-membership gates
14928        // which all use exact-string equality on the typed identity.
14929        let deps = vec![Dep::simple("orquestra-helper", "^0.1")];
14930        validate_no_self_dep(&deps, &[], "orquestra").unwrap();
14931    }
14932
14933    // ── drift-detection: DEP_AUTHOR_KEY_{DEPS,DEPS_DEV} pin ─────────────
14934
14935    #[test]
14936    fn dep_author_key_consts_pin_canonical_kebab_case_labels() {
14937        // Scalar-value pin: the two author-facing kebab-case labels the
14938        // `(defcaixa … :deps ((…)) :deps-dev ((…)))` surface admits on
14939        // the two-list dep-graph slot axis, one arm per typed slot.
14940        // Mirrors the peer scalar-value pin the sibling
14941        // [`crate::M2_AUTHOR_KEY_LIMITS`] /
14942        // [`crate::M2_AUTHOR_KEY_BEHAVIOR`] /
14943        // [`crate::M2_AUTHOR_KEY_UPGRADE_FROM`] (f49c8b0) M2 top-level
14944        // author-labels, [`crate::M3_AUTHOR_KEY_MEMBROS`] etc.
14945        // (882f498) M3 top-level author-labels, and
14946        // [`crate::SUPERVISOR_AUTHOR_KEY_ESTRATEGIA`] etc. (be40492)
14947        // Supervisor top-level author-labels carry, so every kind-scoped
14948        // typed-slot-family axis routes through one canonical per-arm
14949        // declaration.
14950        //
14951        // A future rebrand (`:deps` → `:dependencies` matching Cargo's
14952        // verbatim key, `:deps-dev` → `:dev-dependencies` matching the
14953        // same, `:deps` / `:deps-dev` → `:runtime-deps` / `:dev-deps`
14954        // for symmetry) lands as an edit to exactly one const, and
14955        // every consumer that reaches for the label picks it up at
14956        // build time rather than at runtime as a downstream mismatch on
14957        // a `DepError::DuplicateNome { list: … }` diagnostic far from
14958        // the rename's commit.
14959        assert_eq!(crate::render::DEP_AUTHOR_KEY_DEPS, ":deps");
14960        assert_eq!(crate::render::DEP_AUTHOR_KEY_DEPS_DEV, ":deps-dev");
14961    }
14962
14963    #[test]
14964    fn dep_author_key_consts_are_pairwise_distinct() {
14965        // Distinct-labels pin: the two `:deps` / `:deps-dev` labels
14966        // must not collapse onto one byte-string. A future copy-paste
14967        // slip that renamed both consts to the same value (or a rebrand
14968        // that dropped the `-dev` suffix from one but not the other)
14969        // would leave every `DepError::DuplicateNome { list: … }`
14970        // diagnostic naming an unattributable list — the linter would
14971        // route the author to the wrong caixa.lisp block, or the
14972        // cross-list precedence gate
14973        // (`validate_deps_duplicate_in_deps_fires_before_duplicate_in_deps_dev`)
14974        // would surface a `:deps`-tagged diagnostic on a `:deps-dev`
14975        // duplicate. Peer of the sibling
14976        // `m2_author_key_consts_are_pairwise_distinct`-shape gates the
14977        // other top-level kind-scoped slot-family axes carry
14978        // (implicitly held by their different byte-values today).
14979        assert_ne!(
14980            crate::render::DEP_AUTHOR_KEY_DEPS,
14981            crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
14982            "DEP_AUTHOR_KEY_{{DEPS,DEPS_DEV}} consts must be pairwise-distinct \
14983             so a `DepError::DuplicateNome {{ list: … }}` diagnostic \
14984             self-locates the offending block in the author's caixa.lisp",
14985        );
14986    }
14987
14988    #[test]
14989    fn validate_no_self_dep_routes_through_lifted_dep_author_key_consts() {
14990        // Production-through-const pin: the two per-arm list tags
14991        // [`validate_no_self_dep`] threads onto the `list:` field of a
14992        // returned [`DepError::DepIsSelf`] route through the lifted
14993        // [`crate::DEP_AUTHOR_KEY_DEPS`] /
14994        // [`crate::DEP_AUTHOR_KEY_DEPS_DEV`] consts. A future drift at
14995        // the walker (a rename that reaches one arm but not the const,
14996        // or vice versa) surfaces here at build time rather than at
14997        // runtime as a `feira lint` diagnostic naming the wrong list
14998        // tag. Mirror of the peer
14999        // [`crate::Caixa::declared_servico_slots`] production tagger
15000        // pin (f49c8b0) on the sibling M2 top-level slot axis, extended
15001        // onto the two-list dep-graph gate.
15002        let deps = vec![Dep::simple("orquestra", "^0.1")];
15003        let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
15004        let DepError::DepIsSelf { list, .. } = err else {
15005            panic!("expected DepIsSelf from :deps walk");
15006        };
15007        assert_eq!(list, crate::render::DEP_AUTHOR_KEY_DEPS);
15008
15009        let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
15010        let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
15011        let DepError::DepIsSelf { list, .. } = err else {
15012            panic!("expected DepIsSelf from :deps-dev walk");
15013        };
15014        assert_eq!(list, crate::render::DEP_AUTHOR_KEY_DEPS_DEV);
15015    }
15016
15017    // ── Dep::nome accessor pins ───────────────────────────────────────
15018    //
15019    // Three coherence pins on the lifted `Dep::nome` accessor: byte-equal
15020    // projection over the plain-shorthand / explicit-git / explicit-path
15021    // fixture triad the [`Dep`] docstring lists (so the accessor's
15022    // accept-set is exercised across every author-surface `:fonte`
15023    // shape); by-borrow pointer identity so the projection stays
15024    // zero-copy at every consumer site; and validate-composition through
15025    // the [`validate_no_self_dep`] cross-slot gate reading its
15026    // parent-name equality check through the lifted accessor rather than
15027    // the raw field.
15028
15029    #[test]
15030    fn dep_nome_returns_declared_nome_across_fonte_shapes() {
15031        // Plain-shorthand form (`:fonte None`).
15032        assert_eq!(Dep::simple("caixa-teia", "^0.1").nome(), "caixa-teia");
15033        // Explicit git-source form with a tag pin — same accessor path.
15034        assert_eq!(
15035            Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0").nome(),
15036            "caixa-teia",
15037        );
15038        // Explicit path-source form.
15039        assert_eq!(
15040            Dep {
15041                nome: "caixa-teia".to_string(),
15042                versao: "0.1.0".to_string(),
15043                fonte: Some(DepSource::Path {
15044                    caminho: "../caixa-teia".to_string(),
15045                }),
15046                opcional: false,
15047                caracteristicas: Vec::new(),
15048            }
15049            .nome(),
15050            "caixa-teia",
15051        );
15052        // The empty-string `:nome` sentinel (which [`Dep::validate`]
15053        // refuses through the [`DepError::NomeEmpty`] arm) still round-
15054        // trips as an empty `&str` through the accessor — the accessor is
15055        // a projection, not a gate; the gate is [`Dep::validate`].
15056        assert_eq!(Dep::simple("", "^0.1").nome(), "");
15057    }
15058
15059    #[test]
15060    fn dep_nome_is_by_borrow_pointer_identity() {
15061        // Zero-copy pin: the accessor must borrow into the field's own
15062        // storage, not clone. If a future rewrite regresses to
15063        // `self.nome.clone().leak()` or an owned-buffer shape, the two
15064        // pointers diverge and this pin fails at build time.
15065        let d = Dep::simple("caixa-teia", "^0.1");
15066        assert!(std::ptr::eq(d.nome().as_ptr(), d.nome.as_ptr()));
15067    }
15068
15069    // ── Dep::versao_requirement accessor pins ─────────────────────────
15070    //
15071    // Three coherence pins on the lifted `Dep::versao_requirement`
15072    // accessor: byte-equal projection over the plain-shorthand /
15073    // explicit-git / explicit-path fixture triad the [`Dep`] docstring
15074    // lists plus the empty-sentinel that round-trips as `""` (the accessor
15075    // is a projection, not a gate; the gate is [`Dep::validate`]); by-
15076    // borrow pointer identity so the projection stays zero-copy at every
15077    // consumer site; and validate-composition through the
15078    // [`crate::render::require_valid_versao_requirement`] cascade reading
15079    // its requirement-shape check through the lifted accessor rather than
15080    // the raw field.
15081    #[test]
15082    fn dep_versao_requirement_returns_declared_versao_across_fonte_shapes() {
15083        // Plain-shorthand form (`:fonte None`).
15084        assert_eq!(
15085            Dep::simple("caixa-teia", "^0.1").versao_requirement(),
15086            "^0.1",
15087        );
15088        // Explicit git-source form with a tag pin — same accessor path.
15089        assert_eq!(
15090            Dep::git(
15091                "caixa-teia",
15092                "~0.1.2",
15093                "github:pleme-io/caixa-teia",
15094                "v0.1.0"
15095            )
15096            .versao_requirement(),
15097            "~0.1.2",
15098        );
15099        // Explicit path-source form.
15100        assert_eq!(
15101            Dep {
15102                nome: "caixa-teia".to_string(),
15103                versao: "0.1.0".to_string(),
15104                fonte: Some(DepSource::Path {
15105                    caminho: "../caixa-teia".to_string(),
15106                }),
15107                opcional: false,
15108                caracteristicas: Vec::new(),
15109            }
15110            .versao_requirement(),
15111            "0.1.0",
15112        );
15113        // The wildcard requirement (`"*"`) — the shorthand
15114        // `parse_requirement` accepts as `VersionReq::STAR` — round-trips
15115        // verbatim through the accessor as `"*"`, same byte-shape the
15116        // author wrote.
15117        assert_eq!(Dep::simple("caixa-teia", "*").versao_requirement(), "*");
15118        // The empty-string `:versao` sentinel (which [`Dep::validate`]
15119        // refuses through the [`DepError::VersaoEmpty`] arm) still round-
15120        // trips as an empty `&str` through the accessor — the accessor is
15121        // a projection, not a gate; the gate is [`Dep::validate`]. Peer
15122        // of the sibling [`Dep::nome`] empty-sentinel round-trip pin.
15123        assert_eq!(Dep::simple("caixa-teia", "").versao_requirement(), "");
15124    }
15125
15126    #[test]
15127    fn dep_versao_requirement_is_by_borrow_pointer_identity() {
15128        // Zero-copy pin: the accessor must borrow into the field's own
15129        // storage, not clone. If a future rewrite regresses to
15130        // `self.versao.clone().leak()` or an owned-buffer shape, the two
15131        // pointers diverge and this pin fails at build time. Peer of the
15132        // sibling [`Dep::nome`] pointer-identity pin — same by-borrow
15133        // discipline extended onto the requirement-carrying axis.
15134        let d = Dep::simple("caixa-teia", "^0.1");
15135        assert!(std::ptr::eq(
15136            d.versao_requirement().as_ptr(),
15137            d.versao.as_ptr(),
15138        ));
15139    }
15140
15141    #[test]
15142    fn dep_validate_reads_requirement_through_accessor() {
15143        // Composition pin: the [`Dep::validate`]
15144        // [`crate::render::require_valid_versao_requirement`] cascade
15145        // consumes the requirement string through the lifted accessor —
15146        // both the requirement-gate input and the
15147        // [`DepError::VersaoInvalid`] error-body carrier route through
15148        // `self.versao_requirement()`. A valid requirement passes
15149        // (positive control); a malformed-but-non-empty requirement fails
15150        // and the diagnostic quotes the offending byte-string verbatim
15151        // (same shape the accessor projects), so a future regression that
15152        // detoured the requirement carrier through a different byte-
15153        // string (say the parsed `VersionReq`'s `Display`, or a
15154        // normalized rewrite) would surface here at build time. The
15155        // empty-`:versao` arm fires the [`DepError::VersaoEmpty`] variant
15156        // ahead of the parse arm, pinning the empty-first cascade the
15157        // accessor's `""` sentinel round-trip acknowledges.
15158        Dep::simple("caixa-teia", "^0.1").validate().unwrap();
15159        let err = Dep::simple("caixa-teia", "v0.1").validate().unwrap_err();
15160        assert!(
15161            matches!(
15162                &err,
15163                DepError::VersaoInvalid {
15164                    nome,
15165                    versao,
15166                    ..
15167                } if nome == "caixa-teia" && versao == "v0.1",
15168            ),
15169            "expected VersaoInvalid quoting the accessor-projected requirement, got {err:?}",
15170        );
15171        let err = Dep::simple("caixa-teia", "").validate().unwrap_err();
15172        assert!(
15173            matches!(
15174                &err,
15175                DepError::VersaoEmpty { nome } if nome == "caixa-teia",
15176            ),
15177            "expected VersaoEmpty from the empty-first arm, got {err:?}",
15178        );
15179    }
15180
15181    // ── Dep::fonte accessor pins ──────────────────────────────────────
15182    //
15183    // Three coherence pins on the lifted `Dep::fonte` accessor: byte-
15184    // equal projection over the plain-shorthand (`:fonte None`) /
15185    // explicit-git-tag / explicit-path fixture triad the [`Dep`]
15186    // docstring lists (so the accessor's accept-set is exercised across
15187    // every author-surface `:fonte` shape and both `DepSource` variants);
15188    // pointer identity so the borrowed reference points into the field's
15189    // own `Option<DepSource>` storage (not a cloned side-buffer); and
15190    // validate-composition through the [`Dep::validate`] gate reading
15191    // its per-`:fonte` [`DepSource::validate`] delegation through the
15192    // lifted accessor rather than the raw `if let Some(ref fonte) =
15193    // self.fonte` bracket.
15194
15195    #[test]
15196    fn dep_fonte_returns_declared_source_across_shapes() {
15197        // Plain-shorthand form — `:fonte` omitted, accessor projects
15198        // the `None` partition the resolver-side default-fill treats
15199        // as "resolve through `github:<default-org>/<nome>`".
15200        assert!(Dep::simple("caixa-teia", "^0.1").fonte().is_none());
15201        // Explicit git-source form with a tag pin — same accessor path.
15202        let git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
15203        match git.fonte() {
15204            Some(DepSource::Git {
15205                repo,
15206                tag,
15207                rev,
15208                branch,
15209            }) => {
15210                assert_eq!(repo, "github:pleme-io/caixa-teia");
15211                assert_eq!(tag.as_deref(), Some("v0.1.0"));
15212                assert!(rev.is_none());
15213                assert!(branch.is_none());
15214            }
15215            other => panic!("expected explicit git :fonte, got {other:?}"),
15216        }
15217        // Explicit path-source form — the dev-only local-filesystem
15218        // arm the [`Dep`] docstring's third fixture carries.
15219        let path = Dep {
15220            nome: "caixa-teia".to_string(),
15221            versao: "0.1.0".to_string(),
15222            fonte: Some(DepSource::Path {
15223                caminho: "../caixa-teia".to_string(),
15224            }),
15225            opcional: false,
15226            caracteristicas: Vec::new(),
15227        };
15228        match path.fonte() {
15229            Some(DepSource::Path { caminho }) => {
15230                assert_eq!(caminho, "../caixa-teia");
15231            }
15232            other => panic!("expected explicit path :fonte, got {other:?}"),
15233        }
15234    }
15235
15236    #[test]
15237    fn dep_fonte_is_by_borrow_pointer_identity() {
15238        // Zero-copy pin: the accessor must borrow into the field's own
15239        // `Option<DepSource>` storage, not clone into a side buffer. If
15240        // a future rewrite regresses to `self.fonte.clone()` or an
15241        // owned-buffer shape, the two pointers diverge and this pin
15242        // fails at build time. Peer of the sibling per-`Dep` [`Dep::nome`]
15243        // (eba2cde) / [`Dep::versao_requirement`] (05529b1) pointer-
15244        // identity pins — same by-borrow discipline extended onto the
15245        // outer-`Dep` `Option<&Composite>` composite-reference axis.
15246        let d = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
15247        let accessed = d.fonte().expect("git :fonte present") as *const DepSource;
15248        let raw = d.fonte.as_ref().expect("git :fonte present") as *const DepSource;
15249        assert!(std::ptr::eq(accessed, raw));
15250    }
15251
15252    #[test]
15253    fn dep_validate_reads_fonte_through_accessor() {
15254        // Composition pin: [`Dep::validate`]'s per-`:fonte`
15255        // [`DepSource::validate`] delegation consumes the typed slot
15256        // through the lifted accessor — an author-omitted `:fonte`
15257        // still passes the outer gate (positive control), an explicit
15258        // well-formed git source with exactly one pin passes, and a
15259        // malformed git source (empty `:repo`) surfaces the
15260        // [`DepError::FonteRepoEmpty`] variant quoting the offending
15261        // dep's `:nome` verbatim so a future regression that detoured
15262        // the `:fonte` delegation through a different path (say a
15263        // per-scope override projector) would surface here at build
15264        // time. Peer of the sibling
15265        // `dep_validate_reads_requirement_through_accessor` composition
15266        // pin on the `:versao` axis.
15267        // Positive control 1: no `:fonte` at all.
15268        Dep::simple("caixa-teia", "^0.1").validate().unwrap();
15269        // Positive control 2: well-formed git source.
15270        Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0")
15271            .validate()
15272            .unwrap();
15273        // Negative control: empty `:repo` — the accessor still returns
15274        // `Some(&DepSource::Git { repo: "", … })` and the delegated
15275        // `DepSource::validate` gate raises the typed carrier.
15276        let bad = Dep {
15277            nome: "caixa-teia".to_string(),
15278            versao: "^0.1".to_string(),
15279            fonte: Some(DepSource::Git {
15280                repo: String::new(),
15281                tag: Some("v0.1.0".to_string()),
15282                rev: None,
15283                branch: None,
15284            }),
15285            opcional: false,
15286            caracteristicas: Vec::new(),
15287        };
15288        let err = bad.validate().unwrap_err();
15289        assert!(
15290            matches!(
15291                &err,
15292                DepError::FonteRepoEmpty { nome } if nome == "caixa-teia",
15293            ),
15294            "expected FonteRepoEmpty from the accessor-routed :fonte gate, got {err:?}",
15295        );
15296    }
15297
15298    #[test]
15299    fn validate_no_self_dep_reads_parent_equality_through_accessor() {
15300        // Composition pin: the cross-slot [`validate_no_self_dep`] gate
15301        // rejects a `:deps` entry whose `:nome` equals the parent caixa's
15302        // own `:nome` through the lifted accessor rather than the raw
15303        // field. Fails-before-passes-after: with the accessor lifted the
15304        // gate reads its equality check through `dep.nome() ==
15305        // parent_nome` on both the `:deps` and `:deps-dev` traversals, so
15306        // the diagnostic still names the offending list tag as expected.
15307        let deps = vec![Dep::simple("orquestra", "^0.1")];
15308        let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
15309        assert!(matches!(
15310            err,
15311            DepError::DepIsSelf {
15312                ref nome,
15313                list,
15314            } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS,
15315        ));
15316        let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
15317        let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
15318        assert!(matches!(
15319            err,
15320            DepError::DepIsSelf {
15321                ref nome,
15322                list,
15323            } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
15324        ));
15325        // A non-matching `:nome` passes through the accessor gate.
15326        let deps = vec![Dep::simple("caixa-teia", "^0.1")];
15327        validate_no_self_dep(&deps, &[], "orquestra").unwrap();
15328    }
15329
15330    // ── Dep::caracteristicas accessor pins ────────────────────────────
15331    //
15332    // Three coherence pins on the lifted `Dep::caracteristicas` accessor:
15333    // byte-equal projection over the default-empty / single-entry /
15334    // multi-entry fixture triad (so the accessor's accept-set is
15335    // exercised across every author-surface `:caracteristicas` shape,
15336    // matching the peer sibling family's fixture-triad discipline); by-
15337    // borrow pointer identity so the projection stays zero-copy at every
15338    // consumer site; and validate-composition through the
15339    // [`Dep::validate_caracteristicas`] gate reading its per-entry
15340    // linear walk through the lifted accessor rather than the raw
15341    // `for c in &self.caracteristicas` bracket.
15342
15343    #[test]
15344    fn dep_caracteristicas_returns_declared_features_across_shapes() {
15345        // Default-empty form — the [`Dep::simple`] constructor's
15346        // `Vec::new()` fill; the accessor projects the empty slice
15347        // verbatim (no `None` collapse).
15348        assert!(
15349            Dep::simple("caixa-teia", "^0.1")
15350                .caracteristicas()
15351                .is_empty(),
15352        );
15353        // Single-entry form — the canonical Cargo-shaped one-feature
15354        // enable ([`crate::render::is_cargo_feature_name`] accepts the
15355        // `"http"` byte-string as a valid feature name).
15356        let one = Dep {
15357            nome: "caixa-teia".to_string(),
15358            versao: "^0.1".to_string(),
15359            fonte: None,
15360            opcional: false,
15361            caracteristicas: vec!["http".to_string()],
15362        };
15363        assert_eq!(one.caracteristicas(), &["http".to_string()]);
15364        // Multi-entry form — the substrate's set-shaped multi-feature
15365        // enable, exercising the accessor over a length-two slice with
15366        // no duplicate collapse.
15367        let two = Dep {
15368            nome: "caixa-teia".to_string(),
15369            versao: "^0.1".to_string(),
15370            fonte: None,
15371            opcional: false,
15372            caracteristicas: vec!["http".to_string(), "json".to_string()],
15373        };
15374        assert_eq!(
15375            two.caracteristicas(),
15376            &["http".to_string(), "json".to_string()],
15377        );
15378    }
15379
15380    #[test]
15381    fn dep_caracteristicas_is_by_borrow_pointer_identity() {
15382        // Zero-copy pin: the accessor must borrow into the field's own
15383        // `Vec<String>` storage, not clone into a side buffer. If a
15384        // future rewrite regresses to `self.caracteristicas.clone()` or
15385        // an owned-buffer shape, the two pointers diverge and this pin
15386        // fails at build time. Peer of the sibling per-`Dep`
15387        // [`Dep::nome`] (eba2cde) / [`Dep::versao_requirement`] (05529b1)
15388        // / [`Dep::fonte`] (d65d1bf) pointer-identity pins — same by-
15389        // borrow discipline extended onto the outer-`Dep` `&[String]`
15390        // slice-projection axis.
15391        let d = Dep {
15392            nome: "caixa-teia".to_string(),
15393            versao: "^0.1".to_string(),
15394            fonte: None,
15395            opcional: false,
15396            caracteristicas: vec!["http".to_string(), "json".to_string()],
15397        };
15398        assert!(std::ptr::eq(
15399            d.caracteristicas().as_ptr(),
15400            d.caracteristicas.as_ptr(),
15401        ));
15402    }
15403
15404    #[test]
15405    fn dep_validate_reads_caracteristicas_through_accessor() {
15406        // Composition pin: [`Dep::validate_caracteristicas`]'s per-entry
15407        // linear walk consumes the feature-toggle list through the
15408        // lifted accessor — a well-formed `:caracteristicas` set passes
15409        // (positive control), an empty-string entry surfaces the
15410        // [`DepError::CaracteristicaEmpty`] variant quoting the offending
15411        // `Dep::nome`, and a within-list duplicate surfaces the
15412        // [`DepError::CaracteristicaDuplicate`] variant so a future
15413        // regression that detoured the walk through a different byte-
15414        // string list (say a per-scope override projector) would surface
15415        // here at build time. Peer of the sibling
15416        // `dep_validate_reads_fonte_through_accessor` /
15417        // `dep_validate_reads_requirement_through_accessor` composition
15418        // pins on the `:fonte` / `:versao` axes.
15419        // Positive control: two distinct well-formed feature names pass.
15420        Dep {
15421            nome: "caixa-teia".to_string(),
15422            versao: "^0.1".to_string(),
15423            fonte: None,
15424            opcional: false,
15425            caracteristicas: vec!["http".to_string(), "json".to_string()],
15426        }
15427        .validate()
15428        .unwrap();
15429        // Negative control 1: empty-string feature-name entry — the
15430        // accessor still returns `&[""]` and the walk raises the typed
15431        // empty-first carrier.
15432        let err = Dep {
15433            nome: "caixa-teia".to_string(),
15434            versao: "^0.1".to_string(),
15435            fonte: None,
15436            opcional: false,
15437            caracteristicas: vec![String::new()],
15438        }
15439        .validate()
15440        .unwrap_err();
15441        assert!(
15442            matches!(
15443                &err,
15444                DepError::CaracteristicaEmpty { nome } if nome == "caixa-teia",
15445            ),
15446            "expected CaracteristicaEmpty from the accessor-routed walk, got {err:?}",
15447        );
15448        // Negative control 2: within-list duplicate — the accessor's
15449        // slice view carries both entries, and the walk's dedup arm
15450        // raises the typed duplicate carrier quoting the offending
15451        // feature name verbatim.
15452        let err = Dep {
15453            nome: "caixa-teia".to_string(),
15454            versao: "^0.1".to_string(),
15455            fonte: None,
15456            opcional: false,
15457            caracteristicas: vec!["http".to_string(), "http".to_string()],
15458        }
15459        .validate()
15460        .unwrap_err();
15461        assert!(
15462            matches!(
15463                &err,
15464                DepError::CaracteristicaDuplicate {
15465                    nome,
15466                    caracteristica,
15467                } if nome == "caixa-teia" && caracteristica == "http",
15468            ),
15469            "expected CaracteristicaDuplicate from the accessor-routed dedup, got {err:?}",
15470        );
15471    }
15472
15473    // ── Dep::opcional accessor pins ───────────────────────────────────
15474    //
15475    // Two coherence pins on the lifted `Dep::opcional` accessor: byte-
15476    // equal projection over the default-`false` / explicit-`true`
15477    // fixture pair across the plain-shorthand (`:fonte None`) / explicit-
15478    // git-tag / explicit-path fixture triad the [`Dep`] docstring lists,
15479    // exercising the accessor's accept-set over every author-surface
15480    // `:fonte` shape × every author-surface `:opcional` shape; and by-
15481    // `Copy` idempotency so the projection stays value-return (no
15482    // silent detour to a fresh `&bool` borrow that would introduce a
15483    // lifetime on the return type the plain-`Copy`-scalar axis's `bool`
15484    // shape elides). No composition pin — `:opcional` does not
15485    // participate in [`Dep::validate`] (an opcional dep with any bool
15486    // value is validate-accepted; the missing-source arm is a resolver-
15487    // side runtime dispatch, not a build-time refusal), so the axis
15488    // reduces to the value-shape + `Copy` pin pair the peer
15489    // [`crate::Caixa::max_restarts`] / [`crate::Caixa::estrategia`]
15490    // outer-`Option<Copy>` accessor pins already carry.
15491
15492    #[test]
15493    fn dep_opcional_returns_declared_opcional_across_fonte_shapes() {
15494        // Default-`false` form via the [`Dep::simple`] constructor —
15495        // the accessor projects the `false` bit the default-fill sets.
15496        assert!(!Dep::simple("caixa-teia", "^0.1").opcional());
15497        // Default-`false` form via the [`Dep::git`] constructor — same
15498        // default fill; the accessor projects `false` regardless of the
15499        // `:fonte` arm.
15500        assert!(!Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0").opcional(),);
15501        // Explicit-`true` form × plain-shorthand `:fonte` — the
15502        // canonical author-surface "this dep may be missing" shape.
15503        let plain_true = Dep {
15504            nome: "caixa-teia".to_string(),
15505            versao: "^0.1".to_string(),
15506            fonte: None,
15507            opcional: true,
15508            caracteristicas: Vec::new(),
15509        };
15510        assert!(plain_true.opcional());
15511        // Explicit-`true` form × explicit git-source — the accessor
15512        // projects the bit verbatim regardless of the `:fonte` arm.
15513        let git_true = Dep {
15514            nome: "caixa-teia".to_string(),
15515            versao: "^0.1".to_string(),
15516            fonte: Some(DepSource::Git {
15517                repo: "github:pleme-io/caixa-teia".to_string(),
15518                tag: Some("v0.1.0".to_string()),
15519                rev: None,
15520                branch: None,
15521            }),
15522            opcional: true,
15523            caracteristicas: Vec::new(),
15524        };
15525        assert!(git_true.opcional());
15526        // Explicit-`true` form × explicit path-source — the dev-only
15527        // local-filesystem arm the [`Dep`] docstring's third fixture
15528        // carries.
15529        let path_true = Dep {
15530            nome: "caixa-teia".to_string(),
15531            versao: "0.1.0".to_string(),
15532            fonte: Some(DepSource::Path {
15533                caminho: "../caixa-teia".to_string(),
15534            }),
15535            opcional: true,
15536            caracteristicas: Vec::new(),
15537        };
15538        assert!(path_true.opcional());
15539    }
15540
15541    #[test]
15542    fn dep_opcional_projects_bool_by_copy() {
15543        // The by-`Copy` pin: [`Dep::opcional`] returns `bool` by value
15544        // (`bool: Copy`) — the accessor does not borrow `&self` past
15545        // the call (no lifetime on the return type), and calling the
15546        // accessor twice on the same [`Dep`] must yield discriminant-
15547        // equal values (idempotent, no side effects on `&self`). Peer
15548        // of the sibling outer-`Caixa` `Option<Copy>` by-`Copy`
15549        // `max_restarts_projects_option_by_copy` (eba5211) /
15550        // `estrategia_projects_option_by_copy` (ed04d3c) pins on the
15551        // outer-`Caixa` altitude — extended here to the outer-`Dep`
15552        // altitude's plain-`Copy` `bool` axis. The `Copy` discipline
15553        // replaces the pointer-equality claim the sibling per-`Dep`
15554        // by-borrow pins (`dep_nome_is_by_borrow_pointer_identity`
15555        // eba2cde, `dep_versao_requirement_is_by_borrow_pointer_identity`
15556        // 05529b1, `dep_fonte_is_by_borrow_pointer_identity` d65d1bf,
15557        // `dep_caracteristicas_is_by_borrow_pointer_identity` 9197944)
15558        // carry (a fresh `Copy` of a `Copy` discriminant is definitionally
15559        // the same discriminant, so the axis reduces to discriminant
15560        // equality).
15561        //
15562        // Pins against a future silent detour that returned a fresh
15563        // `&bool` reference (which would type-check but silently
15564        // introduce a borrow of `&self` past the call, collapsing the
15565        // load-bearing "no lifetime on the return type" `Copy`
15566        // projection the plain-`Copy`-scalar axis's `bool` shape
15567        // carries) or a stale-read side effect that flipped the outer
15568        // discriminant on successive calls.
15569        for opcional in [false, true] {
15570            let d = Dep {
15571                nome: "caixa-teia".to_string(),
15572                versao: "^0.1".to_string(),
15573                fonte: None,
15574                opcional,
15575                caracteristicas: Vec::new(),
15576            };
15577            let first = d.opcional();
15578            let second = d.opcional();
15579            assert_eq!(
15580                first, second,
15581                "Dep::opcional must be idempotent — two successive calls \
15582                 on the same &self must return the same bool",
15583            );
15584            assert_eq!(
15585                first, opcional,
15586                "Dep::opcional must return :opcional verbatim by Copy — \
15587                 got {first}, expected {opcional}",
15588            );
15589            assert_eq!(
15590                d.opcional(),
15591                d.opcional,
15592                "Dep::opcional accessor and self.opcional field access \
15593                 must byte-equal — a bit-flip drift would silently split \
15594                 the paired resolver-side drop-vs-error dispatch from \
15595                 the storage-side default-fill the [`Dep::simple`] / \
15596                 [`Dep::git`] constructor pair carries",
15597            );
15598        }
15599    }
15600
15601    // ── DepSource::sole_pin — sole-set git-pin accessor ─────────────────
15602
15603    #[test]
15604    fn sole_pin_returns_none_for_path_source() {
15605        // A path source carries no git-ref, so `sole_pin()` returns
15606        // `None` structurally — the sibling arm every git-fetching
15607        // consumer partitions off before reaching for a git-ref. Pins
15608        // the Path-arm branch of the accessor against a future silent
15609        // detour that treats a `Self::Path` as an unpinned-git source
15610        // and returns the wrong "no pin" signal (e.g. the empty string,
15611        // or a hard-coded `Some("HEAD")` matching the caixa-crd
15612        // path-arm `git_ref` fill).
15613        let s = DepSource::Path {
15614            caminho: "../local-caixa".to_string(),
15615        };
15616        assert_eq!(s.sole_pin(), None);
15617    }
15618
15619    #[test]
15620    fn sole_pin_returns_none_for_unpinned_git_source() {
15621        // The [`DepSource::default_github`] shorthand shape carries no
15622        // pin — every `tag`/`rev`/`branch` is `None`, and `sole_pin()`
15623        // returns `None`. This is the shape caixa-resolver's `fetch_dep`
15624        // materializes when the author omits `:fonte` entirely, then
15625        // hands to `fetch_git` which raises `ResolveError::MissingPin`
15626        // on the `None` arm — the accessor's return matches the arm
15627        // the resolver's diagnostic keys off.
15628        let s = DepSource::default_github("pleme-io", "caixa-teia");
15629        assert_eq!(s.sole_pin(), None);
15630    }
15631
15632    #[test]
15633    fn sole_pin_returns_rev_when_only_rev_is_set() {
15634        let s = DepSource::Git {
15635            repo: "github:o/x".into(),
15636            tag: None,
15637            rev: Some("deadbeefcafebabe1234567890abcdef12345678".into()),
15638            branch: None,
15639        };
15640        assert_eq!(
15641            s.sole_pin(),
15642            Some("deadbeefcafebabe1234567890abcdef12345678")
15643        );
15644    }
15645
15646    #[test]
15647    fn sole_pin_returns_tag_when_only_tag_is_set() {
15648        let s = DepSource::Git {
15649            repo: "github:o/x".into(),
15650            tag: Some("v0.1.0".into()),
15651            rev: None,
15652            branch: None,
15653        };
15654        assert_eq!(s.sole_pin(), Some("v0.1.0"));
15655    }
15656
15657    #[test]
15658    fn sole_pin_returns_branch_when_only_branch_is_set() {
15659        let s = DepSource::Git {
15660            repo: "github:o/x".into(),
15661            tag: None,
15662            rev: None,
15663            branch: Some("main".into()),
15664        };
15665        assert_eq!(s.sole_pin(), Some("main"));
15666    }
15667
15668    #[test]
15669    fn sole_pin_precedence_rev_beats_tag_and_branch() {
15670        // Precedence: rev > tag > branch. Validate() rejects
15671        // multiple-pin shapes, but the accessor's precedence is defined
15672        // for pre-validate consumers (the resolver's `MissingPin`
15673        // diagnostic path, the caixa-crd round-trip's default `"main"`
15674        // fallback) and as defense-in-depth if the gate is ever
15675        // bypassed. Pins the same precedence caixa-resolver's
15676        // `fetch_git` and caixa-crd's `dep_into_ref` already apply
15677        // inline.
15678        let s = DepSource::Git {
15679            repo: "github:o/x".into(),
15680            tag: Some("v1".into()),
15681            rev: Some("deadbeefcafebabe1234567890abcdef12345678".into()),
15682            branch: Some("main".into()),
15683        };
15684        assert_eq!(
15685            s.sole_pin(),
15686            Some("deadbeefcafebabe1234567890abcdef12345678")
15687        );
15688    }
15689
15690    #[test]
15691    fn sole_pin_precedence_tag_beats_branch_when_no_rev() {
15692        let s = DepSource::Git {
15693            repo: "github:o/x".into(),
15694            tag: Some("v1".into()),
15695            rev: None,
15696            branch: Some("main".into()),
15697        };
15698        assert_eq!(s.sole_pin(), Some("v1"));
15699    }
15700
15701    #[test]
15702    fn sole_pin_byte_equals_inline_rev_or_tag_or_branch_cascade() {
15703        // Fail-before-pass-after byte-parity pin: the substrate accessor
15704        // must return byte-identical to the inline
15705        // `rev.as_deref().or(tag.as_deref()).or(branch.as_deref())`
15706        // cascade both caixa-resolver's `fetch_git` and caixa-crd's
15707        // `dep_into_ref` open-coded pre-lift. Trips at caixa-core build
15708        // time if the accessor's precedence silently drifts from the
15709        // consumer-side cascade — the exact drift this lift converges
15710        // to one substrate primitive to close structurally.
15711        //
15712        // Iterates through the 2^3 = 8 combinations of (tag, rev,
15713        // branch) each-either-`None`-or-`Some`, so every arm of the
15714        // precedence cascade lands under the pin. `validate()` refuses
15715        // the 4 multi-pin combinations, but the accessor's return is
15716        // defined on all 8.
15717        let vals = [Some("R".to_string()), None];
15718        for tag in &vals {
15719            for rev in &vals {
15720                for branch in &vals {
15721                    let s = DepSource::Git {
15722                        repo: "github:o/x".into(),
15723                        tag: tag.clone(),
15724                        rev: rev.clone(),
15725                        branch: branch.clone(),
15726                    };
15727                    // The exact inline cascade the two pre-lift
15728                    // consumer sites hand-rolled, byte-for-byte.
15729                    let expected = rev.as_deref().or(tag.as_deref()).or(branch.as_deref());
15730                    assert_eq!(
15731                        s.sole_pin(),
15732                        expected,
15733                        "sole_pin() must byte-equal \
15734                         rev.or(tag).or(branch) for \
15735                         (tag={tag:?}, rev={rev:?}, branch={branch:?}) — \
15736                         a drift would silently split caixa-resolver's \
15737                         fetch_git checkout target from caixa-crd's \
15738                         dep_into_ref git_ref fill",
15739                    );
15740                }
15741            }
15742        }
15743    }
15744}