Skip to main content

caixa_core/
dep.rs

1use serde::{Deserialize, Serialize};
2use thiserror::Error;
3
4/// A single dependency declaration in a `caixa.lisp` manifest.
5///
6/// **Store model = Git, like Zig.** There is no central registry; a caixa is
7/// just a Git repo with a `caixa.lisp` at its root. When `:fonte` is omitted,
8/// the resolver falls back to `github:<default-org>/<nome>` (org defaults to
9/// `pleme-io`, override via `~/.config/caixa/config.yaml`).
10///
11/// ```lisp
12/// ;; Shorthand — resolves to github:pleme-io/caixa-teia (or your default org):
13/// (:nome "caixa-teia" :versao "^0.1")
14///
15/// ;; Explicit git source:
16/// (:nome "caixa-teia"
17///  :versao "^0.1"
18///  :fonte (:tipo git :repo "github:pleme-io/caixa-teia" :tag "v0.1.0"))
19///
20/// ;; Arbitrary git URL (not limited to GitHub):
21/// (:nome "private-caixa"
22///  :versao "*"
23///  :fonte (:tipo git :repo "ssh://git@git.example/team/priv-caixa.git" :branch "main"))
24///
25/// ;; Local path (dev only; not publishable):
26/// (:nome "caixa-teia"
27///  :versao "0.1.0"
28///  :fonte (:tipo path :caminho "../caixa-teia"))
29/// ```
30#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
31#[serde(rename_all = "camelCase")]
32pub struct Dep {
33    /// Caixa name — must match the target caixa's `:nome`.
34    pub nome: String,
35
36    /// Semver constraint string (`"^0.1"`, `"~0.1.2"`, `"0.1.0"`, `"*"`).
37    pub versao: String,
38
39    /// Where to fetch the caixa from. Defaults to the feira registry.
40    #[serde(default, skip_serializing_if = "Option::is_none")]
41    pub fonte: Option<DepSource>,
42
43    /// If true, a missing `:fonte` is not a build failure.
44    #[serde(default, skip_serializing_if = "is_false")]
45    pub opcional: bool,
46
47    /// Feature flags to enable on the target caixa.
48    #[serde(default, skip_serializing_if = "Vec::is_empty")]
49    pub caracteristicas: Vec<String>,
50}
51
52/// Where a dep is fetched from. Tagged via `:tipo` in Lisp.
53///
54/// Only two shapes — Git and local Path. No central registry variant: a caixa
55/// is just a Git repo. Omitting `:fonte` means *"use the default resolver
56/// convention"*, which is `github:<default-org>/<nome>`; the resolver fills
57/// that in when computing the lacre.
58///
59/// The [`gen_platform::IsVariant`] derive emits per-arm arm-discriminator
60/// predicates — [`Self::is_git`], [`Self::is_path`] — so every downstream
61/// consumer that only needs the arm-discriminator projection (not the
62/// borrowed field value) reaches for one typed dispatch on the substrate
63/// primitive rather than a hand-rolled `matches!(s, DepSource::X { .. })`
64/// literal. Extends the closed-set-typed-enum discipline the sibling
65/// caixa-core enums ([`crate::CaixaKind`], [`crate::CaixaDialeto`],
66/// [`crate::supervisor::RestartStrategy`], [`crate::supervisor::RestartPolicy`],
67/// [`crate::upgrade::UpgradeInstruction`], [`crate::aplicacao::PlacementStrategy`],
68/// [`crate::aplicacao::RateLimitUnit`], [`crate::aplicacao::WitTarget`],
69/// [`crate::render::PathShapeViolation`], [`DepList`]) and the sibling
70/// out-of-crate enums (caixa-arch's `InvariantKind` + `ArchVerdict`,
71/// caixa-lint's `Severity` + `FixSafety`, caixa-provedor's
72/// `FerriteRuntime`, caixa-theme's `Semantic`, caixa-flux's `GitRefSpec`,
73/// caixa-ast's `NodeKind` + `TriviaKind`) already carry onto the
74/// two-arm `:fonte` dep-source axis — the 17th closed-set typed enum
75/// on the caixa surface, and the first on the outer-`Dep` `:fonte`-slot
76/// axis every git-fetching consumer runs after the outer `:fonte` slot
77/// resolves to a shape.
78#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, gen_platform::IsVariant)]
79#[serde(tag = "tipo", rename_all = "lowercase")]
80pub enum DepSource {
81    /// Clone from Git. One of `:tag`, `:rev`, or `:branch` may be set.
82    /// `repo` can be a `github:org/repo` shorthand, a full `https://…` URL,
83    /// or any git-ssh URL.
84    Git {
85        repo: String,
86        #[serde(default, skip_serializing_if = "Option::is_none")]
87        tag: Option<String>,
88        #[serde(default, skip_serializing_if = "Option::is_none")]
89        rev: Option<String>,
90        #[serde(default, skip_serializing_if = "Option::is_none")]
91        branch: Option<String>,
92    },
93    /// Local filesystem path — dev only; cannot be published.
94    Path { caminho: String },
95}
96
97impl DepSource {
98    /// Build a registry-shorthand git source (`github:<org>/<nome>`).
99    ///
100    /// This is the resolver-side fallback for `dep.fonte: None`, not an
101    /// author-surface value — it carries no pin (`:tag`/`:rev`/`:branch`
102    /// all `None`) and is therefore rejected by [`Self::validate`]. The
103    /// resolver fills the pin in at fetch time from the resolved commit;
104    /// authors never serialize this shape as a `Dep::fonte` value.
105    #[must_use]
106    pub fn default_github(org: &str, nome: &str) -> Self {
107        Self::Git {
108            repo: format!("github:{org}/{nome}"),
109            tag: None,
110            rev: None,
111            branch: None,
112        }
113    }
114
115    /// Substrate-canonical per-`:fonte` sole-set git-pin scalar accessor
116    /// every consumer that reads "which single git ref does this source
117    /// resolve to?" keys off — returns the author-declared `:tag` /
118    /// `:rev` / `:branch` byte-string verbatim as an `Option<&str>`,
119    /// borrowed from the typed slot's own `Option<String>` storage; `None`
120    /// on [`Self::Path`] (a path source carries no git-ref) and on a
121    /// [`Self::Git`] variant whose `tag`, `rev`, and `branch` are all
122    /// `None` (the [`Self::default_github`] shorthand shape the resolver
123    /// materializes when the author omits `:fonte` — rejected by
124    /// [`Self::validate`], but the accessor's return is defined on this
125    /// arm too so pre-validate consumers reach for the same typed dispatch
126    /// as post-validate ones).
127    ///
128    /// **Precedence: rev > tag > branch.** The canonical precedence every
129    /// per-`:fonte` git-ref consumer already applies: caixa-resolver's
130    /// per-fetch `git checkout <ref>` reads through the same
131    /// `rev.or(tag).or(branch)` cascade at caixa-resolver/src/resolve.rs,
132    /// and caixa-crd's `dep_into_ref` `CaixaSource.git_ref` fill reads
133    /// through the same cascade at caixa-crd/src/conversion.rs. The
134    /// [`Self::validate`] gate enforces "exactly one pin set" — under
135    /// that invariant every accepted [`Self::Git`] carries exactly one
136    /// non-`None` pin and the precedence is unobservable, but the
137    /// precedence remains defined for pre-validate consumers (the
138    /// resolver's `MissingPin` diagnostic path, the caixa-crd
139    /// round-trip's default `"main"` fallback the author never sees a
140    /// diagnostic on) and defense-in-depth for a hypothetical future
141    /// state where multiple pins survive the gate. The precedence is
142    /// **rev before tag** because `:rev` (a git commit OID) is the
143    /// reproducibility-strongest identifier — an OID resolves to exactly
144    /// one commit regardless of which refname points at it, whereas
145    /// `:tag` and `:branch` are refnames the remote can silently move
146    /// (a tag re-push, a branch head advance); the resolver's freeze
147    /// step at fetch time promotes the resolved commit to `:rev` for
148    /// exactly this reason. **Tag before branch** because `:tag` is
149    /// conventionally immutable (a release tag) whereas `:branch` is
150    /// conventionally mutable (a tracking ref) — a caixa carrying both
151    /// a release tag and a tracking branch reads as "prefer the release
152    /// pin, fall through to the tracking pin only if the release is
153    /// missing". The cascade order also matches the byte-order every
154    /// per-`:tag`/`:rev`/`:branch` diagnostic tuple this crate emits
155    /// (`(":tag", tag), (":rev", rev), (":branch", branch)` — see
156    /// [`Self::validate`]'s `pins` array).
157    ///
158    /// Prior to this lift the "sole set pin" projection sat twice in the
159    /// workspace — inline at caixa-resolver's `fetch_git` (`let gitref =
160    /// rev.or(tag).or(branch).ok_or_else(|| ResolveError::MissingPin
161    /// { … })?;`) and at caixa-crd's `dep_into_ref`
162    /// (`git_ref: rev.clone().or(tag.clone()).or(branch.clone())
163    /// .unwrap_or_else(|| "main".to_string())`) — two open-coded copies
164    /// of the same precedence cascade with no compile-time link back to
165    /// the typed slot. A future extension of the pin axis to a richer
166    /// author surface (a `:commit` pin peer of `:rev` once the substrate
167    /// grows a signed-commit-verification pin, a `:ref` pin the M4
168    /// substrate operator resolves per-cluster ahead of fetch, a
169    /// promotion of the plain `Option<String>` pins to a typed
170    /// `GitPin::{Rev(Oid), Tag(RefName), Branch(RefName)}` newtype
171    /// once the sibling [`crate::render::is_git_oid`] /
172    /// [`crate::render::is_git_ref_name`] gates land as typed
173    /// constructors) would have had to be threaded through both
174    /// open-coded copies in lockstep or the resolver's `git checkout`
175    /// target would silently disagree with the CRD's `git_ref` fill —
176    /// an author's `(:fonte (:tipo git :repo "…" :rev "deadbeef" :tag
177    /// "v1"))` would ship with the resolver checking out `deadbeef`
178    /// while the CRD round-trip re-emitted a Dep pointing at `v1`, one
179    /// lacre closure disagreeing with the emitted K8s CR the operator
180    /// reads. Lifting the resolution to a typed method on the substrate
181    /// primitive means both downstream consumers reach for exactly one
182    /// typed dispatch — the resolver's accept-set migrates as a unit on
183    /// any future pin-axis addition.
184    ///
185    /// Peer of the sibling outer-`Dep` [`Dep::fonte`] (d65d1bf)
186    /// `Option<&DepSource>` composite-reference accessor on the outer-
187    /// `Dep` `:fonte`-slot axis — extended one nesting level down onto
188    /// the per-[`Self::Git`]-variant sole-set-pin projection axis every
189    /// git-fetching consumer runs after the outer `:fonte` slot resolves
190    /// to a [`Self::Git`] shape. Same "one typed dispatch on the
191    /// substrate primitive, thin projections at each consumer" discipline
192    /// the outer accessor family already carries.
193    #[must_use]
194    pub fn sole_pin(&self) -> Option<&str> {
195        match self {
196            Self::Git {
197                tag, rev, branch, ..
198            } => rev.as_deref().or(tag.as_deref()).or(branch.as_deref()),
199            Self::Path { .. } => None,
200        }
201    }
202
203    /// Validate the `:fonte` value-shape: every author-surface
204    /// `:fonte (:tipo git …)` must carry a non-empty `:repo` and
205    /// exactly one of `:tag` / `:rev` / `:branch` set to a non-empty
206    /// value; every `:fonte (:tipo path …)` must carry a non-empty
207    /// `:caminho`.
208    ///
209    /// Called from [`Dep::validate`] with the dep's `:nome` so every
210    /// diagnostic carries the offending entry verbatim — same
211    /// self-locating shape the `:deps :versao` (2420c44),
212    /// `:membros :versao` (9888b13), `:children :versao` (b38ff3a),
213    /// `:placement :clusters` (6cbb900), and `:membros :caixa`
214    /// (3f9d7a0) gates already expose.
215    ///
216    /// Until this gate landed `:fonte` was the only `:deps`-related
217    /// typed surface still untyped past `Caixa::from_lisp`:
218    /// - Empty `:repo` (`(:tipo git :repo "" :tag "v1")`) silently
219    ///   passed parse and surfaced as a git-clone failure at
220    ///   lacre-resolve time, far from the source caixa.lisp.
221    /// - A bare `(:tipo git :repo "…")` with no `:tag`/`:rev`/`:branch`
222    ///   passed parse and surfaced as the resolver's
223    ///   [`ResolveError::MissingPin`](../../caixa-resolver/src/resolve.rs)
224    ///   at fetch time, again far from the source caixa.lisp; lifting
225    ///   to validate-time gives the author the same diagnostic at the
226    ///   edit site.
227    /// - `(:tipo git :repo "…" :tag "v1" :branch "main")` — multiple
228    ///   pins set — passed parse and the resolver silently picked
229    ///   `:rev > :tag > :branch`, ignoring the other pins with no
230    ///   diagnostic; the author had no way to know their `:branch`
231    ///   was dropped. This is the canonical "pin drift" footgun.
232    /// - An empty pin value (`(:tipo git :repo "…" :tag "")`) silently
233    ///   passed parse and surfaced as `git checkout ""` at fetch time.
234    /// - Empty `:caminho` (`(:tipo path :caminho "")`) silently passed
235    ///   parse and surfaced as
236    ///   [`ResolveError::MissingPath`](../../caixa-resolver/src/resolve.rs)
237    ///   with `path: PathBuf("")` — not actionable.
238    ///
239    /// Each rejected shape maps to a typed
240    /// [`DepError::Fonte*`] variant that names the offending
241    /// dep's `:nome` and the specific axis, so the author can grep
242    /// their caixa.lisp for the `:nome "<nome>"` block and fix it in
243    /// one edit.
244    pub fn validate(&self, nome: &str) -> Result<(), DepError> {
245        match self {
246            Self::Git {
247                repo,
248                tag,
249                rev,
250                branch,
251            } => {
252                if repo.is_empty() {
253                    return Err(DepError::fonte_repo_empty(nome));
254                }
255                // The `:repo` value flows verbatim into the caixa-resolver's
256                // `git clone <repo>` subprocess invocation. Until this gate
257                // landed `:repo` was the last untyped `:fonte`-related axis
258                // past the empty arm: a malformed-but-non-empty repo URL
259                // (`":repo "github:p/x ""` trailing space, paste-from-doc;
260                // `":repo "-upload-pack=evil""` leading `-` — the canonical
261                // CLI-argument-injection vector at the `git clone` boundary;
262                // `":repo "pleme-io/caixa-teia""` missing scheme — `git clone`
263                // reads as a relative filesystem path rather than the
264                // GitHub-shorthand expansion; `":repo "github:p/x\n""`
265                // embedded newline; `":repo "github:café/x""` raw non-ASCII)
266                // silently passed validate and the failure surfaced at
267                // lacre-resolve time with a porcelain-quoting-confused error
268                // far from the source caixa.lisp. The lifted predicate makes
269                // the git-porcelain-URL intersection-floor a substrate-level
270                // invariant at validate time, peer with the three pin axes
271                // (`:tag` + `:branch` via [`crate::render::is_git_ref_name`],
272                // e70d213; `:rev` via [`crate::render::is_git_oid`], be07fd5)
273                // — every `:fonte (:tipo git …)` past validate is now
274                // structurally accept-shaped on every axis the resolver
275                // consumes (the `:repo` URL the `git clone` invokes against,
276                // the `:tag`/`:branch` refname `git fetch`/`git checkout`
277                // accepts, the `:rev` commit OID the lacre's content-
278                // addressing equality probe resolves), closing the
279                // `:fonte` slot's value-shape trajectory end-to-end.
280                if let Err(reason) = crate::render::is_git_repo_url(repo) {
281                    return Err(DepError::FonteRepoShape {
282                        nome: nome.to_string(),
283                        repo: repo.clone(),
284                        reason,
285                    });
286                }
287                let pins: [(&'static str, Option<&String>); 3] = [
288                    (":tag", tag.as_ref()),
289                    (":rev", rev.as_ref()),
290                    (":branch", branch.as_ref()),
291                ];
292                let set: Vec<&'static str> =
293                    pins.iter().filter_map(|(n, v)| v.map(|_| *n)).collect();
294                match set.len() {
295                    0 => {
296                        return Err(DepError::fonte_pin_missing(nome));
297                    }
298                    1 => {
299                        for (pin, value) in pins {
300                            if value.is_some_and(String::is_empty) {
301                                return Err(DepError::FontePinEmpty {
302                                    nome: nome.to_string(),
303                                    pin: pin.to_string(),
304                                });
305                            }
306                        }
307                    }
308                    _ => {
309                        return Err(DepError::FontePinAmbiguous {
310                            nome: nome.to_string(),
311                            pins: set.join(", "),
312                        });
313                    }
314                }
315                // Per-pin value-shape gate. The refname-shaped axes
316                // (`:tag` + `:branch`) route through
317                // [`crate::render::is_git_ref_name`]; the hex-OID-shaped
318                // `:rev` axis routes through
319                // [`crate::render::is_git_oid`]. The two predicates
320                // partition the `:fonte` pin axes structurally — refname
321                // vs. hex commit — so a cross-axis mis-slot (the
322                // canonical "I conflated `:rev` and `:branch`" footgun:
323                // `:rev "main"` defeating the reproducibility contract,
324                // `:tag "deadbeef…"` mis-slotting a SHA into the
325                // refname-shaped axis) lands at the offending axis's
326                // predicate, not at lacre-resolve `git fetch` /
327                // `git checkout` time. Their valid sets intersect at
328                // the empty set: every refname is rejected by
329                // `is_git_oid`, every OID is rejected by
330                // `is_git_ref_name`, structurally.
331                //
332                // Until this gate landed `:tag` / `:branch` were the
333                // refname-shaped axes still untyped past the empty-pin
334                // arm: a malformed-but-non-empty refname
335                // (`:tag "v0.1.0 "` trailing space — the canonical
336                // paste-from-doc footgun; `:tag "v0.1.0.lock"` colliding
337                // with git's atomic-rename guard suffix; `:tag "../escape"`
338                // path-traversal via consecutive dots; `:branch "main "`
339                // trailing space; `:branch "feature/foo bar"` embedded
340                // space; `:branch "@"` the literal HEAD alias;
341                // `:branch "refs/heads/main"` the fully-qualified ref
342                // copied from `git show-ref` output that resolves to
343                // a literal ref named `refs/heads/refs/heads/main` on
344                // disk) silently passed validate; the `:rev` axis was
345                // the last `:fonte`-related axis still untyped past the
346                // empty-pin arm: a malformed-but-non-empty hex-OID
347                // (`:rev "main"` conflating with `:branch` — the
348                // reproducibility-contract leak; `:rev "v0.1.0"`
349                // conflating with `:tag` — the same mis-slot on the
350                // refname/OID boundary; `:rev "c0ffee"` an abbreviated
351                // 6-char prefix that's ambiguous across repo history;
352                // `:rev "DEADBEEF…"` an uppercase OID that round-trips
353                // inconsistently against `git rev-parse HEAD`'s
354                // lowercase emission) silently passed validate and the
355                // failure surfaced at lacre-resolve `git fetch` /
356                // `git checkout` time with a quoting-confused error
357                // far from the source caixa.lisp, with no field naming
358                // which `:deps` entry carried the typo. Lifting both
359                // gates to caixa-build time matches the value-shape
360                // trajectory the peer typed axes already follow
361                // (c4213a4 typed WitContract endpoint/subject/slot;
362                // eb3456d :entrada :paths; c7d05ec :entrada :host;
363                // 4f0390b :contratos :endpoint; 6226bf4 :contratos :wit;
364                // 63e18a0 :contratos :subject; 2f4316e :contratos
365                // :slot; e70d213 :fonte :tag + :branch) — the typed
366                // slot's valid set matches its downstream consumer's
367                // accepted set (here, the git porcelain's refname /
368                // commit-OID grammars at `git fetch` / `git checkout`
369                // time), structurally. Same diagnostic shape every
370                // per-axis value-shape lift already exposes
371                // (`*Invalid { axis, reason }`); the `value:` field
372                // carries the offending refname / OID verbatim so the
373                // author can grep their caixa.lisp for the
374                // `:tag "<value>"` / `:branch "<value>"` /
375                // `:rev "<value>"` literal and fix it in one edit.
376                for (pin, value) in [(":tag", tag.as_ref()), (":branch", branch.as_ref())] {
377                    if let Some(v) = value
378                        && let Err(reason) = crate::render::is_git_ref_name(v)
379                    {
380                        return Err(DepError::fonte_pin_shape(nome, pin, v, reason));
381                    }
382                }
383                if let Some(v) = rev.as_ref()
384                    && let Err(reason) = crate::render::is_git_oid(v)
385                {
386                    return Err(DepError::fonte_pin_shape(nome, ":rev", v, reason));
387                }
388                Ok(())
389            }
390            Self::Path { caminho } => Self::validate_caminho(nome, caminho),
391        }
392    }
393
394    /// Reproducibility + path-API gate on the `:fonte (:tipo path …)`
395    /// `:caminho` axis. Walks the leading-byte cascade closed by the
396    /// b94fd83 (`/`), a5c248e (`~`), and f4efe9c (`$`) arms; the
397    /// orthogonal embedded-control-byte arm (d624c8d) covering
398    /// `0x00..=0x1F` plus `0x7F` anywhere in the value; and the
399    /// embedded-`\` Windows-path-separator arm closing the
400    /// cross-host-OS-separator divergence vector on the same
401    /// THEORY.md §V.2 render-determinism axis.
402    ///
403    /// Extracted from [`Self::validate`]'s `Self::Path` arm because the
404    /// per-arm cascade now spans nine diagnostic shapes — every new
405    /// `:caminho` arm (a future `&` / `;` / `|` shell-metachar arm,
406    /// a future glob-metachar `*` / `?` arm) lands here rather than
407    /// re-inflating `Self::validate`. The
408    /// function stays a thin per-arm linear walk for one reason: each
409    /// arm's diagnostic carries a distinct typed [`DepError`] variant
410    /// rather than a parser-shaped `reason` string, so collapsing the
411    /// cascade onto a generic [`crate::render`] predicate would regress
412    /// the per-arm self-locating diagnostic that `feira lint` consumers
413    /// depend on. The wrapped predicate trajectory ([`crate::render::is_dns_1123_label`],
414    /// [`crate::render::is_git_repo_url`], etc.) lives on the
415    /// reason-string-shaped axes; the `:caminho` axis keeps its
416    /// per-arm variant shape.
417    #[allow(
418        clippy::too_many_lines,
419        reason = "the per-arm cascade is structurally flat by design — every \
420                  `:caminho` arm carries its own typed [`DepError`] variant + \
421                  per-arm Why comment, so collapsing the cascade onto a generic \
422                  [`crate::render`] predicate would regress the per-arm self-locating \
423                  diagnostic the `feira lint` consumer surface depends on"
424    )]
425    fn validate_caminho(nome: &str, caminho: &str) -> Result<(), DepError> {
426        if caminho.is_empty() {
427            return Err(DepError::fonte_caminho_empty(nome));
428        }
429        // Reproducibility gate on the `:fonte (:tipo path …)`
430        // `:caminho` axis. The lacre pipeline embeds the value
431        // verbatim in its per-dep content-address
432        // (`conteudo: format!("path:{caminho}")`,
433        // caixa-resolver/src/resolve.rs:189) and that string
434        // folds into the BLAKE3 closure the lacre keys every
435        // downstream consumer (the substrate's reproducibility
436        // contract, CAIXA-SDLC §III.2 — the lacre is the
437        // build's content-addressed identity, peer of the Nix
438        // store path) against. Until this gate landed an
439        // absolute `:caminho` (`/home/me/work/caixa-teia` — the
440        // canonical "I dragged the folder out of Finder into
441        // my editor" footgun; `/Users/alice/dev/caixa-teia` on
442        // the macOS path-layout peer; the
443        // `${WORKSPACE}/caixa-teia` shell-expanded literal
444        // pasted from a CI manifest) silently passed validate
445        // and the failure surfaced *as a successful build with
446        // a divergent lacre*: the BLAKE3 closure on Alice's
447        // workstation differed from the closure on Bob's
448        // workstation, two CI runners with different
449        // `${HOME}` layouts emitted two distinct
450        // content-addresses for the byte-identical caixa, and
451        // the substrate's "the lacre is the build's identity"
452        // contract silently broke far from the source
453        // caixa.lisp — the most insidious failure mode the
454        // typed slot can carry (no error surfaces; the
455        // divergence is invisible until two machines compare
456        // lacres). The same THEORY.md §V.2 render-determinism
457        // discipline `is_sandboxed_relative_path` already
458        // applies on the M2 typed path-slots
459        // (`:behavior :on-*`, `:upgrade-from :state-change
460        // :script`, `:bibliotecas`, `:exe`, `:servicos`), here
461        // narrowed to the absolute-vs-relative axis only:
462        // `:fonte :caminho`'s canonical author-surface form is
463        // the `..`-traversing sibling-workspace path
464        // (`"../caixa-teia"`, the in-tree dev-dep frame), so a
465        // full `is_sandboxed_relative_path` lift would
466        // structurally reject every legitimate path-fonte
467        // dep. The narrower
468        // `std::path::Path::is_absolute` cut admits the
469        // sibling-workspace form while still rejecting the
470        // host-layout-leaking absolute shape — the
471        // reproducibility contract bites at exactly the
472        // absolute boundary, and that's the axis the
473        // substrate-level invariant is meant to hold. Same
474        // diagnostic shape every per-axis value-shape lift on
475        // the surrounding [`DepError::Fonte*`] cluster carries
476        // (the offending `:nome` + offending `:caminho`
477        // quoted verbatim so the author can grep their
478        // caixa.lisp for the `:caminho "<value>"` literal and
479        // fix it in one edit). The empty arm strictly
480        // precedes this arm so the blank-string footgun
481        // surfaces the more self-locating
482        // `FonteCaminhoEmpty` diagnostic (the empty string
483        // is not absolute under `Path::new("").is_absolute()`
484        // so the precedence is a no-op at value level — the
485        // pin matters only at the diagnostic-shape level if
486        // a future codec round-trip ever produces an empty
487        // string that probes as absolute).
488        if std::path::Path::new(caminho).is_absolute() {
489            return Err(DepError::fonte_caminho_absolute(nome, caminho));
490        }
491        // Reproducibility gate's tilde-expansion arm. The b94fd83
492        // `FonteCaminhoAbsolute` closes the leading-`/`
493        // host-layout-leak; a `:caminho "~/work/caixa-teia"` (the
494        // canonical paste-from-shell-prompt / paste-from-`cd ~`-
495        // doc footgun) silently passed both the empty arm and
496        // the absolute arm because `Path::new("~").is_absolute()`
497        // returns `false` — `~` is a shell-expansion convention,
498        // not a POSIX path component, so `std::path::Path` treats
499        // it as a literal directory-name segment. The lacre
500        // pipeline then embedded the value verbatim
501        // (`conteudo: format!("path:~/work/caixa-teia")`) and the
502        // failure mode forked per consumer:
503        //
504        //   - The caixa-resolver's `Path` arm folds `:caminho`
505        //     through `Path::new(caminho).join(<file>)` without
506        //     `~`-expansion, so the build looked for a literal
507        //     `./~/work/caixa-teia` subdirectory and failed at
508        //     resolve time with a `No such file or directory`
509        //     error far from the source caixa.lisp (the lacre
510        //     itself, though, was already byte-identical across
511        //     machines — every machine emitted the same
512        //     `path:~/work/caixa-teia` content-address).
513        //   - A future caixa-resolver pass that *does* expand `~`
514        //     (the canonical shell-convention idiom every
515        //     resolver eventually reaches for once an author
516        //     reports the literal-`~`-directory bug) would re-
517        //     introduce the host-layout-leak the b94fd83 absolute
518        //     gate closes: Alice's `~` expands to `/home/alice`,
519        //     Bob's to `/home/bob`, two CI runners with different
520        //     `$HOME` layouts resolve to two distinct paths for
521        //     the byte-identical caixa, and the substrate's
522        //     "the lacre is the build's identity" contract
523        //     silently breaks far from the source caixa.lisp.
524        //
525        // Closing the gate at `DepSource::validate` (here at the
526        // canonical caixa-build-time boundary, peer with the
527        // absolute arm above) refuses both failure modes
528        // structurally: the typed accepted set excludes every
529        // `~`-prefixed authoring shape, so the resolver is
530        // free to grow `~`-expansion (or any other convention-
531        // expansion the substrate adopts) without re-opening
532        // the host-layout-leak at the typed boundary. Same
533        // diagnostic shape every per-axis value-shape gate on
534        // the surrounding [`DepError::Fonte*`] cluster carries
535        // (the offending `:nome` + offending `:caminho` quoted
536        // verbatim so the author can grep their caixa.lisp for
537        // the `:caminho "<value>"` literal and fix it in one
538        // edit).
539        //
540        // The cascade preserves narrower-diagnostic-first
541        // ordering: `FonteCaminhoEmpty` → `FonteCaminhoAbsolute`
542        // → `FonteCaminhoTildeExpansion`. The empty arm
543        // structurally precedes both (the bytes "" / "~" don't
544        // overlap), and the absolute arm structurally precedes
545        // the tilde arm (an absolute path can't start with `~`
546        // since absolute paths start with `/`; the bytes "/" /
547        // "~" don't overlap either). Both arms are
548        // value-disjoint, so the precedence is a no-op at value
549        // level — the pin matters only at the diagnostic-shape
550        // level if a future codec round-trip ever produces a
551        // value that probes as both absolute and tilde-prefixed.
552        if caminho.starts_with('~') {
553            return Err(DepError::fonte_caminho_tilde_expansion(nome, caminho));
554        }
555        // Reproducibility gate's shell-variable-expansion arm.
556        // The b94fd83 `FonteCaminhoAbsolute` closes the leading-`/`
557        // host-layout-leak; the a5c248e `FonteCaminhoTildeExpansion`
558        // closes the leading-`~` shell-home-expansion shape; the
559        // leading-`$` is the sibling shell-variable-expansion shape
560        // — same host-layout-leaking semantic, different syntactic
561        // surface. A `:caminho "$HOME/work/caixa-teia"` (the
562        // canonical paste-from-`echo $HOME`-doc footgun) and the
563        // `${VAR}`-braced variant (`"${WORKSPACE}/caixa-teia"` —
564        // the canonical paste-from-CI-manifest footgun every
565        // GitHub Actions / GitLab CI / Drone manifest carries)
566        // silently passed every prior arm because
567        // `Path::is_absolute` returns false on `$` (the `$` is a
568        // shell convention, not a POSIX path component, so
569        // `std::path::Path` treats it as a literal directory-name
570        // segment) and the tilde arm's `starts_with('~')` doesn't
571        // fire.
572        //
573        // Same per-consumer failure-fork the tilde arm closes:
574        //
575        //   - The caixa-resolver's `Path` arm folds `:caminho`
576        //     through `Path::new(caminho).join(<file>)` without
577        //     `$`-expansion, so the build looks for a literal
578        //     `./$HOME/work/caixa-teia` subdirectory and fails at
579        //     resolve time with a `No such file or directory`
580        //     error far from the source caixa.lisp.
581        //   - A future caixa-resolver pass that *does* expand
582        //     `$VAR` (the shell-convention idiom every resolver
583        //     eventually reaches for once an author reports the
584        //     literal-`$HOME`-directory bug, especially for CI's
585        //     `${WORKSPACE}` idiom) would re-introduce the host-
586        //     layout-leak the b94fd83 absolute gate closes:
587        //     Alice's `$HOME` expands to `/home/alice`, Bob's to
588        //     `/home/bob`, two CI runners with different
589        //     `${WORKSPACE}` layouts resolve to two distinct
590        //     paths for the byte-identical caixa, and the
591        //     substrate's "the lacre is the build's identity"
592        //     contract silently breaks far from the source
593        //     caixa.lisp.
594        //
595        // Closing the gate at `DepSource::validate` (here at the
596        // canonical caixa-build-time boundary, peer with the
597        // absolute + tilde arms above) refuses both failure modes
598        // structurally. Same diagnostic shape every per-axis
599        // value-shape gate on the surrounding [`DepError::Fonte*`]
600        // cluster carries (the offending `:nome` + offending
601        // `:caminho` quoted verbatim).
602        //
603        // The cascade preserves narrower-diagnostic-first ordering:
604        // `FonteCaminhoEmpty` → `FonteCaminhoAbsolute` →
605        // `FonteCaminhoTildeExpansion` → `FonteCaminhoVarExpansion`.
606        // The empty arm structurally precedes all three subsequent
607        // arms; the absolute arm structurally precedes both the
608        // tilde and the var arms (absolute paths start with `/`,
609        // the bytes `/` / `~` / `$` don't overlap at the leading
610        // position); the tilde arm structurally precedes the var
611        // arm (`~` and `$` don't overlap at the leading position).
612        // Every pair is value-disjoint, so the precedence is a
613        // no-op at value level — the pin matters only at the
614        // diagnostic-shape level if a future codec round-trip ever
615        // produces a probe-as-both value.
616        //
617        // The gate covers every leading-`$` shape: the canonical
618        // `"$HOME/work/caixa-teia"` (POSIX shell), the braced
619        // `"${HOME}/work/caixa-teia"` (POSIX shell braces), the
620        // CI-manifest idiom `"${WORKSPACE}/caixa-teia"` (the
621        // GitHub Actions / GitLab CI / Drone paste footgun), the
622        // XDG idiom `"$XDG_CONFIG_HOME/caixa"`, and the bare `$`
623        // (degenerate "I meant `$HOME` and forgot the rest"). All
624        // shapes route through the same `caminho.starts_with('$')`
625        // byte check.
626        if caminho.starts_with('$') {
627            return Err(DepError::fonte_caminho_var_expansion(nome, caminho));
628        }
629        // Reproducibility gate's leading-space arm. The b94fd83 / a5c248e /
630        // f4efe9c arms closed the leading-byte host-layout-leak shapes
631        // (`/` / `~` / `$`); the embedded-control-byte arm below closes
632        // every byte in `0x00..=0x1F` plus `0x7F` (which already includes
633        // tab `0x09`, LF `0x0A`, CR `0x0D` — every ASCII whitespace
634        // *except* the ASCII space byte `0x20`). The bare ASCII space at
635        // the leading position is the orthogonal paste-from-aligned-doc
636        // shape that silently passed every prior arm: `Path::is_absolute`
637        // returns false on `" ../caixa-teia"` (the leading byte is `0x20`
638        // not `0x2F`), `0x20` is not `~` / `$` / `\` / a control byte, and
639        // the value's last byte is not `/`, so the canonical
640        // paste-from-aligned-`caixa.lisp`-doc footgun (every `:fonte`
641        // form in a multi-entry `:deps` block sits at the same column —
642        // an author selecting `"<sp><sp><sp>../caixa-teia"` and pasting
643        // it from the rendered alignment into a fresh entry preserves the
644        // leading whitespace verbatim) silently rendered as a path with
645        // a leading-space directory component the resolver folds through
646        // `Path::join` looking for a literal `./ ../caixa-teia`
647        // subdirectory that fails at resolve time with a non-self-
648        // locating `No such file or directory` error.
649        //
650        // The lacre pipeline's reproducibility contract bites
651        // strictly at this byte: `path:" ../caixa-teia"` and
652        // `path:"../caixa-teia"` yield distinct BLAKE3 closures
653        // (`conteudo: format!("path:{caminho}")`,
654        // caixa-resolver/src/resolve.rs:189) for the byte-divergent /
655        // semantic-identical caixa, and the substrate's "the lacre is
656        // the build's identity" contract (CAIXA-SDLC §III.2) silently
657        // breaks across two workstations whose authors differ only in
658        // paste-from-aligned-doc whitespace habits — the most insidious
659        // failure mode the typed slot can carry (no error surfaces; the
660        // divergence is invisible until two machines compare lacres).
661        //
662        // The arm fires AFTER the absolute / tilde / var leading-byte
663        // arms (each names the more self-locating shell-convention
664        // diagnostic on values that probe as that arm's leading-byte
665        // sentinel followed by a leading space — e.g.
666        // `:caminho "/  /foo"` surfaces `FonteCaminhoAbsolute` because
667        // the leading byte is `/`, not space) and BEFORE the
668        // embedded-control-byte arm (a leading-space value with an
669        // embedded control byte surfaces the broader leading-space
670        // diagnostic because the cascade walks leading-byte arms first
671        // — peer with how `FonteCaminhoAbsolute` precedes
672        // `FonteCaminhoControlChar` on `"/etc/passwd\n"`).
673        //
674        // The peer single-token-shaped axes already reject leading
675        // whitespace on the same paste-from-aligned-doc contract:
676        // [`crate::render::is_git_repo_url`] rejects leading whitespace
677        // on `:fonte :repo`, [`crate::render::is_git_ref_name`] rejects
678        // leading whitespace on `:fonte :tag`/`:branch`,
679        // [`crate::render::is_chart_description_shape`] rejects leading
680        // whitespace on `:descricao`,
681        // [`crate::render::is_spdx_expression_shape`] rejects leading
682        // whitespace on `:licenca`. Closing the same byte on
683        // `:fonte :caminho` makes the substrate-wide "no leading ASCII
684        // space anywhere in a typed string slot" invariant structurally
685        // consistent across every value-shape-gated typed surface (the
686        // `:caminho` axis was the last typed string surface still
687        // admitting a leading space byte).
688        if caminho.starts_with(' ') {
689            return Err(DepError::fonte_caminho_leading_whitespace(nome, caminho));
690        }
691        // Reproducibility gate's leading-`-` CLI-argument-injection arm.
692        // The b94fd83 + a5c248e + f4efe9c + LeadingWhitespace arms closed
693        // the four prior leading-byte shapes (`/` / `~` / `$` / space);
694        // this arm closes the orthogonal leading-`-` axis on the same
695        // subprocess-argument-boundary the peer `is_git_repo_url` arm
696        // (render.rs:2037, `-upload-pack=…` on `:fonte :repo`) and
697        // `is_git_ref_name` arm (render.rs:1381, 5a28454, `-stable` on
698        // `:fonte :tag` / `:branch`) already reject.
699        //
700        // The lacre pipeline embeds `:caminho` verbatim in its per-dep
701        // content-address (`conteudo: format!("path:{caminho}")`,
702        // caixa-resolver/src/resolve.rs:189) and the resolver folds the
703        // value through `Path::join` looking for a literal `./{caminho}`
704        // subdirectory. Every downstream subprocess that consumes the
705        // resolved path — a `git -C {caminho} <verb>` invocation, a
706        // future `feira tofu` `terraform -chdir={caminho}` shell-out, a
707        // future operator-side `nix build --path {caminho}` spawn, an
708        // `xargs` / `find {caminho}` / `stat {caminho}` /
709        // `rm -rf {caminho}` cleanup — reinterprets a leading-`-` value
710        // as a CLI flag rather than a positional path when the
711        // subprocess invocation does not carry a `--` argument-list
712        // terminator between the flag block and the path argument. The
713        // canonical footguns:
714        //
715        //   - `:caminho "-rf"` — bare short-flag paste (`rm -rf` /
716        //     `find -rf` reinterpretation; the byte the peer
717        //     `FonteCaminhoShellSemicolon` arm's `; rm -rf build`
718        //     example paste-idiom carries as its first token).
719        //   - `:caminho "-C"` — `git -C` config-injection paste
720        //     (`git -C -C` reinterprets the second `-C` as another
721        //     `--change-directory` flag rather than the path
722        //     argument; the canonical `git -C <path>` porcelain
723        //     idiom every multi-repo workspace tool carries).
724        //   - `:caminho "--upload-pack=cat /etc/passwd"` — the
725        //     canonical long-flag CLI-arg-injection vector at every
726        //     git porcelain entry point (`git clone`, `git fetch`,
727        //     `git ls-remote`) that consumes a path or URL
728        //     argument; peer with `is_git_repo_url`'s leading-`-`
729        //     arm (render.rs:2037) on the sibling `:fonte :repo`
730        //     axis, which the arm's diagnostic explicitly cites.
731        //   - `:caminho "--config=…"` / `:caminho "-c"` — git-config
732        //     override paste-idiom (paste-from-`git -c foo=bar`
733        //     shell-history footgun that reinterprets the value as
734        //     a `[foo] bar` config injection on every git porcelain
735        //     entry point).
736        //
737        // POSIX `std::path::Path` treats a leading `-` as a literal
738        // filename byte, so the resolver folds `-rf` through `Path::join`
739        // and looks for a literal `./-rf` subdirectory — the failure
740        // surfaces at resolve time with a non-self-locating `No such
741        // file or directory` error far from the source caixa.lisp, and
742        // the value rides through the lacre content-address into every
743        // downstream shell-spawned subprocess. On any consumer that
744        // shells out without the `--` terminator (the common case at
745        // every porcelain entry-point) the reinterpretation is silent
746        // and the failure mode is arbitrary-argument-injection.
747        //
748        // The arm fires AFTER the absolute / tilde / var / leading-space
749        // leading-byte arms (each names the more self-locating shell-
750        // convention diagnostic on values that probe as that arm's
751        // leading-byte sentinel — the byte sets are pairwise disjoint at
752        // the leading position, so the precedence pin is a no-op at
753        // value level, but the ordering keeps every leading-byte arm's
754        // diagnostic-shape stable) and BEFORE the embedded-control-byte
755        // arm (a leading-`-` value with an embedded control byte
756        // surfaces the narrower leading-`-` diagnostic because the
757        // cascade walks leading-byte arms first — peer with how
758        // `FonteCaminhoAbsolute` precedes `FonteCaminhoControlChar` on
759        // `"/etc/passwd\n"`, and how `FonteCaminhoLeadingWhitespace`
760        // precedes `FonteCaminhoControlChar` on `" ../foo\n"`).
761        //
762        // The peer single-token-shaped axes already reject leading `-`
763        // on the same CLI-arg-injection contract:
764        // [`crate::render::is_git_repo_url`] rejects it on `:fonte :repo`
765        // (render.rs:2037), [`crate::render::is_git_ref_name`] rejects
766        // it on `:fonte :tag` / `:fonte :branch` (render.rs:1381,
767        // 5a28454), [`crate::render::is_dns_1123_label`] rejects it on
768        // every DNS-1123-shaped axis (top-level Caixa `:nome`, `:membros
769        // :caixa`, `:children :caixa`, `:deps :nome`, cluster names),
770        // [`crate::render::is_cargo_feature_name`] rejects it on
771        // `:caracteristicas`, and the feira `init` / `add <nome>`
772        // positional gate (868c191) rejects it on the CLI positional
773        // itself. Closing the same byte on `:fonte :caminho` makes the
774        // substrate-wide "no leading `-` anywhere in a typed single-
775        // token string slot routed through a subprocess argument"
776        // invariant structurally consistent across every value-shape-
777        // gated typed surface (the `:caminho` axis was the last typed
778        // string surface still admitting a leading `-` byte).
779        if caminho.starts_with('-') {
780            return Err(DepError::fonte_caminho_leading_hyphen(nome, caminho));
781        }
782        // Reproducibility gate's embedded-control-byte arm. The
783        // b94fd83 + a5c248e + f4efe9c arms closed the three
784        // leading-byte host-layout-leak shapes (`/` / `~` / `$`);
785        // this arm closes the orthogonal embedded-control-byte
786        // axis — any ASCII control byte (`0x00..=0x1F` plus
787        // `0x7F` DEL) appearing anywhere in `:caminho`. Same
788        // shape every peer single-token-typed-slot value-shape
789        // predicate the surrounding [`crate::render`] cluster
790        // gates against (the lifted `is_git_repo_url` arm on
791        // `:fonte :repo`, the `is_git_ref_name` arm on
792        // `:tag`/`:branch`, the `is_chart_description_shape` /
793        // `is_chart_maintainer_name_shape` /
794        // `is_chart_keyword_shape` arms on the
795        // Helm-chart-shaped axes); now consistent on the
796        // `:caminho` axis too.
797        //
798        // Until this gate landed any embedded control byte
799        // silently passed validate, the lacre pipeline embedded
800        // the value verbatim in its per-dep content-address
801        // (`conteudo: format!("path:{caminho}")`,
802        // caixa-resolver/src/resolve.rs:189), and the failure
803        // forked per byte and per consumer:
804        //
805        //   - NUL (`0x00`) the canonical "POSIX paths cannot
806        //     contain a NUL byte" shape: every `std::fs` syscall
807        //     routes the path through `CString::new`, which
808        //     fails with `NulError` on the first NUL byte; the
809        //     build would surface a `NulError` at resolve time
810        //     far from the source caixa.lisp.
811        //   - LF (`0x0A`) / CR (`0x0D`) the canonical paste-from-
812        //     multiline-doc footgun: a `:caminho
813        //     "../caixa-teia\nrm -rf /"` value (paste landed mid-
814        //     `:caminho` block from a multi-line code-fence)
815        //     silently round-trips through `Path::join` but the
816        //     embedded newline class is a sibling of the CRLF-at-
817        //     subprocess-argument injection vector
818        //     `is_git_repo_url` already closes on `:repo`.
819        //   - Tab (`0x09`) the canonical paste-from-aligned-table
820        //     footgun: the tab is invisible in most editors, and
821        //     the lacre embeds the value verbatim so two
822        //     paste-from-distinct-tables yield divergent lacres
823        //     across host editors that strip vs preserve tabs.
824        //   - DEL (`0x7F`) + every other `0x00..=0x1F` byte: the
825        //     paste-from-binary-blob shape every peer single-
826        //     token-shaped slot rejects under the same
827        //     `b < 0x20 || b == 0x7F` predicate.
828        //
829        // Mirrors the cascade discipline every prior `:caminho`
830        // arm establishes: `FonteCaminhoEmpty` →
831        // `FonteCaminhoAbsolute` → `FonteCaminhoTildeExpansion`
832        // → `FonteCaminhoVarExpansion` →
833        // `FonteCaminhoLeadingWhitespace` →
834        // `FonteCaminhoLeadingHyphen` → `FonteCaminhoControlChar`.
835        // The six leading-byte arms structurally precede the
836        // embedded-byte arm because the leading-byte shapes are
837        // the more self-locating diagnostic on values that probe
838        // as both (e.g. `:caminho "/etc/passwd\n"` surfaces the
839        // narrower `FonteCaminhoAbsolute` rather than the broader
840        // embedded-control-byte arm); the precedence pin matters
841        // at the diagnostic-shape level even though the empty /
842        // absolute / tilde / var arms are value-disjoint from a
843        // bare control byte (which would itself be a leading
844        // byte under the empty / absolute / tilde / var arms'
845        // leading-position semantics, but those arms guard the
846        // specific shell-convention characters `/` / `~` / `$`
847        // — a leading `0x01` byte falls through to this arm).
848        for &b in caminho.as_bytes() {
849            if b < 0x20 || b == 0x7F {
850                return Err(DepError::fonte_caminho_control_char(nome, caminho, b));
851            }
852        }
853        // Reproducibility gate's Windows-path-separator arm. The four
854        // leading-byte arms (`/` / `~` / `$`) and the embedded-
855        // control-byte arm close the host-layout-leaking + paste-from-
856        // multiline-doc shapes; the leading-`\` / embedded-`\` byte is
857        // the orthogonal cross-host-OS-separator shape — same render-
858        // determinism axis, different semantic mechanism. POSIX
859        // [`std::path::Path`] treats `\` (0x5C) as a literal byte
860        // inside a single path component (so `..\caixa-teia` is one
861        // directory named literally `..\caixa-teia`, sibling of `.`
862        // and `..`); Windows [`std::path::Path`] treats `\` as a
863        // primary path separator equal to `/` (so `..\caixa-teia` is
864        // the parent's sibling directory `caixa-teia`). The lacre
865        // pipeline embeds the value verbatim in its per-dep content-
866        // address (`conteudo: format!("path:{caminho}")`, caixa-
867        // resolver/src/resolve.rs:189), so byte-identical caixa.lisp
868        // values resolve to two distinct directories across runner
869        // OSes — the same THEORY.md §V.2 render-determinism contract
870        // the absolute / tilde / var arms protect, here against the
871        // cross-host-OS-separator divergence vector. Even on POSIX-
872        // only resolvers (the canonical pleme-io substrate posture),
873        // a `..\caixa-teia` (the Windows-Explorer "copy as path" /
874        // PowerShell `Get-Location` paste-idiom footgun) silently
875        // passes every prior arm because `Path::is_absolute` returns
876        // false on `..` and `\` is neither a leading-byte sentinel
877        // nor a control byte, then the resolver folds the value
878        // through `Path::new(caminho).join(<file>)` looking for a
879        // literal `./..\caixa-teia` subdirectory and fails at
880        // resolve time with a non-self-locating `No such file or
881        // directory` error far from the source caixa.lisp.
882        //
883        // The peer single-token-shaped axes on the same git-CLI /
884        // path-CLI consumer cluster already reject `\` under the same
885        // Windows-path-leak banner: [`crate::render::is_git_ref_name`]
886        // line 1441 (`"must not contain \\ … the canonical Windows-
887        // path-leak footgun; use / for hierarchical refs"`) gates
888        // `:fonte :tag` / `:fonte :branch` against the same byte,
889        // and [`crate::render::is_gateway_api_http_path`] line 506
890        // includes `\` in the eleven-byte RFC-3986-reserved rejection
891        // set on `:entrada :paths`. Closing the same byte on `:fonte
892        // :caminho` makes the substrate-wide "no Windows path
893        // separator anywhere in a typed string slot" invariant
894        // structurally consistent across every path-shaped typed
895        // surface (the `:caminho` axis was the last typed string
896        // surface still admitting `\`).
897        //
898        // The arm fires AFTER the control-char arm because the
899        // control-char diagnostic is the more self-locating axis on
900        // values that probe as both (`"..\caixa\0teia"` carries both
901        // a `\` and a NUL — NUL is the load-bearing POSIX-syscall-
902        // rejected byte, so `FonteCaminhoControlChar` wins). Same
903        // narrower-diagnostic-first cascade discipline every prior
904        // arm establishes. A pure-`\` value
905        // (`"..\caixa-teia"` with no control bytes) falls through
906        // every prior arm and lands here.
907        for &b in caminho.as_bytes() {
908            if b == b'\\' {
909                return Err(DepError::fonte_caminho_backslash(nome, caminho));
910            }
911        }
912        // Reproducibility gate's shell-redirection arm. The 3a4e1d7 backslash
913        // arm closes the cross-host-OS-separator vector; `<` (`0x3C`) and `>`
914        // (`0x3E`) are the orthogonal shell-redirection sentinels — same
915        // paste-from-shell-prompt footgun class, different syntactic surface.
916        // POSIX `std::path::Path` treats `<` / `>` as literal bytes inside a
917        // single path component (so `../caixa-teia>output` is one directory
918        // named literally `../caixa-teia>output`, sibling of `.` and `..`),
919        // but every interactive shell (bash / zsh / fish / nushell) lexes
920        // `<` / `>` as input / output redirection operators — a `:caminho
921        // "../caixa-teia>build.log"` (the canonical "I pasted a shell
922        // pipeline that wrote build output and forgot to trim the redirect"
923        // footgun) or `:caminho "../<input.lisp"` (the symmetric input-
924        // redirection paste idiom) silently passes every prior arm because
925        // `Path::is_absolute` returns false, `<` / `>` are neither leading-
926        // byte sentinels nor control bytes nor `\`, and the value's last byte
927        // isn't `/`. The resolver folds the value through
928        // `Path::new(caminho).join(<file>)` looking for a literal
929        // `./..\caixa-teia>build.log` subdirectory and fails at resolve time
930        // with a non-self-locating `No such file or directory` error far
931        // from the source caixa.lisp.
932        //
933        // The lacre pipeline embeds the value verbatim in its per-dep
934        // content-address (`conteudo: format!("path:{caminho}")`,
935        // caixa-resolver/src/resolve.rs:189), so a `<` / `>` byte lands in
936        // the BLAKE3 closure and rides downstream as part of the build's
937        // identity. The bytes carry a second class of hazard the prior
938        // separator-shaped arms don't: every typed-string slot whose value
939        // ever flows verbatim into a shell-spawned subprocess (the caixa-
940        // resolver's `git clone` invocation, a future `feira tofu` shell-
941        // out, a future operator-side `nix flake check` spawn) is the
942        // canonical CRLF-at-subprocess-argument / shell-metachar injection
943        // surface that every peer single-token-shaped typed slot already
944        // closes. The peer path-shaped axis `[crate::render::is_gateway_api_http_path]`
945        // (caixa-core/src/render.rs:506) rejects `<` / `>` as part of its
946        // eleven-byte RFC-3986-reserved set on `:entrada :paths`, and the
947        // peer git-ref-shaped axis `[crate::render::is_git_ref_name]` rejects
948        // `<` / `>` on `:fonte :tag` / `:fonte :branch` under the same
949        // shell-metachar-injection banner. The `:caminho` axis was the last
950        // typed string surface still admitting these two bytes; this arm
951        // closes the gap so the substrate-wide "no shell-redirection
952        // metacharacter anywhere in a typed string slot" invariant is now
953        // structurally consistent across every path-shaped typed surface.
954        //
955        // The arm fires AFTER the control-char arm + backslash arm because
956        // both prior arms carry more self-locating diagnostics on values
957        // that probe as both (`"..\foo<bar"` carries both `\` and `<` — the
958        // cross-OS-separator divergence is the load-bearing axis, so the
959        // backslash arm wins; `"../foo\n<bar"` carries both LF and `<` —
960        // the POSIX-syscall-rejected byte is the load-bearing axis, so the
961        // control-char arm wins). The arm fires BEFORE the trailing-`/` arm
962        // because the embedded redirection byte is the more semantic-
963        // locating axis on probe-as-both values (`"../foo</"` ends in `/`
964        // but the load-bearing diagnostic is the embedded `<` shell-
965        // redirection — the trailing `/` is the secondary observation, and
966        // an author who removes the `<` is likely to also tab-strip the
967        // trailing separator).
968        for &b in caminho.as_bytes() {
969            if b == b'<' || b == b'>' {
970                return Err(DepError::fonte_caminho_shell_redirection(nome, caminho, b));
971            }
972        }
973        // Reproducibility gate's shell-pipe arm. The e457141 shell-redirection
974        // arm closes the `<` / `>` input/output redirection sentinels; `|`
975        // (`0x7C`) is the orthogonal shell-pipe sentinel — same paste-from-
976        // shell-prompt footgun class, different syntactic surface. POSIX
977        // `std::path::Path` treats `|` as a literal path-component byte (so
978        // `../caixa-teia|tee` is one directory named literally
979        // `../caixa-teia|tee`, sibling of `.` and `..`), but every interactive
980        // shell (bash / zsh / fish / nushell) lexes `|` as the pipe operator
981        // — a `:caminho "../caixa-teia | grep foo"` (the canonical "I copied a
982        // `ls ../caixa-teia | grep` line out of a shell-history block and
983        // forgot to trim the pipeline tail" footgun) or `:caminho
984        // "../foo||bar"` (the symmetric "I copied a `cmd-a || cmd-b` short-
985        // circuit OR line" idiom) silently passes every prior arm because
986        // `Path::is_absolute` returns false on `..`, `|` is neither a leading-
987        // byte sentinel nor a control byte nor `\` nor `<` / `>`, and the
988        // value's last byte isn't `/`. The resolver folds the value through
989        // `Path::new(caminho).join(<file>)` looking for a literal
990        // `./../caixa-teia | grep foo` subdirectory and fails at resolve time
991        // with a non-self-locating `No such file or directory` error far
992        // from the source caixa.lisp.
993        //
994        // The lacre pipeline embeds the value verbatim in its per-dep
995        // content-address (`conteudo: format!("path:{caminho}")`,
996        // caixa-resolver/src/resolve.rs:189), so a `|` byte lands in the
997        // BLAKE3 closure and rides downstream as part of the build's identity
998        // into every shell-spawned subprocess (the caixa-resolver's `git
999        // clone` invocation, a future `feira tofu` shell-out, a future
1000        // operator-side `nix flake check` spawn) as the canonical CRLF-at-
1001        // subprocess-argument / shell-metachar injection surface every peer
1002        // single-token-shaped typed slot already closes. The peer path-shaped
1003        // axis [`crate::render::is_gateway_api_http_path`]
1004        // (caixa-core/src/render.rs:506) rejects `|` as part of its eleven-
1005        // byte RFC-3986-reserved set on `:entrada :paths`. The `:caminho`
1006        // axis was the last typed path-string surface still admitting this
1007        // byte; this arm closes the gap so the substrate-wide "no shell-
1008        // composition metacharacter anywhere in a typed string slot that
1009        // flows verbatim into a shell-spawned subprocess" invariant extends
1010        // from shell-redirection (`<` / `>`) to shell-pipe (`|`) on the
1011        // `:caminho` axis.
1012        //
1013        // The arm fires AFTER the shell-redirection arm because the prior
1014        // arm's two-byte `byte: u8` payload is the more self-locating axis on
1015        // values that probe as both (`"../caixa-teia<input|tee"` carries both
1016        // `<` and `|` — the input-redirection-paste idiom is the load-bearing
1017        // root-cause edit, so `FonteCaminhoShellRedirection` wins; same
1018        // cascade discipline every prior `:caminho` arm establishes). The arm
1019        // fires BEFORE the trailing-`/` arm because the embedded pipe byte is
1020        // the more semantic-locating axis on probe-as-both values
1021        // (`"../foo|tee/"` ends in `/` but the load-bearing diagnostic is the
1022        // embedded `|` shell-pipe — the trailing `/` is the secondary
1023        // observation, and an author who removes the `|` is likely to also
1024        // tab-strip the trailing separator).
1025        for &b in caminho.as_bytes() {
1026            if b == b'|' {
1027                return Err(DepError::fonte_caminho_shell_pipe(nome, caminho));
1028            }
1029        }
1030        // Reproducibility gate's shell-command-separator arm. The 124106f
1031        // shell-pipe arm closes the `|` byte; `;` (`0x3B`) is the orthogonal
1032        // shell-command-separator sentinel — same paste-from-shell-prompt
1033        // footgun class, different syntactic surface. POSIX `std::path::Path`
1034        // treats `;` as a literal path-component byte (so
1035        // `../caixa-teia;rm -rf /` is one directory named literally
1036        // `../caixa-teia;rm -rf /`, sibling of `.` and `..`), but every
1037        // interactive shell (bash / zsh / fish / nushell) lexes `;` as the
1038        // sequential-command terminator that fires the next command
1039        // regardless of the prior command's exit status — a `:caminho
1040        // "../caixa-teia; rm -rf build"` (the canonical "I pasted a shell
1041        // one-liner that chained a cleanup tail after the directory name"
1042        // footgun) or `:caminho "../foo;;bar"` (the symmetric "I copied a
1043        // POSIX `case` arm's `;;` terminator into the middle of a path"
1044        // idiom) silently passes every prior arm because `Path::is_absolute`
1045        // returns false on `..`, `;` is neither a leading-byte sentinel nor a
1046        // control byte nor `\` nor `<` / `>` nor `|`, and the value's last
1047        // byte isn't `/`. The resolver folds the value through
1048        // `Path::new(caminho).join(<file>)` looking for a literal
1049        // `./../caixa-teia; rm -rf build` subdirectory and fails at resolve
1050        // time with a non-self-locating `No such file or directory` error far
1051        // from the source caixa.lisp.
1052        //
1053        // The lacre pipeline embeds the value verbatim in its per-dep
1054        // content-address (`conteudo: format!("path:{caminho}")`,
1055        // caixa-resolver/src/resolve.rs:189), so a `;` byte lands in the
1056        // BLAKE3 closure and rides downstream as part of the build's identity
1057        // into every shell-spawned subprocess (the caixa-resolver's `git
1058        // clone` invocation, a future `feira tofu` shell-out, a future
1059        // operator-side `nix flake check` spawn) as the canonical
1060        // shell-metachar injection surface every peer single-token-shaped
1061        // typed slot already closes. The peer path-shaped axis
1062        // [`crate::render::is_gateway_api_http_path`]
1063        // (caixa-core/src/render.rs:506) rejects `;` as part of its eleven-
1064        // byte RFC-3986-reserved set on `:entrada :paths`. The `:caminho`
1065        // axis was the last typed path-string surface still admitting this
1066        // byte; this arm closes the gap so the substrate-wide "no shell-
1067        // composition metacharacter anywhere in a typed string slot that
1068        // flows verbatim into a shell-spawned subprocess" invariant extends
1069        // from shell-pipe (`|`) to shell-command-separator (`;`) on the
1070        // `:caminho` axis.
1071        //
1072        // The arm fires AFTER the shell-pipe arm because the prior arm's
1073        // canonical-cmd-a-|-cmd-b shape is the more common shell-history
1074        // paste idiom on values that probe as both (`"../caixa-teia | tee;
1075        // rm"` carries both `|` and `;` — the pipeline-tail paste is the
1076        // load-bearing root-cause edit, so `FonteCaminhoShellPipe` wins; same
1077        // cascade discipline every prior `:caminho` arm establishes). The arm
1078        // fires BEFORE the trailing-`/` arm because the embedded
1079        // command-separator byte is the more semantic-locating axis on
1080        // probe-as-both values (`"../foo;rm/"` ends in `/` but the
1081        // load-bearing diagnostic is the embedded `;` shell-command-
1082        // separator — the trailing `/` is the secondary observation, and an
1083        // author who removes the `;` is likely to also tab-strip the trailing
1084        // separator).
1085        for &b in caminho.as_bytes() {
1086            if b == b';' {
1087                return Err(DepError::fonte_caminho_shell_semicolon(nome, caminho));
1088            }
1089        }
1090        // Reproducibility gate's shell-background / logical-AND arm. The
1091        // 05c358e shell-command-separator arm closes the `;` byte; `&`
1092        // (`0x26`) is the orthogonal shell-background / list-AND sentinel
1093        // — same paste-from-shell-prompt footgun class, different
1094        // syntactic surface. POSIX `std::path::Path` treats `&` as a
1095        // literal path-component byte (so `../caixa-teia & sleep 1` is
1096        // one directory named literally `../caixa-teia & sleep 1`,
1097        // sibling of `.` and `..`), but every interactive shell
1098        // (bash / zsh / fish / nushell) lexes `&` two ways:
1099        //
1100        //   - Single `&` as the background-task terminator that detaches
1101        //     the prior command into the background and returns control
1102        //     to the prompt immediately (the canonical `cmd &` idiom
1103        //     every long-running pipeline uses);
1104        //   - Double `&&` as the logical-AND list operator that fires
1105        //     the next command only if the prior command succeeded (the
1106        //     canonical `make && make install` idiom every build script
1107        //     carries).
1108        //
1109        // A `:caminho "../caixa-teia & sleep 1"` (the canonical "I
1110        // pasted a `cd path & sleep 1` background-launch into the
1111        // `:caminho` slot" footgun) or `:caminho "../caixa-teia && make"`
1112        // (the symmetric "I copied a `cd path && make` build chain"
1113        // idiom) silently passes every prior arm because
1114        // `Path::is_absolute` returns false on `..`, `&` is neither a
1115        // leading-byte sentinel nor a control byte nor `\` nor
1116        // `<` / `>` nor `|` nor `;`, and the value's last byte isn't `/`.
1117        // The resolver folds the value through
1118        // `Path::new(caminho).join(<file>)` looking for a literal
1119        // `./../caixa-teia & sleep 1` subdirectory and fails at resolve
1120        // time with a non-self-locating `No such file or directory`
1121        // error far from the source caixa.lisp.
1122        //
1123        // The lacre pipeline embeds the value verbatim in its per-dep
1124        // content-address (`conteudo: format!("path:{caminho}")`,
1125        // caixa-resolver/src/resolve.rs:189), so an `&` byte lands in
1126        // the BLAKE3 closure and rides downstream as part of the build's
1127        // identity into every shell-spawned subprocess (the
1128        // caixa-resolver's `git clone` invocation, a future `feira tofu`
1129        // shell-out, a future operator-side `nix flake check` spawn) as
1130        // the canonical shell-metachar injection surface every peer
1131        // single-token-shaped typed slot already closes. The peer
1132        // path-shaped axis [`crate::render::is_gateway_api_http_path`]
1133        // (caixa-core/src/render.rs:506) rejects `&` as part of its
1134        // eleven-byte RFC-3986-reserved set on `:entrada :paths`. The
1135        // `:caminho` axis was the last typed path-string surface still
1136        // admitting this byte; this arm closes the gap so the
1137        // substrate-wide "no shell-composition metacharacter anywhere
1138        // in a typed string slot that flows verbatim into a
1139        // shell-spawned subprocess" invariant extends from
1140        // shell-command-separator (`;`) to shell-background /
1141        // logical-AND (`&`) on the `:caminho` axis.
1142        //
1143        // The arm fires AFTER the shell-command-separator arm because
1144        // the prior arm's `cmd-a; cmd-b` shape is the more common
1145        // shell-history paste idiom on values that probe as both
1146        // (`"../caixa-teia; rm & sleep"` carries both `;` and `&` — the
1147        // command-separator-tail paste is the load-bearing root-cause
1148        // edit, so `FonteCaminhoShellSemicolon` wins; same cascade
1149        // discipline every prior `:caminho` arm establishes). The arm
1150        // fires BEFORE the trailing-`/` arm because the embedded
1151        // background / list-AND byte is the more semantic-locating axis
1152        // on probe-as-both values (`"../foo&bar/"` ends in `/` but the
1153        // load-bearing diagnostic is the embedded `&` shell-background
1154        // / logical-AND metachar — the trailing `/` is the secondary
1155        // observation, and an author who removes the `&` is likely to
1156        // also tab-strip the trailing separator).
1157        for &b in caminho.as_bytes() {
1158            if b == b'&' {
1159                return Err(DepError::fonte_caminho_shell_background(nome, caminho));
1160            }
1161        }
1162        // Reproducibility gate's shell-command-substitution arm. The
1163        // e12e4f3 shell-background / logical-AND arm closes the `&`
1164        // byte; the backtick (`0x60`) is the orthogonal POSIX legacy
1165        // command-substitution sentinel — every POSIX shell (sh /
1166        // bash / zsh / dash / ksh / fish / nushell) lexes the byte as
1167        // the canonical legacy wrapper that runs the enclosed command
1168        // and substitutes its standard-output verbatim into the
1169        // surrounding word (a `whoami` wrapped in backticks expands
1170        // to the current user's name; a `cat /etc/passwd` wrapped in
1171        // backticks expands to the file's contents — the canonical
1172        // CWE-78 shell-command-injection vector every shell-side
1173        // hardening guide enumerates first). POSIX
1174        // `std::path::Path` treats backtick as a literal path-
1175        // component byte (so `../caixa-teia/<backtick>whoami<backtick>`
1176        // is one directory named literally that, sibling of `.` and
1177        // `..`).
1178        //
1179        // A `:caminho "../caixa-teia/<backtick>whoami<backtick>"` (the
1180        // canonical "I pasted a shell one-liner carrying a backticked
1181        // `whoami` command-substitution expansion into the `:caminho`
1182        // slot" footgun) or `:caminho "<backtick>pwd<backtick>/caixa-
1183        // teia"` (the symmetric "I copied a `<backtick>pwd<backtick>/
1184        // path` working-directory expansion") silently passes every
1185        // prior arm because `Path::is_absolute` returns false on
1186        // `..`, the backtick byte is neither a leading-byte sentinel
1187        // (the f4efe9c `FonteCaminhoVarExpansion` arm catches the
1188        // modern `$()` form at leading position only; backtick is
1189        // the orthogonal legacy form) nor a control byte nor `\` nor
1190        // `<` / `>` nor `|` nor `;` nor `&`, and the value's last
1191        // byte isn't `/`. The resolver folds the value through
1192        // `Path::new(caminho).join(<file>)` looking for a literal
1193        // subdirectory whose name embeds the backticked token and
1194        // fails at resolve time with a non-self-locating `No such
1195        // file or directory` error far from the source caixa.lisp.
1196        //
1197        // The lacre pipeline embeds the value verbatim in its per-
1198        // dep content-address (`conteudo: format!("path:{caminho}")`,
1199        // caixa-resolver/src/resolve.rs:189), so a backtick byte
1200        // lands in the BLAKE3 closure and rides downstream as part
1201        // of the build's identity into every shell-spawned
1202        // subprocess (the caixa-resolver's `git clone` invocation, a
1203        // future `feira tofu` shell-out, a future operator-side
1204        // `nix flake check` spawn) as the canonical shell-metachar
1205        // injection surface every peer single-token-shaped typed
1206        // slot already closes. The peer path-shaped axis
1207        // [`crate::render::is_gateway_api_http_path`]
1208        // (caixa-core/src/render.rs:506) rejects backtick as part of
1209        // its eleven-byte RFC-3986-reserved set on `:entrada
1210        // :paths`. The `:caminho` axis was the last typed path-
1211        // string surface still admitting this byte; this arm closes
1212        // the gap so the substrate-wide "no shell-composition
1213        // metacharacter anywhere in a typed string slot that flows
1214        // verbatim into a shell-spawned subprocess" invariant
1215        // extends from shell-background / logical-AND (`&`) to
1216        // shell-command-substitution (backtick) on the `:caminho`
1217        // axis.
1218        //
1219        // The arm fires AFTER the shell-background arm because the
1220        // prior arm's `cmd & sleep` shape is the more common shell-
1221        // history paste idiom on values that probe as both (a
1222        // `"../caixa-teia & <backtick>whoami<backtick>"` carries
1223        // both `&` and a backtick — the background-launch tail is
1224        // the load-bearing root-cause edit, so
1225        // `FonteCaminhoShellBackground` wins; same cascade
1226        // discipline every prior `:caminho` arm establishes). The
1227        // arm fires BEFORE the trailing-`/` arm because the
1228        // embedded command-substitution byte is the more semantic-
1229        // locating axis on probe-as-both values (a
1230        // `"../<backtick>whoami<backtick>/"` ends in `/` but the
1231        // load-bearing diagnostic is the embedded backtick shell-
1232        // command-substitution metachar — the trailing `/` is the
1233        // secondary observation, and an author who removes the
1234        // backtick is likely to also tab-strip the trailing
1235        // separator).
1236        for &b in caminho.as_bytes() {
1237            if b == b'`' {
1238                return Err(DepError::fonte_caminho_shell_command_substitution(
1239                    nome, caminho,
1240                ));
1241            }
1242        }
1243        // Reproducibility gate's shell-glob arm. The c4d62b3 shell-command-
1244        // substitution arm closes the backtick byte; `*` (`0x2A`) and `?`
1245        // (`0x3F`) are the orthogonal POSIX glob-expansion sentinels — same
1246        // paste-from-shell-prompt footgun class, different syntactic surface.
1247        // Every POSIX shell (sh / bash / zsh / dash / ksh / fish / nushell)
1248        // lexes `*` and `?` as pathname-expansion wildcards: `*` matches any
1249        // sequence of characters in a path component (including the empty
1250        // sequence), `?` matches exactly one character. POSIX
1251        // `std::path::Path` treats both bytes as literal path-component bytes
1252        // (so `../caixa-teia/*.lisp` is one directory named literally
1253        // `../caixa-teia/*.lisp`, sibling of `.` and `..`).
1254        //
1255        // A `:caminho "../caixa-teia/*"` (the canonical "I pasted a
1256        // `ls ../caixa-teia/*` shell-listing one-liner into the `:caminho`
1257        // slot" footgun) or `:caminho "../foo?"` (the symmetric "I copied a
1258        // `rm foo?` single-char-wildcard removal idiom") silently passes
1259        // every prior arm because `Path::is_absolute` returns false on `..`,
1260        // `*` / `?` are neither leading-byte sentinels nor control bytes nor
1261        // `\` nor `<` / `>` nor `|` nor `;` nor `&` nor backtick, and the
1262        // value's last byte isn't `/`. The resolver folds the value through
1263        // `Path::new(caminho).join(<file>)` looking for a literal
1264        // `./../caixa-teia/*` subdirectory and fails at resolve time with a
1265        // non-self-locating `No such file or directory` error far from the
1266        // source caixa.lisp.
1267        //
1268        // The lacre pipeline embeds the value verbatim in its per-dep
1269        // content-address (`conteudo: format!("path:{caminho}")`,
1270        // caixa-resolver/src/resolve.rs:189), so a `*` or `?` byte lands in
1271        // the BLAKE3 closure and rides downstream as part of the build's
1272        // identity into every shell-spawned subprocess (the caixa-resolver's
1273        // `git clone` invocation, a future `feira tofu` shell-out, a future
1274        // operator-side `nix flake check` spawn) as the canonical
1275        // shell-metachar / pathname-expansion surface every peer
1276        // single-token-shaped typed slot already closes. The peer path-shaped
1277        // axis [`crate::render::is_gateway_api_http_path`]
1278        // (caixa-core/src/render.rs:506) rejects `*` and `?` as part of its
1279        // eleven-byte RFC-3986-reserved set on `:entrada :paths`. The
1280        // `:caminho` axis was the last typed path-string surface still
1281        // admitting these two bytes; this arm closes the gap so the
1282        // substrate-wide "no shell-composition / glob-expansion
1283        // metacharacter anywhere in a typed string slot that flows verbatim
1284        // into a shell-spawned subprocess" invariant extends from
1285        // shell-command-substitution (backtick) to glob-expansion
1286        // (`*` / `?`) on the `:caminho` axis.
1287        //
1288        // The arm fires AFTER the backtick arm because the prior arm's
1289        // CWE-78 shell-command-injection vector is the load-bearing
1290        // diagnostic on values that probe as both (a `"../`whoami`/*"`
1291        // carries both backtick and `*` — the command-substitution paste
1292        // is the load-bearing root-cause edit, so
1293        // `FonteCaminhoShellCommandSubstitution` wins; same cascade
1294        // discipline every prior `:caminho` arm establishes). The arm
1295        // fires BEFORE the trailing-`/` arm because the embedded glob
1296        // byte is the more semantic-locating axis on probe-as-both values
1297        // (`"../foo*/"` ends in `/` but the load-bearing diagnostic is the
1298        // embedded `*` glob metachar — the trailing `/` is the secondary
1299        // observation, and an author who removes the `*` is likely to
1300        // also tab-strip the trailing separator).
1301        for &b in caminho.as_bytes() {
1302            if b == b'*' || b == b'?' {
1303                return Err(DepError::fonte_caminho_shell_glob(nome, caminho, b));
1304            }
1305        }
1306        // Reproducibility gate's shell-subshell-grouping arm. The cf9034b
1307        // shell-glob arm closes the `*` / `?` pathname-expansion sentinels;
1308        // `(` (`0x28`) and `)` (`0x29`) are the orthogonal POSIX subshell-
1309        // grouping sentinels — same paste-from-shell-prompt footgun class,
1310        // different syntactic surface. Every POSIX shell (sh / bash / zsh /
1311        // dash / ksh / fish / nushell) lexes the parenthesis pair as the
1312        // subshell-grouping operator: `(<cmd>)` runs `<cmd>` in a child
1313        // shell with a fresh environment scope (the canonical sandboxing
1314        // idiom every shell-history `(cd <path> && <cmd>)` one-liner uses
1315        // to scope a `cd` to one subshell without disturbing the parent's
1316        // working directory), and `$(<cmd>)` is the modern Bourne
1317        // command-substitution shape the upstream f4efe9c
1318        // `FonteCaminhoVarExpansion` arm closes the leading `$` byte of —
1319        // the closing `)` byte completes that substitution shape and must
1320        // be refused on the same axis (peer with the
1321        // [`crate::render::is_git_repo_url`] 3b99147 arm that closes the
1322        // same byte-pair on the sibling `:fonte :repo` axis under the
1323        // same shell-subshell-grouping + RFC-3986-sub-delims banner).
1324        // POSIX `std::path::Path` treats both bytes as literal path-
1325        // component bytes (so `../caixa-teia/(date)` is one directory
1326        // named literally `../caixa-teia/(date)`, sibling of `.` and
1327        // `..`).
1328        //
1329        // A `:caminho "../caixa-teia/$(date)/build"` (the canonical "I
1330        // pasted a `cd ../caixa-teia/$(date)/build` shell-history one-
1331        // liner whose modern command-substitution expansion lands the
1332        // current date as a subdirectory name" footgun) or `:caminho
1333        // "../(cd foo && pwd)/caixa-teia"` (the symmetric "I copied a
1334        // `(cd foo && pwd)` subshell-grouping working-directory probe
1335        // idiom") silently passes every prior arm because
1336        // `Path::is_absolute` returns false on `..`, `(` / `)` are
1337        // neither leading-byte sentinels nor control bytes nor `\` nor
1338        // `<` / `>` nor `|` nor `;` nor `&` nor backtick nor `*` / `?`,
1339        // and the value's last byte isn't `/`. The resolver folds the
1340        // value through `Path::new(caminho).join(<file>)` looking for a
1341        // literal `./../caixa-teia/$(date)/build` subdirectory and fails
1342        // at resolve time with a non-self-locating `No such file or
1343        // directory` error far from the source caixa.lisp.
1344        //
1345        // The lacre pipeline embeds the value verbatim in its per-dep
1346        // content-address (`conteudo: format!("path:{caminho}")`,
1347        // caixa-resolver/src/resolve.rs:189), so a `(` or `)` byte lands
1348        // in the BLAKE3 closure and rides downstream as part of the
1349        // build's identity into every shell-spawned subprocess (the
1350        // caixa-resolver's `git clone` invocation, a future `feira tofu`
1351        // shell-out, a future operator-side `nix flake check` spawn) as
1352        // the canonical shell-metachar / subshell-grouping surface every
1353        // peer single-token-shaped typed slot already closes. The peer
1354        // git-source axis [`crate::render::is_git_repo_url`] (3b99147)
1355        // rejects the same byte pair on `:fonte :repo` under the same
1356        // shell-subshell-grouping / RFC-3986-sub-delims banner. The
1357        // `:caminho` axis was the last typed path-string surface still
1358        // admitting these two bytes;
1359        // this arm closes the gap so the substrate-wide "no shell-
1360        // composition metacharacter anywhere in a typed string slot that
1361        // flows verbatim into a shell-spawned subprocess" invariant
1362        // extends from shell-glob (`*` / `?`) to shell-subshell-grouping
1363        // (`(` / `)`) on the `:caminho` axis. Together with the f4efe9c
1364        // leading-`$` arm, the typed `:caminho` accepted set now
1365        // structurally excludes the entire modern Bourne
1366        // command-substitution surface — leading `$` closes the
1367        // leading byte of every `$(<cmd>)` shape, this arm closes the
1368        // trailing `)` boundary.
1369        //
1370        // The arm fires AFTER the shell-glob arm because the prior arm's
1371        // `*` / `?` pathname-expansion shape is the more common shell-
1372        // history paste idiom on values that probe as both
1373        // (`"../caixa-teia/*(date)"` carries both `*` and `(` — the
1374        // glob-paste-tail is the load-bearing root-cause edit, so
1375        // `FonteCaminhoShellGlob` wins; same cascade discipline every
1376        // prior `:caminho` arm establishes). The arm fires BEFORE the
1377        // trailing-`/` arm because the embedded subshell-grouping byte
1378        // is the more semantic-locating axis on probe-as-both values
1379        // (`"../foo(date)/"` ends in `/` but the load-bearing diagnostic
1380        // is the embedded `(` shell-subshell-grouping metachar — the
1381        // trailing `/` is the secondary observation, and an author who
1382        // removes the `(` is likely to also tab-strip the trailing
1383        // separator).
1384        for &b in caminho.as_bytes() {
1385            if b == b'(' || b == b')' {
1386                return Err(DepError::fonte_caminho_shell_subshell_grouping(
1387                    nome, caminho, b,
1388                ));
1389            }
1390        }
1391        // Reproducibility gate's shell-brace-expansion arm. The 0633c91
1392        // shell-subshell-grouping arm closes `(` / `)`; `{` (`0x7b`) and
1393        // `}` (`0x7d`) are the orthogonal shell-brace-expansion /
1394        // URI-Template-placeholder byte pair — same paste-from-shell-
1395        // prompt + paste-from-templated-doc footgun class, different
1396        // syntactic surface. Every POSIX-derived shell that implements
1397        // brace expansion (bash / zsh / ksh / fish; the canonical
1398        // `mkdir -p ../{caixa-teia,caixa-helm,caixa-flux}` /
1399        // `cp file{,.bak}` idiom every shell-history block carries)
1400        // expands `{a,b,c}` to the cross-product of its comma-separated
1401        // members and `{1..10}` to the integer range; RFC 6570 reserves
1402        // the matched pair for URI Template placeholders (the canonical
1403        // `https://{host}/{org}/{repo}` substitution shape every
1404        // OpenAPI / Swagger / Postman / GitHub Octokit client /
1405        // Helm chart-URL fragment / Mustache `{{org}}` doubled-brace
1406        // form carries), and Tera / Jinja2 / Handlebars / Go html/template
1407        // every IaC tool (Helm, Kustomize, Terraform's `${var}` cousin
1408        // shape) emit. POSIX `std::path::Path` treats both bytes as
1409        // literal path-component bytes (so `../{caixa-teia,caixa-helm}`
1410        // is one directory named literally `../{caixa-teia,caixa-helm}`,
1411        // sibling of `.` and `..`).
1412        //
1413        // A `:caminho "../{caixa-teia,caixa-helm}/build"` (the canonical
1414        // "I pasted a `cd ../{caixa-teia,caixa-helm}` shell brace-
1415        // expansion one-liner that fans across two siblings" footgun)
1416        // or `:caminho "../{{org}}/caixa-teia"` (the symmetric "I copied
1417        // a `{{org}}` Mustache / Helm template placeholder out of a
1418        // README quick-start and forgot to substitute") silently passes
1419        // every prior arm because `Path::is_absolute` returns false on
1420        // `..`, `{` / `}` are neither leading-byte sentinels nor control
1421        // bytes nor `\` nor `<` / `>` nor `|` nor `;` nor `&` nor
1422        // backtick nor `*` / `?` nor `(` / `)`, and the value's last
1423        // byte isn't `/`. The resolver folds the value through
1424        // `Path::new(caminho).join(<file>)` looking for a literal
1425        // `./../{caixa-teia,caixa-helm}/build` subdirectory and fails
1426        // at resolve time with a non-self-locating `No such file or
1427        // directory` error far from the source caixa.lisp.
1428        //
1429        // The lacre pipeline embeds the value verbatim in its per-dep
1430        // content-address (`conteudo: format!("path:{caminho}")`,
1431        // caixa-resolver/src/resolve.rs:189), so a `{` or `}` byte
1432        // lands in the BLAKE3 closure and rides downstream as part of
1433        // the build's identity into every shell-spawned subprocess
1434        // (the caixa-resolver's `git clone` invocation, a future
1435        // `feira tofu` shell-out, a future operator-side `nix flake
1436        // check` spawn) as the canonical shell-metachar / brace-
1437        // expansion surface every peer single-token-shaped typed
1438        // slot already closes. The peer git-source axis
1439        // [`crate::render::is_git_repo_url`] (42d8f9d — the URI Template
1440        // placeholder arm) rejects the same byte pair on `:fonte :repo`
1441        // under the same RFC-3986-'delims' / RFC-6570-URI-Template /
1442        // shell-brace-expansion banner. The `:caminho` axis was the last
1443        // typed path-string surface still admitting these two bytes;
1444        // this arm closes the gap so the substrate-wide "no shell-
1445        // composition metacharacter anywhere in a typed string slot
1446        // that flows verbatim into a shell-spawned subprocess"
1447        // invariant extends from shell-subshell-grouping (`(` / `)`)
1448        // to shell-brace-expansion (`{` / `}`) on the `:caminho` axis,
1449        // and the typed `:caminho` accepted set now also structurally
1450        // excludes the URI Template / templating-engine placeholder
1451        // surface that would silently round-trip through any
1452        // downstream IaC templating-engine layer.
1453        //
1454        // The arm fires AFTER the shell-subshell-grouping arm because
1455        // the prior arm's `(` / `)` shape is the more semantic-locating
1456        // axis on values that probe as both (`"../{cd foo}(date)"`
1457        // carries both `{` and `(` — the parenthesis-pair is the
1458        // load-bearing modern-Bourne-command-substitution surface the
1459        // prior arm closes; same cascade discipline every prior
1460        // `:caminho` arm establishes). The arm fires BEFORE the
1461        // trailing-`/` arm because the embedded brace-expansion byte
1462        // is the more semantic-locating axis on probe-as-both values
1463        // (`"../{caixa-teia,caixa-helm}/"` ends in `/` but the
1464        // load-bearing diagnostic is the embedded `{` brace-expansion
1465        // metachar — the trailing `/` is the secondary observation,
1466        // and an author who removes the `{` is likely to also tab-
1467        // strip the trailing separator).
1468        for &b in caminho.as_bytes() {
1469            if b == b'{' || b == b'}' {
1470                return Err(DepError::fonte_caminho_shell_brace_expansion(
1471                    nome, caminho, b,
1472                ));
1473            }
1474        }
1475        // Reproducibility gate's shell-bracket-expansion arm. The 598b770
1476        // shell-brace-expansion arm closes `{` / `}`; `[` (`0x5b`) and
1477        // `]` (`0x5d`) are the orthogonal POSIX glob-character-class /
1478        // shell-`test`-builtin byte pair — same paste-from-shell-prompt
1479        // footgun class, different syntactic surface. Every POSIX shell
1480        // (sh / bash / zsh / dash / ksh / fish / nushell) lexes the
1481        // bracket pair as the glob character-class operator: `[abc]`
1482        // matches one of `a`, `b`, `c`; `[a-z]` matches any lowercase
1483        // ASCII letter; `[^x]` negates (the canonical
1484        // `ls *.[ch]` C-source-file glob and the `cd ../[a-z]*`
1485        // lowercase-sibling glob every shell-history block carries —
1486        // the orthogonal axis to the cf9034b `*` / `?` shell-glob arm
1487        // closing the unbounded pathname-expansion sentinels). The
1488        // bracket pair additionally carries the POSIX `test` /
1489        // `[` builtin command (`[ -d ../caixa-teia ] && cd ...` —
1490        // the canonical idiom every shell-script conditional uses) and
1491        // bash's `[[ ... ]]` extended-test grammar. Beyond shell, the
1492        // bracket pair is the TOML inline-array delimiter
1493        // (`features = ["a", "b"]` — the canonical paste-from-Cargo-
1494        // manifest cross-idiom-leak vector), the YAML flow-sequence
1495        // delimiter (`paths: [/a, /b]` — the canonical paste-from-
1496        // values.yaml cross-idiom leak), the JSON array delimiter,
1497        // and the POSIX-ERE / PCRE bracket-expression / character-
1498        // class anchor (the canonical paste-from-regex-doc shape).
1499        // POSIX `std::path::Path` treats both bytes as literal path-
1500        // component bytes (so `../[caixa-teia]` is one directory
1501        // named literally `../[caixa-teia]`, sibling of `.` and
1502        // `..`).
1503        //
1504        // A `:caminho "../caixa-[a-z]/build"` (the canonical "I
1505        // pasted a `cd ../caixa-[a-z]/build` glob-character-class
1506        // one-liner that matches every lowercase-sibling-suffix
1507        // sibling directory" footgun), `:caminho "../[caixa-teia]/
1508        // build"` (the symmetric "I pasted a TOML inline-array /
1509        // YAML flow-sequence shape out of an aligned manifest"
1510        // idiom), or `:caminho "../caixa-[ch]"` (the canonical
1511        // `*.[ch]` C-source character-class paste-from-shell-history
1512        // shape) silently passes every prior arm because
1513        // `Path::is_absolute` returns false on `..`, `[` / `]` are
1514        // neither leading-byte sentinels nor control bytes nor `\`
1515        // nor `<` / `>` nor `|` nor `;` nor `&` nor backtick nor
1516        // `*` / `?` nor `(` / `)` nor `{` / `}`, and the value's
1517        // last byte isn't `/`. The resolver folds the value through
1518        // `Path::new(caminho).join(<file>)` looking for a literal
1519        // `./../caixa-[a-z]/build` subdirectory and fails at resolve
1520        // time with a non-self-locating `No such file or directory`
1521        // error far from the source caixa.lisp.
1522        //
1523        // The lacre pipeline embeds the value verbatim in its per-dep
1524        // content-address (`conteudo: format!("path:{caminho}")`,
1525        // caixa-resolver/src/resolve.rs:189), so a `[` or `]` byte
1526        // lands in the BLAKE3 closure and rides downstream as part of
1527        // the build's identity into every shell-spawned subprocess
1528        // (the caixa-resolver's `git clone` invocation, a future
1529        // `feira tofu` shell-out, a future operator-side `nix flake
1530        // check` spawn) as the canonical shell-metachar / glob-
1531        // character-class / TOML-array surface every peer single-
1532        // token-shaped typed slot already closes. The `:caminho` axis
1533        // was the last typed path-string surface still admitting
1534        // these two bytes; this arm closes the gap so the substrate-
1535        // wide "no shell-composition metacharacter anywhere in a
1536        // typed string slot that flows verbatim into a shell-spawned
1537        // subprocess" invariant extends from shell-brace-expansion
1538        // (`{` / `}`) to shell-bracket-expansion (`[` / `]`) on the
1539        // `:caminho` axis. Together with the cf9034b `*` / `?` arm,
1540        // the typed `:caminho` accepted set now structurally excludes
1541        // the entire POSIX pathname-expansion / glob surface —
1542        // unbounded glob (`*` / `?`) AND bounded character-class
1543        // (`[abc]` / `[a-z]`).
1544        //
1545        // The arm fires AFTER the shell-brace-expansion arm because
1546        // the prior arm's `{` / `}` shape is the more semantic-
1547        // locating axis on values that probe as both
1548        // (`"../{a,b}[ch]"` carries both `{` and `[` — the brace-
1549        // expansion fan is the load-bearing root-cause edit, so
1550        // `FonteCaminhoShellBraceExpansion` wins; same cascade
1551        // discipline every prior `:caminho` arm establishes). The arm
1552        // fires BEFORE the trailing-`/` arm because the embedded
1553        // bracket-expansion byte is the more semantic-locating axis
1554        // on probe-as-both values (`"../[a-z]/"` ends in `/` but the
1555        // load-bearing diagnostic is the embedded `[` glob-character-
1556        // class metachar — the trailing `/` is the secondary
1557        // observation, and an author who removes the `[` is likely
1558        // to also tab-strip the trailing separator).
1559        for &b in caminho.as_bytes() {
1560            if b == b'[' || b == b']' {
1561                return Err(DepError::fonte_caminho_shell_bracket_expansion(
1562                    nome, caminho, b,
1563                ));
1564            }
1565        }
1566        // Reproducibility gate's shell-quote-grouping arm. The 986963b
1567        // shell-bracket-expansion arm closes `[` / `]`; `'` (`0x27`) and
1568        // `"` (`0x22`) are the orthogonal POSIX shell-string-literal
1569        // delimiter pair — same paste-from-shell-prompt footgun class,
1570        // different syntactic surface. Every POSIX shell (sh / bash /
1571        // zsh / dash / ksh / fish / nushell) lexes the pair as the
1572        // string-literal quoting operator: `'…'` is the strong
1573        // (no-expansion) single-quoted string and `"…"` is the weak
1574        // (variable-/command-substitution-preserving) double-quoted
1575        // string — the canonical `cd '../caixa-teia'` shell-history
1576        // idiom every path-with-embedded-whitespace paste block carries,
1577        // and the symmetric `git clone "$REPO"` weak-quoted CI-manifest
1578        // shape. Beyond shell, the two bytes carry the JSON string-literal
1579        // delimiter (`"key": "value"` — the canonical paste-from-JSON-
1580        // config cross-idiom-leak vector), the YAML double-quoted +
1581        // single-quoted flow-scalar delimiters (`path: "../caixa-teia"`
1582        // — the canonical paste-from-values.yaml / paste-from-K8s-YAML-
1583        // manifest cross-idiom leak), the TOML basic + literal string
1584        // delimiters (`path = "../caixa-teia"` — the canonical paste-
1585        // from-Cargo-manifest cross-idiom-leak vector), the tatara-lisp
1586        // string-literal delimiter itself (`(:caminho "../caixa-teia")`
1587        // — the canonical "I copied the entire `:caminho "..."` slot
1588        // rather than just the string body" author-surface footgun),
1589        // and RFC 3986 §2.2's `gen-delims` / `sub-delims` grammar which
1590        // excludes both bytes from the `unreserved / pct-encoded /
1591        // sub-delims / ":" / "@"` `pchar` production. POSIX
1592        // `std::path::Path` treats both bytes as literal path-component
1593        // bytes (so `../"caixa-teia"` is one directory named literally
1594        // `../"caixa-teia"`, sibling of `.` and `..`).
1595        //
1596        // A `:caminho "'../caixa-teia'"` (the canonical "I pasted a
1597        // `cd '../caixa-teia'` shell-history one-liner whose strong-
1598        // quoting preserved the sibling-workspace path verbatim across
1599        // the whitespace paste boundary" footgun), `:caminho
1600        // "\"../caixa-teia\""` (the symmetric weak-quoted paste-from-
1601        // JSON / paste-from-YAML flow-scalar / paste-from-TOML basic-
1602        // string / paste-from-tatara-lisp string-literal cross-idiom-
1603        // leak shape), or `:caminho "../\"caixa-teia\""` (the embedded-
1604        // quote "I pasted a JSON key-value pair fragment into the
1605        // middle of the path" idiom) silently passes every prior arm
1606        // because `Path::is_absolute` returns false on `..` / `'` /
1607        // `"`, `'` / `"` are neither leading-byte sentinels nor
1608        // control bytes nor `\` nor `<` / `>` nor `|` nor `;` nor `&`
1609        // nor backtick nor `*` / `?` nor `(` / `)` nor `{` / `}` nor
1610        // `[` / `]`, and the value's last byte isn't `/`. The resolver
1611        // folds the value through `Path::new(caminho).join(<file>)`
1612        // looking for a literal `./'../caixa-teia'` subdirectory and
1613        // fails at resolve time with a non-self-locating `No such file
1614        // or directory` error far from the source caixa.lisp.
1615        //
1616        // The lacre pipeline embeds the value verbatim in its per-dep
1617        // content-address (`conteudo: format!("path:{caminho}")`,
1618        // caixa-resolver/src/resolve.rs:189), so a `'` or `"` byte
1619        // lands in the BLAKE3 closure and rides downstream as part of
1620        // the build's identity into every shell-spawned subprocess
1621        // (the caixa-resolver's `git clone` invocation, a future
1622        // `feira tofu` shell-out, a future operator-side `nix flake
1623        // check` spawn) as the canonical shell-metachar / string-
1624        // literal-delimiter surface every peer single-token-shaped
1625        // typed slot already closes. The peer `:fonte :repo` axis
1626        // closes both bytes under the same shell-quote-grouping /
1627        // RFC-3986-sub-delims banner (e7a109f `'` shell-single-quote
1628        // + 4267d8b `"` shell-double-quote on `is_git_repo_url`). The
1629        // `:caminho` axis was the last typed path-string surface
1630        // still admitting these two bytes; this arm closes the gap
1631        // so the substrate-wide "no shell-composition metacharacter
1632        // anywhere in a typed string slot that flows verbatim into a
1633        // shell-spawned subprocess" invariant extends from shell-
1634        // bracket-expansion (`[` / `]`) to shell-quote-grouping (`'`
1635        // / `"`) on the `:caminho` axis. Together with the peer
1636        // JSON / YAML / TOML string-literal delimiters closing at
1637        // this arm and the 598b770 `{` / `}` brace-expansion arm
1638        // closing the templating-engine-placeholder boundary, the
1639        // typed `:caminho` accepted set now structurally excludes
1640        // the entire cross-config-DSL string-literal / templating
1641        // paste-from-aligned-manifest cross-idiom-leak surface that
1642        // would silently round-trip through any downstream JSON /
1643        // YAML / TOML / HCL / tatara-lisp parsing layer.
1644        //
1645        // The arm fires AFTER the shell-bracket-expansion arm because
1646        // the prior arm's `[` / `]` shape is the more semantic-
1647        // locating axis on values that probe as both (`"../[a-z]'x'"`
1648        // carries both `[` and `'` — the glob-character-class
1649        // expansion is the load-bearing root-cause edit, so
1650        // `FonteCaminhoShellBracketExpansion` wins; same cascade
1651        // discipline every prior `:caminho` arm establishes). The arm
1652        // fires BEFORE the trailing-`/` arm because the embedded
1653        // quote-grouping byte is the more semantic-locating axis on
1654        // probe-as-both values (`"../'caixa-teia'/"` ends in `/` but
1655        // the load-bearing diagnostic is the embedded `'` shell-
1656        // string-literal metachar — the trailing `/` is the secondary
1657        // observation, and an author who removes the `'` is likely to
1658        // also tab-strip the trailing separator).
1659        for &b in caminho.as_bytes() {
1660            if b == b'\'' || b == b'"' {
1661                return Err(DepError::fonte_caminho_shell_quote_grouping(
1662                    nome, caminho, b,
1663                ));
1664            }
1665        }
1666        // Reproducibility gate's shell-comment / URL-fragment / YAML-comment arm.
1667        // The d14cbc5 shell-quote-grouping arm closes `'` / `"`; `#` (`0x23`) is
1668        // the orthogonal "byte at which four distinct downstream parsers all
1669        // truncate the value at the first occurrence" surface, and no prior arm
1670        // has covered it on the `:caminho` axis. Every POSIX shell (sh / bash /
1671        // zsh / dash / ksh / fish / nushell) lexes an unquoted `#` at the head
1672        // of a word (or after unquoted whitespace) as the comment-lead: from
1673        // that byte to the end of the physical line is a comment discarded
1674        // before command parsing (`cd ../caixa-teia  # legacy sibling` — the
1675        // canonical paste-from-shell-history-with-trailing-annotation shape
1676        // every operator-notebook and CI-manifest carries; POSIX.1-2017 §2.3
1677        // Token Recognition step 6). YAML 1.2 §6.6 makes `#` the comment lead
1678        // at any position preceded by whitespace or at line-start (`path:
1679        // ../caixa-teia  # pin` — the canonical paste-from-values.yaml /
1680        // paste-from-K8s-manifest cross-idiom-leak shape). tatara-lisp itself
1681        // treats `;` as the comment-lead but a growing number of consumer
1682        // config-DSL layers (HCL, Terraform, Nix flake attributes, .env
1683        // dotenv-style files, gitconfig / .gitignore, ini / TOML) use `#` as
1684        // the comment-lead too — the pair extends the cross-config-DSL
1685        // paste-idiom surface the d14cbc5 quote-grouping arm and the 598b770
1686        // brace-expansion arm already cover on adjacent axes. RFC 3986 §3.5
1687        // reserves `#` as the URL fragment-identifier delimiter (the canonical
1688        // paste-from-browser-address-bar `github.com/foo/bar#readme` /
1689        // `github.com/foo/bar#L42` permalink shape, and the symmetric
1690        // Nix-flake-ref cross-idiom leak `github:foo/bar#packageName` where
1691        // `#` selects a flake output — the same axis the peer
1692        // [`crate::render::is_git_repo_url`] closes on the `:fonte :repo`
1693        // surface at a68f818 with the same downstream-drops-the-tail
1694        // rationale).
1695        //
1696        // POSIX `std::path::Path` treats `#` as a literal path-component byte,
1697        // so a `:caminho "../caixa-teia # legacy sibling"` (the canonical
1698        // paste-from-shell-history-with-trailing-annotation footgun),
1699        // `:caminho "../caixa-teia  # pin"` (the symmetric YAML flow-scalar
1700        // paste-with-trailing-comment shape), or `:caminho "../caixa-teia
1701        // #readme"` (the URL fragment paste-from-browser-address-bar shape)
1702        // silently passes every prior arm because `Path::is_absolute` returns
1703        // false on `..`, `#` is neither a leading-byte sentinel nor a control
1704        // byte nor `\` nor `<` / `>` nor `|` nor `;` nor `&` nor backtick nor
1705        // `*` / `?` nor `(` / `)` nor `{` / `}` nor `[` / `]` nor `'` / `"`,
1706        // and the value's last byte isn't `/`. The resolver folds the value
1707        // through `Path::new(caminho).join(<file>)` looking for a literal
1708        // subdirectory named `../caixa-teia # legacy sibling` and fails at
1709        // resolve time with a non-self-locating `No such file or directory`
1710        // error far from the source caixa.lisp — while every downstream
1711        // shell / YAML / URL parser silently truncates the value at the `#`
1712        // byte to `../caixa-teia`, so a `feira tofu` shell-out to a
1713        // `cd '{caminho}'` command line and a `nix flake check` invocation on
1714        // an emitted YAML `path:` scalar disagree with the resolver on which
1715        // directory the value names. Two workstations whose downstream
1716        // shell / YAML / URL parsing layers differ in unquoted-`#`
1717        // recognition emit divergent build artifacts for the byte-identical
1718        // caixa.lisp value.
1719        //
1720        // The lacre pipeline embeds the value verbatim in its per-dep
1721        // content-address (`conteudo: format!("path:{caminho}")`,
1722        // caixa-resolver/src/resolve.rs:189), so the byte lands in the BLAKE3
1723        // closure and rides downstream as part of the build's identity into
1724        // every shell-spawned subprocess (the caixa-resolver's `git clone`
1725        // invocation, a future `feira tofu` shell-out, a future operator-side
1726        // `nix flake check` spawn) as the canonical shell-metachar /
1727        // comment-lead / URL-fragment-delimiter surface every peer
1728        // single-token-shaped typed slot already closes. The peer `:fonte
1729        // :repo` axis closes the byte under the URL-fragment-identifier
1730        // banner (a68f818 `#` on `is_git_repo_url`); the `:caminho` axis was
1731        // the last typed path-string surface still admitting the byte. This
1732        // arm closes the gap so the substrate-wide "no shell-composition
1733        // metacharacter / comment-lead / URL-fragment-delimiter anywhere in a
1734        // typed string slot that flows verbatim into a shell-spawned
1735        // subprocess or downstream YAML / URL parser" invariant extends from
1736        // shell-quote-grouping (`'` / `"`) to shell-comment / URL-fragment
1737        // (`#`) on the `:caminho` axis. Together with the peer JSON / YAML /
1738        // TOML string-literal delimiters the d14cbc5 quote-grouping arm
1739        // closes and the 598b770 `{` / `}` brace-expansion arm closes on the
1740        // templating-engine-placeholder boundary, the typed `:caminho`
1741        // accepted set now structurally excludes the entire
1742        // paste-with-trailing-annotation / paste-from-URL-permalink /
1743        // paste-from-YAML-comment cross-idiom-leak surface that would
1744        // silently round-trip through any downstream shell / YAML / URL /
1745        // dotenv / gitconfig / HCL parsing layer to a different value than
1746        // the resolver's `Path::join` sees.
1747        //
1748        // The arm fires AFTER the shell-quote-grouping arm because the prior
1749        // arm's `'` / `"` shape is the more semantic-locating axis on values
1750        // that probe as both (`"../'x'#pin"` carries both `'` and `#` — the
1751        // shell-string-literal-delimiter is the load-bearing root-cause edit,
1752        // so `FonteCaminhoShellQuoteGrouping` wins; same cascade discipline
1753        // every prior `:caminho` arm establishes). The arm fires BEFORE the
1754        // trailing-`/` arm because the embedded comment-lead / fragment-
1755        // delimiter byte is the more semantic-locating axis on probe-as-both
1756        // values (`"../caixa-teia#pin/"` ends in `/` but the load-bearing
1757        // diagnostic is the embedded `#` — the trailing `/` is the secondary
1758        // observation, and an author who removes the `#pin` fragment is
1759        // likely to also tab-strip the trailing separator).
1760        for &b in caminho.as_bytes() {
1761            if b == b'#' {
1762                return Err(DepError::fonte_caminho_shell_comment(nome, caminho, b));
1763            }
1764        }
1765        // Reproducibility gate's URL-percent-encoding-escape arm. The 6622063
1766        // shell-comment arm closes the `#` URL-fragment-identifier byte; `%`
1767        // (`0x25`) is the orthogonal RFC 3986 §2.1 URL percent-encoding-escape
1768        // byte — the mandatory encoding mechanism for every byte outside the
1769        // `unreserved` alphanumeric / `-` / `.` / `_` / `~` set, and `%`
1770        // itself must be percent-encoded as `%25` to appear literally inside
1771        // a URL value. The byte carries three distinct render-determinism
1772        // hazards on the `:caminho` axis, no prior arm has covered it, and
1773        // the peer `:fonte :repo` axis (a323db8 `%` on `is_git_repo_url`)
1774        // already closes the same byte under the same URL-percent-encoding
1775        // banner — the `:caminho` axis was the last typed path-string surface
1776        // still admitting the byte.
1777        //
1778        // First, the paste-from-browser-address-bar percent-encoded-space
1779        // footgun: an author copies `../caixa%20teia` out of a URL-encoded
1780        // README hyperlink / a browser address bar / a percent-encoded
1781        // permalink expecting `%20` to decode to a literal space at the
1782        // filesystem layer. POSIX `std::path::Path` treats the byte as a
1783        // literal path-component byte, so `Path::join` looks for a literal
1784        // `./../caixa%20teia` subdirectory and fails at resolve time with a
1785        // non-self-locating `No such file or directory` error far from the
1786        // source caixa.lisp — while the author's mental model was
1787        // `../caixa teia`, the decoded shape. Two authors whose only
1788        // difference is percent-encoding presence resolve to two distinct
1789        // BLAKE3 closures (`path:../caixa%20teia` vs `path:../caixa teia`)
1790        // for what they intended as the byte-identical sibling-workspace
1791        // dep. The lacre pipeline embeds the value verbatim in its per-dep
1792        // content-address (`conteudo: format!("path:{caminho}")`,
1793        // caixa-resolver/src/resolve.rs:189), so the divergence rides
1794        // downstream into the BLAKE3 closure and locks the substrate's
1795        // "the lacre is the build's identity" contract (CAIXA-SDLC §III.2)
1796        // to the wrong encoding — the same THEORY.md §V.2 render-
1797        // determinism vector every prior `:caminho` arm protects.
1798        //
1799        // Second, the printf-format-specifier lead footgun: `%` is the C /
1800        // POSIX printf format-directive lead-in (`%s`, `%d`, `%02x`, the
1801        // canonical `printf "path=%s\n" ../caixa-teia` invocation every
1802        // shell-diagnostic one-liner carries) and the printf builtin is
1803        // wired into every POSIX shell (bash / zsh / dash / ksh / busybox
1804        // ash) as the format-string lead. A `:caminho "../caixa-%s-teia"`
1805        // value flowing into any future `feira` verb that shells out with a
1806        // printf-formatted path template silently gets reinterpreted as a
1807        // format-directive rather than a literal byte — the canonical
1808        // CWE-134 format-string-injection vector.
1809        //
1810        // Third, the bash-job-control-specifier lead footgun: bash / zsh /
1811        // ksh reserve `%N` at word-start as the job-control specifier —
1812        // `%1` names "job 1", `%%` names "the current job", `%foo` names
1813        // "the most recent job whose command started with `foo`". A future
1814        // `feira` verb that invokes `kill %1` on a caminho-scoped
1815        // subprocess would silently redirect the signal to a wrong target.
1816        //
1817        // Beyond the three shell-side hazards, `%` is a first-class parser
1818        // byte in three cross-config-DSL layers the substrate's paste-idiom
1819        // surface routinely crosses: YAML 1.2 §6.8.1 lexes `%` at
1820        // line-start as the directive lead (`%YAML 1.2` / `%TAG` — a
1821        // `:caminho "%YAML/1.2/../caixa-teia"` paste from a top-of-doc
1822        // YAML directive block silently trips the YAML directive parser on
1823        // any downstream emitted YAML manifest); Prometheus / Grafana
1824        // template syntax uses `%(var)s` as the substitution lead; and Nix
1825        // interpolation uses `${var}` (not `%`) but Envsubst /
1826        // Kubernetes / OpenShift template layers use `%VAR%` as the
1827        // Windows-shell env-var-reference lead — the paste-from-`.bat` /
1828        // paste-from-PowerShell-`%env:PATH%` cross-idiom leak.
1829        //
1830        // The three malformed-`%HH` classes documented on the peer
1831        // `is_git_repo_url` `%` arm (a323db8) apply here too:
1832        //
1833        //   - The lone-`%` malformed-escape shape (`"../caixa-teia%foo"`
1834        //     where `%` isn't followed by two hex digits) — every WHATWG-
1835        //     conformant URL parser rejects the value at parse time per
1836        //     RFC 3986 §2.1, but the byte rides into the lacre before
1837        //     the resolver subprocess crosses the URL-parser boundary.
1838        //   - The over-encoded path-separator shape (`"../caixa%2Fteia"`
1839        //     intending the `%2F` as the URL encoding of `/`) locks a
1840        //     `path:../caixa%2Fteia` BLAKE3 closure that diverges from
1841        //     the byte-identical `path:../caixa/teia` form.
1842        //   - The double-encoded shape (`"../caixa%2520teia"` — the `%25`
1843        //     already itself an encoded `%`, so the intent was likely a
1844        //     literal `%20` that survived one round-trip through a
1845        //     URL-encoder that shouldn't have run) locks a triply-
1846        //     divergent closure across the encoded / once-decoded /
1847        //     twice-decoded chain.
1848        //
1849        // POSIX `std::path::Path` treats the byte as a literal path-
1850        // component byte, so a `:caminho "../caixa%20teia"` (the canonical
1851        // paste-from-browser-address-bar percent-encoded-space footgun),
1852        // `:caminho "%YAML/../caixa-teia"` (the symmetric paste-from-YAML-
1853        // directive-block cross-idiom leak), or `:caminho
1854        // "../caixa-%s-teia"` (the printf-format-specifier paste-from-
1855        // shell-diagnostic-one-liner shape) silently passes every prior arm
1856        // because `Path::is_absolute` returns false on `..`, `%` is neither
1857        // a leading-byte sentinel nor a control byte nor `\` nor `<` / `>`
1858        // nor `|` nor `;` nor `&` nor backtick nor `*` / `?` nor `(` / `)`
1859        // nor `{` / `}` nor `[` / `]` nor `'` / `"` nor `#`, and the
1860        // value's last byte isn't `/`. The resolver folds the value through
1861        // `Path::new(caminho).join(<file>)` looking for a literal
1862        // subdirectory named `../caixa%20teia` and fails at resolve time
1863        // with a non-self-locating `No such file or directory` error far
1864        // from the source caixa.lisp — while every downstream URL parser /
1865        // shell printf builtin / YAML directive parser silently
1866        // reinterprets the byte to a different value than the resolver's
1867        // `Path::join` sees. Two workstations whose downstream URL / shell
1868        // / YAML layers differ in `%HH` recognition emit divergent build
1869        // artifacts for the byte-identical caixa.lisp value.
1870        //
1871        // The lacre pipeline embeds the value verbatim in its per-dep
1872        // content-address (`conteudo: format!("path:{caminho}")`, caixa-
1873        // resolver/src/resolve.rs:189), so the byte lands in the BLAKE3
1874        // closure and rides into every shell-spawned subprocess (the
1875        // resolver's `git clone`, a future `feira tofu` shell-out, a
1876        // future operator-side `nix flake check` spawn) as the canonical
1877        // URL-percent-encoding-escape / printf-format-specifier / bash-
1878        // job-control-specifier surface every peer single-token-shaped
1879        // typed slot already closes. This arm closes the gap so the
1880        // substrate-wide "no URL-percent-encoding-escape / printf-format-
1881        // specifier / job-control-specifier / YAML-directive-lead byte
1882        // anywhere in a typed string slot that flows verbatim into a
1883        // shell-spawned subprocess or downstream URL / printf / YAML
1884        // parser" invariant extends from shell-comment / URL-fragment
1885        // (`#` — 6622063) to URL-percent-encoding-escape (`%`) on the
1886        // `:caminho` axis.
1887        //
1888        // The arm fires AFTER the shell-comment arm because the prior
1889        // arm's `#` shape is the more semantic-locating axis on values
1890        // that probe as both (`"../caixa%20teia#pin"` carries both `%`
1891        // and `#` — the URL-fragment-identifier is the load-bearing
1892        // downstream-truncation edit, so `FonteCaminhoShellComment` wins;
1893        // same cascade discipline every prior `:caminho` arm establishes).
1894        // The arm fires BEFORE the trailing-`/` arm because the embedded
1895        // percent-encoding-escape byte is the more semantic-locating axis
1896        // on probe-as-both values (`"../caixa%20teia/"` ends in `/` but
1897        // the load-bearing diagnostic is the embedded `%` percent-
1898        // encoding-escape — the trailing `/` is the secondary observation,
1899        // and an author who decodes the `%20` to a literal space is
1900        // likely to also tab-strip the trailing separator).
1901        for &b in caminho.as_bytes() {
1902            if b == b'%' {
1903                return Err(DepError::fonte_caminho_url_percent_encoding(
1904                    nome, caminho, b,
1905                ));
1906            }
1907        }
1908        // Reproducibility gate's embedded-`$` shell-variable-expansion /
1909        // command-substitution / arithmetic-expansion arm. The f4efe9c
1910        // leading-`$` arm at line 540 routes `caminho.starts_with('$')`
1911        // through `FonteCaminhoVarExpansion` under the leading-byte-
1912        // sentinel host-layout-leak banner (peer with the b94fd83
1913        // absolute / a5c248e tilde leading-byte arms), but the arm
1914        // fires only at position 0 — a `:caminho "../foo$HOME/bar"`
1915        // (embedded `$HOME` in a nested path segment — the canonical
1916        // paste-from-`ls ../foo$HOME/bar`-shell-one-liner footgun where
1917        // an author copies a partially-substituted shell one-liner and
1918        // the leading segment is a literal `../foo` while the mid
1919        // segment carries the un-substituted `$HOME` template), a
1920        // `:caminho "../foo${WORKSPACE}/bar"` (the symmetric braced-CI-
1921        // manifest paste-from-`.gitlab-ci.yml` / paste-from-GitHub-
1922        // Actions-workflow shape), a `:caminho "../foo$(whoami)/bar"`
1923        // (the paste-from-shell-prompt command-substitution idiom), or
1924        // a `:caminho "../foo$((1+2))/bar"` (the arithmetic-expansion
1925        // idiom) silently passes every prior arm because
1926        // `Path::is_absolute` returns false on `..`, `$` is neither a
1927        // leading-byte sentinel (the f4efe9c arm fires only at position
1928        // 0) nor a control byte nor `\` nor `<` / `>` nor `|` nor `;`
1929        // nor `&` nor backtick nor `*` / `?` nor `(` / `)` nor `{` /
1930        // `}` nor `[` / `]` nor `'` / `"` nor `#` nor `%`, and the
1931        // value's last byte isn't `/`. Note that `$(...)` command-
1932        // substitution and `$((...))` arithmetic-expansion each carry
1933        // an embedded `(` byte that the 0633c91 shell-subshell-grouping
1934        // arm catches structurally at the earlier `(` position — but
1935        // an author who reaches for the sh-brace-substitution
1936        // `${VAR}` or the bare `$VAR` shape carries only the `$` byte,
1937        // which no prior arm covers. This arm closes the last
1938        // positional gap on the `$` byte on the `:caminho` axis so
1939        // every position — leading (`FonteCaminhoVarExpansion`) and
1940        // embedded (`FonteCaminhoShellVariableExpansion`) — is
1941        // structurally rejected.
1942        //
1943        // Every POSIX shell (sh / bash / zsh / dash / ksh / busybox
1944        // ash / fish / nushell) lexes `$` as the variable-expansion /
1945        // command-substitution / arithmetic-expansion operator per
1946        // POSIX.1-2017 §2.6 (Word Expansions): `$<name>` (Parameter
1947        // Expansion) expands a named variable, `${<name>}` (Parameter
1948        // Expansion braced form) does the same with an explicit token
1949        // boundary, `$(<cmd>)` (Command Substitution modern form,
1950        // `` `<cmd>` `` legacy form which the c370458 backtick arm
1951        // already closes) runs a subshell and substitutes its stdout,
1952        // and `$((<expr>))` (Arithmetic Expansion) evaluates an
1953        // arithmetic expression. Every form is a host-layout /
1954        // environment-state / shell-subprocess-side-effect leak when
1955        // the byte lands in a value the resolver passes to a shell-
1956        // spawned subprocess. Beyond the POSIX shell layer, `$` is
1957        // the Nix `${var}` string-interpolation lead (the paste-from-
1958        // `flake.nix` / paste-from-`.nix`-attribute cross-idiom leak
1959        // where an author copies `"${pkgs.hello}/bin/hello"` out of a
1960        // nix expression), the Make `$(var)` / `$@` / `$<` automatic-
1961        // variable lead (the paste-from-`Makefile` shape), the
1962        // JavaScript / TypeScript template-literal `${expr}` interp
1963        // lead (the paste-from-JS-template-string idiom in a
1964        // multi-lang-monorepo where a `path` attribute gets copied out
1965        // of a `package.json` script or a Vite config), the envsubst /
1966        // Kubernetes / OpenShift template `${VAR}` interp lead (the
1967        // paste-from-Helm-values / paste-from-K8s-manifest cross-idiom
1968        // leak), the PHP variable lead (`$_GET`, `$_ENV` — the paste-
1969        // from-`.php`-config footgun), the Perl scalar-variable lead
1970        // (`$foo`), the SASS / SCSS variable lead (`$primary-color`),
1971        // and the SQL bind-parameter lead in PostgreSQL / SQLite
1972        // (`$1`, `$2` — the paste-from-`.sql`-migration idiom). The
1973        // cross-idiom paste-footgun surface is broader than any single
1974        // shell layer — `$` is a first-class parser byte in nearly
1975        // every config / templating / build-system DSL the substrate's
1976        // paste-idiom surface routinely crosses. The peer `:fonte
1977        // :repo` axis closes the byte under the shell-variable-
1978        // expansion / URL-sub-delim banner (b9d187c `$` on
1979        // `is_git_repo_url`), the peer `:fonte :tag` / `:fonte :branch`
1980        // axes close `$` as part of `is_git_ref_name`'s printable-
1981        // ASCII-restricted grammar (`git check-ref-format` rejects the
1982        // byte outright), and the peer `:entrada :paths` axis closes
1983        // `$` via `is_gateway_api_http_path`'s eleven-byte RFC-3986-
1984        // reserved set. The `:caminho` axis was the last typed path-
1985        // string surface still admitting `$` at positions other than 0.
1986        //
1987        // POSIX `std::path::Path` treats `$` as a literal path-
1988        // component byte, so `:caminho "../foo$HOME/bar"` silently
1989        // routes through `Path::new(caminho).join(<file>)` looking for
1990        // a literal `./{caminho}` subdirectory that fails at resolve
1991        // time with a non-self-locating `No such file or directory`
1992        // error far from the source caixa.lisp. But every downstream
1993        // shell / envsubst / Nix / Make / K8s-template parser silently
1994        // reinterprets the byte to a different value than the
1995        // resolver's `Path::join` sees — so a `feira tofu` shell-out
1996        // to a `cd '{caminho}'` command line, a `nix flake check`
1997        // invocation on an emitted YAML `path:` scalar folded through
1998        // envsubst, or a `helm template` invocation with a
1999        // `values.yaml` `path: {caminho}` embedded in a `{{`-quoted
2000        // template all disagree with the resolver on which directory
2001        // the value names. Two workstations whose downstream shell /
2002        // envsubst / Nix / Make / K8s-template parsing layers differ
2003        // in `$VAR` recognition (or, worse, expand the byte against
2004        // divergent environments — Alice's `$HOME=/home/alice`, Bob's
2005        // `$HOME=/home/bob`) emit divergent build artifacts for the
2006        // byte-identical caixa.lisp value. Even in the case where the
2007        // resolver strictly does NOT expand `$VAR` (the current
2008        // implementation) the divergence still bites at the lacre-
2009        // identity axis: the lacre pipeline embeds the value verbatim
2010        // in its per-dep content-address (`conteudo:
2011        // format!("path:{caminho}")`, caixa-resolver/src/resolve.rs:189),
2012        // so `path:../foo$HOME/bar` locks a BLAKE3 closure distinct
2013        // from the byte-identical-semantic `path:../foo/home/alice/bar`
2014        // one author would have produced by substituting the literal
2015        // value at author time, defeating the THEORY.md §V.2 render-
2016        // determinism contract on the same axis every prior `:caminho`
2017        // arm protects.
2018        //
2019        // Beyond the render-determinism / host-layout-leak vectors,
2020        // `$` at any position in a value flowing verbatim into a
2021        // shell-spawned subprocess is the canonical CWE-78 shell-
2022        // command-injection surface every peer single-token-shaped
2023        // typed slot already closes. A `:caminho "../foo$(whoami)/bar"`
2024        // that rides into a future `feira tofu` shell-out as `cd
2025        // '../foo$(whoami)/bar'` gets substituted by the shell at
2026        // subprocess-argument-expansion time even inside single quotes
2027        // in fewer positions than one might expect (the substitution
2028        // fires only outside single-quoting per POSIX §2.2.2, but
2029        // eval-style wrappers and `sh -c` layers that route the value
2030        // through re-parsing round-trip the substitution — the same
2031        // vector the c370458 backtick arm closes at the sibling
2032        // command-substitution-legacy-form surface). Every future
2033        // `feira` verb that shells out with a `caminho`-formatted
2034        // subprocess argument silently inherits this substitution
2035        // vector unless the typed slot's accepted set structurally
2036        // excludes the byte.
2037        //
2038        // Frontier inspiration: OTP's `gen_server` return-value grammar
2039        // rejects mid-tuple shell-metachar bytes by construction —
2040        // `{noreply, State}` never carries a raw `$` because the
2041        // Erlang term type system has no notion of "string that gets
2042        // shelled out"; caixa's typed slots inherit the same
2043        // structural discipline (types-are-theorems, the compounding
2044        // mandate's leverage-point-1) by refusing values that would
2045        // silently reinterpret at any downstream layer. Peer with
2046        // Unison's content-addressed code (no ambient environment —
2047        // every reference is a hash, no `$VAR` substitution possible)
2048        // and Pony's capabilities (a path capability that carries a
2049        // `$` would be ill-typed at the reference layer).
2050        //
2051        // The arm fires AFTER the URL-percent-encoding-escape arm (the
2052        // e3558fa `%` arm) because a value carrying both `%` and `$`
2053        // (`"../foo%20$HOME/bar"` — the canonical "I pasted a percent-
2054        // encoded space next to a `$HOME` template") surfaces the
2055        // narrower URL-encoding diagnostic first — the paste-from-
2056        // browser-address-bar shape is the load-bearing self-locating
2057        // edit on every probe-as-both value; same cascade discipline
2058        // every prior `:caminho` arm establishes (a323db8 %  before
2059        // this arm, this arm before trailing-`/`). The arm fires
2060        // BEFORE the trailing-`/` arm because the embedded shell-
2061        // variable-expansion byte is the more semantic-locating axis
2062        // on probe-as-both values (`"../foo$HOME/bar/"` ends in `/`
2063        // but the load-bearing diagnostic is the embedded `$` — the
2064        // trailing `/` is the secondary observation, and an author
2065        // who substitutes the `$HOME` template with a literal value is
2066        // likely to also tab-strip the trailing separator).
2067        for &b in caminho.as_bytes() {
2068            if b == b'$' {
2069                return Err(DepError::fonte_caminho_shell_variable_expansion(
2070                    nome, caminho, b,
2071                ));
2072            }
2073        }
2074        // Reproducibility gate's shell-history-expansion / RFC-3986-sub-delims
2075        // arm. The immediate-predecessor `$` embedded arm closes the shell-
2076        // variable-expansion / command-substitution byte; `!` (`0x21`) is the
2077        // orthogonal POSIX shell-history-expansion sentinel every interactive
2078        // shell with history enabled (bash / ksh / zsh's `bashcompat` /
2079        // csh / tcsh) lexes as the history-expansion prefix: `!command`
2080        // re-runs the most recent history entry beginning with `command`,
2081        // `!!` re-runs the prior command verbatim, `!$` substitutes the
2082        // last word of the prior command, `!:N` substitutes the Nth word,
2083        // `^old^new` rewrites the prior command's `old` to `new` (the
2084        // canonical set of `set -o histexpand` operators bash's default
2085        // interactive session enables). Beyond the shell-history layer,
2086        // RFC 3986 §2.2 lists `!` in the `sub-delims` set (the URL grammar
2087        // admits the byte inside a path segment, but every WHATWG-conformant
2088        // special-scheme URL parser percent-encodes it inside a query
2089        // component via the 'special-query percent-encode set' the peer
2090        // `is_git_repo_url` `*` / `(` / `)` / `'` arms close on); the byte
2091        // is also the C / C++ / Rust / JavaScript / Python bang-operator
2092        // (logical-negation prefix — the paste-from-source-code idiom where
2093        // an author copies `!path.exists()` out of a Rust snippet and the
2094        // trailing punctuation crosses the string-literal boundary); the
2095        // canonical English-typography emphasis / exclamation mark (the
2096        // paste-from-prose enthusiasm-form idiom where an author writes
2097        // `:caminho "../caixa-teia!"` expecting the substrate to coerce it
2098        // to a kebab-case slug); and the Nix flake-ref import-attribute
2099        // `import ./foo.nix { … }` sibling operator surface.
2100        //
2101        // POSIX `std::path::Path` treats `!` as a literal path-component
2102        // byte, so a `:caminho "../caixa-teia!sudo"` (the canonical paste-
2103        // from-shell-history footgun where the author copies a `cd
2104        // ../caixa-teia && !sudo make install` one-liner from a quick-
2105        // start README and the trailing `!sudo` rides in verbatim as a
2106        // history-expansion reference), a `:caminho "../foo!!/bar"` (the
2107        // `!!` repeat-prior-command paste idiom), a `:caminho
2108        // "../caixa-teia!"` (the English-typography enthusiasm-form
2109        // paste-from-prose footgun), or a `:caminho "../foo!$"` (the
2110        // last-word-substitution shape) silently pass every prior arm
2111        // because `Path::is_absolute` returns false on `..`, `!` is neither
2112        // a leading-byte sentinel nor a control byte nor `\` nor `<` / `>`
2113        // nor `|` nor `;` nor `&` nor backtick nor `*` / `?` nor `(` / `)`
2114        // nor `{` / `}` nor `[` / `]` nor `'` / `"` nor `#` nor `%` nor `$`,
2115        // and the value's last byte isn't `/`. The resolver folds the value
2116        // through `Path::new(caminho).join(<file>)` looking for a literal
2117        // `./../caixa-teia!sudo` subdirectory and fails at resolve time
2118        // with a non-self-locating `No such file or directory` error far
2119        // from the source caixa.lisp — while every downstream interactive
2120        // shell with `set -o histexpand` reinterprets the byte as the
2121        // history-expansion prefix, and the failure mode forks per
2122        // consumer: a `feira tofu` shell-out to a `cd '{caminho}'` command
2123        // line executed under `bash -i` (the operator-notebook interactive
2124        // shell) substitutes the `!sudo` reference to the most recent
2125        // history entry starting with `sudo`, silently invoking whatever
2126        // privileged command that entry named.
2127        //
2128        // The lacre pipeline embeds the value verbatim in its per-dep
2129        // content-address (`conteudo: format!("path:{caminho}")`,
2130        // caixa-resolver/src/resolve.rs:189), so the byte lands in the
2131        // BLAKE3 closure and rides into every shell-spawned subprocess
2132        // (the resolver's `git clone`, a future `feira tofu` shell-out,
2133        // a future operator-side `nix flake check` spawn) as the
2134        // canonical shell-history-expansion / RFC-3986-sub-delims surface
2135        // every peer single-token-shaped typed slot already closes. The
2136        // peer `:fonte :repo` axis closes the byte under the same shell-
2137        // history-expansion / RFC-3986-sub-delims banner (7d53c68 `!` on
2138        // `is_git_repo_url`); the `:caminho` axis was the last typed
2139        // path-string surface still admitting the byte. This arm closes
2140        // the gap so the substrate-wide "no shell-composition
2141        // metacharacter / history-expansion sentinel anywhere in a typed
2142        // string slot that flows verbatim into a shell-spawned subprocess"
2143        // invariant extends from shell-variable-expansion (`$`) to shell-
2144        // history-expansion (`!`) on the `:caminho` axis. Together with
2145        // the peer c370458 backtick command-substitution-legacy-form arm
2146        // and the b9d187c-`$`-embedded-variable-expansion arm on the
2147        // sibling `:repo` axis, the typed `:caminho` accepted set now
2148        // structurally excludes every byte the POSIX shell §2.6 Word
2149        // Expansions section, §2.3 Token Recognition step 6, and every
2150        // history-expansion / brace-expansion / pathname-expansion /
2151        // parameter-expansion / command-substitution / arithmetic-
2152        // expansion operator lexes as a first-class parser byte.
2153        //
2154        // Frontier inspiration: Unison's content-addressed code (no
2155        // ambient environment — every reference is a hash, no `!<num>`
2156        // history-index substitution possible; the caixa substrate's
2157        // lacre discipline arrives at the same guarantee by refusing
2158        // bytes at manifest-parse time that would reinterpret against
2159        // ambient shell history state); Pony's capabilities (a path
2160        // capability that carries a `!` would be ill-typed at the
2161        // reference layer).
2162        //
2163        // The arm fires AFTER the shell-variable-expansion arm because a
2164        // value carrying both `$` and `!` (`"../foo$HOME/bar!sudo"` — the
2165        // canonical "I pasted a `$HOME`-templated path adjacent to a
2166        // trailing `!sudo` history-expansion") surfaces the narrower
2167        // shell-variable-expansion diagnostic first — the paste-from-CI-
2168        // manifest-with-`$VAR`-template shape is the load-bearing self-
2169        // locating edit on every probe-as-both value; same cascade
2170        // discipline every prior `:caminho` arm establishes. The arm
2171        // fires BEFORE the trailing-`/` arm because the embedded shell-
2172        // history-expansion byte is the more semantic-locating axis on
2173        // probe-as-both values (`"../foo!sudo/"` ends in `/` but the
2174        // load-bearing diagnostic is the embedded `!` — the trailing `/`
2175        // is the secondary observation, and an author who removes the
2176        // `!sudo` history reference is likely to also tab-strip the
2177        // trailing separator).
2178        for &b in caminho.as_bytes() {
2179            if b == b'!' {
2180                return Err(DepError::fonte_caminho_shell_history_expansion(
2181                    nome, caminho, b,
2182                ));
2183            }
2184        }
2185        // Reproducibility gate's shell-history-substitution / RFC-3986-unwise
2186        // / regex-anchor arm. The immediate-predecessor `!` arm closes the
2187        // POSIX `!command` / `!!` / `!$` history-expansion prefix; `^`
2188        // (`0x5E`) is the paired-operator half of the same bash-reference
2189        // §9.3 histexpand feature — the `^old^new^` "quick substitution"
2190        // form (POSIX bash rewrites the prior command's `old` string to
2191        // `new` and re-executes it, the canonical typo-correction one-
2192        // liner idiom `git clone <bad-url>` → `^bad^good` that pastes the
2193        // trailing substitution fragment verbatim into a `:caminho` value
2194        // when the author trims only the leading `git clone` prefix). The
2195        // peer `:fonte :repo` axis closes the byte under the same
2196        // shell-history-substitution / RFC-3986-unwise banner (49e142f `^`
2197        // on `is_git_repo_url`); the `:caminho` axis was the last typed
2198        // path-string surface still admitting the byte after 6a04767
2199        // landed the `!` arm.
2200        //
2201        // Beyond bash history-substitution, `^` carries five distinct
2202        // downstream-reinterpretation surfaces the typed slot's accepted
2203        // set must structurally exclude:
2204        //
2205        // 1. **RFC 3986 §2 'unwise' set** — the four-byte cross-transport
2206        //    layer set (`{`, `}`, `|`, `\`) plus `^` every URL parser is
2207        //    required to percent-encode-or-refuse at the wire boundary.
2208        //    The WHATWG URL spec's 'fragment percent-encode set' maps
2209        //    `^` → `%5E` at the query / fragment component transition;
2210        //    libcurl silently percent-encodes the byte on the wire, so a
2211        //    `:caminho "../foo^bar"` value the resolver's `Path::join`
2212        //    sees as a literal `./../foo^bar` subdirectory diverges from
2213        //    the byte-transformed `%5E` shape any downstream `feira tofu`
2214        //    curl-invocation or artifact-registry-fetch would emit — the
2215        //    canonical wire-boundary divergence vector the peer
2216        //    `{`, `}`, `|`, `\` `:caminho` arms already close (
2217        //    `FonteCaminhoShellBraceExpansion` at 598b770,
2218        //    `FonteCaminhoShellPipe` at the pipe arm,
2219        //    `FonteCaminhoBackslash` at the backslash arm).
2220        // 2. **Regex character-class negation prefix `[^abc]`** — the
2221        //    canonical paste-from-doc-regex-pipeline footgun where an
2222        //    author copies a `grep '[^abc]'` idiom from a docs quick-
2223        //    listing and the character-class negation byte rides in
2224        //    verbatim.
2225        // 3. **Bitwise XOR operator** in C / C++ / Rust / Python /
2226        //    JavaScript / Nix / Go — the paste-from-source-code idiom
2227        //    where an author copies an `x ^ y`-shaped expression out of
2228        //    a source snippet and the operator crosses the string-
2229        //    literal boundary.
2230        // 4. **Windows `cmd.exe` escape metacharacter** — the byte
2231        //    escapes the next character in a `cmd.exe` batch context (a
2232        //    peer of the backslash arm's Windows-separator-leak vector).
2233        //    A `:caminho "..^&whoami"` cross-platform paste-from-batch-
2234        //    file footgun reinterprets at every `cmd.exe`-spawned
2235        //    subprocess (the resolver's future Windows-runner shell-out,
2236        //    the operator's WinRM path, a future PowerShell-embedded
2237        //    invocation).
2238        // 5. **LaTeX / Markdown / BibTeX superscript operator** — the
2239        //    paste-from-typeset-doc footgun where a mathematical
2240        //    superscript notation (`x^2` / `M^T`) leaks from prose.
2241        //
2242        // POSIX `std::path::Path` treats `^` as a literal path-component
2243        // byte, so `:caminho "../foo^bar/baz"` (embedded quick-
2244        // substitution), `:caminho "../foo^"` (trailing history-
2245        // substitution-open shape), `:caminho "../[^a-z]/foo"` (regex-
2246        // negation-prefix paste from a grep pipeline; note the `[` / `]`
2247        // arm at 986963b fires first on this shape), or `:caminho
2248        // "../x^y"` (XOR-expression paste-from-source) all silently pass
2249        // every prior arm (`^` isn't `\` / `<` / `>` / `|` / `;` / `&` /
2250        // backtick / `*` / `?` / `(` / `)` / `{` / `}` / `[` / `]` / `'`
2251        // / `"` / `#` / `%` / `$` / `!`) and route through
2252        // `Path::new(caminho).join(<file>)` looking for a literal
2253        // `./{caminho}` subdirectory that fails at resolve time with a
2254        // non-self-locating `No such file or directory` error far from
2255        // the source caixa.lisp — while every downstream shell / curl /
2256        // regex / `cmd.exe` layer reinterprets the byte to its own
2257        // semantic.
2258        //
2259        // The lacre pipeline embeds the value verbatim in its per-dep
2260        // content-address (`conteudo: format!("path:{caminho}")`,
2261        // caixa-resolver/src/resolve.rs:189), so the byte lands in the
2262        // BLAKE3 closure and rides into every shell-spawned subprocess
2263        // (the resolver's `git clone`, a future `feira tofu` shell-out,
2264        // a future operator-side `nix flake check` spawn) as the
2265        // canonical shell-history-substitution / RFC-3986-unwise /
2266        // regex-negation surface every peer single-token-shaped typed
2267        // slot already closes. This arm together with the immediate-
2268        // predecessor `!` arm (6a04767) closes the full `set -o
2269        // histexpand` operator surface on the `:caminho` axis — the
2270        // `!command` / `!!` / `!$` prefix form via `!`, the `^old^new^`
2271        // quick-substitution form via `^` — so the substrate-wide "no
2272        // shell-history operator anywhere in a typed string slot that
2273        // flows verbatim into a shell-spawned subprocess" invariant
2274        // extends from the `!` prefix half to the `^` quick-substitution
2275        // half. Every peer bash-history operator now fails at manifest-
2276        // parse time with a self-locating diagnostic naming the offending
2277        // caixa.lisp rather than at resolve-time as a `Path::join`-
2278        // derived `No such file or directory` (harmless but non-self-
2279        // locating) or worse riding into a downstream `bash -i` context
2280        // that reinterprets the byte-pair against ambient history state.
2281        //
2282        // Frontier inspiration: bash reference §9.3 HISTORY EXPANSION
2283        // "Quick substitution. Repeat the previous command, replacing
2284        // string1 with string2." + RFC 3986 §2 'unwise' set
2285        // ("characters that gateways and other transport agents are
2286        // known to sometimes modify") + Pony's capabilities (a path
2287        // capability that carries a `^` would be ill-typed at the
2288        // reference layer, matching the same structural discipline the
2289        // sibling `!` history-expansion arm inherits from Unison's
2290        // content-addressed no-ambient-history discipline).
2291        //
2292        // The arm fires AFTER the shell-history-expansion `!` arm because
2293        // a value carrying both `!` and `^` (`"../foo!sudo^bad^good"` —
2294        // the canonical "I pasted a `!sudo` history-reference next to a
2295        // `^bad^good` quick-substitution") surfaces the narrower prefix-
2296        // form `!` diagnostic first — the `!` form is the load-bearing
2297        // self-locating edit on every probe-as-both value (an author who
2298        // removes the `!sudo` reference is likely to also strip the
2299        // paired `^` substitution fragment); same cascade discipline
2300        // every prior `:caminho` arm establishes. The arm fires BEFORE
2301        // the trailing-`/` arm because the embedded shell-history-
2302        // substitution byte is the more semantic-locating axis on
2303        // probe-as-both values (`"../foo^bar/"` ends in `/` but the
2304        // load-bearing diagnostic is the embedded `^` — the trailing `/`
2305        // is the secondary observation, and an author who removes the
2306        // `^bar` substitution fragment is likely to also tab-strip the
2307        // trailing separator).
2308        for &b in caminho.as_bytes() {
2309            if b == b'^' {
2310                return Err(DepError::fonte_caminho_shell_history_substitution(
2311                    nome, caminho, b,
2312                ));
2313            }
2314        }
2315        // Reproducibility gate's trailing-`/` arm. The b94fd83 absolute arm
2316        // closes the leading-`/` host-layout-leak; the embedded-control-byte
2317        // arm closes any byte-in-the-`0x00..=0x1F` / `0x7F` range; the
2318        // backslash arm closes the cross-host-OS-separator vector. The
2319        // trailing-`/` is the orthogonal shell-tab-completion-on-a-directory
2320        // footgun — `Path::join("../caixa-teia")` and
2321        // `Path::join("../caixa-teia/")` resolve to the same directory
2322        // (POSIX path-component-walk treats trailing `/` as a no-op for
2323        // directory targets, which `:caminho` always names — the sibling-
2324        // workspace dep root is structurally a directory). The lacre
2325        // pipeline embeds the value verbatim in its per-dep content-address
2326        // (`conteudo: format!("path:{caminho}")`,
2327        // caixa-resolver/src/resolve.rs:189), so byte-identical caixa
2328        // semantic-meaning yields two distinct BLAKE3 closures depending on
2329        // whether the author shell-tab-completed the path (every interactive
2330        // shell appends `/` on tab-completing a directory, idiomatic in
2331        // bash / zsh / fish / nushell), pasted from `pwd` (which on most
2332        // shells emits without trailing `/`, but `realpath -e -m` on a
2333        // directory with trailing `/` preserves it), or copied a Cargo
2334        // `path = "../caixa-teia/"` entry from cross-substrate documentation
2335        // (Cargo accepts both shapes and folds them the same way). Two
2336        // workstations whose authors differ only in tab-completion habits
2337        // emit byte-divergent lacres for the byte-identical-semantic caixa,
2338        // and the substrate's "the lacre is the build's identity" contract
2339        // (CAIXA-SDLC §III.2) silently breaks far from the source caixa.lisp.
2340        //
2341        // Same THEORY.md §V.2 render-determinism axis every prior `:caminho`
2342        // arm protects, here against the trailing-separator divergence
2343        // vector: every typed slot's accepted set excludes byte-divergent
2344        // values that round-trip to the same downstream semantic. The peer
2345        // path-shaped axes already reject trailing separators on the same
2346        // contract: [`crate::render::is_gateway_api_http_path`] gates
2347        // `:entrada :paths` against any non-canonical normalization, and
2348        // [`crate::render::is_sandboxed_relative_path`] gates the M2 typed
2349        // path-slots (`:behavior :on-*`, `:upgrade-from :state-change
2350        // :script`, `:bibliotecas`, `:exe`, `:servicos`) against shapes
2351        // whose canonical form would re-introduce determinism divergence.
2352        //
2353        // The arm fires last in the cascade because every prior arm carries
2354        // a more self-locating diagnostic on values that probe as both
2355        // (e.g. `:caminho "../foo/\0/"` ends in `/` but the load-bearing
2356        // diagnostic is the NUL byte's POSIX-syscall-rejection — the
2357        // control-char arm wins; `:caminho "/etc/passwd/"` ends in `/` but
2358        // the load-bearing diagnostic is the absolute host-layout-leak —
2359        // the absolute arm wins; `:caminho "..\caixa-teia/"` ends in `/`
2360        // but the load-bearing diagnostic is the Windows-separator cross-
2361        // OS divergence — the backslash arm wins). The arm covers every
2362        // shape where the last byte is `/` regardless of length, including
2363        // the degenerate single-`/` (which the absolute arm catches first)
2364        // and the consecutive-`//` (where every prior arm passes on the
2365        // bytes other than the trailing `/`).
2366        if caminho.as_bytes().last() == Some(&b'/') {
2367            return Err(DepError::fonte_caminho_trailing_slash(nome, caminho));
2368        }
2369        Ok(())
2370    }
2371}
2372
2373impl Dep {
2374    /// Substrate-canonical per-`:deps` / `:deps-dev` entry `:nome` scalar
2375    /// accessor every consumer of the dep-graph identity axis keys off —
2376    /// returns the author-declared `:nome` byte-string verbatim as a
2377    /// `&str`, borrowed from the typed slot's own [`String`] storage.
2378    ///
2379    /// The `:deps :nome` / `:deps-dev :nome` slot carries the DNS-1123
2380    /// label that names the target caixa (validated by [`Self::validate`]
2381    /// through the shared [`crate::render::is_dns_1123_label`] predicate,
2382    /// same accept-set the peer caixa-identifier axes carry — top-level
2383    /// [`crate::Caixa::nome`], per-`:membros` [`crate::Membro::nome`],
2384    /// per-`:children` [`crate::supervisor::ChildSpec::nome`]). Every
2385    /// downstream consumer that fans on the dep's name-identity keys off
2386    /// this scalar: the [`crate::Caixa::validate_deps`] per-list
2387    /// [`crate::render::insert_first_seen`] dedup key + the paired
2388    /// [`DepError::DuplicateNome`] carrier the walk raises on collision,
2389    /// the cross-list [`validate_no_self_dep`] parent-name equality gate
2390    /// on both `:deps` and `:deps-dev` traversals, the `caixa-resolver`
2391    /// pipeline's `HashSet<String>` seen-set the closure walker gates
2392    /// requeueing off (`caixa-resolver/src/resolve.rs:55`), the resolver's
2393    /// per-transitive-target requeue path (`resolve.rs:63,66`), the
2394    /// [`crate::DepSource::default_github`]-shaped resolver-side shorthand
2395    /// fill-in that folds `:nome` into the fetched-git-URL (`resolve.rs:147`),
2396    /// every `caixa-resolver` `ResolveError::MissingPath` /
2397    /// `ResolveError::MissingPin` carrier that names the offending dep
2398    /// (`resolve.rs:177,206`), each resolved
2399    /// `caixa-lacre::LacreEntry` `nome:` field the closure hash keys off
2400    /// (`resolve.rs:108,113`), and the peer `feira lock` stub-resolver's
2401    /// `LacreEntry` emitter (`caixa-feira/src/cmd/lock.rs:59,61,64`).
2402    ///
2403    /// Prior to this lift the `.nome` byte-string was read inline at every
2404    /// production site — the [`crate::Caixa::validate_deps`] paired
2405    /// `dep.nome.as_str()` / `dep.nome.clone()` accesses on both `:deps`
2406    /// and `:deps-dev` traversals, the [`validate_no_self_dep`] pair of
2407    /// parent-equality checks, and every caixa-resolver / caixa-feira
2408    /// site enumerated above — open-coded field-accesses that expressed
2409    /// no compile-time link back to the typed slot. A future extension of
2410    /// the `:deps :nome` axis to a richer author surface (a per-scope
2411    /// alias table the resolver folds through the `~/.config/caixa/config.yaml`
2412    /// entry the [`crate::dep::Dep`] docstring already acknowledges, a
2413    /// namespace-qualified rewrite the future M4 lacre-federation layer
2414    /// applies per-cluster, a promotion of the plain [`String`] byte-string
2415    /// to a richer scoped-identifier newtype once cross-registry federation
2416    /// lands) would have had to be threaded through every open-coded copy
2417    /// in lockstep or two consumers would silently disagree on which caixa
2418    /// a given dep resolves to — the [`crate::Caixa::validate_deps`] dedup
2419    /// set treating the name as `"caixa-teia"` while the caixa-resolver
2420    /// closure walker treated it as `"tenant-a/caixa-teia"` would silently
2421    /// split the [`DepError::DuplicateNome`] refusal from the resolver's
2422    /// requeue-suppression seen-set, one build-time diagnostic
2423    /// disagreeing with the run-time closure the substrate's lacre
2424    /// pipeline actually materializes. Lifting the resolution rule to a
2425    /// typed method on the substrate primitive means every downstream
2426    /// consumer of the caixa's per-`:deps` identity surface reaches for
2427    /// exactly one typed dispatch — the resolver's accept-set migrates as
2428    /// a unit on any future axis addition.
2429    ///
2430    /// First accessor on the outer `Dep` type — opens the outer-`Dep`
2431    /// `&str`-return required-scalar projection pattern the sibling
2432    /// per-`Dep` `:versao` future lift folds on. Peer of the sibling
2433    /// per-`:membros` [`crate::Membro::nome`] (4a32abf) /
2434    /// per-`:children` [`crate::supervisor::ChildSpec::nome`] (dfb4a81)
2435    /// / top-level [`crate::Caixa::nome`] (e6b7d97) caixa-identity scalar
2436    /// accessors — same "one typed dispatch on the substrate primitive,
2437    /// thin projections at each consumer" discipline extended onto the
2438    /// third named-caixa-referencing axis (`:deps` / `:deps-dev`), the
2439    /// remaining unlifted caixa-name-referencing accessor family in the
2440    /// substrate. Named `nome()` to match the tatara-lisp author-surface
2441    /// term the field's docstring already reaches for ("Caixa name — must
2442    /// match the target caixa's `:nome`") and the peer caixa-identity
2443    /// accessor family the substrate already carries.
2444    #[must_use]
2445    pub const fn nome(&self) -> &str {
2446        self.nome.as_str()
2447    }
2448
2449    /// Substrate-canonical per-`:deps` / `:deps-dev` entry `:versao`
2450    /// Cargo-shaped semver-requirement scalar accessor every consumer of
2451    /// the dep-graph version-pin axis keys off — returns the author-
2452    /// declared `:versao` requirement byte-string verbatim as a `&str`,
2453    /// borrowed from the typed slot's own [`String`] storage.
2454    ///
2455    /// The `:deps :versao` / `:deps-dev :versao` slot carries the
2456    /// Cargo-shaped semver requirement string (`"^0.1"`, `"~0.1.2"`,
2457    /// `"0.1.0"`, `"*"`) the shared [`crate::version::parse_requirement`]
2458    /// entry-point consumes — same accept-set the peer requirement-
2459    /// carrying axes carry (per-`:membros`
2460    /// [`crate::Membro::versao_requirement`], per-`:children`
2461    /// [`crate::supervisor::ChildSpec::versao_requirement`]), validated
2462    /// through the shared
2463    /// [`crate::render::require_valid_versao_requirement`] cascade in
2464    /// [`Self::validate`]. Every downstream consumer that fans on the
2465    /// dep's version-pin keys off this scalar: the [`Self::validate`]
2466    /// `require_valid_versao_requirement` gate + the paired
2467    /// [`DepError::VersaoInvalid`] carrier the cascade raises on
2468    /// requirement-shape rejection, the `feira lock` stub-resolver's
2469    /// `format!("{}@{}", dep.nome(), dep.versao_requirement())`
2470    /// `conteudo` hash-input interpolation and the paired
2471    /// `LacreEntry.versao:` `String`-carry fill (`caixa-feira/src/cmd/lock.rs`),
2472    /// and the peer `feira lock` end-to-end fixture in `caixa-feira/tests/feira_e2e.rs`.
2473    ///
2474    /// Prior to this lift the `.versao` byte-string was read inline at
2475    /// every production site — the [`Self::validate`] paired
2476    /// `&self.versao` requirement-gate reference and `self.versao.clone()`
2477    /// error-body carrier, the `caixa-feira/src/cmd/lock.rs` paired
2478    /// `format!("{}@{}", dep.nome(), dep.versao)` `conteudo` interpolation
2479    /// and `versao: dep.versao.clone()` `LacreEntry` fill, and the
2480    /// `caixa-feira/tests/feira_e2e.rs` end-to-end fixture's pair of the
2481    /// same shapes — open-coded field-accesses that expressed no
2482    /// compile-time link back to the typed slot. A future extension of
2483    /// the `:deps :versao` axis to a richer author surface (a per-scope
2484    /// version-lock overlay the resolver folds through the
2485    /// `~/.config/caixa/config.yaml` entry the [`crate::dep::Dep`]
2486    /// docstring already acknowledges, a per-cluster canary-version
2487    /// overlay per MESH-COMPOSITION §III.2, a promotion of the plain
2488    /// [`String`] requirement to a richer parsed-`VersionReq` newtype
2489    /// once cross-registry federation lands) would have had to be
2490    /// threaded through every open-coded copy in lockstep or two
2491    /// consumers would silently disagree on which release constraint a
2492    /// given dep resolves to — the [`Self::validate`] requirement-gate
2493    /// call reading `"^0.1"` while the `feira lock` stub-resolver's
2494    /// `conteudo` hash-input read `"tenant-a-pin/^0.1"` would silently
2495    /// split the [`DepError::VersaoInvalid`] refusal from the lacre's
2496    /// content-addressed hash the substrate's fetch pipeline actually
2497    /// materializes, one build-time diagnostic disagreeing with the
2498    /// run-time closure. Lifting the resolution rule to a typed method
2499    /// on the substrate primitive means every downstream consumer of
2500    /// the caixa's per-`:deps` version-pin surface reaches for exactly
2501    /// one typed dispatch — the resolver's accept-set migrates as a
2502    /// unit on any future axis addition.
2503    ///
2504    /// Second accessor on the outer `Dep` type — folds on the outer-
2505    /// `Dep` `&str`-return required-scalar projection pattern the
2506    /// sibling per-`Dep` [`Self::nome`] (eba2cde) accessor opened. Peer
2507    /// of the per-`:membros` [`crate::Membro::versao_requirement`]
2508    /// (a40b0e3) / per-`:children`
2509    /// [`crate::supervisor::ChildSpec::versao_requirement`] (7844f4e
2510    /// family) member/child version-pin accessors — the three
2511    /// requirement-carrying axes (`Dep::versao_requirement` on the
2512    /// per-caixa dep-graph edge, `Membro::versao_requirement` on the M3
2513    /// Aplicacao side, `ChildSpec::versao_requirement` on the M2
2514    /// Supervisor side) now share one accessor discipline for the
2515    /// shared substrate concept "another caixa referenced by a
2516    /// Cargo-shaped semver requirement". The pair
2517    /// `(nome(), versao_requirement())` jointly projects the
2518    /// `(nome, versao)` field pair every dep-graph consumer that fans
2519    /// on per-dep identity + version pin keys off. Named
2520    /// `versao_requirement()` rather than `versao()` because the field's
2521    /// storage-side `.versao` label is already the author-surface term
2522    /// (`:versao`); the accessor's name carries the semantic role — the
2523    /// semver *requirement* string the shared
2524    /// [`crate::version::parse_requirement`] entry-point consumes — so a
2525    /// raw field access and a typed dispatch read differently at every
2526    /// consumer site. Matches the peer
2527    /// [`crate::Membro::versao_requirement`] /
2528    /// [`crate::supervisor::ChildSpec::versao_requirement`] naming
2529    /// discipline verbatim.
2530    #[must_use]
2531    pub const fn versao_requirement(&self) -> &str {
2532        self.versao.as_str()
2533    }
2534
2535    /// Substrate-canonical per-`:deps` / `:deps-dev` entry `:fonte`
2536    /// Zig-store-model per-dep source-tuple optional-composite-reference
2537    /// accessor every consumer of the dep-graph fetch-source axis keys
2538    /// off — returns the author-declared `:fonte` typed [`DepSource`]
2539    /// verbatim as an `Option<&DepSource>` borrowed from the typed slot's
2540    /// own `Option<DepSource>` storage, with `None` naming the "author
2541    /// omitted `:fonte`" shorthand every resolver-side default-fill
2542    /// (`caixa-feira/src/cmd/lock.rs`'s stub, `caixa-resolver/src/resolve.rs`'s
2543    /// canonical fetcher, per the [`DepSource::default_github`] fallback
2544    /// the [`Dep::fonte`] field docstring already documents) treats as
2545    /// the "resolve through the configured default host / org
2546    /// (`github:<default-org>/<nome>`)" partition.
2547    ///
2548    /// The `:deps :fonte` / `:deps-dev :fonte` slot carries the two-
2549    /// arm typed [`DepSource`] the `Zig-style git-only store model` the
2550    /// enclosing [`Dep`] docstring names — `DepSource::Git { repo, tag,
2551    /// rev, branch }` for the git-clone arm every published caixa
2552    /// resolves through, `DepSource::Path { caminho }` for the dev-only
2553    /// local-filesystem arm every unpublishable in-tree checkout
2554    /// resolves through. Every downstream consumer that fans on the
2555    /// dep's fetch-source keys off this accessor: [`Self::validate`]'s
2556    /// per-`:fonte` [`DepSource::validate`] delegation (which raises
2557    /// the empty-`:repo` / missing-pin / multiple-pin / empty-`:caminho`
2558    /// diagnostics through the [`DepError::Fonte*`] carrier family
2559    /// naming the offending `Dep::nome`), the caixa-crd conversion
2560    /// crate's `dep_into_ref` two-arm projection into the `CaixaSource`
2561    /// `{repo, git_ref}` pair the K8s-CR side consumes
2562    /// (`caixa-crd/src/conversion.rs`), and — through the paired
2563    /// resolver-side default-fill's `Option::unwrap_or_else` — every
2564    /// `caixa-feira` / `caixa-resolver` fetch site that requires a
2565    /// concrete `DepSource` at run time.
2566    ///
2567    /// Prior to this lift the `.fonte` typed slot was read inline at
2568    /// every production site — the [`Self::validate`]
2569    /// `if let Some(ref fonte) = self.fonte` bracket the per-`:fonte`
2570    /// gate delegates through, the caixa-crd `dep_into_ref`
2571    /// `d.fonte.as_ref().and_then(...)` two-arm `CaixaSource` projector,
2572    /// the resolver-side `caixa-feira/src/cmd/lock.rs` / `caixa-resolver/src/resolve.rs`
2573    /// `dep.fonte.clone().unwrap_or_else(...)` default-fill pair — open-
2574    /// coded field-accesses that expressed no compile-time link back to
2575    /// the typed slot. A future extension of the `:deps :fonte` axis
2576    /// to a richer author surface (a per-scope source-override table
2577    /// the resolver folds through the `~/.config/caixa/config.yaml`
2578    /// entry the [`Dep`] docstring already acknowledges, a per-org
2579    /// mirror-fallback list the future M4 lacre-federation resolver
2580    /// consults ahead of the `default_github` fallback, a promotion of
2581    /// the plain `Option<DepSource>` to a richer
2582    /// `{primary, mirrors, integrity}` triple once cross-registry
2583    /// federation lands, a per-dep `sri:sha256-…` integrity slot the
2584    /// M4 lacre gate binds against ahead of the git-fetch) would have
2585    /// had to be threaded through every open-coded copy in lockstep or
2586    /// two consumers would silently disagree on which fetch source a
2587    /// given dep resolves to — the [`Self::validate`] per-`:fonte`
2588    /// gate reading the author-declared source while the caixa-crd
2589    /// projector read a per-scope-override-resolved source would
2590    /// silently split the build-time refusal from the CR the
2591    /// substrate's admission pipeline actually materializes, one
2592    /// build-time diagnostic disagreeing with the run-time closure.
2593    /// Lifting the resolution rule to a typed method on the substrate
2594    /// primitive means every downstream consumer of the caixa's per-
2595    /// `:deps` fetch-source surface reaches for exactly one typed
2596    /// dispatch — the resolver's accept-set migrates as a unit on any
2597    /// future axis addition.
2598    ///
2599    /// First outer-`Dep` `Option<&Composite>`-return composite-reference
2600    /// accessor — opens the outer-`Dep` `Option<&Composite>` composite-
2601    /// reference projection pattern the sibling per-`Dep` `:opcional`
2602    /// (`Option<Copy>` — the plain-bool axis) / `:caracteristicas`
2603    /// (`&[String]` — the feature-flag list) future outer scalar / slice
2604    /// lifts fold on. Peer of the outer-top-level [`crate::Caixa`]
2605    /// `Option<&Composite>` composite-reference sub-family the
2606    /// [`crate::Caixa::limits`] (b2bd9d7) / [`crate::Caixa::behavior`]
2607    /// (35d8b52) / [`crate::Caixa::politicas`] (5d23d29) /
2608    /// [`crate::Caixa::placement`] (4fb8074) / [`crate::Caixa::entrada`]
2609    /// (e4128e4) accessors already close on the outer [`crate::Caixa`]
2610    /// altitude, and of the outer M3 mesh-slot [`crate::AplicacaoSpec`]
2611    /// altitude the sibling [`crate::AplicacaoSpec::entrada`] (d32111c)
2612    /// accessor already carries — extends that "one typed dispatch on
2613    /// the substrate primitive, thin projections at each consumer"
2614    /// discipline onto the third outer typed-slot altitude that carries
2615    /// an `Option<Composite>` axis (`Dep`, the outer per-dep-list-entry
2616    /// slot). Returns `Option<&DepSource>` (not the owning composite by
2617    /// copy or clone) because every downstream consumer of the fonte
2618    /// composite treats it as a read-only per-arm dispatch source — the
2619    /// reference-view is the narrowest borrow that supports every
2620    /// present + roadmapped consumer (per-arm match projection at the
2621    /// caixa-crd `CaixaSource` two-arm emitter, presence-probe early
2622    /// return on the "author-omitted `:fonte` ⇒ resolver-side
2623    /// `default_github` fill applies" partition every resolver
2624    /// consults, `.cloned()`-on-demand for the two resolver-side
2625    /// default-fill call sites that require an owned `DepSource` for
2626    /// `Option::unwrap_or_else`) without cloning the composite through
2627    /// every consumer's fast path. The `Option` half of the return-type
2628    /// preserves the load-bearing "author-omitted `:fonte` ⇒ resolver-
2629    /// side default applies" partition (not a default composite the
2630    /// downstream must reject on emptiness) — the accessor projects the
2631    /// raw `Option<DepSource>` slot's presence bit through the
2632    /// reference-return unchanged. Named `fonte()` to match the storage
2633    /// field's name verbatim and the tatara-lisp author-surface term
2634    /// (`:fonte`) the field's own docstring already carries.
2635    ///
2636    /// Declared `pub const fn` — the body projects through
2637    /// `Option::<DepSource>::as_ref`, const-stable since Rust 1.83 and
2638    /// well within the workspace MSRV, so every downstream `const`-
2639    /// context consumer of the per-`Dep` `:fonte` composite-reference
2640    /// accessor reaches through the same typed dispatch on the
2641    /// substrate primitive at const-eval time as at runtime. The
2642    /// paired [`dep_outer_accessor_family_is_const_fn`][pin] pin
2643    /// (a `const fn <name>_via_const_fn(d: &Dep) -> …` wrapper family
2644    /// that forwards through each lifted accessor) locks the posture
2645    /// load-bearing at caixa-core build time — any future accidental
2646    /// downgrade to non-`const` fails the wrapper with E0015
2647    /// (`cannot call non-const method`), strictly stronger than a
2648    /// runtime `assert!` and side-stepping the destructor-in-const
2649    /// restriction the `Dep` fixture's `String` / `Option<DepSource>`
2650    /// / `Vec<String>` carriers rule out. Peer of the sibling per-
2651    /// `WitContract` pre-projection accessor family's `const`-eval-
2652    /// surface pass (279823b) and of the outer-`Caixa` slice-return
2653    /// accessor family's parallel pass (231a968) — same "one canonical
2654    /// dispatch per axis, `const`-eval posture pinned at the substrate
2655    /// primitive, thin projections at each consumer" discipline
2656    /// extended onto the outer per-dep-list-entry [`Dep`] altitude.
2657    ///
2658    /// [pin]: tests::dep_outer_accessor_family_is_const_fn
2659    #[must_use]
2660    pub const fn fonte(&self) -> Option<&DepSource> {
2661        self.fonte.as_ref()
2662    }
2663
2664    /// Substrate-canonical per-`:deps` / `:deps-dev` entry
2665    /// `:caracteristicas` Cargo-shaped feature-toggle-set slice accessor
2666    /// every consumer of the dep-graph feature-flag axis keys off —
2667    /// returns the author-declared `:caracteristicas` feature-name list
2668    /// verbatim as a `&[String]` slice-view over the same backing buffer
2669    /// the raw `self.caracteristicas.as_slice()` field access borrows
2670    /// from. Empty-list-carrying (`:caracteristicas` is a default-empty
2671    /// axis every `Dep` supplies with `Vec::new()` when the author omits
2672    /// the slot; the [`crate::Caixa::from_lisp`] derive folds an omitted
2673    /// `:caracteristicas` through `#[serde(default)]` to `Vec::new()`,
2674    /// so a `Dep` past parse definitionally carries a `Vec<String>` slot
2675    /// — possibly empty — and the returned `&[String]` degenerates to
2676    /// an empty slice on that arm without any silent `None` collapse).
2677    ///
2678    /// The `:deps :caracteristicas` / `:deps-dev :caracteristicas` slot
2679    /// carries the set-shaped feature-toggle list the substrate walks
2680    /// through the [`Self::validate_caracteristicas`] per-entry shape +
2681    /// duplicate cascade — same Cargo `[dependencies.<dep>.features]`
2682    /// accept-set (per-entry Cargo-feature-name grammar via the shared
2683    /// [`crate::render::is_cargo_feature_name`] predicate, cross-entry
2684    /// uniqueness via the shared [`crate::render::insert_first_seen`]
2685    /// walk, empty-first / value-shape-second / duplicate-third
2686    /// precedence via the peer per-axis two-arm cascade discipline every
2687    /// substrate-blessed Vec-keyed-by-name slot already follows).
2688    /// Every downstream consumer that fans on the dep's feature-toggle
2689    /// keys off this accessor: [`Self::validate_caracteristicas`]'s
2690    /// per-entry linear walk that gates each feature-name byte-string
2691    /// through the empty / value-shape / duplicate arms (raising the
2692    /// [`DepError::CaracteristicaEmpty`] / [`DepError::CaracteristicaInvalid`]
2693    /// / [`DepError::CaracteristicaDuplicate`] carrier family naming the
2694    /// offending `Dep::nome`), and every future
2695    /// per-`Caixa`-manifest / caixa-resolver / caixa-crd feature-toggle-
2696    /// facing consumer the CAIXA-SDLC §I roadmap acknowledges (the
2697    /// future caixa-resolver per-dep feature-projection walk that folds
2698    /// the toggle set into the resolved [`crate::Caixa`]'s activated
2699    /// [`crate::render::CARGO_FEATURE_NAME_MAX_LEN`]-bounded feature
2700    /// closure ahead of the lacre hash, the future caixa-crd per-`spec.deps`
2701    /// features slice the K8s-CR admission gate consumes, the future
2702    /// per-cluster feature-overlay the M4 lacre-federation resolver
2703    /// composes ahead of the substrate-wide feature-name accept-set).
2704    ///
2705    /// Prior to this lift the `.caracteristicas` byte-string list was
2706    /// read inline at the [`Self::validate_caracteristicas`] `for c in
2707    /// &self.caracteristicas` walk — the only in-crate consumer of the
2708    /// raw field beyond the per-`Dep` constructor pair
2709    /// ([`Self::simple`] / [`Self::git`]) and the paired serde
2710    /// round-trip / per-test fixture-mutation paths — an open-coded
2711    /// field-access that expressed no compile-time link back to the
2712    /// typed slot. A future extension of the `:caracteristicas` axis to
2713    /// a richer author surface (a per-scope feature-overlay the resolver
2714    /// folds through the `~/.config/caixa/config.yaml` entry the
2715    /// [`Dep`] docstring already acknowledges, a per-cluster feature-
2716    /// activation overlay the future M4 lacre-federation layer applies
2717    /// per-CR, a promotion of the plain `Vec<String>` byte-string list
2718    /// to a richer parsed-feature-set newtype once the Cargo-shaped
2719    /// namespaced-dep `dep/feat` syntax the value-shape gate's
2720    /// docstring anticipates lands) would have had to be threaded
2721    /// through every open-coded copy in lockstep or two consumers
2722    /// would silently disagree on which feature closure a given dep
2723    /// activates — the [`Self::validate_caracteristicas`] gate walking
2724    /// the author-declared list while a downstream caixa-resolver
2725    /// consumer walked a per-scope-override-resolved list would
2726    /// silently split the build-time refusal from the lacre closure
2727    /// the substrate's fetch pipeline actually materializes, one
2728    /// build-time diagnostic disagreeing with the run-time closure.
2729    /// Lifting the resolution rule to a typed method on the substrate
2730    /// primitive means every downstream consumer of the caixa's per-
2731    /// `:deps` feature-toggle surface reaches for exactly one typed
2732    /// dispatch — the resolver's accept-set migrates as a unit on any
2733    /// future axis addition.
2734    ///
2735    /// First outer-`Dep` `&[T]`-return slice accessor — opens the
2736    /// outer-`Dep` `&[String]` slice projection pattern the sibling
2737    /// per-`Dep` `:opcional` (`bool` — the plain-`Copy`-scalar axis)
2738    /// future outer scalar lift folds on and closes the outer-`Dep`
2739    /// slot-family the sibling [`Self::nome`] (eba2cde) /
2740    /// [`Self::versao_requirement`] (05529b1) / [`Self::fonte`] (d65d1bf)
2741    /// accessors already open, leaving the `:opcional` `Copy`-scalar arm
2742    /// as the sole remaining unlifted outer-`Dep` slot. Peer of the
2743    /// outer top-level [`crate::Caixa`] `&[String]`-return foreign-code-
2744    /// slot sub-family ([`crate::Caixa::bibliotecas`] 8a36c23,
2745    /// [`crate::Caixa::exe`] 65d9527, [`crate::Caixa::servicos`]
2746    /// 611f78b) and the outer top-level [`crate::Caixa`] universal-axis
2747    /// text-tag family ([`crate::Caixa::autores`] b5d813f,
2748    /// [`crate::Caixa::etiquetas`] 78c7d3c) that already carry the
2749    /// `&[String]` slice-projection discipline on the outer-`Caixa`
2750    /// altitude — extends the "one typed dispatch on the substrate
2751    /// primitive, thin projections at each consumer" discipline onto the
2752    /// outer per-dep-list-entry [`Dep`] altitude's set-shaped byte-
2753    /// string list slot. Returns `&[String]` (not `&Vec<String>`)
2754    /// because every downstream consumer of the feature-toggle list
2755    /// treats it as a read-only sequence — the slice-view is the
2756    /// narrowest borrow that supports every present + roadmapped
2757    /// consumer (`.iter()`, `.len()`, `.is_empty()`) without leaking
2758    /// the backing `Vec`'s grow/push/reserve surface no consumer of
2759    /// the typed view reaches for (the storage-side `Vec` remains
2760    /// reachable through the `pub caracteristicas` field for the
2761    /// mutation-carrying serde round-trip and per-test fixture-mutation
2762    /// paths). Named `caracteristicas()` to match the storage field's
2763    /// name verbatim and the tatara-lisp author-surface term
2764    /// (`:caracteristicas`) the field's own docstring already carries.
2765    ///
2766    /// Declared `pub const fn` — the body projects through
2767    /// `Vec::<String>::as_slice`, const-stable since Rust 1.83 and
2768    /// well within the workspace MSRV, so every downstream `const`-
2769    /// context consumer of the per-`Dep` `:caracteristicas` slice-
2770    /// accessor reaches through the same typed dispatch on the
2771    /// substrate primitive at const-eval time as at runtime. Pinned
2772    /// load-bearing by the paired
2773    /// [`dep_outer_accessor_family_is_const_fn`][pin] wrapper family
2774    /// alongside its sibling [`Self::fonte`] — see [`Self::fonte`] for
2775    /// the full pin-shape rationale.
2776    ///
2777    /// [pin]: tests::dep_outer_accessor_family_is_const_fn
2778    #[must_use]
2779    pub const fn caracteristicas(&self) -> &[String] {
2780        self.caracteristicas.as_slice()
2781    }
2782
2783    /// Substrate-canonical per-`:deps` / `:deps-dev` entry `:opcional`
2784    /// missing-source-tolerance flag scalar accessor every consumer of
2785    /// the dep-graph opt-in-fetch axis keys off — returns the author-
2786    /// declared `:opcional` `bool` verbatim, `Copy`-projected from the
2787    /// typed slot's own `bool` storage (no borrow of `&self` past the
2788    /// call; the `Copy`-return arm matches the peer
2789    /// [`crate::Caixa::max_restarts`] (eba5211) `Option<u32>` `Copy`-
2790    /// projected sibling discipline the outer flat-spread family
2791    /// already carries). Default-`false` (`#[serde(default,
2792    /// skip_serializing_if = "is_false")]` on the storage slot, so a
2793    /// `Dep` past parse definitionally carries a `bool` — `false` when
2794    /// the author omits `:opcional` — and the returned value degenerates
2795    /// to `false` on that arm without any silent `None` collapse).
2796    ///
2797    /// The `:deps :opcional` / `:deps-dev :opcional` slot carries the
2798    /// per-entry "if this dep's `:fonte` cannot be resolved, treat the
2799    /// missing-source arm as a soft-fail rather than a build refusal"
2800    /// bit — the same Cargo-shaped `[dependencies.<dep>.optional = true]`
2801    /// accept-set (an opcional dep whose `:fonte` fails to resolve is
2802    /// dropped from the resolved dep-graph rather than tripping the
2803    /// build-refusal edge that a mandatory `:opcional false` entry
2804    /// would). Every downstream consumer that fans on the dep's
2805    /// missing-source-tolerance keys off this accessor: the future
2806    /// caixa-resolver's per-`:fonte` resolve-fail arm (drop-vs-error
2807    /// dispatch on the opcional bit ahead of the lacre closure
2808    /// materialization), the future caixa-crd per-`spec.deps`
2809    /// `optional` boolean the K8s-CR admission gate consumes on the
2810    /// per-dep partition, and the future feira / caixa-resolver /
2811    /// caixa-crd feature-projection walk that folds the opcional bit
2812    /// into the resolved feature-closure the future M4 lacre-federation
2813    /// layer emits.
2814    ///
2815    /// Prior to this lift the `.opcional` `bool` slot was read inline
2816    /// at the sole in-crate consumer site — the tests-module
2817    /// `registry_dep_is_minimal` fixture's `assert!(!d.opcional)` gate
2818    /// pinning the [`Self::simple`] constructor's default-`false` fill
2819    /// (the only in-crate read of the raw field beyond the per-`Dep`
2820    /// constructor pair [`Self::simple`] / [`Self::git`] and the paired
2821    /// serde round-trip / per-test fixture-mutation paths) — an open-
2822    /// coded field-access that expressed no compile-time link back to
2823    /// the typed slot. A future extension of the `:opcional` axis to a
2824    /// richer author surface (a per-scope opcional-override the resolver
2825    /// folds through the `~/.config/caixa/config.yaml` entry the [`Dep`]
2826    /// docstring already acknowledges, a per-cluster opcional-override
2827    /// the future M4 lacre-federation layer applies per-CR, a promotion
2828    /// of the plain `bool` to a richer `OpcionalPolicy { drop, warn,
2829    /// error }` tri-state once the CAIXA-SDLC §II opcional-policy
2830    /// roadmap lands) would have had to be threaded through every open-
2831    /// coded copy in lockstep or two consumers would silently disagree
2832    /// on which missing-source arm a given dep resolves to — the
2833    /// [`Self::simple`] constructor's default-`false` fill reading
2834    /// verbatim while a downstream caixa-resolver consumer read a per-
2835    /// scope-override-resolved bit would silently split the build-time
2836    /// arm from the lacre closure the substrate's fetch pipeline
2837    /// actually materializes, one build-time diagnostic disagreeing
2838    /// with the run-time closure. Lifting the resolution rule to a
2839    /// typed method on the substrate primitive means every downstream
2840    /// consumer of the caixa's per-`:deps` opcional-tolerance surface
2841    /// reaches for exactly one typed dispatch — the resolver's accept-
2842    /// set migrates as a unit on any future axis addition.
2843    ///
2844    /// Fifth and final outer-`Dep` accessor — closes the outer-`Dep`
2845    /// slot-family the sibling per-`Dep` [`Self::nome`] (eba2cde) /
2846    /// [`Self::versao_requirement`] (05529b1) / [`Self::fonte`] (d65d1bf)
2847    /// / [`Self::caracteristicas`] (9197944) accessors opened, so every
2848    /// outer-`Dep` slot (`:nome`, `:versao`, `:fonte`, `:opcional`,
2849    /// `:caracteristicas`) now routes through exactly one typed
2850    /// dispatch on the substrate primitive. First outer-`Dep`
2851    /// `bool`-return / plain-`Copy`-scalar accessor — opens the
2852    /// outer-`Dep` `Copy`-scalar projection pattern that folds on the
2853    /// peer outer-top-level [`crate::Caixa`] `Option<Copy>`
2854    /// flat-spread sub-family ([`crate::Caixa::max_restarts`] eba5211,
2855    /// [`crate::Caixa::estrategia`] ed04d3c) the outer-`Caixa` altitude
2856    /// already carries — extends the "one typed dispatch on the
2857    /// substrate primitive, thin projections at each consumer"
2858    /// discipline onto the outer per-dep-list-entry [`Dep`] altitude's
2859    /// bool-shaped missing-source-tolerance slot. Returns `bool` by
2860    /// `Copy` (not by `&bool` reference) because `bool` is `Copy` and
2861    /// every downstream consumer treats it as a plain discriminant
2862    /// value — the by-value return is the narrowest return-shape that
2863    /// supports every present + roadmapped consumer (`.then(…)` early
2864    /// return on the resolver-side drop-vs-error partition, direct
2865    /// bool composition with a per-scope-override projector, plain
2866    /// `if dep.opcional() { … }` early return at every future admission
2867    /// gate) without leaking the storage field's `bool`-in-`&self`
2868    /// lifetime the by-value return elides. Marked `pub const fn` so
2869    /// the accessor is `const`-callable — same discipline the peer
2870    /// [`crate::Caixa::max_restarts`] `Option<u32>` `Copy`-return
2871    /// accessor carries. Named `opcional()` to match the storage
2872    /// field's name verbatim and the tatara-lisp author-surface term
2873    /// (`:opcional`) the field's own docstring already carries.
2874    #[must_use]
2875    pub const fn opcional(&self) -> bool {
2876        self.opcional
2877    }
2878
2879    /// Build a minimal registry-sourced dep.
2880    #[must_use]
2881    pub fn simple(nome: impl Into<String>, versao: impl Into<String>) -> Self {
2882        Self {
2883            nome: nome.into(),
2884            versao: versao.into(),
2885            fonte: None,
2886            opcional: false,
2887            caracteristicas: Vec::new(),
2888        }
2889    }
2890
2891    /// Build a Git-sourced dep (tag-based).
2892    #[must_use]
2893    pub fn git(
2894        nome: impl Into<String>,
2895        versao: impl Into<String>,
2896        repo: impl Into<String>,
2897        tag: impl Into<String>,
2898    ) -> Self {
2899        Self {
2900            nome: nome.into(),
2901            versao: versao.into(),
2902            fonte: Some(DepSource::Git {
2903                repo: repo.into(),
2904                tag: Some(tag.into()),
2905                rev: None,
2906                branch: None,
2907            }),
2908            opcional: false,
2909            caracteristicas: Vec::new(),
2910        }
2911    }
2912
2913    /// Reject dependency entries whose `:nome` or `:versao` are empty,
2914    /// whose `:nome` is non-empty but not a valid DNS-1123 label,
2915    /// or whose `:versao` is non-empty but not a valid Cargo-shaped
2916    /// semver requirement.
2917    ///
2918    /// The author surface for `:deps :versao` (and `:deps-dev :versao`)
2919    /// is the same Cargo-shaped requirement string `:membros :versao`
2920    /// (validated at [`crate::AplicacaoSpec::validate`] since 9888b13)
2921    /// and `:children :versao` (validated at
2922    /// [`crate::SupervisorSpec::validate`] since b38ff3a) carry — and
2923    /// the lacre pipeline resolves all three axes through the same
2924    /// [`crate::parse_requirement`] entry-point. Until 2420c44 landed
2925    /// `:deps :versao` was the last `:versao` axis untyped past
2926    /// `Caixa::from_lisp`: a malformed-but-non-empty requirement
2927    /// (`"^bad-version"`, `"^^0.1"`, the canonical git-tag-shape-
2928    /// leaking-into-:versao `"v0.1"` typo, the accidental
2929    /// `"not-a-req"`) silently passed parse and the `semver::Error`
2930    /// surfaced at lacre-resolve time, far from the source
2931    /// caixa.lisp, with no field naming which `:deps` entry carried
2932    /// the typo. The diagnostic [`DepError::VersaoInvalid`] carries
2933    /// the offending entry's `:nome` + the offending `:versao`
2934    /// verbatim + the parser's own wording in `reason`, so the
2935    /// author's grep target is unambiguous.
2936    ///
2937    /// The author surface for `:deps :nome` is the same DNS-1123 label
2938    /// the peer caixa-identifier axes carry — top-level Caixa `:nome`
2939    /// (validated at [`crate::Caixa::validate_nome`] since 6c992f8),
2940    /// `:membros :caixa` (validated at
2941    /// [`crate::AplicacaoSpec::validate_membros`] since 3f9d7a0),
2942    /// `:children :caixa` (validated at
2943    /// [`crate::SupervisorSpec::validate`] since 31bfa43). A `:deps
2944    /// :nome` value flows verbatim through the lacre pipeline as the
2945    /// target caixa's `:nome` (which the gate at the *target* side now
2946    /// rejects if non-DNS-1123) and lands as the rendered caixa's
2947    /// `lareira-<nome>` Helm chart name segment, the per-dep
2948    /// `LABEL_PROGRAM` label value, and the `caixa-resolver`'s
2949    /// `~/.cache/caixa/<org>/<nome>` checkout-directory leaf. Until
2950    /// this gate landed `:deps :nome` was the fourth and last
2951    /// DNS-1123-shaped caixa-identifier axis still untyped past
2952    /// `Caixa::from_lisp`: a syntactically wrong dep name (`"Caixa-
2953    /// Teia"` uppercase — the canonical "I copied the README header"
2954    /// typo; `"caixa_teia"` underscore — the Go module / Python
2955    /// identifier leak; `"caixa-teia."` trailing dot — the FQDN
2956    /// confusion; `"-caixa-teia"` leading hyphen; a 64-byte slug)
2957    /// silently passed parse and surfaced at lacre-resolve time when
2958    /// the resolved target caixa's `:nome` failed *its* DNS-1123 gate
2959    /// — far from the source `:deps` entry, with a diagnostic naming
2960    /// the *target's* `:nome` rather than the dep entry that referenced
2961    /// it. Mirroring the 3f9d7a0 / 31bfa43 / 6c992f8 trajectory through
2962    /// the lifted [`crate::render::is_dns_1123_label`] predicate (the
2963    /// "before its third occurrence" PRIME DIRECTIVE boundary, THEORY.md
2964    /// §I.3.5): every `Dep::nome` past validate is DNS-1123-label-shaped,
2965    /// so every downstream consumer (caixa-resolver's lacre fetch,
2966    /// caixa-helm's `lareira-<nome>` chart name, the future M4 per-dep
2967    /// fan-out emitter) reaches for the name knowing the value is
2968    /// apiserver-valid without re-validating.
2969    ///
2970    /// Empty checks fire first (narrower diagnostic), parse last —
2971    /// same ordering discipline as
2972    /// [`crate::AplicacaoSpec::validate_membros`] and
2973    /// [`crate::SupervisorSpec::validate`]. `parse_requirement("")`
2974    /// returns `Ok(VersionReq::STAR)`, so the empty-`:versao` arm is
2975    /// structurally necessary even with the parse arm in place. The
2976    /// `:nome` shape gate runs after the `:nome` empty gate and before
2977    /// the `:versao` checks so a one-entry caixa.lisp with both wrong
2978    /// sees the name-side diagnostic first (the name is the
2979    /// self-locating axis — without it, the parse diagnostic can't
2980    /// quote `:nome "<bad>"`).
2981    pub fn validate(&self) -> Result<(), DepError> {
2982        if self.nome.is_empty() {
2983            return Err(DepError::NomeEmpty);
2984        }
2985        if let Err(reason) = crate::render::is_dns_1123_label(&self.nome) {
2986            return Err(DepError::NomeInvalid {
2987                nome: self.nome.clone(),
2988                reason,
2989            });
2990        }
2991        // Delegate the empty-first + `parse_requirement` cascade to the
2992        // shared [`crate::render::require_valid_versao_requirement`]
2993        // helper — same two-arm shape the peer
2994        // [`crate::AplicacaoSpec::validate_membros`] on `:membros
2995        // :versao` and [`crate::SupervisorSpec::validate`] on `:children
2996        // :versao` route through, so drift between the three axes'
2997        // accepted requirement sets is structurally impossible and the
2998        // parse-side no-op the empty-first arm closes (semver's empty
2999        // parse yields an implicit `*`) lives in exactly one predicate.
3000        crate::render::require_valid_versao_requirement(
3001            self.versao_requirement(),
3002            || DepError::versao_empty(&self.nome),
3003            |reason| DepError::VersaoInvalid {
3004                nome: self.nome.clone(),
3005                versao: self.versao_requirement().to_string(),
3006                reason,
3007            },
3008        )?;
3009        if let Some(fonte) = self.fonte() {
3010            fonte.validate(&self.nome)?;
3011        }
3012        self.validate_caracteristicas()?;
3013        Ok(())
3014    }
3015
3016    /// Reject per-entry `:caracteristicas` (feature-flag) values that
3017    /// are operationally meaningless. The `:caracteristicas` slot is
3018    /// a set of feature toggles to enable on the target caixa — same
3019    /// shape as Cargo's `[dependencies.<dep>.features]` list — and
3020    /// two structural footguns close here:
3021    ///
3022    ///   - empty-string entry (`(:caracteristicas (""))`): the future
3023    ///     caixa-resolver lacre pipeline would consume the empty
3024    ///     identifier as a no-op feature enable, silently dropping the
3025    ///     author's intent far from the source `caixa.lisp`;
3026    ///   - duplicate entry within one dep (`(:caracteristicas ("http"
3027    ///     "http"))`): the feature-toggle slot is set-shaped (enabling
3028    ///     a feature twice has no additional semantic — there is no
3029    ///     `feature × 2`), so two entries naming the same feature are
3030    ///     a silent miscount, the same set-not-multiset distinction
3031    ///     every peer Vec-keyed-by-name axis already closes
3032    ///     ([`crate::SupervisorError::DuplicateChildCaixa`] on
3033    ///     `:children :caixa`, [`crate::AplicacaoError::MembroDuplicate`]
3034    ///     on `:membros :caixa`, [`crate::AplicacaoError::ContratoDuplicate`]
3035    ///     on `:contratos`, [`crate::AplicacaoError::PlacementClusterDuplicate`]
3036    ///     on `:placement :clusters`, [`crate::AplicacaoError::EntradaPathDuplicate`]
3037    ///     on `:entrada :paths`, [`crate::UpgradeError::DuplicateFrom`]
3038    ///     on `:upgrade-from :from`, [`crate::UpgradeError::DuplicateLoadModule`]
3039    ///     / [`crate::UpgradeError::DuplicateStateChange`] /
3040    ///     [`crate::UpgradeError::DuplicateCleanup`] on the within-
3041    ///     entry `:upgrade-from` axes, and [`DepError::DuplicateNome`]
3042    ///     on the cross-entry `:deps`/`:deps-dev` `:nome` axis the
3043    ///     immediate-predecessor 359fba5 closed).
3044    ///
3045    /// Same linear-walk + `HashSet` + first-collision diagnostic shape
3046    /// every peer set-not-multiset gate uses; the empty arm fires
3047    /// before the duplicate arm so an entry with both an empty feature
3048    /// *and* a duplicate of some later feature surfaces the empty-
3049    /// shape diagnostic first (the empty-feature axis is the
3050    /// more-actionable defect since the missing-name renders the
3051    /// duplicate-key arm ambiguous: two `""` entries would both report
3052    /// `caracteristica: ""` with no way to distinguish the offending
3053    /// site). Empty-first cascade discipline mirrors every peer per-
3054    /// entry shape + duplicate gate
3055    /// (`SupervisorSpec::validate`'s `EmptyChildName` before
3056    /// `DuplicateChildCaixa`; `validate_membros`'s `MembroCaixaEmpty`
3057    /// before `MembroDuplicate`).
3058    ///
3059    /// The per-entry value-shape gate (Cargo-feature-name grammar via
3060    /// the lifted [`crate::render::is_cargo_feature_name`] predicate)
3061    /// fires between the empty arm and the duplicate arm — the
3062    /// canonical per-entry-shape-before-cross-entry-uniqueness
3063    /// precedence every peer two-arm + value-shape gate establishes
3064    /// ([`crate::SupervisorSpec::validate`]'s `EmptyChildName` →
3065    /// `ChildCaixaInvalid` → `DuplicateChildCaixa`,
3066    /// [`crate::AplicacaoSpec::validate_membros`]'s `MembroCaixaEmpty`
3067    /// → `MembroCaixaInvalid` → `MembroDuplicate`, [`Dep::validate`]'s
3068    /// `NomeEmpty` → `NomeInvalid` → cross-list `DuplicateNome`).
3069    /// Until the value-shape arm landed `:caracteristicas` accepted
3070    /// every non-empty distinct string — a structurally invalid
3071    /// feature name (`"http feature"` whitespace, `"+http"` the
3072    /// canonical paste-from-`+optional-feature` doc activation-form
3073    /// footgun, `"-flag"` leading hyphen, `".feat"` leading dot,
3074    /// `"http/json"` Cargo's `dep/feat` namespaced-dep syntax that
3075    /// only applies inside list-grammar contexts, `"http,json"`
3076    /// list-separator-belongs-to-the-list-grammar miscomprehension,
3077    /// `"café"` un-percent-encoded non-ASCII silently round-tripping
3078    /// inconsistently across NFC/NFD normalization, the 65-byte
3079    /// paste-from-binary slug) silently passed validate and the
3080    /// failure surfaced at `cargo metadata` time as the
3081    /// `restricted_names::validate_feature_name` parser's rejection,
3082    /// far from the source `caixa.lisp`, with no field naming which
3083    /// `:deps` entry's `:caracteristicas` carried the typo. The
3084    /// lifted predicate makes the Cargo-feature-name-grammar
3085    /// intersection-floor a substrate-level invariant at validate
3086    /// time — same trajectory as the eight peer
3087    /// [`crate::render`] value-shape predicates each typed surface
3088    /// downstream of a structured grammar already follows
3089    /// ([`is_dns_1123_label`](crate::render::is_dns_1123_label),
3090    /// [`is_gateway_api_http_path`](crate::render::is_gateway_api_http_path),
3091    /// [`is_wit_world_ref`](crate::render::is_wit_world_ref),
3092    /// [`is_nats_subject`](crate::render::is_nats_subject),
3093    /// [`is_wasi_keyvalue_slot`](crate::render::is_wasi_keyvalue_slot),
3094    /// [`is_git_ref_name`](crate::render::is_git_ref_name),
3095    /// [`is_git_oid`](crate::render::is_git_oid),
3096    /// [`is_git_repo_url`](crate::render::is_git_repo_url)).
3097    fn validate_caracteristicas(&self) -> Result<(), DepError> {
3098        let mut seen = std::collections::HashSet::new();
3099        for c in self.caracteristicas() {
3100            if c.is_empty() {
3101                return Err(DepError::caracteristica_empty(&self.nome));
3102            }
3103            if let Err(reason) = crate::render::is_cargo_feature_name(c) {
3104                return Err(DepError::CaracteristicaInvalid {
3105                    nome: self.nome.clone(),
3106                    caracteristica: c.clone(),
3107                    reason,
3108                });
3109            }
3110            crate::render::insert_first_seen(&mut seen, c.as_str(), || {
3111                DepError::CaracteristicaDuplicate {
3112                    nome: self.nome.clone(),
3113                    caracteristica: c.clone(),
3114                }
3115            })?;
3116        }
3117        Ok(())
3118    }
3119}
3120
3121/// Cross-slot coherence gate on the dep-graph axis: no `:deps` or
3122/// `:deps-dev` entry may name the caixa's own `:nome`.
3123///
3124/// A caixa that lists itself as a dep is a degenerate self-edge in the
3125/// lacre closure's dep-graph — the closure is a DAG rooted at the
3126/// caixa's `:nome`, and the caixa-resolver's lacre pipeline traverses
3127/// every `:deps` / `:deps-dev` entry's target by name. A self-dep
3128/// hands the resolver a node that is its own parent: a one-node cycle
3129/// it either rejects mid-traversal far from the source `caixa.lisp`
3130/// (the resolver detecting infinite recursion on the closure walk) or,
3131/// worse, recurses on until it exhausts its stack. Because every
3132/// `:nome` is a globally-unique substrate identity (DNS-1123 label +
3133/// lacre closure root), a dep entry whose `:nome` equals the caixa's
3134/// own `:nome` *is* the caixa itself, not a coincidentally-named peer.
3135///
3136/// Lives outside [`Caixa::validate_deps`] because the dep-list view
3137/// carries the entries but not the parent `:nome`; mirrors the
3138/// cross-slot self-edge gates [`crate::supervisor::validate_no_self_supervision`]
3139/// (ad4abf1) on the `:children :caixa` axis and
3140/// [`crate::aplicacao::validate_no_self_membership`] on the
3141/// `:membros :caixa` axis — the same "an edge from a graph node to
3142/// itself is structurally not a tree/graph edge" discipline, here on
3143/// the third typed-name-graph axis (the dep closure; the supervision
3144/// tree and the Aplicacao membership set were the prior two).
3145///
3146/// Walks `:deps` first then `:deps-dev` so the diagnostic for a caixa
3147/// that self-references on both axes surfaces the `:deps` arm first —
3148/// the load-bearing axis the lacre closure resolves at every build,
3149/// peer with the canonical [`Caixa::validate_deps`] walk order
3150/// (`:deps` → `:deps-dev`).
3151///
3152/// Carries the offending list tag (`":deps"` or `":deps-dev"`)
3153/// verbatim into the diagnostic so the author can grep their
3154/// `caixa.lisp` for the offending block in one edit — same
3155/// `list: &'static str` shape [`DepError::DuplicateNome`] (359fba5)
3156/// uses on the cross-list duplicate-name axis.
3157///
3158/// `Code paths` (`:bibliotecas` / `:exe` / `:servicos`) are the
3159/// substrate-blessed shape for referencing the caixa's *own* code, so
3160/// the diagnostic names them as the corrective surface — every
3161/// legitimate "I want to use code from this caixa" authoring intent
3162/// routes through one of those three slots, not a self-dep.
3163pub fn validate_no_self_dep(
3164    deps: &[Dep],
3165    deps_dev: &[Dep],
3166    parent_nome: &str,
3167) -> Result<(), DepError> {
3168    for dep in deps {
3169        if dep.nome() == parent_nome {
3170            return Err(DepError::dep_is_self(
3171                parent_nome,
3172                crate::render::DEP_AUTHOR_KEY_DEPS,
3173            ));
3174        }
3175    }
3176    for dep in deps_dev {
3177        if dep.nome() == parent_nome {
3178            return Err(DepError::dep_is_self(
3179                parent_nome,
3180                crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
3181            ));
3182        }
3183    }
3184    Ok(())
3185}
3186
3187/// Closed-set typed enum for the two dep-list author-surface axes every
3188/// top-level [`crate::Caixa`] carries — the runtime-closure `:deps` slot
3189/// (`Prod`) and the dev-only-closure `:deps-dev` slot (`Dev`). Every
3190/// substrate consumer that dispatches on "which of the two dep-lists"
3191/// (the `feira add` mutation head, the future per-cluster dev-closure-
3192/// audit overlay the M4 CR materializer resolves per-CR, the future
3193/// `caixa app graph` per-list dep summary, every future
3194/// `Caixa::push_dep` / `Caixa::deps_by_list` typed-method dispatch a
3195/// caller reaches for) reads through this enum rather than through a
3196/// bare `&'static str` — the closed-set is expressed at the type layer,
3197/// so a future third dep-list axis (a `:deps-build` build-only closure
3198/// once the substrate grows cross-artifact heterogeneous dep-graphs,
3199/// per CAIXA-SDLC §I) is one variant plus one arm per method and the
3200/// compiler enforces exhaustiveness on every consumer's `match` arms.
3201///
3202/// The wire byte-string [`Self::as_str`] returns is the same author-
3203/// surface tag the sibling [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3204/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] constants carry — the
3205/// [`DepError::DuplicateNome`] / [`DepError::DepIsSelf`] `list:
3206/// &'static str` payload family the substrate already emits routes
3207/// through the same source of truth (an author reading a
3208/// [`DepError::DuplicateNome`] refusal can grep their `caixa.lisp`
3209/// for the offending `:deps` / `:deps-dev` block in one edit whether
3210/// the diagnostic came from a `Caixa::validate_deps` walk or a
3211/// `Caixa::push_dep` mutation).
3212///
3213/// Same "closed-set typed-enum discriminator with canonical
3214/// projections per axis" discipline the sibling closed-set typed enums
3215/// on the caixa typed surface carry
3216/// ([`crate::aplicacao::PlacementStrategy`] cc8f749,
3217/// [`crate::aplicacao::RateLimitUnit`] 6bce03d,
3218/// [`crate::supervisor::RestartStrategy`],
3219/// [`crate::supervisor::RestartPolicy`],
3220/// [`crate::upgrade::UpgradeInstruction`], [`crate::CaixaKind`])
3221/// — extended onto the outer-`Caixa` two-list dep-graph axis, the
3222/// substrate's last unlifted closed-set-shaped `&'static str`-carrying
3223/// axis on the top-level manifest surface.
3224#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, gen_platform::IsVariant)]
3225pub enum DepList {
3226    /// Runtime-closure `:deps` axis — the load-bearing dep-list the
3227    /// lacre closure resolves at every build. Wire-format
3228    /// [`crate::render::DEP_AUTHOR_KEY_DEPS`].
3229    Prod,
3230    /// Dev-only-closure `:deps-dev` axis — Cargo's `[dev-dependencies]`
3231    /// table's dev-time-only visibility contract per CAIXA-SDLC §I.
3232    /// Wire-format [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`].
3233    Dev,
3234}
3235
3236impl DepList {
3237    /// Exhaustive iteration surface for every consumer that reads the
3238    /// full closed-set (the future M4 admission webhook's per-list
3239    /// summary rejection body, any future round-trip pin harness). A
3240    /// future variant addition extends this slice as a single edit and
3241    /// every consumer picks up the new entry by construction — the
3242    /// compiler-checked exhaustiveness on the sibling method `match`
3243    /// arms is the build-time guarantee that no arm forgets to grow.
3244    pub const ALL: &'static [Self] = &[Self::Prod, Self::Dev];
3245
3246    /// Canonical author-surface tag every substrate consumer that
3247    /// names the offending dep-list in a diagnostic reaches for —
3248    /// [`crate::render::DEP_AUTHOR_KEY_DEPS`] for [`Self::Prod`] and
3249    /// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] for [`Self::Dev`],
3250    /// the same `&'static str` payload the sibling
3251    /// [`DepError::DuplicateNome`] and [`DepError::DepIsSelf`] variants
3252    /// already carry. Routing every dep-list diagnostic through the
3253    /// closed-set enum's `as_str` closes the last `&'static str`-shape
3254    /// literal-carry axis on the two-list dep-graph surface — a
3255    /// future kebab-case rebrand (`":deps"` → `":packages"`) or a
3256    /// wire-format promotion (a distinct diagnostic form for the
3257    /// `Dev` arm) reaches every consumer through one edit on the
3258    /// canonical constant, not a coordinated rewrite across the
3259    /// substrate's dep-graph consumers.
3260    #[must_use]
3261    pub const fn as_str(self) -> &'static str {
3262        match self {
3263            Self::Prod => crate::render::DEP_AUTHOR_KEY_DEPS,
3264            Self::Dev => crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
3265        }
3266    }
3267
3268    /// Substrate-canonical reverse projection on the two-list dep-graph
3269    /// axis — parses the author-surface wire tag back to the typed
3270    /// variant, or `None` when `s` is outside the closed-set arm-string
3271    /// set [`Self::as_str`] emits. Dispatches on the same lifted
3272    /// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3273    /// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] constants the
3274    /// [`Self::as_str`] emitter walks, so the parse and emit halves of
3275    /// the round-trip migrate through one caixa-core edit on any future
3276    /// list-axis addition.
3277    ///
3278    /// Prior to this lift the substrate carried only the forward
3279    /// `Self → &str` projection on the two-list dep-graph axis (the
3280    /// [`Self::as_str`] emitter, the [`std::fmt::Display`] impl routed
3281    /// through it, the two [`DepError::DuplicateNome`] /
3282    /// [`DepError::DepIsSelf`] variants that carry the wire tag verbatim
3283    /// as a `&'static str` `list:` field). Every future consumer that
3284    /// wanted to promote the wire tag back to the typed enum (a future
3285    /// `feira dep --list <deps|deps-dev>` CLI arg-parse that binds the
3286    /// wire form into the typed enum before dispatching to
3287    /// [`crate::Caixa::deps_of`] / [`crate::Caixa::push_dep`], the M4
3288    /// `mesh.pleme.io/v1alpha1/Caixa` CR materializer's admission-time
3289    /// wire re-parse of the per-list diagnostic body, a future
3290    /// [`DepError`] widening that promotes the two `list: &'static str`
3291    /// fields to a typed `list: DepList` carry so downstream consumers
3292    /// dispatch on the enum rather than string-comparing the wire
3293    /// scalar) would have had to re-inline a two-arm `match s { ":deps"
3294    /// => …, ":deps-dev" => …, _ => … }` cascade that expressed no
3295    /// compile-time link back to the typed [`DepList`] enum. A future
3296    /// variant addition (a `:build-dep` or `:test-dep` third list once
3297    /// the substrate grows Cargo-style split-graphs, a `:tool-dep` for
3298    /// build-time-only tooling per the peer Cargo `[build-dependencies]`
3299    /// / `[target.<cfg>.dev-dependencies]` future admission surface)
3300    /// would silently split the wire byte-string the emitter walks from
3301    /// the parser's arm-set — the round-trip would carry the new list
3302    /// through the forward projection but land on the fallback silently
3303    /// at every non-updated reverse parser, far from the arm-addition
3304    /// commit that caused the drift. Lifting the resolver to a typed
3305    /// method on the substrate primitive closes the drift footgun by
3306    /// construction: the parser's accept-set is the same set the
3307    /// [`Self::as_str`] emitter walks (routed through the same lifted
3308    /// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3309    /// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] consts), so both halves
3310    /// of the round-trip migrate through one caixa-core edit on any
3311    /// future list-axis addition.
3312    ///
3313    /// Same closed-set-reverse-projection discipline the sibling
3314    /// [`crate::CaixaKind::from_wire`] (2aa6d23) /
3315    /// [`crate::supervisor::RestartStrategy::from_wire`] (4eec29c) /
3316    /// [`crate::supervisor::RestartPolicy::from_wire`] (dd32ccf) /
3317    /// [`crate::aplicacao::PlacementStrategy::from_wire`] (18c7342) /
3318    /// [`crate::aplicacao::RateLimitUnit::from_suffix`] typed enums
3319    /// carry on the peer wire-side `str → Self` axes — extended onto
3320    /// the two-list dep-graph closed-set axis, the sixth substrate-side
3321    /// closed-set typed enum on the caixa surface to converge on the
3322    /// two-way `str ↔ Self` round-trip. Method-named `from_wire` (not
3323    /// `from_str`) to match the peer shapes verbatim and side-step the
3324    /// derived [`std::str::FromStr`] impls the sibling
3325    /// [`gen_platform::FromStrKind`]-carrying axes install on their
3326    /// kebab-case dispatcher-catalog identity. Returns `Option<Self>`
3327    /// (rather than `Result<Self, _>`) to match the peer shapes: the
3328    /// caller picks the diagnostic form appropriate for its use site —
3329    /// a future `feira dep --list …` arg-parse that surfaces
3330    /// `unknown list: <arg>` at the CLI builds one on top by iterating
3331    /// [`Self::ALL`], while the future M4 admission-webhook's rejection
3332    /// path folds `None` onto its per-CR structured refusal body.
3333    #[must_use]
3334    pub fn from_wire(s: &str) -> Option<Self> {
3335        match s {
3336            crate::render::DEP_AUTHOR_KEY_DEPS => Some(Self::Prod),
3337            crate::render::DEP_AUTHOR_KEY_DEPS_DEV => Some(Self::Dev),
3338            _ => None,
3339        }
3340    }
3341}
3342
3343/// Route [`std::fmt::Display`] through [`DepList::as_str`], so every
3344/// consumer that formats the axis as user-facing text (a future
3345/// `feira app graph` per-list summary, a future M4 admission-webhook
3346/// rejection body naming the offending list, this crate's own
3347/// [`DepError`] `#[error(...)]` templates when they widen to carry a
3348/// typed [`DepList`]) lands on the same author-surface tag the
3349/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3350/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] constants carry. Same
3351/// as-str-through-Display convergence discipline the sibling
3352/// [`crate::aplicacao::PlacementStrategy`],
3353/// [`crate::aplicacao::RateLimitUnit`],
3354/// [`crate::supervisor::RestartStrategy`],
3355/// [`crate::supervisor::RestartPolicy`], and [`crate::CaixaKind`]
3356/// closed-set typed enums carry.
3357impl std::fmt::Display for DepList {
3358    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3359        f.write_str(self.as_str())
3360    }
3361}
3362
3363/// Errors raised by [`Dep::validate`].
3364///
3365/// Mirrors the per-axis error families the other `:versao`-carrying
3366/// typed surfaces expose
3367/// ([`crate::AplicacaoError::MembroVersaoEmpty`] /
3368/// [`crate::AplicacaoError::MembroVersaoInvalid`],
3369/// [`crate::SupervisorError::EmptyChildVersion`] /
3370/// [`crate::SupervisorError::ChildVersaoInvalid`]) so a future top-
3371/// level `CaixaError` (M4) sums these without reshaping the diagnostic.
3372#[derive(Debug, Error, PartialEq, Eq)]
3373pub enum DepError {
3374    #[error(
3375        ":deps entry has empty :nome (every dep must name a target caixa; \
3376         omit the entry instead of carrying an empty name)"
3377    )]
3378    NomeEmpty,
3379    #[error(
3380        ":deps entry :nome {nome:?} is not a valid DNS-1123 label: {reason} \
3381         (the value flows verbatim as the target caixa's `:nome`, the rendered \
3382         `lareira-<nome>` Helm chart name segment, the `LABEL_PROGRAM` label \
3383         value, and the resolver's checkout-directory leaf — each apiserver-side \
3384         schema rejects non-DNS-1123 names at admission time; use a lowercase \
3385         RFC 1123 label like `\"caixa-teia\"` or `\"pleme-mesh\"`, 1..=63 bytes, \
3386         pattern `^[a-z0-9]([-a-z0-9]*[a-z0-9])?$`)"
3387    )]
3388    NomeInvalid { nome: String, reason: String },
3389    #[error(
3390        ":deps entry {nome:?} has empty :versao (every dep must pin a semver \
3391         constraint that resolves through the lacre pipeline)"
3392    )]
3393    VersaoEmpty { nome: String },
3394    #[error(
3395        ":deps entry {nome:?} :versao {versao:?} is not a valid semver \
3396         requirement: {reason} (use Cargo-shaped forms like `\"^0.1\"`, \
3397         `\"~0.1.2\"`, `\"0.1.0\"`, or `\"*\"` — the same shape `:membros :versao` \
3398         and `:children :versao` carry; the lacre pipeline resolves all three \
3399         through the same parser)"
3400    )]
3401    VersaoInvalid {
3402        nome: String,
3403        versao: String,
3404        reason: String,
3405    },
3406    #[error(
3407        ":deps entry {nome:?} :fonte (:tipo git …) has empty :repo \
3408         (every git source must name a repo — use a `github:org/repo` \
3409         shorthand, an `https://…` URL, or an ssh-git URL; omit the \
3410         entire :fonte block to fall back to the default-host resolver \
3411         convention)"
3412    )]
3413    FonteRepoEmpty { nome: String },
3414    #[error(
3415        ":deps entry {nome:?} :fonte (:tipo git …) :repo {repo:?} has \
3416         invalid value-shape: {reason} (the value flows verbatim into the \
3417         caixa-resolver's `git clone <repo>` subprocess invocation; every \
3418         documented form carries a `:` separator and no whitespace / \
3419         control / non-ASCII bytes — use a `github:org/repo` shorthand, \
3420         an `https://host/path` / `ssh://[user@]host/path` / \
3421         `git://host/path` / `file:///path` URL, or the `git@host:path` \
3422         scp-style SSH form)"
3423    )]
3424    FonteRepoShape {
3425        nome: String,
3426        repo: String,
3427        reason: String,
3428    },
3429    #[error(
3430        ":deps entry {nome:?} :fonte (:tipo git …) has no pin set \
3431         (set exactly one of :tag, :rev, or :branch so the resolver \
3432         can pick a reproducible commit; omit the entire :fonte block \
3433         to fall back to the default-host resolver convention, which \
3434         resolves the latest tag matching :versao)"
3435    )]
3436    FontePinMissing { nome: String },
3437    #[error(
3438        ":deps entry {nome:?} :fonte (:tipo git …) has multiple pins \
3439         set ({pins}); exactly one of :tag, :rev, or :branch must be \
3440         set so the resolver's checkout target is unambiguous (the \
3441         resolver's silent precedence is :rev > :tag > :branch — if \
3442         you intended one specifically, drop the others)"
3443    )]
3444    FontePinAmbiguous { nome: String, pins: String },
3445    #[error(
3446        ":deps entry {nome:?} :fonte (:tipo git …) has empty {pin} \
3447         (a set pin must name a non-empty git ref; drop the {pin} key \
3448         entirely to fall through to another pin axis)"
3449    )]
3450    FontePinEmpty { nome: String, pin: String },
3451    #[error(
3452        ":deps entry {nome:?} :fonte (:tipo git …) {pin} {value:?} has invalid \
3453         value-shape: {reason} (the git porcelain enforces the same shape at \
3454         `git fetch` / `git checkout` time on every pin; use a leaf refname \
3455         like `\"v0.1.0\"` for `:tag` or `\"main\"` / `\"feature/foo\"` for \
3456         `:branch`, or a full 40/64 lowercase-hex commit OID for `:rev` — \
3457         drop any `refs/heads/` or `refs/tags/` prefix the caixa-resolver \
3458         prepends at clone time, and avoid abbreviated SHAs which are \
3459         ambiguous across repository history)"
3460    )]
3461    FontePinShape {
3462        nome: String,
3463        pin: String,
3464        value: String,
3465        reason: String,
3466    },
3467    #[error(
3468        ":deps entry {nome:?} :fonte (:tipo path …) has empty :caminho \
3469         (every path source must name a non-empty filesystem path; \
3470         omit the entire :fonte block to fall back to the default-host \
3471         resolver convention)"
3472    )]
3473    FonteCaminhoEmpty { nome: String },
3474    #[error(
3475        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} is \
3476         absolute (the lacre pipeline embeds the value verbatim in its \
3477         per-dep content-address `path:{caminho}` at \
3478         caixa-resolver/src/resolve.rs:189, so an absolute path makes the \
3479         BLAKE3 closure differ across machines — defeating the \
3480         reproducibility contract that's load-bearing for CSE; express \
3481         the path relative to the caixa.lisp location, e.g. \
3482         \"../caixa-teia\" for a sibling workspace dep)"
3483    )]
3484    FonteCaminhoAbsolute { nome: String, caminho: String },
3485    #[error(
3486        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
3487         with `~` (the leading-tilde is a shell-expansion convention, not a \
3488         POSIX path component — `Path::is_absolute` returns false on it, so \
3489         the b94fd83 absolute-path gate doesn't catch it, but the lacre \
3490         pipeline embeds the value verbatim in its per-dep content-address \
3491         `path:{caminho}` at caixa-resolver/src/resolve.rs:189 and the \
3492         caixa-resolver folds it through `Path::join` without `~`-expansion, \
3493         so the build looks for a literal `./{caminho}` subdirectory and \
3494         fails at resolve time far from the source caixa.lisp; even worse, a \
3495         future caixa-resolver pass that *does* expand `~` would silently \
3496         re-open the host-layout-leak the b94fd83 absolute gate closes — \
3497         Alice's `~` resolves to `/home/alice`, Bob's to `/home/bob`, two CI \
3498         runners with different `$HOME` layouts resolve to two distinct paths \
3499         for the byte-identical caixa, defeating the THEORY.md §V.2 render-\
3500         determinism contract; express the path relative to the caixa.lisp \
3501         location, e.g. \"../caixa-teia\" for a sibling workspace dep, or \
3502         spell out the full relative path explicitly if a workstation-rooted \
3503         dep is genuinely intended)"
3504    )]
3505    FonteCaminhoTildeExpansion { nome: String, caminho: String },
3506    #[error(
3507        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
3508         with `$` (the leading-`$` is a shell-variable-expansion convention, \
3509         not a POSIX path component — `Path::is_absolute` returns false on it \
3510         and the a5c248e tilde gate doesn't catch it, but the lacre pipeline \
3511         embeds the value verbatim in its per-dep content-address \
3512         `path:{caminho}` at caixa-resolver/src/resolve.rs:189 and the \
3513         caixa-resolver folds it through `Path::join` without `$`-expansion, \
3514         so the build looks for a literal `./{caminho}` subdirectory and \
3515         fails at resolve time far from the source caixa.lisp; even worse, a \
3516         future caixa-resolver pass that *does* expand `$VAR` (the canonical \
3517         shell-convention idiom that CI's `${{WORKSPACE}}` paste-idiom \
3518         invites) would silently re-open the host-layout-leak the b94fd83 \
3519         absolute gate closes — Alice's `$HOME` resolves to `/home/alice`, \
3520         Bob's to `/home/bob`, two CI runners with different `${{WORKSPACE}}` \
3521         layouts resolve to two distinct paths for the byte-identical caixa, \
3522         defeating the THEORY.md §V.2 render-determinism contract; express \
3523         the path relative to the caixa.lisp location, e.g. \"../caixa-teia\" \
3524         for a sibling workspace dep, or spell out the full relative path \
3525         explicitly if a workstation-rooted dep is genuinely intended)"
3526    )]
3527    FonteCaminhoVarExpansion { nome: String, caminho: String },
3528    #[error(
3529        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
3530         with a space (the leading ASCII space `0x20` is the orthogonal \
3531         paste-from-aligned-doc footgun that silently passes \
3532         `Path::is_absolute` and every prior leading-byte arm — \
3533         `\" ../caixa-teia\"` resolves via `Path::join` to a literal \
3534         `./ ../caixa-teia` subdirectory the resolver fails to find at \
3535         resolve time with a non-self-locating `No such file or directory` \
3536         error far from the source caixa.lisp; the lacre pipeline embeds \
3537         the value verbatim in its per-dep content-address `path:{caminho}` \
3538         at caixa-resolver/src/resolve.rs:189, so byte-divergent / \
3539         semantic-identical caixa values (` ../caixa-teia` vs \
3540         `../caixa-teia`) yield two distinct BLAKE3 closures across two \
3541         workstations whose authors differ only in paste-from-aligned- \
3542         caixa.lisp-doc whitespace habits — the most insidious failure \
3543         mode the typed slot can carry (no error surfaces; the divergence \
3544         is invisible until two machines compare lacres), defeating the \
3545         THEORY.md §V.2 render-determinism contract. The canonical \
3546         paste-from-aligned-`:deps`-block footgun (every `:fonte` form in \
3547         a multi-entry `:deps` block sits at the same column — an author \
3548         selecting `\"<sp><sp><sp>../caixa-teia\"` and pasting it from \
3549         the rendered alignment into a fresh entry preserves the leading \
3550         whitespace verbatim); peer `:fonte :repo` axis already rejects \
3551         leading whitespace via `is_git_repo_url`, `:fonte :tag` / \
3552         `:fonte :branch` via `is_git_ref_name`, `:descricao` via \
3553         `is_chart_description_shape`, `:licenca` via \
3554         `is_spdx_expression_shape`. Drop the leading space; express the \
3555         path as a bare relative single-token like \"../caixa-teia\")"
3556    )]
3557    FonteCaminhoLeadingWhitespace { nome: String, caminho: String },
3558    #[error(
3559        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
3560         with `-` (the canonical CLI-argument-injection footgun on the \
3561         `:caminho` axis — the lacre pipeline embeds the value verbatim in \
3562         its per-dep content-address `path:{caminho}` at \
3563         caixa-resolver/src/resolve.rs:189 and the caixa-resolver folds it \
3564         through `Path::join` looking for a literal `./{caminho}` \
3565         subdirectory. Every downstream subprocess that consumes the resolved \
3566         path — `git -C {caminho} <verb>`, `terraform -chdir={caminho}`, \
3567         `nix build --path {caminho}`, `find {caminho}`, `stat {caminho}`, \
3568         `cp -r {caminho} …`, `rm -rf {caminho}` — reinterprets a leading-`-` \
3569         value as a CLI flag rather than a positional path when the invocation \
3570         does not carry a `--` argument-list terminator between the flag block \
3571         and the path (the common case at every porcelain entry point). The \
3572         canonical footguns: `:caminho \"-rf\"` (bare short-flag paste), \
3573         `:caminho \"-C\"` (`git -C -C` config-injection paste), \
3574         `:caminho \"--upload-pack=cat /etc/passwd\"` (the canonical long-flag \
3575         CLI-arg-injection vector at every git porcelain entry point that \
3576         consumes a path or URL argument, peer with is_git_repo_url's \
3577         leading-`-` arm on the sibling `:fonte :repo` axis), \
3578         `:caminho \"--config=…\"` (`git -c foo=bar` config-override paste). \
3579         POSIX `std::path::Path` treats a leading `-` as a literal filename \
3580         byte so the resolver folds `\"-rf\"` through `Path::join` and looks \
3581         for a literal `./-rf` subdirectory that fails at resolve time with a \
3582         non-self-locating `No such file or directory` error far from the \
3583         source caixa.lisp — but on any downstream shell-out without `--` the \
3584         reinterpretation is silent and the failure mode is arbitrary-\
3585         argument-injection. Peer arms: `is_git_repo_url` (render.rs:2037) \
3586         rejects leading `-` on `:fonte :repo` for `git clone <repo>` CLI-\
3587         arg-injection; `is_git_ref_name` (render.rs:1381, 5a28454) rejects \
3588         leading `-` on `:fonte :tag` / `:branch` for `git checkout <ref>` \
3589         CLI-arg-injection; `is_dns_1123_label` rejects leading `-` on every \
3590         DNS-1123-shaped axis (top-level Caixa `:nome`, `:membros :caixa`, \
3591         `:children :caixa`, `:deps :nome`, cluster names); \
3592         `is_cargo_feature_name` rejects leading `-` on `:caracteristicas`; \
3593         the feira `init` / `add <nome>` positional gate (868c191) rejects \
3594         leading `-` on the CLI positional itself. Express the path as a bare \
3595         relative single-token like \"../caixa-teia\" — the sibling-workspace \
3596         directory name carries no leading-hyphen semantic, and `./` / `../` \
3597         prefixes structurally partition the leading-byte set to safe values.)"
3598    )]
3599    FonteCaminhoLeadingHyphen { nome: String, caminho: String },
3600    #[error(
3601        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains \
3602         ASCII control byte 0x{byte:02x} (POSIX paths reject NUL `0x00` outright — \
3603         every `std::fs` syscall routes the path through `CString::new` which \
3604         fails with `NulError` at resolve time; the lacre pipeline embeds the \
3605         value verbatim in its per-dep content-address `path:{caminho}` at \
3606         caixa-resolver/src/resolve.rs:189 so a control byte anywhere in the \
3607         value lands in the BLAKE3 closure and breaks the THEORY.md §V.2 render-\
3608         determinism contract — the canonical paste-from-multiline-doc \
3609         (`\\n`/`\\r`), paste-from-aligned-table (`\\t`), or paste-from-binary-\
3610         blob (`0x00`-DEL) footgun every peer single-token-shaped axis \
3611         (`:fonte :repo`, `:fonte :tag`/`:branch`, the Helm chart-string axes) \
3612         already gates against. Express the path as a relative single-line ASCII \
3613         string, e.g. \"../caixa-teia\" for a sibling workspace dep)"
3614    )]
3615    FonteCaminhoControlChar {
3616        nome: String,
3617        caminho: String,
3618        byte: u8,
3619    },
3620    #[error(
3621        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains `\\` \
3622         (POSIX `std::path::Path` treats `\\` as a literal byte inside a single path \
3623         component, so `..\\caixa-teia` is one directory named literally `..\\caixa-teia` — \
3624         not the parent's sibling — and the caixa-resolver folds the value through \
3625         `Path::join` looking for a literal `./{caminho}` subdirectory that fails at \
3626         resolve time with a non-self-locating `No such file or directory` error far \
3627         from the source caixa.lisp; Windows `std::path::Path` treats `\\` as a \
3628         primary path separator equal to `/`, so byte-identical caixa.lisp values \
3629         resolve to two distinct directories across runner OSes — the lacre pipeline \
3630         embeds the value verbatim in its per-dep content-address `path:{caminho}` at \
3631         caixa-resolver/src/resolve.rs:189, defeating the THEORY.md §V.2 render-\
3632         determinism contract via the cross-host-OS-separator divergence vector. The \
3633         canonical Windows-Explorer `Copy as path` / PowerShell `Get-Location` \
3634         paste-idiom footgun; peer `:fonte :tag` / `:fonte :branch` axis already \
3635         rejects `\\` via `is_git_ref_name` for the same Windows-path-leak reason, \
3636         and `:entrada :paths` rejects `\\` via `is_gateway_api_http_path`'s eleven-\
3637         byte RFC-3986-reserved set. Express the path with `/` as the separator, e.g. \
3638         \"../caixa-teia\" for a sibling workspace dep)"
3639    )]
3640    FonteCaminhoBackslash { nome: String, caminho: String },
3641    #[error(
3642        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3643         redirection metacharacter 0x{byte:02x} `{ch}` (every interactive shell — bash / \
3644         zsh / fish / nushell — lexes `<` and `>` as input / output redirection \
3645         operators, so `:caminho \"../caixa-teia>build.log\"` is the canonical \
3646         paste-from-shell-pipeline footgun where an author copies a `command > log` \
3647         tail without trimming the redirect; POSIX `std::path::Path` treats both bytes \
3648         as literal path-component bytes, so the resolver folds the value through \
3649         `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
3650         subdirectory and fails at resolve time with a non-self-locating `No such \
3651         file or directory` error far from the source caixa.lisp. The lacre pipeline \
3652         embeds the value verbatim in its per-dep content-address `path:{caminho}` at \
3653         caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure \
3654         and rides into every shell-spawned subprocess (the resolver's `git clone`, a \
3655         future `feira tofu` shell-out, a future operator-side `nix` spawn) as the \
3656         canonical CRLF-at-subprocess-argument / shell-metachar injection surface every \
3657         peer single-token-shaped typed slot already closes. The peer `:fonte :tag` / \
3658         `:fonte :branch` axis already rejects `<` / `>` via `is_git_ref_name`, and \
3659         `:entrada :paths` rejects them via `is_gateway_api_http_path`'s eleven-byte \
3660         RFC-3986-reserved set. Express the path as a bare relative single-token like \
3661         \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
3662         redirection semantic.",
3663        ch = *byte as char
3664    )]
3665    FonteCaminhoShellRedirection {
3666        nome: String,
3667        caminho: String,
3668        byte: u8,
3669    },
3670    #[error(
3671        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-pipe \
3672         metacharacter `|` (every interactive shell — bash / zsh / fish / nushell — lexes \
3673         `|` as the pipe operator that wires one command's stdout to the next command's \
3674         stdin, so `:caminho \"../caixa-teia | grep foo\"` is the canonical paste-from-\
3675         shell-history footgun where an author copies a `ls ../caixa-teia | grep` line \
3676         without trimming the pipeline tail, and `:caminho \"../foo||bar\"` is the \
3677         symmetric `cmd-a || cmd-b` short-circuit-OR paste shape; POSIX `std::path::Path` \
3678         treats `|` as a literal path-component byte, so the resolver folds the value \
3679         through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
3680         subdirectory and fails at resolve time with a non-self-locating `No such file or \
3681         directory` error far from the source caixa.lisp. The lacre pipeline embeds the \
3682         value verbatim in its per-dep content-address `path:{caminho}` at caixa-resolver/\
3683         src/resolve.rs:189, so the byte lands in the BLAKE3 closure and rides into every \
3684         shell-spawned subprocess (the resolver's `git clone`, a future `feira tofu` \
3685         shell-out, a future operator-side `nix` spawn) as the canonical CRLF-at-\
3686         subprocess-argument / shell-metachar injection surface every peer single-token-\
3687         shaped typed slot already closes. The peer `:entrada :paths` axis rejects `|` \
3688         via `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the \
3689         path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
3690         workspace directory name carries no shell-pipe semantic."
3691    )]
3692    FonteCaminhoShellPipe { nome: String, caminho: String },
3693    #[error(
3694        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3695         command-separator metacharacter `;` (every interactive shell — bash / zsh / fish \
3696         / nushell — lexes `;` as the sequential-command terminator that fires the next \
3697         command regardless of the prior command's exit status, so `:caminho \
3698         \"../caixa-teia; rm -rf build\"` is the canonical paste-from-shell-one-liner \
3699         footgun where an author copies a `cd path; do-thing` chain without trimming \
3700         the cleanup tail, and `:caminho \"../foo;;bar\"` is the symmetric POSIX `case` \
3701         arm `;;` terminator paste shape; POSIX `std::path::Path` treats `;` as a \
3702         literal path-component byte, so the resolver folds the value through \
3703         `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
3704         subdirectory and fails at resolve time with a non-self-locating `No such file \
3705         or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
3706         the value verbatim in its per-dep content-address `path:{caminho}` at \
3707         caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
3708         rides into every shell-spawned subprocess (the resolver's `git clone`, a \
3709         future `feira tofu` shell-out, a future operator-side `nix` spawn) as the \
3710         canonical shell-metachar injection surface every peer single-token-shaped \
3711         typed slot already closes. The peer `:entrada :paths` axis rejects `;` via \
3712         `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the \
3713         path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
3714         workspace directory name carries no shell-command-separator semantic."
3715    )]
3716    FonteCaminhoShellSemicolon { nome: String, caminho: String },
3717    #[error(
3718        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3719         background / list-AND metacharacter `&` (every interactive shell — bash / zsh \
3720         / fish / nushell — lexes `&` two ways: single `&` as the background-task \
3721         terminator detaching the prior command and returning control immediately to \
3722         the prompt, double `&&` as the logical-AND list operator firing the next \
3723         command only if the prior succeeded; POSIX `std::path::Path` treats it as a \
3724         literal byte. The canonical paste-from-shell-prompt footgun is a `cd path & \
3725         sleep 1` background-launch one-liner or a `cd path && make install` build-\
3726         chain idiom selected whole into the `:caminho` slot — the prior `;` arm at \
3727         05c358e closed the sequential-command-separator vector, this arm closes the \
3728         orthogonal background-task / logical-AND vector on the same paste-from-shell-\
3729         prompt class. The lacre pipeline embeds the value verbatim in its per-dep \
3730         content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the \
3731         byte lands in the BLAKE3 closure and rides into every shell-spawned \
3732         subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a \
3733         future operator-side `nix` spawn) as the canonical shell-metachar injection \
3734         surface every peer single-token-shaped typed slot already closes. The peer \
3735         `:entrada :paths` axis rejects `&` via `is_gateway_api_http_path`'s eleven-\
3736         byte RFC-3986-reserved set. Express the path as a bare relative single-token \
3737         like \"../caixa-teia\" — the sibling-workspace directory name carries no \
3738         shell-background / logical-AND semantic."
3739    )]
3740    FonteCaminhoShellBackground { nome: String, caminho: String },
3741    #[error(
3742        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3743         command-substitution metacharacter `` ` `` (every POSIX shell — sh / bash / zsh / \
3744         dash / ksh / fish / nushell — lexes the byte as the legacy command-substitution \
3745         wrapper that runs the enclosed command and substitutes its standard-output \
3746         verbatim into the surrounding word, so a backticked `whoami` expands to the \
3747         current user's name and a backticked `cat /etc/passwd` expands to the file's \
3748         contents — the canonical CWE-78 shell-command-injection vector; POSIX \
3749         `std::path::Path` treats the byte as a literal path-component byte. The canonical \
3750         paste-from-shell-prompt footgun is a `cd ../path/<backtick>whoami<backtick>` legacy substitution \
3751         one-liner or a `cd <backtick>pwd<backtick>/path` working-directory expansion idiom selected whole \
3752         into the `:caminho` slot — the prior `&` arm at e12e4f3 closed the shell-\
3753         background / logical-AND vector, this arm closes the orthogonal command-\
3754         substitution vector on the same paste-from-shell-prompt class (the modern `$()` \
3755         form is gated at leading position by the f4efe9c `FonteCaminhoVarExpansion` arm; \
3756         the legacy backtick form is the orthogonal axis). The lacre pipeline embeds the \
3757         value verbatim in its per-dep content-address `path:{caminho}` at \
3758         caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
3759         rides into every shell-spawned subprocess (the resolver's `git clone`, a future \
3760         `feira tofu` shell-out, a future operator-side `nix` spawn) as the canonical \
3761         shell-metachar injection surface every peer single-token-shaped typed slot \
3762         already closes. The peer `:entrada :paths` axis rejects the byte via \
3763         `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the path \
3764         as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
3765         directory name carries no shell-command-substitution semantic."
3766    )]
3767    FonteCaminhoShellCommandSubstitution { nome: String, caminho: String },
3768    #[error(
3769        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3770         glob / pathname-expansion metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — \
3771         sh / bash / zsh / dash / ksh / fish / nushell — lexes `*` and `?` as pathname-\
3772         expansion wildcards: `*` matches any sequence of characters in a path component \
3773         and `?` matches exactly one character, so a `:caminho \"../caixa-teia/*\"` is the \
3774         canonical paste-from-shell-listing footgun where an author copies a \
3775         `ls ../caixa-teia/*` listing without trimming the wildcard, and `:caminho \
3776         \"../foo?\"` is the symmetric single-char-wildcard paste shape; POSIX \
3777         `std::path::Path` treats both bytes as literal path-component bytes, so the \
3778         resolver folds the value through `Path::new(caminho).join(<file>)` looking for \
3779         a literal `./{caminho}` subdirectory and fails at resolve time with a non-self-\
3780         locating `No such file or directory` error far from the source caixa.lisp. The \
3781         lacre pipeline embeds the value verbatim in its per-dep content-address \
3782         `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in the \
3783         BLAKE3 closure and rides into every shell-spawned subprocess (the resolver's \
3784         `git clone`, a future `feira tofu` shell-out, a future operator-side `nix` \
3785         spawn) as the canonical shell-metachar / glob-expansion surface every peer \
3786         single-token-shaped typed slot already closes. The peer `:entrada :paths` axis \
3787         rejects `*` and `?` via `is_gateway_api_http_path`'s eleven-byte RFC-3986-\
3788         reserved set. Express the path as a bare relative single-token like \
3789         \"../caixa-teia\" — the sibling-workspace directory name carries no shell-glob \
3790         / pathname-expansion semantic.",
3791        ch = *byte as char
3792    )]
3793    FonteCaminhoShellGlob {
3794        nome: String,
3795        caminho: String,
3796        byte: u8,
3797    },
3798    #[error(
3799        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3800         subshell-grouping metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / \
3801         zsh / dash / ksh / fish / nushell — lexes `(` and `)` as the subshell-grouping \
3802         operator: `(<cmd>)` runs `<cmd>` in a child shell with a fresh environment scope \
3803         (the canonical `(cd <path> && <cmd>)` shell-history one-liner scopes a `cd` to one \
3804         subshell without disturbing the parent's working directory), and `$(<cmd>)` is the \
3805         modern Bourne command-substitution shape the leading-`$` `FonteCaminhoVarExpansion` \
3806         arm closes the leading byte of — together the two arms now structurally exclude the \
3807         entire `$(<cmd>)` substitution surface from the typed `:caminho` accepted set. \
3808         POSIX `std::path::Path` treats the byte as a literal path-component byte, so a \
3809         `:caminho \"../caixa-teia/$(date)/build\"` (the canonical paste-from-shell-history \
3810         modern-command-substitution footgun) or `:caminho \"../(cd foo && pwd)/caixa-teia\"` \
3811         (the symmetric subshell-grouping working-directory-probe paste idiom) silently passes \
3812         every prior arm and the resolver folds the value through `Path::new(caminho).join(\
3813         <file>)` looking for a literal subdirectory and fails at resolve time with a non-\
3814         self-locating `No such file or directory` error far from the source caixa.lisp. The \
3815         lacre pipeline embeds the value verbatim in its per-dep content-address `path:\
3816         {caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 \
3817         closure and rides into every shell-spawned subprocess (the resolver's `git clone`, a \
3818         future `feira tofu` shell-out, a future operator-side `nix` spawn) as the canonical \
3819         shell-metachar / subshell-grouping surface every peer single-token-shaped typed slot \
3820         already closes. The peer `:fonte :repo` axis (3b99147) closes the same byte under the \
3821         same shell-subshell-grouping / RFC-3986-sub-delims banner on `is_git_repo_url`, \
3822         together with the leading-`$` `FonteCaminhoVarExpansion` arm closing the leading byte \
3823         of every `$(<cmd>)` shape. Express the path as a bare relative single-token \
3824         like \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
3825         subshell-grouping semantic.",
3826        ch = *byte as char
3827    )]
3828    FonteCaminhoShellSubshellGrouping {
3829        nome: String,
3830        caminho: String,
3831        byte: u8,
3832    },
3833    #[error(
3834        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3835         brace-expansion / URI-Template placeholder metacharacter 0x{byte:02x} `{ch}` \
3836         (every POSIX-derived brace-expanding shell — bash / zsh / ksh / fish — lexes `{{` / \
3837         `}}` as the brace-expansion operator: `{{a,b,c}}` expands to the cross-product of \
3838         comma-separated members and `{{1..10}}` expands to the integer range — the \
3839         canonical `mkdir -p ../{{caixa-teia,caixa-helm,caixa-flux}}` / `cp file{{,.bak}}` \
3840         idiom every shell-history block carries; RFC 6570 reserves the matched pair for \
3841         URI Template placeholders (the canonical `https://{{host}}/{{org}}/{{repo}}` \
3842         substitution shape every OpenAPI / Swagger / Postman / GitHub Octokit client \
3843         library / Helm chart-URL fragment carries) and the Mustache / Handlebars / \
3844         Tera / Jinja2 / Go html/template doubled-brace substitution form every IaC \
3845         templating engine (Helm, Kustomize, Terraform's `${{var}}` cousin) emits. POSIX \
3846         `std::path::Path` treats the byte as a literal path-component byte, so a \
3847         `:caminho \"../{{caixa-teia,caixa-helm}}/build\"` (the canonical paste-from-\
3848         shell-history brace-expansion fan-across-siblings footgun) or `:caminho \"../{{{{org}}}}/\
3849         caixa-teia\"` (the symmetric paste-from-templated-doc URI-Template placeholder \
3850         idiom every README quick-start / OpenAPI spec / Helm chart `home:` field carries) \
3851         silently passes every prior arm and the resolver folds the value through \
3852         `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
3853         resolve time with a non-self-locating `No such file or directory` error far from \
3854         the source caixa.lisp. The lacre pipeline embeds the value verbatim in its \
3855         per-dep content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, \
3856         so the byte lands in the BLAKE3 closure and rides into every shell-spawned \
3857         subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a \
3858         future operator-side `nix` spawn) as the canonical shell-metachar / brace-\
3859         expansion / URI-Template-placeholder surface every peer single-token-shaped \
3860         typed slot already closes. The peer `:fonte :repo` axis (42d8f9d) closes the \
3861         same byte pair on `is_git_repo_url` under the same RFC-3986-'delims' / \
3862         RFC-6570-URI-Template / shell-brace-expansion banner. Express the path as a \
3863         bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
3864         directory name carries no shell-brace-expansion / URI-Template-placeholder \
3865         semantic; if two siblings actually need pinning, author two separate `:deps` \
3866         entries rather than one brace-expanded `:caminho` value.",
3867        ch = *byte as char
3868    )]
3869    FonteCaminhoShellBraceExpansion {
3870        nome: String,
3871        caminho: String,
3872        byte: u8,
3873    },
3874    #[error(
3875        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3876         bracket-expansion / POSIX glob-character-class / shell-`test`-builtin metacharacter \
3877         0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / nushell \
3878         — lexes the bracket pair as the glob character-class operator: `[abc]` matches one of \
3879         `a` / `b` / `c`, `[a-z]` matches any lowercase ASCII letter, `[^x]` negates — the \
3880         canonical `ls *.[ch]` C-source-file glob and `cd ../caixa-[a-z]*` lowercase-sibling \
3881         glob every shell-history block carries; the bracket pair additionally carries the \
3882         POSIX `test` / `[` builtin command (`[ -d ../caixa-teia ] && cd ...` every shell-\
3883         script conditional uses) and bash's `[[ ... ]]` extended-test grammar; beyond shell \
3884         the pair is the TOML inline-array delimiter (`features = [\"a\", \"b\"]` — the \
3885         canonical paste-from-Cargo-manifest cross-idiom-leak vector), the YAML flow-sequence \
3886         delimiter (`paths: [/a, /b]` — the canonical paste-from-values.yaml cross-idiom \
3887         leak), the JSON array delimiter, and the POSIX-ERE / PCRE bracket-expression anchor. \
3888         POSIX `std::path::Path` treats the byte as a literal path-component byte, so a \
3889         `:caminho \"../caixa-[a-z]/build\"` (the canonical paste-from-shell-history glob-\
3890         character-class fan-across-siblings footgun) or `:caminho \"../[caixa-teia]/build\"` \
3891         (the symmetric paste-from-TOML-array / paste-from-YAML-flow-sequence cross-idiom \
3892         leak) silently passes every prior arm and the resolver folds the value through \
3893         `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
3894         resolve time with a non-self-locating `No such file or directory` error far from \
3895         the source caixa.lisp. The lacre pipeline embeds the value verbatim in its per-dep \
3896         content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte \
3897         lands in the BLAKE3 closure and rides into every shell-spawned subprocess (the \
3898         resolver's `git clone`, a future `feira tofu` shell-out, a future operator-side \
3899         `nix` spawn) as the canonical shell-metachar / glob-character-class / TOML-array \
3900         surface every peer single-token-shaped typed slot already closes. Express the path \
3901         as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
3902         directory name carries no shell-bracket-expansion / glob-character-class / array-\
3903         literal semantic; if a family of sibling caixas actually needs pinning, author \
3904         separate `:deps` entries rather than one character-class-expanded `:caminho` value.",
3905        ch = *byte as char
3906    )]
3907    FonteCaminhoShellBracketExpansion {
3908        nome: String,
3909        caminho: String,
3910        byte: u8,
3911    },
3912    #[error(
3913        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3914         quote-grouping / cross-config-DSL string-literal-delimiter metacharacter \
3915         0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / \
3916         nushell — lexes `'` as the strong string-literal delimiter (`'…'` — no expansion) \
3917         and `\"` as the weak string-literal delimiter (`\"…\"` — variable- / command-\
3918         substitution-preserving); the canonical `cd '../caixa-teia'` shell-history idiom \
3919         every path-with-embedded-whitespace paste block carries and the symmetric \
3920         `git clone \"$REPO\"` weak-quoted CI-manifest shape both leak the pair verbatim. \
3921         Beyond shell the pair is the JSON string-literal delimiter (`\"key\": \"value\"` — \
3922         the canonical paste-from-JSON-config cross-idiom-leak vector), the YAML double- \
3923         and single-quoted flow-scalar delimiter (`path: \"../caixa-teia\"` — the canonical \
3924         paste-from-values.yaml / paste-from-K8s-YAML-manifest cross-idiom leak), the TOML \
3925         basic and literal string delimiter (`path = \"../caixa-teia\"` — the canonical \
3926         paste-from-Cargo-manifest cross-idiom leak), the tatara-lisp string-literal \
3927         delimiter itself (`(:caminho \"../caixa-teia\")` — the canonical \"I copied the \
3928         entire `:caminho \"...\"` slot rather than just the string body\" author-surface \
3929         footgun), and RFC 3986 §2.2's `gen-delims` / `sub-delims` grammar which excludes \
3930         both bytes from the `pchar = unreserved / pct-encoded / sub-delims / \":\" / \"@\"` \
3931         production. POSIX `std::path::Path` treats the byte as a literal path-component \
3932         byte, so a `:caminho \"'../caixa-teia'\"` (the canonical paste-from-shell-history \
3933         strong-quoted sibling-workspace path footgun) or `:caminho \"\\\"../caixa-teia\\\"\"` \
3934         (the symmetric weak-quoted paste-from-JSON / paste-from-YAML flow-scalar / paste-\
3935         from-TOML basic-string / paste-from-tatara-lisp string-literal cross-idiom-leak \
3936         shape) silently passes every prior arm and the resolver folds the value through \
3937         `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
3938         resolve time with a non-self-locating `No such file or directory` error far from \
3939         the source caixa.lisp. The lacre pipeline embeds the value verbatim in its per-dep \
3940         content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte \
3941         lands in the BLAKE3 closure and rides into every shell-spawned subprocess (the \
3942         resolver's `git clone`, a future `feira tofu` shell-out, a future operator-side \
3943         `nix` spawn) as the canonical shell-metachar / string-literal-delimiter surface \
3944         every peer single-token-shaped typed slot already closes. The peer `:fonte :repo` \
3945         axis closes both bytes under the same shell-quote-grouping / RFC-3986-sub-delims \
3946         banner (e7a109f `'` shell-single-quote + 4267d8b `\"` shell-double-quote on \
3947         `is_git_repo_url`). Express the path as a bare relative single-token like \
3948         \"../caixa-teia\" — the sibling-workspace directory name carries no shell-quote-\
3949         grouping / string-literal-delimiter semantic; strip the outer quote pair from the \
3950         paste (the tatara-lisp `:caminho \"...\"` slot already carries the string-literal \
3951         quoting on the outer syntactic layer, so an inner quote pair would nest and \
3952         desugar to a broken layer).",
3953        ch = *byte as char
3954    )]
3955    FonteCaminhoShellQuoteGrouping {
3956        nome: String,
3957        caminho: String,
3958        byte: u8,
3959    },
3960    #[error(
3961        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3962         comment / URL-fragment-identifier / YAML-comment cross-config-DSL metacharacter \
3963         0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / \
3964         nushell — lexes an unquoted `#` at the head of a word or after unquoted \
3965         whitespace as the comment-lead per POSIX.1-2017 §2.3 Token Recognition step 6, \
3966         discarding the byte and everything after it to the end of the physical line \
3967         before command parsing (`cd ../caixa-teia  # legacy sibling` — the canonical \
3968         paste-from-shell-history-with-trailing-annotation shape every operator-notebook \
3969         and CI-manifest carries); YAML 1.2 §6.6 makes `#` the comment-lead at any \
3970         position preceded by whitespace or at line-start (`path: ../caixa-teia  # pin` \
3971         — the canonical paste-from-values.yaml / paste-from-K8s-manifest cross-idiom-\
3972         leak); RFC 3986 §3.5 reserves `#` as the URL fragment-identifier delimiter (the \
3973         canonical paste-from-browser-address-bar `github.com/foo/bar#readme` / \
3974         `github.com/foo/bar#L42` permalink shape, and the symmetric Nix-flake-ref \
3975         cross-idiom leak `github:foo/bar#packageName` where `#` selects a flake \
3976         output); the same cross-config-DSL surface extends to HCL / Terraform / Nix \
3977         flake attributes / dotenv `.env` / gitconfig / .gitignore / ini / TOML where \
3978         `#` is likewise the comment-lead. POSIX `std::path::Path` treats the byte as a \
3979         literal path-component byte, so a `:caminho \"../caixa-teia # legacy sibling\"` \
3980         (the canonical paste-from-shell-history-with-trailing-annotation footgun), \
3981         `:caminho \"../caixa-teia  # pin\"` (the symmetric YAML flow-scalar paste-with-\
3982         trailing-comment shape), or `:caminho \"../caixa-teia#readme\"` (the URL \
3983         fragment paste-from-browser-address-bar shape) silently passes every prior arm \
3984         and the resolver folds the value through `Path::new(caminho).join(<file>)` \
3985         looking for a literal subdirectory named `../caixa-teia # legacy sibling` and \
3986         fails at resolve time with a non-self-locating `No such file or directory` \
3987         error far from the source caixa.lisp — while every downstream shell / YAML / \
3988         URL parser silently truncates the value at the `#` byte to `../caixa-teia`, so \
3989         a `feira tofu` shell-out and a `nix flake check` on an emitted YAML `path:` \
3990         scalar disagree with the resolver on which directory the value names. The \
3991         lacre pipeline embeds the value verbatim in its per-dep content-address \
3992         `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in \
3993         the BLAKE3 closure and rides into every shell-spawned subprocess (the \
3994         resolver's `git clone`, a future `feira tofu` shell-out, a future operator-\
3995         side `nix` spawn) as the canonical shell-metachar / comment-lead / URL-\
3996         fragment-delimiter surface every peer single-token-shaped typed slot already \
3997         closes. The peer `:fonte :repo` axis closes the byte under the same URL-\
3998         fragment-identifier banner (a68f818 `#` on `is_git_repo_url`). Express the \
3999         path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
4000         workspace directory name carries no shell-comment / URL-fragment / YAML-\
4001         comment semantic; move any trailing annotation to a tatara-lisp `;`-comment \
4002         on the surrounding form (`;; legacy sibling` above the `(:caminho ...)` slot) \
4003         and drop any `#fragment` tail entirely (fragment identifiers select \
4004         renderings, not directories, and `:caminho` names a directory).",
4005        ch = *byte as char
4006    )]
4007    FonteCaminhoShellComment {
4008        nome: String,
4009        caminho: String,
4010        byte: u8,
4011    },
4012    #[error(
4013        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains URL-\
4014         percent-encoding-escape / printf-format-specifier / bash-job-control-specifier \
4015         / YAML-directive-lead metacharacter 0x{byte:02x} `{ch}` (RFC 3986 §2.1 reserves \
4016         `%` as the URL percent-encoding-escape — `%HH` is the mandatory encoding \
4017         mechanism for every byte outside the `unreserved` alphanumeric / `-` / `.` / \
4018         `_` / `~` set, and `%` itself must be percent-encoded as `%25` to appear \
4019         literally inside a URL value. The canonical paste-from-browser-address-bar \
4020         percent-encoded-space footgun (an author copies `../caixa%20teia` out of a URL-\
4021         encoded README hyperlink / browser address bar / percent-encoded permalink \
4022         expecting `%20` to decode to a literal space at the filesystem layer) locks two \
4023         distinct BLAKE3 closures (`path:../caixa%20teia` vs `path:../caixa teia`) for \
4024         what the author intended as the byte-identical sibling-workspace dep. POSIX \
4025         `std::path::Path` treats the byte as a literal path-component byte, so \
4026         `Path::join` looks for a literal `./{caminho}` subdirectory and fails at \
4027         resolve time with a non-self-locating `No such file or directory` error far \
4028         from the source caixa.lisp — while every downstream URL parser / shell printf \
4029         builtin / YAML directive parser silently reinterprets the byte to a different \
4030         value than the resolver's `Path::join` sees. Beyond the URL-encoding hazard, \
4031         `%` is the C / POSIX printf format-directive lead-in (`%s`, `%d`, `%02x` — \
4032         wired into every POSIX shell's `printf` builtin, the canonical CWE-134 format-\
4033         string-injection vector); the bash / zsh / ksh job-control-specifier lead-in \
4034         (`%1` names \"job 1\", `%%` names \"the current job\", `%foo` names \"the most \
4035         recent job whose command started with `foo`\" — a future `kill %1` invocation \
4036         silently redirects the signal to a wrong target); the YAML 1.2 §6.8.1 \
4037         directive lead-in (`%YAML 1.2` / `%TAG` — the paste-from-top-of-doc YAML \
4038         directive block cross-idiom leak); and the Windows-shell env-var-reference \
4039         lead-in (`%PATH%` — the paste-from-`.bat` / paste-from-PowerShell-`%env:PATH%` \
4040         cross-idiom leak). The lacre pipeline embeds the value verbatim in its per-dep \
4041         content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the \
4042         byte lands in the BLAKE3 closure and rides into every shell-spawned subprocess \
4043         (the resolver's `git clone`, a future `feira tofu` shell-out, a future \
4044         operator-side `nix` spawn) as the canonical URL-percent-encoding-escape / \
4045         printf-format-specifier / job-control-specifier surface every peer single-\
4046         token-shaped typed slot already closes. The peer `:fonte :repo` axis closes \
4047         the byte under the same URL-percent-encoding-escape banner (a323db8 `%` on \
4048         `is_git_repo_url`). Express the path as a bare relative single-token like \
4049         \"../caixa-teia\" — the sibling-workspace directory name carries no URL-\
4050         percent-encoding-escape / format-specifier / job-control semantic; substitute \
4051         any `%20` percent-encoded-space with a literal space then reject the whole \
4052         value at the leading-whitespace / embedded-`?` arm on the same axis (a caixa \
4053         directory name never carries an embedded space in practice); drop any \
4054         `%2F`-encoded path separator in favor of a literal `/`; and drop any leading \
4055         `%YAML` / `%PATH%` cross-idiom-leak prefix entirely.",
4056        ch = *byte as char
4057    )]
4058    FonteCaminhoUrlPercentEncoding {
4059        nome: String,
4060        caminho: String,
4061        byte: u8,
4062    },
4063    #[error(
4064        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4065         variable-expansion / command-substitution / arithmetic-expansion / cross-config-\
4066         DSL-interpolation metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — sh / \
4067         bash / zsh / dash / ksh / busybox ash / fish / nushell — lexes `$` per \
4068         POSIX.1-2017 §2.6 as the variable-expansion `$<name>` / braced-form `${{<name>}}` \
4069         / command-substitution `$(<cmd>)` / arithmetic-expansion `$((<expr>))` operator; \
4070         Nix uses `${{var}}` as the string-interpolation lead, Make uses `$(var)` / `$@` \
4071         / `$<` for variables and automatic-variables, JavaScript / TypeScript template \
4072         literals use `${{expr}}` for interpolation, envsubst / Kubernetes / OpenShift \
4073         templates use `${{VAR}}` for env-var-reference, PHP uses `$_GET` / `$_ENV` for \
4074         superglobals, Perl uses `$foo` for scalars, SASS / SCSS uses `$primary-color` \
4075         for variables, and PostgreSQL / SQLite use `$1` / `$2` for bind parameters — \
4076         the byte is a first-class parser byte in nearly every config / templating / \
4077         build-system DSL the substrate's paste-idiom surface routinely crosses. POSIX \
4078         `std::path::Path` treats the byte as a literal path-component byte, so the \
4079         canonical paste-from-shell-one-liner `:caminho \"../foo$HOME/bar\"` / paste-\
4080         from-CI-manifest `:caminho \"../foo${{WORKSPACE}}/bar\"` / paste-from-shell-\
4081         prompt `:caminho \"../foo$(whoami)/bar\"` footguns silently pass every prior \
4082         cascade arm (`$` isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / \
4083         `?` / `(` / `)` / `{{` / `}}` / `[` / `]` / `'` / `\"` / `#` / `%`) and route \
4084         through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
4085         subdirectory that fails at resolve time with a non-self-locating `No such file \
4086         or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
4087         the value verbatim in its per-dep content-address `path:{caminho}` at \
4088         caixa-resolver/src/resolve.rs:189, so byte-identical caixa.lisp values differing \
4089         only in whether the author substituted `$HOME` / `${{WORKSPACE}}` at author \
4090         time lock to two distinct BLAKE3 closures across two workstations whose \
4091         downstream envsubst / Nix / Make / K8s-template layers differ in `$VAR` \
4092         recognition — defeating the THEORY.md §V.2 render-determinism contract on the \
4093         same axis every prior `:caminho` arm protects. Beyond the determinism vector, \
4094         `$` at any position in a value flowing verbatim into a shell-spawned subprocess \
4095         is the canonical CWE-78 shell-command-injection surface every peer single-\
4096         token-shaped typed slot already closes: peer `:fonte :repo` axis rejects `$` \
4097         under the shell-variable-expansion / URL-sub-delim banner via `is_git_repo_url` \
4098         (b9d187c), peer `:fonte :tag` / `:fonte :branch` axes reject `$` as part of \
4099         `is_git_ref_name`'s printable-ASCII-restricted grammar (`git check-ref-format` \
4100         rejects the byte outright), and peer `:entrada :paths` axis rejects `$` via \
4101         `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. The leading-`$` \
4102         position on the same axis routes through `FonteCaminhoVarExpansion` at the \
4103         f4efe9c leading-byte arm; this arm closes the last positional gap on the byte \
4104         so every position — leading and embedded — is structurally rejected. Substitute \
4105         the `$VAR` / `${{VAR}}` / `$(cmd)` template with the literal value at author \
4106         time, or express the path as a bare relative single-token like \
4107         \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
4108         variable-expansion / command-substitution / arithmetic-expansion semantic.",
4109        ch = *byte as char
4110    )]
4111    FonteCaminhoShellVariableExpansion {
4112        nome: String,
4113        caminho: String,
4114        byte: u8,
4115    },
4116    #[error(
4117        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4118         history-expansion / RFC-3986-sub-delims / bang-operator metacharacter 0x{byte:02x} \
4119         `{ch}` (every interactive POSIX shell with history enabled — bash / ksh / zsh's \
4120         `bashcompat` / csh / tcsh — lexes `!` as the history-expansion prefix per bash \
4121         reference §9.3: `!command` re-runs the most recent history entry beginning with \
4122         `command`, `!!` re-runs the prior command verbatim, `!$` substitutes the last \
4123         word of the prior command, `!:N` substitutes the Nth word of the prior command, \
4124         and the substitution fires at every history-expansion-enabled shell context — \
4125         `set -o histexpand` is bash's default for interactive sessions and the layer \
4126         every `feira tofu` / `git clone` / `nix flake check` subprocess-argument \
4127         invocation crosses when spawned under `bash -i`. Beyond shell history, RFC 3986 \
4128         §2.2 lists `!` in the `sub-delims` set (the URL grammar admits the byte inside \
4129         a path segment, but every WHATWG-conformant special-scheme URL parser percent-\
4130         encodes it inside a query component via the 'special-query percent-encode set' \
4131         the peer `is_git_repo_url` `*` / `(` / `)` / `'` arms close on); the byte is \
4132         also the C / C++ / Rust / JavaScript / Python bang-operator (logical-negation \
4133         prefix — the paste-from-source-code idiom where an author copies \
4134         `!path.exists()` out of a Rust snippet and the trailing punctuation crosses \
4135         the string-literal boundary); the canonical English-typography emphasis / \
4136         exclamation mark (the paste-from-prose enthusiasm-form idiom where an author \
4137         writes `:caminho \"../caixa-teia!\"` expecting the substrate to coerce it to a \
4138         kebab-case slug); and the Nix flake-ref attribute-selection operator surface. \
4139         POSIX `std::path::Path` treats `!` as a literal path-component byte, so the \
4140         canonical paste-from-shell-history footgun `:caminho \"../caixa-teia!sudo\"` \
4141         (an author copies a `cd ../caixa-teia && !sudo make install` one-liner from a \
4142         quick-start README and the trailing `!sudo` rides in verbatim as a history-\
4143         expansion reference), the symmetric `:caminho \"../foo!!/bar\"` (the `!!` \
4144         repeat-prior-command paste idiom), the English-typography `:caminho \
4145         \"../caixa-teia!\"` (paste-from-prose enthusiasm-form), and the last-word-\
4146         substitution `:caminho \"../foo!$\"` shape silently pass every prior cascade \
4147         arm (`!` isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / `?` / `(` \
4148         / `)` / `{{` / `}}` / `[` / `]` / `'` / `\"` / `#` / `%` / `$`) and route \
4149         through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
4150         subdirectory that fails at resolve time with a non-self-locating `No such file \
4151         or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
4152         the value verbatim in its per-dep content-address `path:{caminho}` at \
4153         caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
4154         rides into every shell-spawned subprocess (the resolver's `git clone`, a \
4155         future `feira tofu` shell-out, a future operator-side `nix flake check` spawn) \
4156         as the canonical shell-history-expansion / RFC-3986-sub-delims surface every \
4157         peer single-token-shaped typed slot already closes. The peer `:fonte :repo` \
4158         axis closes the byte under the same shell-history-expansion / RFC-3986-sub-\
4159         delims banner (7d53c68 `!` on `is_git_repo_url`). Express the path as a bare \
4160         relative single-token like \"../caixa-teia\" — the sibling-workspace directory \
4161         name carries no shell-history-expansion / bang-operator semantic; drop any \
4162         `!sudo` / `!!` / `!$` history-expansion trailing paste-from-shell-history \
4163         idiom; and drop any trailing English-typography exclamation mark that pasted \
4164         from prose.",
4165        ch = *byte as char
4166    )]
4167    FonteCaminhoShellHistoryExpansion {
4168        nome: String,
4169        caminho: String,
4170        byte: u8,
4171    },
4172    #[error(
4173        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4174         history-substitution / RFC-3986-'unwise' / regex-negation metacharacter 0x{byte:02x} \
4175         `{ch}` (POSIX bash's `set -o histexpand` mode — the default for every interactive \
4176         session and every `bash -i` subprocess-argument context `feira tofu` / `git clone` / \
4177         `nix flake check` cross — lexes `^old^new^` per bash reference §9.3 as the 'quick \
4178         substitution' history operator that rewrites the prior command's `old` string to \
4179         `new` and re-executes it verbatim, the canonical typo-correction one-liner idiom \
4180         (`git clone <bad-url>` → `^bad^good` typo-fix-and-rerun the paste-from-shell-\
4181         history author trims only the leading `git clone` prefix from). RFC 3986 §2 lists \
4182         `^` in the 'unwise' set every URL parser is required to percent-encode-or-refuse at \
4183         the wire boundary, and the WHATWG URL spec's 'fragment percent-encode set' maps \
4184         `^` → `%5E` at the query / fragment component transition, so `Path::join` on the \
4185         literal value diverges from every downstream `feira tofu` curl-invocation / \
4186         artifact-registry-fetch that percent-encodes the byte before the wire. `^` is also \
4187         the regex character-class negation prefix (`[^abc]`), the bitwise XOR operator in \
4188         C / C++ / Rust / Python / JavaScript / Nix / Go, the Windows `cmd.exe` escape \
4189         metacharacter, and the LaTeX / Markdown / BibTeX superscript operator. POSIX \
4190         `std::path::Path` treats `^` as a literal path-component byte, so \
4191         `:caminho \"../foo^bar/baz\"` (embedded quick-substitution), `:caminho \
4192         \"../foo^\"` (trailing history-substitution-open shape), or `:caminho \"../x^y\"` \
4193         (XOR-expression paste-from-source) silently pass every prior cascade arm (`^` \
4194         isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / `?` / `(` / `)` / `{{` \
4195         / `}}` / `[` / `]` / `'` / `\"` / `#` / `%` / `$` / `!`) and route through \
4196         `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` subdirectory \
4197         that fails at resolve time with a non-self-locating `No such file or directory` \
4198         error far from the source caixa.lisp. The lacre pipeline embeds the value verbatim \
4199         in its per-dep content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, \
4200         so the byte lands in the BLAKE3 closure and rides into every shell-spawned \
4201         subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a future \
4202         operator-side `nix flake check` spawn) as the canonical shell-history-substitution \
4203         / RFC-3986-unwise surface every peer single-token-shaped typed slot already closes. \
4204         The peer `:fonte :repo` axis closes the byte under the same shell-history-\
4205         substitution / RFC-3986-unwise banner (49e142f `^` on `is_git_repo_url`). Together \
4206         with the immediate-predecessor `!` arm (6a04767) this arm closes the full `set -o \
4207         histexpand` operator surface on the `:caminho` axis — the `!command` / `!!` / `!$` \
4208         prefix form via `!`, the `^old^new^` quick-substitution form via `^`. Express the \
4209         path as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
4210         directory name carries no shell-history-substitution / regex-negation / XOR-operator \
4211         semantic; drop any `^old^new` history-substitution paste-from-shell-history idiom; \
4212         drop any trailing `^` history-substitution-open fragment.",
4213        ch = *byte as char
4214    )]
4215    FonteCaminhoShellHistorySubstitution {
4216        nome: String,
4217        caminho: String,
4218        byte: u8,
4219    },
4220    #[error(
4221        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} has a trailing \
4222         `/` (the resolver's `Path::join` resolves `\"../caixa-teia\"` and \
4223         `\"../caixa-teia/\"` to the same directory, but the lacre pipeline embeds the \
4224         value verbatim in its per-dep content-address `path:{caminho}` at \
4225         caixa-resolver/src/resolve.rs:189, so two authors whose only difference is \
4226         shell tab-completion emit byte-divergent BLAKE3 closures for the same caixa — \
4227         defeating the THEORY.md §V.2 render-determinism contract via the trailing-\
4228         separator vector (the canonical paste-from-shell-tab-completion + paste-from-\
4229         `pwd`-with-`/`-suffix footgun, and the canonical Cargo-style `path = \
4230         \"../caixa-teia/\"` paste-from-Cargo-manifest cross-idiom leak). Drop the \
4231         trailing `/`; every `:caminho` value names a sibling-workspace directory \
4232         already, so the trailing separator carries no information. Use \
4233         `\"../caixa-teia\"` rather than `\"../caixa-teia/\"`)"
4234    )]
4235    FonteCaminhoTrailingSlash { nome: String, caminho: String },
4236    #[error(
4237        "{list} carries duplicate entry :nome {nome:?} — every dep list keys its \
4238         entries by caixa name (Cargo's [dependencies] / [dev-dependencies] tables \
4239         apply the same set-not-multiset discipline; one package per table), and \
4240         two entries naming the same caixa carry two version constraints / source \
4241         pins / feature sets for one identity. The caixa-resolver's lacre pipeline \
4242         consumes the list as a `HashMap`-keyed-by-`:nome` lookup: the second entry \
4243         silently overwrites the first at the resolver-side `concrete_versao` step, \
4244         and the dropped entry's pin / features never reach the closure — far from \
4245         the source caixa.lisp, with no field naming which `:deps` entry was the \
4246         silent loser. If two version constraints are genuinely needed (the rare \
4247         multi-version closure case the lacre pipeline doesn't yet support), the \
4248         author surface is two distinct caixa names (e.g. a `caixa-teia-v01` / \
4249         `caixa-teia-v02` aliased pair); within one list, one entry per caixa name."
4250    )]
4251    DuplicateNome { nome: String, list: &'static str },
4252    #[error(
4253        ":deps entry {nome:?} has empty :caracteristicas entry — every feature flag must \
4254         name a non-empty identifier on the target caixa (Cargo's [dependencies.<dep>.features] \
4255         applies the same per-entry non-empty discipline). An empty feature flag reaches the \
4256         caixa-resolver's lacre pipeline as a no-op feature enable, silently dropping the \
4257         author's intent far from the source caixa.lisp; drop the empty entry, or replace it \
4258         with the canonical kebab-case feature name the target caixa declares."
4259    )]
4260    CaracteristicaEmpty { nome: String },
4261    #[error(
4262        ":deps entry {nome:?} :caracteristicas entry {caracteristica:?} is not a valid Cargo \
4263         feature name: {reason} (the value flows verbatim into Cargo's \
4264         [dependencies.<dep>.features] list and Cargo's `restricted_names::validate_feature_name` \
4265         parser enforces the same shape at `cargo metadata` time; use a single-token \
4266         identifier like `\"http\"`, `\"derive\"`, or `\"runtime-tokio\"` — kebab-case ASCII \
4267         alphanumeric with `-`, `_`, `+`, or `.` as continuation characters, starting with \
4268         an ASCII alphanumeric or `_`)"
4269    )]
4270    CaracteristicaInvalid {
4271        nome: String,
4272        caracteristica: String,
4273        reason: String,
4274    },
4275    #[error(
4276        ":deps entry {nome:?} :caracteristicas carries duplicate feature {caracteristica:?} — \
4277         every feature-flag list keys its entries by name (Cargo's \
4278         [dependencies.<dep>.features] applies the same set-not-multiset discipline; one entry \
4279         per feature per dep), and two entries naming the same feature are a redundant \
4280         set-membership declaration for one identity (the feature-toggle slot is set-shaped; \
4281         enabling a feature twice has no additional semantic). The caixa-resolver's lacre \
4282         pipeline consumes the list as a set-shaped feature toggle — the resolver enables the \
4283         feature once regardless of declaration count, so the duplicate's pin / position never \
4284         reaches the closure with no field naming the silent loser. One entry per feature per \
4285         dep; if two distinct features are intended, name each verbatim."
4286    )]
4287    CaracteristicaDuplicate {
4288        nome: String,
4289        caracteristica: String,
4290    },
4291    #[error(
4292        "{list} entry :nome {nome:?} names the caixa itself — a caixa cannot depend \
4293         on itself (the lacre closure's dep-graph traversal is rooted at the caixa's \
4294         :nome, and a self-dep would be a one-node cycle the caixa-resolver either \
4295         rejects mid-traversal far from the source caixa.lisp or recurses on until \
4296         it exhausts its stack). Every :nome is globally-unique substrate identity, \
4297         so a :deps / :deps-dev entry whose :nome equals the parent caixa's :nome \
4298         *is* the parent itself, not a coincidentally-named peer. Drop the \
4299         self-referential dep entry — to reference code from this caixa, use \
4300         :bibliotecas / :exe / :servicos (the substrate-blessed shape for \
4301         referencing the caixa's own code surface) instead."
4302    )]
4303    DepIsSelf { nome: String, list: &'static str },
4304}
4305
4306// Fold the eleven `DepError::FonteCaminho<Variant> { nome: nome.to_string(),
4307// caminho: caminho.to_string() }` two-slot struct-variant wire-up sites at
4308// [`DepSource::validate_caminho`] onto one substrate primitive per typed
4309// variant — the paired `{ nome: String, caminho: String }` two-slot family
4310// on [`DepError`], sibling of the peer
4311// [`crate::supervisor::supervisor_caixa_only_ctors!`] (db09650, 3 variants
4312// on `{ caixa: String }`) on the `SupervisorError` envelope, the peer
4313// [`crate::aplicacao::contrato_empty_pair_ctors!`] (8580068, 4 variants on
4314// `{ de, para }`), [`crate::aplicacao::aplicacao_field_reason_ctors!`]
4315// (981060b, 7 variants on `{ <field>: String, reason: String }`),
4316// [`crate::aplicacao::contrato_target_ctors!`] (14b81d5, 2 variants on
4317// `{ de, para, wit, expected }`), and
4318// [`crate::aplicacao::contrato_pair_value_reason_ctors!`] (14e13f1, 3
4319// variants on `{ de, para, <field>: String, reason: String }`) on the
4320// `AplicacaoError` envelopes, the peer
4321// [`crate::layout::layout_violation_ctors!`] (131ca0d, 16 variants on
4322// `{ caixa, issue }`), [`crate::layout::layout_slot_kind_ctors!`]
4323// (0419438, 4 variants on `{ caixa, kind, slots }`),
4324// [`crate::LayoutError::missing_entry`] (1b09f9d, one variant on
4325// `{ kind, path }`), and [`crate::layout::layout_nome_only_ctors!`]
4326// (3fe3dd7, 6 variants on `<Variant>(String)`) on the `LayoutError`
4327// envelopes, the peer three [`crate::limits::limits_codec_value_*_ctors!`]
4328// codec-family macros (81c856c, 12 wire-ups) on the `LimitsError`
4329// envelope, and the peer [`crate::upgrade::upgrade_from_script_ctors!`]
4330// (8e67041, 3 variants on `{ from: String, script: PathBuf }`) on the
4331// `UpgradeError` envelope. First fold family on this `DepError` envelope.
4332//
4333// Each of the eleven wire-up sites on this shape (the leading-byte cascade
4334// closing the seven `FonteCaminho{Absolute, TildeExpansion, VarExpansion,
4335// LeadingWhitespace, LeadingHyphen}` arms; the orthogonal single-metachar
4336// cascade closing `FonteCaminhoBackslash` on `\`; the shell-lexer-metachar
4337// cascade closing `FonteCaminhoShell{Pipe, Semicolon, Background,
4338// CommandSubstitution}` on the four single-byte shell operators; and the
4339// trailing-`/` reproducibility arm closing `FonteCaminhoTrailingSlash`)
4340// opened the identical `DepError::FonteCaminho<Variant> { nome:
4341// nome.to_string(), caminho: caminho.to_string() }` four-line
4342// struct-literal against the same `(nome: &str, caminho: &str)` local pair
4343// — the exact "same block re-inlined at every consumer" shape the PRIME
4344// DIRECTIVE names as a bug, on the same altitude the peer `LayoutError` /
4345// `AplicacaoError` / `SupervisorError` / `LimitsError` / `UpgradeError`
4346// families each closed on their sibling envelopes. The eleven variants
4347// share one `{ nome: String, caminho: String }` shape, so the fold routes
4348// each wire-up site through one dispatch per typed variant.
4349//
4350// The macro below generates one `#[must_use]` inherent constructor per
4351// variant of shape `fn <ctor>(nome: &str, caminho: &str) -> Self`, so every
4352// wire-up site collapses onto one dispatch:
4353// `DepError::<ctor>(nome, caminho)`, byte-equal to the pre-lift
4354// struct-literal on the same `(&str, &str)` fixture. The uniform two-field
4355// construction (`nome.to_string()` / `caminho.to_string()`) is spelled
4356// once — inside the macro — rather than at every wire-up site.
4357//
4358// The twelve `FonteCaminho<Variant> { nome, caminho, byte }` three-field
4359// shapes at the per-byte-classification arms — the
4360// `FonteCaminho{ControlChar,ShellRedirection,ShellGlob,
4361// ShellSubshellGrouping,ShellBraceExpansion,ShellBracketExpansion,
4362// ShellQuoteGrouping,ShellComment,UrlPercentEncoding,
4363// ShellVariableExpansion,ShellHistoryExpansion,ShellHistorySubstitution}`
4364// cluster — carry an additional `byte: u8` naming the offending byte and
4365// so would break the uniform-two-field routing this macro promises. They
4366// instead fold onto the sibling three-field envelope through
4367// [`fonte_caminho_byte_ctors!`] (this-commit-lift, 12 variants on the
4368// `{ nome, caminho, byte }` shape), whose sole additional axis over this
4369// two-slot family is the `byte: u8` classification the arms carry. The
4370// remaining `FonteCaminhoEmpty` one-field `{ nome }` shape at the empty-
4371// first arm folds instead onto the peer [`dep_nome_only_ctors!`]
4372// (792aa92, 5 variants on `{ nome: String }`) sibling family of this
4373// envelope.
4374//
4375// Every future consumer that wants to construct one of these eleven
4376// variants outside the current in-crate [`DepSource::validate_caminho`]
4377// wire-up sites (a deferred `caixa-resolver` per-`:caminho` re-validator
4378// at lacre-resolve time re-checking the same value-shape axes the resolver
4379// consumes, a future `feira validate --deps` per-caixa admission verb
4380// re-checking the `:fonte :caminho` axis, a per-lacre overlay resolver
4381// rejecting a `:caminho` value against a cluster-local snapshot) now
4382// reaches each variant through one call rather than re-inlining the
4383// four-line struct-literal in lockstep with the eleven in-crate wire-up
4384// sites.
4385macro_rules! fonte_caminho_ctors {
4386    ($($ctor:ident => $variant:ident),* $(,)?) => {
4387        impl DepError {
4388            $(
4389                #[doc = concat!(
4390                    "Construct a [`DepError::",
4391                    stringify!($variant),
4392                    "`] naming the offending `:deps :nome` + `:fonte ",
4393                    "(:tipo path …) :caminho` pair. Folds the uniform ",
4394                    "`Self::",
4395                    stringify!($variant),
4396                    " { nome: nome.to_string(), caminho: caminho.to_string() }` ",
4397                    "two-slot struct-literal onto one substrate primitive so ",
4398                    "every [`DepSource::validate_caminho`] wire-up on this ",
4399                    "variant reads through one dispatch rather than the ",
4400                    "pre-lift four-line open-coded block."
4401                )]
4402                #[must_use]
4403                pub fn $ctor(nome: &str, caminho: &str) -> Self {
4404                    Self::$variant {
4405                        nome: nome.to_string(),
4406                        caminho: caminho.to_string(),
4407                    }
4408                }
4409            )*
4410        }
4411    };
4412}
4413
4414fonte_caminho_ctors! {
4415    fonte_caminho_absolute => FonteCaminhoAbsolute,
4416    fonte_caminho_tilde_expansion => FonteCaminhoTildeExpansion,
4417    fonte_caminho_var_expansion => FonteCaminhoVarExpansion,
4418    fonte_caminho_leading_whitespace => FonteCaminhoLeadingWhitespace,
4419    fonte_caminho_leading_hyphen => FonteCaminhoLeadingHyphen,
4420    fonte_caminho_backslash => FonteCaminhoBackslash,
4421    fonte_caminho_shell_pipe => FonteCaminhoShellPipe,
4422    fonte_caminho_shell_semicolon => FonteCaminhoShellSemicolon,
4423    fonte_caminho_shell_background => FonteCaminhoShellBackground,
4424    fonte_caminho_shell_command_substitution => FonteCaminhoShellCommandSubstitution,
4425    fonte_caminho_trailing_slash => FonteCaminhoTrailingSlash,
4426}
4427
4428// Fold the twelve `DepError::FonteCaminho<Variant> { nome: nome.to_string(),
4429// caminho: caminho.to_string(), byte: b }` three-slot struct-variant wire-up
4430// sites at [`DepSource::validate_caminho`] onto one substrate primitive per
4431// typed variant — the paired `{ nome: String, caminho: String, byte: u8 }`
4432// three-slot family on [`DepError`], strict sibling of the peer
4433// [`fonte_caminho_ctors!`] (f85f145, 11 variants on the two-slot
4434// `{ nome: String, caminho: String }` envelope) of this envelope. Extends
4435// that fold onto the `byte`-classifying arms whose additional `byte: u8`
4436// axis broke its uniform-two-field routing — the exact "future compounding
4437// work" the pre-lift `fonte_caminho_ctors!` prose named as deferred, closed
4438// here. Third fold family on this `DepError` envelope, sibling of the peer
4439// two-slot [`fonte_caminho_ctors!`] and one-slot [`dep_nome_only_ctors!`]
4440// (792aa92, 5 variants on the `{ nome: String }` envelope) families on the
4441// same enum.
4442//
4443// Each of the twelve wire-up sites on this shape (the control-byte arm
4444// closing `FonteCaminhoControlChar` on the sub-`0x20` / `0x7F` cluster; the
4445// shell-lexer-metachar cascade closing `FonteCaminhoShellRedirection` on
4446// `< >`, `FonteCaminhoShellGlob` on `* ?`, `FonteCaminhoShellSubshellGrouping`
4447// on `( )`, `FonteCaminhoShellBraceExpansion` on `{ }`,
4448// `FonteCaminhoShellBracketExpansion` on `[ ]`, and
4449// `FonteCaminhoShellQuoteGrouping` on `' "`; the single-metachar arms
4450// closing `FonteCaminhoShellComment` on `#`, `FonteCaminhoUrlPercentEncoding`
4451// on `%`, `FonteCaminhoShellVariableExpansion` on `$`,
4452// `FonteCaminhoShellHistoryExpansion` on `!`, and
4453// `FonteCaminhoShellHistorySubstitution` on `^`) opened the identical
4454// `DepError::FonteCaminho<Variant> { nome: nome.to_string(),
4455// caminho: caminho.to_string(), byte: b }` five-line struct-literal against
4456// the same `(nome: &str, caminho: &str, b: u8)` local triple — the exact
4457// "same block re-inlined at every consumer" shape the PRIME DIRECTIVE names
4458// as a bug, on the same altitude the peer two-slot `fonte_caminho_ctors!`
4459// closed on the sibling two-field envelope of this same enum. The twelve
4460// variants share one `{ nome: String, caminho: String, byte: u8 }` shape, so
4461// the fold routes each wire-up site through one dispatch per typed variant.
4462//
4463// The macro below generates one `#[must_use]` inherent constructor per
4464// variant of shape `fn <ctor>(nome: &str, caminho: &str, byte: u8) -> Self`,
4465// so every wire-up site collapses onto one dispatch:
4466// `DepError::<ctor>(nome, caminho, b)`, byte-equal to the pre-lift
4467// struct-literal on the same `(&str, &str, u8)` fixture. The uniform
4468// three-field construction (`nome.to_string()` / `caminho.to_string()` /
4469// `byte`) is spelled once — inside the macro — rather than at every wire-up
4470// site.
4471//
4472// Every future consumer that wants to construct one of these twelve
4473// variants outside the current in-crate [`DepSource::validate_caminho`]
4474// wire-up sites (a deferred `caixa-resolver` per-`:caminho` re-validator
4475// at lacre-resolve time re-checking the same value-shape axes the resolver
4476// consumes, a future `feira validate --deps` per-caixa admission verb
4477// re-checking the `:fonte :caminho` axis against the shell-metachar
4478// classification bytes this cluster catches, a per-lacre overlay resolver
4479// rejecting a `:caminho` value against a cluster-local snapshot) now
4480// reaches each variant through one call rather than re-inlining the
4481// five-line struct-literal in lockstep with the twelve in-crate wire-up
4482// sites.
4483macro_rules! fonte_caminho_byte_ctors {
4484    ($($ctor:ident => $variant:ident),* $(,)?) => {
4485        impl DepError {
4486            $(
4487                #[doc = concat!(
4488                    "Construct a [`DepError::",
4489                    stringify!($variant),
4490                    "`] naming the offending `:deps :nome` + `:fonte ",
4491                    "(:tipo path …) :caminho` pair + the offending `byte: u8` ",
4492                    "classification. Folds the uniform `Self::",
4493                    stringify!($variant),
4494                    " { nome: nome.to_string(), caminho: caminho.to_string(), ",
4495                    "byte }` three-slot struct-literal onto one substrate ",
4496                    "primitive so every [`DepSource::validate_caminho`] wire-up ",
4497                    "on this variant reads through one dispatch rather than ",
4498                    "the pre-lift five-line open-coded block."
4499                )]
4500                #[must_use]
4501                pub fn $ctor(nome: &str, caminho: &str, byte: u8) -> Self {
4502                    Self::$variant {
4503                        nome: nome.to_string(),
4504                        caminho: caminho.to_string(),
4505                        byte,
4506                    }
4507                }
4508            )*
4509        }
4510    };
4511}
4512
4513fonte_caminho_byte_ctors! {
4514    fonte_caminho_control_char => FonteCaminhoControlChar,
4515    fonte_caminho_shell_redirection => FonteCaminhoShellRedirection,
4516    fonte_caminho_shell_glob => FonteCaminhoShellGlob,
4517    fonte_caminho_shell_subshell_grouping => FonteCaminhoShellSubshellGrouping,
4518    fonte_caminho_shell_brace_expansion => FonteCaminhoShellBraceExpansion,
4519    fonte_caminho_shell_bracket_expansion => FonteCaminhoShellBracketExpansion,
4520    fonte_caminho_shell_quote_grouping => FonteCaminhoShellQuoteGrouping,
4521    fonte_caminho_shell_comment => FonteCaminhoShellComment,
4522    fonte_caminho_url_percent_encoding => FonteCaminhoUrlPercentEncoding,
4523    fonte_caminho_shell_variable_expansion => FonteCaminhoShellVariableExpansion,
4524    fonte_caminho_shell_history_expansion => FonteCaminhoShellHistoryExpansion,
4525    fonte_caminho_shell_history_substitution => FonteCaminhoShellHistorySubstitution,
4526}
4527
4528// Fold the five `DepError::<Variant> { nome: <owner>.clone_or_to_string() }`
4529// single-slot struct-variant wire-up sites scattered across
4530// [`Dep::validate`] / [`Dep::validate_caracteristicas`] /
4531// [`DepSource::validate`] / [`DepSource::validate_caminho`] onto one
4532// substrate primitive per typed variant — the paired `{ nome: String }`
4533// single-slot family on [`DepError`], sibling of the peer
4534// [`fonte_caminho_ctors!`] (f85f145, 11 variants on
4535// `{ nome: String, caminho: String }`) on the sibling two-slot envelope of
4536// the same enum, and of the peer
4537// [`crate::supervisor::supervisor_caixa_only_ctors!`] (db09650, 3 variants
4538// on `{ caixa: String }`) on the `SupervisorError` envelope's single-slot
4539// axis. Second fold family on this `DepError` envelope, and the first on
4540// the single-`{ nome }` shape.
4541//
4542// The five wire-up sites this fold closes each opened the identical
4543// `DepError::<Variant> { nome: <owner>.to_string_or_clone() }` three-line
4544// struct-literal against the same `nome: &str` (or `self.nome: &String`)
4545// local — the exact "same block re-inlined at every consumer" shape the
4546// PRIME DIRECTIVE names as a bug. The five variants share one
4547// `{ nome: String }` shape, so the fold routes each wire-up site through
4548// one dispatch per typed variant.
4549//
4550// The macro below generates one `#[must_use]` inherent constructor per
4551// variant of shape `fn <ctor>(nome: &str) -> Self`, so every wire-up site
4552// collapses onto one dispatch: `DepError::<ctor>(nome)`, byte-equal to the
4553// pre-lift struct-literal on the same `&str` fixture. The uniform
4554// one-field construction (`nome.to_string()`) is spelled once — inside
4555// the macro — rather than at every wire-up site. Callers that hold a
4556// `String` (`self.nome`) pass `&self.nome`, which auto-derefs to `&str`
4557// and lets the macro-owned `.to_string()` produce the fresh owning copy
4558// the enum variant needs; the semantics collapse onto the same
4559// `.clone()`-equivalent one this fold replaces at every site.
4560//
4561// The sibling `NomeEmpty` unit-variant (`enum DepError { NomeEmpty, … }`)
4562// on the same envelope stays on its pre-lift open-coded wire-up shape —
4563// it carries no `nome` field (the offending `:nome` value *is* the empty
4564// string this variant catches) so the uniform `fn(nome: &str) -> Self`
4565// signature this macro promises does not apply. Every future consumer
4566// that wants to construct one of these five variants outside the current
4567// in-crate wire-up sites (a deferred `caixa-resolver` per-`:versao` /
4568// `:caracteristicas` / `:fonte :repo` / `:fonte :pin` / `:fonte :caminho`
4569// re-validator at lacre-resolve time, a future `feira validate --deps`
4570// per-caixa admission verb, a per-lacre overlay resolver rejecting one of
4571// these empty-value shapes against a cluster-local snapshot) now reaches
4572// each variant through one call rather than re-inlining the three-line
4573// struct-literal in lockstep with the five in-crate wire-up sites.
4574macro_rules! dep_nome_only_ctors {
4575    ($($ctor:ident => $variant:ident),* $(,)?) => {
4576        impl DepError {
4577            $(
4578                #[doc = concat!(
4579                    "Construct a [`DepError::",
4580                    stringify!($variant),
4581                    "`] naming the offending `:deps :nome`. Folds the ",
4582                    "uniform `Self::",
4583                    stringify!($variant),
4584                    " { nome: nome.to_string() }` one-field ",
4585                    "struct-literal onto one substrate primitive so every ",
4586                    "in-crate wire-up on this variant reads through one ",
4587                    "dispatch rather than the pre-lift three-line ",
4588                    "open-coded block."
4589                )]
4590                #[must_use]
4591                pub fn $ctor(nome: &str) -> Self {
4592                    Self::$variant { nome: nome.to_string() }
4593                }
4594            )*
4595        }
4596    };
4597}
4598
4599dep_nome_only_ctors! {
4600    versao_empty => VersaoEmpty,
4601    fonte_repo_empty => FonteRepoEmpty,
4602    fonte_pin_missing => FontePinMissing,
4603    fonte_caminho_empty => FonteCaminhoEmpty,
4604    caracteristica_empty => CaracteristicaEmpty,
4605}
4606
4607// Fold the four `DepError::{DuplicateNome, DepIsSelf}` struct-variant
4608// wire-up sites at [`crate::manifest::Caixa::push_dep`] +
4609// [`crate::manifest::Caixa::validate_deps`] +
4610// [`validate_no_self_dep`] onto one substrate-primitive family per
4611// typed variant — the `DepError`-side siblings of the peer
4612// [`crate::supervisor::supervisor_caixa_only_ctors!`] macro (db09650)
4613// on the `SupervisorError { caixa: String }` one-slot envelope and of
4614// the peer [`dep_nome_only_ctors!`] macro (792aa92) on the
4615// `DepError { nome: String }` one-slot envelope. The two variants
4616// carry the same `{ nome: String, list: &'static str }` two-slot
4617// shape: the `nome` field names the offending dep the diagnostic
4618// points the author back at, and the `list` field carries the
4619// `":deps"` / `":deps-dev"` author-surface tag verbatim (via
4620// [`crate::dep::DepList::as_str`] on the [`push_dep`] /
4621// [`validate_deps`] arms, and via the paired
4622// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
4623// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `&'static str`
4624// canonicals on the [`validate_no_self_dep`] arm) so the author can
4625// grep their caixa.lisp for the offending list block in one edit.
4626//
4627// Each of the four wire-up sites opened the same struct-literal
4628// `DepError::<Variant> { nome: <name>.to_string(), list: <tag> }`
4629// two-line block — the exact "same block re-inlined at every
4630// consumer" shape the PRIME DIRECTIVE names as a bug, on the same
4631// altitude the peer `DepError` / `SupervisorError` /
4632// `AplicacaoError` / `LayoutError` / `LimitsError` ctor families
4633// already closed on their sibling envelopes. The two `#[must_use]`
4634// inherent constructors below fold each wire-up onto one dispatch:
4635// `DepError::duplicate_nome(<nome>, <list>)` and
4636// `DepError::dep_is_self(<nome>, <list>)`, byte-equal to the
4637// pre-lift struct-literal on the same scalar fixtures. The `list:
4638// &'static str` parameter (not `impl Into<String>`) preserves the
4639// exact wire tag every consumer already passes verbatim — no
4640// downstream diagnostic reshaping at the lift, matching the peer
4641// `DepList::as_str` / `DEP_AUTHOR_KEY_DEPS*` `&'static str`
4642// contract each wire-up site already keys off.
4643macro_rules! dep_nome_list_ctors {
4644    ($($ctor:ident => $variant:ident),* $(,)?) => {
4645        impl DepError {
4646            $(
4647                #[doc = concat!(
4648                    "Construct a [`DepError::",
4649                    stringify!($variant),
4650                    "`] naming the offending `:deps :nome` and the ",
4651                    "author-surface list tag (`:deps` vs. `:deps-dev`) ",
4652                    "the diagnostic points the author back at. Folds ",
4653                    "the uniform `Self::",
4654                    stringify!($variant),
4655                    " { nome: nome.to_string(), list }` two-field ",
4656                    "struct-literal onto one substrate primitive so ",
4657                    "every in-crate wire-up on this variant reads ",
4658                    "through one dispatch rather than the pre-lift ",
4659                    "open-coded struct-literal block."
4660                )]
4661                #[must_use]
4662                pub fn $ctor(nome: &str, list: &'static str) -> Self {
4663                    Self::$variant { nome: nome.to_string(), list }
4664                }
4665            )*
4666        }
4667    };
4668}
4669
4670dep_nome_list_ctors! {
4671    duplicate_nome => DuplicateNome,
4672    dep_is_self => DepIsSelf,
4673}
4674
4675// Fold the two `DepError::FontePinShape { nome: nome.to_string(),
4676// pin: <pin>.to_string(), value: v.clone(), reason }` four-slot
4677// struct-variant wire-up sites at [`DepSource::validate`]'s
4678// per-`:fonte` git-pin value-shape gate onto one substrate primitive on
4679// the `DepError` envelope — the last open-coded ctor site remaining on
4680// the `:fonte (:tipo git …)` value-shape trajectory this envelope
4681// carries, and the single-variant sibling of the peer four already-
4682// lifted [`DepError`] ctor families ([`fonte_caminho_ctors!`] f85f145
4683// on the two-slot `{ nome, caminho }` envelope,
4684// [`fonte_caminho_byte_ctors!`] 0e35793 on the three-slot
4685// `{ nome, caminho, byte }` envelope, [`dep_nome_only_ctors!`] 792aa92
4686// on the one-slot `{ nome }` envelope, and [`dep_nome_list_ctors!`]
4687// 6f5e0cd on the two-slot `{ nome, list }` envelope). Peer of the
4688// sibling [`crate::aplicacao::contrato_pair_value_reason_ctors!`]
4689// (14e13f1) four-slot fold on the `AplicacaoError` envelope — same
4690// `{ …, value: String, reason: String }` payload shape, one axis
4691// removed at the `nome`-only-owner altitude the `DepError` envelope
4692// keys off (no `edge_pair()` de/para pair).
4693//
4694// The two wire-up sites this fold closes are the paired refname-pin
4695// arm (`|| DepError::FontePinShape { nome: nome.to_string(),
4696// pin: pin.to_string(), value: v.clone(), reason }` inside the
4697// `[(":tag", tag), (":branch", branch)]` iterator against
4698// [`crate::render::is_git_ref_name`]) and the hex-OID-pin arm
4699// (`|| DepError::FontePinShape { nome: nome.to_string(),
4700// pin: ":rev".to_string(), value: v.clone(), reason }` against
4701// [`crate::render::is_git_oid`]) — each opened the identical
4702// `DepError::FontePinShape { … }` six-line struct-literal against the
4703// same `(nome: &str, pin: &str, v: &String, reason: String)` local
4704// tuple, the exact "same block re-inlined at every consumer" shape
4705// the PRIME DIRECTIVE names as a bug. The `pin` axis discriminator is
4706// the only thing that varies between them (`":tag"`/`":branch"` on
4707// the refname arm, `":rev"` on the hex-OID arm); the rest of the
4708// struct-literal is a byte-for-byte re-inline. Refname/hex-OID both
4709// route through the same ctor because their `pin` field carries the
4710// author-surface tag verbatim (matching the `FontePinEmpty` /
4711// `FontePinAmbiguous` sibling variants' `pin: String` axis
4712// convention), so the offending author can grep their caixa.lisp for
4713// the offending `:tag "<value>"` / `:branch "<value>"` /
4714// `:rev "<value>"` literal in one edit.
4715//
4716// The single ctor below folds each wire-up onto one dispatch:
4717// `DepError::fonte_pin_shape(nome, pin, v, reason)`, byte-equal to
4718// the pre-lift struct-literal on the same `(&str, &str, &str,
4719// String)` fixture. The uniform four-field construction
4720// (`nome.to_string()` / `pin.to_string()` / `value.to_string()` /
4721// `reason` forwarded owned) is spelled once here rather than at every
4722// wire-up site. The `reason: String` field takes an owned `String`
4723// (not `impl Into<String>`) matching the two call sites' pre-existing
4724// `let Err(reason) = crate::render::is_git_ref_name(v)` /
4725// `let Err(reason) = crate::render::is_git_oid(v)` shape — both
4726// predicates return `Result<(), String>`, so the caller always holds
4727// an owned `String` at the wire-up site and threading it through the
4728// ctor without a `.into()` shim keeps the routing shape byte-equal to
4729// the pre-lift block. The `value: &str` parameter accepts both `&str`
4730// literals (unused today) and `&String` (from the caller-held
4731// `v: &String` on each arm, via Deref coercion), so every existing
4732// wire-up threads through the ctor without a pre-conversion.
4733//
4734// Every future consumer that wants to construct this variant outside
4735// the two in-crate [`DepSource::validate`] wire-up sites (a deferred
4736// `caixa-resolver` per-`:fonte` re-validator at lacre-resolve time
4737// re-checking the same value-shape axes the resolver consumes, a
4738// future `feira validate --deps` per-caixa admission verb re-checking
4739// the `:fonte :tag`/`:branch`/`:rev` axes, a per-lacre overlay
4740// resolver rejecting a git-pin value against a cluster-local
4741// snapshot) now reaches this variant through one call rather than
4742// re-inlining the six-line struct-literal in lockstep with the two
4743// in-crate wire-up sites.
4744impl DepError {
4745    /// Construct a [`DepError::FontePinShape`] naming the offending
4746    /// `:deps :nome`, the offending `:fonte (:tipo git …) :<pin>`
4747    /// axis tag, the offending value, and the parser-shaped `reason`.
4748    /// Folds the uniform
4749    /// `Self::FontePinShape { nome: nome.to_string(),
4750    /// pin: pin.to_string(), value: value.to_string(), reason }`
4751    /// four-field struct-literal onto one substrate primitive so
4752    /// every [`DepSource::validate`] wire-up on this variant reads
4753    /// through one dispatch rather than the pre-lift six-line
4754    /// open-coded block. The `nome` string threads verbatim from
4755    /// [`Dep::nome`] at the call site; the `pin` string carries the
4756    /// author-surface `:tag` / `:branch` / `:rev` tag verbatim; the
4757    /// `value` string carries the offending refname / hex-OID
4758    /// verbatim; and `reason` forwards the owned `String` returned
4759    /// by [`crate::render::is_git_ref_name`] /
4760    /// [`crate::render::is_git_oid`] without a `.into()` shim.
4761    #[must_use]
4762    pub fn fonte_pin_shape(nome: &str, pin: &str, value: &str, reason: String) -> Self {
4763        Self::FontePinShape {
4764            nome: nome.to_string(),
4765            pin: pin.to_string(),
4766            value: value.to_string(),
4767            reason,
4768        }
4769    }
4770}
4771
4772#[allow(clippy::trivially_copy_pass_by_ref)]
4773fn is_false(b: &bool) -> bool {
4774    !*b
4775}
4776
4777#[cfg(test)]
4778mod tests {
4779    use super::*;
4780
4781    #[test]
4782    fn registry_dep_is_minimal() {
4783        let d = Dep::simple("caixa-teia", "^0.1");
4784        assert_eq!(d.nome, "caixa-teia");
4785        assert_eq!(d.versao, "^0.1");
4786        assert!(d.fonte.is_none());
4787        assert!(!d.opcional());
4788        assert!(d.caracteristicas().is_empty());
4789    }
4790
4791    #[test]
4792    fn dep_string_scalar_accessor_pair_is_const_fn() {
4793        // Fail-before-pass-after pin on [`Dep::nome`] +
4794        // [`Dep::versao_requirement`]'s `const`-eval-surface posture.
4795        // Each accessor projects the per-`:deps` / per-`:deps-dev`
4796        // entry's [`String`] storage through the `pub const fn`
4797        // [`String::as_str`] (const-stable since Rust 1.87, well
4798        // within the workspace MSRV) — any future accidental
4799        // downgrade to non-`const` fails the corresponding
4800        // `<name>_via_const_fn` wrapper at caixa-core build time with
4801        // E0015 (`cannot call non-const method`), strictly stronger
4802        // than a runtime `assert!`. Sibling of the peer
4803        // per-M2/M3/universal-axis `String → &str` scalar-accessor
4804        // family pins on the sibling `const`-eval-surface passes
4805        // ([`crate::Caixa::nome`] / [`crate::Caixa::versao`] at the
4806        // top-level manifest, [`crate::CaixaVersion::as_str`] at the
4807        // typed-newtype wrapper, [`crate::aplicacao::Membro::nome`] /
4808        // [`crate::aplicacao::Membro::versao_requirement`] at the M3
4809        // membership axis, [`crate::aplicacao::Entrada::hostname`] /
4810        // [`crate::aplicacao::Entrada::destination`] at the M3
4811        // ingress axis, [`crate::supervisor::ChildSpec::nome`] /
4812        // [`crate::supervisor::ChildSpec::versao_requirement`] at the
4813        // M2 supervisor-tree axis,
4814        // [`crate::upgrade::UpgradeFromEntry::prior_versao`] at the
4815        // M2 upgrade axis, and the per-`:contratos`
4816        // [`crate::aplicacao::WitContract::source`] /
4817        // [`crate::aplicacao::WitContract::destination`] /
4818        // [`crate::aplicacao::WitContract::world_ref`] trio the
4819        // sibling pin at 279823b already anchors).
4820        const fn nome_via_const_fn(d: &Dep) -> &str {
4821            d.nome()
4822        }
4823        const fn versao_via_const_fn(d: &Dep) -> &str {
4824            d.versao_requirement()
4825        }
4826        for (nome, versao) in [
4827            ("caixa-teia", "^0.1"),
4828            ("caixa-mesh", "~0.2.3"),
4829            ("caixa-helm", "*"),
4830        ] {
4831            let d = Dep::simple(nome, versao);
4832            assert_eq!(nome_via_const_fn(&d), d.nome());
4833            assert_eq!(versao_via_const_fn(&d), d.versao_requirement());
4834            assert_eq!(d.nome(), nome);
4835            assert_eq!(d.versao_requirement(), versao);
4836        }
4837    }
4838
4839    #[test]
4840    fn dep_outer_accessor_family_is_const_fn() {
4841        // Fail-before-pass-after pin on [`Dep::fonte`] +
4842        // [`Dep::caracteristicas`]'s `const`-eval-surface posture.
4843        // Each accessor projects the per-`:deps` / per-`:deps-dev`
4844        // entry's composite / list storage through a `pub const fn`
4845        // stdlib method (`Option::<DepSource>::as_ref` /
4846        // `Vec::<String>::as_slice`, both const-stable since Rust
4847        // 1.83, well within the workspace MSRV). Any future
4848        // accidental downgrade to non-`const` fails the corresponding
4849        // `<name>_via_const_fn` wrapper at caixa-core build time with
4850        // E0015 (`cannot call non-const method`), strictly stronger
4851        // than a runtime `assert!` and side-stepping the destructor-
4852        // in-const restriction the `Dep` fixture's `String` /
4853        // `Option<DepSource>` / `Vec<String>` carriers rule out on the
4854        // direct-`const _: () = assert!(...)` residence.
4855        //
4856        // Peer of the sibling per-`Dep` scalar-accessor pair pin
4857        // [`dep_string_scalar_accessor_pair_is_const_fn`] on the same
4858        // outer per-dep-list-entry [`Dep`] altitude — this pin extends
4859        // the `const`-eval-surface discipline onto the composite-
4860        // reference and slice-return arms of the outer-`Dep` accessor
4861        // family, closing the four-slot outer surface (`:nome` +
4862        // `:versao` + `:fonte` + `:caracteristicas`) on the `const`-fn
4863        // posture. The `:opcional` `bool` arm already carries the
4864        // posture through [`Dep::opcional`]'s prior `pub const fn`
4865        // declaration, so this pin lands the last two unlifted
4866        // outer-`Dep` accessors and closes the family.
4867        const fn fonte_via_const_fn(d: &Dep) -> Option<&DepSource> {
4868            d.fonte()
4869        }
4870        const fn caracteristicas_via_const_fn(d: &Dep) -> &[String] {
4871            d.caracteristicas()
4872        }
4873        // `Dep::simple` — no `:fonte`, empty `:caracteristicas`.
4874        let empty = Dep::simple("caixa-teia", "^0.1");
4875        assert!(fonte_via_const_fn(&empty).is_none());
4876        assert_eq!(fonte_via_const_fn(&empty), empty.fonte());
4877        assert!(caracteristicas_via_const_fn(&empty).is_empty());
4878        assert_eq!(
4879            caracteristicas_via_const_fn(&empty),
4880            empty.caracteristicas()
4881        );
4882        // `Dep::git` — `:fonte` is `Some(Git{…})`, `:caracteristicas`
4883        // still empty.
4884        let git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
4885        assert!(fonte_via_const_fn(&git).is_some());
4886        assert_eq!(fonte_via_const_fn(&git), git.fonte());
4887        assert_eq!(caracteristicas_via_const_fn(&git), git.caracteristicas());
4888        // Populated `:caracteristicas` — exercise the non-empty
4889        // slice-view arm to pin the accessor's borrow shape against
4890        // both a `Vec::new()` empty backing buffer and a populated one.
4891        let mut with_features = Dep::simple("caixa-teia", "^0.1");
4892        with_features.caracteristicas = vec!["feat-a".into(), "feat-b".into()];
4893        assert_eq!(caracteristicas_via_const_fn(&with_features).len(), 2);
4894        assert_eq!(
4895            caracteristicas_via_const_fn(&with_features),
4896            with_features.caracteristicas()
4897        );
4898    }
4899
4900    #[test]
4901    fn git_dep_carries_tag() {
4902        let d = Dep::git("t", "*", "github:o/r", "v1");
4903        match d.fonte {
4904            Some(DepSource::Git {
4905                ref repo, ref tag, ..
4906            }) => {
4907                assert_eq!(repo, "github:o/r");
4908                assert_eq!(tag.as_deref(), Some("v1"));
4909            }
4910            _ => panic!("expected Git source"),
4911        }
4912    }
4913
4914    #[test]
4915    fn validate_accepts_simple_dep() {
4916        Dep::simple("caixa-teia", "^0.1").validate().unwrap();
4917    }
4918
4919    #[test]
4920    fn validate_rejects_empty_nome() {
4921        // The fail-before-pass-after pin for `:nome ""`: the empty-name
4922        // arm fires first so the per-entry parse-side diagnostic doesn't
4923        // emit a useless `nome: ""` reference.
4924        let mut d = Dep::simple("placeholder", "^0.1");
4925        d.nome = String::new();
4926        assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
4927    }
4928
4929    #[test]
4930    fn validate_rejects_empty_versao() {
4931        // `parse_requirement("")` returns `Ok(VersionReq::STAR)` (the
4932        // semver crate accepts the empty string as a wildcard match),
4933        // so the empty-`:versao` arm is structurally necessary even
4934        // with the parse arm in place — mirrors `MembroVersaoEmpty` /
4935        // `EmptyChildVersion` ordering on the other two `:versao` axes.
4936        let mut d = Dep::simple("caixa-teia", "ignored");
4937        d.versao = String::new();
4938        let err = d.validate().unwrap_err();
4939        assert!(
4940            matches!(err, DepError::VersaoEmpty { ref nome } if nome == "caixa-teia"),
4941            "got {err:?}"
4942        );
4943    }
4944
4945    // ── value-shape: DNS-1123 label on :deps :nome ────────────────────────
4946
4947    #[test]
4948    fn validate_rejects_nome_with_uppercase() {
4949        // The fail-before-pass-after pin: a non-empty but uppercase
4950        // `:nome` silently passed `validate()` on every pre-gate
4951        // codebase because the prior shape only refused the empty
4952        // string. The DNS-1123 violation surfaced far downstream at
4953        // lacre-resolve time when the *target* caixa's `:nome` failed
4954        // its own gate — far from the `:deps` entry, with a diagnostic
4955        // naming the target rather than the dep entry that referenced
4956        // it. Same fail-before-pass-after fixture pinned for
4957        // `:membros :caixa` (3f9d7a0), `:children :caixa` (31bfa43),
4958        // and Caixa `:nome` (6c992f8).
4959        let d = Dep::simple("Caixa-Teia", "^0.1");
4960        let err = d.validate().unwrap_err();
4961        assert!(
4962            matches!(
4963                err,
4964                DepError::NomeInvalid { ref nome, ref reason }
4965                    if nome == "Caixa-Teia" && reason.contains("uppercase")
4966            ),
4967            "got {err:?}"
4968        );
4969    }
4970
4971    #[test]
4972    fn validate_rejects_nome_with_underscore() {
4973        // RFC 1123 allows `[a-z0-9-]` only; underscore is the canonical
4974        // "I'm thinking of Go module names / Python identifiers" leak.
4975        // Same fixture pinned for the peer caixa-identifier axes.
4976        let d = Dep::simple("caixa_teia", "^0.1");
4977        let err = d.validate().unwrap_err();
4978        assert!(
4979            matches!(
4980                err,
4981                DepError::NomeInvalid { ref nome, ref reason }
4982                    if nome == "caixa_teia" && reason.contains('_')
4983            ),
4984            "got {err:?}"
4985        );
4986    }
4987
4988    #[test]
4989    fn validate_rejects_nome_with_dot() {
4990        // A `:deps :nome` is a single DNS-1123 *label*, not a
4991        // subdomain — dots are rejected. The `"caixa.teia"` shape is
4992        // the canonical "I confused the dep name with the FQDN /
4993        // namespace" footgun, distinct from the legitimate
4994        // `:fonte :repo "github:org/caixa-teia"` axis.
4995        let d = Dep::simple("caixa.teia", "^0.1");
4996        let err = d.validate().unwrap_err();
4997        assert!(
4998            matches!(
4999                err,
5000                DepError::NomeInvalid { ref nome, ref reason }
5001                    if nome == "caixa.teia" && reason.contains('.')
5002            ),
5003            "got {err:?}"
5004        );
5005    }
5006
5007    #[test]
5008    fn validate_rejects_nome_with_leading_hyphen() {
5009        // RFC 1123 requires alphanumeric at both label boundaries.
5010        // Pinned in parity with the peer DNS-1123 fixtures.
5011        let d = Dep::simple("-caixa-teia", "^0.1");
5012        let err = d.validate().unwrap_err();
5013        assert!(
5014            matches!(
5015                err,
5016                DepError::NomeInvalid { ref nome, ref reason }
5017                    if nome == "-caixa-teia" && reason.contains("alphanumeric")
5018            ),
5019            "got {err:?}"
5020        );
5021    }
5022
5023    #[test]
5024    fn validate_rejects_nome_with_trailing_hyphen() {
5025        let d = Dep::simple("caixa-teia-", "^0.1");
5026        let err = d.validate().unwrap_err();
5027        assert!(
5028            matches!(
5029                err,
5030                DepError::NomeInvalid { ref nome, ref reason }
5031                    if nome == "caixa-teia-" && reason.contains("alphanumeric")
5032            ),
5033            "got {err:?}"
5034        );
5035    }
5036
5037    #[test]
5038    fn validate_rejects_nome_with_slash() {
5039        // The canonical "I copied the GitHub repo path into `:nome`
5040        // instead of `:fonte :repo`" typo. A `/` in the name leaks the
5041        // lacre-side `:repositorio` shape (`pleme-io/caixa-teia`) into
5042        // the local-name slot. Same fixture pinned for `:membros
5043        // :caixa` (3f9d7a0).
5044        let d = Dep::simple("pleme-io/caixa-teia", "^0.1");
5045        let err = d.validate().unwrap_err();
5046        assert!(
5047            matches!(
5048                err,
5049                DepError::NomeInvalid { ref nome, ref reason }
5050                    if nome == "pleme-io/caixa-teia" && reason.contains('/')
5051            ),
5052            "got {err:?}"
5053        );
5054    }
5055
5056    #[test]
5057    fn validate_rejects_nome_too_long() {
5058        // 64-byte label — one over the RFC 1035 / RFC 1123 label cap.
5059        // Built from a valid character set so the length-bound
5060        // diagnostic surfaces before any per-character check (the
5061        // order pin parallel to the per-character predicates inside
5062        // [`crate::render::is_dns_1123_label`]).
5063        let long = "a".repeat(64);
5064        let d = Dep::simple(&long, "^0.1");
5065        let err = d.validate().unwrap_err();
5066        assert!(
5067            matches!(
5068                err,
5069                DepError::NomeInvalid { ref nome, ref reason }
5070                    if nome.len() == 64 && reason.contains("max length of 63")
5071            ),
5072            "got {err:?}"
5073        );
5074    }
5075
5076    #[test]
5077    fn validate_accepts_canonical_nome_labels() {
5078        // Positive-control sweep — every form the K8s apiserver
5079        // accepts as a DNS-1123 label must round-trip through
5080        // validate. Covers a hyphen-bearing label, a numeric-suffix
5081        // label, a leading-digit label, a single-character label, and
5082        // a 63-byte (exactly the cap) label — the same fixture set
5083        // the peer `:membros :caixa` / `:children :caixa` positive
5084        // controls pin.
5085        for nome in [
5086            "caixa-teia",
5087            "caixa-resolver2",
5088            "2nd-tier-cache",
5089            "x",
5090            "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0",
5091        ] {
5092            Dep::simple(nome, "^0.1")
5093                .validate()
5094                .unwrap_or_else(|e| panic!("canonical label {nome:?} must validate, got {e:?}"));
5095        }
5096    }
5097
5098    #[test]
5099    fn nome_empty_takes_precedence_over_nome_invalid() {
5100        // Ordering pin: `NomeEmpty` is the more self-locating
5101        // diagnostic on `""` and must lead — `is_dns_1123_label` is
5102        // only reached after the empty-check fires at the call site.
5103        // Mirrors `membro_caixa_empty_takes_precedence_over_invalid`
5104        // (3f9d7a0) on the peer caixa-identifier axis.
5105        let mut d = Dep::simple("placeholder", "^0.1");
5106        d.nome = String::new();
5107        assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
5108    }
5109
5110    #[test]
5111    fn nome_invalid_fires_before_versao_empty() {
5112        // Ordering pin: a malformed `:nome` fires before any `:versao`
5113        // axis check on the *same* entry — the per-entry shape gates
5114        // run top-to-bottom (nome empty → nome shape → versao empty →
5115        // versao parse → fonte shape), so a one-entry caixa.lisp with
5116        // both wrong sees the name-side diagnostic first (the name is
5117        // the self-locating axis — without a valid name, the parse
5118        // diagnostic can't quote `:nome "<bad>"`). Same ordering
5119        // discipline as `membro_caixa_invalid_fires_before_versao_check`
5120        // (3f9d7a0).
5121        let mut d = Dep::simple("Caixa-Teia", "^0.1");
5122        d.versao = String::new();
5123        let err = d.validate().unwrap_err();
5124        assert!(
5125            matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
5126            "got {err:?}"
5127        );
5128    }
5129
5130    #[test]
5131    fn nome_invalid_fires_before_versao_invalid() {
5132        // Ordering pin: a malformed `:nome` fires before the `:versao`
5133        // parse-side check on the *same* entry. Pin separately from
5134        // the empty-versao ordering so a future re-ordering surfaces
5135        // here, parallel to the b0c8389 / c4213a4 trajectory.
5136        let d = Dep::simple("Caixa-Teia", "^^0.1");
5137        let err = d.validate().unwrap_err();
5138        assert!(
5139            matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
5140            "got {err:?}"
5141        );
5142    }
5143
5144    #[test]
5145    fn nome_invalid_fires_before_fonte_invalid() {
5146        // Ordering pin: a malformed `:nome` fires before the `:fonte`
5147        // shape check on the *same* entry. The `:fonte` diagnostic
5148        // names the offending dep's `:nome` verbatim (via
5149        // `DepSource::validate(&self.nome)`), so a non-self-locating
5150        // name would taint the downstream diagnostic too — the gate
5151        // ordering keeps both diagnostics individually self-locating.
5152        let mut d = Dep::simple("Caixa-Teia", "^0.1");
5153        d.fonte = Some(DepSource::Git {
5154            repo: String::new(),
5155            tag: None,
5156            rev: None,
5157            branch: None,
5158        });
5159        let err = d.validate().unwrap_err();
5160        assert!(
5161            matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
5162            "got {err:?}"
5163        );
5164    }
5165
5166    #[test]
5167    fn nome_invalid_diagnostic_carries_offending_name() {
5168        // The diagnostic-shape pin: the error names the offending
5169        // `:nome` value verbatim so the author can grep their
5170        // caixa.lisp without re-running the build, and carries a
5171        // non-empty `reason` from `is_dns_1123_label` so the
5172        // predicate's own wording flows through to the diagnostic.
5173        // Same shape as `MembroCaixaInvalid` (3f9d7a0),
5174        // `ChildCaixaInvalid` (31bfa43), `ManifestError::NomeInvalid`
5175        // (6c992f8) — the four DNS-1123 caixa-identifier axes now
5176        // share a structurally-equivalent diagnostic family.
5177        let d = Dep::simple("Caixa_Teia", "^0.1");
5178        let err = d.validate().unwrap_err();
5179        let DepError::NomeInvalid { nome, reason } = err else {
5180            panic!("expected NomeInvalid, got other variant");
5181        };
5182        assert_eq!(nome, "Caixa_Teia");
5183        assert!(
5184            !reason.is_empty(),
5185            "NomeInvalid `reason` must carry the predicate's wording verbatim"
5186        );
5187    }
5188
5189    #[test]
5190    fn validate_rejects_invalid_versao_requirement() {
5191        // The fail-before-pass-after pin: a non-empty but malformed
5192        // requirement (`"^bad-version"`) silently passed every pre-gate
5193        // codebase because `:deps :versao` wasn't validated. The parse
5194        // failure surfaced far downstream at lacre-resolve time with a
5195        // `semver::Error` that didn't name which `:deps` entry carried
5196        // the typo. The new gate moves the check to caixa-build time
5197        // at the source caixa.lisp.
5198        let d = Dep::simple("caixa-teia", "^bad-version");
5199        let err = d.validate().unwrap_err();
5200        assert!(
5201            matches!(
5202                err,
5203                DepError::VersaoInvalid { ref nome, ref versao, .. }
5204                    if nome == "caixa-teia" && versao == "^bad-version"
5205            ),
5206            "got {err:?}"
5207        );
5208    }
5209
5210    #[test]
5211    fn validate_rejects_versao_with_double_caret_typo() {
5212        // `"^^0.1"` is the canonical doubled-caret typo — looks like a
5213        // Cargo-shaped requirement on first glance but fails the parser
5214        // because semver doesn't accept stacked operators. Pin this
5215        // adjacent-shape footgun explicitly so a future relaxation that
5216        // accepts "looks-canonical-but-isn't" forms surfaces here, in
5217        // parity with the `:membros` / `:children` fixtures.
5218        let d = Dep::simple("caixa-teia", "^^0.1");
5219        let err = d.validate().unwrap_err();
5220        assert!(
5221            matches!(
5222                err,
5223                DepError::VersaoInvalid { ref nome, ref versao, .. }
5224                    if nome == "caixa-teia" && versao == "^^0.1"
5225            ),
5226            "got {err:?}"
5227        );
5228    }
5229
5230    #[test]
5231    fn validate_rejects_versao_with_v_prefixed_tag() {
5232        // `"v0.1"` is the canonical "git-tag-shape leaking into the
5233        // semver requirement slot" typo — an author copies the
5234        // publish-side git-tag string verbatim into `:versao`, but
5235        // Cargo's semver parser rejects the leading `v`. Same fixture
5236        // pinned for `:membros :versao` (9888b13) and `:children
5237        // :versao` (b38ff3a). (Bare `x`-glob shorthands like `^0.1.x`
5238        // are *accepted* by the semver crate as an `*` wildcard on the
5239        // patch axis — they're a Cargo-side valid shape, not a typo.)
5240        let d = Dep::simple("caixa-teia", "v0.1");
5241        let err = d.validate().unwrap_err();
5242        assert!(
5243            matches!(
5244                err,
5245                DepError::VersaoInvalid { ref nome, ref versao, .. }
5246                    if nome == "caixa-teia" && versao == "v0.1"
5247            ),
5248            "got {err:?}"
5249        );
5250    }
5251
5252    #[test]
5253    fn validate_accepts_canonical_versao_forms() {
5254        // The five Cargo-shaped requirement forms `:membros :versao`
5255        // and `:children :versao` already accept via
5256        // `crate::parse_requirement` must pass the deps gate without
5257        // re-validating at the resolver layer. Pin every leg so a
5258        // future tightening of the canonical set surfaces here as a
5259        // test failure.
5260        for form in [
5261            "^0.1",      // caret — minor-range pin (the most common shape)
5262            "~0.1.2",    // tilde — patch-range pin
5263            "0.1.0",     // exact — single-version pin
5264            "*",         // wildcard — explicitly any-version
5265            ">=0.1, <2", // multi-range — comma-separated comparators
5266        ] {
5267            Dep::simple("caixa-teia", form)
5268                .validate()
5269                .unwrap_or_else(|e| panic!("canonical form {form:?} must validate, got {e:?}"));
5270        }
5271    }
5272
5273    #[test]
5274    fn versao_empty_takes_precedence_over_invalid() {
5275        // Order pin: the existing `VersaoEmpty` diagnostic (which
5276        // doesn't try to parse) fires before the new `VersaoInvalid`
5277        // parse-side diagnostic, so an empty `:versao` keeps its
5278        // narrower error message — `parse_requirement("")` would
5279        // otherwise return `Ok(STAR)` and silently pass, but the empty
5280        // arm catches it first.
5281        let mut d = Dep::simple("caixa-teia", "ignored");
5282        d.versao = String::new();
5283        let err = d.validate().unwrap_err();
5284        assert!(
5285            matches!(err, DepError::VersaoEmpty { ref nome } if nome == "caixa-teia"),
5286            "got {err:?}"
5287        );
5288    }
5289
5290    #[test]
5291    fn nome_empty_takes_precedence_over_versao_invalid() {
5292        // Order pin: even when `:versao` is malformed and would raise
5293        // its own diagnostic, `:nome ""` fires first because the
5294        // per-entry parse diagnostic needs a non-empty name to be
5295        // self-locating. Mirrors the
5296        // `membros_validation_runs_before_contratos_membership_check`
5297        // ordering on the typed-graph layer.
5298        let mut d = Dep::simple("placeholder", "^bad");
5299        d.nome = String::new();
5300        let err = d.validate().unwrap_err();
5301        assert_eq!(err, DepError::NomeEmpty);
5302    }
5303
5304    #[test]
5305    fn versao_invalid_diagnostic_carries_offending_versao() {
5306        // The diagnostic-shape pin: the error names the offending
5307        // `:versao` value verbatim so the author can grep their
5308        // caixa.lisp without re-running the build, and carries a
5309        // non-empty `reason` from `semver::VersionReq::parse` so the
5310        // parser's own wording flows through to the diagnostic.
5311        let d = Dep::simple("caixa-teia", "not-a-req");
5312        let err = d.validate().unwrap_err();
5313        let DepError::VersaoInvalid {
5314            nome,
5315            versao,
5316            reason,
5317        } = err
5318        else {
5319            panic!("expected VersaoInvalid, got other variant");
5320        };
5321        assert_eq!(nome, "caixa-teia");
5322        assert_eq!(versao, "not-a-req");
5323        assert!(
5324            !reason.is_empty(),
5325            "VersaoInvalid `reason` must carry the parser's wording verbatim"
5326        );
5327    }
5328
5329    // -- :fonte value-shape gate ------------------------------------------
5330
5331    fn dep_with_fonte(fonte: DepSource) -> Dep {
5332        let mut d = Dep::simple("caixa-teia", "^0.1");
5333        d.fonte = Some(fonte);
5334        d
5335    }
5336
5337    #[test]
5338    fn validate_accepts_git_fonte_with_tag() {
5339        // The positive-control pin on the canonical git source — exactly
5340        // one of :tag/:rev/:branch set, non-empty :repo. Mirrors the
5341        // shape every existing caixa-resolver integration test uses.
5342        let d = dep_with_fonte(DepSource::Git {
5343            repo: "github:pleme-io/caixa-teia".into(),
5344            tag: Some("v0.1.0".into()),
5345            rev: None,
5346            branch: None,
5347        });
5348        d.validate().unwrap();
5349    }
5350
5351    #[test]
5352    fn validate_accepts_git_fonte_with_rev() {
5353        // Each of the three pin axes is independently a valid single-pin
5354        // shape; pin the :rev arm so a future relaxation that only
5355        // accepts :tag surfaces here. The value is a full 40-hex SHA-1
5356        // OID — the canonical `git rev-parse HEAD` emission shape the
5357        // `crate::render::is_git_oid` value-shape gate now requires;
5358        // abbreviated OIDs are ambiguous across repo history and
5359        // rejected at this gate (pinned separately by
5360        // `validate_rejects_git_fonte_with_rev_abbreviated_prefix`).
5361        let d = dep_with_fonte(DepSource::Git {
5362            repo: "github:pleme-io/caixa-teia".into(),
5363            tag: None,
5364            rev: Some("c0ffee0123abcdef0123456789abcdef01234567".into()),
5365            branch: None,
5366        });
5367        d.validate().unwrap();
5368    }
5369
5370    #[test]
5371    fn validate_accepts_git_fonte_with_branch() {
5372        // The :branch arm is the third valid single-pin shape — pinned
5373        // separately so the gate-accepts-all-three-pin-axes contract is
5374        // a build-error to relax.
5375        let d = dep_with_fonte(DepSource::Git {
5376            repo: "github:pleme-io/caixa-teia".into(),
5377            tag: None,
5378            rev: None,
5379            branch: Some("main".into()),
5380        });
5381        d.validate().unwrap();
5382    }
5383
5384    #[test]
5385    fn validate_accepts_path_fonte() {
5386        // The positive-control pin on the path source — non-empty
5387        // :caminho, no pin axes (paths have no commit identity). Pinned
5388        // so a future "paths must also pin a rev" tightening surfaces
5389        // here as a structural decision, not a silent break.
5390        let d = dep_with_fonte(DepSource::Path {
5391            caminho: "../caixa-teia".into(),
5392        });
5393        d.validate().unwrap();
5394    }
5395
5396    #[test]
5397    fn validate_rejects_git_fonte_with_empty_repo() {
5398        // The fail-before-pass-after pin for `(:tipo git :repo "" :tag
5399        // "v1")`: the empty-repo shape silently passed every pre-gate
5400        // codebase because `:fonte` wasn't validated. The git-clone
5401        // failure surfaced far downstream at lacre-resolve time with no
5402        // field naming which `:deps` entry carried the typo. The new
5403        // gate moves the check to caixa-build time at the source
5404        // caixa.lisp.
5405        let d = dep_with_fonte(DepSource::Git {
5406            repo: String::new(),
5407            tag: Some("v0.1.0".into()),
5408            rev: None,
5409            branch: None,
5410        });
5411        let err = d.validate().unwrap_err();
5412        assert!(
5413            matches!(err, DepError::FonteRepoEmpty { ref nome } if nome == "caixa-teia"),
5414            "got {err:?}"
5415        );
5416    }
5417
5418    // -- :repo value-shape gate -------------------------------------------
5419    //
5420    // The `:fonte (:tipo git :repo …)` value flows verbatim into the
5421    // caixa-resolver's `git clone <repo>` subprocess. The pre-gate
5422    // codebase admitted any non-empty string; the new
5423    // [`crate::render::is_git_repo_url`] predicate gates the git-porcelain
5424    // URL intersection-floor at validate time, peer with the three pin
5425    // axes (`:tag` + `:branch` via `is_git_ref_name`, `:rev` via
5426    // `is_git_oid`). Every test in this section is a fail-before /
5427    // pass-after pin on a specific authoring footgun.
5428
5429    #[test]
5430    fn validate_rejects_git_fonte_with_repo_carrying_trailing_space() {
5431        // The canonical paste-from-doc footgun on `:repo` — an author
5432        // copies `"github:pleme-io/caixa-teia "` (trailing space) out of
5433        // a doc paragraph. Until this gate landed the empty-repo arm
5434        // passed (the string isn't empty), the resolver issued
5435        // `git clone 'github:pleme-io/caixa-teia '`, and the failure
5436        // surfaced at clone time with a quoting-confused error far from
5437        // the source caixa.lisp. Same paste-from-doc footgun the
5438        // `:tag "v0.1.0 "` gate (e70d213) closes on the peer refname
5439        // axis — now closed on the `:repo` URL axis too.
5440        let d = dep_with_fonte(DepSource::Git {
5441            repo: "github:pleme-io/caixa-teia ".into(),
5442            tag: Some("v0.1.0".into()),
5443            rev: None,
5444            branch: None,
5445        });
5446        let err = d.validate().unwrap_err();
5447        let DepError::FonteRepoShape { nome, repo, reason } = err else {
5448            panic!("expected FonteRepoShape, got other variant");
5449        };
5450        assert_eq!(nome, "caixa-teia");
5451        assert_eq!(repo, "github:pleme-io/caixa-teia ");
5452        assert!(
5453            reason.contains("whitespace"),
5454            "reason must surface the whitespace arm, got {reason:?}"
5455        );
5456    }
5457
5458    #[test]
5459    fn validate_rejects_git_fonte_with_repo_starting_with_dash() {
5460        // The canonical CLI-argument-injection footgun at the `git clone`
5461        // subprocess boundary — `:repo "-upload-pack=evil"` makes git's
5462        // argv parser read the value as a CLI flag, escaping the
5463        // subprocess argument boundary. The `--` separator workaround
5464        // does not fix the typed slot's accepted set; the gate rejects
5465        // the shape upstream at validate time so the resolver never
5466        // invokes a `git clone -…` subprocess.
5467        let d = dep_with_fonte(DepSource::Git {
5468            repo: "-upload-pack=evil".into(),
5469            tag: Some("v0.1.0".into()),
5470            rev: None,
5471            branch: None,
5472        });
5473        let err = d.validate().unwrap_err();
5474        let DepError::FonteRepoShape { repo, reason, .. } = err else {
5475            panic!("expected FonteRepoShape, got other variant");
5476        };
5477        assert_eq!(repo, "-upload-pack=evil");
5478        assert!(
5479            reason.contains("must not start with `-`"),
5480            "reason must surface the leading-`-` arm, got {reason:?}"
5481        );
5482    }
5483
5484    #[test]
5485    fn validate_rejects_git_fonte_with_repo_carrying_embedded_newline() {
5486        // The canonical paste-from-multiline-doc footgun — a `:repo`
5487        // string with an embedded `\n` silently breaks git's URL parser
5488        // and is a class of CRLF-injection at the subprocess-argument
5489        // boundary. Caught by the control-char arm (0x0A < 0x20).
5490        let d = dep_with_fonte(DepSource::Git {
5491            repo: "github:pleme-io/caixa-teia\nrm -rf /".into(),
5492            tag: Some("v0.1.0".into()),
5493            rev: None,
5494            branch: None,
5495        });
5496        let err = d.validate().unwrap_err();
5497        let DepError::FonteRepoShape { reason, .. } = err else {
5498            panic!("expected FonteRepoShape, got other variant");
5499        };
5500        assert!(
5501            reason.contains("control character"),
5502            "reason must surface the control-char arm, got {reason:?}"
5503        );
5504    }
5505
5506    #[test]
5507    fn validate_rejects_git_fonte_with_repo_carrying_tab() {
5508        // Tab is the sibling whitespace footgun (the canonical
5509        // copy-from-aligned-table paste); pinned separately from the
5510        // space arm so a future relaxation that only catches one
5511        // surfaces here.
5512        let d = dep_with_fonte(DepSource::Git {
5513            repo: "github:pleme-io/caixa-teia\t".into(),
5514            tag: Some("v0.1.0".into()),
5515            rev: None,
5516            branch: None,
5517        });
5518        let err = d.validate().unwrap_err();
5519        assert!(
5520            matches!(
5521                err,
5522                DepError::FonteRepoShape { ref reason, .. }
5523                    if reason.contains("whitespace")
5524            ),
5525            "got {err:?}"
5526        );
5527    }
5528
5529    #[test]
5530    fn validate_rejects_git_fonte_with_repo_carrying_non_ascii() {
5531        // IDN hosts must be pre-encoded as Punycode (`xn--…`) — raw
5532        // non-ASCII silently breaks at git's URL parser and round-trips
5533        // inconsistently across NFC/NFD normalization on APFS /
5534        // case-folding filesystems. Same intersection-floor
5535        // [`is_git_ref_name`] enforces on the refname axes.
5536        let d = dep_with_fonte(DepSource::Git {
5537            repo: "https://github.com/pleme-io/café".into(),
5538            tag: Some("v0.1.0".into()),
5539            rev: None,
5540            branch: None,
5541        });
5542        let err = d.validate().unwrap_err();
5543        assert!(
5544            matches!(
5545                err,
5546                DepError::FonteRepoShape { ref reason, .. }
5547                    if reason.contains("non-ASCII")
5548            ),
5549            "got {err:?}"
5550        );
5551    }
5552
5553    #[test]
5554    fn validate_rejects_git_fonte_with_repo_carrying_fragment_anchor() {
5555        // The fail-before-pass-after pin for the canonical paste-from-
5556        // browser-address-bar footgun on `:repo`: an author copies a
5557        // GitHub permalink to a README anchor / line-permalink and
5558        // forgets to trim the `#fragment` tail. Until this arm landed
5559        // `:repo "https://github.com/pleme-io/caixa-teia#readme"`
5560        // silently passed every prior arm (no whitespace, no control
5561        // chars, no non-ASCII, contains a `:`, doesn't start with `-`
5562        // or `:`), libcurl's URL parser stripped the `#readme` tail
5563        // before opening the HTTPS transport, and the lacre embedded
5564        // the value verbatim in its per-dep BLAKE3 closure — two
5565        // authors whose values differ only in their fragment anchor
5566        // (`#readme` vs `#L42`) resolve to the byte-identical upstream
5567        // `git clone` but lock to two distinct lacres, defeating the
5568        // THEORY.md §V.2 render-determinism contract. Same value-shape
5569        // axis-floor every peer typed surface enforces; peer `:fonte
5570        // :tag` / `:fonte :branch` already reject the byte-class through
5571        // `is_git_ref_name`'s alphabet (refs are leaf identifiers, no
5572        // URL grammar admitted) and `:entrada :paths` rejects `#` as
5573        // part of `is_gateway_api_http_path`'s RFC-3986-reserved set.
5574        let d = dep_with_fonte(DepSource::Git {
5575            repo: "https://github.com/pleme-io/caixa-teia#readme".into(),
5576            tag: Some("v0.1.0".into()),
5577            rev: None,
5578            branch: None,
5579        });
5580        let err = d.validate().unwrap_err();
5581        let DepError::FonteRepoShape { nome, repo, reason } = err else {
5582            panic!("expected FonteRepoShape, got other variant");
5583        };
5584        assert_eq!(nome, "caixa-teia");
5585        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia#readme");
5586        assert!(
5587            reason.contains("must not contain `#`"),
5588            "reason must surface the fragment-`#` arm, got {reason:?}"
5589        );
5590        assert!(
5591            reason.contains("fragment"),
5592            "reason must name the URL fragment grammar, got {reason:?}"
5593        );
5594    }
5595
5596    #[test]
5597    fn validate_rejects_git_fonte_with_repo_carrying_flake_ref_fragment() {
5598        // The symmetric paste-from-Nix-flake-ref footgun — an author
5599        // confuses the Nix flake-reference idiom (`github:foo/
5600        // bar#packageName`, where `#packageName` selects a flake
5601        // output) with the bare git `:repo` shape. The pleme-io
5602        // substrate authors compose flakes downstream of caixa
5603        // (caixa-flake renders a flake.nix), so the cross-idiom leak
5604        // is the canonical near-miss: the author writes the
5605        // flake-ref shape into a git `:repo` slot. Pinned separately
5606        // from the HTTPS-anchor arm so a future relaxation that
5607        // narrows to one URL scheme surfaces here.
5608        let d = dep_with_fonte(DepSource::Git {
5609            repo: "github:pleme-io/caixa-teia#caixa-teia".into(),
5610            tag: Some("v0.1.0".into()),
5611            rev: None,
5612            branch: None,
5613        });
5614        let err = d.validate().unwrap_err();
5615        let DepError::FonteRepoShape { reason, .. } = err else {
5616            panic!("expected FonteRepoShape, got other variant");
5617        };
5618        assert!(
5619            reason.contains("must not contain `#`"),
5620            "reason must surface the fragment-`#` arm, got {reason:?}"
5621        );
5622        assert!(
5623            reason.contains("Nix flake"),
5624            "reason must name the Nix-flake-ref cross-idiom footgun, got {reason:?}"
5625        );
5626    }
5627
5628    #[test]
5629    fn validate_rejects_git_fonte_with_repo_carrying_query_string() {
5630        // The fail-before-pass-after pin for the canonical paste-from-
5631        // browser-address-bar footgun on `:repo` (peer with the
5632        // a68f818 fragment-`#` arm on the same axis). An author
5633        // copies a GitHub tab deep-link out of the address bar and
5634        // forgets to trim the `?tab=…` query tail. Until this arm
5635        // landed `:repo "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file"`
5636        // silently passed every prior arm (no whitespace, no control
5637        // chars, no non-ASCII, no `#` fragment, contains a `:`,
5638        // doesn't start with `-` or `:`); GitHub silently ignored
5639        // the `?query` tail and served the same repo regardless;
5640        // the lacre embedded the value verbatim in its per-dep
5641        // BLAKE3 closure — two authors whose values differ only in
5642        // their query tail (`?tab=readme-ov-file` vs `?ref=main` vs
5643        // `?utm_source=twitter`) resolve to the byte-identical
5644        // upstream `git clone` but lock to two distinct lacres,
5645        // defeating the THEORY.md §V.2 render-determinism contract
5646        // on the same axis the `#` fragment arm closes. Same value-
5647        // shape axis-floor every peer typed surface enforces; peer
5648        // `:fonte :tag` / `:fonte :branch` already reject the byte-
5649        // class through `is_git_ref_name`'s alphabet (refspec glob
5650        // wildcards, caixa-core/src/render.rs:1426) and `:entrada
5651        // :paths` rejects `?` as the query separator in
5652        // `is_gateway_api_http_path` (caixa-core/src/render.rs:473).
5653        let d = dep_with_fonte(DepSource::Git {
5654            repo: "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file".into(),
5655            tag: Some("v0.1.0".into()),
5656            rev: None,
5657            branch: None,
5658        });
5659        let err = d.validate().unwrap_err();
5660        let DepError::FonteRepoShape { nome, repo, reason } = err else {
5661            panic!("expected FonteRepoShape, got other variant");
5662        };
5663        assert_eq!(nome, "caixa-teia");
5664        assert_eq!(
5665            repo,
5666            "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file"
5667        );
5668        assert!(
5669            reason.contains("must not contain `?`"),
5670            "reason must surface the query-`?` arm, got {reason:?}"
5671        );
5672        assert!(
5673            reason.contains("query"),
5674            "reason must name the URL query grammar, got {reason:?}"
5675        );
5676    }
5677
5678    #[test]
5679    fn validate_rejects_git_fonte_with_repo_carrying_utm_tracker() {
5680        // The symmetric paste-from-social-share footgun — an author
5681        // copies a repo URL out of a Slack unfurl / Twitter share /
5682        // newsletter link / Discord embed and forgets to trim the
5683        // `?utm_source=…` / `?utm_medium=…` / `?utm_campaign=…`
5684        // campaign-tracker tail. Every major social-share / unfurl /
5685        // newsletter platform appends these UTM parameters; the
5686        // canonical near-miss on the `:repo` axis. Pinned separately
5687        // from the GitHub-tab-deep-link arm so a future relaxation
5688        // that narrows to one query-parameter class surfaces here.
5689        let d = dep_with_fonte(DepSource::Git {
5690            repo: "https://github.com/pleme-io/caixa-teia?utm_source=twitter&utm_campaign=launch"
5691                .into(),
5692            tag: Some("v0.1.0".into()),
5693            rev: None,
5694            branch: None,
5695        });
5696        let err = d.validate().unwrap_err();
5697        let DepError::FonteRepoShape { reason, .. } = err else {
5698            panic!("expected FonteRepoShape, got other variant");
5699        };
5700        assert!(
5701            reason.contains("must not contain `?`"),
5702            "reason must surface the query-`?` arm, got {reason:?}"
5703        );
5704        assert!(
5705            reason.contains("campaign-tracker"),
5706            "reason must name the campaign-tracker paste footgun, got {reason:?}"
5707        );
5708    }
5709
5710    #[test]
5711    fn fonte_repo_fragment_fires_before_query_when_fragment_first() {
5712        // Cascade pin: the fragment-`#` arm and the query-`?` arm are
5713        // both per-byte arms inside the same `for &b in s.as_bytes()`
5714        // loop, so the byte that appears first in the value's byte
5715        // order wins. A `:repo "https://github.com/p/x#readme?ref=main"`
5716        // (fragment before query — unusual URL-grammar but value-
5717        // disjoint at byte level) carries both `#` and `?`; the `#`
5718        // byte appears first, so the fragment-`#` arm fires, surfacing
5719        // the more self-locating diagnostic on the byte the author
5720        // pasted earliest in the URL. Mirrors the peer cascade
5721        // discipline `fonte_repo_control_char_fires_before_fragment`
5722        // pins on the prior `:repo` byte-class arm.
5723        let d = dep_with_fonte(DepSource::Git {
5724            repo: "https://github.com/pleme-io/caixa-teia#readme?ref=main".into(),
5725            tag: Some("v0.1.0".into()),
5726            rev: None,
5727            branch: None,
5728        });
5729        let err = d.validate().unwrap_err();
5730        let DepError::FonteRepoShape { reason, .. } = err else {
5731            panic!("expected FonteRepoShape, got other variant");
5732        };
5733        assert!(
5734            reason.contains("must not contain `#`"),
5735            "reason must surface the fragment-`#` arm (fires before query-`?` when \
5736             `#` byte appears first in value), got {reason:?}"
5737        );
5738    }
5739
5740    #[test]
5741    fn fonte_repo_control_char_fires_before_fragment() {
5742        // Cascade pin: the control-char arm structurally precedes the
5743        // fragment-`#` arm. A value like `"github:p/x\n#readme"` probes
5744        // positive on both arms (contains LF and `#`), but the narrower
5745        // POSIX-syscall-rejected / CRLF-injection-class diagnostic
5746        // (`control character`) wins so the author sees the more
5747        // self-locating arm first. Mirrors the peer cascade discipline
5748        // every prior `:repo` byte-class arm establishes.
5749        let d = dep_with_fonte(DepSource::Git {
5750            repo: "github:pleme-io/caixa-teia\n#readme".into(),
5751            tag: Some("v0.1.0".into()),
5752            rev: None,
5753            branch: None,
5754        });
5755        let err = d.validate().unwrap_err();
5756        let DepError::FonteRepoShape { reason, .. } = err else {
5757            panic!("expected FonteRepoShape, got other variant");
5758        };
5759        assert!(
5760            reason.contains("control character"),
5761            "reason must surface the control-char arm, got {reason:?}"
5762        );
5763    }
5764
5765    #[test]
5766    fn validate_rejects_git_fonte_with_repo_carrying_embedded_backslash() {
5767        // The fail-before-pass-after pin for the canonical Windows-
5768        // file-path-confusion footgun on `:repo` (peer with the 3a4e1d7
5769        // backslash arm on the sibling `:caminho` path-fonte axis).
5770        // An author pastes a Windows Explorer address-bar / PowerShell
5771        // `Get-Location` output into a `file://` URL slot, producing
5772        // `file:///C:\Users\me\caixa-teia`. Until this arm landed the
5773        // value silently passed every prior arm (no whitespace, no
5774        // control chars, no non-ASCII, no `#`, no `?`, doesn't start
5775        // with `-` or `:`); libcurl's URL parser silently translates
5776        // `\` → `/` on some platforms and refuses it on others, so
5777        // the byte rides verbatim into the lacre's per-dep content-
5778        // address but is silently rewritten / rejected at the wire —
5779        // two authors whose `:repo` values differ only in backslash-
5780        // vs-forward-slash (`file:///C:\path` vs `file:///C:/path`)
5781        // resolve to the byte-identical local clone but lock to two
5782        // distinct BLAKE3 closures, defeating the THEORY.md §V.2
5783        // render-determinism contract on the same axis the `#`
5784        // fragment and `?` query arms close. Same value-shape axis-
5785        // floor every peer typed surface enforces; the `:caminho`
5786        // 3a4e1d7 arm closes the same byte on the path-fonte axis.
5787        let d = dep_with_fonte(DepSource::Git {
5788            repo: "file:///C:\\Users\\me\\caixa-teia".into(),
5789            tag: Some("v0.1.0".into()),
5790            rev: None,
5791            branch: None,
5792        });
5793        let err = d.validate().unwrap_err();
5794        let DepError::FonteRepoShape { nome, repo, reason } = err else {
5795            panic!("expected FonteRepoShape, got other variant");
5796        };
5797        assert_eq!(nome, "caixa-teia");
5798        assert_eq!(repo, "file:///C:\\Users\\me\\caixa-teia");
5799        assert!(
5800            reason.contains("must not contain `\\`"),
5801            "reason must surface the backslash-`\\` arm, got {reason:?}"
5802        );
5803        assert!(
5804            reason.contains("Windows"),
5805            "reason must name the Windows-path-confusion footgun, got {reason:?}"
5806        );
5807    }
5808
5809    #[test]
5810    fn validate_rejects_git_fonte_with_repo_carrying_mangled_https_backslashes() {
5811        // The symmetric Win32-shell-mangled-slashes footgun — an author
5812        // copies `https://github.com/foo/bar` into a Win32 shell that
5813        // rewrites every `/` to `\` (the canonical `cmd.exe` path-
5814        // separator-coercion bug), pastes the result into a `:repo`
5815        // slot, and produces `https:\\github.com\foo\bar`. Pinned
5816        // separately from the `file://` Explorer-paste arm so a future
5817        // relaxation that narrows to one URL scheme surfaces here.
5818        let d = dep_with_fonte(DepSource::Git {
5819            repo: "https:\\\\github.com\\pleme-io\\caixa-teia".into(),
5820            tag: Some("v0.1.0".into()),
5821            rev: None,
5822            branch: None,
5823        });
5824        let err = d.validate().unwrap_err();
5825        let DepError::FonteRepoShape { reason, .. } = err else {
5826            panic!("expected FonteRepoShape, got other variant");
5827        };
5828        assert!(
5829            reason.contains("must not contain `\\`"),
5830            "reason must surface the backslash-`\\` arm, got {reason:?}"
5831        );
5832        assert!(
5833            reason.contains("path separator") || reason.contains("path-segment separator"),
5834            "reason must name the URL path-segment separator grammar, got {reason:?}"
5835        );
5836    }
5837
5838    #[test]
5839    fn fonte_repo_fragment_fires_before_backslash_when_fragment_first() {
5840        // Cascade pin: the fragment-`#` arm and the backslash-`\` arm
5841        // are both per-byte arms inside the same `for &b in s.as_bytes()`
5842        // loop, so the byte that appears first in the value's byte order
5843        // wins. A `:repo "https://github.com/p/x#readme\\foo"` carries
5844        // both `#` and `\`; the `#` byte appears first, so the fragment-
5845        // `#` arm fires, surfacing the more self-locating diagnostic on
5846        // the byte the author pasted earliest in the URL. Mirrors the
5847        // peer cascade discipline `fonte_repo_fragment_fires_before_query_when_fragment_first`
5848        // pins on the prior `:repo` byte-class arm.
5849        let d = dep_with_fonte(DepSource::Git {
5850            repo: "https://github.com/pleme-io/caixa-teia#readme\\foo".into(),
5851            tag: Some("v0.1.0".into()),
5852            rev: None,
5853            branch: None,
5854        });
5855        let err = d.validate().unwrap_err();
5856        let DepError::FonteRepoShape { reason, .. } = err else {
5857            panic!("expected FonteRepoShape, got other variant");
5858        };
5859        assert!(
5860            reason.contains("must not contain `#`"),
5861            "reason must surface the fragment-`#` arm (fires before backslash-`\\` when \
5862             `#` byte appears first in value), got {reason:?}"
5863        );
5864    }
5865
5866    #[test]
5867    fn validate_rejects_git_fonte_with_repo_carrying_uri_template_placeholder() {
5868        // The fail-before-pass-after pin for the canonical URI Template
5869        // (RFC 6570) placeholder footgun on `:repo`. An author copies a
5870        // README quick-start snippet / OpenAPI `servers:` URL / Helm
5871        // chart `home:` template that carries unresolved
5872        // `{org}` / `{repo}` placeholders and pastes the raw template
5873        // into the `:repo` slot, expecting the substrate to resolve the
5874        // placeholder downstream. Until this arm landed the value
5875        // silently passed every prior arm (no whitespace, no control
5876        // chars, no non-ASCII, no `#`, no `?`, no `\`, doesn't start
5877        // with `-` or `:`); libcurl percent-encodes `{` / `}` to `%7B`
5878        // / `%7D` on the wire, so the byte rides verbatim into the
5879        // lacre's per-dep content-address but round-trips inconsistently
5880        // between the lacre's per-dep content-address and the
5881        // resolver's `git clone <repo>` invocation, defeating the
5882        // THEORY.md §V.2 render-determinism contract on the same axis
5883        // the `#` fragment, `?` query, and `\` backslash arms close;
5884        // every git porcelain entry-point additionally fetches a
5885        // nonexistent literal-`{placeholder}`-named path far from the
5886        // source caixa.lisp.
5887        let d = dep_with_fonte(DepSource::Git {
5888            repo: "https://github.com/{org}/caixa-teia".into(),
5889            tag: Some("v0.1.0".into()),
5890            rev: None,
5891            branch: None,
5892        });
5893        let err = d.validate().unwrap_err();
5894        let DepError::FonteRepoShape { nome, repo, reason } = err else {
5895            panic!("expected FonteRepoShape, got other variant");
5896        };
5897        assert_eq!(nome, "caixa-teia");
5898        assert_eq!(repo, "https://github.com/{org}/caixa-teia");
5899        assert!(
5900            reason.contains("must not contain `{`"),
5901            "reason must surface the open-brace `{{` arm, got {reason:?}"
5902        );
5903        assert!(
5904            reason.contains("URI Template") || reason.contains("RFC 6570"),
5905            "reason must name the RFC 6570 URI Template grammar, got {reason:?}"
5906        );
5907    }
5908
5909    #[test]
5910    fn validate_rejects_git_fonte_with_repo_carrying_handlebars_doubled_brace() {
5911        // The symmetric Mustache / Handlebars doubled-brace
5912        // substitution-form footgun every CI / IaC templating engine
5913        // (Argo Workflows, Jinja2, Liquid, Vue / Angular interpolation,
5914        // GitHub Actions `${{ … }}` even though Actions uses `${{`) /
5915        // chart README quick-start snippet emits. Pinned separately
5916        // from the single-`{` `{org}` arm so a future relaxation that
5917        // narrows to one substitution-form surfaces here.
5918        let d = dep_with_fonte(DepSource::Git {
5919            repo: "https://github.com/{{org}}/caixa-teia".into(),
5920            tag: Some("v0.1.0".into()),
5921            rev: None,
5922            branch: None,
5923        });
5924        let err = d.validate().unwrap_err();
5925        let DepError::FonteRepoShape { reason, .. } = err else {
5926            panic!("expected FonteRepoShape, got other variant");
5927        };
5928        assert!(
5929            reason.contains("must not contain `{`"),
5930            "reason must surface the open-brace `{{` arm, got {reason:?}"
5931        );
5932    }
5933
5934    #[test]
5935    fn validate_rejects_git_fonte_with_repo_carrying_closing_brace_only() {
5936        // Asymmetric `}`-only shape — covers the closing-brace-by-
5937        // itself footgun (an author truncated `{org}/{repo}` mid-edit
5938        // and left a trailing `}` from the prior template fragment,
5939        // or pasted a value that included a closing brace from a
5940        // surrounding shell context). Pinned to ensure the predicate
5941        // refuses each brace independently rather than only when both
5942        // appear — a future regression that ANDs the two byte tests
5943        // surfaces here.
5944        let d = dep_with_fonte(DepSource::Git {
5945            repo: "https://github.com/pleme-io/caixa-teia}".into(),
5946            tag: Some("v0.1.0".into()),
5947            rev: None,
5948            branch: None,
5949        });
5950        let err = d.validate().unwrap_err();
5951        let DepError::FonteRepoShape { reason, .. } = err else {
5952            panic!("expected FonteRepoShape, got other variant");
5953        };
5954        assert!(
5955            reason.contains("must not contain `}`"),
5956            "reason must surface the close-brace `}}` arm, got {reason:?}"
5957        );
5958    }
5959
5960    #[test]
5961    fn fonte_repo_fragment_fires_before_template_placeholder_when_fragment_first() {
5962        // Cascade pin: the fragment-`#` arm and the template-`{` /
5963        // `}` arm are both per-byte arms inside the same
5964        // `for &b in s.as_bytes()` loop, so the byte that appears
5965        // first in the value's byte order wins. A `:repo
5966        // "https://github.com/p/x#readme{org}"` carries both `#` and
5967        // `{`; the `#` byte appears first, so the fragment-`#` arm
5968        // fires, surfacing the more self-locating diagnostic on the
5969        // byte the author pasted earliest in the URL. Mirrors the
5970        // peer cascade discipline `fonte_repo_fragment_fires_before_backslash_when_fragment_first`
5971        // pins on the prior `:repo` byte-class arm.
5972        let d = dep_with_fonte(DepSource::Git {
5973            repo: "https://github.com/pleme-io/caixa-teia#readme{org}".into(),
5974            tag: Some("v0.1.0".into()),
5975            rev: None,
5976            branch: None,
5977        });
5978        let err = d.validate().unwrap_err();
5979        let DepError::FonteRepoShape { reason, .. } = err else {
5980            panic!("expected FonteRepoShape, got other variant");
5981        };
5982        assert!(
5983            reason.contains("must not contain `#`"),
5984            "reason must surface the fragment-`#` arm (fires before template-`{{` when \
5985             `#` byte appears first in value), got {reason:?}"
5986        );
5987    }
5988
5989    #[test]
5990    fn validate_rejects_git_fonte_with_repo_carrying_output_redirection() {
5991        // The fail-before-pass-after pin for the canonical
5992        // shell-output-redirection footgun on `:repo`: an author
5993        // pastes a shell-pipeline tail (`git clone <repo> > build.log`
5994        // / `… >output.txt`) into the `:repo` slot without trimming
5995        // the redirect. Until this arm landed the value silently
5996        // passed every prior arm (no whitespace, no control chars,
5997        // no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, doesn't
5998        // start with `-` or `:`); RFC 3986 §2 lists `<` / `>` in the
5999        // 'delims' / 'unwise' set and the WHATWG URL spec's fragment
6000        // percent-encode set maps `>` → `%3E` on the wire, so the
6001        // byte rides verbatim into the lacre's per-dep BLAKE3 closure
6002        // but is silently rewritten or rejected at libcurl's URL-
6003        // parser layer — two authors whose values differ only in
6004        // their redirect tail (`>build.log` vs nothing) resolve to
6005        // the byte-identical upstream `git clone` but lock to two
6006        // distinct lacres, defeating the THEORY.md §V.2 render-
6007        // determinism contract. Peer with the `:caminho` axis's
6008        // `FonteCaminhoShellRedirection` arm (e457141) on the sibling
6009        // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
6010        // byte RFC-3986-reserved set on `:entrada :paths`.
6011        let d = dep_with_fonte(DepSource::Git {
6012            repo: "https://github.com/pleme-io/caixa-teia>build.log".into(),
6013            tag: Some("v0.1.0".into()),
6014            rev: None,
6015            branch: None,
6016        });
6017        let err = d.validate().unwrap_err();
6018        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6019            panic!("expected FonteRepoShape, got other variant");
6020        };
6021        assert_eq!(nome, "caixa-teia");
6022        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia>build.log");
6023        assert!(
6024            reason.contains("must not contain `>`"),
6025            "reason must surface the output-redirection `>` arm, got {reason:?}"
6026        );
6027        assert!(
6028            reason.contains("redirection") || reason.contains("'delims'"),
6029            "reason must name the shell-redirection / RFC-3986-unwise rationale, got {reason:?}"
6030        );
6031    }
6032
6033    #[test]
6034    fn validate_rejects_git_fonte_with_repo_carrying_input_redirection() {
6035        // The symmetric shell-input-redirection footgun — an author
6036        // pastes a shell-pipeline head (`git clone <input.url` /
6037        // `cat <README.md`) into the `:repo` slot. Pinned separately
6038        // from the `>`-output arm so a future relaxation that only
6039        // catches one of the two redirect bytes surfaces here. Peer
6040        // with the `:caminho` axis's `FonteCaminhoShellRedirection`
6041        // arm which closes both `<` and `>` under the same banner.
6042        let d = dep_with_fonte(DepSource::Git {
6043            repo: "https://github.com/pleme-io/caixa-teia<input.url".into(),
6044            tag: Some("v0.1.0".into()),
6045            rev: None,
6046            branch: None,
6047        });
6048        let err = d.validate().unwrap_err();
6049        let DepError::FonteRepoShape { reason, .. } = err else {
6050            panic!("expected FonteRepoShape, got other variant");
6051        };
6052        assert!(
6053            reason.contains("must not contain `<`"),
6054            "reason must surface the input-redirection `<` arm, got {reason:?}"
6055        );
6056        assert!(
6057            reason.contains("RFC 3986") || reason.contains("'unwise'"),
6058            "reason must name the RFC 3986 'unwise' grammar, got {reason:?}"
6059        );
6060    }
6061
6062    #[test]
6063    fn validate_rejects_git_fonte_with_repo_carrying_backtick_command_substitution() {
6064        // The fail-before-pass-after pin for the canonical
6065        // paste-from-shell-prompt-with-backticked-substitution footgun
6066        // on `:repo` (peer with the c4d62b3 backtick arm on the sibling
6067        // `:caminho` path-fonte axis). An author pastes a URL whose
6068        // segment carries a backticked command-substitution wrapper
6069        // (`` `whoami` ``, `` `git config user.name` ``, `` `pwd` ``)
6070        // from a doc / README quick-start snippet that expected the
6071        // substrate to substitute the value downstream. Until this arm
6072        // landed the value silently passed every prior arm (no
6073        // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
6074        // no `\`, no `{`/`}`, no `<`/`>`, doesn't start with `-` or
6075        // `:`); RFC 3986 §2 lists the backtick byte in the 'delims' /
6076        // 'unwise' set and the WHATWG URL spec's fragment percent-
6077        // encode set maps `` ` `` → `%60` on the wire, so the byte
6078        // rides verbatim into the lacre's per-dep BLAKE3 closure but
6079        // is silently rewritten or rejected at libcurl's URL-parser
6080        // layer — two authors whose values differ only in their
6081        // backtick wrapper (`` `whoami` `` vs nothing) resolve to the
6082        // byte-identical upstream `git clone` but lock to two distinct
6083        // lacres, defeating the THEORY.md §V.2 render-determinism
6084        // contract. Peer with the `:caminho` axis's
6085        // `FonteCaminhoShellCommandSubstitution` arm (c4d62b3) on the
6086        // sibling path-fonte axis, and `is_gateway_api_http_path`'s
6087        // eleven-byte RFC-3986-reserved set on `:entrada :paths`.
6088        let d = dep_with_fonte(DepSource::Git {
6089            repo: "https://github.com/pleme-io/`whoami`/caixa-teia".into(),
6090            tag: Some("v0.1.0".into()),
6091            rev: None,
6092            branch: None,
6093        });
6094        let err = d.validate().unwrap_err();
6095        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6096            panic!("expected FonteRepoShape, got other variant");
6097        };
6098        assert_eq!(nome, "caixa-teia");
6099        assert_eq!(repo, "https://github.com/pleme-io/`whoami`/caixa-teia");
6100        assert!(
6101            reason.contains("must not contain `` ` ``"),
6102            "reason must surface the backtick command-substitution arm, got {reason:?}"
6103        );
6104        assert!(
6105            reason.contains("command-substitution") || reason.contains("'unwise'"),
6106            "reason must name the shell-command-substitution / RFC-3986-unwise rationale, \
6107             got {reason:?}"
6108        );
6109    }
6110
6111    #[test]
6112    fn fonte_repo_fragment_fires_before_backtick_when_fragment_first() {
6113        // Cascade pin: the fragment-`#` arm and the backtick command-
6114        // substitution arm are both per-byte arms inside the same
6115        // `for &b in s.as_bytes()` loop, so the byte that appears first
6116        // in the value's byte order wins. A `:repo
6117        // "https://github.com/p/x#readme/`whoami`"` carries both `#`
6118        // and backtick; the `#` byte appears first, so the fragment-
6119        // `#` arm fires, surfacing the more self-locating diagnostic
6120        // on the byte the author pasted earliest in the URL. Mirrors
6121        // the peer cascade discipline
6122        // `fonte_repo_fragment_fires_before_shell_redirection_when_fragment_first`
6123        // pins on the prior `:repo` byte-class arm.
6124        let d = dep_with_fonte(DepSource::Git {
6125            repo: "https://github.com/pleme-io/caixa-teia#readme/`whoami`".into(),
6126            tag: Some("v0.1.0".into()),
6127            rev: None,
6128            branch: None,
6129        });
6130        let err = d.validate().unwrap_err();
6131        let DepError::FonteRepoShape { reason, .. } = err else {
6132            panic!("expected FonteRepoShape, got other variant");
6133        };
6134        assert!(
6135            reason.contains("must not contain `#`"),
6136            "reason must surface the fragment-`#` arm (fires before backtick when `#` byte \
6137             appears first in value), got {reason:?}"
6138        );
6139    }
6140
6141    #[test]
6142    fn fonte_repo_shell_redirection_fires_before_backtick_when_redirection_first() {
6143        // Cascade pin: the shell-redirection `<` / `>` arm and the
6144        // backtick command-substitution arm are both per-byte arms
6145        // inside the same `for &b in s.as_bytes()` loop, so the byte
6146        // that appears first in the value's byte order wins. A `:repo
6147        // "https://github.com/p/x>build.log/`whoami`"` carries both
6148        // `>` and backtick; the `>` byte appears first, so the
6149        // shell-redirection arm fires, surfacing the more self-
6150        // locating diagnostic on the byte the author pasted earliest
6151        // in the URL. Pins the natural-order cascade so a future
6152        // reorder of the per-byte arms surfaces here.
6153        let d = dep_with_fonte(DepSource::Git {
6154            repo: "https://github.com/pleme-io/caixa-teia>build.log/`whoami`".into(),
6155            tag: Some("v0.1.0".into()),
6156            rev: None,
6157            branch: None,
6158        });
6159        let err = d.validate().unwrap_err();
6160        let DepError::FonteRepoShape { reason, .. } = err else {
6161            panic!("expected FonteRepoShape, got other variant");
6162        };
6163        assert!(
6164            reason.contains("must not contain `>`"),
6165            "reason must surface the shell-redirection `>` arm (fires before backtick when \
6166             `>` byte appears first in value), got {reason:?}"
6167        );
6168    }
6169
6170    #[test]
6171    fn fonte_repo_fragment_fires_before_shell_redirection_when_fragment_first() {
6172        // Cascade pin: the fragment-`#` arm and the shell-redirection
6173        // `<` / `>` arm are both per-byte arms inside the same
6174        // `for &b in s.as_bytes()` loop, so the byte that appears
6175        // first in the value's byte order wins. A `:repo
6176        // "https://github.com/p/x#readme>build.log"` carries both
6177        // `#` and `>`; the `#` byte appears first, so the fragment-
6178        // `#` arm fires, surfacing the more self-locating diagnostic
6179        // on the byte the author pasted earliest in the URL. Mirrors
6180        // the peer cascade discipline
6181        // `fonte_repo_fragment_fires_before_template_placeholder_when_fragment_first`
6182        // pins on the prior `:repo` byte-class arm.
6183        let d = dep_with_fonte(DepSource::Git {
6184            repo: "https://github.com/pleme-io/caixa-teia#readme>build.log".into(),
6185            tag: Some("v0.1.0".into()),
6186            rev: None,
6187            branch: None,
6188        });
6189        let err = d.validate().unwrap_err();
6190        let DepError::FonteRepoShape { reason, .. } = err else {
6191            panic!("expected FonteRepoShape, got other variant");
6192        };
6193        assert!(
6194            reason.contains("must not contain `#`"),
6195            "reason must surface the fragment-`#` arm (fires before shell-redirection `>` when \
6196             `#` byte appears first in value), got {reason:?}"
6197        );
6198    }
6199
6200    #[test]
6201    fn validate_rejects_git_fonte_with_repo_carrying_shell_pipe() {
6202        // The fail-before-pass-after pin for the canonical
6203        // paste-from-shell-prompt-with-piped-pipeline footgun on
6204        // `:repo` (peer with the 124106f pipe arm on the sibling
6205        // `:caminho` path-fonte axis). An author pastes a shell
6206        // pipeline (`git clone <url> | tee build.log`,
6207        // `git ls-remote <url> | head`) into the `:repo` slot,
6208        // forgetting to trim the `| <consumer>` tail. Until this arm
6209        // landed the value silently passed every prior arm (no
6210        // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
6211        // no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, doesn't start
6212        // with `-` or `:`); RFC 3986 §2 lists the pipe byte in the
6213        // 'unwise' set and the WHATWG URL spec's fragment percent-
6214        // encode set maps `|` → `%7C` on the wire, so the byte rides
6215        // verbatim into the lacre's per-dep BLAKE3 closure but is
6216        // silently rewritten or rejected at libcurl's URL-parser
6217        // layer — two authors whose values differ only in their pipe
6218        // tail (`|tee build.log` vs nothing) resolve to the byte-
6219        // identical upstream `git clone` but lock to two distinct
6220        // lacres, defeating the THEORY.md §V.2 render-determinism
6221        // contract. Peer with the `:caminho` axis's
6222        // `FonteCaminhoShellPipe` arm (124106f) on the sibling path-
6223        // fonte axis, and `is_gateway_api_http_path`'s eleven-byte
6224        // RFC-3986-reserved set on `:entrada :paths`.
6225        let d = dep_with_fonte(DepSource::Git {
6226            repo: "https://github.com/pleme-io/caixa-teia|tee build.log".into(),
6227            tag: Some("v0.1.0".into()),
6228            rev: None,
6229            branch: None,
6230        });
6231        let err = d.validate().unwrap_err();
6232        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6233            panic!("expected FonteRepoShape, got other variant");
6234        };
6235        assert_eq!(nome, "caixa-teia");
6236        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia|tee build.log");
6237        assert!(
6238            reason.contains("must not contain `|`"),
6239            "reason must surface the shell-pipe arm, got {reason:?}"
6240        );
6241        assert!(
6242            reason.contains("pipe") || reason.contains("'unwise'"),
6243            "reason must name the shell-pipe / RFC-3986-unwise rationale, got {reason:?}"
6244        );
6245    }
6246
6247    #[test]
6248    fn fonte_repo_fragment_fires_before_pipe_when_fragment_first() {
6249        // Cascade pin: the fragment-`#` arm and the pipe arm are both
6250        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
6251        // so the byte that appears first in the value's byte order
6252        // wins. A `:repo "https://github.com/p/x#readme|tee"` carries
6253        // both `#` and `|`; the `#` byte appears first, so the
6254        // fragment-`#` arm fires, surfacing the more self-locating
6255        // diagnostic on the byte the author pasted earliest in the
6256        // URL. Mirrors the peer cascade discipline
6257        // `fonte_repo_fragment_fires_before_backtick_when_fragment_first`
6258        // pins on the prior `:repo` byte-class arm.
6259        let d = dep_with_fonte(DepSource::Git {
6260            repo: "https://github.com/pleme-io/caixa-teia#readme|tee".into(),
6261            tag: Some("v0.1.0".into()),
6262            rev: None,
6263            branch: None,
6264        });
6265        let err = d.validate().unwrap_err();
6266        let DepError::FonteRepoShape { reason, .. } = err else {
6267            panic!("expected FonteRepoShape, got other variant");
6268        };
6269        assert!(
6270            reason.contains("must not contain `#`"),
6271            "reason must surface the fragment-`#` arm (fires before pipe when `#` byte \
6272             appears first in value), got {reason:?}"
6273        );
6274    }
6275
6276    #[test]
6277    fn fonte_repo_backtick_fires_before_pipe_when_backtick_first() {
6278        // Cascade pin: the backtick arm and the pipe arm are both per-
6279        // byte arms inside the same `for &b in s.as_bytes()` loop, so
6280        // the byte that appears first in the value's byte order wins.
6281        // A `:repo "https://github.com/p/x/`whoami`|tee"` carries both
6282        // `` ` `` and `|`; the backtick byte appears first, so the
6283        // backtick arm fires, surfacing the more self-locating
6284        // diagnostic on the byte the author pasted earliest in the
6285        // URL. Pins the natural-order cascade so a future reorder of
6286        // the per-byte arms surfaces here.
6287        let d = dep_with_fonte(DepSource::Git {
6288            repo: "https://github.com/pleme-io/caixa-teia/`whoami`|tee".into(),
6289            tag: Some("v0.1.0".into()),
6290            rev: None,
6291            branch: None,
6292        });
6293        let err = d.validate().unwrap_err();
6294        let DepError::FonteRepoShape { reason, .. } = err else {
6295            panic!("expected FonteRepoShape, got other variant");
6296        };
6297        assert!(
6298            reason.contains("must not contain `` ` ``"),
6299            "reason must surface the backtick arm (fires before pipe when `` ` `` byte \
6300             appears first in value), got {reason:?}"
6301        );
6302    }
6303
6304    #[test]
6305    fn validate_rejects_git_fonte_with_repo_carrying_shell_command_separator() {
6306        // The fail-before-pass-after pin for the canonical
6307        // paste-from-shell-prompt-with-sequential-command-tail footgun
6308        // on `:repo` (peer with the 05c358e `;` arm on the sibling
6309        // `:caminho` path-fonte axis). An author pastes a shell
6310        // one-liner that chained a cleanup tail after the URL
6311        // (`git clone <url>; rm -rf build`, `git ls-remote <url>;
6312        // echo done`) into the `:repo` slot, forgetting to trim the
6313        // `; <cmd>` tail. Until this arm landed the value silently
6314        // passed every prior `is_git_repo_url` arm (no whitespace, no
6315        // control chars, no non-ASCII, no `#`, no `?`, no `\`, no
6316        // `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, doesn't start with
6317        // `-` or `:`); RFC 3986 §2 lists `;` in the 'sub-delims' /
6318        // reserved set and the WHATWG URL spec's fragment percent-
6319        // encode set maps `;` → `%3B` on the wire, so the byte rides
6320        // verbatim into the lacre's per-dep BLAKE3 closure but is
6321        // silently rewritten at libcurl's URL-parser layer — two
6322        // authors whose values differ only in their sequential-command
6323        // tail (`; rm -rf build` vs nothing) resolve to the byte-
6324        // identical upstream `git clone` but lock to two distinct
6325        // lacres, defeating the THEORY.md §V.2 render-determinism
6326        // contract. Peer with the `:caminho` axis's
6327        // `FonteCaminhoShellSemicolon` arm (05c358e) on the sibling
6328        // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
6329        // byte RFC-3986-reserved set on `:entrada :paths`.
6330        let d = dep_with_fonte(DepSource::Git {
6331            repo: "https://github.com/pleme-io/caixa-teia; rm -rf build".into(),
6332            tag: Some("v0.1.0".into()),
6333            rev: None,
6334            branch: None,
6335        });
6336        let err = d.validate().unwrap_err();
6337        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6338            panic!("expected FonteRepoShape, got other variant");
6339        };
6340        assert_eq!(nome, "caixa-teia");
6341        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia; rm -rf build");
6342        assert!(
6343            reason.contains("must not contain `;`"),
6344            "reason must surface the shell-command-separator arm, got {reason:?}"
6345        );
6346        assert!(
6347            reason.contains("sequential-command") || reason.contains("'sub-delims'"),
6348            "reason must name the shell-command-separator / RFC-3986-sub-delims \
6349             rationale, got {reason:?}"
6350        );
6351    }
6352
6353    #[test]
6354    fn fonte_repo_fragment_fires_before_semicolon_when_fragment_first() {
6355        // Cascade pin: the fragment-`#` arm and the semicolon arm are
6356        // both per-byte arms inside the same `for &b in s.as_bytes()`
6357        // loop, so the byte that appears first in the value's byte
6358        // order wins. A `:repo "https://github.com/p/x#readme; rm"`
6359        // carries both `#` and `;`; the `#` byte appears first, so the
6360        // fragment-`#` arm fires, surfacing the more self-locating
6361        // diagnostic on the byte the author pasted earliest in the URL.
6362        // Mirrors the peer cascade discipline
6363        // `fonte_repo_fragment_fires_before_pipe_when_fragment_first`
6364        // pins on the prior `:repo` byte-class arm.
6365        let d = dep_with_fonte(DepSource::Git {
6366            repo: "https://github.com/pleme-io/caixa-teia#readme; rm".into(),
6367            tag: Some("v0.1.0".into()),
6368            rev: None,
6369            branch: None,
6370        });
6371        let err = d.validate().unwrap_err();
6372        let DepError::FonteRepoShape { reason, .. } = err else {
6373            panic!("expected FonteRepoShape, got other variant");
6374        };
6375        assert!(
6376            reason.contains("must not contain `#`"),
6377            "reason must surface the fragment-`#` arm (fires before semicolon when `#` \
6378             byte appears first in value), got {reason:?}"
6379        );
6380    }
6381
6382    #[test]
6383    fn fonte_repo_pipe_fires_before_semicolon_when_pipe_first() {
6384        // Cascade pin: the pipe arm and the semicolon arm are both
6385        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
6386        // so the byte that appears first in the value's byte order
6387        // wins. A `:repo "https://github.com/p/x|tee; rm"` carries
6388        // both `|` and `;`; the `|` byte appears first, so the
6389        // pipe arm fires, surfacing the more self-locating diagnostic
6390        // on the byte the author pasted earliest in the URL. Pins the
6391        // natural-order cascade so a future reorder of the per-byte
6392        // arms surfaces here.
6393        let d = dep_with_fonte(DepSource::Git {
6394            repo: "https://github.com/pleme-io/caixa-teia|tee; rm".into(),
6395            tag: Some("v0.1.0".into()),
6396            rev: None,
6397            branch: None,
6398        });
6399        let err = d.validate().unwrap_err();
6400        let DepError::FonteRepoShape { reason, .. } = err else {
6401            panic!("expected FonteRepoShape, got other variant");
6402        };
6403        assert!(
6404            reason.contains("must not contain `|`"),
6405            "reason must surface the pipe arm (fires before semicolon when `|` byte \
6406             appears first in value), got {reason:?}"
6407        );
6408    }
6409
6410    #[test]
6411    fn validate_rejects_git_fonte_with_repo_carrying_shell_background() {
6412        // The fail-before-pass-after pin for the canonical
6413        // paste-from-shell-prompt-with-background-launch-tail footgun
6414        // on `:repo` (peer with the e12e4f3 `&` arm on the sibling
6415        // `:caminho` path-fonte axis). An author pastes a shell one-
6416        // liner that detached the clone into the background
6417        // (`git clone <url> & sleep 1`, `git clone <url> && cd …`)
6418        // into the `:repo` slot, forgetting to trim the `& <cmd>` /
6419        // `&& <cmd>` tail. Until this arm landed the value silently
6420        // passed every prior `is_git_repo_url` arm (no whitespace,
6421        // no control chars, no non-ASCII, no `#`, no `?`, no `\`,
6422        // no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no `;`,
6423        // doesn't start with `-` or `:`); RFC 3986 §2 lists `&` in
6424        // the 'sub-delims' / reserved set and the WHATWG URL spec's
6425        // fragment percent-encode set maps `&` → `%26` on the wire,
6426        // so the byte rides verbatim into the lacre's per-dep
6427        // BLAKE3 closure but is silently rewritten at libcurl's
6428        // URL-parser layer — two authors whose values differ only
6429        // in their background-launch tail (`& sleep 1` vs nothing)
6430        // resolve to the byte-identical upstream `git clone` but
6431        // lock to two distinct lacres, defeating the THEORY.md
6432        // §V.2 render-determinism contract. Peer with the
6433        // `:caminho` axis's `FonteCaminhoShellBackground` arm
6434        // (e12e4f3) on the sibling path-fonte axis, and
6435        // `is_gateway_api_http_path`'s eleven-byte RFC-3986-
6436        // reserved set on `:entrada :paths`.
6437        let d = dep_with_fonte(DepSource::Git {
6438            repo: "https://github.com/pleme-io/caixa-teia&sleep".into(),
6439            tag: Some("v0.1.0".into()),
6440            rev: None,
6441            branch: None,
6442        });
6443        let err = d.validate().unwrap_err();
6444        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6445            panic!("expected FonteRepoShape, got other variant");
6446        };
6447        assert_eq!(nome, "caixa-teia");
6448        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia&sleep");
6449        assert!(
6450            reason.contains("must not contain `&`"),
6451            "reason must surface the shell-background / logical-AND arm, got {reason:?}"
6452        );
6453        assert!(
6454            reason.contains("background-task") || reason.contains("'sub-delims'"),
6455            "reason must name the shell-background / RFC-3986-sub-delims rationale, \
6456             got {reason:?}"
6457        );
6458    }
6459
6460    #[test]
6461    fn validate_rejects_git_fonte_with_repo_carrying_logical_and() {
6462        // The fail-before-pass-after pin for the symmetric `&&`
6463        // logical-AND build-chain paste footgun: an author pastes
6464        // a `git clone <url> && cd <repo>` build-chain one-liner
6465        // and forgets to trim the `&& <cmd>` tail. The `&&` shape
6466        // is the same `&` byte twice in a row; the per-byte arm
6467        // fires on the first `&` it sees. Pinned separately from
6468        // the single-`&` background-launch shape so a future
6469        // diagnostic-surface change that special-cased the
6470        // doubled-byte form surfaces here.
6471        let d = dep_with_fonte(DepSource::Git {
6472            repo: "github:pleme-io/caixa-teia&&echo".into(),
6473            tag: Some("v0.1.0".into()),
6474            rev: None,
6475            branch: None,
6476        });
6477        let err = d.validate().unwrap_err();
6478        let DepError::FonteRepoShape { reason, .. } = err else {
6479            panic!("expected FonteRepoShape, got other variant");
6480        };
6481        assert!(
6482            reason.contains("must not contain `&`"),
6483            "reason must surface the shell-background / logical-AND arm on the doubled-`&&` \
6484             shape too, got {reason:?}"
6485        );
6486    }
6487
6488    #[test]
6489    fn fonte_repo_fragment_fires_before_background_when_fragment_first() {
6490        // Cascade pin: the fragment-`#` arm and the background-`&`
6491        // arm are both per-byte arms inside the same `for &b in
6492        // s.as_bytes()` loop, so the byte that appears first in the
6493        // value's byte order wins. A `:repo
6494        // "https://github.com/p/x#readme & sleep"` carries both `#`
6495        // and `&`; the `#` byte appears first, so the fragment-`#`
6496        // arm fires, surfacing the more self-locating diagnostic on
6497        // the byte the author pasted earliest in the URL. Mirrors
6498        // the peer cascade discipline
6499        // `fonte_repo_fragment_fires_before_semicolon_when_fragment_first`
6500        // on the prior `:repo` byte-class arm.
6501        let d = dep_with_fonte(DepSource::Git {
6502            repo: "https://github.com/pleme-io/caixa-teia#readme&sleep".into(),
6503            tag: Some("v0.1.0".into()),
6504            rev: None,
6505            branch: None,
6506        });
6507        let err = d.validate().unwrap_err();
6508        let DepError::FonteRepoShape { reason, .. } = err else {
6509            panic!("expected FonteRepoShape, got other variant");
6510        };
6511        assert!(
6512            reason.contains("must not contain `#`"),
6513            "reason must surface the fragment-`#` arm (fires before background-`&` when `#` \
6514             byte appears first in value), got {reason:?}"
6515        );
6516    }
6517
6518    #[test]
6519    fn fonte_repo_semicolon_fires_before_background_when_semicolon_first() {
6520        // Cascade pin: the semicolon arm and the background-`&` arm
6521        // are both per-byte arms inside the same `for &b in
6522        // s.as_bytes()` loop, so the byte that appears first in the
6523        // value's byte order wins. A `:repo
6524        // "https://github.com/p/x; rm & sleep"` carries both `;` and
6525        // `&`; the `;` byte appears first, so the semicolon arm
6526        // fires, surfacing the more self-locating diagnostic on the
6527        // byte the author pasted earliest in the URL. Pins the
6528        // natural-order cascade so a future reorder of the per-byte
6529        // arms surfaces here.
6530        let d = dep_with_fonte(DepSource::Git {
6531            repo: "https://github.com/pleme-io/caixa-teia;rm&sleep".into(),
6532            tag: Some("v0.1.0".into()),
6533            rev: None,
6534            branch: None,
6535        });
6536        let err = d.validate().unwrap_err();
6537        let DepError::FonteRepoShape { reason, .. } = err else {
6538            panic!("expected FonteRepoShape, got other variant");
6539        };
6540        assert!(
6541            reason.contains("must not contain `;`"),
6542            "reason must surface the semicolon arm (fires before background-`&` when `;` \
6543             byte appears first in value), got {reason:?}"
6544        );
6545    }
6546
6547    #[test]
6548    fn validate_rejects_git_fonte_with_repo_carrying_shell_variable_expansion() {
6549        // The fail-before-pass-after pin for the canonical
6550        // paste-from-shell-prompt-with-unsubstituted-variable footgun
6551        // on `:repo` (peer with the f4efe9c `$` arm on the sibling
6552        // `:caminho` path-fonte axis). An author pastes a shell one-
6553        // liner that referenced an environment variable
6554        // (`git clone https://github.com/$ORG/x`, `git clone
6555        // github:$USER/repo`) into the `:repo` slot, forgetting to
6556        // substitute the literal value at author time. Until this arm
6557        // landed the value silently passed every prior
6558        // `is_git_repo_url` arm (no whitespace, no control chars, no
6559        // non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no `<`/`>`,
6560        // no `` ` ``, no `|`, no `;`, no `&`, doesn't start with `-`
6561        // or `:`); RFC 3986 §2 lists `$` in the 'sub-delims' /
6562        // reserved set and the WHATWG URL spec's fragment percent-
6563        // encode set maps `$` → `%24` on the wire, so the byte rides
6564        // verbatim into the lacre's per-dep BLAKE3 closure but is
6565        // silently rewritten at libcurl's URL-parser layer — two
6566        // authors whose values differ only in their `$VAR` /
6567        // `${VAR}` / `$(cmd)` expansion tail resolve to the byte-
6568        // identical upstream `git clone` but lock to two distinct
6569        // lacres, defeating the THEORY.md §V.2 render-determinism
6570        // contract. Beyond determinism, the value is a structural
6571        // host-layout leak: two authors with the same `:repo` slot
6572        // but different `$ORG` / `$HOME` / `$WORKSPACE` resolve
6573        // different upstreams. Peer with the `:caminho` axis's
6574        // `FonteCaminhoVarExpansion` arm (f4efe9c) on the sibling
6575        // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
6576        // byte RFC-3986-reserved set on `:entrada :paths`.
6577        let d = dep_with_fonte(DepSource::Git {
6578            repo: "https://github.com/$ORG/caixa-teia".into(),
6579            tag: Some("v0.1.0".into()),
6580            rev: None,
6581            branch: None,
6582        });
6583        let err = d.validate().unwrap_err();
6584        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6585            panic!("expected FonteRepoShape, got other variant");
6586        };
6587        assert_eq!(nome, "caixa-teia");
6588        assert_eq!(repo, "https://github.com/$ORG/caixa-teia");
6589        assert!(
6590            reason.contains("must not contain `$`"),
6591            "reason must surface the shell-variable-expansion arm, got {reason:?}"
6592        );
6593        assert!(
6594            reason.contains("variable-expansion") || reason.contains("'sub-delims'"),
6595            "reason must name the shell-variable-expansion / RFC-3986-sub-delims \
6596             rationale, got {reason:?}"
6597        );
6598    }
6599
6600    #[test]
6601    fn validate_rejects_git_fonte_with_repo_carrying_braced_variable_expansion() {
6602        // The fail-before-pass-after pin for the symmetric POSIX-
6603        // shell braced `${VAR}` expansion paste footgun: an author
6604        // pastes a CI-manifest line `git clone
6605        // https://github.com/${WORKSPACE}/x` (the canonical GitHub
6606        // Actions / GitLab CI / Drone shape) and forgets to
6607        // substitute the literal value. The `${...}` shape is the
6608        // same `$` byte at the leading position of the expansion;
6609        // the per-byte arm fires on the `$`. Pinned separately from
6610        // the bare-`$VAR` shape so a future diagnostic-surface
6611        // change that special-cased the braced form surfaces here.
6612        let d = dep_with_fonte(DepSource::Git {
6613            repo: "https://github.com/${WORKSPACE}/caixa-teia".into(),
6614            tag: Some("v0.1.0".into()),
6615            rev: None,
6616            branch: None,
6617        });
6618        let err = d.validate().unwrap_err();
6619        let DepError::FonteRepoShape { reason, .. } = err else {
6620            panic!("expected FonteRepoShape, got other variant");
6621        };
6622        assert!(
6623            reason.contains("must not contain `$`"),
6624            "reason must surface the shell-variable-expansion arm on the braced `${{...}}` \
6625             shape too, got {reason:?}"
6626        );
6627    }
6628
6629    #[test]
6630    fn fonte_repo_fragment_fires_before_var_expansion_when_fragment_first() {
6631        // Cascade pin: the fragment-`#` arm and the var-expansion-`$`
6632        // arm are both per-byte arms inside the same `for &b in
6633        // s.as_bytes()` loop, so the byte that appears first in the
6634        // value's byte order wins. A `:repo
6635        // "https://github.com/p/x#readme$HOME"` carries both `#` and
6636        // `$`; the `#` byte appears first, so the fragment-`#` arm
6637        // fires, surfacing the more self-locating diagnostic on the
6638        // byte the author pasted earliest in the URL. Mirrors the
6639        // peer cascade discipline
6640        // `fonte_repo_fragment_fires_before_background_when_fragment_first`
6641        // on the prior `:repo` byte-class arm.
6642        let d = dep_with_fonte(DepSource::Git {
6643            repo: "https://github.com/pleme-io/caixa-teia#readme$HOME".into(),
6644            tag: Some("v0.1.0".into()),
6645            rev: None,
6646            branch: None,
6647        });
6648        let err = d.validate().unwrap_err();
6649        let DepError::FonteRepoShape { reason, .. } = err else {
6650            panic!("expected FonteRepoShape, got other variant");
6651        };
6652        assert!(
6653            reason.contains("must not contain `#`"),
6654            "reason must surface the fragment-`#` arm (fires before var-expansion-`$` when \
6655             `#` byte appears first in value), got {reason:?}"
6656        );
6657    }
6658
6659    #[test]
6660    fn fonte_repo_background_fires_before_var_expansion_when_background_first() {
6661        // Cascade pin: the background-`&` arm and the
6662        // var-expansion-`$` arm are both per-byte arms inside the
6663        // same `for &b in s.as_bytes()` loop, so the byte that
6664        // appears first in the value's byte order wins. A `:repo
6665        // "https://github.com/p/x&sleep$HOME"` carries both `&` and
6666        // `$`; the `&` byte appears first, so the background arm
6667        // fires, surfacing the more self-locating diagnostic on the
6668        // byte the author pasted earliest in the URL. Pins the
6669        // natural-order cascade so a future reorder of the per-byte
6670        // arms surfaces here — `$` is the most recent byte-class arm,
6671        // so the cascade-pin sweep extends to cover every immediately
6672        // prior byte arm (`#`, `&`) firing first when ordered ahead
6673        // of `$` in the value.
6674        let d = dep_with_fonte(DepSource::Git {
6675            repo: "https://github.com/pleme-io/caixa-teia&sleep$HOME".into(),
6676            tag: Some("v0.1.0".into()),
6677            rev: None,
6678            branch: None,
6679        });
6680        let err = d.validate().unwrap_err();
6681        let DepError::FonteRepoShape { reason, .. } = err else {
6682            panic!("expected FonteRepoShape, got other variant");
6683        };
6684        assert!(
6685            reason.contains("must not contain `&`"),
6686            "reason must surface the background-`&` arm (fires before var-expansion-`$` when \
6687             `&` byte appears first in value), got {reason:?}"
6688        );
6689    }
6690
6691    #[test]
6692    fn validate_rejects_git_fonte_with_repo_carrying_shell_glob_wildcard() {
6693        // The fail-before-pass-after pin for the canonical
6694        // paste-from-shell-prompt glob footgun on `:repo` (peer with
6695        // the cf9034b `*` / `?` arm on the sibling `:caminho`
6696        // path-fonte axis). An author pastes a shell one-liner that
6697        // referenced a glob expansion (`ls
6698        // github.com/pleme-io/caixa-*`, `git clone
6699        // github:pleme-io/caixa-*`) into the `:repo` slot, forgetting
6700        // to substitute the literal repo name. Until this arm landed
6701        // the `*` byte silently passed every prior `is_git_repo_url`
6702        // arm (no whitespace, no control chars, no non-ASCII, no `#`,
6703        // no `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`,
6704        // no `;`, no `&`, no `$`, doesn't start with `-` or `:`); RFC
6705        // 3986 §2 lists `*` in the 'sub-delims' / reserved set and
6706        // the WHATWG URL spec's special-query percent-encode set maps
6707        // `*` → `%2A` on the wire, so the byte rides verbatim into
6708        // the lacre's per-dep BLAKE3 closure but is silently
6709        // rewritten at libcurl's URL-parser layer — two authors
6710        // whose values differ only in their asterisk presence
6711        // resolve to the byte-identical upstream `git clone` but
6712        // lock to two distinct lacres, defeating the THEORY.md §V.2
6713        // render-determinism contract. Peer with the `:caminho`
6714        // axis's `FonteCaminhoShellGlob` arm (cf9034b) on the
6715        // sibling path-fonte axis, and the `is_git_ref_name`
6716        // refspec-wildcard cascade on the `:fonte :tag` / `:branch`
6717        // axes.
6718        let d = dep_with_fonte(DepSource::Git {
6719            repo: "https://github.com/pleme-io/caixa-*".into(),
6720            tag: Some("v0.1.0".into()),
6721            rev: None,
6722            branch: None,
6723        });
6724        let err = d.validate().unwrap_err();
6725        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6726            panic!("expected FonteRepoShape, got other variant");
6727        };
6728        assert_eq!(nome, "caixa-teia");
6729        assert_eq!(repo, "https://github.com/pleme-io/caixa-*");
6730        assert!(
6731            reason.contains("must not contain `*`"),
6732            "reason must surface the shell-glob arm, got {reason:?}"
6733        );
6734        assert!(
6735            reason.contains("pathname-expansion") || reason.contains("'sub-delims'"),
6736            "reason must name the shell-glob / pathname-expansion / \
6737             RFC-3986-sub-delims rationale, got {reason:?}"
6738        );
6739    }
6740
6741    #[test]
6742    fn validate_rejects_git_fonte_with_repo_carrying_recursive_shell_glob() {
6743        // The fail-before-pass-after pin for the symmetric bash
6744        // `globstar` recursive-glob paste footgun: an author pastes
6745        // a `ls github.com/pleme-io/**/x` (the canonical
6746        // `globstar`-shopt-enabled recursive-listing tail) into the
6747        // `:repo` slot. The `**` shape is two `*` bytes adjacent;
6748        // the per-byte arm fires on the first `*`. Pinned
6749        // separately from the single-`*` shape so a future
6750        // diagnostic-surface change that special-cased the
6751        // double-`*` form surfaces here.
6752        let d = dep_with_fonte(DepSource::Git {
6753            repo: "https://github.com/pleme-io/**/caixa-teia".into(),
6754            tag: Some("v0.1.0".into()),
6755            rev: None,
6756            branch: None,
6757        });
6758        let err = d.validate().unwrap_err();
6759        let DepError::FonteRepoShape { reason, .. } = err else {
6760            panic!("expected FonteRepoShape, got other variant");
6761        };
6762        assert!(
6763            reason.contains("must not contain `*`"),
6764            "reason must surface the shell-glob arm on the `**` recursive-glob shape too, \
6765             got {reason:?}"
6766        );
6767    }
6768
6769    #[test]
6770    fn fonte_repo_fragment_fires_before_glob_when_fragment_first() {
6771        // Cascade pin: the fragment-`#` arm and the glob-`*` arm are
6772        // both per-byte arms inside the same `for &b in s.as_bytes()`
6773        // loop, so the byte that appears first in the value's byte
6774        // order wins. A `:repo
6775        // "https://github.com/p/x#readme*tail"` carries both `#` and
6776        // `*`; the `#` byte appears first, so the fragment-`#` arm
6777        // fires, surfacing the more self-locating diagnostic on the
6778        // byte the author pasted earliest in the URL. Mirrors the
6779        // peer cascade discipline
6780        // `fonte_repo_fragment_fires_before_var_expansion_when_fragment_first`
6781        // on the prior `:repo` byte-class arm.
6782        let d = dep_with_fonte(DepSource::Git {
6783            repo: "https://github.com/pleme-io/caixa-teia#readme*tail".into(),
6784            tag: Some("v0.1.0".into()),
6785            rev: None,
6786            branch: None,
6787        });
6788        let err = d.validate().unwrap_err();
6789        let DepError::FonteRepoShape { reason, .. } = err else {
6790            panic!("expected FonteRepoShape, got other variant");
6791        };
6792        assert!(
6793            reason.contains("must not contain `#`"),
6794            "reason must surface the fragment-`#` arm (fires before glob-`*` when `#` byte \
6795             appears first in value), got {reason:?}"
6796        );
6797    }
6798
6799    #[test]
6800    fn fonte_repo_var_expansion_fires_before_glob_when_var_expansion_first() {
6801        // Cascade pin: the var-expansion-`$` arm and the glob-`*`
6802        // arm are both per-byte arms inside the same `for &b in
6803        // s.as_bytes()` loop, so the byte that appears first in the
6804        // value's byte order wins. A `:repo
6805        // "https://github.com/p/$ORG-*"` carries both `$` and `*`;
6806        // the `$` byte appears first, so the var-expansion arm
6807        // fires, surfacing the more self-locating diagnostic on the
6808        // byte the author pasted earliest in the URL. Pins the
6809        // natural-order cascade so a future reorder of the per-byte
6810        // arms surfaces here — `*` is the most recent byte-class
6811        // arm, so the cascade-pin sweep extends to cover the
6812        // immediately prior `$` byte arm firing first when ordered
6813        // ahead of `*` in the value.
6814        let d = dep_with_fonte(DepSource::Git {
6815            repo: "https://github.com/pleme-io/$ORG-caixa-*".into(),
6816            tag: Some("v0.1.0".into()),
6817            rev: None,
6818            branch: None,
6819        });
6820        let err = d.validate().unwrap_err();
6821        let DepError::FonteRepoShape { reason, .. } = err else {
6822            panic!("expected FonteRepoShape, got other variant");
6823        };
6824        assert!(
6825            reason.contains("must not contain `$`"),
6826            "reason must surface the var-expansion-`$` arm (fires before glob-`*` when `$` \
6827             byte appears first in value), got {reason:?}"
6828        );
6829    }
6830
6831    #[test]
6832    fn validate_rejects_git_fonte_with_repo_carrying_subshell_open_paren() {
6833        // The fail-before-pass-after pin for the canonical paste-from-
6834        // shell-prompt subshell-grouping footgun on `:repo`. An author
6835        // pastes a doc / README snippet carrying a regex-alternation
6836        // grouping shape (`https://github.com/(foo|bar)/repo`) or a
6837        // dynamic-config-substitution wrapper (`$(<cmd>)`) into the
6838        // `:repo` slot, forgetting to substitute one literal org name.
6839        // Until this arm landed the `(` byte silently passed every
6840        // prior `is_git_repo_url` arm (no whitespace, no control
6841        // chars, no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no
6842        // `<`/`>`, no `` ` ``, no `|`, no `;`, no `&`, no `$`, no
6843        // `*`, doesn't start with `-` or `:`); RFC 3986 §2 lists `(`
6844        // / `)` in the 'sub-delims' / reserved set, and the WHATWG
6845        // URL spec's special-query percent-encode set maps `(` →
6846        // `%28` and `)` → `%29` on the wire, so the byte rides
6847        // verbatim into the lacre's per-dep BLAKE3 closure but is
6848        // silently rewritten at libcurl's URL-parser layer —
6849        // defeating the THEORY.md §V.2 render-determinism contract on
6850        // the same axis the prior twelve byte-class arms close.
6851        let d = dep_with_fonte(DepSource::Git {
6852            repo: "https://github.com/(foo|bar)/caixa-teia".into(),
6853            tag: Some("v0.1.0".into()),
6854            rev: None,
6855            branch: None,
6856        });
6857        let err = d.validate().unwrap_err();
6858        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6859            panic!("expected FonteRepoShape, got other variant");
6860        };
6861        assert_eq!(nome, "caixa-teia");
6862        assert_eq!(repo, "https://github.com/(foo|bar)/caixa-teia");
6863        assert!(
6864            reason.contains("must not contain `(`"),
6865            "reason must surface the subshell-open-paren arm, got {reason:?}"
6866        );
6867        assert!(
6868            reason.contains("subshell-grouping") || reason.contains("'sub-delims'"),
6869            "reason must name the shell-subshell-grouping / RFC-3986-sub-delims rationale, \
6870             got {reason:?}"
6871        );
6872    }
6873
6874    #[test]
6875    fn validate_rejects_git_fonte_with_repo_carrying_subshell_close_paren() {
6876        // The symmetric arm pin on the closing `)` byte: an author
6877        // pastes a `$(date)` command-substitution wrapper or a
6878        // regex-alternation `(foo|bar)` tail into the `:repo` slot.
6879        // Pinned separately from the opening `(` shape so a future
6880        // diagnostic-surface change that only checked one boundary
6881        // surfaces here. The `(` byte appears earlier in the
6882        // canonical regex / subshell wrapper so the per-byte loop
6883        // fires on `(` first; this test exercises a `:repo` value
6884        // carrying only the closing `)` byte (no opening paren) so
6885        // the `)` arm fires directly — pinning the byte-class arm
6886        // independent of order.
6887        let d = dep_with_fonte(DepSource::Git {
6888            repo: "github:pleme-io/caixa-teia)tail".into(),
6889            tag: Some("v0.1.0".into()),
6890            rev: None,
6891            branch: None,
6892        });
6893        let err = d.validate().unwrap_err();
6894        let DepError::FonteRepoShape { reason, .. } = err else {
6895            panic!("expected FonteRepoShape, got other variant");
6896        };
6897        assert!(
6898            reason.contains("must not contain `)`"),
6899            "reason must surface the subshell-close-paren arm on the bare `)` shape, \
6900             got {reason:?}"
6901        );
6902    }
6903
6904    #[test]
6905    fn fonte_repo_fragment_fires_before_subshell_when_fragment_first() {
6906        // Cascade pin: the fragment-`#` arm and the subshell-`(` arm
6907        // are both per-byte arms inside the same `for &b in
6908        // s.as_bytes()` loop, so the byte that appears first in the
6909        // value's byte order wins. A `:repo
6910        // "https://github.com/p/x#readme(tail)"` carries both `#` and
6911        // `(`; the `#` byte appears first, so the fragment-`#` arm
6912        // fires, surfacing the more self-locating diagnostic on the
6913        // byte the author pasted earliest in the URL. Mirrors the
6914        // peer cascade discipline
6915        // `fonte_repo_fragment_fires_before_glob_when_fragment_first`
6916        // on the prior `:repo` byte-class arm.
6917        let d = dep_with_fonte(DepSource::Git {
6918            repo: "https://github.com/pleme-io/caixa-teia#readme(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 fragment-`#` arm (fires before subshell-`(` when `#` \
6930             byte appears first in value), got {reason:?}"
6931        );
6932    }
6933
6934    #[test]
6935    fn fonte_repo_glob_fires_before_subshell_when_glob_first() {
6936        // Cascade pin: the glob-`*` arm (the immediate-predecessor
6937        // byte-class arm, 3902a9a) and the subshell-`(` arm are both
6938        // per-byte arms inside the same `for &b in s.as_bytes()`
6939        // loop, so the byte that appears first in the value's byte
6940        // order wins. A `:repo
6941        // "https://github.com/p/x-*-(date)"` carries both `*` and
6942        // `(`; the `*` byte appears first, so the glob arm fires,
6943        // surfacing the more self-locating diagnostic on the byte
6944        // the author pasted earliest in the URL. Pins the natural-
6945        // order cascade so a future reorder of the per-byte arms
6946        // surfaces here — `(` is the most recent byte-class arm,
6947        // so the cascade-pin sweep extends to cover the immediately
6948        // prior `*` byte arm firing first when ordered ahead of `(`
6949        // in the value.
6950        let d = dep_with_fonte(DepSource::Git {
6951            repo: "https://github.com/pleme-io/caixa-teia-*-(date)".into(),
6952            tag: Some("v0.1.0".into()),
6953            rev: None,
6954            branch: None,
6955        });
6956        let err = d.validate().unwrap_err();
6957        let DepError::FonteRepoShape { reason, .. } = err else {
6958            panic!("expected FonteRepoShape, got other variant");
6959        };
6960        assert!(
6961            reason.contains("must not contain `*`"),
6962            "reason must surface the glob-`*` arm (fires before subshell-`(` when `*` byte \
6963             appears first in value), got {reason:?}"
6964        );
6965    }
6966
6967    #[test]
6968    fn validate_rejects_git_fonte_with_repo_carrying_shell_double_quote() {
6969        // The fail-before-pass-after pin for the canonical paste-from-
6970        // doc-shell-quoting footgun on `:repo`. An author copies a
6971        // README quick-start snippet (`$ git clone "https://github.com/
6972        // foo/bar"`) and keeps the surrounding double-quote bytes when
6973        // pasting into the `:repo` slot — the doc wraps the URL in
6974        // double quotes so the shell doesn't re-lex metachars inside,
6975        // but the typed slot is itself a byte-level string parser, not
6976        // a shell context, so the quote bytes ride into the value
6977        // verbatim. Until this arm landed the `"` byte silently passed
6978        // every prior `is_git_repo_url` arm (no whitespace, no control
6979        // chars, no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no
6980        // `<`/`>`, no `` ` ``, no `|`, no `;`, no `&`, no `$`, no `*`,
6981        // no `(`/`)`, doesn't start with `-` or `:`); RFC 3986 §2 lists
6982        // `"` in the strict four-byte 'delims' subset (with `<`, `>`,
6983        // `` ` ``) every URL parser is required to refuse or percent-
6984        // encode, and the WHATWG URL spec's 'C0 control percent-encode
6985        // set' maps `"` → `%22` on the wire, so the byte rides verbatim
6986        // into the lacre's per-dep BLAKE3 closure but is silently
6987        // rewritten at libcurl's URL-parser layer, defeating the
6988        // THEORY.md §V.2 render-determinism contract.
6989        let d = dep_with_fonte(DepSource::Git {
6990            repo: "\"https://github.com/pleme-io/caixa-teia\"".into(),
6991            tag: Some("v0.1.0".into()),
6992            rev: None,
6993            branch: None,
6994        });
6995        let err = d.validate().unwrap_err();
6996        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6997            panic!("expected FonteRepoShape, got other variant");
6998        };
6999        assert_eq!(nome, "caixa-teia");
7000        assert_eq!(repo, "\"https://github.com/pleme-io/caixa-teia\"");
7001        assert!(
7002            reason.contains("must not contain `\"`"),
7003            "reason must surface the shell-double-quote arm, got {reason:?}"
7004        );
7005        assert!(
7006            reason.contains("double-quote") || reason.contains("'delims'"),
7007            "reason must name the shell-double-quote / RFC-3986-delims rationale, \
7008             got {reason:?}"
7009        );
7010    }
7011
7012    #[test]
7013    fn validate_rejects_git_fonte_with_repo_carrying_stray_trailing_double_quote() {
7014        // The symmetric stray-quote tail pin: an author pastes only a
7015        // closing `"` from a shell-history line like `git clone
7016        // "https://github.com/foo/bar" && cd …` (the trim went too
7017        // far in one direction but not the other) into the `:repo`
7018        // slot. Pinned separately from the wrapped-quote shape so a
7019        // future diagnostic-surface change that only checked one
7020        // boundary (only leading, only trailing, only paired) surfaces
7021        // here — the per-byte arm fires anywhere `"` appears.
7022        let d = dep_with_fonte(DepSource::Git {
7023            repo: "github:pleme-io/caixa-teia\"".into(),
7024            tag: Some("v0.1.0".into()),
7025            rev: None,
7026            branch: None,
7027        });
7028        let err = d.validate().unwrap_err();
7029        let DepError::FonteRepoShape { reason, .. } = err else {
7030            panic!("expected FonteRepoShape, got other variant");
7031        };
7032        assert!(
7033            reason.contains("must not contain `\"`"),
7034            "reason must surface the shell-double-quote arm on the trailing-`\"` shape, \
7035             got {reason:?}"
7036        );
7037    }
7038
7039    #[test]
7040    fn fonte_repo_fragment_fires_before_double_quote_when_fragment_first() {
7041        // Cascade pin: the fragment-`#` arm and the double-quote arm
7042        // are both per-byte arms inside the same `for &b in
7043        // s.as_bytes()` loop, so the byte that appears first in the
7044        // value's byte order wins. A `:repo
7045        // "https://github.com/p/x#readme\"tail"` carries both `#` and
7046        // `"`; the `#` byte appears first, so the fragment-`#` arm
7047        // fires, surfacing the more self-locating diagnostic on the
7048        // byte the author pasted earliest in the URL.
7049        let d = dep_with_fonte(DepSource::Git {
7050            repo: "https://github.com/pleme-io/caixa-teia#readme\"tail".into(),
7051            tag: Some("v0.1.0".into()),
7052            rev: None,
7053            branch: None,
7054        });
7055        let err = d.validate().unwrap_err();
7056        let DepError::FonteRepoShape { reason, .. } = err else {
7057            panic!("expected FonteRepoShape, got other variant");
7058        };
7059        assert!(
7060            reason.contains("must not contain `#`"),
7061            "reason must surface the fragment-`#` arm (fires before double-quote when `#` \
7062             byte appears first in value), got {reason:?}"
7063        );
7064    }
7065
7066    #[test]
7067    fn fonte_repo_subshell_fires_before_double_quote_when_subshell_first() {
7068        // Cascade pin: the subshell-`(` arm (the immediate-predecessor
7069        // byte-class arm, 3b99147) and the double-quote arm are both
7070        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
7071        // so the byte that appears first in the value's byte order
7072        // wins. A `:repo "github:p/x(date)\"tail"` carries both `(`
7073        // and `"`; the `(` byte appears first, so the subshell arm
7074        // fires, surfacing the more self-locating diagnostic on the
7075        // byte the author pasted earliest in the URL. Pins the natural-
7076        // order cascade so a future reorder of the per-byte arms
7077        // surfaces here — `"` is the most recent byte-class arm, so
7078        // the cascade-pin sweep extends to cover the immediately prior
7079        // `(` byte arm firing first when ordered ahead of `"` in the
7080        // value.
7081        let d = dep_with_fonte(DepSource::Git {
7082            repo: "github:pleme-io/caixa-teia(date)\"tail".into(),
7083            tag: Some("v0.1.0".into()),
7084            rev: None,
7085            branch: None,
7086        });
7087        let err = d.validate().unwrap_err();
7088        let DepError::FonteRepoShape { reason, .. } = err else {
7089            panic!("expected FonteRepoShape, got other variant");
7090        };
7091        assert!(
7092            reason.contains("must not contain `(`"),
7093            "reason must surface the subshell-`(` arm (fires before double-quote when `(` \
7094             byte appears first in value), got {reason:?}"
7095        );
7096    }
7097
7098    #[test]
7099    fn validate_rejects_git_fonte_with_repo_carrying_shell_single_quote() {
7100        // The fail-before-pass-after pin for the canonical paste-from-
7101        // doc-strong-quoting footgun on `:repo`. An author copies a
7102        // security-conscious README quick-start snippet (`$ git clone
7103        // 'https://github.com/foo/bar'`) and keeps the surrounding
7104        // single-quote bytes when pasting into the `:repo` slot — the
7105        // doc strong-quotes the URL so the shell suppresses every form
7106        // of expansion on the bytes inside (no `$`, no backtick, no
7107        // glob, no word-splitting), but the typed slot is itself a
7108        // byte-level string parser, not a shell context, so the quote
7109        // bytes ride into the value verbatim. Until this arm landed the
7110        // `'` byte silently passed every prior `is_git_repo_url` arm
7111        // (no whitespace, no control chars, no non-ASCII, no `#`, no
7112        // `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no
7113        // `;`, no `&`, no `$`, no `*`, no `(`/`)`, no `"`, doesn't start
7114        // with `-` or `:`); RFC 3986 §2.2 lists `'` in the 'sub-delims'
7115        // set, peer with the `\"` 'delims' double-quote arm and the
7116        // partner ASCII shell-string-delimiter byte every byte-level
7117        // string parser sharing a value-shape with a shell argument
7118        // must refuse on a URL-shaped slot.
7119        let d = dep_with_fonte(DepSource::Git {
7120            repo: "'https://github.com/pleme-io/caixa-teia'".into(),
7121            tag: Some("v0.1.0".into()),
7122            rev: None,
7123            branch: None,
7124        });
7125        let err = d.validate().unwrap_err();
7126        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7127            panic!("expected FonteRepoShape, got other variant");
7128        };
7129        assert_eq!(nome, "caixa-teia");
7130        assert_eq!(repo, "'https://github.com/pleme-io/caixa-teia'");
7131        assert!(
7132            reason.contains("must not contain `'`"),
7133            "reason must surface the shell-single-quote arm, got {reason:?}"
7134        );
7135        assert!(
7136            reason.contains("single-quote") || reason.contains("strong-quote"),
7137            "reason must name the shell-single-quote / strong-quote rationale, \
7138             got {reason:?}"
7139        );
7140    }
7141
7142    #[test]
7143    fn validate_rejects_git_fonte_with_repo_carrying_english_apostrophe() {
7144        // The symmetric English-typography pin: an author writes
7145        // `:repo "github:p/repo's-fork"` (the possessive-form paste-
7146        // from-prose idiom every README / commit-message / chat-thread
7147        // reference to a repo carries) expecting the substrate to
7148        // coerce it to a kebab-case slug — but the byte rides into the
7149        // lacre verbatim. Pinned separately from the wrapped-quote
7150        // shape so a future diagnostic-surface change that only checked
7151        // the boundary positions (only leading, only trailing, only
7152        // paired) surfaces here — the per-byte arm fires anywhere `'`
7153        // appears in the value.
7154        let d = dep_with_fonte(DepSource::Git {
7155            repo: "github:pleme-io/repo's-fork".into(),
7156            tag: Some("v0.1.0".into()),
7157            rev: None,
7158            branch: None,
7159        });
7160        let err = d.validate().unwrap_err();
7161        let DepError::FonteRepoShape { reason, .. } = err else {
7162            panic!("expected FonteRepoShape, got other variant");
7163        };
7164        assert!(
7165            reason.contains("must not contain `'`"),
7166            "reason must surface the shell-single-quote arm on the mid-string \
7167             apostrophe shape, got {reason:?}"
7168        );
7169    }
7170
7171    #[test]
7172    fn fonte_repo_fragment_fires_before_single_quote_when_fragment_first() {
7173        // Cascade pin: the fragment-`#` arm and the single-quote arm
7174        // are both per-byte arms inside the same `for &b in
7175        // s.as_bytes()` loop, so the byte that appears first in the
7176        // value's byte order wins. A `:repo
7177        // "https://github.com/p/x#readme'tail"` carries both `#` and
7178        // `'`; the `#` byte appears first, so the fragment-`#` arm
7179        // fires, surfacing the more self-locating diagnostic on the
7180        // byte the author pasted earliest in the URL.
7181        let d = dep_with_fonte(DepSource::Git {
7182            repo: "https://github.com/pleme-io/caixa-teia#readme'tail".into(),
7183            tag: Some("v0.1.0".into()),
7184            rev: None,
7185            branch: None,
7186        });
7187        let err = d.validate().unwrap_err();
7188        let DepError::FonteRepoShape { reason, .. } = err else {
7189            panic!("expected FonteRepoShape, got other variant");
7190        };
7191        assert!(
7192            reason.contains("must not contain `#`"),
7193            "reason must surface the fragment-`#` arm (fires before single-quote when `#` \
7194             byte appears first in value), got {reason:?}"
7195        );
7196    }
7197
7198    #[test]
7199    fn fonte_repo_double_quote_fires_before_single_quote_when_double_quote_first() {
7200        // Cascade pin: the double-quote-`"` arm (the immediate-predecessor
7201        // byte-class arm, 4267d8b) and the single-quote arm are both
7202        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
7203        // so the byte that appears first in the value's byte order
7204        // wins. A `:repo "github:p/x\"mid'tail"` carries both `"` and
7205        // `'`; the `"` byte appears first, so the double-quote arm
7206        // fires, surfacing the more self-locating diagnostic on the
7207        // byte the author pasted earliest in the URL. Pins the natural-
7208        // order cascade so a future reorder of the per-byte arms
7209        // surfaces here — `'` is the most recent byte-class arm, so
7210        // the cascade-pin sweep extends to cover the immediately prior
7211        // `"` byte arm firing first when ordered ahead of `'` in the
7212        // value.
7213        let d = dep_with_fonte(DepSource::Git {
7214            repo: "github:pleme-io/caixa-teia\"mid'tail".into(),
7215            tag: Some("v0.1.0".into()),
7216            rev: None,
7217            branch: None,
7218        });
7219        let err = d.validate().unwrap_err();
7220        let DepError::FonteRepoShape { reason, .. } = err else {
7221            panic!("expected FonteRepoShape, got other variant");
7222        };
7223        assert!(
7224            reason.contains("must not contain `\"`"),
7225            "reason must surface the double-quote arm (fires before single-quote when `\"` \
7226             byte appears first in value), got {reason:?}"
7227        );
7228    }
7229
7230    #[test]
7231    fn validate_rejects_git_fonte_with_repo_carrying_shell_history_expansion() {
7232        // The fail-before-pass-after pin for the canonical paste-from-
7233        // shell-history footgun on `:repo`. An author copies a `git
7234        // clone <url>!sudo make install` one-liner from a README's
7235        // quick-start snippet, intending the trailing `!sudo` as a
7236        // shell-history-expansion reference but the typed slot is itself
7237        // a byte-level string parser, not a shell context, so the byte
7238        // rides into the value verbatim. Until this arm landed the `!`
7239        // byte silently passed every prior `is_git_repo_url` arm (no
7240        // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
7241        // no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no `;`,
7242        // no `&`, no `$`, no `*`, no `(`/`)`, no `"`, no `'`, doesn't
7243        // start with `-` or `:`); bash with the default `histexpand`
7244        // mode rewrites `!command` to the most recent history entry
7245        // beginning with `command`, the canonical RCE-class injection
7246        // vector when the byte rides into a shell argument.
7247        let d = dep_with_fonte(DepSource::Git {
7248            repo: "https://github.com/pleme-io/caixa-teia!sudo".into(),
7249            tag: Some("v0.1.0".into()),
7250            rev: None,
7251            branch: None,
7252        });
7253        let err = d.validate().unwrap_err();
7254        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7255            panic!("expected FonteRepoShape, got other variant");
7256        };
7257        assert_eq!(nome, "caixa-teia");
7258        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia!sudo");
7259        assert!(
7260            reason.contains("must not contain `!`"),
7261            "reason must surface the shell-history-expansion arm, got {reason:?}"
7262        );
7263        assert!(
7264            reason.contains("history-expansion") || reason.contains("bang"),
7265            "reason must name the shell-history-expansion / bang rationale, got {reason:?}"
7266        );
7267    }
7268
7269    #[test]
7270    fn validate_rejects_git_fonte_with_repo_carrying_double_bang_history_reference() {
7271        // The symmetric `!!` repeat-prior-command pin: an author paste-
7272        // trims a `git clone <url>` retry idiom from shell history that
7273        // expands to the previous command via `!!`. Pinned separately
7274        // from the wrapped `!command` shape so a future diagnostic-
7275        // surface change that only checked the leading or paired-bang
7276        // position surfaces here — the per-byte arm fires anywhere `!`
7277        // appears in the value.
7278        let d = dep_with_fonte(DepSource::Git {
7279            repo: "github:pleme-io/caixa-teia!!".into(),
7280            tag: Some("v0.1.0".into()),
7281            rev: None,
7282            branch: None,
7283        });
7284        let err = d.validate().unwrap_err();
7285        let DepError::FonteRepoShape { reason, .. } = err else {
7286            panic!("expected FonteRepoShape, got other variant");
7287        };
7288        assert!(
7289            reason.contains("must not contain `!`"),
7290            "reason must surface the shell-history-expansion arm on the trailing-`!!` shape, \
7291             got {reason:?}"
7292        );
7293    }
7294
7295    #[test]
7296    fn fonte_repo_fragment_fires_before_bang_when_fragment_first() {
7297        // Cascade pin: the fragment-`#` arm and the bang arm are both
7298        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
7299        // so the byte that appears first in the value's byte order
7300        // wins. A `:repo "https://github.com/p/x#readme!tail"` carries
7301        // both `#` and `!`; the `#` byte appears first, so the
7302        // fragment-`#` arm fires, surfacing the more self-locating
7303        // diagnostic on the byte the author pasted earliest in the URL.
7304        let d = dep_with_fonte(DepSource::Git {
7305            repo: "https://github.com/pleme-io/caixa-teia#readme!tail".into(),
7306            tag: Some("v0.1.0".into()),
7307            rev: None,
7308            branch: None,
7309        });
7310        let err = d.validate().unwrap_err();
7311        let DepError::FonteRepoShape { reason, .. } = err else {
7312            panic!("expected FonteRepoShape, got other variant");
7313        };
7314        assert!(
7315            reason.contains("must not contain `#`"),
7316            "reason must surface the fragment-`#` arm (fires before bang when `#` byte \
7317             appears first in value), got {reason:?}"
7318        );
7319    }
7320
7321    #[test]
7322    fn fonte_repo_single_quote_fires_before_bang_when_single_quote_first() {
7323        // Cascade pin: the single-quote-`'` arm (the immediate-predecessor
7324        // byte-class arm, e7a109f) and the bang arm are both per-byte
7325        // arms inside the same `for &b in s.as_bytes()` loop, so the
7326        // byte that appears first in the value's byte order wins. A
7327        // `:repo "github:p/x'mid!tail"` carries both `'` and `!`; the
7328        // `'` byte appears first, so the single-quote arm fires,
7329        // surfacing the more self-locating diagnostic on the byte the
7330        // author pasted earliest in the URL. Pins the natural-order
7331        // cascade so a future reorder of the per-byte arms surfaces
7332        // here — `!` is the most recent byte-class arm, so the
7333        // cascade-pin sweep extends to cover the immediately prior `'`
7334        // byte arm firing first when ordered ahead of `!` in the value.
7335        let d = dep_with_fonte(DepSource::Git {
7336            repo: "github:pleme-io/caixa-teia'mid!tail".into(),
7337            tag: Some("v0.1.0".into()),
7338            rev: None,
7339            branch: None,
7340        });
7341        let err = d.validate().unwrap_err();
7342        let DepError::FonteRepoShape { reason, .. } = err else {
7343            panic!("expected FonteRepoShape, got other variant");
7344        };
7345        assert!(
7346            reason.contains("must not contain `'`"),
7347            "reason must surface the single-quote arm (fires before bang when `'` byte \
7348             appears first in value), got {reason:?}"
7349        );
7350    }
7351
7352    #[test]
7353    fn validate_rejects_git_fonte_with_repo_carrying_list_separator_comma() {
7354        // The fail-before-pass-after pin for the canonical
7355        // list-separator-belongs-to-list-grammar footgun on `:repo`.
7356        // An author copies a `git clone <a>, <b>, <c>` paste-from-CSV
7357        // one-liner from a multi-repo bootstrap doc, intending the
7358        // comma to separate multiple repo entries but the typed
7359        // `:repo` slot names *one* repo (the list-separator belongs
7360        // to the `:deps` list grammar, not to the value). Until this
7361        // arm landed the `,` byte silently passed every prior
7362        // `is_git_repo_url` arm (no whitespace, no control chars, no
7363        // non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no `<`/`>`,
7364        // no `` ` ``, no `|`, no `;`, no `&`, no `$`, no `*`, no
7365        // `(`/`)`, no `"`, no `'`, no `!`, doesn't start with `-` or
7366        // `:`); the byte rode into the lacre's per-dep content-
7367        // address and the resolver's `git clone <repo>` subprocess
7368        // invocation, where no host's repo registry resolved the
7369        // comma-bearing slug.
7370        let d = dep_with_fonte(DepSource::Git {
7371            repo: "github:pleme-io/caixa-teia,github:pleme-io/caixa-feira".into(),
7372            tag: Some("v0.1.0".into()),
7373            rev: None,
7374            branch: None,
7375        });
7376        let err = d.validate().unwrap_err();
7377        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7378            panic!("expected FonteRepoShape, got other variant");
7379        };
7380        assert_eq!(nome, "caixa-teia");
7381        assert_eq!(
7382            repo,
7383            "github:pleme-io/caixa-teia,github:pleme-io/caixa-feira"
7384        );
7385        assert!(
7386            reason.contains("must not contain `,`"),
7387            "reason must surface the list-separator-comma arm, got {reason:?}"
7388        );
7389        assert!(
7390            reason.contains("list-separator") || reason.contains("sub-delims"),
7391            "reason must name the list-separator / RFC-3986-sub-delims rationale, \
7392             got {reason:?}"
7393        );
7394    }
7395
7396    #[test]
7397    fn validate_rejects_git_fonte_with_repo_carrying_trailing_comma() {
7398        // The symmetric trailing-`,` paste-from-prose pin: an author
7399        // writes `:repo "github:pleme-io/caixa-feira,"` (the trailing
7400        // comma every README-prose list-of-projects sentence carries,
7401        // mistakenly retained when the slug is pasted mid-sentence)
7402        // expecting the substrate to coerce it to a kebab-case slug.
7403        // Pinned separately from the wrapped mid-token shape so a
7404        // future diagnostic-surface change that only checked the
7405        // leading or paired-comma position surfaces here — the
7406        // per-byte arm fires anywhere `,` appears in the value.
7407        let d = dep_with_fonte(DepSource::Git {
7408            repo: "github:pleme-io/caixa-feira,".into(),
7409            tag: Some("v0.1.0".into()),
7410            rev: None,
7411            branch: None,
7412        });
7413        let err = d.validate().unwrap_err();
7414        let DepError::FonteRepoShape { reason, .. } = err else {
7415            panic!("expected FonteRepoShape, got other variant");
7416        };
7417        assert!(
7418            reason.contains("must not contain `,`"),
7419            "reason must surface the list-separator-comma arm on the trailing-`,` shape, \
7420             got {reason:?}"
7421        );
7422    }
7423
7424    #[test]
7425    fn fonte_repo_fragment_fires_before_comma_when_fragment_first() {
7426        // Cascade pin: the fragment-`#` arm and the comma arm are
7427        // both per-byte arms inside the same `for &b in s.as_bytes()`
7428        // loop, so the byte that appears first in the value's byte
7429        // order wins. A `:repo "https://github.com/p/x#readme,tail"`
7430        // carries both `#` and `,`; the `#` byte appears first, so
7431        // the fragment-`#` arm fires, surfacing the more self-
7432        // locating diagnostic on the byte the author pasted earliest
7433        // in the URL.
7434        let d = dep_with_fonte(DepSource::Git {
7435            repo: "https://github.com/pleme-io/caixa-teia#readme,tail".into(),
7436            tag: Some("v0.1.0".into()),
7437            rev: None,
7438            branch: None,
7439        });
7440        let err = d.validate().unwrap_err();
7441        let DepError::FonteRepoShape { reason, .. } = err else {
7442            panic!("expected FonteRepoShape, got other variant");
7443        };
7444        assert!(
7445            reason.contains("must not contain `#`"),
7446            "reason must surface the fragment-`#` arm (fires before comma when `#` byte \
7447             appears first in value), got {reason:?}"
7448        );
7449    }
7450
7451    #[test]
7452    fn fonte_repo_bang_fires_before_comma_when_bang_first() {
7453        // Cascade pin: the bang-`!` arm (the immediate-predecessor
7454        // byte-class arm, 7d53c68) and the comma arm are both
7455        // per-byte arms inside the same `for &b in s.as_bytes()`
7456        // loop, so the byte that appears first in the value's byte
7457        // order wins. A `:repo "github:p/x!mid,tail"` carries both
7458        // `!` and `,`; the `!` byte appears first, so the bang arm
7459        // fires, surfacing the more self-locating diagnostic on the
7460        // byte the author pasted earliest in the URL. Pins the
7461        // natural-order cascade so a future reorder of the per-byte
7462        // arms surfaces here — `,` is the most recent byte-class
7463        // arm, so the cascade-pin sweep extends to cover the
7464        // immediately prior `!` byte arm firing first when ordered
7465        // ahead of `,` in the value.
7466        let d = dep_with_fonte(DepSource::Git {
7467            repo: "github:pleme-io/caixa-teia!mid,tail".into(),
7468            tag: Some("v0.1.0".into()),
7469            rev: None,
7470            branch: None,
7471        });
7472        let err = d.validate().unwrap_err();
7473        let DepError::FonteRepoShape { reason, .. } = err else {
7474            panic!("expected FonteRepoShape, got other variant");
7475        };
7476        assert!(
7477            reason.contains("must not contain `!`"),
7478            "reason must surface the bang arm (fires before comma when `!` byte \
7479             appears first in value), got {reason:?}"
7480        );
7481    }
7482
7483    #[test]
7484    fn validate_rejects_git_fonte_with_repo_carrying_shell_env_var_assignment() {
7485        // The fail-before-pass-after pin for the canonical
7486        // shell-env-var-assignment-belongs-to-shell-grammar footgun
7487        // on `:repo`. An author copies
7488        // `GIT_TERMINAL_PROMPT=0 git clone <url>` (or
7489        // `GIT_SSL_NO_VERIFY=1 git clone <url>`, `HTTPS_PROXY=…
7490        // git clone <url>`, etc. — the canonical
7491        // git-troubleshooting README idiom for a one-shot env-var
7492        // scoped to the `git clone` invocation) from a shell-prompt
7493        // one-liner, intending the `KEY=VALUE` prefix as a shell-
7494        // grammar env-var assignment but the typed `:repo` slot is
7495        // a value parser, not a shell context, so the bytes ride
7496        // into the value verbatim. Until this arm landed the `=`
7497        // byte silently passed every prior `is_git_repo_url` arm
7498        // (no whitespace, no control chars, no non-ASCII, no `#`,
7499        // no `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no
7500        // `|`, no `;`, no `&`, no `$`, no `*`, no `(`/`)`, no `"`,
7501        // no `'`, no `!`, no `,`, doesn't start with `-` or `:`);
7502        // the byte rode into the lacre's per-dep content-address
7503        // and the resolver's `git clone <repo>` subprocess
7504        // invocation, where the upstream host's git porcelain
7505        // fetched a literal `GIT_TERMINAL_PROMPT=0 https://…`-shaped
7506        // path that no host's repo registry resolves.
7507        let d = dep_with_fonte(DepSource::Git {
7508            repo: "GIT_TERMINAL_PROMPT=0 https://github.com/pleme-io/caixa-teia".into(),
7509            tag: Some("v0.1.0".into()),
7510            rev: None,
7511            branch: None,
7512        });
7513        let err = d.validate().unwrap_err();
7514        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7515            panic!("expected FonteRepoShape, got other variant");
7516        };
7517        assert_eq!(nome, "caixa-teia");
7518        assert_eq!(
7519            repo,
7520            "GIT_TERMINAL_PROMPT=0 https://github.com/pleme-io/caixa-teia"
7521        );
7522        // The `=` byte at position 19 of `GIT_TERMINAL_PROMPT=0 …`
7523        // appears before the ` ` byte at position 21, so the `=`
7524        // arm fires (not the whitespace arm) — both arms guard
7525        // the slot, but the per-byte for-loop scans left-to-right
7526        // and the first matching byte wins.
7527        assert!(
7528            reason.contains("must not contain `=`"),
7529            "reason must surface the equals-`=` arm on the env-var-assignment \
7530             paste shape, got {reason:?}"
7531        );
7532        assert!(
7533            reason.contains("env-var-assignment") || reason.contains("KEY=VALUE"),
7534            "reason must name the shell-env-var-assignment rationale, got {reason:?}"
7535        );
7536    }
7537
7538    #[test]
7539    fn validate_rejects_git_fonte_with_repo_carrying_gitconfig_url_key_prefix() {
7540        // The symmetric paste-from-gitconfig pin: an author copies
7541        // `url=https://github.com/p/x` from `git config --get-all
7542        // remote.origin.url` output, a `.gitconfig` `[remote
7543        // "origin"] url = https://…` ini-stanza paste, or a
7544        // `git config remote.origin.url <value>` doc snippet,
7545        // intending the `url=` prefix as the ini-key but the typed
7546        // `:repo` slot is a URL value parser, not a gitconfig
7547        // grammar. With no leading whitespace and no earlier-arm
7548        // bytes in the value, the `=` arm itself fires (rather
7549        // than cascading to the whitespace arm as in the env-var
7550        // paste shape). Pinned separately so a future diagnostic-
7551        // surface change that only checked the whitespace-leading
7552        // shape surfaces here — the per-byte arm fires anywhere
7553        // `=` appears in the value.
7554        let d = dep_with_fonte(DepSource::Git {
7555            repo: "url=https://github.com/pleme-io/caixa-feira".into(),
7556            tag: Some("v0.1.0".into()),
7557            rev: None,
7558            branch: None,
7559        });
7560        let err = d.validate().unwrap_err();
7561        let DepError::FonteRepoShape { reason, .. } = err else {
7562            panic!("expected FonteRepoShape, got other variant");
7563        };
7564        assert!(
7565            reason.contains("must not contain `=`"),
7566            "reason must surface the equals-`=` arm on the `url=…` gitconfig \
7567             paste shape, got {reason:?}"
7568        );
7569        assert!(
7570            reason.contains("key-value-separator") || reason.contains("sub-delims"),
7571            "reason must name the key-value-separator / RFC-3986-sub-delims \
7572             rationale, got {reason:?}"
7573        );
7574    }
7575
7576    #[test]
7577    fn fonte_repo_fragment_fires_before_equals_when_fragment_first() {
7578        // Cascade pin: the fragment-`#` arm and the `=` arm are
7579        // both per-byte arms inside the same `for &b in s.as_bytes()`
7580        // loop, so the byte that appears first in the value's byte
7581        // order wins. A `:repo "https://github.com/p/x#readme=tail"`
7582        // carries both `#` and `=`; the `#` byte appears first, so
7583        // the fragment-`#` arm fires, surfacing the more self-
7584        // locating diagnostic on the byte the author pasted earliest
7585        // in the URL.
7586        let d = dep_with_fonte(DepSource::Git {
7587            repo: "https://github.com/pleme-io/caixa-teia#readme=tail".into(),
7588            tag: Some("v0.1.0".into()),
7589            rev: None,
7590            branch: None,
7591        });
7592        let err = d.validate().unwrap_err();
7593        let DepError::FonteRepoShape { reason, .. } = err else {
7594            panic!("expected FonteRepoShape, got other variant");
7595        };
7596        assert!(
7597            reason.contains("must not contain `#`"),
7598            "reason must surface the fragment-`#` arm (fires before equals when \
7599             `#` byte appears first in value), got {reason:?}"
7600        );
7601    }
7602
7603    #[test]
7604    fn fonte_repo_comma_fires_before_equals_when_comma_first() {
7605        // Cascade pin: the comma-`,` arm (the immediate-predecessor
7606        // byte-class arm, 775b80e) and the `=` arm are both per-byte
7607        // arms inside the same `for &b in s.as_bytes()` loop, so
7608        // the byte that appears first in the value's byte order
7609        // wins. A `:repo "github:p/x,mid=tail"` carries both `,`
7610        // and `=`; the `,` byte appears first, so the comma arm
7611        // fires, surfacing the more self-locating diagnostic on
7612        // the byte the author pasted earliest in the URL. Pins the
7613        // natural-order cascade so a future reorder of the per-byte
7614        // arms surfaces here — `=` is the most recent byte-class
7615        // arm, so the cascade-pin sweep extends to cover the
7616        // immediately prior `,` byte arm firing first when ordered
7617        // ahead of `=` in the value.
7618        let d = dep_with_fonte(DepSource::Git {
7619            repo: "github:pleme-io/caixa-teia,mid=tail".into(),
7620            tag: Some("v0.1.0".into()),
7621            rev: None,
7622            branch: None,
7623        });
7624        let err = d.validate().unwrap_err();
7625        let DepError::FonteRepoShape { reason, .. } = err else {
7626            panic!("expected FonteRepoShape, got other variant");
7627        };
7628        assert!(
7629            reason.contains("must not contain `,`"),
7630            "reason must surface the comma arm (fires before equals when `,` byte \
7631             appears first in value), got {reason:?}"
7632        );
7633    }
7634
7635    #[test]
7636    fn validate_rejects_git_fonte_with_repo_carrying_percent_encoded_space() {
7637        // The fail-before-pass-after pin for the canonical paste-from-
7638        // browser-address-bar percent-encoded-space footgun on `:repo`.
7639        // An author copies `https://github.com/p/x%20test` from a
7640        // browser address bar (or a percent-encoded README hyperlink,
7641        // or a `curl --data-urlencode` shell-pipeline output)
7642        // intending `%20` as the URL encoding of a literal space; the
7643        // typed `:repo` slot already rejects the literal space byte
7644        // (the whitespace arm at the top of `is_git_repo_url`), so an
7645        // author trying to express "I really meant a space" reaches
7646        // for percent-encoding. Until this arm landed the `%` byte
7647        // silently passed every prior `is_git_repo_url` arm and rode
7648        // verbatim into the lacre's per-dep content-address — but
7649        // libcurl re-percent-encodes `%` to `%25` on the wire (since
7650        // `%` is reserved as the escape-sequence lead-in), so the
7651        // wire request becomes `https://github.com/p/x%2520test`, a
7652        // path the lacre's content-address never names. The classic
7653        // render-determinism violation on the encoding-mechanism axis
7654        // itself.
7655        let d = dep_with_fonte(DepSource::Git {
7656            repo: "https://github.com/pleme-io/caixa-teia%20test".into(),
7657            tag: Some("v0.1.0".into()),
7658            rev: None,
7659            branch: None,
7660        });
7661        let err = d.validate().unwrap_err();
7662        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7663            panic!("expected FonteRepoShape, got other variant");
7664        };
7665        assert_eq!(nome, "caixa-teia");
7666        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia%20test");
7667        assert!(
7668            reason.contains("must not contain `%`"),
7669            "reason must surface the percent-`%` arm on the percent-encoded-space \
7670             paste shape, got {reason:?}"
7671        );
7672        assert!(
7673            reason.contains("percent-encoding") || reason.contains("%25"),
7674            "reason must name the percent-encoding / `%25` re-encoding rationale, \
7675             got {reason:?}"
7676        );
7677    }
7678
7679    #[test]
7680    fn validate_rejects_git_fonte_with_repo_carrying_percent_encoded_slash() {
7681        // The symmetric over-encoded-path-separator pin: an author
7682        // writes `:repo "https://github.com/p%2Fx"` intending the
7683        // `%2F` as the URL encoding of `/` (the canonical
7684        // paste-from-OpenAPI-spec / paste-from-percent-encoded-template
7685        // footgun every API client library and OAuth redirect-URI
7686        // documentation surfaces — the `/` is the URL-path-separator
7687        // and some templates percent-encode it to escape interpretation
7688        // as a path separator). The GitHub Smart-HTTP transport
7689        // resolves the URL's path-segment grammar before the
7690        // percent-decoding pass, so the value identifies a different
7691        // resource on the wire than the literal-`/` form the lacre's
7692        // content-address must agree with — two authors whose `:repo`
7693        // values differ only in their `/` vs `%2F` presence lock to
7694        // two distinct BLAKE3 closures for the byte-identical upstream
7695        // `git clone`. Pinned separately so a future diagnostic
7696        // surface that only catches the `%20` shape surfaces here too.
7697        let d = dep_with_fonte(DepSource::Git {
7698            repo: "https://github.com/pleme-io%2Fcaixa-teia".into(),
7699            tag: Some("v0.1.0".into()),
7700            rev: None,
7701            branch: None,
7702        });
7703        let err = d.validate().unwrap_err();
7704        let DepError::FonteRepoShape { reason, .. } = err else {
7705            panic!("expected FonteRepoShape, got other variant");
7706        };
7707        assert!(
7708            reason.contains("must not contain `%`"),
7709            "reason must surface the percent-`%` arm on the over-encoded-path \
7710             shape, got {reason:?}"
7711        );
7712        assert!(
7713            reason.contains("render-determinism") || reason.contains("BLAKE3"),
7714            "reason must name the render-determinism / BLAKE3-closure rationale, \
7715             got {reason:?}"
7716        );
7717    }
7718
7719    #[test]
7720    fn fonte_repo_fragment_fires_before_percent_when_fragment_first() {
7721        // Cascade pin: the fragment-`#` arm and the `%` arm are both
7722        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
7723        // so the byte that appears first in the value's byte order
7724        // wins. A `:repo "https://github.com/p/x#sec%20tail"` carries
7725        // both `#` and `%`; the `#` byte appears first, so the
7726        // fragment-`#` arm fires, surfacing the more self-locating
7727        // diagnostic on the byte the author pasted earliest in the URL.
7728        let d = dep_with_fonte(DepSource::Git {
7729            repo: "https://github.com/pleme-io/caixa-teia#sec%20tail".into(),
7730            tag: Some("v0.1.0".into()),
7731            rev: None,
7732            branch: None,
7733        });
7734        let err = d.validate().unwrap_err();
7735        let DepError::FonteRepoShape { reason, .. } = err else {
7736            panic!("expected FonteRepoShape, got other variant");
7737        };
7738        assert!(
7739            reason.contains("must not contain `#`"),
7740            "reason must surface the fragment-`#` arm (fires before percent when \
7741             `#` byte appears first in value), got {reason:?}"
7742        );
7743    }
7744
7745    #[test]
7746    fn fonte_repo_equals_fires_before_percent_when_equals_first() {
7747        // Cascade pin: the equals-`=` arm (the immediate-predecessor
7748        // byte-class arm, acf99af) and the `%` arm are both per-byte
7749        // arms inside the same `for &b in s.as_bytes()` loop, so the
7750        // byte that appears first in the value's byte order wins.
7751        // A `:repo "github:p/x=mid%20tail"` carries both `=` and `%`;
7752        // the `=` byte appears first, so the equals arm fires,
7753        // surfacing the more self-locating diagnostic on the byte the
7754        // author pasted earliest in the URL. Pins the natural-order
7755        // cascade so a future reorder of the per-byte arms surfaces
7756        // here — `%` is the most recent byte-class arm, so the
7757        // cascade-pin sweep extends to cover the immediately prior
7758        // `=` byte arm firing first when ordered ahead of `%` in the
7759        // value.
7760        let d = dep_with_fonte(DepSource::Git {
7761            repo: "github:pleme-io/caixa-teia=mid%20tail".into(),
7762            tag: Some("v0.1.0".into()),
7763            rev: None,
7764            branch: None,
7765        });
7766        let err = d.validate().unwrap_err();
7767        let DepError::FonteRepoShape { reason, .. } = err else {
7768            panic!("expected FonteRepoShape, got other variant");
7769        };
7770        assert!(
7771            reason.contains("must not contain `=`"),
7772            "reason must surface the equals arm (fires before percent when `=` byte \
7773             appears first in value), got {reason:?}"
7774        );
7775    }
7776
7777    #[test]
7778    fn validate_rejects_git_fonte_with_repo_carrying_caret_history_substitution() {
7779        // The fail-before-pass-after pin for the canonical paste-from-
7780        // shell-history footgun on `:repo`. An author copies a
7781        // `git clone <url>` line from their terminal followed by a
7782        // bash / ksh / zsh `^typo^fix^` quick-edit-and-rerun shell-
7783        // history shorthand (the `^old^new^` form re-runs the prior
7784        // history entry with the first `old` substituted by `new`,
7785        // bash's default behavior on interactive sessions with
7786        // `set -o histexpand`), forgetting to trim the trailing
7787        // `^...^...` shell-history fragment from the URL value. The
7788        // `^` byte sits in the RFC 3986 §2 'unwise' set (peer with
7789        // `{`, `}`, `|`, `\\` — the strictest of the §2 reserved
7790        // classes), the WHATWG URL spec's 'fragment percent-encode
7791        // set' maps `^` → `%5E` on the wire, so the byte rides
7792        // verbatim into the lacre's per-dep content-address but
7793        // libcurl re-encodes it to `%5E` at `git clone` time — the
7794        // classic render-determinism violation on the same axis the
7795        // peer `%`, `=`, `,`, `!`, `'`, `"`, `(`, `)`, `*`, `$`,
7796        // `&`, `;`, `|`, backtick, `<`, `>`, `{`, `}`, `\\`, `?`,
7797        // `#` arms close.
7798        let d = dep_with_fonte(DepSource::Git {
7799            repo: "https://github.com/pleme-io/caixa-teia^typo^fix".into(),
7800            tag: Some("v0.1.0".into()),
7801            rev: None,
7802            branch: None,
7803        });
7804        let err = d.validate().unwrap_err();
7805        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7806            panic!("expected FonteRepoShape, got other variant");
7807        };
7808        assert_eq!(nome, "caixa-teia");
7809        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia^typo^fix");
7810        assert!(
7811            reason.contains("must not contain `^`"),
7812            "reason must surface the caret-`^` arm on the paste-from-shell-history \
7813             shape, got {reason:?}"
7814        );
7815        assert!(
7816            reason.contains("history-substitution") || reason.contains("%5E"),
7817            "reason must name the shell-history-substitution / `%5E` wire-encoding \
7818             rationale, got {reason:?}"
7819        );
7820    }
7821
7822    #[test]
7823    fn validate_rejects_git_fonte_with_repo_carrying_caret_regex_anchor() {
7824        // The symmetric paste-from-doc-grep-pipeline footgun: an
7825        // author writes `:repo "github:p/^archived"` after copying a
7826        // `grep '^archived'` regex-anchor / negation idiom from a
7827        // doc / README quick-listing snippet, expecting the substrate
7828        // to coerce it to a literal repo name. The byte rides
7829        // verbatim into the lacre's per-dep content-address and
7830        // diverges from the byte-identical literal `archived` form
7831        // every other author authored — the canonical render-
7832        // determinism violation pin on the second footgun shape the
7833        // caret-`^` arm closes.
7834        let d = dep_with_fonte(DepSource::Git {
7835            repo: "github:pleme-io/^archived".into(),
7836            tag: Some("v0.1.0".into()),
7837            rev: None,
7838            branch: None,
7839        });
7840        let err = d.validate().unwrap_err();
7841        let DepError::FonteRepoShape { reason, .. } = err else {
7842            panic!("expected FonteRepoShape, got other variant");
7843        };
7844        assert!(
7845            reason.contains("must not contain `^`"),
7846            "reason must surface the caret-`^` arm on the regex-anchor shape, \
7847             got {reason:?}"
7848        );
7849        assert!(
7850            reason.contains("render-determinism") || reason.contains("BLAKE3"),
7851            "reason must name the render-determinism / BLAKE3-closure rationale, \
7852             got {reason:?}"
7853        );
7854    }
7855
7856    #[test]
7857    fn fonte_repo_percent_fires_before_caret_when_percent_first() {
7858        // Cascade pin: the `%` arm (the immediate-predecessor byte-
7859        // class arm, a323db8) and the `^` arm are both per-byte arms
7860        // inside the same `for &b in s.as_bytes()` loop, so the byte
7861        // that appears first in the value's byte order wins. A
7862        // `:repo "https://github.com/p/x%20mid^tail"` carries both
7863        // `%` and `^`; the `%` byte appears first, so the percent
7864        // arm fires, surfacing the more self-locating diagnostic on
7865        // the byte the author pasted earliest in the URL. Pins the
7866        // natural-order cascade so a future reorder of the per-byte
7867        // arms surfaces here — `^` is the most recent byte-class arm,
7868        // so the cascade-pin sweep extends to cover the immediately
7869        // prior `%` byte arm firing first when ordered ahead of `^`
7870        // in the value.
7871        let d = dep_with_fonte(DepSource::Git {
7872            repo: "https://github.com/pleme-io/caixa-teia%20mid^tail".into(),
7873            tag: Some("v0.1.0".into()),
7874            rev: None,
7875            branch: None,
7876        });
7877        let err = d.validate().unwrap_err();
7878        let DepError::FonteRepoShape { reason, .. } = err else {
7879            panic!("expected FonteRepoShape, got other variant");
7880        };
7881        assert!(
7882            reason.contains("must not contain `%`"),
7883            "reason must surface the percent arm (fires before caret when `%` byte \
7884             appears first in value), got {reason:?}"
7885        );
7886    }
7887
7888    #[test]
7889    fn validate_rejects_git_fonte_with_repo_missing_colon_separator() {
7890        // The "I dropped the scheme" footgun — `:repo "pleme-io/caixa-teia"`
7891        // (no `github:` prefix, no scheme). Every documented form
7892        // carries a `:` (`github:`, `https://`, `ssh://`, `git://`,
7893        // `file://`, or `git@host:path`); a bare `org/repo` is
7894        // ambiguous (`git clone` reads as a relative filesystem path
7895        // rather than the GitHub-shorthand expansion the author
7896        // probably intended) and the gate rejects the shape upstream.
7897        let d = dep_with_fonte(DepSource::Git {
7898            repo: "pleme-io/caixa-teia".into(),
7899            tag: Some("v0.1.0".into()),
7900            rev: None,
7901            branch: None,
7902        });
7903        let err = d.validate().unwrap_err();
7904        let DepError::FonteRepoShape { reason, .. } = err else {
7905            panic!("expected FonteRepoShape, got other variant");
7906        };
7907        assert!(
7908            reason.contains("must contain a `:`"),
7909            "reason must surface the missing-`:` arm, got {reason:?}"
7910        );
7911        assert!(
7912            reason.contains("github:"),
7913            "reason must name the canonical `github:` shorthand prefix, got {reason:?}"
7914        );
7915    }
7916
7917    #[test]
7918    fn validate_rejects_git_fonte_with_repo_leading_colon() {
7919        // The "empty scheme" footgun — `:repo ":foo"` has a zero-length
7920        // scheme that no git porcelain entry-point accepts. Pinned
7921        // separately from the missing-`:` arm because a value with a
7922        // leading `:` does technically contain a `:` separator; the
7923        // shape gate rejects on a dedicated arm so the diagnostic
7924        // names the specific footgun.
7925        let d = dep_with_fonte(DepSource::Git {
7926            repo: ":pleme-io/caixa-teia".into(),
7927            tag: Some("v0.1.0".into()),
7928            rev: None,
7929            branch: None,
7930        });
7931        let err = d.validate().unwrap_err();
7932        let DepError::FonteRepoShape { reason, .. } = err else {
7933            panic!("expected FonteRepoShape, got other variant");
7934        };
7935        assert!(
7936            reason.contains("must not start with `:`"),
7937            "reason must surface the leading-`:` arm, got {reason:?}"
7938        );
7939    }
7940
7941    #[test]
7942    fn validate_rejects_git_fonte_with_repo_too_long() {
7943        // The cap arm — a `:repo` value longer than
7944        // [`crate::render::GIT_REPO_URL_MAX_LEN`] (2048) bytes is
7945        // structurally untenable on every realistic landing site (the
7946        // resolver's `git clone` invocation, the future M4 CR
7947        // materializer's per-dep `repo:` axis); a value of that length
7948        // is almost certainly a paste-from-binary slug.
7949        let too_long = format!(
7950            "github:pleme-io/{}",
7951            "x".repeat(crate::render::GIT_REPO_URL_MAX_LEN)
7952        );
7953        let d = dep_with_fonte(DepSource::Git {
7954            repo: too_long.clone(),
7955            tag: Some("v0.1.0".into()),
7956            rev: None,
7957            branch: None,
7958        });
7959        let err = d.validate().unwrap_err();
7960        let DepError::FonteRepoShape { reason, .. } = err else {
7961            panic!("expected FonteRepoShape, got other variant");
7962        };
7963        assert!(
7964            reason.contains("2048"),
7965            "reason must name the cap, got {reason:?}"
7966        );
7967    }
7968
7969    #[test]
7970    fn validate_accepts_canonical_git_fonte_repo_shapes() {
7971        // The positive-control sweep: every documented author shape on
7972        // the `:fonte :repo` axis ([`crate::DepSource::Git`] doc comment)
7973        // must pass the value-shape gate. Pinned so a future tightening
7974        // (e.g. forbidding `http://` in favor of `https://`-only) surfaces
7975        // here as a structural decision. Each form is exercised with the
7976        // same canonical `:tag` pin so only the `:repo` axis varies.
7977        for repo in [
7978            // The pleme-io registry-shorthand convention — `github:org/repo`.
7979            "github:pleme-io/caixa-teia",
7980            // Other host-aliased shorthands (the resolver's pluggable
7981            // host-prefix table).
7982            "gitlab:pleme-io/caixa-teia",
7983            "codeberg:pleme-io/caixa-teia",
7984            "sourcehut:~pleme-io/caixa-teia",
7985            // Full HTTPS URL with and without `.git` suffix.
7986            "https://github.com/pleme-io/caixa-teia",
7987            "https://github.com/pleme-io/caixa-teia.git",
7988            // HTTP (rare; dev / mirror).
7989            "http://example.com/pleme-io/caixa-teia.git",
7990            // SSH URL.
7991            "ssh://git@github.com/pleme-io/caixa-teia.git",
7992            "ssh://git@git.example.com:2222/pleme-io/caixa-teia.git",
7993            // Scp-style SSH — the canonical `git@host:path` short form.
7994            "git@github.com:pleme-io/caixa-teia.git",
7995            "git@git.example.com:team/private.git",
7996            // Anonymous git protocol.
7997            "git://git.example.com/pleme-io/caixa-teia.git",
7998            // Local file URL (dev path).
7999            "file:///tmp/caixa-teia",
8000        ] {
8001            let d = dep_with_fonte(DepSource::Git {
8002                repo: repo.into(),
8003                tag: Some("v0.1.0".into()),
8004                rev: None,
8005                branch: None,
8006            });
8007            d.validate()
8008                .unwrap_or_else(|e| panic!("canonical repo {repo:?} must validate, got {e:?}"));
8009        }
8010    }
8011
8012    #[test]
8013    fn fonte_repo_empty_takes_precedence_over_shape() {
8014        // Order pin: the existing `FonteRepoEmpty` diagnostic (narrower
8015        // diagnostic; doesn't try to parse the URL shape) fires before
8016        // the new `FonteRepoShape` per-axis gate, so an empty `:repo`
8017        // keeps its narrower error message. Mirrors
8018        // `fonte_repo_empty_fires_before_pin_missing` (already pinned)
8019        // on the ordering layer.
8020        let d = dep_with_fonte(DepSource::Git {
8021            repo: String::new(),
8022            tag: Some("v0.1.0".into()),
8023            rev: None,
8024            branch: None,
8025        });
8026        let err = d.validate().unwrap_err();
8027        assert!(
8028            matches!(err, DepError::FonteRepoEmpty { .. }),
8029            "got {err:?}"
8030        );
8031    }
8032
8033    #[test]
8034    fn fonte_repo_shape_fires_before_pin_missing() {
8035        // Order pin: a malformed `:repo` value on a dep with no pin set
8036        // surfaces the `:repo` shape diagnostic (the more self-locating
8037        // axis — the `:repo` is the load-bearing identity of the source;
8038        // a missing pin is downstream from "do we even know the repo")
8039        // rather than collapsing onto the pin-missing diagnostic. The
8040        // shape gate runs inline before the pin enumeration in
8041        // `DepSource::validate`.
8042        let d = dep_with_fonte(DepSource::Git {
8043            repo: "pleme-io/caixa-teia".into(), // missing `:` separator
8044            tag: None,
8045            rev: None,
8046            branch: None,
8047        });
8048        let err = d.validate().unwrap_err();
8049        assert!(
8050            matches!(err, DepError::FonteRepoShape { .. }),
8051            "got {err:?}"
8052        );
8053    }
8054
8055    #[test]
8056    fn fonte_repo_shape_diagnostic_carries_offending_repo_verbatim() {
8057        // The diagnostic-shape pin: the error names the offending
8058        // `:repo` value verbatim plus a non-empty parser-shaped `reason`
8059        // so the author can grep their caixa.lisp without re-running
8060        // the build. Mirrors the diagnostic-shape sweep on every prior
8061        // value-shape gate (3f9d7a0, 6cbb900, c7d05ec, e70d213, be07fd5).
8062        let d = dep_with_fonte(DepSource::Git {
8063            repo: "pleme-io/caixa-teia".into(),
8064            tag: Some("v0.1.0".into()),
8065            rev: None,
8066            branch: None,
8067        });
8068        let err = d.validate().unwrap_err();
8069        let DepError::FonteRepoShape { nome, repo, reason } = err else {
8070            panic!("expected FonteRepoShape, got other variant");
8071        };
8072        assert_eq!(nome, "caixa-teia");
8073        assert_eq!(repo, "pleme-io/caixa-teia");
8074        assert!(
8075            !reason.is_empty(),
8076            "FonteRepoShape `reason` must carry the predicate's wording verbatim"
8077        );
8078    }
8079
8080    #[test]
8081    fn validate_rejects_git_fonte_with_no_pin() {
8082        // The fail-before-pass-after pin for the canonical
8083        // `(:tipo git :repo "github:pleme-io/x")` shape with no
8084        // :tag/:rev/:branch — until this gate landed the resolver's
8085        // ResolveError::MissingPin surfaced at fetch time, far from the
8086        // source caixa.lisp. The new gate moves the check to validate
8087        // time and names the offending dep.
8088        let d = dep_with_fonte(DepSource::Git {
8089            repo: "github:pleme-io/caixa-teia".into(),
8090            tag: None,
8091            rev: None,
8092            branch: None,
8093        });
8094        let err = d.validate().unwrap_err();
8095        assert!(
8096            matches!(err, DepError::FontePinMissing { ref nome } if nome == "caixa-teia"),
8097            "got {err:?}"
8098        );
8099    }
8100
8101    #[test]
8102    fn validate_rejects_git_fonte_with_ambiguous_tag_and_branch() {
8103        // The canonical "pin drift" footgun: an author writes
8104        // `:tag "v1"` and later adds `:branch "main"` without removing
8105        // the :tag, and the resolver silently picks :tag (precedence
8106        // :rev > :tag > :branch). The :branch was dropped with no
8107        // diagnostic. The gate now rejects multi-pin shapes so the
8108        // author makes the precedence explicit at the source.
8109        let d = dep_with_fonte(DepSource::Git {
8110            repo: "github:pleme-io/caixa-teia".into(),
8111            tag: Some("v0.1.0".into()),
8112            rev: None,
8113            branch: Some("main".into()),
8114        });
8115        let err = d.validate().unwrap_err();
8116        let DepError::FontePinAmbiguous { nome, pins } = err else {
8117            panic!("expected FontePinAmbiguous");
8118        };
8119        assert_eq!(nome, "caixa-teia");
8120        assert!(pins.contains(":tag"));
8121        assert!(pins.contains(":branch"));
8122        assert!(!pins.contains(":rev"));
8123    }
8124
8125    #[test]
8126    fn validate_rejects_git_fonte_with_ambiguous_tag_and_rev() {
8127        // Sibling arm of the pin-drift footgun: :tag + :rev set
8128        // simultaneously. Pinned separately so a future relaxation
8129        // that only catches the (:tag, :branch) pair surfaces here.
8130        let d = dep_with_fonte(DepSource::Git {
8131            repo: "github:pleme-io/caixa-teia".into(),
8132            tag: Some("v0.1.0".into()),
8133            rev: Some("c0ffee".into()),
8134            branch: None,
8135        });
8136        let err = d.validate().unwrap_err();
8137        let DepError::FontePinAmbiguous { nome, pins } = err else {
8138            panic!("expected FontePinAmbiguous");
8139        };
8140        assert_eq!(nome, "caixa-teia");
8141        assert!(pins.contains(":tag"));
8142        assert!(pins.contains(":rev"));
8143    }
8144
8145    #[test]
8146    fn validate_rejects_git_fonte_with_all_three_pins() {
8147        // The maximal ambiguity case — every pin axis set. Pinned so a
8148        // future relaxation that only catches pairs surfaces here. The
8149        // diagnostic must enumerate every offending axis so the author
8150        // sees the full set, not just the first match.
8151        let d = dep_with_fonte(DepSource::Git {
8152            repo: "github:pleme-io/caixa-teia".into(),
8153            tag: Some("v0.1.0".into()),
8154            rev: Some("c0ffee".into()),
8155            branch: Some("main".into()),
8156        });
8157        let err = d.validate().unwrap_err();
8158        let DepError::FontePinAmbiguous { nome, pins } = err else {
8159            panic!("expected FontePinAmbiguous");
8160        };
8161        assert_eq!(nome, "caixa-teia");
8162        assert!(pins.contains(":tag"));
8163        assert!(pins.contains(":rev"));
8164        assert!(pins.contains(":branch"));
8165    }
8166
8167    #[test]
8168    fn validate_rejects_git_fonte_with_empty_tag_pin() {
8169        // The empty-pin arm: exactly one pin axis is `Some(_)`, but its
8170        // inner string is empty. Distinct from FontePinMissing (where
8171        // every axis is None) — pinned separately so a future
8172        // tightening collapsing them surfaces here as a structural
8173        // decision.
8174        let d = dep_with_fonte(DepSource::Git {
8175            repo: "github:pleme-io/caixa-teia".into(),
8176            tag: Some(String::new()),
8177            rev: None,
8178            branch: None,
8179        });
8180        let err = d.validate().unwrap_err();
8181        let DepError::FontePinEmpty { nome, pin } = err else {
8182            panic!("expected FontePinEmpty");
8183        };
8184        assert_eq!(nome, "caixa-teia");
8185        assert_eq!(pin, ":tag");
8186    }
8187
8188    #[test]
8189    fn validate_rejects_git_fonte_with_empty_rev_pin() {
8190        // Sibling arm — the empty-pin diagnostic names which axis
8191        // carries the empty value, so the author's grep target is
8192        // unambiguous.
8193        let d = dep_with_fonte(DepSource::Git {
8194            repo: "github:pleme-io/caixa-teia".into(),
8195            tag: None,
8196            rev: Some(String::new()),
8197            branch: None,
8198        });
8199        let err = d.validate().unwrap_err();
8200        let DepError::FontePinEmpty { nome, pin } = err else {
8201            panic!("expected FontePinEmpty");
8202        };
8203        assert_eq!(nome, "caixa-teia");
8204        assert_eq!(pin, ":rev");
8205    }
8206
8207    #[test]
8208    fn validate_rejects_path_fonte_with_empty_caminho() {
8209        // The fail-before-pass-after pin for `(:tipo path :caminho "")`:
8210        // until this gate landed the resolver's
8211        // ResolveError::MissingPath surfaced with `path: PathBuf("")` at
8212        // fetch time — not actionable. The new gate moves the check to
8213        // validate time and names the offending dep.
8214        let d = dep_with_fonte(DepSource::Path {
8215            caminho: String::new(),
8216        });
8217        let err = d.validate().unwrap_err();
8218        assert!(
8219            matches!(err, DepError::FonteCaminhoEmpty { ref nome } if nome == "caixa-teia"),
8220            "got {err:?}"
8221        );
8222    }
8223
8224    #[test]
8225    fn validate_rejects_path_fonte_with_absolute_caminho() {
8226        // The fail-before-pass-after pin for the absolute-`:caminho`
8227        // shape: `(:tipo path :caminho "/home/me/work/caixa-teia")`.
8228        // Until this gate landed an absolute `:caminho` silently
8229        // passed validate; the lacre pipeline embedded the
8230        // host-specific filesystem path verbatim in its
8231        // content-address (`conteudo: format!("path:{caminho}")`,
8232        // caixa-resolver/src/resolve.rs:189), so the BLAKE3 closure
8233        // differed per machine — the build succeeded but two CI
8234        // runners with different `${HOME}` layouts emitted two
8235        // distinct lacres for the byte-identical caixa, silently
8236        // breaking the THEORY.md §V.2 render-determinism contract
8237        // far from the source caixa.lisp. The new gate moves the
8238        // check to validate time and names the offending dep +
8239        // caminho verbatim.
8240        let d = dep_with_fonte(DepSource::Path {
8241            caminho: "/home/me/work/caixa-teia".into(),
8242        });
8243        let err = d.validate().unwrap_err();
8244        let DepError::FonteCaminhoAbsolute { nome, caminho } = err else {
8245            panic!("expected FonteCaminhoAbsolute, got other variant");
8246        };
8247        assert_eq!(nome, "caixa-teia");
8248        assert_eq!(caminho, "/home/me/work/caixa-teia");
8249    }
8250
8251    #[test]
8252    fn validate_accepts_path_fonte_with_parent_escape_caminho() {
8253        // The canonical sibling-workspace dep form
8254        // (`:caminho "../caixa-teia"`) remains accepted. The
8255        // absolute-path gate above is specifically narrower than the
8256        // shared [`crate::render::is_sandboxed_relative_path`]
8257        // predicate (which additionally forbids `..` traversal): a
8258        // local-path dep's canonical author surface is the in-tree
8259        // sibling-workspace path, so a full sandboxed-relative-path
8260        // lift would structurally reject every legitimate path-fonte
8261        // dep. Pinned so a future tightening to the full predicate
8262        // surfaces here as a structural decision, not a silent break.
8263        let d = dep_with_fonte(DepSource::Path {
8264            caminho: "../caixa-teia".into(),
8265        });
8266        d.validate().unwrap();
8267    }
8268
8269    #[test]
8270    fn validate_accepts_path_fonte_with_deeply_nested_relative_caminho() {
8271        // A multi-segment relative `:caminho`
8272        // (`"vendor/forks/caixa-teia"`) remains accepted — the
8273        // absolute-path gate brackets the host-layout-leaking shape
8274        // at the leading-`/` boundary only; every relative shape past
8275        // the empty arm continues to pass. Pinned alongside the
8276        // `..`-traversal positive control so a future tightening
8277        // surfaces the full set of legitimate relative forms here
8278        // rather than at a downstream consumer.
8279        let d = dep_with_fonte(DepSource::Path {
8280            caminho: "vendor/forks/caixa-teia".into(),
8281        });
8282        d.validate().unwrap();
8283    }
8284
8285    #[test]
8286    fn validate_rejects_path_fonte_with_tilde_prefix_caminho() {
8287        // The fail-before-pass-after pin for the tilde-expansion
8288        // `:caminho` shape: `(:tipo path :caminho "~/work/caixa-teia")`.
8289        // Until this gate landed the b94fd83 absolute arm let `~/foo`
8290        // through (`Path::is_absolute` returns false on a leading `~`
8291        // — the tilde is a shell-expansion convention, not a POSIX
8292        // path component), so the lacre embedded the value verbatim
8293        // and the resolver folded it through `Path::join` without
8294        // expansion, looking for a literal `./~/work/caixa-teia`
8295        // subdirectory and failing at resolve time with a
8296        // `No such file or directory` error far from the source
8297        // caixa.lisp. The new gate moves the check to validate time
8298        // and names the offending dep + caminho verbatim.
8299        let d = dep_with_fonte(DepSource::Path {
8300            caminho: "~/work/caixa-teia".into(),
8301        });
8302        let err = d.validate().unwrap_err();
8303        let DepError::FonteCaminhoTildeExpansion { nome, caminho } = err else {
8304            panic!("expected FonteCaminhoTildeExpansion, got {err:?}");
8305        };
8306        assert_eq!(nome, "caixa-teia");
8307        assert_eq!(caminho, "~/work/caixa-teia");
8308    }
8309
8310    #[test]
8311    fn validate_rejects_path_fonte_with_bare_tilde_caminho() {
8312        // The bare `~` form (canonical "I meant `$HOME` and forgot
8313        // the rest"): both the leading-tilde arm catches it and the
8314        // canonical-user-tilde shell idiom (`~alice/dev/caixa-teia`)
8315        // sweeps through the same arm. Pinned both to ensure the
8316        // gate doesn't narrow to `~/` only.
8317        for s in ["~", "~alice/dev/caixa-teia", "~/", "~root/work"] {
8318            let d = dep_with_fonte(DepSource::Path { caminho: s.into() });
8319            let err = d.validate().unwrap_err();
8320            assert!(
8321                matches!(err, DepError::FonteCaminhoTildeExpansion { .. }),
8322                "{s:?} → {err:?}",
8323            );
8324        }
8325    }
8326
8327    #[test]
8328    fn validate_accepts_path_fonte_with_mid_path_tilde_caminho() {
8329        // The leading-`~` is the canonical shell-expansion footgun —
8330        // a tilde mid-path (`"../foo~bar/caixa-teia"` — the canonical
8331        // backup-file-suffix idiom) is a legitimate POSIX path byte
8332        // with no shell-expansion semantic at the leading position.
8333        // Pinned so the gate doesn't widen to a full no-tilde-anywhere
8334        // sweep that would break every legitimate-shape backup-file
8335        // path.
8336        let d = dep_with_fonte(DepSource::Path {
8337            caminho: "../foo~bar/caixa-teia".into(),
8338        });
8339        d.validate().unwrap();
8340    }
8341
8342    #[test]
8343    fn fonte_caminho_empty_fires_before_tilde_expansion() {
8344        // Cascade pin: the empty arm structurally precedes the
8345        // tilde arm (the bytes `""` and `"~"` don't overlap), but the
8346        // pin establishes the precedence at the diagnostic-shape
8347        // level should a future codec round-trip ever produce a
8348        // probe-as-both value. Mirrors the peer
8349        // `fonte_repo_empty_fires_before_pin_missing` cascade
8350        // discipline.
8351        let d = dep_with_fonte(DepSource::Path {
8352            caminho: String::new(),
8353        });
8354        let err = d.validate().unwrap_err();
8355        assert!(
8356            matches!(err, DepError::FonteCaminhoEmpty { .. }),
8357            "got {err:?}",
8358        );
8359    }
8360
8361    #[test]
8362    fn fonte_caminho_tilde_diagnostic_carries_offending_dep_and_caminho() {
8363        // Diagnostic-shape pin (peer with
8364        // `validate_rejects_path_fonte_with_absolute_caminho`'s
8365        // payload assertion): the error's Display surfaces both the
8366        // offending `:nome` and the offending `:caminho` verbatim
8367        // so a `feira lint` run can render the diagnostic without
8368        // re-parsing.
8369        let d = dep_with_fonte(DepSource::Path {
8370            caminho: "~alice/dev/caixa-teia".into(),
8371        });
8372        let rendered = d.validate().unwrap_err().to_string();
8373        assert!(
8374            rendered.contains("caixa-teia"),
8375            "diagnostic must name the offending dep: {rendered}",
8376        );
8377        assert!(
8378            rendered.contains("~alice/dev/caixa-teia"),
8379            "diagnostic must quote the offending caminho: {rendered}",
8380        );
8381        assert!(
8382            rendered.contains('~'),
8383            "diagnostic must reference the tilde footgun: {rendered}",
8384        );
8385    }
8386
8387    #[test]
8388    fn validate_rejects_path_fonte_with_dollar_prefix_caminho() {
8389        // The fail-before-pass-after pin for the shell-variable-
8390        // expansion `:caminho` shape: `(:tipo path :caminho
8391        // "$HOME/work/caixa-teia")`. Until this gate landed the
8392        // b94fd83 absolute arm + the a5c248e tilde arm both let
8393        // `$HOME/foo` through (`Path::is_absolute` returns false on
8394        // a leading `$` — the `$` is a shell convention, not a POSIX
8395        // path component; `starts_with('~')` returns false too), so
8396        // the lacre embedded the value verbatim and the resolver
8397        // folded it through `Path::join` without `$`-expansion,
8398        // looking for a literal `./$HOME/work/caixa-teia`
8399        // subdirectory and failing at resolve time with a
8400        // `No such file or directory` error far from the source
8401        // caixa.lisp. The new gate moves the check to validate time
8402        // and names the offending dep + caminho verbatim.
8403        let d = dep_with_fonte(DepSource::Path {
8404            caminho: "$HOME/work/caixa-teia".into(),
8405        });
8406        let err = d.validate().unwrap_err();
8407        let DepError::FonteCaminhoVarExpansion { nome, caminho } = err else {
8408            panic!("expected FonteCaminhoVarExpansion, got {err:?}");
8409        };
8410        assert_eq!(nome, "caixa-teia");
8411        assert_eq!(caminho, "$HOME/work/caixa-teia");
8412    }
8413
8414    #[test]
8415    fn validate_rejects_path_fonte_with_dollar_brace_prefix_caminho() {
8416        // Sweep over every leading-`$` shape: the `${VAR}`-braced
8417        // form (canonical "paste-from-CI-manifest" footgun every
8418        // GitHub Actions / GitLab CI / Drone manifest carries on
8419        // `${WORKSPACE}`), the XDG idiom (`$XDG_CONFIG_HOME/caixa`,
8420        // canonical "I'm referencing a per-user config dir"),
8421        // and the bare `$` (canonical "I meant `$HOME` and forgot
8422        // the rest"). All shapes route through the same gate's
8423        // byte check. Pinned so the gate doesn't narrow to a
8424        // single shape (e.g. `$HOME/` only).
8425        for s in [
8426            "${HOME}/work/caixa-teia",
8427            "${WORKSPACE}/caixa-teia",
8428            "$XDG_CONFIG_HOME/caixa",
8429            "$",
8430        ] {
8431            let d = dep_with_fonte(DepSource::Path { caminho: s.into() });
8432            let err = d.validate().unwrap_err();
8433            assert!(
8434                matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
8435                "{s:?} → {err:?}",
8436            );
8437        }
8438    }
8439
8440    #[test]
8441    fn validate_rejects_path_fonte_with_mid_path_dollar_caminho() {
8442        // The `$` byte is the canonical shell-variable-expansion /
8443        // command-substitution / arithmetic-expansion sentinel and
8444        // is rejected at *every* position on the `:caminho` axis: the
8445        // leading arm surfaces `FonteCaminhoVarExpansion`, the
8446        // embedded arm surfaces `FonteCaminhoShellVariableExpansion`
8447        // (6620f39). Pinned so a future arm doesn't narrow the gate
8448        // back to the leading position and re-open the paste-from-
8449        // shell-one-liner `"../foo$HOME/bar"` / paste-from-CI-
8450        // manifest `"../foo${WORKSPACE}/bar"` / paste-from-shell-
8451        // prompt `"../foo$(whoami)/bar"` cross-idiom-leak surface on
8452        // the lacre content-address (`path:{caminho}`,
8453        // caixa-resolver/src/resolve.rs:189).
8454        let d = dep_with_fonte(DepSource::Path {
8455            caminho: "../foo$bar/caixa-teia".into(),
8456        });
8457        let err = d.validate().unwrap_err();
8458        assert!(
8459            matches!(
8460                err,
8461                DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
8462            ),
8463            "got {err:?}",
8464        );
8465    }
8466
8467    #[test]
8468    fn fonte_caminho_tilde_fires_before_var_expansion() {
8469        // Cascade pin: the tilde arm structurally precedes the var
8470        // arm (the bytes `~` and `$` don't overlap at the leading
8471        // position), but the pin establishes the precedence at the
8472        // diagnostic-shape level should a future codec round-trip
8473        // ever produce a probe-as-both value. Mirrors the peer
8474        // `fonte_caminho_empty_fires_before_tilde_expansion` cascade
8475        // discipline on the immediate-predecessor arm.
8476        let d = dep_with_fonte(DepSource::Path {
8477            caminho: "~/work/caixa-teia".into(),
8478        });
8479        let err = d.validate().unwrap_err();
8480        assert!(
8481            matches!(err, DepError::FonteCaminhoTildeExpansion { .. }),
8482            "got {err:?}",
8483        );
8484    }
8485
8486    #[test]
8487    fn fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho() {
8488        // Diagnostic-shape pin (peer with
8489        // `fonte_caminho_tilde_diagnostic_carries_offending_dep_and_caminho`'s
8490        // payload assertion on the immediate-predecessor arm): the
8491        // error's Display surfaces both the offending `:nome` and
8492        // the offending `:caminho` verbatim plus the `$` footgun
8493        // character itself so a `feira lint` run can render the
8494        // diagnostic without re-parsing.
8495        let d = dep_with_fonte(DepSource::Path {
8496            caminho: "${WORKSPACE}/caixa-teia".into(),
8497        });
8498        let rendered = d.validate().unwrap_err().to_string();
8499        assert!(
8500            rendered.contains("caixa-teia"),
8501            "diagnostic must name the offending dep: {rendered}",
8502        );
8503        assert!(
8504            rendered.contains("${WORKSPACE}/caixa-teia"),
8505            "diagnostic must quote the offending caminho: {rendered}",
8506        );
8507        assert!(
8508            rendered.contains('$'),
8509            "diagnostic must reference the dollar footgun: {rendered}",
8510        );
8511    }
8512
8513    #[test]
8514    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_nul() {
8515        // The fail-before-pass-after pin for the load-bearing NUL byte:
8516        // POSIX paths cannot contain `0x00` (every `std::fs` syscall
8517        // routes the path through `CString::new` which fails with
8518        // `NulError`); until this gate landed a `:caminho
8519        // "../caixa\0teia"` silently passed validate, the lacre
8520        // pipeline embedded the value verbatim, and the failure
8521        // surfaced at the resolver's `Path::join` → `CString::new`
8522        // boundary with a non-self-locating `NulError` far from the
8523        // source caixa.lisp. The new gate moves the check to validate
8524        // time and names the offending dep + caminho + offending byte
8525        // verbatim.
8526        let d = dep_with_fonte(DepSource::Path {
8527            caminho: "../caixa\0teia".into(),
8528        });
8529        let err = d.validate().unwrap_err();
8530        let DepError::FonteCaminhoControlChar {
8531            nome,
8532            caminho,
8533            byte,
8534        } = err
8535        else {
8536            panic!("expected FonteCaminhoControlChar, got {err:?}");
8537        };
8538        assert_eq!(nome, "caixa-teia");
8539        assert_eq!(caminho, "../caixa\0teia");
8540        assert_eq!(byte, 0x00);
8541    }
8542
8543    #[test]
8544    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_newline() {
8545        // The canonical paste-from-multiline-doc footgun on `:caminho`
8546        // — author copies `"../caixa-teia\n"` (trailing newline) out
8547        // of a multi-line code-fence or, worse, a `:caminho
8548        // "../caixa-teia\nrm -rf /"` value (CRLF-at-subprocess-argument
8549        // injection sibling on the path axis the `is_git_repo_url`
8550        // control-char arm already closes on `:repo`). Pinned
8551        // separately from the NUL arm so a future relaxation that
8552        // catches one but not the other surfaces here.
8553        let d = dep_with_fonte(DepSource::Path {
8554            caminho: "../caixa-teia\n".into(),
8555        });
8556        let err = d.validate().unwrap_err();
8557        let DepError::FonteCaminhoControlChar { byte, .. } = err else {
8558            panic!("expected FonteCaminhoControlChar, got {err:?}");
8559        };
8560        assert_eq!(byte, 0x0A);
8561    }
8562
8563    #[test]
8564    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_carriage_return() {
8565        // The CRLF sibling of the LF arm — Windows-line-ending
8566        // paste-from-multiline-doc on a `\r\n`-terminated buffer
8567        // leaves a stray `\r` mid-string after the LF strip. Pinned
8568        // separately from the LF arm so a future relaxation that
8569        // only catches LF surfaces here.
8570        let d = dep_with_fonte(DepSource::Path {
8571            caminho: "../caixa-teia\r".into(),
8572        });
8573        let err = d.validate().unwrap_err();
8574        let DepError::FonteCaminhoControlChar { byte, .. } = err else {
8575            panic!("expected FonteCaminhoControlChar, got {err:?}");
8576        };
8577        assert_eq!(byte, 0x0D);
8578    }
8579
8580    #[test]
8581    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_tab() {
8582        // The canonical paste-from-aligned-table footgun — a `\t`
8583        // mid-`:caminho` is invisible in most editors but rides
8584        // through the lacre's content-address verbatim, so two
8585        // paste-from-distinct-tables (one editor strips tabs, one
8586        // preserves them) yield divergent lacres for the byte-
8587        // identical-looking caixa. Pinned separately from the
8588        // whitespace-shaped LF/CR arms so a future relaxation that
8589        // narrows to line-terminator-only surfaces here.
8590        let d = dep_with_fonte(DepSource::Path {
8591            caminho: "../caixa\tteia".into(),
8592        });
8593        let err = d.validate().unwrap_err();
8594        let DepError::FonteCaminhoControlChar { byte, .. } = err else {
8595            panic!("expected FonteCaminhoControlChar, got {err:?}");
8596        };
8597        assert_eq!(byte, 0x09);
8598    }
8599
8600    #[test]
8601    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_del() {
8602        // The DEL byte (`0x7F`) closes the upper-end paste-from-
8603        // binary-blob footgun — the gate's contract is `b < 0x20 ||
8604        // b == 0x7F`, matching the `is_git_repo_url` /
8605        // `is_git_ref_name` predicates' control-char arms. Pinned
8606        // separately from the lower-range arms so a future narrowing
8607        // to `< 0x20` only surfaces here.
8608        let d = dep_with_fonte(DepSource::Path {
8609            caminho: "../caixa\x7fteia".into(),
8610        });
8611        let err = d.validate().unwrap_err();
8612        let DepError::FonteCaminhoControlChar { byte, .. } = err else {
8613            panic!("expected FonteCaminhoControlChar, got {err:?}");
8614        };
8615        assert_eq!(byte, 0x7F);
8616    }
8617
8618    #[test]
8619    fn validate_accepts_path_fonte_with_caminho_carrying_high_bit_utf8() {
8620        // The control-byte arm targets `0x00..=0x1F` + `0x7F` only —
8621        // high-bit / non-ASCII UTF-8 bytes are not gated. POSIX paths
8622        // are opaque byte sequences and UTF-8 multi-byte sequences
8623        // are a legitimate filename shape (the `café-teia/foo` idiom).
8624        // Pinned so the gate doesn't widen to a full ASCII-only sweep
8625        // that would break every legitimate-shape UTF-8 path.
8626        let d = dep_with_fonte(DepSource::Path {
8627            caminho: "../café-teia/foo".into(),
8628        });
8629        d.validate().unwrap();
8630    }
8631
8632    #[test]
8633    fn fonte_caminho_var_fires_before_control_char() {
8634        // Cascade pin: the var-expansion arm structurally precedes the
8635        // control-char arm. A value like `"$\n"` probes positive on
8636        // both arms (`starts_with('$')` and contains LF), but the
8637        // narrower leading-byte diagnostic (`FonteCaminhoVarExpansion`)
8638        // wins so the author sees the more self-locating shell-
8639        // expansion arm first. Mirrors the
8640        // `fonte_caminho_tilde_fires_before_var_expansion` cascade
8641        // discipline on the immediate-predecessor arm.
8642        let d = dep_with_fonte(DepSource::Path {
8643            caminho: "$HOME\n".into(),
8644        });
8645        let err = d.validate().unwrap_err();
8646        assert!(
8647            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
8648            "got {err:?}",
8649        );
8650    }
8651
8652    #[test]
8653    fn validate_rejects_path_fonte_with_leading_space_caminho() {
8654        // The fail-before-pass-after pin for the leading ASCII space
8655        // `:caminho` shape: `(:tipo path :caminho " ../caixa-teia")`.
8656        // Until this gate landed the b94fd83 absolute arm + the a5c248e
8657        // tilde arm + the f4efe9c var arm + the d624c8d control-byte arm
8658        // all let `" ../caixa-teia"` through: `Path::is_absolute` returns
8659        // false on a leading space (the leading byte is `0x20`, not `0x2F`),
8660        // `starts_with('~')` / `starts_with('$')` return false, and `0x20`
8661        // is not in the `0x00..=0x1F` plus `0x7F` control-byte set (the
8662        // four ASCII whitespace bytes `0x09` tab, `0x0A` LF, `0x0D` CR
8663        // are caught, but the most common whitespace `0x20` space is
8664        // not). The lacre embedded the value verbatim and the resolver
8665        // folded it through `Path::join` looking for a literal `./ ../
8666        // caixa-teia` subdirectory and failing at resolve time with a
8667        // non-self-locating `No such file or directory` error far from
8668        // the source caixa.lisp. The new gate moves the check to
8669        // validate time and names the offending dep + caminho verbatim.
8670        let d = dep_with_fonte(DepSource::Path {
8671            caminho: " ../caixa-teia".into(),
8672        });
8673        let err = d.validate().unwrap_err();
8674        let DepError::FonteCaminhoLeadingWhitespace { nome, caminho } = err else {
8675            panic!("expected FonteCaminhoLeadingWhitespace, got {err:?}");
8676        };
8677        assert_eq!(nome, "caixa-teia");
8678        assert_eq!(caminho, " ../caixa-teia");
8679    }
8680
8681    #[test]
8682    fn validate_rejects_path_fonte_with_multiple_leading_spaces_caminho() {
8683        // The aligned-doc paste footgun sweep: more than one leading
8684        // space (`"   ../caixa-teia"` — the canonical "I selected the
8685        // aligned column from a four-`:fonte`-entry `:deps` block"
8686        // paste) routes through the same gate's `starts_with(' ')`
8687        // byte check. Pinned so the gate doesn't narrow to a
8688        // single-space prefix.
8689        let d = dep_with_fonte(DepSource::Path {
8690            caminho: "   ../caixa-teia".into(),
8691        });
8692        let err = d.validate().unwrap_err();
8693        assert!(
8694            matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
8695            "got {err:?}",
8696        );
8697    }
8698
8699    #[test]
8700    fn validate_accepts_path_fonte_with_mid_path_space_caminho() {
8701        // The leading-space is the canonical paste-from-aligned-doc
8702        // footgun — a space mid-path (`"../my dir/caixa-teia"` — the
8703        // canonical "I have a directory with a space in its name"
8704        // idiom; ASCII `0x20` is a valid POSIX filename byte) is a
8705        // legitimate path with no whitespace-leak semantic at the
8706        // non-leading position. Pinned so the gate doesn't widen to a
8707        // full no-space-anywhere sweep that would break every
8708        // legitimate-shape space-in-filename path.
8709        let d = dep_with_fonte(DepSource::Path {
8710            caminho: "../my dir/caixa-teia".into(),
8711        });
8712        d.validate().unwrap();
8713    }
8714
8715    #[test]
8716    fn fonte_caminho_var_fires_before_leading_whitespace() {
8717        // Cascade pin: the var-expansion arm structurally precedes the
8718        // leading-whitespace arm. A value like `"$ "` would probe positive
8719        // on var (`starts_with('$')`) but the leading-byte arms walk
8720        // left-to-right so the var arm fires on the leading `$` before
8721        // the leading-whitespace arm probes. Mirrors the
8722        // `fonte_caminho_tilde_fires_before_var_expansion` cascade
8723        // discipline on the immediate-predecessor arms.
8724        let d = dep_with_fonte(DepSource::Path {
8725            caminho: "$VAR".into(),
8726        });
8727        let err = d.validate().unwrap_err();
8728        assert!(
8729            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
8730            "got {err:?}",
8731        );
8732    }
8733
8734    #[test]
8735    fn fonte_caminho_leading_whitespace_fires_before_control_char() {
8736        // Cascade pin: the leading-whitespace arm structurally precedes
8737        // the control-char arm. A value like `" ../foo\n"` probes
8738        // positive on both (starts with space AND contains LF), but
8739        // the narrower leading-byte diagnostic
8740        // (`FonteCaminhoLeadingWhitespace`) wins so the author sees the
8741        // more self-locating paste-from-aligned-doc arm first. Mirrors
8742        // the `fonte_caminho_var_fires_before_control_char` cascade
8743        // discipline on the immediate-predecessor arm.
8744        let d = dep_with_fonte(DepSource::Path {
8745            caminho: " ../foo\n".into(),
8746        });
8747        let err = d.validate().unwrap_err();
8748        assert!(
8749            matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
8750            "got {err:?}",
8751        );
8752    }
8753
8754    #[test]
8755    fn fonte_caminho_leading_whitespace_diagnostic_carries_offending_dep_and_caminho() {
8756        // Diagnostic-shape pin (peer with
8757        // `fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho`'s
8758        // payload assertion on the immediate-predecessor arm): the
8759        // error's Display surfaces both the offending `:nome` and the
8760        // offending `:caminho` verbatim, so a `feira lint` run can
8761        // render the diagnostic without re-parsing and the author can
8762        // grep their caixa.lisp for `:caminho "<value>"` and fix it in
8763        // one edit.
8764        let d = dep_with_fonte(DepSource::Path {
8765            caminho: " ../caixa-teia".into(),
8766        });
8767        let rendered = d.validate().unwrap_err().to_string();
8768        assert!(
8769            rendered.contains("caixa-teia"),
8770            "diagnostic must name the offending dep: {rendered}",
8771        );
8772        assert!(
8773            rendered.contains(" ../caixa-teia"),
8774            "diagnostic must quote the offending caminho: {rendered}",
8775        );
8776        assert!(
8777            rendered.contains("space"),
8778            "diagnostic must name the space footgun: {rendered}",
8779        );
8780    }
8781
8782    #[test]
8783    fn fonte_caminho_absolute_fires_before_control_char() {
8784        // Cascade pin on the sibling leading-byte arm: a leading `/`
8785        // value with embedded control byte (`"/etc/passwd\n"`) routes
8786        // through `FonteCaminhoAbsolute` not `FonteCaminhoControlChar`
8787        // — the host-layout-leak diagnostic is the load-bearing axis,
8788        // the control byte is the secondary observation. Same precedence
8789        // logic on every prior leading-byte arm.
8790        let d = dep_with_fonte(DepSource::Path {
8791            caminho: "/etc/passwd\n".into(),
8792        });
8793        let err = d.validate().unwrap_err();
8794        assert!(
8795            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
8796            "got {err:?}",
8797        );
8798    }
8799
8800    #[test]
8801    fn validate_rejects_path_fonte_with_leading_hyphen_caminho() {
8802        // The fail-before-pass-after pin for the leading-`-` CLI-arg-
8803        // injection `:caminho` shape sweep. Until this gate landed
8804        // every prior leading-byte arm passed a leading-`-` value
8805        // through: `Path::is_absolute` returns false on `-` (the
8806        // leading byte is `0x2D`, not `0x2F`), `starts_with('~')` /
8807        // `starts_with('$')` / `starts_with(' ')` all return false,
8808        // and `0x2D` sits outside the control-byte set. The lacre
8809        // embedded the value verbatim and the resolver folded it
8810        // through `Path::join` looking for a literal `./-rf` /
8811        // `./-C` / `./--upload-pack=…` subdirectory; the failure at
8812        // `Path::join` time is non-self-locating but harmless, while
8813        // the failure at every downstream `git -C {caminho}` /
8814        // `terraform -chdir={caminho}` / `find {caminho}` shell-out
8815        // is arbitrary-CLI-arg-injection because none of those
8816        // porcelains carry a `--` argument-list terminator between
8817        // the flag block and the path argument. The new arm moves the
8818        // rejection to `Caixa::from_lisp` boundary time and names
8819        // the offending dep + caminho verbatim.
8820        //
8821        // Sweep spans the canonical CLI-arg-injection shapes matching
8822        // the peer sweep on the sibling `is_git_ref_name` /
8823        // `is_git_repo_url` axes: short-flag `-rf` (the `rm -rf` /
8824        // `find -rf` reinterpretation vector), `-C` (the `git -C`
8825        // change-directory-config-injection paste), long-flag
8826        // `--upload-pack=cat /etc/passwd` (the canonical
8827        // arbitrary-command-execution vector on every git porcelain
8828        // entry point), git-config-injection `--config=core.merge=ours`,
8829        // and the degenerate single-byte `-` value.
8830        for caminho in [
8831            "-rf",
8832            "-C",
8833            "--upload-pack=cat /etc/passwd",
8834            "--config=core.merge=ours",
8835            "-",
8836        ] {
8837            let d = dep_with_fonte(DepSource::Path {
8838                caminho: caminho.into(),
8839            });
8840            let err = d.validate().unwrap_err();
8841            let DepError::FonteCaminhoLeadingHyphen { nome, caminho: got } = err else {
8842                panic!("expected FonteCaminhoLeadingHyphen for {caminho:?}, got {err:?}");
8843            };
8844            assert_eq!(nome, "caixa-teia");
8845            assert_eq!(got, caminho);
8846        }
8847    }
8848
8849    #[test]
8850    fn validate_accepts_path_fonte_with_mid_path_hyphen_caminho() {
8851        // The leading-`-` is the canonical CLI-arg-injection footgun
8852        // — a `-` anywhere else in the path (`"../caixa-teia"` — the
8853        // canonical kebab-separator-between-alphanumeric-segments
8854        // shape every DNS-1123-shaped caixa name carries; `"../-hidden"`
8855        // — a mid-path segment starting with `-`, still a legitimate
8856        // POSIX filename byte at that non-leading position because the
8857        // subprocess reads the whole `{caminho}` value as one positional
8858        // argument, so only the very first byte of the composite path
8859        // string is at the CLI-arg-injection boundary) is a legitimate
8860        // path with no CLI-flag-reinterpretation semantic at the non-
8861        // leading position of the top-level value. Pinned so the gate
8862        // doesn't widen to a full no-`-`-anywhere sweep that would
8863        // break every legitimate-shape kebab-in-filename path (i.e.
8864        // essentially every sibling-workspace caixa dep).
8865        for caminho in [
8866            "../caixa-teia",
8867            "../caixa-teia/-hidden",
8868            "./my-lib",
8869            "../foo-bar/baz",
8870        ] {
8871            let d = dep_with_fonte(DepSource::Path {
8872                caminho: caminho.into(),
8873            });
8874            d.validate()
8875                .unwrap_or_else(|e| panic!("mid-path `-` caminho {caminho:?} must pass: {e:?}"));
8876        }
8877    }
8878
8879    #[test]
8880    fn fonte_caminho_leading_whitespace_fires_before_leading_hyphen() {
8881        // Cascade pin: the leading-whitespace arm structurally precedes
8882        // the leading-hyphen arm. A value like `" -rf"` probes positive
8883        // on both (leading space AND, one byte in, a `-` — though the
8884        // leading-hyphen arm probes only the very first byte so it
8885        // wouldn't fire on this value; the pin instead documents the
8886        // arm order on the more common "leading space then a hyphen"
8887        // paste-from-aligned-doc paste-flag-shell-one-liner idiom).
8888        // The narrower leading-space diagnostic (the paste-from-aligned-
8889        // doc footgun) wins so the author sees the more self-locating
8890        // whitespace arm first. Mirrors the
8891        // `fonte_caminho_var_fires_before_leading_whitespace` cascade
8892        // discipline on the immediate-predecessor arm.
8893        let d = dep_with_fonte(DepSource::Path {
8894            caminho: " -rf".into(),
8895        });
8896        let err = d.validate().unwrap_err();
8897        assert!(
8898            matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
8899            "got {err:?}",
8900        );
8901    }
8902
8903    #[test]
8904    fn fonte_caminho_leading_hyphen_fires_before_control_char() {
8905        // Cascade pin: the leading-hyphen arm structurally precedes
8906        // the control-char arm. A value like `"-rf\n"` probes positive
8907        // on both (starts with `-` AND contains LF), but the narrower
8908        // leading-byte diagnostic (`FonteCaminhoLeadingHyphen`) wins so
8909        // the author sees the more self-locating CLI-arg-injection arm
8910        // first. Mirrors the
8911        // `fonte_caminho_leading_whitespace_fires_before_control_char`
8912        // cascade discipline on the immediate-predecessor arm.
8913        let d = dep_with_fonte(DepSource::Path {
8914            caminho: "-rf\n".into(),
8915        });
8916        let err = d.validate().unwrap_err();
8917        assert!(
8918            matches!(err, DepError::FonteCaminhoLeadingHyphen { .. }),
8919            "got {err:?}",
8920        );
8921    }
8922
8923    #[test]
8924    fn fonte_caminho_leading_hyphen_diagnostic_carries_offending_dep_and_caminho() {
8925        // Diagnostic-shape pin (peer with
8926        // `fonte_caminho_leading_whitespace_diagnostic_carries_offending_dep_and_caminho`'s
8927        // payload assertion on the immediate-predecessor arm): the
8928        // error's Display surfaces both the offending `:nome` and the
8929        // offending `:caminho` verbatim plus the CLI-argument-injection
8930        // vocabulary, so a `feira lint` run can render the diagnostic
8931        // without re-parsing and the author can grep their caixa.lisp
8932        // for `:caminho "<value>"` and fix it in one edit.
8933        let d = dep_with_fonte(DepSource::Path {
8934            caminho: "--upload-pack=cat /etc/passwd".into(),
8935        });
8936        let rendered = d.validate().unwrap_err().to_string();
8937        assert!(
8938            rendered.contains("caixa-teia"),
8939            "diagnostic must name the offending dep: {rendered}",
8940        );
8941        assert!(
8942            rendered.contains("--upload-pack=cat /etc/passwd"),
8943            "diagnostic must quote the offending caminho: {rendered}",
8944        );
8945        assert!(
8946            rendered.contains("CLI-argument-injection"),
8947            "diagnostic must name the CLI-argument-injection vector: {rendered}",
8948        );
8949        assert!(
8950            rendered.contains("`-`"),
8951            "diagnostic must name the offending byte: {rendered}",
8952        );
8953    }
8954
8955    #[test]
8956    fn fonte_caminho_control_diagnostic_carries_offending_dep_caminho_byte() {
8957        // Diagnostic-shape pin (peer with
8958        // `fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho`'s
8959        // payload assertion on the immediate-predecessor arm): the
8960        // error's Display surfaces the offending `:nome`, the
8961        // offending `:caminho` verbatim, and the offending byte in
8962        // hex form (`0x09` for tab) so a `feira lint` run can render
8963        // the diagnostic without re-parsing.
8964        let d = dep_with_fonte(DepSource::Path {
8965            caminho: "../caixa\tteia".into(),
8966        });
8967        let rendered = d.validate().unwrap_err().to_string();
8968        assert!(
8969            rendered.contains("caixa-teia"),
8970            "diagnostic must name the offending dep: {rendered}",
8971        );
8972        assert!(
8973            rendered.contains("../caixa\tteia"),
8974            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
8975        );
8976        assert!(
8977            rendered.contains("0x09"),
8978            "diagnostic must name the offending byte in hex: {rendered:?}",
8979        );
8980    }
8981
8982    #[test]
8983    fn validate_rejects_path_fonte_with_caminho_carrying_backslash() {
8984        // The fail-before-pass-after pin for the canonical Windows-
8985        // path-separator paste footgun: an author who pastes a path
8986        // from Windows-Explorer's `Copy as path`, PowerShell's
8987        // `Get-Location`, or any CMD/Cygwin/MSYS shell prompt
8988        // produces `..\caixa-teia`-shape values that silently passed
8989        // every prior arm (`Path::is_absolute("..\\caixa-teia")` is
8990        // false; `\` is neither a leading-byte sentinel nor a
8991        // control byte). On POSIX resolvers the value rides through
8992        // `Path::join` as a literal directory name and fails at
8993        // resolve time with `No such file or directory`; on Windows
8994        // resolvers the value resolves to the parent's sibling — two
8995        // distinct directories for the byte-identical caixa.lisp.
8996        // The new arm moves the rejection to validate time and names
8997        // the offending dep + caminho verbatim.
8998        let d = dep_with_fonte(DepSource::Path {
8999            caminho: "..\\caixa-teia".into(),
9000        });
9001        let err = d.validate().unwrap_err();
9002        let DepError::FonteCaminhoBackslash { nome, caminho } = err else {
9003            panic!("expected FonteCaminhoBackslash, got {err:?}");
9004        };
9005        assert_eq!(nome, "caixa-teia");
9006        assert_eq!(caminho, "..\\caixa-teia");
9007    }
9008
9009    #[test]
9010    fn validate_rejects_path_fonte_with_caminho_carrying_windows_drive_letter() {
9011        // The Windows drive-letter paste shape (`C:\work\caixa-teia`
9012        // out of Explorer / `cd`-and-`pwd`-on-Windows). On POSIX
9013        // hosts `Path::is_absolute("C:\\work\\caixa-teia")` returns
9014        // false (POSIX absolute paths start with `/`, drive letters
9015        // are not a POSIX concept), so the b94fd83 absolute arm
9016        // doesn't fire; the value contains `\` bytes that this arm
9017        // now catches with the more self-locating Windows-path-
9018        // separator diagnostic. Pinned separately from the bare
9019        // `..\caixa-teia` shape so a future arm that targets only
9020        // leading-`..\` doesn't regress the drive-letter coverage.
9021        let d = dep_with_fonte(DepSource::Path {
9022            caminho: "C:\\work\\caixa-teia".into(),
9023        });
9024        let err = d.validate().unwrap_err();
9025        assert!(
9026            matches!(err, DepError::FonteCaminhoBackslash { .. }),
9027            "got {err:?}",
9028        );
9029    }
9030
9031    #[test]
9032    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_backslash() {
9033        // The trailing-`\` shape (`..\caixa-teia\` — the canonical
9034        // PowerShell tab-completion-on-a-directory append). Pinned
9035        // separately from the embedded-`\` shape so the gate's
9036        // contract is "any `\` anywhere", not "any `\` not at end".
9037        let d = dep_with_fonte(DepSource::Path {
9038            caminho: "..\\caixa-teia\\".into(),
9039        });
9040        let err = d.validate().unwrap_err();
9041        assert!(
9042            matches!(err, DepError::FonteCaminhoBackslash { .. }),
9043            "got {err:?}",
9044        );
9045    }
9046
9047    #[test]
9048    fn validate_accepts_path_fonte_with_caminho_carrying_legitimate_forward_slash() {
9049        // The positive-control pin: the gate targets `\` only,
9050        // never `/`. The canonical relative POSIX path
9051        // (`../caixa-teia/foo/bar`) must continue to validate cleanly
9052        // so legitimate nested-directory deps aren't broken. Pinned
9053        // so the gate doesn't accidentally widen to a "no path
9054        // separators at all" sweep.
9055        let d = dep_with_fonte(DepSource::Path {
9056            caminho: "../caixa-teia/foo/bar".into(),
9057        });
9058        d.validate().unwrap();
9059    }
9060
9061    #[test]
9062    fn fonte_caminho_control_char_fires_before_backslash() {
9063        // Cascade pin: the control-char arm structurally precedes the
9064        // backslash arm. A value like `"..\caixa\0teia"` probes
9065        // positive on both (`\` byte + NUL byte), but the control-
9066        // char diagnostic wins so the author sees the more self-
9067        // locating POSIX-syscall-rejected-byte diagnostic first
9068        // (NUL outright breaks `CString::new` at every `std::fs`
9069        // syscall boundary; the `\` divergence is the cross-OS-
9070        // separator axis). Mirrors the
9071        // `fonte_caminho_var_fires_before_control_char` cascade
9072        // discipline on the immediate-predecessor arm.
9073        let d = dep_with_fonte(DepSource::Path {
9074            caminho: "..\\caixa\0teia".into(),
9075        });
9076        let err = d.validate().unwrap_err();
9077        assert!(
9078            matches!(err, DepError::FonteCaminhoControlChar { .. }),
9079            "got {err:?}",
9080        );
9081    }
9082
9083    #[test]
9084    fn fonte_caminho_absolute_fires_before_backslash() {
9085        // Cascade pin on the load-bearing leading-byte arm: a leading
9086        // `/` value with embedded `\` (`/etc/passwd\foo`) routes
9087        // through `FonteCaminhoAbsolute` not `FonteCaminhoBackslash`
9088        // — the host-layout-leak diagnostic is the load-bearing
9089        // axis, the `\` byte is the secondary observation. Same
9090        // precedence logic as every prior leading-byte arm.
9091        let d = dep_with_fonte(DepSource::Path {
9092            caminho: "/etc/passwd\\foo".into(),
9093        });
9094        let err = d.validate().unwrap_err();
9095        assert!(
9096            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
9097            "got {err:?}",
9098        );
9099    }
9100
9101    #[test]
9102    fn fonte_caminho_var_fires_before_backslash() {
9103        // Cascade pin on the var-expansion arm: a leading-`$` value
9104        // with embedded `\` (`$WORKSPACE\caixa-teia` — the canonical
9105        // PowerShell-env-var paste-from-CI-manifest footgun) routes
9106        // through `FonteCaminhoVarExpansion` not `FonteCaminhoBackslash`.
9107        // The shell-expansion diagnostic is the more self-locating
9108        // axis since both the leading `$` and the embedded `\`
9109        // are Windows-shell artifacts but the `$` is the root-cause
9110        // surface (an author who removes the `$` is likely to leave
9111        // the `\` too).
9112        let d = dep_with_fonte(DepSource::Path {
9113            caminho: "$WORKSPACE\\caixa-teia".into(),
9114        });
9115        let err = d.validate().unwrap_err();
9116        assert!(
9117            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
9118            "got {err:?}",
9119        );
9120    }
9121
9122    #[test]
9123    fn fonte_caminho_backslash_diagnostic_carries_offending_dep_and_caminho() {
9124        // Diagnostic-shape pin (peer with the prior
9125        // `fonte_caminho_*_diagnostic_carries_*` payload assertions
9126        // on every preceding arm): the error's Display surfaces the
9127        // offending `:nome` and the offending `:caminho` verbatim
9128        // so a `feira lint` run can render the diagnostic without
9129        // re-parsing.
9130        let d = dep_with_fonte(DepSource::Path {
9131            caminho: "..\\caixa-teia".into(),
9132        });
9133        let rendered = d.validate().unwrap_err().to_string();
9134        assert!(
9135            rendered.contains("caixa-teia"),
9136            "diagnostic must name the offending dep: {rendered}",
9137        );
9138        assert!(
9139            rendered.contains("..\\caixa-teia"),
9140            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
9141        );
9142        assert!(
9143            rendered.contains('\\'),
9144            "diagnostic must reference the backslash footgun: {rendered:?}",
9145        );
9146    }
9147
9148    #[test]
9149    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_slash() {
9150        // The fail-before-pass-after pin for the canonical trailing-`/`
9151        // paste footgun: an author who shell-tab-completes a sibling
9152        // directory (every interactive shell — bash/zsh/fish/nushell —
9153        // appends `/` on tab-completing a directory) produces
9154        // `"../caixa-teia/"`-shape values that silently passed every
9155        // prior arm (the leading byte is `.`, no control bytes, no
9156        // backslash). `Path::join` resolves both shapes to the same
9157        // directory at the resolver, but the lacre embeds the value
9158        // verbatim and the BLAKE3 closures diverge across two
9159        // workstations whose authors differ only in tab-completion
9160        // habits.
9161        let d = dep_with_fonte(DepSource::Path {
9162            caminho: "../caixa-teia/".into(),
9163        });
9164        let err = d.validate().unwrap_err();
9165        let DepError::FonteCaminhoTrailingSlash { nome, caminho } = err else {
9166            panic!("expected FonteCaminhoTrailingSlash, got {err:?}");
9167        };
9168        assert_eq!(nome, "caixa-teia");
9169        assert_eq!(caminho, "../caixa-teia/");
9170    }
9171
9172    #[test]
9173    fn validate_rejects_path_fonte_with_caminho_carrying_bare_dot_slash() {
9174        // The `"./"` shape (the canonical "I meant the caixa.lisp's own
9175        // directory and tab-completed it" footgun). Pinned separately
9176        // from the canonical `"../caixa-teia/"` shape so the gate's
9177        // contract is "any trailing `/`", not "trailing `/` after a leaf
9178        // name".
9179        let d = dep_with_fonte(DepSource::Path {
9180            caminho: "./".into(),
9181        });
9182        let err = d.validate().unwrap_err();
9183        assert!(
9184            matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
9185            "got {err:?}",
9186        );
9187    }
9188
9189    #[test]
9190    fn validate_rejects_path_fonte_with_caminho_carrying_consecutive_trailing_slashes() {
9191        // The `"foo//"` shape (the canonical "I pasted from a CI manifest
9192        // that double-templated `${VAR}/` over an already-`/`-suffixed
9193        // path" footgun). The gate fires on the last byte being `/`
9194        // regardless of how many `/` precede it; the arm contract is
9195        // "the value ends with `/`", structurally.
9196        let d = dep_with_fonte(DepSource::Path {
9197            caminho: "../caixa-teia//".into(),
9198        });
9199        let err = d.validate().unwrap_err();
9200        assert!(
9201            matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
9202            "got {err:?}",
9203        );
9204    }
9205
9206    #[test]
9207    fn validate_rejects_path_fonte_with_caminho_carrying_dotdot_trailing_slash() {
9208        // The `"../"` shape (the canonical "I want the parent" tab-
9209        // completion footgun on a bare `..` path). Pinned separately so
9210        // the gate doesn't accidentally narrow to "trailing `/` only on
9211        // multi-segment paths".
9212        let d = dep_with_fonte(DepSource::Path {
9213            caminho: "../".into(),
9214        });
9215        let err = d.validate().unwrap_err();
9216        assert!(
9217            matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
9218            "got {err:?}",
9219        );
9220    }
9221
9222    #[test]
9223    fn validate_accepts_path_fonte_with_caminho_carrying_internal_slashes() {
9224        // The positive-control pin: the gate targets the trailing byte
9225        // only, never internal `/` separators. The canonical nested
9226        // relative POSIX path (`"../caixa-teia/foo/bar"`) must continue
9227        // to validate cleanly so legitimate deeply-nested deps aren't
9228        // broken. Pinned so the gate doesn't accidentally widen to a
9229        // "no `/` separators anywhere" sweep that would defeat the
9230        // entire path-fonte author surface.
9231        let d = dep_with_fonte(DepSource::Path {
9232            caminho: "../caixa-teia/foo/bar".into(),
9233        });
9234        d.validate().unwrap();
9235    }
9236
9237    #[test]
9238    fn validate_accepts_path_fonte_with_caminho_carrying_bare_dot() {
9239        // The positive-control pin on the degenerate single-`.` shape
9240        // (the canonical "the caixa.lisp's own directory" idiom). The
9241        // gate fires on the trailing byte being `/`, not on the path
9242        // being short, so `"."` (one byte, not `/`) must continue to
9243        // validate cleanly.
9244        let d = dep_with_fonte(DepSource::Path {
9245            caminho: ".".into(),
9246        });
9247        d.validate().unwrap();
9248    }
9249
9250    #[test]
9251    fn fonte_caminho_control_char_fires_before_trailing_slash() {
9252        // Cascade pin: the control-char arm structurally precedes the
9253        // trailing-slash arm. A value like `"../foo\n/"` ends in `/`
9254        // but the embedded LF (`0x0A`) is the load-bearing diagnostic
9255        // (control bytes are the paste-from-multiline-doc footgun the
9256        // d624c8d arm already closes). Mirrors the
9257        // `fonte_caminho_control_char_fires_before_backslash` cascade
9258        // discipline on the immediate-predecessor arm.
9259        let d = dep_with_fonte(DepSource::Path {
9260            caminho: "../foo\n/".into(),
9261        });
9262        let err = d.validate().unwrap_err();
9263        assert!(
9264            matches!(err, DepError::FonteCaminhoControlChar { .. }),
9265            "got {err:?}",
9266        );
9267    }
9268
9269    #[test]
9270    fn fonte_caminho_backslash_fires_before_trailing_slash() {
9271        // Cascade pin on the backslash arm: a value like `"..\foo/"`
9272        // ends in `/` but the embedded `\` is the load-bearing
9273        // diagnostic (the cross-host-OS-separator divergence vector
9274        // the 3a4e1d7 arm closes). Same precedence logic as the prior
9275        // narrower-diagnostic-first cascade.
9276        let d = dep_with_fonte(DepSource::Path {
9277            caminho: "..\\caixa-teia/".into(),
9278        });
9279        let err = d.validate().unwrap_err();
9280        assert!(
9281            matches!(err, DepError::FonteCaminhoBackslash { .. }),
9282            "got {err:?}",
9283        );
9284    }
9285
9286    #[test]
9287    fn fonte_caminho_absolute_fires_before_trailing_slash() {
9288        // Cascade pin on the load-bearing leading-byte arm: a leading
9289        // `/` value with a trailing `/` (`"/etc/passwd/"`) routes
9290        // through `FonteCaminhoAbsolute` not `FonteCaminhoTrailingSlash`
9291        // — the host-layout-leak diagnostic is the load-bearing axis,
9292        // the trailing `/` is the secondary observation. Same
9293        // precedence logic as every prior leading-byte arm.
9294        let d = dep_with_fonte(DepSource::Path {
9295            caminho: "/etc/passwd/".into(),
9296        });
9297        let err = d.validate().unwrap_err();
9298        assert!(
9299            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
9300            "got {err:?}",
9301        );
9302    }
9303
9304    #[test]
9305    fn fonte_caminho_trailing_slash_diagnostic_carries_offending_dep_and_caminho() {
9306        // Diagnostic-shape pin (peer with the prior
9307        // `fonte_caminho_*_diagnostic_carries_*` payload assertions on
9308        // every preceding arm): the error's Display surfaces the
9309        // offending `:nome` and the offending `:caminho` verbatim so a
9310        // `feira lint` run can render the diagnostic without re-parsing.
9311        let d = dep_with_fonte(DepSource::Path {
9312            caminho: "../caixa-teia/".into(),
9313        });
9314        let rendered = d.validate().unwrap_err().to_string();
9315        assert!(
9316            rendered.contains("caixa-teia"),
9317            "diagnostic must name the offending dep: {rendered}",
9318        );
9319        assert!(
9320            rendered.contains("../caixa-teia/"),
9321            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
9322        );
9323        assert!(
9324            rendered.contains("trailing"),
9325            "diagnostic must reference the trailing-slash footgun: {rendered:?}",
9326        );
9327    }
9328
9329    // -- :caminho shell-redirection metacharacter arm -----------------------
9330
9331    #[test]
9332    fn validate_rejects_path_fonte_with_caminho_carrying_gt_redirection() {
9333        // The fail-before-pass-after pin for the canonical output-redirection
9334        // paste footgun: an author copies a shell pipeline tail
9335        // (`"../caixa-teia>build.log"` — the canonical "I selected the whole
9336        // line including the `> build.log` redirect" idiom) and silently
9337        // passed every prior arm (`Path::is_absolute` false on `..`, no
9338        // control bytes, no backslash, doesn't end in `/`). The lacre
9339        // embedded the value verbatim, the resolver folded it through
9340        // `Path::join` looking for a literal `./../caixa-teia>build.log`
9341        // subdirectory, and the failure surfaced at resolve time with a
9342        // non-self-locating `No such file or directory` error. The new arm
9343        // moves the rejection to validate time and names the offending dep
9344        // + caminho + byte verbatim.
9345        let d = dep_with_fonte(DepSource::Path {
9346            caminho: "../caixa-teia>build.log".into(),
9347        });
9348        let err = d.validate().unwrap_err();
9349        let DepError::FonteCaminhoShellRedirection {
9350            nome,
9351            caminho,
9352            byte,
9353        } = err
9354        else {
9355            panic!("expected FonteCaminhoShellRedirection, got {err:?}");
9356        };
9357        assert_eq!(nome, "caixa-teia");
9358        assert_eq!(caminho, "../caixa-teia>build.log");
9359        assert_eq!(byte, b'>');
9360    }
9361
9362    #[test]
9363    fn validate_rejects_path_fonte_with_caminho_carrying_lt_redirection() {
9364        // The symmetric input-redirection paste shape
9365        // (`"../caixa-teia<input.lisp"` — the canonical "I copied a
9366        // `command < input.lisp` line from a tatara-lisp REPL log"
9367        // idiom). Pinned separately from the `>` shape so the gate's
9368        // contract is "any `<` or `>` anywhere", not single-byte coverage.
9369        let d = dep_with_fonte(DepSource::Path {
9370            caminho: "../caixa-teia<input.lisp".into(),
9371        });
9372        let err = d.validate().unwrap_err();
9373        let DepError::FonteCaminhoShellRedirection { byte, .. } = err else {
9374            panic!("expected FonteCaminhoShellRedirection, got {err:?}");
9375        };
9376        assert_eq!(byte, b'<');
9377    }
9378
9379    #[test]
9380    fn validate_rejects_path_fonte_with_caminho_carrying_leading_gt_redirection() {
9381        // Leading-position `>` shape (`">../caixa-teia"` — the degenerate
9382        // "I forgot the source side of the redirect" idiom). Pinned
9383        // separately from the embedded-byte shapes so the gate covers
9384        // every position, not only mid-path.
9385        let d = dep_with_fonte(DepSource::Path {
9386            caminho: ">../caixa-teia".into(),
9387        });
9388        let err = d.validate().unwrap_err();
9389        assert!(
9390            matches!(
9391                err,
9392                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
9393            ),
9394            "got {err:?}",
9395        );
9396    }
9397
9398    #[test]
9399    fn validate_rejects_path_fonte_with_caminho_carrying_double_gt_append() {
9400        // The bash append-redirection shape (`"../caixa-teia>>build.log"` —
9401        // the canonical "I copied a `>>` append redirect" idiom). The arm
9402        // fires on the first `>` encountered; pinned so a future arm that
9403        // tries to distinguish `>` from `>>` doesn't break the broader
9404        // contract.
9405        let d = dep_with_fonte(DepSource::Path {
9406            caminho: "../caixa-teia>>build.log".into(),
9407        });
9408        let err = d.validate().unwrap_err();
9409        assert!(
9410            matches!(
9411                err,
9412                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
9413            ),
9414            "got {err:?}",
9415        );
9416    }
9417
9418    #[test]
9419    fn validate_accepts_path_fonte_with_caminho_carrying_no_redirection() {
9420        // The positive-control pin: the gate targets only `<` / `>`,
9421        // never adjacent printable ASCII or POSIX-valid bytes. The
9422        // canonical relative POSIX path (`"../caixa-teia"`) and a
9423        // nested deeply-pathed variant (`"../caixa-teia/foo/bar"`) must
9424        // continue to validate cleanly so the gate doesn't widen to a
9425        // "no printable punctuation anywhere" sweep that would defeat
9426        // the entire path-fonte author surface.
9427        let d = dep_with_fonte(DepSource::Path {
9428            caminho: "../caixa-teia/foo/bar".into(),
9429        });
9430        d.validate().unwrap();
9431    }
9432
9433    #[test]
9434    fn fonte_caminho_backslash_fires_before_shell_redirection() {
9435        // Cascade pin on the immediate-predecessor arm: a value carrying
9436        // both `\` and `<` / `>` (`"..\caixa-teia>build.log"` — the
9437        // canonical "I pasted a Windows-shell command with output
9438        // redirect" footgun) routes through `FonteCaminhoBackslash` not
9439        // `FonteCaminhoShellRedirection`. The cross-host-OS-separator
9440        // divergence is the load-bearing axis (an author who removes
9441        // the `\` is the root-cause edit; the `>` falls away in the
9442        // same edit since it's downstream of the Windows-shell
9443        // convention).
9444        let d = dep_with_fonte(DepSource::Path {
9445            caminho: "..\\caixa-teia>build.log".into(),
9446        });
9447        let err = d.validate().unwrap_err();
9448        assert!(
9449            matches!(err, DepError::FonteCaminhoBackslash { .. }),
9450            "got {err:?}",
9451        );
9452    }
9453
9454    #[test]
9455    fn fonte_caminho_control_char_fires_before_shell_redirection() {
9456        // Cascade pin on the embedded-control-byte arm: a value carrying
9457        // both a control byte and `<` / `>` (`"../foo\n>bar"` — the
9458        // canonical paste-from-multiline-doc footgun where a newline
9459        // landed mid-caminho) routes through `FonteCaminhoControlChar`
9460        // not `FonteCaminhoShellRedirection`. The POSIX-syscall-
9461        // rejected-byte / NUL-`CString::new`-fail diagnostic is the
9462        // load-bearing axis on every value that probes positive for
9463        // both — mirrors the cascade discipline on every prior arm.
9464        let d = dep_with_fonte(DepSource::Path {
9465            caminho: "../foo\n>bar".into(),
9466        });
9467        let err = d.validate().unwrap_err();
9468        assert!(
9469            matches!(err, DepError::FonteCaminhoControlChar { .. }),
9470            "got {err:?}",
9471        );
9472    }
9473
9474    #[test]
9475    fn fonte_caminho_absolute_fires_before_shell_redirection() {
9476        // Cascade pin on the load-bearing leading-byte arm: a leading
9477        // `/` value with embedded `<` / `>` (`"/etc/passwd>out"`)
9478        // routes through `FonteCaminhoAbsolute` not
9479        // `FonteCaminhoShellRedirection` — the host-layout-leak
9480        // diagnostic is the load-bearing axis, the `>` byte is the
9481        // secondary observation. Same precedence logic as every prior
9482        // leading-byte arm.
9483        let d = dep_with_fonte(DepSource::Path {
9484            caminho: "/etc/passwd>out".into(),
9485        });
9486        let err = d.validate().unwrap_err();
9487        assert!(
9488            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
9489            "got {err:?}",
9490        );
9491    }
9492
9493    #[test]
9494    fn fonte_caminho_shell_redirection_fires_before_trailing_slash() {
9495        // Cascade pin on the immediate-successor arm: a value carrying
9496        // both `<` / `>` and a trailing `/` (`"../foo></"` — the
9497        // canonical "I tab-completed a path that already had a
9498        // redirect" footgun) routes through `FonteCaminhoShellRedirection`
9499        // not `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
9500        // the more semantic-locating axis (an author who removes the
9501        // `<` / `>` typically also drops the trailing separator since
9502        // both are paste-from-shell artifacts).
9503        let d = dep_with_fonte(DepSource::Path {
9504            caminho: "../foo></".into(),
9505        });
9506        let err = d.validate().unwrap_err();
9507        assert!(
9508            matches!(
9509                err,
9510                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
9511            ),
9512            "got {err:?}",
9513        );
9514    }
9515
9516    #[test]
9517    fn fonte_caminho_shell_redirection_diagnostic_carries_offending_dep_caminho_byte() {
9518        // Diagnostic-shape pin (peer with
9519        // `fonte_caminho_control_diagnostic_carries_offending_dep_caminho_byte`'s
9520        // payload assertion on the closest peer arm that also carries a
9521        // `byte` field): the error's Display surfaces the offending
9522        // `:nome`, the offending `:caminho` verbatim, and the offending
9523        // byte in hex (`0x3c` for `<`, `0x3e` for `>`) so a `feira lint`
9524        // run can render the diagnostic without re-parsing.
9525        let d = dep_with_fonte(DepSource::Path {
9526            caminho: "../caixa-teia>build.log".into(),
9527        });
9528        let rendered = d.validate().unwrap_err().to_string();
9529        assert!(
9530            rendered.contains("caixa-teia"),
9531            "diagnostic must name the offending dep: {rendered}",
9532        );
9533        assert!(
9534            rendered.contains("../caixa-teia>build.log"),
9535            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
9536        );
9537        assert!(
9538            rendered.contains("0x3e"),
9539            "diagnostic must name the offending byte in hex: {rendered:?}",
9540        );
9541        assert!(
9542            rendered.contains("redirection"),
9543            "diagnostic must name the shell-redirection footgun: {rendered:?}",
9544        );
9545    }
9546
9547    // -- :caminho shell-pipe metacharacter arm ----------------------------
9548
9549    #[test]
9550    fn validate_rejects_path_fonte_with_caminho_carrying_pipe() {
9551        // The fail-before-pass-after pin for the canonical shell-pipe
9552        // paste footgun: an author copies a shell-history line
9553        // (`"../caixa-teia | grep foo"` — the canonical "I selected
9554        // the whole `ls dir | grep` line out of zsh history") and
9555        // silently passed every prior arm (`Path::is_absolute` false
9556        // on `..`, no control bytes, no backslash, no `<` / `>`,
9557        // doesn't end in `/`). The lacre embedded the value verbatim,
9558        // the resolver folded it through `Path::join` looking for a
9559        // literal `./../caixa-teia | grep foo` subdirectory, and the
9560        // failure surfaced at resolve time with a non-self-locating
9561        // `No such file or directory` error. The new arm moves the
9562        // rejection to validate time and names the offending dep +
9563        // caminho verbatim.
9564        let d = dep_with_fonte(DepSource::Path {
9565            caminho: "../caixa-teia | grep foo".into(),
9566        });
9567        let err = d.validate().unwrap_err();
9568        let DepError::FonteCaminhoShellPipe { nome, caminho } = err else {
9569            panic!("expected FonteCaminhoShellPipe, got {err:?}");
9570        };
9571        assert_eq!(nome, "caixa-teia");
9572        assert_eq!(caminho, "../caixa-teia | grep foo");
9573    }
9574
9575    #[test]
9576    fn validate_rejects_path_fonte_with_caminho_carrying_leading_pipe() {
9577        // Leading-position `|` shape (`"|../caixa-teia"` — the
9578        // degenerate "I forgot the source side of the pipe" idiom).
9579        // Pinned separately from the embedded-byte shape so the gate
9580        // covers every position, not only mid-path.
9581        let d = dep_with_fonte(DepSource::Path {
9582            caminho: "|../caixa-teia".into(),
9583        });
9584        let err = d.validate().unwrap_err();
9585        assert!(
9586            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
9587            "got {err:?}",
9588        );
9589    }
9590
9591    #[test]
9592    fn validate_rejects_path_fonte_with_caminho_carrying_double_pipe_or() {
9593        // The bash short-circuit-OR shape (`"../caixa-teia||fallback"`
9594        // — the canonical "I copied a `cmd-a || cmd-b` fallback line"
9595        // idiom). The arm fires on the first `|` encountered; pinned
9596        // so a future arm that tries to distinguish `|` from `||`
9597        // doesn't break the broader contract.
9598        let d = dep_with_fonte(DepSource::Path {
9599            caminho: "../caixa-teia||fallback".into(),
9600        });
9601        let err = d.validate().unwrap_err();
9602        assert!(
9603            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
9604            "got {err:?}",
9605        );
9606    }
9607
9608    #[test]
9609    fn validate_accepts_path_fonte_with_caminho_carrying_no_pipe() {
9610        // The positive-control pin: the gate targets only `|`, never
9611        // adjacent printable ASCII or POSIX-valid bytes. The canonical
9612        // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
9613        // pathed variant with adjacent printable punctuation
9614        // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
9615        // cleanly so the gate doesn't widen to a "no printable
9616        // punctuation anywhere" sweep that would defeat the entire
9617        // path-fonte author surface.
9618        let d = dep_with_fonte(DepSource::Path {
9619            caminho: "../caixa-teia/sub-dir.v2".into(),
9620        });
9621        d.validate().unwrap();
9622    }
9623
9624    #[test]
9625    fn fonte_caminho_shell_redirection_fires_before_shell_pipe() {
9626        // Cascade pin on the immediate-predecessor arm: a value carrying
9627        // both `<` / `>` and `|` (`"../caixa-teia<input|tee"` — the
9628        // canonical "I pasted a `cmd < input | tee` pipeline tail"
9629        // footgun) routes through `FonteCaminhoShellRedirection` not
9630        // `FonteCaminhoShellPipe`. The input/output redirection
9631        // metachar carries the more self-locating `byte: u8` payload
9632        // (it names which of `<` or `>` triggered), so the prior arm
9633        // wins on every probe-as-both value — same cascade discipline
9634        // every prior `:caminho` arm establishes.
9635        let d = dep_with_fonte(DepSource::Path {
9636            caminho: "../caixa-teia<input|tee".into(),
9637        });
9638        let err = d.validate().unwrap_err();
9639        assert!(
9640            matches!(
9641                err,
9642                DepError::FonteCaminhoShellRedirection { byte: b'<', .. }
9643            ),
9644            "got {err:?}",
9645        );
9646    }
9647
9648    #[test]
9649    fn fonte_caminho_backslash_fires_before_shell_pipe() {
9650        // Cascade pin on the upstream backslash arm: a value carrying
9651        // both `\` and `|` (`"..\caixa-teia|tee"` — the canonical
9652        // "I pasted a Windows-shell command with pipe to tee"
9653        // footgun) routes through `FonteCaminhoBackslash` not
9654        // `FonteCaminhoShellPipe`. The cross-host-OS-separator
9655        // divergence is the load-bearing axis on every probe-as-both
9656        // value (an author who removes the `\` is the root-cause edit;
9657        // the `|` falls away in the same edit since it's downstream of
9658        // the Windows-shell convention).
9659        let d = dep_with_fonte(DepSource::Path {
9660            caminho: "..\\caixa-teia|tee".into(),
9661        });
9662        let err = d.validate().unwrap_err();
9663        assert!(
9664            matches!(err, DepError::FonteCaminhoBackslash { .. }),
9665            "got {err:?}",
9666        );
9667    }
9668
9669    #[test]
9670    fn fonte_caminho_control_char_fires_before_shell_pipe() {
9671        // Cascade pin on the embedded-control-byte arm: a value
9672        // carrying both a control byte and `|` (`"../foo\n|bar"` —
9673        // the canonical paste-from-multiline-doc footgun where a
9674        // newline landed mid-caminho) routes through
9675        // `FonteCaminhoControlChar` not `FonteCaminhoShellPipe`. The
9676        // POSIX-syscall-rejected-byte / NUL-`CString::new`-fail
9677        // diagnostic is the load-bearing axis on every value that
9678        // probes positive for both — mirrors the cascade discipline
9679        // on every prior arm.
9680        let d = dep_with_fonte(DepSource::Path {
9681            caminho: "../foo\n|bar".into(),
9682        });
9683        let err = d.validate().unwrap_err();
9684        assert!(
9685            matches!(err, DepError::FonteCaminhoControlChar { .. }),
9686            "got {err:?}",
9687        );
9688    }
9689
9690    #[test]
9691    fn fonte_caminho_absolute_fires_before_shell_pipe() {
9692        // Cascade pin on the load-bearing leading-byte arm: a leading
9693        // `/` value with embedded `|` (`"/etc/passwd|tee"`) routes
9694        // through `FonteCaminhoAbsolute` not `FonteCaminhoShellPipe`
9695        // — the host-layout-leak diagnostic is the load-bearing axis,
9696        // the `|` byte is the secondary observation. Same precedence
9697        // logic as every prior leading-byte arm.
9698        let d = dep_with_fonte(DepSource::Path {
9699            caminho: "/etc/passwd|tee".into(),
9700        });
9701        let err = d.validate().unwrap_err();
9702        assert!(
9703            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
9704            "got {err:?}",
9705        );
9706    }
9707
9708    #[test]
9709    fn fonte_caminho_shell_pipe_fires_before_trailing_slash() {
9710        // Cascade pin on the immediate-successor arm: a value carrying
9711        // both `|` and a trailing `/` (`"../foo|tee/"` — the canonical
9712        // "I tab-completed a path that already had a pipeline tail"
9713        // footgun) routes through `FonteCaminhoShellPipe` not
9714        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
9715        // the more semantic-locating axis (an author who removes the
9716        // `|` typically also drops the trailing separator since both
9717        // are paste-from-shell artifacts).
9718        let d = dep_with_fonte(DepSource::Path {
9719            caminho: "../foo|tee/".into(),
9720        });
9721        let err = d.validate().unwrap_err();
9722        assert!(
9723            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
9724            "got {err:?}",
9725        );
9726    }
9727
9728    #[test]
9729    fn fonte_caminho_shell_pipe_diagnostic_carries_offending_dep_and_caminho() {
9730        // Diagnostic-shape pin (peer with
9731        // `fonte_caminho_backslash_diagnostic_carries_offending_dep_and_caminho`
9732        // on the closest single-byte peer arm): the error's Display
9733        // surfaces the offending `:nome` and the offending `:caminho`
9734        // verbatim, and names the shell-pipe footgun explicitly so a
9735        // `feira lint` run can render the diagnostic without
9736        // re-parsing.
9737        let d = dep_with_fonte(DepSource::Path {
9738            caminho: "../caixa-teia | grep foo".into(),
9739        });
9740        let rendered = d.validate().unwrap_err().to_string();
9741        assert!(
9742            rendered.contains("caixa-teia"),
9743            "diagnostic must name the offending dep: {rendered}",
9744        );
9745        assert!(
9746            rendered.contains("../caixa-teia | grep foo"),
9747            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
9748        );
9749        assert!(
9750            rendered.contains('|'),
9751            "diagnostic must reference the pipe footgun: {rendered:?}",
9752        );
9753        assert!(
9754            rendered.contains("pipe"),
9755            "diagnostic must name the shell-pipe footgun: {rendered:?}",
9756        );
9757    }
9758
9759    // -- :caminho shell-command-separator metacharacter arm ---------------
9760
9761    #[test]
9762    fn validate_rejects_path_fonte_with_caminho_carrying_semicolon() {
9763        // The fail-before-pass-after pin for the canonical shell-command-
9764        // separator paste footgun: an author copies a shell one-liner
9765        // (`"../caixa-teia; rm -rf build"` — the canonical "I selected the
9766        // whole `cd path; do-thing` chain out of a shell-history block")
9767        // and silently passed every prior arm (`Path::is_absolute` false
9768        // on `..`, no control bytes, no backslash, no `<` / `>`, no `|`,
9769        // doesn't end in `/`). The lacre embedded the value verbatim, the
9770        // resolver folded it through `Path::join` looking for a literal
9771        // `./../caixa-teia; rm -rf build` subdirectory, and the failure
9772        // surfaced at resolve time with a non-self-locating `No such file
9773        // or directory` error. The new arm moves the rejection to validate
9774        // time and names the offending dep + caminho verbatim.
9775        let d = dep_with_fonte(DepSource::Path {
9776            caminho: "../caixa-teia; rm -rf build".into(),
9777        });
9778        let err = d.validate().unwrap_err();
9779        let DepError::FonteCaminhoShellSemicolon { nome, caminho } = err else {
9780            panic!("expected FonteCaminhoShellSemicolon, got {err:?}");
9781        };
9782        assert_eq!(nome, "caixa-teia");
9783        assert_eq!(caminho, "../caixa-teia; rm -rf build");
9784    }
9785
9786    #[test]
9787    fn validate_rejects_path_fonte_with_caminho_carrying_leading_semicolon() {
9788        // Leading-position `;` shape (`";../caixa-teia"` — the degenerate
9789        // "I forgot the prior command side of the separator" idiom).
9790        // Pinned separately from the embedded-byte shape so the gate
9791        // covers every position, not only mid-path.
9792        let d = dep_with_fonte(DepSource::Path {
9793            caminho: ";../caixa-teia".into(),
9794        });
9795        let err = d.validate().unwrap_err();
9796        assert!(
9797            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
9798            "got {err:?}",
9799        );
9800    }
9801
9802    #[test]
9803    fn validate_rejects_path_fonte_with_caminho_carrying_double_semicolon() {
9804        // The POSIX `case` arm `;;` terminator shape
9805        // (`"../caixa-teia;;next"` — the canonical "I copied a `case`
9806        // arm tail" idiom). The arm fires on the first `;` encountered;
9807        // pinned so a future arm that tries to distinguish `;` from `;;`
9808        // doesn't break the broader contract.
9809        let d = dep_with_fonte(DepSource::Path {
9810            caminho: "../caixa-teia;;next".into(),
9811        });
9812        let err = d.validate().unwrap_err();
9813        assert!(
9814            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
9815            "got {err:?}",
9816        );
9817    }
9818
9819    #[test]
9820    fn validate_accepts_path_fonte_with_caminho_carrying_no_semicolon() {
9821        // The positive-control pin: the gate targets only `;`, never
9822        // adjacent printable ASCII or POSIX-valid bytes. The canonical
9823        // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
9824        // pathed variant with adjacent printable punctuation
9825        // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
9826        // cleanly so the gate doesn't widen to a "no printable
9827        // punctuation anywhere" sweep that would defeat the entire
9828        // path-fonte author surface.
9829        let d = dep_with_fonte(DepSource::Path {
9830            caminho: "../caixa-teia/sub-dir.v2".into(),
9831        });
9832        d.validate().unwrap();
9833    }
9834
9835    #[test]
9836    fn fonte_caminho_shell_pipe_fires_before_shell_semicolon() {
9837        // Cascade pin on the immediate-predecessor arm: a value carrying
9838        // both `|` and `;` (`"../caixa-teia | tee; rm"` — the canonical
9839        // "I pasted a `cmd | tee; cleanup` chain" footgun) routes through
9840        // `FonteCaminhoShellPipe` not `FonteCaminhoShellSemicolon`. The
9841        // pipeline-tail paste is the load-bearing root-cause edit on
9842        // every probe-as-both value (an author who removes the `|`
9843        // typically also drops the trailing `; cleanup` since both are
9844        // the same paste-from-shell-history artifact) — same cascade
9845        // discipline every prior `:caminho` arm establishes.
9846        let d = dep_with_fonte(DepSource::Path {
9847            caminho: "../caixa-teia | tee; rm".into(),
9848        });
9849        let err = d.validate().unwrap_err();
9850        assert!(
9851            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
9852            "got {err:?}",
9853        );
9854    }
9855
9856    #[test]
9857    fn fonte_caminho_shell_redirection_fires_before_shell_semicolon() {
9858        // Cascade pin on the upstream shell-redirection arm: a value
9859        // carrying both `<` / `>` and `;` (`"../caixa-teia>log; rm"` —
9860        // the canonical "I pasted a `cmd > log; cleanup` chain"
9861        // footgun) routes through `FonteCaminhoShellRedirection` not
9862        // `FonteCaminhoShellSemicolon`. The input/output redirection
9863        // metachar carries the more self-locating `byte: u8` payload
9864        // (it names which of `<` or `>` triggered), so the prior arm
9865        // wins on every probe-as-both value.
9866        let d = dep_with_fonte(DepSource::Path {
9867            caminho: "../caixa-teia>log; rm".into(),
9868        });
9869        let err = d.validate().unwrap_err();
9870        assert!(
9871            matches!(
9872                err,
9873                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
9874            ),
9875            "got {err:?}",
9876        );
9877    }
9878
9879    #[test]
9880    fn fonte_caminho_backslash_fires_before_shell_semicolon() {
9881        // Cascade pin on the upstream backslash arm: a value carrying
9882        // both `\` and `;` (`"..\caixa-teia;rm"` — the canonical "I
9883        // pasted a Windows-shell `cd ..\path; cleanup` chain") routes
9884        // through `FonteCaminhoBackslash` not `FonteCaminhoShellSemicolon`.
9885        // The cross-host-OS-separator divergence is the load-bearing axis
9886        // on every probe-as-both value (an author who removes the `\` is
9887        // the root-cause edit; the `;` falls away in the same edit since
9888        // it's downstream of the Windows-shell convention).
9889        let d = dep_with_fonte(DepSource::Path {
9890            caminho: "..\\caixa-teia;rm".into(),
9891        });
9892        let err = d.validate().unwrap_err();
9893        assert!(
9894            matches!(err, DepError::FonteCaminhoBackslash { .. }),
9895            "got {err:?}",
9896        );
9897    }
9898
9899    #[test]
9900    fn fonte_caminho_control_char_fires_before_shell_semicolon() {
9901        // Cascade pin on the embedded-control-byte arm: a value carrying
9902        // both a control byte and `;` (`"../foo\n;bar"` — the canonical
9903        // paste-from-multiline-doc footgun where a newline landed mid-
9904        // caminho) routes through `FonteCaminhoControlChar` not
9905        // `FonteCaminhoShellSemicolon`. The POSIX-syscall-rejected-byte
9906        // / NUL-`CString::new`-fail diagnostic is the load-bearing axis
9907        // on every value that probes positive for both — mirrors the
9908        // cascade discipline on every prior arm.
9909        let d = dep_with_fonte(DepSource::Path {
9910            caminho: "../foo\n;bar".into(),
9911        });
9912        let err = d.validate().unwrap_err();
9913        assert!(
9914            matches!(err, DepError::FonteCaminhoControlChar { .. }),
9915            "got {err:?}",
9916        );
9917    }
9918
9919    #[test]
9920    fn fonte_caminho_absolute_fires_before_shell_semicolon() {
9921        // Cascade pin on the load-bearing leading-byte arm: a leading
9922        // `/` value with embedded `;` (`"/etc/passwd;rm"`) routes
9923        // through `FonteCaminhoAbsolute` not `FonteCaminhoShellSemicolon`
9924        // — the host-layout-leak diagnostic is the load-bearing axis,
9925        // the `;` byte is the secondary observation. Same precedence
9926        // logic as every prior leading-byte arm.
9927        let d = dep_with_fonte(DepSource::Path {
9928            caminho: "/etc/passwd;rm".into(),
9929        });
9930        let err = d.validate().unwrap_err();
9931        assert!(
9932            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
9933            "got {err:?}",
9934        );
9935    }
9936
9937    #[test]
9938    fn fonte_caminho_shell_semicolon_fires_before_trailing_slash() {
9939        // Cascade pin on the immediate-successor arm: a value carrying
9940        // both `;` and a trailing `/` (`"../foo;rm/"` — the canonical
9941        // "I tab-completed a path that already had a `; cleanup` tail"
9942        // footgun) routes through `FonteCaminhoShellSemicolon` not
9943        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
9944        // the more semantic-locating axis (an author who removes the
9945        // `;` typically also drops the trailing separator since both
9946        // are paste-from-shell artifacts).
9947        let d = dep_with_fonte(DepSource::Path {
9948            caminho: "../foo;rm/".into(),
9949        });
9950        let err = d.validate().unwrap_err();
9951        assert!(
9952            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
9953            "got {err:?}",
9954        );
9955    }
9956
9957    #[test]
9958    fn fonte_caminho_shell_semicolon_diagnostic_carries_offending_dep_and_caminho() {
9959        // Diagnostic-shape pin (peer with
9960        // `fonte_caminho_shell_pipe_diagnostic_carries_offending_dep_and_caminho`
9961        // on the closest single-byte peer arm): the error's Display
9962        // surfaces the offending `:nome` and the offending `:caminho`
9963        // verbatim, and names the shell-command-separator footgun
9964        // explicitly so a `feira lint` run can render the diagnostic
9965        // without re-parsing.
9966        let d = dep_with_fonte(DepSource::Path {
9967            caminho: "../caixa-teia; rm -rf build".into(),
9968        });
9969        let rendered = d.validate().unwrap_err().to_string();
9970        assert!(
9971            rendered.contains("caixa-teia"),
9972            "diagnostic must name the offending dep: {rendered}",
9973        );
9974        assert!(
9975            rendered.contains("../caixa-teia; rm -rf build"),
9976            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
9977        );
9978        assert!(
9979            rendered.contains(';'),
9980            "diagnostic must reference the semicolon footgun: {rendered:?}",
9981        );
9982        assert!(
9983            rendered.contains("command-separator"),
9984            "diagnostic must name the shell-command-separator footgun: {rendered:?}",
9985        );
9986    }
9987
9988    #[test]
9989    fn validate_rejects_path_fonte_with_caminho_carrying_ampersand() {
9990        // The fail-before-pass-after pin for the canonical shell-
9991        // background-task paste footgun: an author copies a shell one-
9992        // liner (`"../caixa-teia & sleep 1"` — the canonical "I selected
9993        // the whole `cd path & sleep 1` background-launch out of a
9994        // shell-history block") and silently passed every prior arm
9995        // (`Path::is_absolute` false on `..`, no control bytes, no
9996        // backslash, no `<` / `>`, no `|`, no `;`, doesn't end in `/`).
9997        // The lacre embedded the value verbatim, the resolver folded it
9998        // through `Path::join` looking for a literal `./../caixa-teia &
9999        // sleep 1` subdirectory, and the failure surfaced at resolve
10000        // time with a non-self-locating `No such file or directory`
10001        // error. The new arm moves the rejection to validate time and
10002        // names the offending dep + caminho verbatim.
10003        let d = dep_with_fonte(DepSource::Path {
10004            caminho: "../caixa-teia & sleep 1".into(),
10005        });
10006        let err = d.validate().unwrap_err();
10007        let DepError::FonteCaminhoShellBackground { nome, caminho } = err else {
10008            panic!("expected FonteCaminhoShellBackground, got {err:?}");
10009        };
10010        assert_eq!(nome, "caixa-teia");
10011        assert_eq!(caminho, "../caixa-teia & sleep 1");
10012    }
10013
10014    #[test]
10015    fn validate_rejects_path_fonte_with_caminho_carrying_leading_ampersand() {
10016        // Leading-position `&` shape (`"&../caixa-teia"` — the
10017        // degenerate "I forgot the prior command side of the
10018        // background terminator" idiom). Pinned separately from the
10019        // embedded-byte shape so the gate covers every position, not
10020        // only mid-path.
10021        let d = dep_with_fonte(DepSource::Path {
10022            caminho: "&../caixa-teia".into(),
10023        });
10024        let err = d.validate().unwrap_err();
10025        assert!(
10026            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
10027            "got {err:?}",
10028        );
10029    }
10030
10031    #[test]
10032    fn validate_rejects_path_fonte_with_caminho_carrying_double_ampersand() {
10033        // The logical-AND `&&` shape (`"../caixa-teia && make"` — the
10034        // canonical "I copied a `cd path && make` build chain" idiom
10035        // every Makefile / shell-script wraps). The arm fires on the
10036        // first `&` encountered; pinned so a future arm that tries to
10037        // distinguish `&` from `&&` doesn't break the broader contract.
10038        let d = dep_with_fonte(DepSource::Path {
10039            caminho: "../caixa-teia && make".into(),
10040        });
10041        let err = d.validate().unwrap_err();
10042        assert!(
10043            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
10044            "got {err:?}",
10045        );
10046    }
10047
10048    #[test]
10049    fn validate_accepts_path_fonte_with_caminho_carrying_no_ampersand() {
10050        // The positive-control pin: the gate targets only `&`, never
10051        // adjacent printable ASCII or POSIX-valid bytes. The canonical
10052        // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
10053        // pathed variant with adjacent printable punctuation
10054        // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
10055        // cleanly so the gate doesn't widen to a "no printable
10056        // punctuation anywhere" sweep that would defeat the entire
10057        // path-fonte author surface.
10058        let d = dep_with_fonte(DepSource::Path {
10059            caminho: "../caixa-teia/sub-dir.v2".into(),
10060        });
10061        d.validate().unwrap();
10062    }
10063
10064    #[test]
10065    fn fonte_caminho_shell_semicolon_fires_before_shell_background() {
10066        // Cascade pin on the immediate-predecessor arm: a value carrying
10067        // both `;` and `&` (`"../caixa-teia; rm & sleep"` — the
10068        // canonical "I pasted a `cmd; cleanup & sleep` chain" footgun)
10069        // routes through `FonteCaminhoShellSemicolon` not
10070        // `FonteCaminhoShellBackground`. The sequential-command-
10071        // separator paste is the more common shell-history paste idiom
10072        // on every probe-as-both value (an author who removes the `;`
10073        // typically also drops the trailing `& sleep` since both are
10074        // paste-from-shell-history artifacts) — same cascade discipline
10075        // every prior `:caminho` arm establishes.
10076        let d = dep_with_fonte(DepSource::Path {
10077            caminho: "../caixa-teia; rm & sleep".into(),
10078        });
10079        let err = d.validate().unwrap_err();
10080        assert!(
10081            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
10082            "got {err:?}",
10083        );
10084    }
10085
10086    #[test]
10087    fn fonte_caminho_shell_pipe_fires_before_shell_background() {
10088        // Cascade pin on the upstream shell-pipe arm: a value carrying
10089        // both `|` and `&` (`"../caixa-teia | tee & sleep"` — the
10090        // canonical "I pasted a `cmd | tee & sleep` background-pipeline
10091        // chain" footgun) routes through `FonteCaminhoShellPipe` not
10092        // `FonteCaminhoShellBackground`. The pipeline-tail paste is the
10093        // load-bearing root-cause edit on every probe-as-both value.
10094        let d = dep_with_fonte(DepSource::Path {
10095            caminho: "../caixa-teia | tee & sleep".into(),
10096        });
10097        let err = d.validate().unwrap_err();
10098        assert!(
10099            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10100            "got {err:?}",
10101        );
10102    }
10103
10104    #[test]
10105    fn fonte_caminho_shell_redirection_fires_before_shell_background() {
10106        // Cascade pin on the upstream shell-redirection arm: a value
10107        // carrying both `>` and `&` (`"../caixa-teia>log & sleep"` —
10108        // the canonical "I pasted a `cmd > log & sleep` background-
10109        // redirect chain" footgun) routes through
10110        // `FonteCaminhoShellRedirection` not
10111        // `FonteCaminhoShellBackground`. The input/output redirection
10112        // metachar carries the more self-locating `byte: u8` payload
10113        // (it names which of `<` or `>` triggered), so the prior arm
10114        // wins on every probe-as-both value.
10115        let d = dep_with_fonte(DepSource::Path {
10116            caminho: "../caixa-teia>log & sleep".into(),
10117        });
10118        let err = d.validate().unwrap_err();
10119        assert!(
10120            matches!(
10121                err,
10122                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
10123            ),
10124            "got {err:?}",
10125        );
10126    }
10127
10128    #[test]
10129    fn fonte_caminho_backslash_fires_before_shell_background() {
10130        // Cascade pin on the upstream backslash arm: a value carrying
10131        // both `\` and `&` (`"..\caixa-teia & sleep"` — the canonical
10132        // "I pasted a Windows-shell `cd ..\path & sleep` background-
10133        // launch chain") routes through `FonteCaminhoBackslash` not
10134        // `FonteCaminhoShellBackground`. The cross-host-OS-separator
10135        // divergence is the load-bearing axis on every probe-as-both
10136        // value (an author who removes the `\` is the root-cause edit;
10137        // the `&` falls away in the same edit since it's downstream of
10138        // the Windows-shell convention).
10139        let d = dep_with_fonte(DepSource::Path {
10140            caminho: "..\\caixa-teia & sleep".into(),
10141        });
10142        let err = d.validate().unwrap_err();
10143        assert!(
10144            matches!(err, DepError::FonteCaminhoBackslash { .. }),
10145            "got {err:?}",
10146        );
10147    }
10148
10149    #[test]
10150    fn fonte_caminho_control_char_fires_before_shell_background() {
10151        // Cascade pin on the embedded-control-byte arm: a value
10152        // carrying both a control byte and `&` (`"../foo\n&sleep"` —
10153        // the canonical paste-from-multiline-doc footgun where a
10154        // newline landed mid-caminho) routes through
10155        // `FonteCaminhoControlChar` not `FonteCaminhoShellBackground`.
10156        // The POSIX-syscall-rejected-byte / NUL-`CString::new`-fail
10157        // diagnostic is the load-bearing axis on every value that
10158        // probes positive for both — mirrors the cascade discipline on
10159        // every prior arm.
10160        let d = dep_with_fonte(DepSource::Path {
10161            caminho: "../foo\n&sleep".into(),
10162        });
10163        let err = d.validate().unwrap_err();
10164        assert!(
10165            matches!(err, DepError::FonteCaminhoControlChar { .. }),
10166            "got {err:?}",
10167        );
10168    }
10169
10170    #[test]
10171    fn fonte_caminho_absolute_fires_before_shell_background() {
10172        // Cascade pin on the load-bearing leading-byte arm: a leading
10173        // `/` value with embedded `&` (`"/etc/passwd & sleep"`) routes
10174        // through `FonteCaminhoAbsolute` not
10175        // `FonteCaminhoShellBackground` — the host-layout-leak
10176        // diagnostic is the load-bearing axis, the `&` byte is the
10177        // secondary observation. Same precedence logic as every prior
10178        // leading-byte arm.
10179        let d = dep_with_fonte(DepSource::Path {
10180            caminho: "/etc/passwd & sleep".into(),
10181        });
10182        let err = d.validate().unwrap_err();
10183        assert!(
10184            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10185            "got {err:?}",
10186        );
10187    }
10188
10189    #[test]
10190    fn fonte_caminho_shell_background_fires_before_trailing_slash() {
10191        // Cascade pin on the immediate-successor arm: a value carrying
10192        // both `&` and a trailing `/` (`"../foo&sleep/"` — the
10193        // canonical "I tab-completed a path that already had a `&
10194        // sleep` background-launch tail" footgun) routes through
10195        // `FonteCaminhoShellBackground` not `FonteCaminhoTrailingSlash`.
10196        // The embedded shell-metachar is the more semantic-locating
10197        // axis (an author who removes the `&` typically also drops
10198        // the trailing separator since both are paste-from-shell
10199        // artifacts).
10200        let d = dep_with_fonte(DepSource::Path {
10201            caminho: "../foo&sleep/".into(),
10202        });
10203        let err = d.validate().unwrap_err();
10204        assert!(
10205            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
10206            "got {err:?}",
10207        );
10208    }
10209
10210    #[test]
10211    fn fonte_caminho_shell_background_diagnostic_carries_offending_dep_and_caminho() {
10212        // Diagnostic-shape pin (peer with
10213        // `fonte_caminho_shell_semicolon_diagnostic_carries_offending_dep_and_caminho`
10214        // on the closest single-byte peer arm): the error's Display
10215        // surfaces the offending `:nome` and the offending `:caminho`
10216        // verbatim, and names the shell-background / logical-AND
10217        // footgun explicitly so a `feira lint` run can render the
10218        // diagnostic without re-parsing.
10219        let d = dep_with_fonte(DepSource::Path {
10220            caminho: "../caixa-teia & sleep 1".into(),
10221        });
10222        let rendered = d.validate().unwrap_err().to_string();
10223        assert!(
10224            rendered.contains("caixa-teia"),
10225            "diagnostic must name the offending dep: {rendered}",
10226        );
10227        assert!(
10228            rendered.contains("../caixa-teia & sleep 1"),
10229            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10230        );
10231        assert!(
10232            rendered.contains('&'),
10233            "diagnostic must reference the ampersand footgun: {rendered:?}",
10234        );
10235        assert!(
10236            rendered.contains("background") || rendered.contains("list-AND"),
10237            "diagnostic must name the shell-background / logical-AND footgun: {rendered:?}",
10238        );
10239    }
10240
10241    #[test]
10242    fn validate_rejects_path_fonte_with_caminho_carrying_backtick() {
10243        // The fail-before-pass-after pin for the canonical shell-
10244        // command-substitution paste footgun: an author copies a
10245        // POSIX legacy backticked one-liner (`"../caixa-teia/`whoami`"`
10246        // — the canonical "I pasted a path that included a `pwd`
10247        // / `whoami` / `date` legacy command-substitution expansion
10248        // out of a shell-history block") and silently passed every
10249        // prior arm (`Path::is_absolute` false on `..`, no control
10250        // bytes, no `\`, no `<` / `>`, no `|`, no `;`, no `&`, doesn't
10251        // end in `/`). The lacre embedded the value verbatim, the
10252        // resolver folded it through `Path::join` looking for a
10253        // literal `./../caixa-teia/`whoami`` subdirectory, and the
10254        // failure surfaced at resolve time with a non-self-locating
10255        // `No such file or directory` error. The new arm moves the
10256        // rejection to validate time and names the offending dep +
10257        // caminho verbatim.
10258        let d = dep_with_fonte(DepSource::Path {
10259            caminho: "../caixa-teia/`whoami`".into(),
10260        });
10261        let err = d.validate().unwrap_err();
10262        let DepError::FonteCaminhoShellCommandSubstitution { nome, caminho } = err else {
10263            panic!("expected FonteCaminhoShellCommandSubstitution, got {err:?}");
10264        };
10265        assert_eq!(nome, "caixa-teia");
10266        assert_eq!(caminho, "../caixa-teia/`whoami`");
10267    }
10268
10269    #[test]
10270    fn validate_rejects_path_fonte_with_caminho_carrying_leading_backtick() {
10271        // Leading-position backtick shape (``"`pwd`/caixa-teia"`` —
10272        // the canonical `<backtick>pwd<backtick>/path` working-
10273        // directory expansion shape every shell-side path-composition
10274        // idiom carries). Pinned separately from the embedded-byte
10275        // shape so the gate covers every position, not only mid-path.
10276        let d = dep_with_fonte(DepSource::Path {
10277            caminho: "`pwd`/caixa-teia".into(),
10278        });
10279        let err = d.validate().unwrap_err();
10280        assert!(
10281            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
10282            "got {err:?}",
10283        );
10284    }
10285
10286    #[test]
10287    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_backtick() {
10288        // Trailing-position backtick shape (`"../caixa-teia`"` — the
10289        // degenerate "I selected an unbalanced backtick out of a
10290        // shell-history block" idiom that probes for the cascade's
10291        // last-byte handling). The trailing-`/` arm fires only on
10292        // last-byte `/`; an unbalanced trailing backtick must route
10293        // through this arm regardless of position.
10294        let d = dep_with_fonte(DepSource::Path {
10295            caminho: "../caixa-teia`".into(),
10296        });
10297        let err = d.validate().unwrap_err();
10298        assert!(
10299            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
10300            "got {err:?}",
10301        );
10302    }
10303
10304    #[test]
10305    fn validate_rejects_path_fonte_with_caminho_carrying_balanced_backtick_pair() {
10306        // The canonical balanced-pair shape (``"../<backtick>cat
10307        // /etc/passwd<backtick>"`` — the canonical CWE-78 shell-
10308        // command-injection paste idiom every shell-side hardening
10309        // guide enumerates first). The arm fires on the first
10310        // backtick encountered; pinned so a future arm that tries to
10311        // distinguish the opening from the closing byte doesn't break
10312        // the broader contract.
10313        let d = dep_with_fonte(DepSource::Path {
10314            caminho: "../`cat /etc/passwd`".into(),
10315        });
10316        let err = d.validate().unwrap_err();
10317        assert!(
10318            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
10319            "got {err:?}",
10320        );
10321    }
10322
10323    #[test]
10324    fn validate_accepts_path_fonte_with_caminho_carrying_no_backtick() {
10325        // The positive-control pin: the gate targets only the
10326        // backtick byte, never adjacent printable ASCII or POSIX-
10327        // valid bytes. The canonical relative POSIX path
10328        // (`"../caixa-teia"`) and a nested deeply-pathed variant with
10329        // adjacent printable punctuation
10330        // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
10331        // cleanly so the gate doesn't widen to a "no printable
10332        // punctuation anywhere" sweep that would defeat the entire
10333        // path-fonte author surface.
10334        let d = dep_with_fonte(DepSource::Path {
10335            caminho: "../caixa-teia/sub-dir.v2".into(),
10336        });
10337        d.validate().unwrap();
10338    }
10339
10340    #[test]
10341    fn fonte_caminho_shell_background_fires_before_shell_command_substitution() {
10342        // Cascade pin on the immediate-predecessor arm: a value
10343        // carrying both `&` and a backtick (``"../caixa-teia &
10344        // <backtick>sleep 1<backtick>"`` — the canonical "I pasted a
10345        // `cmd & <backtick>sleep N<backtick>` background-launch +
10346        // command-substitution chain" footgun) routes through
10347        // `FonteCaminhoShellBackground` not
10348        // `FonteCaminhoShellCommandSubstitution`. The background-
10349        // launch tail is the more common shell-history paste idiom
10350        // on every probe-as-both value — same cascade discipline
10351        // every prior `:caminho` arm establishes.
10352        let d = dep_with_fonte(DepSource::Path {
10353            caminho: "../caixa-teia & `sleep 1`".into(),
10354        });
10355        let err = d.validate().unwrap_err();
10356        assert!(
10357            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
10358            "got {err:?}",
10359        );
10360    }
10361
10362    #[test]
10363    fn fonte_caminho_shell_semicolon_fires_before_shell_command_substitution() {
10364        // Cascade pin on the upstream shell-semicolon arm: a value
10365        // carrying both `;` and a backtick (``"../caixa-teia;
10366        // <backtick>whoami<backtick>"`` — the canonical "I pasted a
10367        // `cmd; <backtick>follow-up<backtick>` sequential-chain
10368        // footgun) routes through `FonteCaminhoShellSemicolon` not
10369        // `FonteCaminhoShellCommandSubstitution`. The sequential-
10370        // command-separator paste is the load-bearing root-cause
10371        // edit on every probe-as-both value.
10372        let d = dep_with_fonte(DepSource::Path {
10373            caminho: "../caixa-teia; `whoami`".into(),
10374        });
10375        let err = d.validate().unwrap_err();
10376        assert!(
10377            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
10378            "got {err:?}",
10379        );
10380    }
10381
10382    #[test]
10383    fn fonte_caminho_shell_pipe_fires_before_shell_command_substitution() {
10384        // Cascade pin on the upstream shell-pipe arm: a value
10385        // carrying both `|` and a backtick (``"../caixa-teia |
10386        // <backtick>tee log<backtick>"`` — the canonical pipeline-to-
10387        // command-substitution paste idiom) routes through
10388        // `FonteCaminhoShellPipe` not
10389        // `FonteCaminhoShellCommandSubstitution`. The pipeline-tail
10390        // paste is the load-bearing root-cause edit on every
10391        // probe-as-both value.
10392        let d = dep_with_fonte(DepSource::Path {
10393            caminho: "../caixa-teia | `tee log`".into(),
10394        });
10395        let err = d.validate().unwrap_err();
10396        assert!(
10397            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10398            "got {err:?}",
10399        );
10400    }
10401
10402    #[test]
10403    fn fonte_caminho_shell_redirection_fires_before_shell_command_substitution() {
10404        // Cascade pin on the upstream shell-redirection arm: a value
10405        // carrying both `>` and a backtick (``"../caixa-teia>log
10406        // <backtick>date<backtick>"`` — the canonical "I pasted a
10407        // `cmd > log <backtick>date<backtick>` redirect-plus-
10408        // substitution chain" footgun) routes through
10409        // `FonteCaminhoShellRedirection` not
10410        // `FonteCaminhoShellCommandSubstitution`. The input/output
10411        // redirection metachar carries the more self-locating `byte`
10412        // payload (it names which of `<` or `>` triggered), so the
10413        // prior arm wins on every probe-as-both value.
10414        let d = dep_with_fonte(DepSource::Path {
10415            caminho: "../caixa-teia>log `date`".into(),
10416        });
10417        let err = d.validate().unwrap_err();
10418        assert!(
10419            matches!(
10420                err,
10421                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
10422            ),
10423            "got {err:?}",
10424        );
10425    }
10426
10427    #[test]
10428    fn fonte_caminho_backslash_fires_before_shell_command_substitution() {
10429        // Cascade pin on the upstream backslash arm: a value
10430        // carrying both `\` and a backtick (``"..\caixa-teia
10431        // <backtick>whoami<backtick>"`` — the canonical "I pasted a
10432        // Windows-shell `cd ..\path <backtick>whoami<backtick>`
10433        // chain") routes through `FonteCaminhoBackslash` not
10434        // `FonteCaminhoShellCommandSubstitution`. The cross-host-OS-
10435        // separator divergence is the load-bearing axis on every
10436        // probe-as-both value (an author who removes the `\` is the
10437        // root-cause edit; the backtick falls away in the same edit
10438        // since it's downstream of the Windows-shell convention).
10439        let d = dep_with_fonte(DepSource::Path {
10440            caminho: "..\\caixa-teia `whoami`".into(),
10441        });
10442        let err = d.validate().unwrap_err();
10443        assert!(
10444            matches!(err, DepError::FonteCaminhoBackslash { .. }),
10445            "got {err:?}",
10446        );
10447    }
10448
10449    #[test]
10450    fn fonte_caminho_control_char_fires_before_shell_command_substitution() {
10451        // Cascade pin on the embedded-control-byte arm: a value
10452        // carrying both a control byte and a backtick (`"../foo\n
10453        // `whoami`"` — the canonical paste-from-multiline-doc
10454        // footgun where a newline landed mid-caminho between two
10455        // paste fragments) routes through `FonteCaminhoControlChar`
10456        // not `FonteCaminhoShellCommandSubstitution`. The POSIX-
10457        // syscall-rejected-byte / NUL-`CString::new`-fail diagnostic
10458        // is the load-bearing axis on every value that probes
10459        // positive for both — mirrors the cascade discipline on
10460        // every prior arm.
10461        let d = dep_with_fonte(DepSource::Path {
10462            caminho: "../foo\n`whoami`".into(),
10463        });
10464        let err = d.validate().unwrap_err();
10465        assert!(
10466            matches!(err, DepError::FonteCaminhoControlChar { .. }),
10467            "got {err:?}",
10468        );
10469    }
10470
10471    #[test]
10472    fn fonte_caminho_absolute_fires_before_shell_command_substitution() {
10473        // Cascade pin on the load-bearing leading-byte arm: a
10474        // leading `/` value with embedded backtick (``"/etc/passwd
10475        // <backtick>whoami<backtick>"``) routes through
10476        // `FonteCaminhoAbsolute` not
10477        // `FonteCaminhoShellCommandSubstitution` — the host-layout-
10478        // leak diagnostic is the load-bearing axis, the backtick
10479        // byte is the secondary observation. Same precedence logic
10480        // as every prior leading-byte arm.
10481        let d = dep_with_fonte(DepSource::Path {
10482            caminho: "/etc/passwd `whoami`".into(),
10483        });
10484        let err = d.validate().unwrap_err();
10485        assert!(
10486            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10487            "got {err:?}",
10488        );
10489    }
10490
10491    #[test]
10492    fn fonte_caminho_shell_command_substitution_fires_before_trailing_slash() {
10493        // Cascade pin on the immediate-successor arm: a value
10494        // carrying both a backtick and a trailing `/`
10495        // (``"../`whoami`/"`` — the canonical "I tab-completed a
10496        // path that already had a backticked `whoami` substitution
10497        // tail" footgun) routes through
10498        // `FonteCaminhoShellCommandSubstitution` not
10499        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
10500        // is the more semantic-locating axis (an author who removes
10501        // the backtick typically also drops the trailing separator
10502        // since both are paste-from-shell artifacts).
10503        let d = dep_with_fonte(DepSource::Path {
10504            caminho: "../`whoami`/".into(),
10505        });
10506        let err = d.validate().unwrap_err();
10507        assert!(
10508            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
10509            "got {err:?}",
10510        );
10511    }
10512
10513    #[test]
10514    fn fonte_caminho_shell_command_substitution_diagnostic_carries_offending_dep_and_caminho() {
10515        // Diagnostic-shape pin (peer with
10516        // `fonte_caminho_shell_background_diagnostic_carries_offending_dep_and_caminho`
10517        // on the closest single-byte peer arm): the error's Display
10518        // surfaces the offending `:nome` and the offending `:caminho`
10519        // verbatim, and names the shell-command-substitution footgun
10520        // explicitly so a `feira lint` run can render the diagnostic
10521        // without re-parsing.
10522        let d = dep_with_fonte(DepSource::Path {
10523            caminho: "../caixa-teia/`whoami`".into(),
10524        });
10525        let rendered = d.validate().unwrap_err().to_string();
10526        assert!(
10527            rendered.contains("caixa-teia"),
10528            "diagnostic must name the offending dep: {rendered}",
10529        );
10530        assert!(
10531            rendered.contains("../caixa-teia/`whoami`"),
10532            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10533        );
10534        assert!(
10535            rendered.contains('`'),
10536            "diagnostic must reference the backtick footgun: {rendered:?}",
10537        );
10538        assert!(
10539            rendered.contains("command-substitution"),
10540            "diagnostic must name the shell-command-substitution footgun: {rendered:?}",
10541        );
10542    }
10543
10544    #[test]
10545    fn validate_rejects_path_fonte_with_caminho_carrying_star_glob() {
10546        // The fail-before-pass-after pin for the canonical pathname-
10547        // expansion paste footgun: an author copies an `ls
10548        // ../caixa-teia/*` shell-listing tail into the `:caminho`
10549        // slot and silently passes every prior arm
10550        // (`Path::is_absolute` false on `..`, no control bytes, no
10551        // `\`, no `<` / `>`, no `|`, no `;`, no `&`, no backtick,
10552        // doesn't end in `/`). The lacre embedded the value
10553        // verbatim, the resolver folded it through `Path::join`
10554        // looking for a literal `./../caixa-teia/*` subdirectory,
10555        // and the failure surfaced at resolve time with a non-self-
10556        // locating `No such file or directory` error. The new arm
10557        // moves the rejection to validate time and names the
10558        // offending dep + caminho + byte verbatim.
10559        let d = dep_with_fonte(DepSource::Path {
10560            caminho: "../caixa-teia/*".into(),
10561        });
10562        let err = d.validate().unwrap_err();
10563        let DepError::FonteCaminhoShellGlob {
10564            nome,
10565            caminho,
10566            byte,
10567        } = err
10568        else {
10569            panic!("expected FonteCaminhoShellGlob, got {err:?}");
10570        };
10571        assert_eq!(nome, "caixa-teia");
10572        assert_eq!(caminho, "../caixa-teia/*");
10573        assert_eq!(byte, b'*');
10574    }
10575
10576    #[test]
10577    fn validate_rejects_path_fonte_with_caminho_carrying_question_glob() {
10578        // The symmetric single-char-wildcard paste shape
10579        // (`"../foo?"` — the canonical "I copied a `rm foo?` line
10580        // out of shell history" idiom). Pinned separately from the
10581        // `*` shape so the gate's contract is "any `*` or `?`
10582        // anywhere", not single-byte coverage.
10583        let d = dep_with_fonte(DepSource::Path {
10584            caminho: "../foo?".into(),
10585        });
10586        let err = d.validate().unwrap_err();
10587        let DepError::FonteCaminhoShellGlob { byte, .. } = err else {
10588            panic!("expected FonteCaminhoShellGlob, got {err:?}");
10589        };
10590        assert_eq!(byte, b'?');
10591    }
10592
10593    #[test]
10594    fn validate_rejects_path_fonte_with_caminho_carrying_leading_star_glob() {
10595        // Leading-position `*` shape (`"*/caixa-teia"` — the
10596        // degenerate "I selected only the wildcard prefix out of a
10597        // shell-glob expression" idiom). Pinned separately from the
10598        // embedded-byte shapes so the gate covers every position,
10599        // not only mid-path.
10600        let d = dep_with_fonte(DepSource::Path {
10601            caminho: "*/caixa-teia".into(),
10602        });
10603        let err = d.validate().unwrap_err();
10604        assert!(
10605            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
10606            "got {err:?}",
10607        );
10608    }
10609
10610    #[test]
10611    fn validate_rejects_path_fonte_with_caminho_carrying_double_star_recursive_glob() {
10612        // The bash/zsh `globstar` recursive-glob shape
10613        // (`"../caixa-teia/**/foo"` — the canonical "I copied a
10614        // `find ../caixa-teia/**/foo` recursive expansion" idiom).
10615        // The arm fires on the first `*` encountered; pinned so a
10616        // future arm that tries to distinguish single `*` from
10617        // double `**` doesn't break the broader contract.
10618        let d = dep_with_fonte(DepSource::Path {
10619            caminho: "../caixa-teia/**/foo".into(),
10620        });
10621        let err = d.validate().unwrap_err();
10622        assert!(
10623            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
10624            "got {err:?}",
10625        );
10626    }
10627
10628    #[test]
10629    fn validate_rejects_path_fonte_with_caminho_carrying_dotted_extension_glob() {
10630        // The canonical extension-glob shape (`"../caixa-teia/*.lisp"`
10631        // — the "I selected `*.lisp` to mean every Lisp source file
10632        // in the dep root" footgun the prior arms structurally
10633        // cannot catch since `.` is a POSIX-valid path-component
10634        // byte). Pinned so the gate's contract covers the most
10635        // idiomatic glob-paste shape every author meets first.
10636        let d = dep_with_fonte(DepSource::Path {
10637            caminho: "../caixa-teia/*.lisp".into(),
10638        });
10639        let err = d.validate().unwrap_err();
10640        assert!(
10641            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
10642            "got {err:?}",
10643        );
10644    }
10645
10646    #[test]
10647    fn validate_accepts_path_fonte_with_caminho_carrying_no_glob() {
10648        // The positive-control pin: the gate targets only `*` /
10649        // `?`, never adjacent printable ASCII or POSIX-valid bytes.
10650        // The canonical relative POSIX path (`"../caixa-teia"`) and
10651        // a nested deeply-pathed variant with adjacent printable
10652        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
10653        // to validate cleanly so the gate doesn't widen to a "no
10654        // printable punctuation anywhere" sweep that would defeat
10655        // the entire path-fonte author surface.
10656        let d = dep_with_fonte(DepSource::Path {
10657            caminho: "../caixa-teia/sub-dir.v2".into(),
10658        });
10659        d.validate().unwrap();
10660    }
10661
10662    #[test]
10663    fn fonte_caminho_shell_command_substitution_fires_before_shell_glob() {
10664        // Cascade pin on the immediate-predecessor arm: a value
10665        // carrying both a backtick and `*` (``"../`whoami`/*"`` —
10666        // the canonical "I pasted a `cd <backtick>whoami<backtick>/*`
10667        // command-substitution + glob chain") routes through
10668        // `FonteCaminhoShellCommandSubstitution` not
10669        // `FonteCaminhoShellGlob`. The CWE-78 shell-command-
10670        // injection vector is the load-bearing root-cause edit on
10671        // every probe-as-both value — same cascade discipline every
10672        // prior `:caminho` arm establishes.
10673        let d = dep_with_fonte(DepSource::Path {
10674            caminho: "../`whoami`/*".into(),
10675        });
10676        let err = d.validate().unwrap_err();
10677        assert!(
10678            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
10679            "got {err:?}",
10680        );
10681    }
10682
10683    #[test]
10684    fn fonte_caminho_shell_background_fires_before_shell_glob() {
10685        // Cascade pin on the upstream shell-background arm: a value
10686        // carrying both `&` and `*` (`"../caixa-teia & ls /*"` — the
10687        // canonical "I pasted a `cmd & ls /*` background + glob
10688        // chain" footgun) routes through `FonteCaminhoShellBackground`
10689        // not `FonteCaminhoShellGlob`. The background-launch tail is
10690        // the load-bearing root-cause edit on every probe-as-both
10691        // value.
10692        let d = dep_with_fonte(DepSource::Path {
10693            caminho: "../caixa-teia & ls /*".into(),
10694        });
10695        let err = d.validate().unwrap_err();
10696        assert!(
10697            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
10698            "got {err:?}",
10699        );
10700    }
10701
10702    #[test]
10703    fn fonte_caminho_shell_semicolon_fires_before_shell_glob() {
10704        // Cascade pin on the upstream shell-semicolon arm: a value
10705        // carrying both `;` and `*` (`"../caixa-teia; rm *"` — the
10706        // canonical sequential-cleanup + glob paste idiom) routes
10707        // through `FonteCaminhoShellSemicolon` not
10708        // `FonteCaminhoShellGlob`. The sequential-command-separator
10709        // paste is the load-bearing root-cause edit on every
10710        // probe-as-both value.
10711        let d = dep_with_fonte(DepSource::Path {
10712            caminho: "../caixa-teia; rm *".into(),
10713        });
10714        let err = d.validate().unwrap_err();
10715        assert!(
10716            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
10717            "got {err:?}",
10718        );
10719    }
10720
10721    #[test]
10722    fn fonte_caminho_shell_pipe_fires_before_shell_glob() {
10723        // Cascade pin on the upstream shell-pipe arm: a value
10724        // carrying both `|` and `*` (`"../caixa-teia | ls *"` — the
10725        // canonical pipeline-to-glob paste idiom) routes through
10726        // `FonteCaminhoShellPipe` not `FonteCaminhoShellGlob`. The
10727        // pipeline-tail paste is the load-bearing root-cause edit
10728        // on every probe-as-both value.
10729        let d = dep_with_fonte(DepSource::Path {
10730            caminho: "../caixa-teia | ls *".into(),
10731        });
10732        let err = d.validate().unwrap_err();
10733        assert!(
10734            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10735            "got {err:?}",
10736        );
10737    }
10738
10739    #[test]
10740    fn fonte_caminho_shell_redirection_fires_before_shell_glob() {
10741        // Cascade pin on the upstream shell-redirection arm: a value
10742        // carrying both `>` and `*` (`"../caixa-teia>log *"` — the
10743        // canonical "I pasted a `cmd > log *` redirect-plus-glob
10744        // chain" footgun) routes through
10745        // `FonteCaminhoShellRedirection` not `FonteCaminhoShellGlob`.
10746        // The input/output redirection metachar carries the more
10747        // self-locating `byte` payload (it names which of `<` or `>`
10748        // triggered), so the prior arm wins on every probe-as-both
10749        // value.
10750        let d = dep_with_fonte(DepSource::Path {
10751            caminho: "../caixa-teia>log *".into(),
10752        });
10753        let err = d.validate().unwrap_err();
10754        assert!(
10755            matches!(
10756                err,
10757                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
10758            ),
10759            "got {err:?}",
10760        );
10761    }
10762
10763    #[test]
10764    fn fonte_caminho_backslash_fires_before_shell_glob() {
10765        // Cascade pin on the upstream backslash arm: a value
10766        // carrying both `\` and `*` (`"..\caixa-teia\*"` — the
10767        // canonical "I pasted a Windows-shell `cd ..\path\*` glob
10768        // expression" footgun) routes through
10769        // `FonteCaminhoBackslash` not `FonteCaminhoShellGlob`. The
10770        // cross-host-OS-separator divergence is the load-bearing
10771        // axis on every probe-as-both value (an author who removes
10772        // the `\` is the root-cause edit; the `*` falls away in the
10773        // same edit since it's downstream of the Windows-shell
10774        // convention).
10775        let d = dep_with_fonte(DepSource::Path {
10776            caminho: "..\\caixa-teia\\*".into(),
10777        });
10778        let err = d.validate().unwrap_err();
10779        assert!(
10780            matches!(err, DepError::FonteCaminhoBackslash { .. }),
10781            "got {err:?}",
10782        );
10783    }
10784
10785    #[test]
10786    fn fonte_caminho_control_char_fires_before_shell_glob() {
10787        // Cascade pin on the embedded-control-byte arm: a value
10788        // carrying both a control byte and `*` (`"../foo\n*"` — the
10789        // canonical paste-from-multiline-doc footgun where a
10790        // newline landed mid-caminho between two paste fragments)
10791        // routes through `FonteCaminhoControlChar` not
10792        // `FonteCaminhoShellGlob`. The POSIX-syscall-rejected-byte /
10793        // NUL-`CString::new`-fail diagnostic is the load-bearing
10794        // axis on every value that probes positive for both —
10795        // mirrors the cascade discipline on every prior arm.
10796        let d = dep_with_fonte(DepSource::Path {
10797            caminho: "../foo\n*".into(),
10798        });
10799        let err = d.validate().unwrap_err();
10800        assert!(
10801            matches!(err, DepError::FonteCaminhoControlChar { .. }),
10802            "got {err:?}",
10803        );
10804    }
10805
10806    #[test]
10807    fn fonte_caminho_absolute_fires_before_shell_glob() {
10808        // Cascade pin on the load-bearing leading-byte arm: a
10809        // leading `/` value with embedded `*` (`"/etc/*"`) routes
10810        // through `FonteCaminhoAbsolute` not `FonteCaminhoShellGlob`
10811        // — the host-layout-leak diagnostic is the load-bearing
10812        // axis, the glob byte is the secondary observation. Same
10813        // precedence logic as every prior leading-byte arm.
10814        let d = dep_with_fonte(DepSource::Path {
10815            caminho: "/etc/*".into(),
10816        });
10817        let err = d.validate().unwrap_err();
10818        assert!(
10819            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10820            "got {err:?}",
10821        );
10822    }
10823
10824    #[test]
10825    fn fonte_caminho_shell_glob_fires_before_trailing_slash() {
10826        // Cascade pin on the immediate-successor arm: a value
10827        // carrying both `*` and a trailing `/` (`"../foo*/"` — the
10828        // canonical "I tab-completed a path that already had a
10829        // glob-expansion tail" footgun) routes through
10830        // `FonteCaminhoShellGlob` not `FonteCaminhoTrailingSlash`.
10831        // The embedded shell-metachar is the more semantic-locating
10832        // axis (an author who removes the `*` typically also drops
10833        // the trailing separator since both are paste-from-shell
10834        // artifacts).
10835        let d = dep_with_fonte(DepSource::Path {
10836            caminho: "../foo*/".into(),
10837        });
10838        let err = d.validate().unwrap_err();
10839        assert!(
10840            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
10841            "got {err:?}",
10842        );
10843    }
10844
10845    #[test]
10846    fn fonte_caminho_shell_glob_diagnostic_carries_offending_dep_caminho_and_byte() {
10847        // Diagnostic-shape pin (peer with
10848        // `fonte_caminho_shell_redirection_diagnostic_*` on the
10849        // closest two-byte peer arm): the error's Display surfaces
10850        // the offending `:nome`, the offending `:caminho` verbatim,
10851        // the offending byte's hex / character form, and names the
10852        // shell-glob / pathname-expansion footgun explicitly so a
10853        // `feira lint` run can render the diagnostic without
10854        // re-parsing.
10855        let d = dep_with_fonte(DepSource::Path {
10856            caminho: "../caixa-teia/*.lisp".into(),
10857        });
10858        let rendered = d.validate().unwrap_err().to_string();
10859        assert!(
10860            rendered.contains("caixa-teia"),
10861            "diagnostic must name the offending dep: {rendered}",
10862        );
10863        assert!(
10864            rendered.contains("../caixa-teia/*.lisp"),
10865            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10866        );
10867        assert!(
10868            rendered.contains("0x2a"),
10869            "diagnostic must surface the offending byte hex: {rendered:?}",
10870        );
10871        assert!(
10872            rendered.contains("glob"),
10873            "diagnostic must name the shell-glob footgun: {rendered:?}",
10874        );
10875        assert!(
10876            rendered.contains("pathname-expansion"),
10877            "diagnostic must reference the POSIX pathname-expansion vocabulary: {rendered:?}",
10878        );
10879    }
10880
10881    #[test]
10882    fn validate_rejects_path_fonte_with_caminho_carrying_modern_command_substitution() {
10883        // The fail-before-pass-after pin for the canonical modern-Bourne
10884        // command-substitution paste footgun: an author copies a
10885        // `cd ../caixa-teia/$(date)/build` shell-history one-liner whose
10886        // `$(<cmd>)` expansion would land the current date as a
10887        // subdirectory name and silently passed every prior arm
10888        // (`Path::is_absolute` false on `..`, no control bytes, no `\`,
10889        // no `<` / `>`, no `|`, no `;`, no `&`, no backtick, no `*` /
10890        // `?`, doesn't end in `/`; the leading-`$` f4efe9c
10891        // `FonteCaminhoVarExpansion` arm doesn't fire because the `$`
10892        // sits mid-path). The lacre embedded the value verbatim, the
10893        // resolver folded it through `Path::join` looking for a literal
10894        // `./../caixa-teia/$(date)/build` subdirectory, and the failure
10895        // surfaced at resolve time with a non-self-locating `No such
10896        // file or directory` error. The new arm moves the rejection to
10897        // validate time and names the offending dep + caminho + byte
10898        // verbatim. The arm fires on the first `(` encountered (the
10899        // opening byte of `$(date)`).
10900        let d = dep_with_fonte(DepSource::Path {
10901            caminho: "../caixa-teia/$(date)/build".into(),
10902        });
10903        let err = d.validate().unwrap_err();
10904        let DepError::FonteCaminhoShellSubshellGrouping {
10905            nome,
10906            caminho,
10907            byte,
10908        } = err
10909        else {
10910            panic!("expected FonteCaminhoShellSubshellGrouping, got {err:?}");
10911        };
10912        assert_eq!(nome, "caixa-teia");
10913        assert_eq!(caminho, "../caixa-teia/$(date)/build");
10914        assert_eq!(byte, b'(');
10915    }
10916
10917    #[test]
10918    fn validate_rejects_path_fonte_with_caminho_carrying_close_paren() {
10919        // The symmetric close-paren paste shape (`"../caixa-teia)"` —
10920        // the degenerate "I selected an unbalanced closing paren out of
10921        // a shell-history block" idiom that probes for the cascade's
10922        // last-byte handling on a value carrying only the closing byte).
10923        // Pinned separately from the open-paren shape so the gate's
10924        // contract is "any `(` or `)` anywhere", not single-byte
10925        // coverage. Mirrors the peer `validate_rejects_path_fonte_with_\
10926        // caminho_carrying_question_glob` shape on the immediate-
10927        // predecessor `FonteCaminhoShellGlob` arm.
10928        let d = dep_with_fonte(DepSource::Path {
10929            caminho: "../caixa-teia)".into(),
10930        });
10931        let err = d.validate().unwrap_err();
10932        let DepError::FonteCaminhoShellSubshellGrouping { byte, .. } = err else {
10933            panic!("expected FonteCaminhoShellSubshellGrouping, got {err:?}");
10934        };
10935        assert_eq!(byte, b')');
10936    }
10937
10938    #[test]
10939    fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_paren() {
10940        // Leading-position `(` shape (`"(cd foo)/caixa-teia"` — the
10941        // canonical "I selected a `(cd foo)` subshell-grouping prefix
10942        // out of a `(cd foo) && cmd` shell-history one-liner" idiom).
10943        // Pinned separately from the embedded-byte shape so the gate
10944        // covers every position, not only mid-path.
10945        let d = dep_with_fonte(DepSource::Path {
10946            caminho: "(cd foo)/caixa-teia".into(),
10947        });
10948        let err = d.validate().unwrap_err();
10949        assert!(
10950            matches!(
10951                err,
10952                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
10953            ),
10954            "got {err:?}",
10955        );
10956    }
10957
10958    #[test]
10959    fn validate_rejects_path_fonte_with_caminho_carrying_balanced_subshell_grouping_pair() {
10960        // The canonical balanced-pair shape (`"../(pwd)/caixa-teia"`
10961        // — the canonical "I copied a `(pwd)` working-directory-probe
10962        // subshell-grouping idiom every shell-history block carries"
10963        // footgun). The value carries no other cascade-preceding
10964        // shell metachar (`&` / `;` / `|` / `<` / `>` / backtick /
10965        // `*` / `?`) so the arm fires on the first `(` encountered;
10966        // pinned so a future arm that tries to distinguish the
10967        // opening from the closing byte doesn't break the broader
10968        // contract. Mirrors the peer
10969        // `validate_rejects_path_fonte_with_caminho_carrying_balanced_\
10970        // backtick_pair` shape on the upstream `FonteCaminhoShell\
10971        // CommandSubstitution` arm.
10972        let d = dep_with_fonte(DepSource::Path {
10973            caminho: "../(pwd)/caixa-teia".into(),
10974        });
10975        let err = d.validate().unwrap_err();
10976        assert!(
10977            matches!(
10978                err,
10979                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
10980            ),
10981            "got {err:?}",
10982        );
10983    }
10984
10985    #[test]
10986    fn validate_accepts_path_fonte_with_caminho_carrying_no_subshell_grouping() {
10987        // The positive-control pin: the gate targets only `(` / `)`,
10988        // never adjacent printable ASCII or POSIX-valid bytes. The
10989        // canonical relative POSIX path (`"../caixa-teia"`) and a
10990        // nested deeply-pathed variant with adjacent printable
10991        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue to
10992        // validate cleanly so the gate doesn't widen to a "no printable
10993        // punctuation anywhere" sweep that would defeat the entire
10994        // path-fonte author surface.
10995        let d = dep_with_fonte(DepSource::Path {
10996            caminho: "../caixa-teia/sub-dir.v2".into(),
10997        });
10998        d.validate().unwrap();
10999    }
11000
11001    #[test]
11002    fn fonte_caminho_shell_glob_fires_before_shell_subshell_grouping() {
11003        // Cascade pin on the immediate-predecessor arm: a value
11004        // carrying both `*` and `(` (`"../caixa-teia/*(date)"` — the
11005        // canonical "I pasted a glob expansion followed by a
11006        // subshell-grouping tail" footgun) routes through
11007        // `FonteCaminhoShellGlob` not
11008        // `FonteCaminhoShellSubshellGrouping`. The pathname-expansion
11009        // shape is the more common shell-history paste idiom on every
11010        // probe-as-both value — same cascade discipline every prior
11011        // `:caminho` arm establishes.
11012        let d = dep_with_fonte(DepSource::Path {
11013            caminho: "../caixa-teia/*(date)".into(),
11014        });
11015        let err = d.validate().unwrap_err();
11016        assert!(
11017            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
11018            "got {err:?}",
11019        );
11020    }
11021
11022    #[test]
11023    fn fonte_caminho_shell_command_substitution_fires_before_shell_subshell_grouping() {
11024        // Cascade pin on the upstream shell-command-substitution arm: a
11025        // value carrying both a backtick and `(` (``"../`whoami`/$(date)"``
11026        // — the canonical "I pasted a legacy-backtick + modern-paren
11027        // command-substitution chain" footgun) routes through
11028        // `FonteCaminhoShellCommandSubstitution` not
11029        // `FonteCaminhoShellSubshellGrouping`. The CWE-78 shell-
11030        // command-injection vector is the load-bearing root-cause edit
11031        // on every probe-as-both value.
11032        let d = dep_with_fonte(DepSource::Path {
11033            caminho: "../`whoami`/$(date)".into(),
11034        });
11035        let err = d.validate().unwrap_err();
11036        assert!(
11037            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11038            "got {err:?}",
11039        );
11040    }
11041
11042    #[test]
11043    fn fonte_caminho_shell_background_fires_before_shell_subshell_grouping() {
11044        // Cascade pin on the upstream shell-background arm: a value
11045        // carrying both `&` and `(` (`"../caixa-teia & (cd foo)"` —
11046        // the canonical "I pasted a `cmd & (cd foo)` background-launch
11047        // + subshell-grouping chain" footgun) routes through
11048        // `FonteCaminhoShellBackground` not
11049        // `FonteCaminhoShellSubshellGrouping`. The background-launch
11050        // tail is the load-bearing root-cause edit on every probe-as-
11051        // both value.
11052        let d = dep_with_fonte(DepSource::Path {
11053            caminho: "../caixa-teia & (cd foo)".into(),
11054        });
11055        let err = d.validate().unwrap_err();
11056        assert!(
11057            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11058            "got {err:?}",
11059        );
11060    }
11061
11062    #[test]
11063    fn fonte_caminho_shell_semicolon_fires_before_shell_subshell_grouping() {
11064        // Cascade pin on the upstream shell-semicolon arm: a value
11065        // carrying both `;` and `(` (`"../caixa-teia; (cd foo)"` —
11066        // the canonical sequential-cleanup + subshell-grouping paste
11067        // idiom) routes through `FonteCaminhoShellSemicolon` not
11068        // `FonteCaminhoShellSubshellGrouping`. The sequential-command-
11069        // separator paste is the load-bearing root-cause edit on
11070        // every probe-as-both value.
11071        let d = dep_with_fonte(DepSource::Path {
11072            caminho: "../caixa-teia; (cd foo)".into(),
11073        });
11074        let err = d.validate().unwrap_err();
11075        assert!(
11076            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11077            "got {err:?}",
11078        );
11079    }
11080
11081    #[test]
11082    fn fonte_caminho_shell_pipe_fires_before_shell_subshell_grouping() {
11083        // Cascade pin on the upstream shell-pipe arm: a value carrying
11084        // both `|` and `(` (`"../caixa-teia | (tee log)"` — the
11085        // canonical pipeline-to-subshell-grouping paste idiom) routes
11086        // through `FonteCaminhoShellPipe` not
11087        // `FonteCaminhoShellSubshellGrouping`. The pipeline-tail paste
11088        // is the load-bearing root-cause edit on every probe-as-both
11089        // value.
11090        let d = dep_with_fonte(DepSource::Path {
11091            caminho: "../caixa-teia | (tee log)".into(),
11092        });
11093        let err = d.validate().unwrap_err();
11094        assert!(
11095            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11096            "got {err:?}",
11097        );
11098    }
11099
11100    #[test]
11101    fn fonte_caminho_shell_redirection_fires_before_shell_subshell_grouping() {
11102        // Cascade pin on the upstream shell-redirection arm: a value
11103        // carrying both `>` and `(` (`"../caixa-teia>log (cd foo)"` —
11104        // the canonical "I pasted a `cmd > log (cd foo)` redirect-
11105        // plus-subshell-grouping chain" footgun) routes through
11106        // `FonteCaminhoShellRedirection` not
11107        // `FonteCaminhoShellSubshellGrouping`. The input/output
11108        // redirection metachar carries the more self-locating `byte`
11109        // payload (it names which of `<` or `>` triggered), so the
11110        // prior arm wins on every probe-as-both value.
11111        let d = dep_with_fonte(DepSource::Path {
11112            caminho: "../caixa-teia>log (cd foo)".into(),
11113        });
11114        let err = d.validate().unwrap_err();
11115        assert!(
11116            matches!(
11117                err,
11118                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11119            ),
11120            "got {err:?}",
11121        );
11122    }
11123
11124    #[test]
11125    fn fonte_caminho_backslash_fires_before_shell_subshell_grouping() {
11126        // Cascade pin on the upstream backslash arm: a value carrying
11127        // both `\` and `(` (`"..\caixa-teia\(cd foo)"` — the canonical
11128        // "I pasted a Windows-shell `cd ..\path\(cmd)` chain") routes
11129        // through `FonteCaminhoBackslash` not
11130        // `FonteCaminhoShellSubshellGrouping`. The cross-host-OS-
11131        // separator divergence is the load-bearing axis on every
11132        // probe-as-both value (an author who removes the `\` is the
11133        // root-cause edit; the `(` falls away in the same edit since
11134        // it's downstream of the Windows-shell convention).
11135        let d = dep_with_fonte(DepSource::Path {
11136            caminho: "..\\caixa-teia\\(cd foo)".into(),
11137        });
11138        let err = d.validate().unwrap_err();
11139        assert!(
11140            matches!(err, DepError::FonteCaminhoBackslash { .. }),
11141            "got {err:?}",
11142        );
11143    }
11144
11145    #[test]
11146    fn fonte_caminho_control_char_fires_before_shell_subshell_grouping() {
11147        // Cascade pin on the embedded-control-byte arm: a value
11148        // carrying both a control byte and `(` (`"../foo\n(cd bar)"` —
11149        // the canonical paste-from-multiline-doc footgun where a
11150        // newline landed mid-caminho between two paste fragments)
11151        // routes through `FonteCaminhoControlChar` not
11152        // `FonteCaminhoShellSubshellGrouping`. The POSIX-syscall-
11153        // rejected-byte / NUL-`CString::new`-fail diagnostic is the
11154        // load-bearing axis on every value that probes positive for
11155        // both — mirrors the cascade discipline on every prior arm.
11156        let d = dep_with_fonte(DepSource::Path {
11157            caminho: "../foo\n(cd bar)".into(),
11158        });
11159        let err = d.validate().unwrap_err();
11160        assert!(
11161            matches!(err, DepError::FonteCaminhoControlChar { .. }),
11162            "got {err:?}",
11163        );
11164    }
11165
11166    #[test]
11167    fn fonte_caminho_absolute_fires_before_shell_subshell_grouping() {
11168        // Cascade pin on the load-bearing leading-byte arm: a leading
11169        // `/` value with embedded `(` (`"/etc/(cd foo)"`) routes
11170        // through `FonteCaminhoAbsolute` not
11171        // `FonteCaminhoShellSubshellGrouping` — the host-layout-leak
11172        // diagnostic is the load-bearing axis, the subshell-grouping
11173        // byte is the secondary observation. Same precedence logic as
11174        // every prior leading-byte arm.
11175        let d = dep_with_fonte(DepSource::Path {
11176            caminho: "/etc/(cd foo)".into(),
11177        });
11178        let err = d.validate().unwrap_err();
11179        assert!(
11180            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11181            "got {err:?}",
11182        );
11183    }
11184
11185    #[test]
11186    fn fonte_caminho_var_expansion_fires_before_shell_subshell_grouping() {
11187        // Cascade pin on the upstream leading-`$` var-expansion arm: a
11188        // value carrying both a leading `$` and a `(` (`"$(date)/\
11189        // caixa-teia"` — the canonical "I pasted a `$(date)` modern-
11190        // command-substitution at the head of a sibling-workspace
11191        // path" footgun) routes through `FonteCaminhoVarExpansion` not
11192        // `FonteCaminhoShellSubshellGrouping`. The leading-byte
11193        // shell-variable-expansion is the more self-locating diagnostic
11194        // on values that probe as both — same load-bearing-leading-
11195        // byte cascade discipline every prior `:caminho` arm
11196        // establishes. Closing both halves of `$(<cmd>)` structurally
11197        // (leading `$` here, trailing `)` on the new arm) excludes the
11198        // entire modern Bourne command-substitution surface from the
11199        // typed `:caminho` accepted set; the cascade preserves the
11200        // narrower leading-byte diagnostic on values that probe both
11201        // halves at the canonical leading position.
11202        let d = dep_with_fonte(DepSource::Path {
11203            caminho: "$(date)/caixa-teia".into(),
11204        });
11205        let err = d.validate().unwrap_err();
11206        assert!(
11207            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
11208            "got {err:?}",
11209        );
11210    }
11211
11212    #[test]
11213    fn fonte_caminho_shell_subshell_grouping_fires_before_trailing_slash() {
11214        // Cascade pin on the immediate-successor arm: a value carrying
11215        // both `(` and a trailing `/` (`"../(cd foo)/"` — the canonical
11216        // "I tab-completed a path that already had a subshell-grouping
11217        // expansion tail" footgun) routes through
11218        // `FonteCaminhoShellSubshellGrouping` not
11219        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
11220        // the more semantic-locating axis (an author who removes the
11221        // `(` typically also drops the trailing separator since both
11222        // are paste-from-shell artifacts).
11223        let d = dep_with_fonte(DepSource::Path {
11224            caminho: "../(cd foo)/".into(),
11225        });
11226        let err = d.validate().unwrap_err();
11227        assert!(
11228            matches!(
11229                err,
11230                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
11231            ),
11232            "got {err:?}",
11233        );
11234    }
11235
11236    #[test]
11237    fn fonte_caminho_shell_subshell_grouping_diagnostic_carries_offending_dep_caminho_and_byte() {
11238        // Diagnostic-shape pin (peer with
11239        // `fonte_caminho_shell_glob_diagnostic_carries_offending_dep_caminho_and_byte`
11240        // on the closest two-byte peer arm): the error's Display
11241        // surfaces the offending `:nome`, the offending `:caminho`
11242        // verbatim, the offending byte's hex / character form, and
11243        // names the shell-subshell-grouping footgun explicitly so a
11244        // `feira lint` run can render the diagnostic without re-
11245        // parsing.
11246        let d = dep_with_fonte(DepSource::Path {
11247            caminho: "../caixa-teia/$(date)/build".into(),
11248        });
11249        let rendered = d.validate().unwrap_err().to_string();
11250        assert!(
11251            rendered.contains("caixa-teia"),
11252            "diagnostic must name the offending dep: {rendered}",
11253        );
11254        assert!(
11255            rendered.contains("../caixa-teia/$(date)/build"),
11256            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11257        );
11258        assert!(
11259            rendered.contains("0x28"),
11260            "diagnostic must surface the offending byte hex: {rendered:?}",
11261        );
11262        assert!(
11263            rendered.contains("subshell-grouping"),
11264            "diagnostic must name the shell-subshell-grouping footgun: {rendered:?}",
11265        );
11266        assert!(
11267            rendered.contains("command-substitution"),
11268            "diagnostic must reference the `$(<cmd>)` command-substitution vocabulary: \
11269             {rendered:?}",
11270        );
11271    }
11272
11273    // ── shell-brace-expansion / URI-Template-placeholder arm ───────────
11274    //
11275    // Peer with the prior `FonteCaminhoShellSubshellGrouping` (`(` /
11276    // `)`) byte-pair arm: the same per-byte cascade with the same
11277    // self-locating `byte: u8` diagnostic on the orthogonal `{` /
11278    // `}` brace-expansion / URI-Template placeholder axis. The peer
11279    // [`crate::render::is_git_repo_url`] (42d8f9d) closes the same
11280    // byte pair on the sibling `:fonte :repo` axis under the same
11281    // banner.
11282
11283    #[test]
11284    fn validate_rejects_path_fonte_with_caminho_carrying_brace_expansion_fan_across_siblings() {
11285        // The fail-before-pass-after pin for the canonical paste-from-
11286        // shell-history brace-expansion footgun: an author copies a
11287        // `cd ../{caixa-teia,caixa-helm}/build` shell-history one-
11288        // liner whose `{a,b}` brace expansion fans across two siblings
11289        // and silently passed every prior arm (`Path::is_absolute`
11290        // false on `..`, no control bytes, no `\`, no `<` / `>`, no
11291        // `|`, no `;`, no `&`, no backtick, no `*` / `?`, no `(` /
11292        // `)`, doesn't end in `/`; the leading-`$` f4efe9c
11293        // `FonteCaminhoVarExpansion` arm doesn't fire because the
11294        // value starts with `..` not `$`). The lacre embedded the
11295        // value verbatim, the resolver folded it through `Path::join`
11296        // looking for a literal `./../{caixa-teia,caixa-helm}/build`
11297        // subdirectory, and the failure surfaced at resolve time with
11298        // a non-self-locating `No such file or directory` error. The
11299        // new arm moves the rejection to validate time and names the
11300        // offending dep + caminho + byte verbatim. The arm fires on
11301        // the first `{` encountered.
11302        let d = dep_with_fonte(DepSource::Path {
11303            caminho: "../{caixa-teia,caixa-helm}/build".into(),
11304        });
11305        let err = d.validate().unwrap_err();
11306        let DepError::FonteCaminhoShellBraceExpansion {
11307            nome,
11308            caminho,
11309            byte,
11310        } = err
11311        else {
11312            panic!("expected FonteCaminhoShellBraceExpansion, got {err:?}");
11313        };
11314        assert_eq!(nome, "caixa-teia");
11315        assert_eq!(caminho, "../{caixa-teia,caixa-helm}/build");
11316        assert_eq!(byte, b'{');
11317    }
11318
11319    #[test]
11320    fn validate_rejects_path_fonte_with_caminho_carrying_close_brace() {
11321        // The symmetric close-brace paste shape (`"../caixa-teia}"` —
11322        // the degenerate "I selected an unbalanced closing brace out
11323        // of a shell-history block" idiom that probes for the
11324        // cascade's last-byte handling on a value carrying only the
11325        // closing byte). Pinned separately from the open-brace shape
11326        // so the gate's contract is "any `{` or `}` anywhere", not
11327        // single-byte coverage. Mirrors the peer
11328        // `validate_rejects_path_fonte_with_caminho_carrying_close_paren`
11329        // shape on the immediate-predecessor `FonteCaminhoShellSubshellGrouping`
11330        // arm.
11331        let d = dep_with_fonte(DepSource::Path {
11332            caminho: "../caixa-teia}".into(),
11333        });
11334        let err = d.validate().unwrap_err();
11335        let DepError::FonteCaminhoShellBraceExpansion { byte, .. } = err else {
11336            panic!("expected FonteCaminhoShellBraceExpansion, got {err:?}");
11337        };
11338        assert_eq!(byte, b'}');
11339    }
11340
11341    #[test]
11342    fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_brace() {
11343        // Leading-position `{` shape (`"{caixa-teia,caixa-helm}/build"`
11344        // — the canonical "I selected a `{a,b}` brace-expansion prefix
11345        // out of a shell-history one-liner" idiom). Pinned separately
11346        // from the embedded-byte shape so the gate covers every
11347        // position, not only mid-path.
11348        let d = dep_with_fonte(DepSource::Path {
11349            caminho: "{caixa-teia,caixa-helm}/build".into(),
11350        });
11351        let err = d.validate().unwrap_err();
11352        assert!(
11353            matches!(
11354                err,
11355                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
11356            ),
11357            "got {err:?}",
11358        );
11359    }
11360
11361    #[test]
11362    fn validate_rejects_path_fonte_with_caminho_carrying_uri_template_placeholder() {
11363        // The canonical URI-Template / Mustache / Helm doubled-brace
11364        // placeholder shape (`"../{{org}}/caixa-teia"` — the canonical
11365        // "I copied a `https://github.com/{{org}}/caixa-teia` README
11366        // quick-start / OpenAPI spec / Helm chart `home:` template
11367        // and forgot to substitute the placeholder" footgun). The arm
11368        // fires on the first `{` encountered; pinned so the gate's
11369        // coverage extends from the bare-brace shell-history shape to
11370        // the doubled-brace URI-Template / templating-engine shape.
11371        // Mirrors the peer 42d8f9d `is_git_repo_url` arm on the
11372        // sibling `:fonte :repo` axis.
11373        let d = dep_with_fonte(DepSource::Path {
11374            caminho: "../{{org}}/caixa-teia".into(),
11375        });
11376        let err = d.validate().unwrap_err();
11377        assert!(
11378            matches!(
11379                err,
11380                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
11381            ),
11382            "got {err:?}",
11383        );
11384    }
11385
11386    #[test]
11387    fn validate_rejects_path_fonte_with_caminho_carrying_brace_range_expansion() {
11388        // The canonical bash brace-range-expansion shape (`"../caixa-
11389        // v{1..10}"` — the `{1..10}` sequence expansion every bash /
11390        // zsh `for i in {1..10}; do …; done` idiom uses, the symmetric
11391        // sequence-range form to the `{a,b,c}` comma-separated form).
11392        // The arm fires on the first `{` encountered; pinned so the
11393        // gate's coverage extends from the comma-separated form to
11394        // the integer-range form.
11395        let d = dep_with_fonte(DepSource::Path {
11396            caminho: "../caixa-v{1..10}".into(),
11397        });
11398        let err = d.validate().unwrap_err();
11399        assert!(
11400            matches!(
11401                err,
11402                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
11403            ),
11404            "got {err:?}",
11405        );
11406    }
11407
11408    #[test]
11409    fn validate_accepts_path_fonte_with_caminho_carrying_no_brace_expansion() {
11410        // The positive-control pin: the gate targets only `{` / `}`,
11411        // never adjacent printable ASCII or POSIX-valid bytes. The
11412        // canonical relative POSIX path (`"../caixa-teia"`) and a
11413        // nested deeply-pathed variant with adjacent printable
11414        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue to
11415        // validate cleanly so the gate doesn't widen to a "no
11416        // printable punctuation anywhere" sweep that would defeat
11417        // the entire path-fonte author surface. Peer with
11418        // `validate_accepts_path_fonte_with_caminho_carrying_no_subshell_grouping`
11419        // on the immediate-predecessor arm.
11420        let d = dep_with_fonte(DepSource::Path {
11421            caminho: "../caixa-teia/sub-dir.v2".into(),
11422        });
11423        d.validate().unwrap();
11424    }
11425
11426    #[test]
11427    fn fonte_caminho_shell_subshell_grouping_fires_before_shell_brace_expansion() {
11428        // Cascade pin on the immediate-predecessor arm: a value
11429        // carrying both `(` and `{` (`"../(cd foo)/{a,b}"` — the
11430        // canonical "I pasted a subshell-grouping followed by a
11431        // brace-expansion tail" footgun) routes through
11432        // `FonteCaminhoShellSubshellGrouping` not
11433        // `FonteCaminhoShellBraceExpansion`. The subshell-grouping
11434        // shape is the more semantic-locating axis on every probe-
11435        // as-both value because it closes both halves of the modern
11436        // Bourne `$(<cmd>)` command-substitution surface — same
11437        // cascade discipline every prior `:caminho` arm establishes.
11438        let d = dep_with_fonte(DepSource::Path {
11439            caminho: "../(cd foo)/{a,b}".into(),
11440        });
11441        let err = d.validate().unwrap_err();
11442        assert!(
11443            matches!(
11444                err,
11445                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
11446            ),
11447            "got {err:?}",
11448        );
11449    }
11450
11451    #[test]
11452    fn fonte_caminho_shell_glob_fires_before_shell_brace_expansion() {
11453        // Cascade pin on the upstream shell-glob arm: a value carrying
11454        // both `*` and `{` (`"../caixa-teia/*{a,b}"` — the canonical
11455        // "I pasted a glob expansion followed by a brace-expansion
11456        // tail" footgun) routes through `FonteCaminhoShellGlob` not
11457        // `FonteCaminhoShellBraceExpansion`. The pathname-expansion
11458        // shape is the load-bearing root-cause edit on every
11459        // probe-as-both value.
11460        let d = dep_with_fonte(DepSource::Path {
11461            caminho: "../caixa-teia/*{a,b}".into(),
11462        });
11463        let err = d.validate().unwrap_err();
11464        assert!(
11465            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
11466            "got {err:?}",
11467        );
11468    }
11469
11470    #[test]
11471    fn fonte_caminho_shell_command_substitution_fires_before_shell_brace_expansion() {
11472        // Cascade pin on the upstream shell-command-substitution arm:
11473        // a value carrying both a backtick and `{` (``"../`whoami`/{a,b}"``
11474        // — the canonical "I pasted a legacy-backtick command-
11475        // substitution followed by a brace-expansion fan-out" footgun)
11476        // routes through `FonteCaminhoShellCommandSubstitution` not
11477        // `FonteCaminhoShellBraceExpansion`. The CWE-78 shell-
11478        // command-injection vector is the load-bearing root-cause
11479        // edit on every probe-as-both value.
11480        let d = dep_with_fonte(DepSource::Path {
11481            caminho: "../`whoami`/{a,b}".into(),
11482        });
11483        let err = d.validate().unwrap_err();
11484        assert!(
11485            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11486            "got {err:?}",
11487        );
11488    }
11489
11490    #[test]
11491    fn fonte_caminho_shell_background_fires_before_shell_brace_expansion() {
11492        // Cascade pin on the upstream shell-background arm: a value
11493        // carrying both `&` and `{` (`"../caixa-teia & {a,b}"` — the
11494        // canonical "I pasted a `cmd & {fork-fan}` background-launch
11495        // + brace-expansion chain" footgun) routes through
11496        // `FonteCaminhoShellBackground` not
11497        // `FonteCaminhoShellBraceExpansion`. The background-launch
11498        // tail is the load-bearing root-cause edit on every
11499        // probe-as-both value.
11500        let d = dep_with_fonte(DepSource::Path {
11501            caminho: "../caixa-teia & {a,b}".into(),
11502        });
11503        let err = d.validate().unwrap_err();
11504        assert!(
11505            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11506            "got {err:?}",
11507        );
11508    }
11509
11510    #[test]
11511    fn fonte_caminho_shell_semicolon_fires_before_shell_brace_expansion() {
11512        // Cascade pin on the upstream shell-semicolon arm: a value
11513        // carrying both `;` and `{` (`"../caixa-teia; {a,b}"` — the
11514        // canonical sequential-cleanup + brace-expansion paste
11515        // idiom) routes through `FonteCaminhoShellSemicolon` not
11516        // `FonteCaminhoShellBraceExpansion`. The sequential-command-
11517        // separator paste is the load-bearing root-cause edit on
11518        // every probe-as-both value.
11519        let d = dep_with_fonte(DepSource::Path {
11520            caminho: "../caixa-teia; {a,b}".into(),
11521        });
11522        let err = d.validate().unwrap_err();
11523        assert!(
11524            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11525            "got {err:?}",
11526        );
11527    }
11528
11529    #[test]
11530    fn fonte_caminho_shell_pipe_fires_before_shell_brace_expansion() {
11531        // Cascade pin on the upstream shell-pipe arm: a value
11532        // carrying both `|` and `{` (`"../caixa-teia | {tee,cat}"`
11533        // — the canonical pipeline-to-brace-expansion paste idiom)
11534        // routes through `FonteCaminhoShellPipe` not
11535        // `FonteCaminhoShellBraceExpansion`. The pipeline-tail paste
11536        // is the load-bearing root-cause edit on every probe-as-
11537        // both value.
11538        let d = dep_with_fonte(DepSource::Path {
11539            caminho: "../caixa-teia | {tee,cat}".into(),
11540        });
11541        let err = d.validate().unwrap_err();
11542        assert!(
11543            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11544            "got {err:?}",
11545        );
11546    }
11547
11548    #[test]
11549    fn fonte_caminho_shell_redirection_fires_before_shell_brace_expansion() {
11550        // Cascade pin on the upstream shell-redirection arm: a value
11551        // carrying both `>` and `{` (`"../caixa-teia>log {a,b}"` —
11552        // the canonical "I pasted a `cmd > log {a,b}` redirect-
11553        // plus-brace-expansion chain" footgun) routes through
11554        // `FonteCaminhoShellRedirection` not
11555        // `FonteCaminhoShellBraceExpansion`. The input/output
11556        // redirection metachar carries the more self-locating
11557        // `byte` payload, so the prior arm wins on every probe-
11558        // as-both value.
11559        let d = dep_with_fonte(DepSource::Path {
11560            caminho: "../caixa-teia>log {a,b}".into(),
11561        });
11562        let err = d.validate().unwrap_err();
11563        assert!(
11564            matches!(
11565                err,
11566                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11567            ),
11568            "got {err:?}",
11569        );
11570    }
11571
11572    #[test]
11573    fn fonte_caminho_backslash_fires_before_shell_brace_expansion() {
11574        // Cascade pin on the upstream backslash arm: a value
11575        // carrying both `\` and `{` (`"..\caixa-teia\{a,b}"` — the
11576        // canonical "I pasted a Windows-shell `cd ..\path\{a,b}`
11577        // chain") routes through `FonteCaminhoBackslash` not
11578        // `FonteCaminhoShellBraceExpansion`. The cross-host-OS-
11579        // separator divergence is the load-bearing axis on every
11580        // probe-as-both value.
11581        let d = dep_with_fonte(DepSource::Path {
11582            caminho: "..\\caixa-teia\\{a,b}".into(),
11583        });
11584        let err = d.validate().unwrap_err();
11585        assert!(
11586            matches!(err, DepError::FonteCaminhoBackslash { .. }),
11587            "got {err:?}",
11588        );
11589    }
11590
11591    #[test]
11592    fn fonte_caminho_control_char_fires_before_shell_brace_expansion() {
11593        // Cascade pin on the embedded-control-byte arm: a value
11594        // carrying both a control byte and `{` (`"../foo\n{a,b}"` —
11595        // the canonical paste-from-multiline-doc footgun where a
11596        // newline landed mid-caminho between two paste fragments)
11597        // routes through `FonteCaminhoControlChar` not
11598        // `FonteCaminhoShellBraceExpansion`. The POSIX-syscall-
11599        // rejected-byte / NUL-`CString::new`-fail diagnostic is the
11600        // load-bearing axis on every value that probes positive for
11601        // both — mirrors the cascade discipline on every prior arm.
11602        let d = dep_with_fonte(DepSource::Path {
11603            caminho: "../foo\n{a,b}".into(),
11604        });
11605        let err = d.validate().unwrap_err();
11606        assert!(
11607            matches!(err, DepError::FonteCaminhoControlChar { .. }),
11608            "got {err:?}",
11609        );
11610    }
11611
11612    #[test]
11613    fn fonte_caminho_absolute_fires_before_shell_brace_expansion() {
11614        // Cascade pin on the load-bearing leading-byte arm: a
11615        // leading `/` value with embedded `{` (`"/etc/{a,b}"`)
11616        // routes through `FonteCaminhoAbsolute` not
11617        // `FonteCaminhoShellBraceExpansion` — the host-layout-leak
11618        // diagnostic is the load-bearing axis, the brace-expansion
11619        // byte is the secondary observation. Same precedence logic
11620        // as every prior leading-byte arm.
11621        let d = dep_with_fonte(DepSource::Path {
11622            caminho: "/etc/{a,b}".into(),
11623        });
11624        let err = d.validate().unwrap_err();
11625        assert!(
11626            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11627            "got {err:?}",
11628        );
11629    }
11630
11631    #[test]
11632    fn fonte_caminho_var_expansion_fires_before_shell_brace_expansion() {
11633        // Cascade pin on the upstream leading-`$` var-expansion
11634        // arm: a value carrying both a leading `$` and a `{`
11635        // (`"${ORG}/caixa-teia"` — the canonical "I pasted a
11636        // `${ORG}` shell-variable + curly-brace expansion at the
11637        // head of a sibling-workspace path" footgun) routes through
11638        // `FonteCaminhoVarExpansion` not
11639        // `FonteCaminhoShellBraceExpansion`. The leading-byte
11640        // shell-variable-expansion is the more self-locating
11641        // diagnostic on values that probe as both — same
11642        // load-bearing-leading-byte cascade discipline every prior
11643        // `:caminho` arm establishes.
11644        let d = dep_with_fonte(DepSource::Path {
11645            caminho: "${ORG}/caixa-teia".into(),
11646        });
11647        let err = d.validate().unwrap_err();
11648        assert!(
11649            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
11650            "got {err:?}",
11651        );
11652    }
11653
11654    #[test]
11655    fn fonte_caminho_shell_brace_expansion_fires_before_trailing_slash() {
11656        // Cascade pin on the immediate-successor arm: a value
11657        // carrying both `{` and a trailing `/`
11658        // (`"../{caixa-teia,caixa-helm}/"` — the canonical "I
11659        // tab-completed a path that already had a brace-expansion
11660        // expansion tail" footgun) routes through
11661        // `FonteCaminhoShellBraceExpansion` not
11662        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
11663        // is the more semantic-locating axis (an author who removes
11664        // the `{` typically also drops the trailing separator since
11665        // both are paste-from-shell artifacts).
11666        let d = dep_with_fonte(DepSource::Path {
11667            caminho: "../{caixa-teia,caixa-helm}/".into(),
11668        });
11669        let err = d.validate().unwrap_err();
11670        assert!(
11671            matches!(
11672                err,
11673                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
11674            ),
11675            "got {err:?}",
11676        );
11677    }
11678
11679    #[test]
11680    fn fonte_caminho_shell_brace_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
11681        // Diagnostic-shape pin (peer with
11682        // `fonte_caminho_shell_subshell_grouping_diagnostic_carries_offending_dep_caminho_and_byte`
11683        // on the closest two-byte peer arm): the error's Display
11684        // surfaces the offending `:nome`, the offending `:caminho`
11685        // verbatim, the offending byte's hex / character form, and
11686        // names the shell-brace-expansion / URI-Template footgun
11687        // explicitly so a `feira lint` run can render the diagnostic
11688        // without re-parsing.
11689        let d = dep_with_fonte(DepSource::Path {
11690            caminho: "../{caixa-teia,caixa-helm}/build".into(),
11691        });
11692        let rendered = d.validate().unwrap_err().to_string();
11693        assert!(
11694            rendered.contains("caixa-teia"),
11695            "diagnostic must name the offending dep: {rendered}",
11696        );
11697        assert!(
11698            rendered.contains("../{caixa-teia,caixa-helm}/build"),
11699            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11700        );
11701        assert!(
11702            rendered.contains("0x7b"),
11703            "diagnostic must surface the offending byte hex: {rendered:?}",
11704        );
11705        assert!(
11706            rendered.contains("brace-expansion"),
11707            "diagnostic must name the shell-brace-expansion footgun: {rendered:?}",
11708        );
11709        assert!(
11710            rendered.contains("URI Template"),
11711            "diagnostic must reference the RFC-6570 URI-Template-placeholder vocabulary: \
11712             {rendered:?}",
11713        );
11714    }
11715
11716    #[test]
11717    fn validate_rejects_path_fonte_with_caminho_carrying_bracket_glob_character_class() {
11718        // The canonical paste-from-shell-history bracket-glob /
11719        // character-class footgun: an author copies a
11720        // `cd ../caixa-[a-z]/build` shell-history one-liner whose
11721        // `[a-z]` POSIX glob character-class matches every lowercase-
11722        // ASCII-suffix sibling caixa directory and silently passed
11723        // every prior arm (`Path::is_absolute` false on `..`, no
11724        // control bytes, no `\`, no `<` / `>`, no `|`, no `;`, no
11725        // `&`, no backtick, no `*` / `?`, no `(` / `)`, no `{` /
11726        // `}`, doesn't end in `/`; the leading-`$` f4efe9c
11727        // `FonteCaminhoVarExpansion` arm doesn't fire because the
11728        // value starts with `..` not `$`). The lacre embedded the
11729        // value verbatim, the resolver folded it through
11730        // `Path::join` looking for a literal `./../caixa-[a-z]/
11731        // build` subdirectory, and the failure surfaced at resolve
11732        // time with a non-self-locating `No such file or directory`
11733        // error. The new arm moves the rejection to validate time
11734        // and names the offending dep + caminho + byte verbatim.
11735        // The arm fires on the first `[` encountered.
11736        let d = dep_with_fonte(DepSource::Path {
11737            caminho: "../caixa-[a-z]/build".into(),
11738        });
11739        let err = d.validate().unwrap_err();
11740        let DepError::FonteCaminhoShellBracketExpansion {
11741            nome,
11742            caminho,
11743            byte,
11744        } = err
11745        else {
11746            panic!("expected FonteCaminhoShellBracketExpansion, got {err:?}");
11747        };
11748        assert_eq!(nome, "caixa-teia");
11749        assert_eq!(caminho, "../caixa-[a-z]/build");
11750        assert_eq!(byte, b'[');
11751    }
11752
11753    #[test]
11754    fn validate_rejects_path_fonte_with_caminho_carrying_close_bracket() {
11755        // The symmetric close-bracket paste shape (`"../caixa-teia]"`
11756        // — the degenerate "I selected an unbalanced closing bracket
11757        // out of a glob character-class block" idiom that probes for
11758        // the cascade's last-byte handling on a value carrying only
11759        // the closing byte). Pinned separately from the open-bracket
11760        // shape so the gate's contract is "any `[` or `]` anywhere",
11761        // not single-byte coverage. Mirrors the peer
11762        // `validate_rejects_path_fonte_with_caminho_carrying_close_brace`
11763        // shape on the immediate-predecessor
11764        // `FonteCaminhoShellBraceExpansion` arm.
11765        let d = dep_with_fonte(DepSource::Path {
11766            caminho: "../caixa-teia]".into(),
11767        });
11768        let err = d.validate().unwrap_err();
11769        let DepError::FonteCaminhoShellBracketExpansion { byte, .. } = err else {
11770            panic!("expected FonteCaminhoShellBracketExpansion, got {err:?}");
11771        };
11772        assert_eq!(byte, b']');
11773    }
11774
11775    #[test]
11776    fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_bracket() {
11777        // Leading-position `[` shape (`"[caixa-teia]/build"` — the
11778        // canonical "I selected a `[caixa-teia]` TOML-table-header /
11779        // glob-character-class prefix out of an aligned config /
11780        // shell-history one-liner" idiom). Pinned separately from
11781        // the embedded-byte shape so the gate covers every position,
11782        // not only mid-path.
11783        let d = dep_with_fonte(DepSource::Path {
11784            caminho: "[caixa-teia]/build".into(),
11785        });
11786        let err = d.validate().unwrap_err();
11787        assert!(
11788            matches!(
11789                err,
11790                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
11791            ),
11792            "got {err:?}",
11793        );
11794    }
11795
11796    #[test]
11797    fn validate_rejects_path_fonte_with_caminho_carrying_toml_inline_array() {
11798        // The canonical TOML inline-array / YAML flow-sequence
11799        // paste shape (`"../[\"a\", \"b\"]/caixa-teia"` — the
11800        // canonical "I copied a `features = [\"a\", \"b\"]` TOML
11801        // inline-array out of a sibling-Cargo manifest" cross-idiom
11802        // leak; the symmetric YAML flow-sequence form `paths: [/a,
11803        // /b]` paste-from-values.yaml shape carries the same
11804        // bracket pair). The arm fires on the first `[` encountered;
11805        // pinned so the gate's coverage extends from the bare-
11806        // bracket glob-character-class shape to the TOML / YAML /
11807        // JSON array-literal shape.
11808        let d = dep_with_fonte(DepSource::Path {
11809            caminho: "../[\"a\", \"b\"]/caixa-teia".into(),
11810        });
11811        let err = d.validate().unwrap_err();
11812        assert!(
11813            matches!(
11814                err,
11815                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
11816            ),
11817            "got {err:?}",
11818        );
11819    }
11820
11821    #[test]
11822    fn validate_rejects_path_fonte_with_caminho_carrying_shell_test_builtin() {
11823        // The canonical POSIX `test` / `[` builtin command paste
11824        // shape (`"../[ -d caixa-teia ]"` — the `[ <expr> ]` shell-
11825        // script conditional every paste-from-shell-script idiom
11826        // carries; bash's `[[ <expr> ]]` extended-test grammar
11827        // would surface the same byte pair). The arm fires on the
11828        // first `[` encountered; pinned so the gate's coverage
11829        // extends from the embedded-glob-character-class shape to
11830        // the leading-`test`-builtin / extended-test form.
11831        let d = dep_with_fonte(DepSource::Path {
11832            caminho: "../[ -d caixa-teia ]".into(),
11833        });
11834        let err = d.validate().unwrap_err();
11835        assert!(
11836            matches!(
11837                err,
11838                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
11839            ),
11840            "got {err:?}",
11841        );
11842    }
11843
11844    #[test]
11845    fn validate_accepts_path_fonte_with_caminho_carrying_no_bracket_expansion() {
11846        // The positive-control pin: the gate targets only `[` /
11847        // `]`, never adjacent printable ASCII or POSIX-valid bytes.
11848        // The canonical relative POSIX path (`"../caixa-teia"`) and
11849        // a nested deeply-pathed variant with adjacent printable
11850        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
11851        // to validate cleanly so the gate doesn't widen to a "no
11852        // printable punctuation anywhere" sweep that would defeat
11853        // the entire path-fonte author surface. Peer with
11854        // `validate_accepts_path_fonte_with_caminho_carrying_no_brace_expansion`
11855        // on the immediate-predecessor arm.
11856        let d = dep_with_fonte(DepSource::Path {
11857            caminho: "../caixa-teia/sub-dir.v2".into(),
11858        });
11859        d.validate().unwrap();
11860    }
11861
11862    #[test]
11863    fn fonte_caminho_shell_brace_expansion_fires_before_shell_bracket_expansion() {
11864        // Cascade pin on the immediate-predecessor arm: a value
11865        // carrying both `{` and `[` (`"../{a,b}[ch]"` — the
11866        // canonical "I pasted a brace-expansion fan followed by a
11867        // glob-character-class tail" footgun) routes through
11868        // `FonteCaminhoShellBraceExpansion` not
11869        // `FonteCaminhoShellBracketExpansion`. The brace-expansion
11870        // fan is the load-bearing root-cause edit on every
11871        // probe-as-both value because the bracket-class tail
11872        // typically rides on a prior brace-expansion expansion;
11873        // same cascade discipline every prior `:caminho` arm
11874        // establishes.
11875        let d = dep_with_fonte(DepSource::Path {
11876            caminho: "../{a,b}[ch]".into(),
11877        });
11878        let err = d.validate().unwrap_err();
11879        assert!(
11880            matches!(
11881                err,
11882                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
11883            ),
11884            "got {err:?}",
11885        );
11886    }
11887
11888    #[test]
11889    fn fonte_caminho_shell_subshell_grouping_fires_before_shell_bracket_expansion() {
11890        // Cascade pin on the upstream shell-subshell-grouping arm:
11891        // a value carrying both `(` and `[` (`"../(cd foo)/[ch]"` —
11892        // the canonical "I pasted a subshell-grouping followed by
11893        // a glob-character-class tail" footgun) routes through
11894        // `FonteCaminhoShellSubshellGrouping` not
11895        // `FonteCaminhoShellBracketExpansion`. The modern Bourne
11896        // `$(<cmd>)` command-substitution boundary is the load-
11897        // bearing axis on every probe-as-both value.
11898        let d = dep_with_fonte(DepSource::Path {
11899            caminho: "../(cd foo)/[ch]".into(),
11900        });
11901        let err = d.validate().unwrap_err();
11902        assert!(
11903            matches!(
11904                err,
11905                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
11906            ),
11907            "got {err:?}",
11908        );
11909    }
11910
11911    #[test]
11912    fn fonte_caminho_shell_glob_fires_before_shell_bracket_expansion() {
11913        // Cascade pin on the upstream shell-glob arm: a value
11914        // carrying both `*` and `[` (`"../caixa-teia/*[ch]"` — the
11915        // canonical "I pasted a `*.[ch]` C-source-file glob whose
11916        // unbounded `*` precedes the bracket character-class"
11917        // footgun) routes through `FonteCaminhoShellGlob` not
11918        // `FonteCaminhoShellBracketExpansion`. The unbounded
11919        // pathname-expansion sentinel is the load-bearing root-
11920        // cause edit on every probe-as-both value — the unbounded
11921        // `*` carries the more aggressive expansion vector than
11922        // the bounded `[ch]` class, so the prior arm wins.
11923        let d = dep_with_fonte(DepSource::Path {
11924            caminho: "../caixa-teia/*[ch]".into(),
11925        });
11926        let err = d.validate().unwrap_err();
11927        assert!(
11928            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
11929            "got {err:?}",
11930        );
11931    }
11932
11933    #[test]
11934    fn fonte_caminho_shell_command_substitution_fires_before_shell_bracket_expansion() {
11935        // Cascade pin on the upstream shell-command-substitution
11936        // arm: a value carrying both a backtick and `[`
11937        // (``"../`whoami`/[ch]"`` — the canonical "I pasted a
11938        // legacy-backtick command-substitution followed by a
11939        // glob-character-class tail" footgun) routes through
11940        // `FonteCaminhoShellCommandSubstitution` not
11941        // `FonteCaminhoShellBracketExpansion`. The CWE-78 shell-
11942        // command-injection vector is the load-bearing root-cause
11943        // edit on every probe-as-both value.
11944        let d = dep_with_fonte(DepSource::Path {
11945            caminho: "../`whoami`/[ch]".into(),
11946        });
11947        let err = d.validate().unwrap_err();
11948        assert!(
11949            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11950            "got {err:?}",
11951        );
11952    }
11953
11954    #[test]
11955    fn fonte_caminho_shell_background_fires_before_shell_bracket_expansion() {
11956        // Cascade pin on the upstream shell-background arm: a
11957        // value carrying both `&` and `[` (`"../caixa-teia & [ch]"`
11958        // — the canonical "I pasted a `cmd & [glob]` background-
11959        // launch + bracket-class chain" footgun) routes through
11960        // `FonteCaminhoShellBackground` not
11961        // `FonteCaminhoShellBracketExpansion`. The background-
11962        // launch tail is the load-bearing root-cause edit on
11963        // every probe-as-both value.
11964        let d = dep_with_fonte(DepSource::Path {
11965            caminho: "../caixa-teia & [ch]".into(),
11966        });
11967        let err = d.validate().unwrap_err();
11968        assert!(
11969            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11970            "got {err:?}",
11971        );
11972    }
11973
11974    #[test]
11975    fn fonte_caminho_shell_semicolon_fires_before_shell_bracket_expansion() {
11976        // Cascade pin on the upstream shell-semicolon arm: a value
11977        // carrying both `;` and `[` (`"../caixa-teia; [ch]"` — the
11978        // canonical sequential-cleanup + bracket-class paste
11979        // idiom) routes through `FonteCaminhoShellSemicolon` not
11980        // `FonteCaminhoShellBracketExpansion`. The sequential-
11981        // command-separator paste is the load-bearing root-cause
11982        // edit on every probe-as-both value.
11983        let d = dep_with_fonte(DepSource::Path {
11984            caminho: "../caixa-teia; [ch]".into(),
11985        });
11986        let err = d.validate().unwrap_err();
11987        assert!(
11988            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11989            "got {err:?}",
11990        );
11991    }
11992
11993    #[test]
11994    fn fonte_caminho_shell_pipe_fires_before_shell_bracket_expansion() {
11995        // Cascade pin on the upstream shell-pipe arm: a value
11996        // carrying both `|` and `[` (`"../caixa-teia | [tee]"` —
11997        // the canonical pipeline-to-bracket-class paste idiom)
11998        // routes through `FonteCaminhoShellPipe` not
11999        // `FonteCaminhoShellBracketExpansion`. The pipeline-tail
12000        // paste is the load-bearing root-cause edit on every
12001        // probe-as-both value.
12002        let d = dep_with_fonte(DepSource::Path {
12003            caminho: "../caixa-teia | [tee]".into(),
12004        });
12005        let err = d.validate().unwrap_err();
12006        assert!(
12007            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
12008            "got {err:?}",
12009        );
12010    }
12011
12012    #[test]
12013    fn fonte_caminho_shell_redirection_fires_before_shell_bracket_expansion() {
12014        // Cascade pin on the upstream shell-redirection arm: a
12015        // value carrying both `>` and `[` (`"../caixa-teia>log
12016        // [ch]"` — the canonical "I pasted a `cmd > log [glob]`
12017        // redirect-plus-bracket chain" footgun) routes through
12018        // `FonteCaminhoShellRedirection` not
12019        // `FonteCaminhoShellBracketExpansion`. The input/output
12020        // redirection metachar carries the more self-locating
12021        // `byte` payload, so the prior arm wins on every
12022        // probe-as-both value.
12023        let d = dep_with_fonte(DepSource::Path {
12024            caminho: "../caixa-teia>log [ch]".into(),
12025        });
12026        let err = d.validate().unwrap_err();
12027        assert!(
12028            matches!(
12029                err,
12030                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
12031            ),
12032            "got {err:?}",
12033        );
12034    }
12035
12036    #[test]
12037    fn fonte_caminho_backslash_fires_before_shell_bracket_expansion() {
12038        // Cascade pin on the upstream backslash arm: a value
12039        // carrying both `\` and `[` (`"..\caixa-teia\[ch]"` — the
12040        // canonical "I pasted a Windows-shell `cd ..\path\[glob]`
12041        // chain") routes through `FonteCaminhoBackslash` not
12042        // `FonteCaminhoShellBracketExpansion`. The cross-host-OS-
12043        // separator divergence is the load-bearing axis on every
12044        // probe-as-both value.
12045        let d = dep_with_fonte(DepSource::Path {
12046            caminho: "..\\caixa-teia\\[ch]".into(),
12047        });
12048        let err = d.validate().unwrap_err();
12049        assert!(
12050            matches!(err, DepError::FonteCaminhoBackslash { .. }),
12051            "got {err:?}",
12052        );
12053    }
12054
12055    #[test]
12056    fn fonte_caminho_control_char_fires_before_shell_bracket_expansion() {
12057        // Cascade pin on the embedded-control-byte arm: a value
12058        // carrying both a control byte and `[` (`"../foo\n[ch]"` —
12059        // the canonical paste-from-multiline-doc footgun where a
12060        // newline landed mid-caminho between two paste fragments)
12061        // routes through `FonteCaminhoControlChar` not
12062        // `FonteCaminhoShellBracketExpansion`. The POSIX-syscall-
12063        // rejected-byte / NUL-`CString::new`-fail diagnostic is
12064        // the load-bearing axis on every value that probes
12065        // positive for both — mirrors the cascade discipline on
12066        // every prior arm.
12067        let d = dep_with_fonte(DepSource::Path {
12068            caminho: "../foo\n[ch]".into(),
12069        });
12070        let err = d.validate().unwrap_err();
12071        assert!(
12072            matches!(err, DepError::FonteCaminhoControlChar { .. }),
12073            "got {err:?}",
12074        );
12075    }
12076
12077    #[test]
12078    fn fonte_caminho_absolute_fires_before_shell_bracket_expansion() {
12079        // Cascade pin on the load-bearing leading-byte arm: a
12080        // leading `/` value with embedded `[` (`"/etc/[ch]"`)
12081        // routes through `FonteCaminhoAbsolute` not
12082        // `FonteCaminhoShellBracketExpansion` — the host-layout-
12083        // leak diagnostic is the load-bearing axis, the bracket-
12084        // expansion byte is the secondary observation. Same
12085        // precedence logic as every prior leading-byte arm.
12086        let d = dep_with_fonte(DepSource::Path {
12087            caminho: "/etc/[ch]".into(),
12088        });
12089        let err = d.validate().unwrap_err();
12090        assert!(
12091            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
12092            "got {err:?}",
12093        );
12094    }
12095
12096    #[test]
12097    fn fonte_caminho_var_expansion_fires_before_shell_bracket_expansion() {
12098        // Cascade pin on the upstream leading-`$` var-expansion
12099        // arm: a value carrying both a leading `$` and a `[`
12100        // (`"$DIR/[ch]"` — the canonical "I pasted a `$DIR` shell-
12101        // variable + bracket-class at the head of a sibling-
12102        // workspace path" footgun) routes through
12103        // `FonteCaminhoVarExpansion` not
12104        // `FonteCaminhoShellBracketExpansion`. The leading-byte
12105        // shell-variable-expansion is the more self-locating
12106        // diagnostic on values that probe as both — same
12107        // load-bearing-leading-byte cascade discipline every
12108        // prior `:caminho` arm establishes.
12109        let d = dep_with_fonte(DepSource::Path {
12110            caminho: "$DIR/[ch]".into(),
12111        });
12112        let err = d.validate().unwrap_err();
12113        assert!(
12114            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
12115            "got {err:?}",
12116        );
12117    }
12118
12119    #[test]
12120    fn fonte_caminho_shell_bracket_expansion_fires_before_trailing_slash() {
12121        // Cascade pin on the immediate-successor arm: a value
12122        // carrying both `[` and a trailing `/` (`"../[a-z]/"` —
12123        // the canonical "I tab-completed a path that already had
12124        // a bracket-glob-character-class expansion tail" footgun)
12125        // routes through `FonteCaminhoShellBracketExpansion` not
12126        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
12127        // is the more semantic-locating axis (an author who
12128        // removes the `[` typically also drops the trailing
12129        // separator since both are paste-from-shell artifacts).
12130        let d = dep_with_fonte(DepSource::Path {
12131            caminho: "../[a-z]/".into(),
12132        });
12133        let err = d.validate().unwrap_err();
12134        assert!(
12135            matches!(
12136                err,
12137                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
12138            ),
12139            "got {err:?}",
12140        );
12141    }
12142
12143    #[test]
12144    fn fonte_caminho_shell_bracket_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
12145        // Diagnostic-shape pin (peer with
12146        // `fonte_caminho_shell_brace_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
12147        // on the closest two-byte peer arm): the error's Display
12148        // surfaces the offending `:nome`, the offending `:caminho`
12149        // verbatim, the offending byte's hex / character form, and
12150        // names the shell-bracket-expansion / glob-character-class
12151        // footgun explicitly so a `feira lint` run can render the
12152        // diagnostic without re-parsing.
12153        let d = dep_with_fonte(DepSource::Path {
12154            caminho: "../caixa-[a-z]/build".into(),
12155        });
12156        let rendered = d.validate().unwrap_err().to_string();
12157        assert!(
12158            rendered.contains("caixa-teia"),
12159            "diagnostic must name the offending dep: {rendered}",
12160        );
12161        assert!(
12162            rendered.contains("../caixa-[a-z]/build"),
12163            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
12164        );
12165        assert!(
12166            rendered.contains("0x5b"),
12167            "diagnostic must surface the offending byte hex: {rendered:?}",
12168        );
12169        assert!(
12170            rendered.contains("bracket-expansion"),
12171            "diagnostic must name the shell-bracket-expansion footgun: {rendered:?}",
12172        );
12173        assert!(
12174            rendered.contains("glob-character-class"),
12175            "diagnostic must reference the POSIX glob-character-class vocabulary: \
12176             {rendered:?}",
12177        );
12178    }
12179
12180    #[test]
12181    fn validate_rejects_path_fonte_with_caminho_carrying_single_quote_grouping() {
12182        // The canonical paste-from-shell-history strong-quoted
12183        // sibling-workspace-path footgun: an author copies a
12184        // `cd '../caixa-teia'` shell-history one-liner whose strong-
12185        // quoting preserved the path across a whitespace paste
12186        // boundary and silently passed every prior arm
12187        // (`Path::is_absolute` false on `'..`, no control bytes, no
12188        // `\`, no `<` / `>`, no `|`, no `;`, no `&`, no backtick, no
12189        // `*` / `?`, no `(` / `)`, no `{` / `}`, no `[` / `]`,
12190        // doesn't end in `/`; the leading-`$` f4efe9c
12191        // `FonteCaminhoVarExpansion` arm doesn't fire because the
12192        // value starts with `'` not `$`). The lacre embedded the
12193        // value verbatim, the resolver folded it through
12194        // `Path::join` looking for a literal `./'../caixa-teia'`
12195        // subdirectory, and the failure surfaced at resolve time
12196        // with a non-self-locating `No such file or directory`
12197        // error. The new arm moves the rejection to validate time
12198        // and names the offending dep + caminho + byte verbatim.
12199        // The arm fires on the first `'` encountered.
12200        let d = dep_with_fonte(DepSource::Path {
12201            caminho: "'../caixa-teia'".into(),
12202        });
12203        let err = d.validate().unwrap_err();
12204        let DepError::FonteCaminhoShellQuoteGrouping {
12205            nome,
12206            caminho,
12207            byte,
12208        } = err
12209        else {
12210            panic!("expected FonteCaminhoShellQuoteGrouping, got {err:?}");
12211        };
12212        assert_eq!(nome, "caixa-teia");
12213        assert_eq!(caminho, "'../caixa-teia'");
12214        assert_eq!(byte, b'\'');
12215    }
12216
12217    #[test]
12218    fn validate_rejects_path_fonte_with_caminho_carrying_double_quote_grouping() {
12219        // The symmetric weak-quoted paste shape (`"\"../caixa-teia\""`
12220        // — the canonical paste-from-JSON-config / paste-from-YAML-
12221        // flow-scalar / paste-from-TOML-basic-string / paste-from-
12222        // tatara-lisp-string-literal cross-idiom leak). Pinned
12223        // separately from the single-quote shape so the gate's
12224        // contract is "any `'` or `\"` anywhere", not single-byte
12225        // coverage. Mirrors the peer
12226        // `validate_rejects_path_fonte_with_caminho_carrying_close_bracket`
12227        // shape on the immediate-predecessor
12228        // `FonteCaminhoShellBracketExpansion` arm.
12229        let d = dep_with_fonte(DepSource::Path {
12230            caminho: "\"../caixa-teia\"".into(),
12231        });
12232        let err = d.validate().unwrap_err();
12233        let DepError::FonteCaminhoShellQuoteGrouping { byte, .. } = err else {
12234            panic!("expected FonteCaminhoShellQuoteGrouping, got {err:?}");
12235        };
12236        assert_eq!(byte, b'"');
12237    }
12238
12239    #[test]
12240    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_double_quote() {
12241        // Embedded-position `"` shape (`"../\"caixa-teia\""` — the
12242        // canonical "I pasted a JSON key-value pair fragment into
12243        // the middle of the path" idiom). Pinned separately from
12244        // the leading-byte shape so the gate covers every position,
12245        // not only leading.
12246        let d = dep_with_fonte(DepSource::Path {
12247            caminho: "../\"caixa-teia\"".into(),
12248        });
12249        let err = d.validate().unwrap_err();
12250        assert!(
12251            matches!(
12252                err,
12253                DepError::FonteCaminhoShellQuoteGrouping { byte: b'"', .. },
12254            ),
12255            "got {err:?}",
12256        );
12257    }
12258
12259    #[test]
12260    fn validate_rejects_path_fonte_with_caminho_carrying_yaml_flow_scalar_paste() {
12261        // The canonical YAML double-quoted flow-scalar cross-idiom
12262        // leak shape (`"path: \"../caixa-teia\""` — the "I copied a
12263        // `path: \"...\"` YAML flow-scalar entry out of an aligned
12264        // values.yaml / K8s manifest and dropped it verbatim into
12265        // the `:caminho` slot including the `path: ` key prefix"
12266        // paste-idiom). The arm fires on the first `"` encountered;
12267        // pinned so the gate's coverage extends from the bare-quote
12268        // paste shape to the aligned-YAML-manifest cross-idiom-leak
12269        // shape.
12270        let d = dep_with_fonte(DepSource::Path {
12271            caminho: "path: \"../caixa-teia\"".into(),
12272        });
12273        let err = d.validate().unwrap_err();
12274        assert!(
12275            matches!(
12276                err,
12277                DepError::FonteCaminhoShellQuoteGrouping { byte: b'"', .. },
12278            ),
12279            "got {err:?}",
12280        );
12281    }
12282
12283    #[test]
12284    fn validate_accepts_path_fonte_with_caminho_carrying_no_quote_grouping() {
12285        // The positive-control pin: the gate targets only `'` /
12286        // `"`, never adjacent printable ASCII or POSIX-valid bytes.
12287        // The canonical relative POSIX path (`"../caixa-teia"`) and
12288        // a nested deeply-pathed variant with adjacent printable
12289        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
12290        // to validate cleanly so the gate doesn't widen to a "no
12291        // printable punctuation anywhere" sweep that would defeat
12292        // the entire path-fonte author surface. Peer with
12293        // `validate_accepts_path_fonte_with_caminho_carrying_no_bracket_expansion`
12294        // on the immediate-predecessor arm.
12295        let d = dep_with_fonte(DepSource::Path {
12296            caminho: "../caixa-teia/sub-dir.v2".into(),
12297        });
12298        d.validate().unwrap();
12299    }
12300
12301    #[test]
12302    fn fonte_caminho_shell_bracket_expansion_fires_before_shell_quote_grouping() {
12303        // Cascade pin on the immediate-predecessor arm: a value
12304        // carrying both `[` and `'` (`"../[a-z]'x'"` — the canonical
12305        // "I pasted a glob-character-class followed by a strong-
12306        // quoted literal tail" footgun) routes through
12307        // `FonteCaminhoShellBracketExpansion` not
12308        // `FonteCaminhoShellQuoteGrouping`. The glob-character-class
12309        // expansion is the load-bearing root-cause edit on every
12310        // probe-as-both value; same cascade discipline every prior
12311        // `:caminho` arm establishes.
12312        let d = dep_with_fonte(DepSource::Path {
12313            caminho: "../[a-z]'x'".into(),
12314        });
12315        let err = d.validate().unwrap_err();
12316        assert!(
12317            matches!(
12318                err,
12319                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
12320            ),
12321            "got {err:?}",
12322        );
12323    }
12324
12325    #[test]
12326    fn fonte_caminho_shell_brace_expansion_fires_before_shell_quote_grouping() {
12327        // Cascade pin on the upstream shell-brace-expansion arm: a
12328        // value carrying both `{` and `'` (`"../{a,b}'x'"` — the
12329        // canonical "I pasted a brace-expansion fan followed by a
12330        // strong-quoted literal tail" footgun) routes through
12331        // `FonteCaminhoShellBraceExpansion` not
12332        // `FonteCaminhoShellQuoteGrouping`. The brace-expansion fan
12333        // is the load-bearing root-cause edit on every probe-as-
12334        // both value.
12335        let d = dep_with_fonte(DepSource::Path {
12336            caminho: "../{a,b}'x'".into(),
12337        });
12338        let err = d.validate().unwrap_err();
12339        assert!(
12340            matches!(
12341                err,
12342                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
12343            ),
12344            "got {err:?}",
12345        );
12346    }
12347
12348    #[test]
12349    fn fonte_caminho_shell_subshell_grouping_fires_before_shell_quote_grouping() {
12350        // Cascade pin on the upstream shell-subshell-grouping arm:
12351        // a value carrying both `(` and `'` (`"../(cd foo)/'x'"` —
12352        // the canonical "I pasted a subshell-grouping followed by
12353        // a strong-quoted literal tail" footgun) routes through
12354        // `FonteCaminhoShellSubshellGrouping` not
12355        // `FonteCaminhoShellQuoteGrouping`. The modern Bourne
12356        // `$(<cmd>)` command-substitution boundary is the load-
12357        // bearing axis on every probe-as-both value.
12358        let d = dep_with_fonte(DepSource::Path {
12359            caminho: "../(cd foo)/'x'".into(),
12360        });
12361        let err = d.validate().unwrap_err();
12362        assert!(
12363            matches!(
12364                err,
12365                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
12366            ),
12367            "got {err:?}",
12368        );
12369    }
12370
12371    #[test]
12372    fn fonte_caminho_shell_glob_fires_before_shell_quote_grouping() {
12373        // Cascade pin on the upstream shell-glob arm: a value
12374        // carrying both `*` and `'` (`"../caixa-teia/*'x'"` — the
12375        // canonical "I pasted a `*` unbounded pathname-expansion
12376        // followed by a strong-quoted literal tail" footgun) routes
12377        // through `FonteCaminhoShellGlob` not
12378        // `FonteCaminhoShellQuoteGrouping`. The unbounded pathname-
12379        // expansion sentinel is the load-bearing root-cause edit
12380        // on every probe-as-both value.
12381        let d = dep_with_fonte(DepSource::Path {
12382            caminho: "../caixa-teia/*'x'".into(),
12383        });
12384        let err = d.validate().unwrap_err();
12385        assert!(
12386            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12387            "got {err:?}",
12388        );
12389    }
12390
12391    #[test]
12392    fn fonte_caminho_shell_command_substitution_fires_before_shell_quote_grouping() {
12393        // Cascade pin on the upstream shell-command-substitution
12394        // arm: a value carrying both a backtick and `'`
12395        // (``"../`whoami`/'x'"`` — the canonical "I pasted a
12396        // legacy-backtick command-substitution followed by a
12397        // strong-quoted literal tail" footgun) routes through
12398        // `FonteCaminhoShellCommandSubstitution` not
12399        // `FonteCaminhoShellQuoteGrouping`. The CWE-78 shell-
12400        // command-injection vector is the load-bearing root-cause
12401        // edit on every probe-as-both value.
12402        let d = dep_with_fonte(DepSource::Path {
12403            caminho: "../`whoami`/'x'".into(),
12404        });
12405        let err = d.validate().unwrap_err();
12406        assert!(
12407            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
12408            "got {err:?}",
12409        );
12410    }
12411
12412    #[test]
12413    fn fonte_caminho_shell_background_fires_before_shell_quote_grouping() {
12414        // Cascade pin on the upstream shell-background arm: a value
12415        // carrying both `&` and `'` (`"../caixa-teia & 'x'"` — the
12416        // canonical "I pasted a `cmd & 'literal'` background-launch
12417        // + quote chain" footgun) routes through
12418        // `FonteCaminhoShellBackground` not
12419        // `FonteCaminhoShellQuoteGrouping`. The background-launch
12420        // tail is the load-bearing root-cause edit on every
12421        // probe-as-both value.
12422        let d = dep_with_fonte(DepSource::Path {
12423            caminho: "../caixa-teia & 'x'".into(),
12424        });
12425        let err = d.validate().unwrap_err();
12426        assert!(
12427            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
12428            "got {err:?}",
12429        );
12430    }
12431
12432    #[test]
12433    fn fonte_caminho_shell_semicolon_fires_before_shell_quote_grouping() {
12434        // Cascade pin on the upstream shell-semicolon arm: a value
12435        // carrying both `;` and `'` (`"../caixa-teia; 'x'"` — the
12436        // canonical sequential-cleanup + quote paste idiom) routes
12437        // through `FonteCaminhoShellSemicolon` not
12438        // `FonteCaminhoShellQuoteGrouping`. The sequential-command-
12439        // separator paste is the load-bearing root-cause edit on
12440        // every probe-as-both value.
12441        let d = dep_with_fonte(DepSource::Path {
12442            caminho: "../caixa-teia; 'x'".into(),
12443        });
12444        let err = d.validate().unwrap_err();
12445        assert!(
12446            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
12447            "got {err:?}",
12448        );
12449    }
12450
12451    #[test]
12452    fn fonte_caminho_shell_pipe_fires_before_shell_quote_grouping() {
12453        // Cascade pin on the upstream shell-pipe arm: a value
12454        // carrying both `|` and `'` (`"../caixa-teia | 'x'"` — the
12455        // canonical pipeline-to-quoted-literal paste idiom) routes
12456        // through `FonteCaminhoShellPipe` not
12457        // `FonteCaminhoShellQuoteGrouping`. The pipeline-tail paste
12458        // is the load-bearing root-cause edit on every probe-as-
12459        // both value.
12460        let d = dep_with_fonte(DepSource::Path {
12461            caminho: "../caixa-teia | 'x'".into(),
12462        });
12463        let err = d.validate().unwrap_err();
12464        assert!(
12465            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
12466            "got {err:?}",
12467        );
12468    }
12469
12470    #[test]
12471    fn fonte_caminho_shell_redirection_fires_before_shell_quote_grouping() {
12472        // Cascade pin on the upstream shell-redirection arm: a
12473        // value carrying both `>` and `'` (`"../caixa-teia>log 'x'"`
12474        // — the canonical "I pasted a `cmd > log 'literal'`
12475        // redirect-plus-quote chain" footgun) routes through
12476        // `FonteCaminhoShellRedirection` not
12477        // `FonteCaminhoShellQuoteGrouping`. The input/output
12478        // redirection metachar carries the more self-locating
12479        // `byte` payload, so the prior arm wins on every probe-as-
12480        // both value.
12481        let d = dep_with_fonte(DepSource::Path {
12482            caminho: "../caixa-teia>log 'x'".into(),
12483        });
12484        let err = d.validate().unwrap_err();
12485        assert!(
12486            matches!(
12487                err,
12488                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
12489            ),
12490            "got {err:?}",
12491        );
12492    }
12493
12494    #[test]
12495    fn fonte_caminho_backslash_fires_before_shell_quote_grouping() {
12496        // Cascade pin on the upstream backslash arm: a value
12497        // carrying both `\` and `'` (`"..\caixa-teia\'x'"` — the
12498        // canonical "I pasted a Windows-shell `cd ..\path\'literal'`
12499        // chain" footgun) routes through `FonteCaminhoBackslash`
12500        // not `FonteCaminhoShellQuoteGrouping`. The cross-host-OS-
12501        // separator divergence is the load-bearing axis on every
12502        // probe-as-both value.
12503        let d = dep_with_fonte(DepSource::Path {
12504            caminho: "..\\caixa-teia\\'x'".into(),
12505        });
12506        let err = d.validate().unwrap_err();
12507        assert!(
12508            matches!(err, DepError::FonteCaminhoBackslash { .. }),
12509            "got {err:?}",
12510        );
12511    }
12512
12513    #[test]
12514    fn fonte_caminho_control_char_fires_before_shell_quote_grouping() {
12515        // Cascade pin on the embedded-control-byte arm: a value
12516        // carrying both a control byte and `'` (`"../foo\n'x'"` —
12517        // the canonical paste-from-multiline-doc footgun where a
12518        // newline landed mid-caminho between two paste fragments)
12519        // routes through `FonteCaminhoControlChar` not
12520        // `FonteCaminhoShellQuoteGrouping`. The POSIX-syscall-
12521        // rejected-byte / NUL-`CString::new`-fail diagnostic is
12522        // the load-bearing axis on every value that probes
12523        // positive for both — mirrors the cascade discipline on
12524        // every prior arm.
12525        let d = dep_with_fonte(DepSource::Path {
12526            caminho: "../foo\n'x'".into(),
12527        });
12528        let err = d.validate().unwrap_err();
12529        assert!(
12530            matches!(err, DepError::FonteCaminhoControlChar { .. }),
12531            "got {err:?}",
12532        );
12533    }
12534
12535    #[test]
12536    fn fonte_caminho_absolute_fires_before_shell_quote_grouping() {
12537        // Cascade pin on the load-bearing leading-byte arm: a
12538        // leading `/` value with embedded `'` (`"/etc/'x'"`) routes
12539        // through `FonteCaminhoAbsolute` not
12540        // `FonteCaminhoShellQuoteGrouping` — the host-layout-leak
12541        // diagnostic is the load-bearing axis, the quote byte is
12542        // the secondary observation. Same precedence logic as every
12543        // prior leading-byte arm.
12544        let d = dep_with_fonte(DepSource::Path {
12545            caminho: "/etc/'x'".into(),
12546        });
12547        let err = d.validate().unwrap_err();
12548        assert!(
12549            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
12550            "got {err:?}",
12551        );
12552    }
12553
12554    #[test]
12555    fn fonte_caminho_var_expansion_fires_before_shell_quote_grouping() {
12556        // Cascade pin on the upstream leading-`$` var-expansion
12557        // arm: a value carrying both a leading `$` and a `'`
12558        // (`"$DIR/'x'"` — the canonical "I pasted a `$DIR` shell-
12559        // variable + quoted literal at the head of a sibling-
12560        // workspace path" footgun) routes through
12561        // `FonteCaminhoVarExpansion` not
12562        // `FonteCaminhoShellQuoteGrouping`. The leading-byte
12563        // shell-variable-expansion is the more self-locating
12564        // diagnostic on values that probe as both — same
12565        // load-bearing-leading-byte cascade discipline every
12566        // prior `:caminho` arm establishes.
12567        let d = dep_with_fonte(DepSource::Path {
12568            caminho: "$DIR/'x'".into(),
12569        });
12570        let err = d.validate().unwrap_err();
12571        assert!(
12572            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
12573            "got {err:?}",
12574        );
12575    }
12576
12577    #[test]
12578    fn fonte_caminho_shell_quote_grouping_fires_before_trailing_slash() {
12579        // Cascade pin on the immediate-successor arm: a value
12580        // carrying both `'` and a trailing `/` (`"../'caixa-teia'/"`
12581        // — the canonical "I tab-completed a path whose strong-
12582        // quoted body already carried the quoting from a shell-
12583        // history paste" footgun) routes through
12584        // `FonteCaminhoShellQuoteGrouping` not
12585        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
12586        // is the more semantic-locating axis (an author who removes
12587        // the `'` typically also drops the trailing separator since
12588        // both are paste-from-shell artifacts).
12589        let d = dep_with_fonte(DepSource::Path {
12590            caminho: "../'caixa-teia'/".into(),
12591        });
12592        let err = d.validate().unwrap_err();
12593        assert!(
12594            matches!(
12595                err,
12596                DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
12597            ),
12598            "got {err:?}",
12599        );
12600    }
12601
12602    #[test]
12603    fn fonte_caminho_shell_quote_grouping_diagnostic_carries_offending_dep_caminho_and_byte() {
12604        // Diagnostic-shape pin (peer with
12605        // `fonte_caminho_shell_bracket_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
12606        // on the closest two-byte peer arm): the error's Display
12607        // surfaces the offending `:nome`, the offending `:caminho`
12608        // verbatim, the offending byte's hex / character form, and
12609        // names the shell-quote-grouping / cross-config-DSL-string-
12610        // literal-delimiter footgun explicitly so a `feira lint`
12611        // run can render the diagnostic without re-parsing.
12612        let d = dep_with_fonte(DepSource::Path {
12613            caminho: "'../caixa-teia'".into(),
12614        });
12615        let rendered = d.validate().unwrap_err().to_string();
12616        assert!(
12617            rendered.contains("caixa-teia"),
12618            "diagnostic must name the offending dep: {rendered}",
12619        );
12620        assert!(
12621            rendered.contains("'../caixa-teia'"),
12622            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
12623        );
12624        assert!(
12625            rendered.contains("0x27"),
12626            "diagnostic must surface the offending byte hex: {rendered:?}",
12627        );
12628        assert!(
12629            rendered.contains("quote-grouping"),
12630            "diagnostic must name the shell-quote-grouping footgun: {rendered:?}",
12631        );
12632        assert!(
12633            rendered.contains("string-literal"),
12634            "diagnostic must reference the cross-config-DSL string-literal-delimiter \
12635             vocabulary: {rendered:?}",
12636        );
12637    }
12638
12639    #[test]
12640    fn validate_rejects_path_fonte_with_caminho_carrying_shell_comment_lead() {
12641        // The canonical paste-from-shell-history-with-trailing-
12642        // annotation footgun: an author pastes a `cd ../caixa-teia
12643        // # legacy sibling` shell-history one-liner whose unquoted `#`
12644        // comment-lead separates the path from an inline annotation.
12645        // The POSIX shell trims the annotation to `../caixa-teia`
12646        // (POSIX.1-2017 §2.3 Token Recognition step 6), but
12647        // `Path::is_absolute` returns false on `..`, `#` is neither
12648        // a leading-byte sentinel nor a control byte nor `\` nor
12649        // `<` / `>` nor `|` nor `;` nor `&` nor backtick nor `*` /
12650        // `?` nor `(` / `)` nor `{` / `}` nor `[` / `]` nor `'` /
12651        // `"`, and the value's last byte isn't `/` — so the value
12652        // silently passed every prior arm. The resolver folded the
12653        // value through `Path::join` looking for a literal
12654        // `./../caixa-teia # legacy sibling` subdirectory and the
12655        // failure surfaced at resolve time with a non-self-locating
12656        // `No such file or directory` error. The new arm moves the
12657        // rejection to validate time and names the offending dep +
12658        // caminho + byte verbatim.
12659        let d = dep_with_fonte(DepSource::Path {
12660            caminho: "../caixa-teia # legacy sibling".into(),
12661        });
12662        let err = d.validate().unwrap_err();
12663        let DepError::FonteCaminhoShellComment {
12664            nome,
12665            caminho,
12666            byte,
12667        } = err
12668        else {
12669            panic!("expected FonteCaminhoShellComment, got {err:?}");
12670        };
12671        assert_eq!(nome, "caixa-teia");
12672        assert_eq!(caminho, "../caixa-teia # legacy sibling");
12673        assert_eq!(byte, b'#');
12674    }
12675
12676    #[test]
12677    fn validate_rejects_path_fonte_with_caminho_carrying_yaml_comment_paste() {
12678        // The symmetric YAML flow-scalar / values.yaml / K8s-manifest
12679        // cross-idiom-leak shape (`"../caixa-teia  # pin"` — the
12680        // canonical "I copied a `path: ../caixa-teia  # pin` YAML
12681        // scalar-plus-comment entry out of an aligned values.yaml and
12682        // dropped it verbatim into the `:caminho` slot" paste-idiom).
12683        // Pinned separately from the shell-history shape so the
12684        // gate's coverage extends from the single-space `#` shape to
12685        // the YAML-canonical double-space `  #` shape. YAML 1.2 §6.6
12686        // requires the `#` to be preceded by whitespace to lex as a
12687        // comment (bare `foo#bar` is a single scalar); the double-
12688        // space paste from an aligned manifest is the canonical
12689        // shape.
12690        let d = dep_with_fonte(DepSource::Path {
12691            caminho: "../caixa-teia  # pin".into(),
12692        });
12693        let err = d.validate().unwrap_err();
12694        assert!(
12695            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
12696            "got {err:?}",
12697        );
12698    }
12699
12700    #[test]
12701    fn validate_rejects_path_fonte_with_caminho_carrying_url_fragment_anchor() {
12702        // The URL-fragment-identifier paste shape
12703        // (`"../caixa-teia#readme"` — the canonical
12704        // paste-from-browser-address-bar permalink shape where the
12705        // browser preserved the `#anchor` tail on the copy). Pinned
12706        // separately from the whitespace-separated shell / YAML
12707        // comment shapes so the gate covers the unpadded RFC 3986
12708        // §3.5 fragment-delimiter position too, not only positions
12709        // preceded by unquoted whitespace. Peer with the immediate-
12710        // sibling `is_git_repo_url` arm on the `:fonte :repo` axis
12711        // (a68f818) which closes the same byte under the same URL-
12712        // fragment-identifier banner.
12713        let d = dep_with_fonte(DepSource::Path {
12714            caminho: "../caixa-teia#readme".into(),
12715        });
12716        let err = d.validate().unwrap_err();
12717        assert!(
12718            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
12719            "got {err:?}",
12720        );
12721    }
12722
12723    #[test]
12724    fn validate_rejects_path_fonte_with_caminho_carrying_leading_shell_comment() {
12725        // Leading-position `#` shape (`"#../caixa-teia"` — the
12726        // "I copied a shell-comment-out entry from a commented-out
12727        // dep row" footgun). Pinned separately from the embedded
12728        // shapes so the gate covers every position, not only
12729        // whitespace-preceded / mid-value.
12730        let d = dep_with_fonte(DepSource::Path {
12731            caminho: "#../caixa-teia".into(),
12732        });
12733        let err = d.validate().unwrap_err();
12734        assert!(
12735            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
12736            "got {err:?}",
12737        );
12738    }
12739
12740    #[test]
12741    fn validate_accepts_path_fonte_with_caminho_carrying_no_shell_comment() {
12742        // The positive-control pin: the gate targets only `#`,
12743        // never adjacent printable ASCII or POSIX-valid bytes. The
12744        // canonical relative POSIX path (`"../caixa-teia"`) and a
12745        // nested deeply-pathed variant with adjacent printable
12746        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
12747        // to validate cleanly so the gate doesn't widen to a "no
12748        // printable punctuation anywhere" sweep that would defeat
12749        // the entire path-fonte author surface. Peer with
12750        // `validate_accepts_path_fonte_with_caminho_carrying_no_quote_grouping`
12751        // on the immediate-predecessor arm.
12752        let d = dep_with_fonte(DepSource::Path {
12753            caminho: "../caixa-teia/sub-dir.v2".into(),
12754        });
12755        d.validate().unwrap();
12756    }
12757
12758    #[test]
12759    fn fonte_caminho_shell_quote_grouping_fires_before_shell_comment() {
12760        // Cascade pin on the immediate-predecessor arm: a value
12761        // carrying both `'` and `#` (`"../'x'#pin"` — the canonical
12762        // "I pasted a strong-quoted literal followed by a URL-
12763        // fragment permalink tail" footgun) routes through
12764        // `FonteCaminhoShellQuoteGrouping` not
12765        // `FonteCaminhoShellComment`. The shell-string-literal-
12766        // delimiter is the load-bearing root-cause edit on every
12767        // probe-as-both value; same cascade discipline every prior
12768        // `:caminho` arm establishes.
12769        let d = dep_with_fonte(DepSource::Path {
12770            caminho: "../'x'#pin".into(),
12771        });
12772        let err = d.validate().unwrap_err();
12773        assert!(
12774            matches!(
12775                err,
12776                DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
12777            ),
12778            "got {err:?}",
12779        );
12780    }
12781
12782    #[test]
12783    fn fonte_caminho_shell_bracket_expansion_fires_before_shell_comment() {
12784        // Cascade pin on the upstream shell-bracket-expansion arm:
12785        // a value carrying both `[` and `#` (`"../[a-z]#pin"` — the
12786        // canonical "I pasted a glob-character-class followed by a
12787        // URL-fragment tail" footgun) routes through
12788        // `FonteCaminhoShellBracketExpansion` not
12789        // `FonteCaminhoShellComment`. The glob-character-class
12790        // expansion is the load-bearing root-cause edit on every
12791        // probe-as-both value.
12792        let d = dep_with_fonte(DepSource::Path {
12793            caminho: "../[a-z]#pin".into(),
12794        });
12795        let err = d.validate().unwrap_err();
12796        assert!(
12797            matches!(
12798                err,
12799                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
12800            ),
12801            "got {err:?}",
12802        );
12803    }
12804
12805    #[test]
12806    fn fonte_caminho_shell_brace_expansion_fires_before_shell_comment() {
12807        // Cascade pin on the upstream shell-brace-expansion arm: a
12808        // value carrying both `{` and `#` (`"../{a,b}#pin"` — the
12809        // canonical "I pasted a brace-expansion fan followed by a
12810        // URL-fragment tail" footgun) routes through
12811        // `FonteCaminhoShellBraceExpansion` not
12812        // `FonteCaminhoShellComment`. The brace-expansion fan is the
12813        // load-bearing root-cause edit on every probe-as-both value.
12814        let d = dep_with_fonte(DepSource::Path {
12815            caminho: "../{a,b}#pin".into(),
12816        });
12817        let err = d.validate().unwrap_err();
12818        assert!(
12819            matches!(
12820                err,
12821                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
12822            ),
12823            "got {err:?}",
12824        );
12825    }
12826
12827    #[test]
12828    fn fonte_caminho_shell_subshell_grouping_fires_before_shell_comment() {
12829        // Cascade pin on the upstream shell-subshell-grouping arm:
12830        // a value carrying both `(` and `#` (`"../(cd foo)#pin"` —
12831        // the canonical "I pasted a subshell-grouping followed by a
12832        // URL-fragment tail" footgun) routes through
12833        // `FonteCaminhoShellSubshellGrouping` not
12834        // `FonteCaminhoShellComment`. The modern Bourne `$(<cmd>)`
12835        // command-substitution boundary is the load-bearing axis on
12836        // every probe-as-both value.
12837        let d = dep_with_fonte(DepSource::Path {
12838            caminho: "../(cd foo)#pin".into(),
12839        });
12840        let err = d.validate().unwrap_err();
12841        assert!(
12842            matches!(
12843                err,
12844                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
12845            ),
12846            "got {err:?}",
12847        );
12848    }
12849
12850    #[test]
12851    fn fonte_caminho_shell_glob_fires_before_shell_comment() {
12852        // Cascade pin on the upstream shell-glob arm: a value
12853        // carrying both `*` and `#` (`"../caixa-teia/*#pin"` — the
12854        // canonical "I pasted a `*` unbounded pathname-expansion
12855        // followed by a URL-fragment tail" footgun) routes through
12856        // `FonteCaminhoShellGlob` not `FonteCaminhoShellComment`.
12857        // The unbounded pathname-expansion sentinel is the load-
12858        // bearing root-cause edit on every probe-as-both value.
12859        let d = dep_with_fonte(DepSource::Path {
12860            caminho: "../caixa-teia/*#pin".into(),
12861        });
12862        let err = d.validate().unwrap_err();
12863        assert!(
12864            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12865            "got {err:?}",
12866        );
12867    }
12868
12869    #[test]
12870    fn fonte_caminho_shell_command_substitution_fires_before_shell_comment() {
12871        // Cascade pin on the upstream shell-command-substitution
12872        // arm: a value carrying both a backtick and `#`
12873        // (``"../`whoami`#pin"`` — the canonical "I pasted a
12874        // legacy-backtick command-substitution followed by a URL-
12875        // fragment tail" footgun) routes through
12876        // `FonteCaminhoShellCommandSubstitution` not
12877        // `FonteCaminhoShellComment`. The CWE-78 shell-command-
12878        // injection vector is the load-bearing root-cause edit on
12879        // every probe-as-both value.
12880        let d = dep_with_fonte(DepSource::Path {
12881            caminho: "../`whoami`#pin".into(),
12882        });
12883        let err = d.validate().unwrap_err();
12884        assert!(
12885            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
12886            "got {err:?}",
12887        );
12888    }
12889
12890    #[test]
12891    fn fonte_caminho_shell_background_fires_before_shell_comment() {
12892        // Cascade pin on the upstream shell-background arm: a value
12893        // carrying both `&` and `#` (`"../caixa-teia&pin#tail"` —
12894        // the canonical "I pasted a `cmd &` background-launch
12895        // followed by a URL-fragment tail" footgun) routes through
12896        // `FonteCaminhoShellBackground` not
12897        // `FonteCaminhoShellComment`. The background-launch tail is
12898        // the load-bearing root-cause edit on every probe-as-both
12899        // value.
12900        let d = dep_with_fonte(DepSource::Path {
12901            caminho: "../caixa-teia&pin#tail".into(),
12902        });
12903        let err = d.validate().unwrap_err();
12904        assert!(
12905            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
12906            "got {err:?}",
12907        );
12908    }
12909
12910    #[test]
12911    fn fonte_caminho_shell_semicolon_fires_before_shell_comment() {
12912        // Cascade pin on the upstream shell-semicolon arm: a value
12913        // carrying both `;` and `#` (`"../caixa-teia;pin#tail"` —
12914        // the canonical sequential-cleanup + URL-fragment paste
12915        // idiom) routes through `FonteCaminhoShellSemicolon` not
12916        // `FonteCaminhoShellComment`. The sequential-command-
12917        // separator paste is the load-bearing root-cause edit on
12918        // every probe-as-both value.
12919        let d = dep_with_fonte(DepSource::Path {
12920            caminho: "../caixa-teia;pin#tail".into(),
12921        });
12922        let err = d.validate().unwrap_err();
12923        assert!(
12924            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
12925            "got {err:?}",
12926        );
12927    }
12928
12929    #[test]
12930    fn fonte_caminho_shell_pipe_fires_before_shell_comment() {
12931        // Cascade pin on the upstream shell-pipe arm: a value
12932        // carrying both `|` and `#` (`"../caixa-teia|pin#tail"` —
12933        // the canonical pipeline-to-URL-fragment paste idiom) routes
12934        // through `FonteCaminhoShellPipe` not
12935        // `FonteCaminhoShellComment`. The pipeline-tail paste is
12936        // the load-bearing root-cause edit on every probe-as-both
12937        // value.
12938        let d = dep_with_fonte(DepSource::Path {
12939            caminho: "../caixa-teia|pin#tail".into(),
12940        });
12941        let err = d.validate().unwrap_err();
12942        assert!(
12943            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
12944            "got {err:?}",
12945        );
12946    }
12947
12948    #[test]
12949    fn fonte_caminho_shell_redirection_fires_before_shell_comment() {
12950        // Cascade pin on the upstream shell-redirection arm: a
12951        // value carrying both `>` and `#` (`"../caixa-teia>log#pin"`
12952        // — the canonical "I pasted a `cmd > log` redirect followed
12953        // by a URL-fragment tail" footgun) routes through
12954        // `FonteCaminhoShellRedirection` not
12955        // `FonteCaminhoShellComment`. The input/output redirection
12956        // metachar carries the more self-locating `byte` payload,
12957        // so the prior arm wins on every probe-as-both value.
12958        let d = dep_with_fonte(DepSource::Path {
12959            caminho: "../caixa-teia>log#pin".into(),
12960        });
12961        let err = d.validate().unwrap_err();
12962        assert!(
12963            matches!(
12964                err,
12965                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
12966            ),
12967            "got {err:?}",
12968        );
12969    }
12970
12971    #[test]
12972    fn fonte_caminho_backslash_fires_before_shell_comment() {
12973        // Cascade pin on the upstream backslash arm: a value
12974        // carrying both `\` and `#` (`"..\caixa-teia#pin"` — the
12975        // canonical "I pasted a Windows-shell path followed by a
12976        // URL-fragment tail" footgun) routes through
12977        // `FonteCaminhoBackslash` not `FonteCaminhoShellComment`.
12978        // The cross-host-OS-separator divergence is the load-
12979        // bearing axis on every probe-as-both value.
12980        let d = dep_with_fonte(DepSource::Path {
12981            caminho: "..\\caixa-teia#pin".into(),
12982        });
12983        let err = d.validate().unwrap_err();
12984        assert!(
12985            matches!(err, DepError::FonteCaminhoBackslash { .. }),
12986            "got {err:?}",
12987        );
12988    }
12989
12990    #[test]
12991    fn fonte_caminho_control_char_fires_before_shell_comment() {
12992        // Cascade pin on the embedded-control-byte arm: a value
12993        // carrying both a control byte and `#` (`"../foo\n#pin"` —
12994        // the canonical paste-from-multiline-doc footgun where a
12995        // newline landed mid-caminho between the path and an
12996        // annotation) routes through `FonteCaminhoControlChar` not
12997        // `FonteCaminhoShellComment`. The POSIX-syscall-rejected-
12998        // byte diagnostic is the load-bearing axis on every value
12999        // that probes positive for both — mirrors the cascade
13000        // discipline on every prior arm.
13001        let d = dep_with_fonte(DepSource::Path {
13002            caminho: "../foo\n#pin".into(),
13003        });
13004        let err = d.validate().unwrap_err();
13005        assert!(
13006            matches!(err, DepError::FonteCaminhoControlChar { .. }),
13007            "got {err:?}",
13008        );
13009    }
13010
13011    #[test]
13012    fn fonte_caminho_absolute_fires_before_shell_comment() {
13013        // Cascade pin on the load-bearing leading-byte arm: a
13014        // leading `/` value with embedded `#` (`"/etc/foo#pin"`)
13015        // routes through `FonteCaminhoAbsolute` not
13016        // `FonteCaminhoShellComment` — the host-layout-leak
13017        // diagnostic is the load-bearing axis, the fragment byte is
13018        // the secondary observation. Same precedence logic as every
13019        // prior leading-byte arm.
13020        let d = dep_with_fonte(DepSource::Path {
13021            caminho: "/etc/foo#pin".into(),
13022        });
13023        let err = d.validate().unwrap_err();
13024        assert!(
13025            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
13026            "got {err:?}",
13027        );
13028    }
13029
13030    #[test]
13031    fn fonte_caminho_var_expansion_fires_before_shell_comment() {
13032        // Cascade pin on the upstream leading-`$` var-expansion
13033        // arm: a value carrying both a leading `$` and a `#`
13034        // (`"$DIR/foo#pin"` — the canonical "I pasted a `$DIR`
13035        // shell-variable at the head of a sibling-workspace path
13036        // followed by a URL-fragment tail" footgun) routes through
13037        // `FonteCaminhoVarExpansion` not `FonteCaminhoShellComment`.
13038        // The leading-byte shell-variable-expansion is the more
13039        // self-locating diagnostic on values that probe as both.
13040        let d = dep_with_fonte(DepSource::Path {
13041            caminho: "$DIR/foo#pin".into(),
13042        });
13043        let err = d.validate().unwrap_err();
13044        assert!(
13045            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
13046            "got {err:?}",
13047        );
13048    }
13049
13050    #[test]
13051    fn fonte_caminho_shell_comment_fires_before_trailing_slash() {
13052        // Cascade pin on the immediate-successor arm: a value
13053        // carrying both `#` and a trailing `/`
13054        // (`"../caixa-teia#pin/"` — the canonical "I tab-completed
13055        // a URL-fragment-carrying path" footgun) routes through
13056        // `FonteCaminhoShellComment` not
13057        // `FonteCaminhoTrailingSlash`. The embedded fragment /
13058        // comment-lead byte is the more semantic-locating axis (an
13059        // author who removes the `#pin` fragment typically also
13060        // drops the trailing separator since both are paste-from-
13061        // URL / paste-from-shell-tab-completion artifacts).
13062        let d = dep_with_fonte(DepSource::Path {
13063            caminho: "../caixa-teia#pin/".into(),
13064        });
13065        let err = d.validate().unwrap_err();
13066        assert!(
13067            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. },),
13068            "got {err:?}",
13069        );
13070    }
13071
13072    #[test]
13073    fn fonte_caminho_shell_comment_diagnostic_carries_offending_dep_caminho_and_byte() {
13074        // Diagnostic-shape pin (peer with
13075        // `fonte_caminho_shell_quote_grouping_diagnostic_carries_offending_dep_caminho_and_byte`
13076        // on the immediate-predecessor arm): the error's Display
13077        // surfaces the offending `:nome`, the offending `:caminho`
13078        // verbatim, the offending byte's hex / character form, and
13079        // names the shell-comment / URL-fragment-identifier /
13080        // YAML-comment cross-config-DSL footgun explicitly so a
13081        // `feira lint` run can render the diagnostic without
13082        // re-parsing.
13083        let d = dep_with_fonte(DepSource::Path {
13084            caminho: "../caixa-teia#readme".into(),
13085        });
13086        let rendered = d.validate().unwrap_err().to_string();
13087        assert!(
13088            rendered.contains("caixa-teia"),
13089            "diagnostic must name the offending dep: {rendered}",
13090        );
13091        assert!(
13092            rendered.contains("../caixa-teia#readme"),
13093            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
13094        );
13095        assert!(
13096            rendered.contains("0x23"),
13097            "diagnostic must surface the offending byte hex: {rendered:?}",
13098        );
13099        assert!(
13100            rendered.contains("shell-comment") || rendered.contains("comment-lead"),
13101            "diagnostic must name the shell-comment footgun: {rendered:?}",
13102        );
13103        assert!(
13104            rendered.contains("fragment") || rendered.contains("URL-fragment"),
13105            "diagnostic must reference the URL-fragment-identifier vocabulary: \
13106             {rendered:?}",
13107        );
13108    }
13109
13110    #[test]
13111    fn validate_rejects_path_fonte_with_caminho_carrying_url_percent_encoded_space() {
13112        // The canonical paste-from-browser-address-bar percent-
13113        // encoded-space footgun: an author copies `../caixa%20teia`
13114        // out of a URL-encoded README hyperlink / browser address
13115        // bar / percent-encoded permalink expecting `%20` to decode
13116        // to a literal space at the filesystem layer. POSIX
13117        // `std::path::Path` treats `%` as a literal path-component
13118        // byte, so `Path::join` looks for a literal
13119        // `./../caixa%20teia` subdirectory. `Path::is_absolute`
13120        // returns false on `..`, `%` is neither a leading-byte
13121        // sentinel nor a control byte nor `\` nor `<` / `>` nor
13122        // `|` nor `;` nor `&` nor backtick nor `*` / `?` nor `(` /
13123        // `)` nor `{` / `}` nor `[` / `]` nor `'` / `"` nor `#`,
13124        // and the value's last byte isn't `/` — so the value
13125        // silently passed every prior arm. The new arm moves the
13126        // rejection to validate time and names the offending dep +
13127        // caminho + byte verbatim.
13128        let d = dep_with_fonte(DepSource::Path {
13129            caminho: "../caixa%20teia".into(),
13130        });
13131        let err = d.validate().unwrap_err();
13132        let DepError::FonteCaminhoUrlPercentEncoding {
13133            nome,
13134            caminho,
13135            byte,
13136        } = err
13137        else {
13138            panic!("expected FonteCaminhoUrlPercentEncoding, got {err:?}");
13139        };
13140        assert_eq!(nome, "caixa-teia");
13141        assert_eq!(caminho, "../caixa%20teia");
13142        assert_eq!(byte, b'%');
13143    }
13144
13145    #[test]
13146    fn validate_rejects_path_fonte_with_caminho_carrying_url_percent_encoded_slash() {
13147        // The over-encoded path-separator shape (`"../caixa%2Fteia"`
13148        // intending the `%2F` as the URL encoding of `/`) locks a
13149        // `path:../caixa%2Fteia` BLAKE3 closure that diverges from
13150        // the byte-identical `path:../caixa/teia` form. Pinned
13151        // separately from the space-encoded shape so the gate's
13152        // coverage extends past the single canonical `%20` example
13153        // to any two-hex-digit percent-encoded sequence.
13154        let d = dep_with_fonte(DepSource::Path {
13155            caminho: "../caixa%2Fteia".into(),
13156        });
13157        let err = d.validate().unwrap_err();
13158        assert!(
13159            matches!(
13160                err,
13161                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
13162            ),
13163            "got {err:?}",
13164        );
13165    }
13166
13167    #[test]
13168    fn validate_rejects_path_fonte_with_caminho_carrying_lone_percent() {
13169        // The lone-`%` malformed-escape shape (`"../caixa-teia%foo"`
13170        // where `%` isn't followed by two hex digits) — every
13171        // WHATWG-conformant URL parser rejects the value at parse
13172        // time per RFC 3986 §2.1, but the byte would silently ride
13173        // into the lacre before the resolver subprocess crosses the
13174        // URL-parser boundary. Pinned separately from the well-
13175        // formed `%HH` shapes so the gate covers every percent-
13176        // occurrence, not only strictly-conformant escapes.
13177        let d = dep_with_fonte(DepSource::Path {
13178            caminho: "../caixa-teia%foo".into(),
13179        });
13180        let err = d.validate().unwrap_err();
13181        assert!(
13182            matches!(
13183                err,
13184                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
13185            ),
13186            "got {err:?}",
13187        );
13188    }
13189
13190    #[test]
13191    fn validate_rejects_path_fonte_with_caminho_carrying_leading_yaml_directive() {
13192        // The YAML-directive-lead paste shape (`"%YAML/../caixa-teia"`
13193        // — the canonical paste-from-top-of-doc YAML directive
13194        // block cross-idiom leak per YAML 1.2 §6.8.1). Pinned
13195        // separately from embedded shapes so the gate covers the
13196        // leading-position `%` too, not only mid-value occurrences.
13197        let d = dep_with_fonte(DepSource::Path {
13198            caminho: "%YAML/../caixa-teia".into(),
13199        });
13200        let err = d.validate().unwrap_err();
13201        assert!(
13202            matches!(
13203                err,
13204                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
13205            ),
13206            "got {err:?}",
13207        );
13208    }
13209
13210    #[test]
13211    fn validate_rejects_path_fonte_with_caminho_carrying_printf_format_specifier() {
13212        // The printf-format-specifier paste shape
13213        // (`"../caixa-%s-teia"` — the canonical paste-from-shell-
13214        // diagnostic-one-liner `printf "path=%s\n" ...` idiom, CWE-
13215        // 134 format-string-injection vector). Pinned separately
13216        // from the URL-encoding shapes so the gate's rationale
13217        // extends past the RFC 3986 axis to the C / POSIX printf
13218        // format-directive-lead axis.
13219        let d = dep_with_fonte(DepSource::Path {
13220            caminho: "../caixa-%s-teia".into(),
13221        });
13222        let err = d.validate().unwrap_err();
13223        assert!(
13224            matches!(
13225                err,
13226                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
13227            ),
13228            "got {err:?}",
13229        );
13230    }
13231
13232    #[test]
13233    fn validate_accepts_path_fonte_with_caminho_carrying_no_percent() {
13234        // The positive-control pin: the gate targets only `%`,
13235        // never adjacent printable ASCII or POSIX-valid bytes. The
13236        // canonical relative POSIX path (`"../caixa-teia"`) and a
13237        // nested deeply-pathed variant with adjacent printable
13238        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
13239        // to validate cleanly so the gate doesn't widen to a "no
13240        // printable punctuation anywhere" sweep that would defeat
13241        // the entire path-fonte author surface. Peer with
13242        // `validate_accepts_path_fonte_with_caminho_carrying_no_shell_comment`
13243        // on the immediate-predecessor arm.
13244        let d = dep_with_fonte(DepSource::Path {
13245            caminho: "../caixa-teia/sub-dir.v2".into(),
13246        });
13247        d.validate().unwrap();
13248    }
13249
13250    #[test]
13251    fn fonte_caminho_shell_comment_fires_before_url_percent_encoding() {
13252        // Cascade pin on the immediate-predecessor arm: a value
13253        // carrying both `#` and `%` (`"../caixa-teia#pin%20"` — the
13254        // canonical "I pasted a URL-fragment permalink followed by a
13255        // percent-encoded space tail" footgun) routes through
13256        // `FonteCaminhoShellComment` not
13257        // `FonteCaminhoUrlPercentEncoding`. The URL-fragment-
13258        // identifier is the load-bearing downstream-truncation edit
13259        // on every probe-as-both value; same cascade discipline
13260        // every prior `:caminho` arm establishes.
13261        let d = dep_with_fonte(DepSource::Path {
13262            caminho: "../caixa-teia#pin%20".into(),
13263        });
13264        let err = d.validate().unwrap_err();
13265        assert!(
13266            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
13267            "got {err:?}",
13268        );
13269    }
13270
13271    #[test]
13272    fn fonte_caminho_shell_quote_grouping_fires_before_url_percent_encoding() {
13273        // Cascade pin on the upstream shell-quote-grouping arm: a
13274        // value carrying both `'` and `%` (`"../'x'%20teia"` — the
13275        // canonical "I pasted a strong-quoted literal followed by
13276        // a percent-encoded space" footgun) routes through
13277        // `FonteCaminhoShellQuoteGrouping` not
13278        // `FonteCaminhoUrlPercentEncoding`. The shell-string-
13279        // literal-delimiter is the load-bearing root-cause edit on
13280        // every probe-as-both value.
13281        let d = dep_with_fonte(DepSource::Path {
13282            caminho: "../'x'%20teia".into(),
13283        });
13284        let err = d.validate().unwrap_err();
13285        assert!(
13286            matches!(
13287                err,
13288                DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
13289            ),
13290            "got {err:?}",
13291        );
13292    }
13293
13294    #[test]
13295    fn fonte_caminho_backslash_fires_before_url_percent_encoding() {
13296        // Cascade pin on the upstream backslash arm: a value
13297        // carrying both `\` and `%` (`"..\\caixa%20teia"` — the
13298        // canonical "I pasted a Windows-shell path followed by a
13299        // percent-encoded space" footgun) routes through
13300        // `FonteCaminhoBackslash` not
13301        // `FonteCaminhoUrlPercentEncoding`. The cross-host-OS-
13302        // separator divergence is the load-bearing root-cause edit
13303        // on every probe-as-both value.
13304        let d = dep_with_fonte(DepSource::Path {
13305            caminho: "..\\caixa%20teia".into(),
13306        });
13307        let err = d.validate().unwrap_err();
13308        assert!(
13309            matches!(err, DepError::FonteCaminhoBackslash { .. }),
13310            "got {err:?}",
13311        );
13312    }
13313
13314    #[test]
13315    fn fonte_caminho_control_char_fires_before_url_percent_encoding() {
13316        // Cascade pin on the upstream control-char arm: a value
13317        // carrying both a NUL byte and `%` (`"../caixa\0%20teia"` —
13318        // the canonical "I pasted a paste-from-binary-blob path
13319        // followed by a percent-encoded space" footgun) routes
13320        // through `FonteCaminhoControlChar` not
13321        // `FonteCaminhoUrlPercentEncoding`. The POSIX-syscall-
13322        // rejected byte is the load-bearing root-cause edit on
13323        // every probe-as-both value.
13324        let d = dep_with_fonte(DepSource::Path {
13325            caminho: "../caixa\0%20teia".into(),
13326        });
13327        let err = d.validate().unwrap_err();
13328        assert!(
13329            matches!(err, DepError::FonteCaminhoControlChar { byte: 0x00, .. },),
13330            "got {err:?}",
13331        );
13332    }
13333
13334    #[test]
13335    fn fonte_caminho_absolute_fires_before_url_percent_encoding() {
13336        // Cascade pin on the upstream absolute-path arm: a value
13337        // that's both absolute and carries `%` (`"/etc/passwd%20"`
13338        // — the canonical "I pasted an absolute path with a
13339        // percent-encoded space tail" footgun) routes through
13340        // `FonteCaminhoAbsolute` not
13341        // `FonteCaminhoUrlPercentEncoding`. The host-layout-leak is
13342        // the load-bearing root-cause edit on every probe-as-both
13343        // value.
13344        let d = dep_with_fonte(DepSource::Path {
13345            caminho: "/etc/passwd%20".into(),
13346        });
13347        let err = d.validate().unwrap_err();
13348        assert!(
13349            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
13350            "got {err:?}",
13351        );
13352    }
13353
13354    #[test]
13355    fn fonte_caminho_var_expansion_fires_before_url_percent_encoding() {
13356        // Cascade pin on the upstream var-expansion arm: a value
13357        // starting with `$` and carrying `%` (`"$HOME/caixa%20teia"`
13358        // — the canonical "I pasted a `$HOME`-rooted path with a
13359        // percent-encoded space" footgun) routes through
13360        // `FonteCaminhoVarExpansion` not
13361        // `FonteCaminhoUrlPercentEncoding`. The shell-variable-
13362        // expansion is the load-bearing root-cause edit on every
13363        // probe-as-both value.
13364        let d = dep_with_fonte(DepSource::Path {
13365            caminho: "$HOME/caixa%20teia".into(),
13366        });
13367        let err = d.validate().unwrap_err();
13368        assert!(
13369            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
13370            "got {err:?}",
13371        );
13372    }
13373
13374    #[test]
13375    fn fonte_caminho_url_percent_encoding_fires_before_trailing_slash() {
13376        // Cascade pin on the immediate-successor arm: a value
13377        // carrying both `%` and a trailing `/`
13378        // (`"../caixa%20teia/"` — the canonical "I tab-completed a
13379        // percent-encoded-space-carrying path" footgun) routes
13380        // through `FonteCaminhoUrlPercentEncoding` not
13381        // `FonteCaminhoTrailingSlash`. The embedded percent-
13382        // encoding-escape byte is the more semantic-locating axis
13383        // (an author who decodes the `%20` to a literal space is
13384        // likely to also tab-strip the trailing separator since
13385        // both are paste-from-URL / paste-from-shell-tab-completion
13386        // artifacts).
13387        let d = dep_with_fonte(DepSource::Path {
13388            caminho: "../caixa%20teia/".into(),
13389        });
13390        let err = d.validate().unwrap_err();
13391        assert!(
13392            matches!(
13393                err,
13394                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
13395            ),
13396            "got {err:?}",
13397        );
13398    }
13399
13400    #[test]
13401    fn fonte_caminho_url_percent_encoding_diagnostic_carries_offending_dep_caminho_and_byte() {
13402        // Diagnostic-shape pin (peer with
13403        // `fonte_caminho_shell_comment_diagnostic_carries_offending_dep_caminho_and_byte`
13404        // on the immediate-predecessor arm): the error's Display
13405        // surfaces the offending `:nome`, the offending `:caminho`
13406        // verbatim, the offending byte's hex / character form, and
13407        // names the URL-percent-encoding-escape / printf-format-
13408        // specifier footgun explicitly so a `feira lint` run can
13409        // render the diagnostic without re-parsing.
13410        let d = dep_with_fonte(DepSource::Path {
13411            caminho: "../caixa%20teia".into(),
13412        });
13413        let rendered = d.validate().unwrap_err().to_string();
13414        assert!(
13415            rendered.contains("caixa-teia"),
13416            "diagnostic must name the offending dep: {rendered}",
13417        );
13418        assert!(
13419            rendered.contains("../caixa%20teia"),
13420            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
13421        );
13422        assert!(
13423            rendered.contains("0x25"),
13424            "diagnostic must surface the offending byte hex: {rendered:?}",
13425        );
13426        assert!(
13427            rendered.contains("percent-encoding") || rendered.contains("percent-encoded"),
13428            "diagnostic must name the URL-percent-encoding-escape footgun: {rendered:?}",
13429        );
13430        assert!(
13431            rendered.contains("printf") || rendered.contains("format-specifier"),
13432            "diagnostic must reference the printf-format-specifier vocabulary: \
13433             {rendered:?}",
13434        );
13435    }
13436
13437    #[test]
13438    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_var_expansion() {
13439        // The canonical embedded-`$` shell-variable-expansion paste
13440        // shape (`"../foo$HOME/bar"` — an author copies a partially-
13441        // substituted shell one-liner where the leading segment is a
13442        // literal `../foo` while the mid segment carries the un-
13443        // substituted `$HOME` template). The leading-`$` position is
13444        // already gated by the f4efe9c leading-byte arm which routes
13445        // through `FonteCaminhoVarExpansion`; this arm closes the
13446        // last positional gap on `$` — every position on the axis is
13447        // structurally rejected.
13448        let d = dep_with_fonte(DepSource::Path {
13449            caminho: "../foo$HOME/bar".into(),
13450        });
13451        let err = d.validate().unwrap_err();
13452        let DepError::FonteCaminhoShellVariableExpansion {
13453            nome,
13454            caminho,
13455            byte,
13456        } = err
13457        else {
13458            panic!("expected FonteCaminhoShellVariableExpansion, got {err:?}");
13459        };
13460        assert_eq!(nome, "caixa-teia");
13461        assert_eq!(caminho, "../foo$HOME/bar");
13462        assert_eq!(byte, b'$');
13463    }
13464
13465    #[test]
13466    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_braced_var_expansion() {
13467        // The symmetric braced-CI-manifest paste shape
13468        // (`"../foo${WORKSPACE}/bar"` — the canonical paste-from-
13469        // GitHub-Actions-workflow / paste-from-`.gitlab-ci.yml`
13470        // footgun). Pinned separately from the bare-`$VAR` shape so
13471        // the gate covers both POSIX shell §2.6 Parameter Expansion
13472        // syntactic forms, not only the unbraced variant. The
13473        // embedded `{` byte in `${...}` is also caught by the 598b770
13474        // shell-brace-expansion arm but that arm fires earlier in
13475        // the cascade — the `$` arm's coverage extends to `${...}`
13476        // structurally, so the diagnostic asserted here is the
13477        // brace-expansion one (which is a valid outcome; the point
13478        // of the pin is that the value never survives validation).
13479        let d = dep_with_fonte(DepSource::Path {
13480            caminho: "../foo${WORKSPACE}/bar".into(),
13481        });
13482        let err = d.validate().unwrap_err();
13483        assert!(
13484            matches!(
13485                err,
13486                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. }
13487                    | DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
13488            ),
13489            "got {err:?}",
13490        );
13491    }
13492
13493    #[test]
13494    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_command_substitution() {
13495        // The paste-from-shell-prompt command-substitution idiom
13496        // (`"../foo$(whoami)/bar"`). Pinned separately from the bare-
13497        // `$VAR` shape so the gate's rationale extends to POSIX shell
13498        // §2.6.3 Command Substitution (the modern `$(<cmd>)` form; the
13499        // legacy `` `<cmd>` `` form is already closed by the c370458
13500        // backtick arm). The embedded `(` byte in `$(...)` is also
13501        // caught structurally by the 0633c91 shell-subshell-grouping
13502        // arm which fires earlier in the cascade — the diagnostic
13503        // asserted here is either outcome, since both structurally
13504        // reject the value; the point of the pin is that the value
13505        // never survives validation.
13506        let d = dep_with_fonte(DepSource::Path {
13507            caminho: "../foo$(whoami)/bar".into(),
13508        });
13509        let err = d.validate().unwrap_err();
13510        assert!(
13511            matches!(
13512                err,
13513                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. }
13514                    | DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
13515            ),
13516            "got {err:?}",
13517        );
13518    }
13519
13520    #[test]
13521    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_positional_parameter() {
13522        // The paste-from-`Makefile` / paste-from-SQL-migration bare-
13523        // `$1` positional-parameter shape (`"../foo$1/bar"` — a Make
13524        // automatic-variable `$1` or a PostgreSQL bind-parameter `$1`
13525        // idiom copied into a caminho template). None of the prior
13526        // shell-metachar arms cover this shape (`1` is a bare digit;
13527        // no `(` / `{` / letter follows the `$`), so the arm is the
13528        // sole gate on the shape.
13529        let d = dep_with_fonte(DepSource::Path {
13530            caminho: "../foo$1/bar".into(),
13531        });
13532        let err = d.validate().unwrap_err();
13533        assert!(
13534            matches!(
13535                err,
13536                DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
13537            ),
13538            "got {err:?}",
13539        );
13540    }
13541
13542    #[test]
13543    fn validate_accepts_path_fonte_with_caminho_carrying_no_dollar() {
13544        // The positive-control pin (peer with
13545        // `validate_accepts_path_fonte_with_caminho_carrying_no_percent`
13546        // on the immediate-predecessor arm): the gate targets only
13547        // `$`, never adjacent printable ASCII or POSIX-valid bytes.
13548        // A relative POSIX path carrying dashes / dots / slashes /
13549        // digits (`"../caixa-teia/sub-dir.v2"`) must continue to
13550        // validate cleanly so the gate doesn't widen to a "no
13551        // printable punctuation anywhere" sweep that would defeat
13552        // the entire path-fonte author surface.
13553        let d = dep_with_fonte(DepSource::Path {
13554            caminho: "../caixa-teia/sub-dir.v2".into(),
13555        });
13556        d.validate().unwrap();
13557    }
13558
13559    #[test]
13560    fn fonte_caminho_var_expansion_fires_before_shell_variable_expansion() {
13561        // Cascade pin on the leading-`$` sibling arm at line 540: a
13562        // value starting with `$` and carrying an embedded `$` too
13563        // (`"$HOME/foo$WORKSPACE/bar"` — the canonical "I pasted a
13564        // fully-templated CI path with two un-substituted variables")
13565        // routes through `FonteCaminhoVarExpansion` not
13566        // `FonteCaminhoShellVariableExpansion`. The leading-byte
13567        // host-layout-leak is the load-bearing self-locating axis
13568        // (the leading position dominates the semantic-locating
13569        // rationale on every probe-as-both value); the embedded
13570        // arm's positional-agnostic sweep catches only values whose
13571        // leading byte doesn't route through the earlier leading-
13572        // byte arms.
13573        let d = dep_with_fonte(DepSource::Path {
13574            caminho: "$HOME/foo$WORKSPACE/bar".into(),
13575        });
13576        let err = d.validate().unwrap_err();
13577        assert!(
13578            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
13579            "got {err:?}",
13580        );
13581    }
13582
13583    #[test]
13584    fn fonte_caminho_url_percent_encoding_fires_before_shell_variable_expansion() {
13585        // Cascade pin on the immediate-predecessor arm: a value
13586        // carrying both `%` and embedded `$` (`"../foo%20$HOME/bar"`
13587        // — the canonical "I pasted a percent-encoded space adjacent
13588        // to a `$HOME` template") routes through
13589        // `FonteCaminhoUrlPercentEncoding` not
13590        // `FonteCaminhoShellVariableExpansion`. The URL-percent-
13591        // encoding-escape byte is the more semantic-locating axis
13592        // (the paste-from-browser-address-bar shape is the load-
13593        // bearing self-locating edit); same cascade discipline every
13594        // prior `:caminho` arm establishes.
13595        let d = dep_with_fonte(DepSource::Path {
13596            caminho: "../foo%20$HOME/bar".into(),
13597        });
13598        let err = d.validate().unwrap_err();
13599        assert!(
13600            matches!(
13601                err,
13602                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
13603            ),
13604            "got {err:?}",
13605        );
13606    }
13607
13608    #[test]
13609    fn fonte_caminho_shell_variable_expansion_fires_before_trailing_slash() {
13610        // Cascade pin on the immediate-successor arm: a value
13611        // carrying both embedded `$` and a trailing `/`
13612        // (`"../foo$HOME/bar/"` — the canonical "I tab-completed a
13613        // `$HOME`-template-carrying path") routes through
13614        // `FonteCaminhoShellVariableExpansion` not
13615        // `FonteCaminhoTrailingSlash`. The embedded shell-variable-
13616        // expansion byte is the more semantic-locating axis on
13617        // probe-as-both values (an author who substitutes the
13618        // `$HOME` template with a literal value is likely to also
13619        // tab-strip the trailing separator).
13620        let d = dep_with_fonte(DepSource::Path {
13621            caminho: "../foo$HOME/bar/".into(),
13622        });
13623        let err = d.validate().unwrap_err();
13624        assert!(
13625            matches!(
13626                err,
13627                DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
13628            ),
13629            "got {err:?}",
13630        );
13631    }
13632
13633    #[test]
13634    fn fonte_caminho_shell_variable_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
13635        // Diagnostic-shape pin (peer with
13636        // `fonte_caminho_url_percent_encoding_diagnostic_carries_offending_dep_caminho_and_byte`
13637        // on the immediate-predecessor arm): the error's Display
13638        // surfaces the offending `:nome`, the offending `:caminho`
13639        // verbatim, the offending byte's hex / character form, and
13640        // names the shell-variable-expansion / command-substitution
13641        // footgun explicitly so a `feira lint` run can render the
13642        // diagnostic without re-parsing.
13643        let d = dep_with_fonte(DepSource::Path {
13644            caminho: "../foo$HOME/bar".into(),
13645        });
13646        let rendered = d.validate().unwrap_err().to_string();
13647        assert!(
13648            rendered.contains("caixa-teia"),
13649            "diagnostic must name the offending dep: {rendered}",
13650        );
13651        assert!(
13652            rendered.contains("../foo$HOME/bar"),
13653            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
13654        );
13655        assert!(
13656            rendered.contains("0x24"),
13657            "diagnostic must surface the offending byte hex: {rendered:?}",
13658        );
13659        assert!(
13660            rendered.contains("variable-expansion") || rendered.contains("variable expansion"),
13661            "diagnostic must name the shell-variable-expansion footgun: {rendered:?}",
13662        );
13663        assert!(
13664            rendered.contains("command-substitution") || rendered.contains("command substitution"),
13665            "diagnostic must reference the command-substitution vocabulary: {rendered:?}",
13666        );
13667    }
13668
13669    #[test]
13670    fn validate_rejects_path_fonte_with_caminho_carrying_shell_history_expansion() {
13671        // The fail-before-pass-after pin for the canonical paste-from-
13672        // shell-history footgun on `:caminho`. An author copies a `cd
13673        // ../caixa-teia && !sudo make install` one-liner from a quick-
13674        // start README, intending the trailing `!sudo` as a shell-
13675        // history-expansion reference but the typed slot is itself a
13676        // byte-level string parser, not a shell context, so the byte
13677        // rides into the value verbatim. Until this arm landed the `!`
13678        // byte silently passed every prior `:caminho` cascade arm
13679        // (`!` isn't `\` / `<` / `>` / `|` / `;` / `&` / backtick /
13680        // `*` / `?` / `(` / `)` / `{` / `}` / `[` / `]` / `'` / `"` /
13681        // `#` / `%` / `$`); bash with the default `histexpand` mode
13682        // rewrites `!command` to the most recent history entry
13683        // beginning with `command`, the canonical RCE-class injection
13684        // vector when the byte rides into a shell argument executed
13685        // under `bash -i` (the operator-notebook interactive shell).
13686        let d = dep_with_fonte(DepSource::Path {
13687            caminho: "../caixa-teia!sudo".into(),
13688        });
13689        let err = d.validate().unwrap_err();
13690        let DepError::FonteCaminhoShellHistoryExpansion {
13691            nome,
13692            caminho,
13693            byte,
13694        } = err
13695        else {
13696            panic!("expected FonteCaminhoShellHistoryExpansion, got {err:?}");
13697        };
13698        assert_eq!(nome, "caixa-teia");
13699        assert_eq!(caminho, "../caixa-teia!sudo");
13700        assert_eq!(byte, b'!');
13701    }
13702
13703    #[test]
13704    fn validate_rejects_path_fonte_with_caminho_carrying_double_bang_history_reference() {
13705        // The symmetric `!!` repeat-prior-command paste idiom (peer with
13706        // `validate_rejects_git_fonte_with_repo_carrying_double_bang_history_reference`
13707        // on `is_git_repo_url`). Pinned separately from the wrapped
13708        // `!command` shape so a future diagnostic-surface change that
13709        // only checked the leading or paired-bang position surfaces
13710        // here — the per-byte arm fires anywhere `!` appears in the
13711        // value, including at consecutive positions in the middle.
13712        let d = dep_with_fonte(DepSource::Path {
13713            caminho: "../foo!!/bar".into(),
13714        });
13715        let err = d.validate().unwrap_err();
13716        assert!(
13717            matches!(
13718                err,
13719                DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
13720            ),
13721            "got {err:?}",
13722        );
13723    }
13724
13725    #[test]
13726    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_enthusiasm_bang() {
13727        // The English-typography enthusiasm-form paste-from-prose
13728        // idiom: an author writes `:caminho "../caixa-teia!"`
13729        // expecting the substrate to coerce it to a kebab-case slug.
13730        // Pinned separately from the `!<word>` shell-history shape so
13731        // the gate's rationale extends to the paste-from-prose surface
13732        // (the same rationale the peer `is_git_repo_url` bang arm at
13733        // 7d53c68 covers). None of the prior shell-metachar arms cover
13734        // this shape (no `!<word>` reference and no `!!` repeat), so
13735        // the arm is the sole gate on the shape.
13736        let d = dep_with_fonte(DepSource::Path {
13737            caminho: "../caixa-teia!".into(),
13738        });
13739        let err = d.validate().unwrap_err();
13740        assert!(
13741            matches!(
13742                err,
13743                DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
13744            ),
13745            "got {err:?}",
13746        );
13747    }
13748
13749    #[test]
13750    fn validate_accepts_path_fonte_with_caminho_carrying_no_bang() {
13751        // The positive-control pin (peer with
13752        // `validate_accepts_path_fonte_with_caminho_carrying_no_dollar`
13753        // on the immediate-predecessor arm): the gate targets only
13754        // `!`, never adjacent printable ASCII or POSIX-valid bytes.
13755        // A relative POSIX path carrying dashes / dots / slashes /
13756        // digits (`"../caixa-teia/sub-dir.v2"`) must continue to
13757        // validate cleanly so the gate doesn't widen to a "no
13758        // printable punctuation anywhere" sweep that would defeat
13759        // the entire path-fonte author surface.
13760        let d = dep_with_fonte(DepSource::Path {
13761            caminho: "../caixa-teia/sub-dir.v2".into(),
13762        });
13763        d.validate().unwrap();
13764    }
13765
13766    #[test]
13767    fn fonte_caminho_shell_variable_expansion_fires_before_shell_history_expansion() {
13768        // Cascade pin on the immediate-predecessor arm: a value
13769        // carrying both embedded `$` and `!` (`"../foo$HOME/bar!sudo"`
13770        // — the canonical "I pasted a `$HOME`-templated path adjacent
13771        // to a trailing `!sudo` history-expansion") routes through
13772        // `FonteCaminhoShellVariableExpansion` not
13773        // `FonteCaminhoShellHistoryExpansion`. The shell-variable-
13774        // expansion byte is the more semantic-locating axis on
13775        // probe-as-both values (the paste-from-CI-manifest-with-`$VAR`-
13776        // template shape is the load-bearing self-locating edit);
13777        // same cascade discipline every prior `:caminho` arm
13778        // establishes.
13779        let d = dep_with_fonte(DepSource::Path {
13780            caminho: "../foo$HOME/bar!sudo".into(),
13781        });
13782        let err = d.validate().unwrap_err();
13783        assert!(
13784            matches!(
13785                err,
13786                DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
13787            ),
13788            "got {err:?}",
13789        );
13790    }
13791
13792    #[test]
13793    fn fonte_caminho_shell_history_expansion_fires_before_trailing_slash() {
13794        // Cascade pin on the immediate-successor arm: a value carrying
13795        // both embedded `!` and a trailing `/` (`"../caixa-teia!sudo/"`
13796        // — the canonical "I tab-completed a `!sudo`-carrying path")
13797        // routes through `FonteCaminhoShellHistoryExpansion` not
13798        // `FonteCaminhoTrailingSlash`. The embedded shell-history-
13799        // expansion byte is the more semantic-locating axis on probe-
13800        // as-both values (an author who removes the `!sudo` history
13801        // reference is likely to also tab-strip the trailing separator).
13802        let d = dep_with_fonte(DepSource::Path {
13803            caminho: "../caixa-teia!sudo/".into(),
13804        });
13805        let err = d.validate().unwrap_err();
13806        assert!(
13807            matches!(
13808                err,
13809                DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
13810            ),
13811            "got {err:?}",
13812        );
13813    }
13814
13815    #[test]
13816    fn fonte_caminho_shell_history_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
13817        // Diagnostic-shape pin (peer with
13818        // `fonte_caminho_shell_variable_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
13819        // on the immediate-predecessor arm): the error's Display
13820        // surfaces the offending `:nome`, the offending `:caminho`
13821        // verbatim, the offending byte's hex / character form, and
13822        // names the shell-history-expansion / bang-operator footgun
13823        // explicitly so a `feira lint` run can render the diagnostic
13824        // without re-parsing.
13825        let d = dep_with_fonte(DepSource::Path {
13826            caminho: "../caixa-teia!sudo".into(),
13827        });
13828        let rendered = d.validate().unwrap_err().to_string();
13829        assert!(
13830            rendered.contains("caixa-teia"),
13831            "diagnostic must name the offending dep: {rendered}",
13832        );
13833        assert!(
13834            rendered.contains("../caixa-teia!sudo"),
13835            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
13836        );
13837        assert!(
13838            rendered.contains("0x21"),
13839            "diagnostic must surface the offending byte hex: {rendered:?}",
13840        );
13841        assert!(
13842            rendered.contains("history-expansion") || rendered.contains("history expansion"),
13843            "diagnostic must name the shell-history-expansion footgun: {rendered:?}",
13844        );
13845        assert!(
13846            rendered.contains("bang"),
13847            "diagnostic must reference the bang-operator vocabulary: {rendered:?}",
13848        );
13849    }
13850
13851    #[test]
13852    fn validate_rejects_path_fonte_with_caminho_carrying_shell_history_substitution() {
13853        // The fail-before-pass-after pin for the canonical paste-from-
13854        // shell-history-quick-substitution footgun on `:caminho`. An
13855        // author copies a `git clone <bad-url>` line from their terminal,
13856        // corrects it via bash's `^bad^good` quick-substitution history
13857        // operator (bash reference §9.3, `set -o histexpand` mode's
13858        // default for interactive sessions), and pastes the trailing
13859        // `^bad^good` substitution fragment into a `:caminho` value
13860        // without trimming the leading `git clone` prefix — the byte
13861        // rides into the manifest verbatim. Until this arm landed the
13862        // `^` byte silently passed every prior `:caminho` cascade arm
13863        // (`^` isn't `\` / `<` / `>` / `|` / `;` / `&` / backtick / `*`
13864        // / `?` / `(` / `)` / `{` / `}` / `[` / `]` / `'` / `"` / `#` /
13865        // `%` / `$` / `!`); bash with the default `histexpand` mode
13866        // rewrites the prior command's `bad` string to `good` and re-
13867        // executes it, the paired-operator half of the `set -o
13868        // histexpand` feature the peer `!` arm already closes the prefix
13869        // half of. The peer `is_git_repo_url` axis rejects the byte at
13870        // 49e142f under the same shell-history-substitution / RFC-3986-
13871        // unwise banner.
13872        let d = dep_with_fonte(DepSource::Path {
13873            caminho: "../foo^bad^good".into(),
13874        });
13875        let err = d.validate().unwrap_err();
13876        let DepError::FonteCaminhoShellHistorySubstitution {
13877            nome,
13878            caminho,
13879            byte,
13880        } = err
13881        else {
13882            panic!("expected FonteCaminhoShellHistorySubstitution, got {err:?}");
13883        };
13884        assert_eq!(nome, "caixa-teia");
13885        assert_eq!(caminho, "../foo^bad^good");
13886        assert_eq!(byte, b'^');
13887    }
13888
13889    #[test]
13890    fn validate_rejects_path_fonte_with_caminho_carrying_regex_negation_anchor() {
13891        // The symmetric paste-from-doc-grep-pipeline footgun (peer with
13892        // `validate_rejects_git_fonte_with_repo_carrying_caret_regex_anchor`
13893        // on `is_git_repo_url`). An author copies a `grep '^archived'`
13894        // regex-anchor / negation idiom from a doc snippet and the byte
13895        // rides in verbatim. Pinned separately from the `^old^new^`
13896        // quick-substitution shape so a future diagnostic-surface change
13897        // that only checked the paired-caret history-substitution
13898        // position surfaces here — the per-byte arm fires anywhere `^`
13899        // appears in the value, including at a solitary leading-of-
13900        // segment position.
13901        let d = dep_with_fonte(DepSource::Path {
13902            caminho: "../foo/^archived".into(),
13903        });
13904        let err = d.validate().unwrap_err();
13905        assert!(
13906            matches!(
13907                err,
13908                DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
13909            ),
13910            "got {err:?}",
13911        );
13912    }
13913
13914    #[test]
13915    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_history_substitution_open() {
13916        // The trailing-`^` history-substitution-open shape — an author
13917        // starts typing a `^bad^good` quick-substitution but pastes only
13918        // the leading `^` sentinel before context-switching (a bash-
13919        // reference §9.3 valid histexpand prefix on its own — even a
13920        // solitary `^` on the prior command's whole re-execution shape).
13921        // Pinned separately from the `^old^new^` full-form and the leading-
13922        // of-segment `^archived` regex-anchor shape so the gate's
13923        // rationale extends to the paste-from-shell-history-with-only-
13924        // the-first-byte-selected surface. None of the prior shell-
13925        // metachar arms cover this shape.
13926        let d = dep_with_fonte(DepSource::Path {
13927            caminho: "../caixa-teia^".into(),
13928        });
13929        let err = d.validate().unwrap_err();
13930        assert!(
13931            matches!(
13932                err,
13933                DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
13934            ),
13935            "got {err:?}",
13936        );
13937    }
13938
13939    #[test]
13940    fn validate_accepts_path_fonte_with_caminho_carrying_no_caret() {
13941        // The positive-control pin (peer with
13942        // `validate_accepts_path_fonte_with_caminho_carrying_no_bang`
13943        // on the immediate-predecessor arm): the gate targets only
13944        // `^`, never adjacent printable ASCII or POSIX-valid bytes.
13945        // A relative POSIX path carrying dashes / dots / slashes /
13946        // digits / underscore (`"../caixa-teia/sub_v2.rc"`) must
13947        // continue to validate cleanly so the gate doesn't widen to
13948        // a "no printable punctuation anywhere" sweep that would
13949        // defeat the entire path-fonte author surface.
13950        let d = dep_with_fonte(DepSource::Path {
13951            caminho: "../caixa-teia/sub_v2.rc".into(),
13952        });
13953        d.validate().unwrap();
13954    }
13955
13956    #[test]
13957    fn fonte_caminho_shell_history_expansion_fires_before_shell_history_substitution() {
13958        // Cascade pin on the immediate-predecessor arm: a value carrying
13959        // both embedded `!` and `^` (`"../foo!sudo^bad^good"` — the
13960        // canonical "I pasted a `!sudo` history-reference next to a
13961        // `^bad^good` quick-substitution") routes through
13962        // `FonteCaminhoShellHistoryExpansion` not
13963        // `FonteCaminhoShellHistorySubstitution`. The `!` prefix form is
13964        // the more semantic-locating axis on probe-as-both values (an
13965        // author who removes the `!sudo` reference is likely to also
13966        // strip the paired `^` substitution fragment); same cascade
13967        // discipline every prior `:caminho` arm establishes.
13968        let d = dep_with_fonte(DepSource::Path {
13969            caminho: "../foo!sudo^bad^good".into(),
13970        });
13971        let err = d.validate().unwrap_err();
13972        assert!(
13973            matches!(
13974                err,
13975                DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
13976            ),
13977            "got {err:?}",
13978        );
13979    }
13980
13981    #[test]
13982    fn fonte_caminho_shell_history_substitution_fires_before_trailing_slash() {
13983        // Cascade pin on the immediate-successor arm: a value carrying
13984        // both embedded `^` and a trailing `/` (`"../foo^bad^good/"` —
13985        // the canonical "I tab-completed a `^bad^good`-carrying path")
13986        // routes through `FonteCaminhoShellHistorySubstitution` not
13987        // `FonteCaminhoTrailingSlash`. The embedded shell-history-
13988        // substitution byte is the more semantic-locating axis on probe-
13989        // as-both values (an author who removes the `^bad^good`
13990        // substitution fragment is likely to also tab-strip the trailing
13991        // separator).
13992        let d = dep_with_fonte(DepSource::Path {
13993            caminho: "../foo^bad^good/".into(),
13994        });
13995        let err = d.validate().unwrap_err();
13996        assert!(
13997            matches!(
13998                err,
13999                DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
14000            ),
14001            "got {err:?}",
14002        );
14003    }
14004
14005    #[test]
14006    fn fonte_caminho_shell_history_substitution_diagnostic_carries_offending_dep_caminho_and_byte()
14007    {
14008        // Diagnostic-shape pin (peer with
14009        // `fonte_caminho_shell_history_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
14010        // on the immediate-predecessor arm): the error's Display
14011        // surfaces the offending `:nome`, the offending `:caminho`
14012        // verbatim, the offending byte's hex form, and names the
14013        // shell-history-substitution / RFC-3986-'unwise' / regex-
14014        // negation footgun explicitly so a `feira lint` run can render
14015        // the diagnostic without re-parsing.
14016        let d = dep_with_fonte(DepSource::Path {
14017            caminho: "../foo^bad^good".into(),
14018        });
14019        let rendered = d.validate().unwrap_err().to_string();
14020        assert!(
14021            rendered.contains("caixa-teia"),
14022            "diagnostic must name the offending dep: {rendered}",
14023        );
14024        assert!(
14025            rendered.contains("../foo^bad^good"),
14026            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
14027        );
14028        assert!(
14029            rendered.contains("0x5e") || rendered.contains("0x5E"),
14030            "diagnostic must surface the offending byte hex: {rendered:?}",
14031        );
14032        assert!(
14033            rendered.contains("history-substitution") || rendered.contains("history substitution"),
14034            "diagnostic must name the shell-history-substitution footgun: {rendered:?}",
14035        );
14036        assert!(
14037            rendered.contains("unwise"),
14038            "diagnostic must reference the RFC-3986 'unwise' set vocabulary: {rendered:?}",
14039        );
14040    }
14041
14042    #[test]
14043    fn fonte_repo_empty_fires_before_pin_missing() {
14044        // Order pin: empty `:repo` is the more self-locating diagnostic
14045        // (every git source needs a repo; the pin discussion is
14046        // secondary), so it fires before the pin-missing arm even when
14047        // both are violated. Mirrors the
14048        // `nome_empty_takes_precedence_over_versao_invalid` ordering
14049        // discipline on the per-entry layer.
14050        let d = dep_with_fonte(DepSource::Git {
14051            repo: String::new(),
14052            tag: None,
14053            rev: None,
14054            branch: None,
14055        });
14056        let err = d.validate().unwrap_err();
14057        assert!(
14058            matches!(err, DepError::FonteRepoEmpty { .. }),
14059            "got {err:?}"
14060        );
14061    }
14062
14063    #[test]
14064    fn fonte_pin_missing_fires_before_pin_empty() {
14065        // Order pin: a fully-None pin set is structurally distinct from
14066        // a Some(empty) pin — the first surfaces as FontePinMissing
14067        // (no axis chosen), the second as FontePinEmpty (axis chosen
14068        // but value blank). Pin the disjoint relationship so a future
14069        // unification collapses to one variant only as a structural
14070        // decision.
14071        let d = dep_with_fonte(DepSource::Git {
14072            repo: "github:pleme-io/caixa-teia".into(),
14073            tag: None,
14074            rev: None,
14075            branch: None,
14076        });
14077        assert!(matches!(
14078            d.validate().unwrap_err(),
14079            DepError::FontePinMissing { .. }
14080        ));
14081    }
14082
14083    #[test]
14084    fn nome_empty_takes_precedence_over_fonte_invalid() {
14085        // Order pin: a per-entry diagnostic without a non-empty :nome
14086        // can't be self-locating, so :nome "" fires first even when
14087        // :fonte is also malformed. Mirrors
14088        // `nome_empty_takes_precedence_over_versao_invalid` on the
14089        // adjacent axis.
14090        let mut d = dep_with_fonte(DepSource::Git {
14091            repo: String::new(),
14092            tag: None,
14093            rev: None,
14094            branch: None,
14095        });
14096        d.nome = String::new();
14097        assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
14098    }
14099
14100    #[test]
14101    fn versao_invalid_takes_precedence_over_fonte_invalid() {
14102        // Order pin: the :versao parse-side diagnostic is narrower than
14103        // the :fonte shape diagnostic — a malformed :versao always names
14104        // the parser's reason, which is more actionable than the
14105        // :fonte gate's "the pins are wrong" wording. Pin the ordering
14106        // so a re-ordering surfaces here.
14107        let mut d = dep_with_fonte(DepSource::Git {
14108            repo: String::new(),
14109            tag: None,
14110            rev: None,
14111            branch: None,
14112        });
14113        d.versao = "v0.1".into();
14114        let err = d.validate().unwrap_err();
14115        assert!(
14116            matches!(err, DepError::VersaoInvalid { ref nome, .. } if nome == "caixa-teia"),
14117            "got {err:?}"
14118        );
14119    }
14120
14121    #[test]
14122    fn fonte_invalid_diagnostic_carries_offending_nome() {
14123        // The diagnostic-shape pin: every :fonte error variant names
14124        // the offending dep's :nome verbatim, so the author can grep
14125        // caixa.lisp for the `:nome "<n>"` block and fix it in one
14126        // edit. Cover all seven variants so a future variant addition
14127        // forces a parallel diagnostic-shape decision.
14128        for (case, fonte) in [
14129            (
14130                "repo-empty",
14131                DepSource::Git {
14132                    repo: String::new(),
14133                    tag: Some("v1".into()),
14134                    rev: None,
14135                    branch: None,
14136                },
14137            ),
14138            (
14139                "repo-shape",
14140                DepSource::Git {
14141                    repo: "github:p/x ".into(),
14142                    tag: Some("v1".into()),
14143                    rev: None,
14144                    branch: None,
14145                },
14146            ),
14147            (
14148                "pin-missing",
14149                DepSource::Git {
14150                    repo: "github:p/x".into(),
14151                    tag: None,
14152                    rev: None,
14153                    branch: None,
14154                },
14155            ),
14156            (
14157                "pin-ambiguous",
14158                DepSource::Git {
14159                    repo: "github:p/x".into(),
14160                    tag: Some("v1".into()),
14161                    rev: None,
14162                    branch: Some("main".into()),
14163                },
14164            ),
14165            (
14166                "pin-empty",
14167                DepSource::Git {
14168                    repo: "github:p/x".into(),
14169                    tag: Some(String::new()),
14170                    rev: None,
14171                    branch: None,
14172                },
14173            ),
14174            (
14175                "caminho-empty",
14176                DepSource::Path {
14177                    caminho: String::new(),
14178                },
14179            ),
14180            (
14181                "caminho-absolute",
14182                DepSource::Path {
14183                    caminho: "/home/me/work/caixa-teia".into(),
14184                },
14185            ),
14186        ] {
14187            let d = dep_with_fonte(fonte);
14188            let msg = d
14189                .validate()
14190                .expect_err(&format!("{case}: expected fonte error"))
14191                .to_string();
14192            assert!(
14193                msg.contains("\"caixa-teia\""),
14194                "{case}: diagnostic must quote the offending :nome verbatim, got {msg:?}"
14195            );
14196        }
14197    }
14198
14199    // -- :tag / :branch value-shape gate ----------------------------------
14200
14201    #[test]
14202    fn validate_rejects_git_fonte_with_tag_carrying_trailing_space() {
14203        // The canonical paste-from-doc footgun on `:tag` — author
14204        // copies `"v0.1.0 "` (trailing space) out of a release-notes
14205        // paragraph. Until this gate landed the empty-pin arm passed
14206        // (the string isn't empty), the resolver issued
14207        // `git fetch <remote> tag 'v0.1.0 '`, and the failure
14208        // surfaced at clone time with a quoting-confused git error
14209        // far from the source caixa.lisp. The new gate moves the
14210        // check to caixa-build time and names the offending dep +
14211        // pin + value verbatim.
14212        let d = dep_with_fonte(DepSource::Git {
14213            repo: "github:pleme-io/caixa-teia".into(),
14214            tag: Some("v0.1.0 ".into()),
14215            rev: None,
14216            branch: None,
14217        });
14218        let err = d.validate().unwrap_err();
14219        let DepError::FontePinShape {
14220            nome,
14221            pin,
14222            value,
14223            reason,
14224        } = err
14225        else {
14226            panic!("expected FontePinShape, got other variant");
14227        };
14228        assert_eq!(nome, "caixa-teia");
14229        assert_eq!(pin, ":tag");
14230        assert_eq!(value, "v0.1.0 ");
14231        assert!(
14232            reason.contains("whitespace"),
14233            "reason must surface the whitespace arm, got {reason:?}"
14234        );
14235    }
14236
14237    #[test]
14238    fn validate_rejects_git_fonte_with_tag_carrying_lock_suffix() {
14239        // The `.lock` suffix is git's atomic-rename guard for
14240        // in-flight ref updates — a refname ending in `.lock` is
14241        // unwritable on disk. Pinned separately from the whitespace
14242        // arm so a future relaxation that admits one but not the
14243        // other surfaces here.
14244        let d = dep_with_fonte(DepSource::Git {
14245            repo: "github:pleme-io/caixa-teia".into(),
14246            tag: Some("v0.1.0.lock".into()),
14247            rev: None,
14248            branch: None,
14249        });
14250        let err = d.validate().unwrap_err();
14251        let DepError::FontePinShape {
14252            pin, value, reason, ..
14253        } = err
14254        else {
14255            panic!("expected FontePinShape, got other variant");
14256        };
14257        assert_eq!(pin, ":tag");
14258        assert_eq!(value, "v0.1.0.lock");
14259        assert!(
14260            reason.contains(".lock"),
14261            "reason must surface the .lock arm, got {reason:?}"
14262        );
14263    }
14264
14265    #[test]
14266    fn validate_rejects_git_fonte_with_branch_carrying_embedded_space() {
14267        // The canonical "branch name with spaces" footgun (`feature
14268        // foo`, `release branch`) — git's refname parser rejects raw
14269        // whitespace, and the failure surfaces at `git checkout
14270        // 'feature foo'` time with a quoting-confused error far from
14271        // the source caixa.lisp. Pinned on the `:branch` axis so the
14272        // gate-applies-to-both-:tag-and-:branch contract is a build-
14273        // error to relax.
14274        let d = dep_with_fonte(DepSource::Git {
14275            repo: "github:pleme-io/caixa-teia".into(),
14276            tag: None,
14277            rev: None,
14278            branch: Some("feature/foo bar".into()),
14279        });
14280        let err = d.validate().unwrap_err();
14281        let DepError::FontePinShape {
14282            pin, value, reason, ..
14283        } = err
14284        else {
14285            panic!("expected FontePinShape, got other variant");
14286        };
14287        assert_eq!(pin, ":branch");
14288        assert_eq!(value, "feature/foo bar");
14289        assert!(
14290            reason.contains("whitespace"),
14291            "reason must surface the whitespace arm, got {reason:?}"
14292        );
14293    }
14294
14295    #[test]
14296    fn validate_rejects_git_fonte_with_branch_carrying_qualified_prefix() {
14297        // The `refs/heads/main` shape — the canonical "I copied the
14298        // fully-qualified ref out of `git show-ref` instead of the
14299        // leaf" footgun. The caixa-resolver prepends `refs/heads/`
14300        // at clone time, so this resolves to a literal ref named
14301        // `refs/heads/refs/heads/main` on disk; the silent double-
14302        // prefix is the load-bearing reason to gate at validate.
14303        // The diagnostic must enumerate the leaf the author probably
14304        // meant (`"main"`) so the fix is one edit.
14305        let d = dep_with_fonte(DepSource::Git {
14306            repo: "github:pleme-io/caixa-teia".into(),
14307            tag: None,
14308            rev: None,
14309            branch: Some("refs/heads/main".into()),
14310        });
14311        let err = d.validate().unwrap_err();
14312        let DepError::FontePinShape {
14313            pin, value, reason, ..
14314        } = err
14315        else {
14316            panic!("expected FontePinShape, got other variant");
14317        };
14318        assert_eq!(pin, ":branch");
14319        assert_eq!(value, "refs/heads/main");
14320        assert!(
14321            reason.contains("fully-qualified"),
14322            "reason must surface the qualified-prefix arm, got {reason:?}"
14323        );
14324        assert!(
14325            reason.contains("\"main\""),
14326            "reason must quote the leaf the author probably meant, got {reason:?}"
14327        );
14328    }
14329
14330    #[test]
14331    fn validate_rejects_git_fonte_with_tag_carrying_qualified_prefix() {
14332        // Sibling arm of the qualified-prefix gate on the `:tag`
14333        // axis (`refs/tags/v0.1.0` — same `git show-ref` output-leak
14334        // footgun). Pinned separately so a future relaxation that
14335        // only catches the `:branch` arm surfaces here.
14336        let d = dep_with_fonte(DepSource::Git {
14337            repo: "github:pleme-io/caixa-teia".into(),
14338            tag: Some("refs/tags/v0.1.0".into()),
14339            rev: None,
14340            branch: None,
14341        });
14342        let err = d.validate().unwrap_err();
14343        let DepError::FontePinShape {
14344            pin, value, reason, ..
14345        } = err
14346        else {
14347            panic!("expected FontePinShape, got other variant");
14348        };
14349        assert_eq!(pin, ":tag");
14350        assert_eq!(value, "refs/tags/v0.1.0");
14351        assert!(
14352            reason.contains("fully-qualified"),
14353            "reason must surface the qualified-prefix arm, got {reason:?}"
14354        );
14355        assert!(
14356            reason.contains("\"v0.1.0\""),
14357            "reason must quote the leaf the author probably meant, got {reason:?}"
14358        );
14359    }
14360
14361    #[test]
14362    fn validate_rejects_git_fonte_with_branch_named_at() {
14363        // The bare `@` is git's alias for `HEAD`; a `:branch "@"` is
14364        // unsourceable. Pinned so a future relaxation that admits
14365        // any single-character refname surfaces here.
14366        let d = dep_with_fonte(DepSource::Git {
14367            repo: "github:pleme-io/caixa-teia".into(),
14368            tag: None,
14369            rev: None,
14370            branch: Some("@".into()),
14371        });
14372        let err = d.validate().unwrap_err();
14373        let DepError::FontePinShape { pin, value, .. } = err else {
14374            panic!("expected FontePinShape, got other variant");
14375        };
14376        assert_eq!(pin, ":branch");
14377        assert_eq!(value, "@");
14378    }
14379
14380    #[test]
14381    fn validate_rejects_git_fonte_with_tag_carrying_double_dot() {
14382        // Git's `<rev1>..<rev2>` range grammar reserves `..` —
14383        // a `:tag "../escape"` (path-traversal-shaped slug) silently
14384        // passes parse and surfaces as a refname-parse error or, on
14385        // older git, a literal `../escape` checkout that escapes the
14386        // refs/ directory tree. Pinned separately from the
14387        // qualified-prefix arm so a future relaxation that catches
14388        // one but not the other surfaces here.
14389        let d = dep_with_fonte(DepSource::Git {
14390            repo: "github:pleme-io/caixa-teia".into(),
14391            tag: Some("../escape".into()),
14392            rev: None,
14393            branch: None,
14394        });
14395        let err = d.validate().unwrap_err();
14396        let DepError::FontePinShape { pin, value, .. } = err else {
14397            panic!("expected FontePinShape, got other variant");
14398        };
14399        assert_eq!(pin, ":tag");
14400        assert_eq!(value, "../escape");
14401    }
14402
14403    #[test]
14404    fn validate_accepts_git_fonte_with_hierarchical_branch() {
14405        // The positive-control pin: hierarchical refnames with one or
14406        // more `/` separators (the `feature/foo` / `user/jdoe/feat`
14407        // canonical idiom) round-trip through the gate. Pinned
14408        // separately from the leaf-`"main"` positive control so a
14409        // future tightening that rejects all multi-component refnames
14410        // surfaces here.
14411        let d = dep_with_fonte(DepSource::Git {
14412            repo: "github:pleme-io/caixa-teia".into(),
14413            tag: None,
14414            rev: None,
14415            branch: Some("feature/checkout-rewrite".into()),
14416        });
14417        d.validate().unwrap();
14418    }
14419
14420    #[test]
14421    fn validate_accepts_git_fonte_with_prerelease_tag() {
14422        // The positive-control pin: semver pre-release shape
14423        // (`v0.1.0-alpha.1`) — the in-component dot is allowed
14424        // (only consecutive `..` and trailing `.` are rejected), the
14425        // mid-component hyphen is allowed. Pinned separately from
14426        // the bare-`"v0.1.0"` positive control so a future tightening
14427        // that rejects pre-release tags surfaces here.
14428        let d = dep_with_fonte(DepSource::Git {
14429            repo: "github:pleme-io/caixa-teia".into(),
14430            tag: Some("v0.1.0-alpha.1".into()),
14431            rev: None,
14432            branch: None,
14433        });
14434        d.validate().unwrap();
14435    }
14436
14437    #[test]
14438    fn validate_rejects_git_fonte_with_rev_carrying_refname_unfriendly_value() {
14439        // The `:rev` axis is routed through `crate::render::is_git_oid`
14440        // (a SHA's character set is `[0-9a-f]`, not a refname's), so a
14441        // value with refname-shape punctuation (here, a `:` mid-string
14442        // — would be a refname violation under `is_git_ref_name` too)
14443        // is rejected at the OID-shape gate. The two predicates
14444        // partition the `:fonte` pin axes structurally: an `:rev` value
14445        // that's a valid refname (`:rev "main"`, `:rev "v0.1.0"`) is
14446        // *still* rejected here because every refname character outside
14447        // `[0-9a-f]` fails the OID gate. Same shape as
14448        // `fonte_pin_shape_diagnostic_carries_offending_nome_pin_value`
14449        // on the refname-shaped axes — the diagnostic names the
14450        // offending dep + pin + value verbatim. The flip-from-accept
14451        // case the prior `:tag`/`:branch` gate left as a "future axis"
14452        // (e70d213) — now landed.
14453        let d = dep_with_fonte(DepSource::Git {
14454            repo: "github:pleme-io/caixa-teia".into(),
14455            tag: None,
14456            rev: Some("c0ffee:notarefname".into()),
14457            branch: None,
14458        });
14459        let err = d.validate().unwrap_err();
14460        let DepError::FontePinShape {
14461            nome,
14462            pin,
14463            value,
14464            reason,
14465        } = err
14466        else {
14467            panic!("expected FontePinShape, got other variant");
14468        };
14469        assert_eq!(nome, "caixa-teia");
14470        assert_eq!(pin, ":rev");
14471        assert_eq!(value, "c0ffee:notarefname");
14472        assert!(
14473            !reason.is_empty(),
14474            "FontePinShape `reason` must carry the predicate's wording verbatim"
14475        );
14476    }
14477
14478    #[test]
14479    fn validate_accepts_git_fonte_with_rev_full_sha1() {
14480        // The positive-control pin on the SHA-1 OID width: exactly 40
14481        // lowercase hex characters — the canonical `git rev-parse HEAD`
14482        // emission on a SHA-1-hashed repository (the default on every
14483        // pre-2.42 git and the canonical pleme-io substrate hash).
14484        // Pinned separately from the SHA-256 positive control so a
14485        // future tightening that only admits one width surfaces here.
14486        let d = dep_with_fonte(DepSource::Git {
14487            repo: "github:pleme-io/caixa-teia".into(),
14488            tag: None,
14489            rev: Some("0123456789abcdef0123456789abcdef01234567".into()),
14490            branch: None,
14491        });
14492        d.validate().unwrap();
14493    }
14494
14495    #[test]
14496    fn validate_accepts_git_fonte_with_rev_full_sha256() {
14497        // The positive-control pin on the SHA-256 OID width: exactly
14498        // 64 lowercase hex characters — `git`'s
14499        // `extensions.objectFormat = sha256` emission (GA since Git
14500        // 2.42 / Oct 2023). The substrate admits either canonical
14501        // width so an `:rev` authored against a SHA-256-hashed
14502        // upstream round-trips through the gate without per-repo
14503        // configuration. Pinned separately from the SHA-1 positive
14504        // control so a future tightening that drops one width surfaces
14505        // here as a structural decision.
14506        let d = dep_with_fonte(DepSource::Git {
14507            repo: "github:pleme-io/caixa-teia".into(),
14508            tag: None,
14509            rev: Some("0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef".into()),
14510            branch: None,
14511        });
14512        d.validate().unwrap();
14513    }
14514
14515    #[test]
14516    fn validate_rejects_git_fonte_with_rev_abbreviated_prefix() {
14517        // The canonical `git log --short` / `git rev-parse --short HEAD`
14518        // paste-from-release-notes footgun: a 7-char prefix (git's
14519        // default `core.abbrev`) silently passes string emptiness
14520        // checks and resolves to one commit today, but becomes ambiguous
14521        // tomorrow as the repo grows. Until this gate landed the empty-
14522        // pin arm passed (the string isn't empty) and the resolver
14523        // accepted the prefix through git's separate prefix-lookup pass
14524        // — defeating the reproducibility contract `:rev` carries vs.
14525        // `:tag` / `:branch`. The new gate moves the check to caixa-
14526        // build time and names the offending dep + pin + value verbatim.
14527        let d = dep_with_fonte(DepSource::Git {
14528            repo: "github:pleme-io/caixa-teia".into(),
14529            tag: None,
14530            rev: Some("c0ffee0".into()),
14531            branch: None,
14532        });
14533        let err = d.validate().unwrap_err();
14534        let DepError::FontePinShape {
14535            pin, value, reason, ..
14536        } = err
14537        else {
14538            panic!("expected FontePinShape, got other variant");
14539        };
14540        assert_eq!(pin, ":rev");
14541        assert_eq!(value, "c0ffee0");
14542        assert!(
14543            reason.contains("abbreviated") || reason.contains("ambiguous"),
14544            "reason must surface the abbreviation arm, got {reason:?}"
14545        );
14546    }
14547
14548    #[test]
14549    fn validate_rejects_git_fonte_with_rev_uppercase_hex() {
14550        // The canonical "I pasted the SHA in uppercase" footgun: `git
14551        // porcelain` emits OIDs lowercase exclusively, so an uppercase-
14552        // bearing `:rev` round-trips inconsistently across the
14553        // resolver's `git fetch <remote> <:rev>` ↔ `git rev-parse HEAD`
14554        // equality-check pipeline and fails the lacre's content-
14555        // addressing probe with a confusing case-only diff. Pinned
14556        // separately from the non-hex arm so a future relaxation that
14557        // admits one but not the other surfaces here.
14558        let d = dep_with_fonte(DepSource::Git {
14559            repo: "github:pleme-io/caixa-teia".into(),
14560            tag: None,
14561            rev: Some("DEADBEEFCAFEBABE0123456789ABCDEF01234567".into()),
14562            branch: None,
14563        });
14564        let err = d.validate().unwrap_err();
14565        let DepError::FontePinShape {
14566            pin, value, reason, ..
14567        } = err
14568        else {
14569            panic!("expected FontePinShape, got other variant");
14570        };
14571        assert_eq!(pin, ":rev");
14572        assert_eq!(value, "DEADBEEFCAFEBABE0123456789ABCDEF01234567");
14573        assert!(
14574            reason.contains("uppercase"),
14575            "reason must surface the uppercase arm, got {reason:?}"
14576        );
14577    }
14578
14579    #[test]
14580    fn validate_rejects_git_fonte_with_rev_refname_value() {
14581        // The cross-axis mis-slot footgun: `:rev "main"` — the author
14582        // conflated `:rev` (hex commit ID, immutable) and `:branch`
14583        // (mutable ref pointing at whatever HEAD is today). Until this
14584        // gate landed the resolver silently dispatched on the value
14585        // shape ("`main` doesn't look like a SHA, fall back to
14586        // refname"), defeating the `:rev` reproducibility contract.
14587        // The new gate rejects every non-hex value on the `:rev` axis,
14588        // so the `:rev`/`:branch` boundary is structurally enforced —
14589        // a refname in the `:rev` slot is a build error, not a
14590        // resolver-time silent reinterpretation.
14591        let d = dep_with_fonte(DepSource::Git {
14592            repo: "github:pleme-io/caixa-teia".into(),
14593            tag: None,
14594            rev: Some("main".into()),
14595            branch: None,
14596        });
14597        let err = d.validate().unwrap_err();
14598        let DepError::FontePinShape {
14599            pin, value, reason, ..
14600        } = err
14601        else {
14602            panic!("expected FontePinShape, got other variant");
14603        };
14604        assert_eq!(pin, ":rev");
14605        assert_eq!(value, "main");
14606        // 4 chars `main` fails the length arm before the character arm,
14607        // so the diagnostic surfaces the abbreviation wording (same
14608        // path the `c0ffee0` 7-char fixture lands on); the structural
14609        // assertion is just that the `:rev "main"` value is rejected.
14610        assert!(
14611            !reason.is_empty(),
14612            "FontePinShape reason must be non-empty for refname-shaped :rev"
14613        );
14614    }
14615
14616    #[test]
14617    fn validate_rejects_git_fonte_with_rev_tag_shaped_value() {
14618        // Sibling cross-axis mis-slot: `:rev "v0.1.0"` — the author
14619        // conflated `:rev` and `:tag`. Pinned separately from the
14620        // `:rev "main"` (`:branch` mis-slot) arm so a future relaxation
14621        // that catches one but not the other surfaces here. The
14622        // length arm fires first (6 chars ≠ 40 ≠ 64); the structural
14623        // assertion is just that the cross-axis mis-slot is a build
14624        // error, regardless of which sub-arm surfaces the diagnostic
14625        // (`is_git_oid` rejects at the first violation; longer
14626        // tag-shape values would hit the non-hex arm instead).
14627        let d = dep_with_fonte(DepSource::Git {
14628            repo: "github:pleme-io/caixa-teia".into(),
14629            tag: None,
14630            rev: Some("v0.1.0".into()),
14631            branch: None,
14632        });
14633        let err = d.validate().unwrap_err();
14634        let DepError::FontePinShape {
14635            pin, value, reason, ..
14636        } = err
14637        else {
14638            panic!("expected FontePinShape, got other variant");
14639        };
14640        assert_eq!(pin, ":rev");
14641        assert_eq!(value, "v0.1.0");
14642        assert!(
14643            !reason.is_empty(),
14644            "FontePinShape reason must be non-empty for tag-shaped :rev"
14645        );
14646    }
14647
14648    #[test]
14649    fn validate_rejects_git_fonte_with_rev_too_long() {
14650        // Boundary case on the upper end: 41 hex chars — one past the
14651        // SHA-1 width, well below the SHA-256 width. Pin so a future
14652        // relaxation that admits "long enough to be a SHA" without
14653        // matching either canonical width surfaces here. The diagnostic
14654        // names the offending length verbatim so the author's grep
14655        // target is unambiguous (either trim one char or paste the
14656        // full SHA-256).
14657        let too_long: String = "0".repeat(41);
14658        let d = dep_with_fonte(DepSource::Git {
14659            repo: "github:pleme-io/caixa-teia".into(),
14660            tag: None,
14661            rev: Some(too_long.clone()),
14662            branch: None,
14663        });
14664        let err = d.validate().unwrap_err();
14665        let DepError::FontePinShape {
14666            pin, value, reason, ..
14667        } = err
14668        else {
14669            panic!("expected FontePinShape, got other variant");
14670        };
14671        assert_eq!(pin, ":rev");
14672        assert_eq!(value, too_long);
14673        assert!(
14674            reason.contains("41"),
14675            "reason must surface the offending length verbatim, got {reason:?}"
14676        );
14677    }
14678
14679    #[test]
14680    fn validate_rejects_git_fonte_with_rev_carrying_whitespace() {
14681        // The canonical paste-from-doc footgun on `:rev` — author
14682        // copies `"deadbeefcafe…0123 "` (trailing space) out of a
14683        // commit-message paragraph. Until this gate landed the empty-
14684        // pin arm passed (the string isn't empty), the resolver issued
14685        // `git fetch <remote> 'deadbeef… '` and the failure surfaced at
14686        // clone time with a quoting-confused git error far from the
14687        // source caixa.lisp. The new gate moves the check to caixa-
14688        // build time. Length is 41 (40 hex + space) so the length arm
14689        // fires first — pinned separately from the pure-length arm to
14690        // ensure the diagnostic surfaces *some* parser wording, not
14691        // silently pass through.
14692        let with_space = "0123456789abcdef0123456789abcdef01234567 ".to_string();
14693        let d = dep_with_fonte(DepSource::Git {
14694            repo: "github:pleme-io/caixa-teia".into(),
14695            tag: None,
14696            rev: Some(with_space.clone()),
14697            branch: None,
14698        });
14699        let err = d.validate().unwrap_err();
14700        let DepError::FontePinShape {
14701            pin, value, reason, ..
14702        } = err
14703        else {
14704            panic!("expected FontePinShape, got other variant");
14705        };
14706        assert_eq!(pin, ":rev");
14707        assert_eq!(value, with_space);
14708        assert!(
14709            !reason.is_empty(),
14710            "FontePinShape reason must be non-empty for whitespace-bearing :rev"
14711        );
14712    }
14713
14714    #[test]
14715    fn fonte_pin_shape_diagnostic_carries_offending_nome_pin_value_for_rev() {
14716        // Diagnostic-shape pin on the `:rev` axis: every FontePinShape
14717        // variant on this axis names the offending dep's `:nome` + the
14718        // `:rev` axis + the offending value verbatim, so the author's
14719        // grep target is the literal `:rev "<value>"` block in
14720        // caixa.lisp. Sibling of the `fonte_pin_shape_diagnostic_
14721        // carries_offending_nome_pin_value` test on the refname-shaped
14722        // (`:tag` / `:branch`) axes.
14723        let d = dep_with_fonte(DepSource::Git {
14724            repo: "github:p/x".into(),
14725            tag: None,
14726            rev: Some("not-a-sha".into()),
14727            branch: None,
14728        });
14729        let msg = d
14730            .validate()
14731            .expect_err(":rev: expected FontePinShape")
14732            .to_string();
14733        assert!(
14734            msg.contains("\"caixa-teia\""),
14735            ":rev: diagnostic must quote the offending :nome verbatim, got {msg:?}"
14736        );
14737        assert!(
14738            msg.contains(":rev"),
14739            ":rev: diagnostic must name the offending pin axis, got {msg:?}"
14740        );
14741        assert!(
14742            msg.contains("not-a-sha"),
14743            ":rev: diagnostic must quote the offending value verbatim, got {msg:?}"
14744        );
14745    }
14746
14747    #[test]
14748    fn fonte_pin_empty_fires_before_pin_shape() {
14749        // Order pin: a `Some("")` `:tag` is the more self-locating
14750        // diagnostic (the author chose an axis but left it blank;
14751        // grep is unambiguous), so it fires before the shape gate
14752        // even when both arms would match. Pinned so a future
14753        // reordering surfaces here. Mirrors the
14754        // `fonte_repo_empty_fires_before_pin_missing` ordering
14755        // discipline on the peer per-axis arms.
14756        let d = dep_with_fonte(DepSource::Git {
14757            repo: "github:pleme-io/caixa-teia".into(),
14758            tag: Some(String::new()),
14759            rev: None,
14760            branch: None,
14761        });
14762        assert!(matches!(
14763            d.validate().unwrap_err(),
14764            DepError::FontePinEmpty { ref pin, .. } if pin == ":tag"
14765        ));
14766    }
14767
14768    #[test]
14769    fn fonte_pin_shape_fires_after_repo_empty() {
14770        // Order pin: `:repo ""` is the more self-locating axis
14771        // (every git source needs a repo; the per-pin shape gate is
14772        // secondary), so the repo-empty arm fires before the
14773        // per-pin shape arm even when both are violated. Pinned so
14774        // a future reordering surfaces here. Mirrors
14775        // `fonte_repo_empty_fires_before_pin_missing` on the
14776        // adjacent axis pair.
14777        let d = dep_with_fonte(DepSource::Git {
14778            repo: String::new(),
14779            tag: Some("v0.1.0 ".into()),
14780            rev: None,
14781            branch: None,
14782        });
14783        assert!(matches!(
14784            d.validate().unwrap_err(),
14785            DepError::FonteRepoEmpty { .. }
14786        ));
14787    }
14788
14789    #[test]
14790    fn fonte_pin_shape_diagnostic_carries_offending_nome_pin_value() {
14791        // Diagnostic-shape pin across both refname-shaped axes
14792        // (`:tag` + `:branch`): every `FontePinShape` variant names
14793        // the offending dep's `:nome` + the offending pin axis + the
14794        // offending value verbatim, so the author's grep target is
14795        // unambiguous (the literal `:tag "<value>"` / `:branch
14796        // "<value>"` lands in caixa.lisp with quotes). Cover both
14797        // pin axes so a future variant addition forces a parallel
14798        // diagnostic-shape decision.
14799        for (pin_label, fonte) in [
14800            (
14801                ":tag",
14802                DepSource::Git {
14803                    repo: "github:p/x".into(),
14804                    tag: Some("v0.1.0~1".into()),
14805                    rev: None,
14806                    branch: None,
14807                },
14808            ),
14809            (
14810                ":branch",
14811                DepSource::Git {
14812                    repo: "github:p/x".into(),
14813                    tag: None,
14814                    rev: None,
14815                    branch: Some("feature/foo*".into()),
14816                },
14817            ),
14818        ] {
14819            let d = dep_with_fonte(fonte);
14820            let msg = d
14821                .validate()
14822                .expect_err(&format!("{pin_label}: expected FontePinShape"))
14823                .to_string();
14824            assert!(
14825                msg.contains("\"caixa-teia\""),
14826                "{pin_label}: diagnostic must quote the offending :nome verbatim, got {msg:?}"
14827            );
14828            assert!(
14829                msg.contains(pin_label),
14830                "{pin_label}: diagnostic must name the offending pin axis, got {msg:?}"
14831            );
14832        }
14833    }
14834
14835    #[test]
14836    fn git_source_json_round_trip() {
14837        let src = DepSource::Git {
14838            repo: "github:pleme-io/caixa-teia".into(),
14839            tag: Some("v0.1.0".into()),
14840            rev: None,
14841            branch: None,
14842        };
14843        let s = serde_json::to_string(&src).unwrap();
14844        assert!(s.contains(&format!(
14845            r#""{tipo}":"{git}""#,
14846            tipo = crate::render::DEP_SOURCE_KEY_TIPO,
14847            git = crate::render::DEP_SOURCE_TIPO_GIT,
14848        )));
14849        assert!(s.contains(r#""repo":"github:pleme-io/caixa-teia""#));
14850        assert!(s.contains(r#""tag":"v0.1.0""#));
14851        assert!(!s.contains("rev"));
14852        assert!(!s.contains("branch"));
14853        let round: DepSource = serde_json::from_str(&s).unwrap();
14854        assert_eq!(round, src);
14855    }
14856
14857    // ── DEP_SOURCE_{KEY_TIPO,TIPO_GIT,TIPO_PATH} drift-detection ────────
14858    //
14859    // The `#[serde(tag = "tipo", rename_all = "lowercase")]` derive
14860    // attribute on [`DepSource`] pins three load-bearing byte-sequences
14861    // that flow into every serialized `Dep.fonte` block: the outer
14862    // discriminator-key `"tipo"` the `tag = "tipo"` attribute names, and
14863    // the two admitted variant-tag values `"git"` / `"path"` the
14864    // `rename_all = "lowercase"` attribute pins as the discriminator's
14865    // closed-set arms. The three pin tests below round-trip a
14866    // fully-populated variant of each arm through
14867    // [`serde_json::to_value`] and assert each canonical byte-sequence
14868    // appears at its axis — pins a hypothetical future
14869    // `tag = "type"` / `tag = "source_type"` typo, a `rename_all`
14870    // rebrand (`"UPPERCASE"` / `"snake_case"` / `"kebab-case"`), or a
14871    // Rust-side variant rename (`Git` → `Repository`, `Path` → `Local`)
14872    // at build time rather than at fetch time when the resolver's
14873    // `Dep.fonte` dispatch silently fails to match on the drifted
14874    // discriminator. Same "serialize-and-check" discipline the peer
14875    // `M2_LIMITS_KEY_*`, `M2_BEHAVIOR_KEY_ON_*`, `SUPERVISOR_KEY_*`,
14876    // and `MEMBRO_KEY_*` drift-detection pins carry — extended here
14877    // to the last `#[serde(tag = ..., rename_all = ...)]` discriminator
14878    // family in caixa-core lacking a lifted peer.
14879
14880    #[test]
14881    fn dep_source_git_serde_keys_match_lifted_dep_source_key_consts() {
14882        // Fail-before-pass-after: a future `tag = "type"` at the derive
14883        // attribute would serialize under `"type":"git"`, and this test
14884        // would trip because `"tipo"` no longer appears at the emitted
14885        // discriminator key. A future `rename_all = "kebab-case"` /
14886        // `"snake_case"` (both no-ops on `Git` since it lacks internal
14887        // word boundaries) is caught by the sibling
14888        // `dep_source_path_serde_keys_match_lifted_dep_source_key_consts`
14889        // pin below (Path has no internal boundary either but the pair
14890        // catches any per-arm inconsistency). A future variant rename
14891        // `Git` → `Repository` would emit `"tipo":"repository"` and
14892        // trip this pin.
14893        let src = DepSource::Git {
14894            repo: "github:pleme-io/caixa-teia".into(),
14895            tag: Some("v0.1.0".into()),
14896            rev: None,
14897            branch: None,
14898        };
14899        let json = serde_json::to_value(&src).unwrap();
14900        let obj = json.as_object().expect("Git serializes as a JSON object");
14901        assert_eq!(
14902            obj.get(crate::render::DEP_SOURCE_KEY_TIPO)
14903                .and_then(serde_json::Value::as_str),
14904            Some(crate::render::DEP_SOURCE_TIPO_GIT),
14905            "DepSource::Git must serialize the tipo discriminator at DEP_SOURCE_KEY_TIPO \
14906             with value DEP_SOURCE_TIPO_GIT — attribute drift or variant rename \
14907             detected in {json}"
14908        );
14909    }
14910
14911    #[test]
14912    fn dep_source_path_serde_keys_match_lifted_dep_source_key_consts() {
14913        // Fail-before-pass-after: a future variant rename `Path` →
14914        // `Local` / `Filesystem` would emit `"tipo":"local"` and trip
14915        // this pin. A per-consumer disambiguation as the `defcaixa`
14916        // macro stabilizes ("caminho" → "path" for English-uniformity)
14917        // is scoped to the inner field key, not the discriminator; this
14918        // pin is orthogonal to that and catches only the outer
14919        // discriminator drift.
14920        let src = DepSource::Path {
14921            caminho: "../caixa-teia".into(),
14922        };
14923        let json = serde_json::to_value(&src).unwrap();
14924        let obj = json.as_object().expect("Path serializes as a JSON object");
14925        assert_eq!(
14926            obj.get(crate::render::DEP_SOURCE_KEY_TIPO)
14927                .and_then(serde_json::Value::as_str),
14928            Some(crate::render::DEP_SOURCE_TIPO_PATH),
14929            "DepSource::Path must serialize the tipo discriminator at DEP_SOURCE_KEY_TIPO \
14930             with value DEP_SOURCE_TIPO_PATH — attribute drift or variant rename \
14931             detected in {json}"
14932        );
14933    }
14934
14935    #[test]
14936    fn dep_source_key_consts_are_pairwise_distinct() {
14937        // Cross-axis collapse detector: a hypothetical future edit that
14938        // accidentally set two of the three consts to the same byte
14939        // (`DEP_SOURCE_TIPO_GIT = "path"` typo matching a peer arm) would
14940        // pass every per-arm serialize pin above but silently collapse
14941        // the discriminator's closed-set arms onto one another; this pin
14942        // catches the collapse at build time.
14943        assert_ne!(
14944            crate::render::DEP_SOURCE_KEY_TIPO,
14945            crate::render::DEP_SOURCE_TIPO_GIT,
14946        );
14947        assert_ne!(
14948            crate::render::DEP_SOURCE_KEY_TIPO,
14949            crate::render::DEP_SOURCE_TIPO_PATH,
14950        );
14951        assert_ne!(
14952            crate::render::DEP_SOURCE_TIPO_GIT,
14953            crate::render::DEP_SOURCE_TIPO_PATH,
14954        );
14955    }
14956
14957    #[test]
14958    fn dep_source_tipo_variant_consts_are_ascii_lowercase_shape() {
14959        // Shape pin against `rename_all` drift: the two variant-tag
14960        // consts must be ASCII-lowercase-only to match the
14961        // `rename_all = "lowercase"` attribute the derive uses; a future
14962        // rebrand to `"UPPERCASE"` / `"PascalCase"` at the attribute
14963        // would emit `"GIT"` / `"Git"` instead and trip this pin.
14964        for (label, s) in [
14965            ("DEP_SOURCE_TIPO_GIT", crate::render::DEP_SOURCE_TIPO_GIT),
14966            ("DEP_SOURCE_TIPO_PATH", crate::render::DEP_SOURCE_TIPO_PATH),
14967        ] {
14968            assert!(!s.is_empty(), "{label} must not be empty");
14969            assert!(
14970                s.bytes().all(|b| b.is_ascii_lowercase()),
14971                "{label} must be ASCII-lowercase-only (matching \
14972                 rename_all = \"lowercase\"), got {s:?}",
14973            );
14974        }
14975    }
14976
14977    // ── per-entry :caracteristicas set-not-multiset gate ────────────
14978    //
14979    // Every Vec-keyed-by-name authoring surface on the typed Caixa
14980    // surface that identifies its entries by a name field now uniformly
14981    // closes the set-not-multiset discipline at build time (cite
14982    // `validate_caracteristicas`'s peer-axis enumeration). The
14983    // `:caracteristicas` axis is per-`Dep`: the feature-toggle slot is
14984    // set-shaped (a feature is either enabled or not — there is no
14985    // `feature × 2` semantic), so two entries naming the same feature
14986    // are a redundant declaration the caixa-resolver's lacre pipeline
14987    // would silently dedup at resolve time. The empty-feature arm
14988    // closes the parallel "operationally-meaningless value" axis on
14989    // the same slot. Same linear-walk + `HashSet` + first-collision
14990    // shape every peer set gate uses; same empty-first cascade every
14991    // peer per-entry shape + duplicate gate uses (the empty-feature
14992    // axis is the more-actionable defect since two `""` entries would
14993    // both report `caracteristica: ""` under a duplicate-first
14994    // ordering, with no way to distinguish the offending site).
14995
14996    fn dep_with_features(features: &[&str]) -> Dep {
14997        Dep {
14998            nome: "caixa-teia".into(),
14999            versao: "^0.1".into(),
15000            fonte: None,
15001            opcional: false,
15002            caracteristicas: features.iter().map(|s| (*s).into()).collect(),
15003        }
15004    }
15005
15006    #[test]
15007    fn validate_rejects_empty_caracteristica() {
15008        // Fail-before-pass-after pin: every pre-gate codebase accepted
15009        // `(:caracteristicas (""))` cleanly (the `Vec<String>` field
15010        // imposed no per-entry shape contract), the dep validated, and
15011        // the empty feature would have reached the future caixa-resolver
15012        // lacre pipeline as a no-op feature enable — silently dropping
15013        // the author's intent far from the source `caixa.lisp`. The new
15014        // gate surfaces the structural defect at the typed-validate
15015        // surface with a self-locating diagnostic naming the offending
15016        // dep's `:nome`.
15017        let d = dep_with_features(&[""]);
15018        assert!(
15019            matches!(d.validate().unwrap_err(), DepError::CaracteristicaEmpty { ref nome } if nome == "caixa-teia"),
15020            "expected CaracteristicaEmpty, got {:?}",
15021            d.validate(),
15022        );
15023    }
15024
15025    #[test]
15026    fn validate_rejects_duplicate_caracteristica() {
15027        // Fail-before-pass-after pin on the set-not-multiset arm: the
15028        // feature-toggle slot is set-shaped, so `(:caracteristicas
15029        // ("http" "http"))` is a redundant declaration the lacre
15030        // pipeline dedupes silently at resolve time. The diagnostic
15031        // names the offending dep + the colliding feature verbatim so
15032        // the author can grep their caixa.lisp for `:caracteristicas`
15033        // and fix it in one edit. First-collision determinism is
15034        // pinned separately below.
15035        let d = dep_with_features(&["http", "http"]);
15036        assert!(
15037            matches!(
15038                d.validate().unwrap_err(),
15039                DepError::CaracteristicaDuplicate { ref nome, ref caracteristica }
15040                    if nome == "caixa-teia" && caracteristica == "http"
15041            ),
15042            "expected CaracteristicaDuplicate, got {:?}",
15043            d.validate(),
15044        );
15045    }
15046
15047    #[test]
15048    fn validate_accepts_distinct_caracteristicas() {
15049        // The canonical authoring shape — every feature distinct — must
15050        // remain a clean pass (positive control sweep). Covers the
15051        // canonical kebab-case feature names a target caixa typically
15052        // declares.
15053        dep_with_features(&["http", "json", "tls"])
15054            .validate()
15055            .unwrap();
15056    }
15057
15058    #[test]
15059    fn validate_accepts_single_caracteristica() {
15060        // Single-element list is the minimum non-empty shape; passes
15061        // the gate as the identity of the duplicate check (no second
15062        // entry to collide with).
15063        dep_with_features(&["http"]).validate().unwrap();
15064    }
15065
15066    #[test]
15067    fn validate_accepts_empty_caracteristicas_list() {
15068        // The bare-dep authoring shape (`Dep::simple` / `Dep::git`)
15069        // produces `caracteristicas: Vec::new()`; the empty list is
15070        // the gate's empty-set identity and passes vacuously. Pin
15071        // this so a future tightening that requires ≥1 feature
15072        // surfaces here as a test failure rather than a silent
15073        // contract narrowing.
15074        Dep::simple("caixa-teia", "^0.1").validate().unwrap();
15075        assert!(dep_with_features(&[]).validate().is_ok());
15076    }
15077
15078    #[test]
15079    fn validate_caracteristica_empty_fires_before_duplicate() {
15080        // Empty-first cascade: an entry with an empty feature *and*
15081        // duplicate entries surfaces the empty diagnostic first. The
15082        // empty-feature axis is the more-actionable defect since
15083        // `caracteristica: ""` is unambiguous; under duplicate-first
15084        // ordering the diagnostic could report the empty string from
15085        // either of two empty entries with no way to distinguish.
15086        // Mirrors the peer empty-before-duplicate ordering
15087        // discipline every per-entry shape + duplicate gate establishes
15088        // (`SupervisorSpec::validate`'s `EmptyChildName` arm before
15089        // `DuplicateChildCaixa`, `validate_membros`'s
15090        // `MembroCaixaEmpty` arm before `MembroDuplicate`).
15091        let d = dep_with_features(&["", "http", "http"]);
15092        assert!(matches!(
15093            d.validate().unwrap_err(),
15094            DepError::CaracteristicaEmpty { .. }
15095        ));
15096    }
15097
15098    #[test]
15099    fn validate_caracteristica_duplicate_first_collision_determinism() {
15100        // Three matching entries: the second occurrence surfaces the
15101        // diagnostic (the second is the first *collision* — the first
15102        // entry is the establishing one, not a duplicate). Mirrors
15103        // every peer first-collision posture
15104        // (`SupervisorError::DuplicateChildCaixa` reports the second
15105        // collision, `AplicacaoError::MembroDuplicate` reports the
15106        // second, `DepError::DuplicateNome` reports the second).
15107        // Pinning this so a future shortcut that flips to last-
15108        // collision (or non-deterministic) surfaces here.
15109        let d = dep_with_features(&["http", "http", "http"]);
15110        assert!(matches!(
15111            d.validate().unwrap_err(),
15112            DepError::CaracteristicaDuplicate { ref caracteristica, .. } if caracteristica == "http"
15113        ));
15114    }
15115
15116    #[test]
15117    fn validate_per_entry_shape_fires_before_caracteristicas() {
15118        // Per-entry shape precedence: a dep with a malformed `:nome`
15119        // (uppercase) AND duplicate `:caracteristicas` surfaces the
15120        // narrower `NomeInvalid` diagnostic first, not the set-gate
15121        // diagnostic. The `:nome` is the self-locating axis (every
15122        // diagnostic from the caracteristicas gate quotes the
15123        // offending dep's `:nome` to anchor the grep target —
15124        // surfacing the malformed name first keeps that anchor
15125        // valid). Same precedence shape every peer per-entry-shape
15126        // arm establishes against its peer set-gate
15127        // (`validate_deps_per_entry_validate_fires_before_duplicate_in_deps`
15128        // on the cross-entry `:nome` axis).
15129        let d = Dep {
15130            nome: "Caixa-Teia".into(), // uppercase — DNS-1123 violation
15131            versao: "^0.1".into(),
15132            fonte: None,
15133            opcional: false,
15134            caracteristicas: vec!["http".into(), "http".into()],
15135        };
15136        assert!(matches!(
15137            d.validate().unwrap_err(),
15138            DepError::NomeInvalid { .. }
15139        ));
15140    }
15141
15142    // ── per-entry :caracteristicas value-shape gate ──────────────────
15143    //
15144    // Until this gate landed `:caracteristicas` only refused the empty
15145    // string and cross-entry duplicates: a non-empty distinct but
15146    // structurally invalid feature name silently passed validate and the
15147    // failure surfaced at `cargo metadata` time as Cargo's
15148    // `restricted_names::validate_feature_name` parser rejection, far from
15149    // the source `caixa.lisp` with no field naming which `:deps` entry's
15150    // `:caracteristicas` carried the typo. The lifted predicate makes the
15151    // Cargo-feature-name-grammar intersection-floor a substrate-level
15152    // invariant at validate time. Same trajectory as the eight peer
15153    // value-shape predicates each typed surface downstream of a structured
15154    // grammar already follows.
15155
15156    #[test]
15157    fn validate_rejects_caracteristica_with_leading_plus() {
15158        // Fail-before-pass-after pin on the canonical Cargo
15159        // `+<feature>` activation-form-in-feature-name-slot footgun.
15160        // Cargo's `[dependencies.<dep>.features]` list grammar accepts
15161        // `+optional-feature` as an enablement of a previously-disabled
15162        // feature; pasting that activation form into `:caracteristicas`
15163        // (which names the feature itself) silently passed pre-gate and
15164        // failed at `cargo metadata` parse time.
15165        let d = dep_with_features(&["+http"]);
15166        let err = d.validate().unwrap_err();
15167        assert!(
15168            matches!(
15169                err,
15170                DepError::CaracteristicaInvalid { ref nome, ref caracteristica, .. }
15171                    if nome == "caixa-teia" && caracteristica == "+http"
15172            ),
15173            "expected CaracteristicaInvalid, got {err:?}"
15174        );
15175    }
15176
15177    #[test]
15178    fn validate_rejects_caracteristica_with_leading_hyphen() {
15179        // Fail-before-pass-after pin on the leading-hyphen footgun. `-`
15180        // is a legitimate continuation character (kebab-case feature
15181        // names like `runtime-tokio` pass) but Cargo rejects it at the
15182        // start; the structural defect — and its CLI-argument-injection
15183        // adjacency at any downstream Cargo subprocess invocation — is
15184        // closed at validate time, not at `cargo metadata` time.
15185        let d = dep_with_features(&["-json"]);
15186        let err = d.validate().unwrap_err();
15187        assert!(
15188            matches!(
15189                err,
15190                DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "-json"
15191            ),
15192            "expected CaracteristicaInvalid, got {err:?}"
15193        );
15194    }
15195
15196    #[test]
15197    fn validate_rejects_caracteristica_with_leading_dot() {
15198        // Fail-before-pass-after pin on the leading-dot footgun. `.` is
15199        // a legitimate continuation character (version-suffix shapes
15200        // like `feat.v2` pass) but the leading-dot form is the
15201        // canonical dotted-version-suffix-as-feature-name confusion.
15202        let d = dep_with_features(&[".feat"]);
15203        let err = d.validate().unwrap_err();
15204        assert!(matches!(
15205            err,
15206            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == ".feat"
15207        ));
15208    }
15209
15210    #[test]
15211    fn validate_rejects_caracteristica_with_whitespace() {
15212        // Fail-before-pass-after pin on the embedded-whitespace footgun:
15213        // a feature name with a space inside is structurally a multi-
15214        // token blob (the canonical paste-from-doc footgun, or an
15215        // accidental `"http server"` where the author meant
15216        // `"http-server"`).
15217        let d = dep_with_features(&["http feature"]);
15218        let err = d.validate().unwrap_err();
15219        assert!(matches!(
15220            err,
15221            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http feature"
15222        ));
15223    }
15224
15225    #[test]
15226    fn validate_rejects_caracteristica_with_comma() {
15227        // Fail-before-pass-after pin on the embedded-comma footgun:
15228        // the list-separator-belongs-to-the-list-grammar
15229        // miscomprehension where the author writes
15230        // `:caracteristicas ("http,json")` intending two features but
15231        // the `Vec<String>` field consumes the bare token as one entry.
15232        let d = dep_with_features(&["http,json"]);
15233        let err = d.validate().unwrap_err();
15234        assert!(matches!(
15235            err,
15236            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http,json"
15237        ));
15238    }
15239
15240    #[test]
15241    fn validate_rejects_caracteristica_with_slash() {
15242        // Fail-before-pass-after pin on the embedded-slash footgun:
15243        // Cargo's `dep/feat` namespaced-dep syntax applies inside
15244        // `[dependencies.<dep>.features]` list entries that already
15245        // name the parent dep (so the syntax says "enable feature
15246        // `feat` on a transitive dep `dep`"); `:caracteristicas` is
15247        // per-dep already (a sibling slot on the `Dep` itself), so the
15248        // segment separator within an entry must be `-`, `_`, `+`,
15249        // or `.`. The diagnostic remediation points at the canonical
15250        // Cargo namespaced-dep discipline.
15251        let d = dep_with_features(&["http/json"]);
15252        let err = d.validate().unwrap_err();
15253        assert!(matches!(
15254            err,
15255            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http/json"
15256        ));
15257    }
15258
15259    #[test]
15260    fn validate_rejects_caracteristica_with_non_ascii() {
15261        // Fail-before-pass-after pin on the un-percent-encoded non-ASCII
15262        // byte footgun: NFC-vs-NFD normalization across filesystems
15263        // silently rewrites the feature-key, breaking the lacre's
15264        // content-addressing invariant. Pinned at a canonical
15265        // smart-quote-paste shape (`café`) where the raw `é` byte is the
15266        // documented APFS round-trip break.
15267        let d = dep_with_features(&["caf\u{e9}"]);
15268        let err = d.validate().unwrap_err();
15269        assert!(matches!(
15270            err,
15271            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "caf\u{e9}"
15272        ));
15273    }
15274
15275    #[test]
15276    fn validate_rejects_caracteristica_with_control_character() {
15277        // Fail-before-pass-after pin on the embedded-control-character
15278        // footgun: a CR/LF or any 0x00..0x1F / 0x7F byte landing in a
15279        // feature name is the canonical paste-from-multiline-doc
15280        // footgun the predicate's reason wording specifically calls out.
15281        let d = dep_with_features(&["http\njson"]);
15282        let err = d.validate().unwrap_err();
15283        assert!(matches!(err, DepError::CaracteristicaInvalid { .. }));
15284    }
15285
15286    #[test]
15287    fn validate_accepts_canonical_caracteristicas_shapes() {
15288        // Positive control sweep: every canonical Cargo feature name
15289        // shape the pleme-io ecosystem uses must still pass. Mirrors
15290        // the substrate-side `cargo_feature_name_accepts_canonical_forms`
15291        // sweep — drift between either landing site and the predicate's
15292        // accepted set is a build error visible at this pair of tests,
15293        // not a per-renderer "this passed validate but failed at
15294        // cargo metadata time" surprise on the next acceptance.
15295        for s in [
15296            "http",
15297            "json",
15298            "derive",
15299            "serde_json",
15300            "runtime-tokio",
15301            "tokio.full",
15302            "v0.1",
15303            "http+json",
15304            "_internal",
15305            "__private",
15306            "default",
15307            "rt-multi-thread",
15308            "feat.v2",
15309        ] {
15310            let d = dep_with_features(&[s]);
15311            d.validate().unwrap_or_else(|e| {
15312                panic!("canonical Cargo feature name {s:?} must pass validate: {e:?}")
15313            });
15314        }
15315    }
15316
15317    #[test]
15318    fn validate_caracteristica_empty_fires_before_invalid() {
15319        // Cascade precedence pin: an entry list with both an empty
15320        // feature AND an invalid-shape feature surfaces the
15321        // `CaracteristicaEmpty` arm first (the empty value carries no
15322        // self-locating data — `caracteristica: ""` is the diagnostic
15323        // with no way to anchor a grep target — so closing the empty
15324        // axis first preserves the per-entry-shape diagnostic's
15325        // self-locating discipline). Same empty-first cascade every
15326        // peer per-entry shape gate establishes
15327        // (`SupervisorSpec::validate`'s `EmptyChildName` before
15328        // `ChildCaixaInvalid`, `validate_membros`'s `MembroCaixaEmpty`
15329        // before `MembroCaixaInvalid`).
15330        let d = dep_with_features(&["", "+http"]);
15331        assert!(matches!(
15332            d.validate().unwrap_err(),
15333            DepError::CaracteristicaEmpty { .. }
15334        ));
15335    }
15336
15337    #[test]
15338    fn validate_caracteristica_invalid_fires_before_duplicate() {
15339        // Per-entry-shape precedence pin: an entry list with the same
15340        // invalid feature shape declared twice surfaces the
15341        // `CaracteristicaInvalid` diagnostic on the first entry, not
15342        // the `CaracteristicaDuplicate` on the second collision. The
15343        // per-entry shape gate fires before the cross-entry set gate
15344        // — same precedence shape every peer two-arm-plus-set gate
15345        // establishes (`SupervisorSpec::validate`'s
15346        // `ChildCaixaInvalid` before `DuplicateChildCaixa`,
15347        // `validate_membros`'s `MembroCaixaInvalid` before
15348        // `MembroDuplicate`, `Dep::validate`'s `NomeInvalid` before
15349        // cross-list `DuplicateNome`).
15350        let d = dep_with_features(&["+http", "+http"]);
15351        assert!(matches!(
15352            d.validate().unwrap_err(),
15353            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "+http"
15354        ));
15355    }
15356
15357    #[test]
15358    fn validate_rejects_caracteristica_at_65_byte_boundary() {
15359        // Boundary pin on the 64-byte cap — both the boundary-accepting
15360        // case and the boundary-exceeding case in one place, so a
15361        // future cap shift surfaces both arms simultaneously, mirroring
15362        // the peer `cargo_feature_name_rejects_at_65_byte_boundary`
15363        // predicate-level pin at the dep-axis landing site.
15364        let max_ok = "a".repeat(64);
15365        dep_with_features(&[&max_ok])
15366            .validate()
15367            .unwrap_or_else(|e| panic!("64-byte feature name must pass: {e:?}"));
15368        let too_long = "a".repeat(65);
15369        let d = dep_with_features(&[&too_long]);
15370        assert!(matches!(
15371            d.validate().unwrap_err(),
15372            DepError::CaracteristicaInvalid { .. }
15373        ));
15374    }
15375
15376    // ── self-dep cross-slot gate ─────────────────────────────────────
15377
15378    #[test]
15379    fn validate_no_self_dep_rejects_self_in_deps() {
15380        // A caixa whose `:deps` lists its own `:nome` is a one-node
15381        // cycle in the lacre closure's dep-graph traversal — rejected,
15382        // naming the parent and the offending list tag.
15383        let deps = vec![
15384            Dep::simple("caixa-teia", "^0.1"),
15385            Dep::simple("orquestra", "^0.1"),
15386        ];
15387        let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
15388        assert!(
15389            matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS),
15390            "got {err:?}"
15391        );
15392    }
15393
15394    #[test]
15395    fn validate_no_self_dep_rejects_self_in_deps_dev() {
15396        // Same gate on the `:deps-dev` axis — neither dep list is a
15397        // second-class citizen on the self-edge invariant.
15398        let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
15399        let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
15400        assert!(
15401            matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
15402            "got {err:?}"
15403        );
15404    }
15405
15406    #[test]
15407    fn validate_no_self_dep_deps_fires_before_deps_dev() {
15408        // Walk order pin: a caixa that self-references on both lists
15409        // surfaces the `:deps` arm first — the load-bearing axis the
15410        // lacre closure resolves at every build. Mirrors the canonical
15411        // [`Caixa::validate_deps`] cascade (`:deps` → `:deps-dev`).
15412        let deps = vec![Dep::simple("orquestra", "^0.1")];
15413        let deps_dev = vec![Dep::simple("orquestra", "^0.2")];
15414        let err = validate_no_self_dep(&deps, &deps_dev, "orquestra").unwrap_err();
15415        assert!(
15416            matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS),
15417            "got {err:?}"
15418        );
15419    }
15420
15421    #[test]
15422    fn validate_no_self_dep_accepts_distinct_names() {
15423        // Positive control: every dep names a distinct caixa. The
15424        // canonical author surface — peer of
15425        // [`validate_no_self_supervision_accepts_distinct_children`].
15426        let deps = vec![
15427            Dep::simple("caixa-teia", "^0.1"),
15428            Dep::simple("caixa-arch", "^0.1"),
15429        ];
15430        let deps_dev = vec![Dep::simple("caixa-test", "^0.1")];
15431        validate_no_self_dep(&deps, &deps_dev, "orquestra").unwrap();
15432    }
15433
15434    #[test]
15435    fn validate_no_self_dep_empty_lists_pass() {
15436        // A caixa with no declared deps has nothing to self-reference —
15437        // the gate is vacuously satisfied. Peer of
15438        // [`validate_no_self_supervision_empty_children_is_ok`].
15439        validate_no_self_dep(&[], &[], "orquestra").unwrap();
15440    }
15441
15442    #[test]
15443    fn validate_no_self_dep_diagnostic_carries_offending_list_and_nome() {
15444        // Diagnostic-shape pin (peer with
15445        // [`validate_no_self_supervision`]'s diagnostic): the error's
15446        // Display surfaces both the offending list tag and the
15447        // parent's `:nome` verbatim, so the author can grep their
15448        // caixa.lisp for the offending block in one edit. Names
15449        // `:bibliotecas` / `:exe` / `:servicos` as the corrective
15450        // surface — every legitimate "I want to use code from this
15451        // caixa" intent routes through one of those three slots.
15452        let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
15453        let rendered = validate_no_self_dep(&[], &deps_dev, "orquestra")
15454            .unwrap_err()
15455            .to_string();
15456        assert!(
15457            rendered.contains(crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
15458            "diagnostic must name the offending list tag: {rendered}",
15459        );
15460        assert!(
15461            rendered.contains("orquestra"),
15462            "diagnostic must quote the parent caixa name: {rendered}",
15463        );
15464        assert!(
15465            rendered.contains(":bibliotecas"),
15466            "diagnostic must point at the corrective code-surface slot: {rendered}",
15467        );
15468    }
15469
15470    #[test]
15471    fn validate_no_self_dep_accepts_coincidental_substring_match() {
15472        // Identity is exact-string equality, not substring — a dep
15473        // named `"orquestra-helper"` is a distinct caixa even when the
15474        // parent is `"orquestra"`. Pin the exact-match discipline so a
15475        // future relaxation that uses `contains` surfaces here, peer
15476        // with the supervision-tree and Aplicacao-membership gates
15477        // which all use exact-string equality on the typed identity.
15478        let deps = vec![Dep::simple("orquestra-helper", "^0.1")];
15479        validate_no_self_dep(&deps, &[], "orquestra").unwrap();
15480    }
15481
15482    // ── drift-detection: DEP_AUTHOR_KEY_{DEPS,DEPS_DEV} pin ─────────────
15483
15484    #[test]
15485    fn dep_author_key_consts_pin_canonical_kebab_case_labels() {
15486        // Scalar-value pin: the two author-facing kebab-case labels the
15487        // `(defcaixa … :deps ((…)) :deps-dev ((…)))` surface admits on
15488        // the two-list dep-graph slot axis, one arm per typed slot.
15489        // Mirrors the peer scalar-value pin the sibling
15490        // [`crate::M2_AUTHOR_KEY_LIMITS`] /
15491        // [`crate::M2_AUTHOR_KEY_BEHAVIOR`] /
15492        // [`crate::M2_AUTHOR_KEY_UPGRADE_FROM`] (f49c8b0) M2 top-level
15493        // author-labels, [`crate::M3_AUTHOR_KEY_MEMBROS`] etc.
15494        // (882f498) M3 top-level author-labels, and
15495        // [`crate::SUPERVISOR_AUTHOR_KEY_ESTRATEGIA`] etc. (be40492)
15496        // Supervisor top-level author-labels carry, so every kind-scoped
15497        // typed-slot-family axis routes through one canonical per-arm
15498        // declaration.
15499        //
15500        // A future rebrand (`:deps` → `:dependencies` matching Cargo's
15501        // verbatim key, `:deps-dev` → `:dev-dependencies` matching the
15502        // same, `:deps` / `:deps-dev` → `:runtime-deps` / `:dev-deps`
15503        // for symmetry) lands as an edit to exactly one const, and
15504        // every consumer that reaches for the label picks it up at
15505        // build time rather than at runtime as a downstream mismatch on
15506        // a `DepError::DuplicateNome { list: … }` diagnostic far from
15507        // the rename's commit.
15508        assert_eq!(crate::render::DEP_AUTHOR_KEY_DEPS, ":deps");
15509        assert_eq!(crate::render::DEP_AUTHOR_KEY_DEPS_DEV, ":deps-dev");
15510    }
15511
15512    #[test]
15513    fn dep_author_key_consts_are_pairwise_distinct() {
15514        // Distinct-labels pin: the two `:deps` / `:deps-dev` labels
15515        // must not collapse onto one byte-string. A future copy-paste
15516        // slip that renamed both consts to the same value (or a rebrand
15517        // that dropped the `-dev` suffix from one but not the other)
15518        // would leave every `DepError::DuplicateNome { list: … }`
15519        // diagnostic naming an unattributable list — the linter would
15520        // route the author to the wrong caixa.lisp block, or the
15521        // cross-list precedence gate
15522        // (`validate_deps_duplicate_in_deps_fires_before_duplicate_in_deps_dev`)
15523        // would surface a `:deps`-tagged diagnostic on a `:deps-dev`
15524        // duplicate. Peer of the sibling
15525        // `m2_author_key_consts_are_pairwise_distinct`-shape gates the
15526        // other top-level kind-scoped slot-family axes carry
15527        // (implicitly held by their different byte-values today).
15528        assert_ne!(
15529            crate::render::DEP_AUTHOR_KEY_DEPS,
15530            crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
15531            "DEP_AUTHOR_KEY_{{DEPS,DEPS_DEV}} consts must be pairwise-distinct \
15532             so a `DepError::DuplicateNome {{ list: … }}` diagnostic \
15533             self-locates the offending block in the author's caixa.lisp",
15534        );
15535    }
15536
15537    #[test]
15538    fn validate_no_self_dep_routes_through_lifted_dep_author_key_consts() {
15539        // Production-through-const pin: the two per-arm list tags
15540        // [`validate_no_self_dep`] threads onto the `list:` field of a
15541        // returned [`DepError::DepIsSelf`] route through the lifted
15542        // [`crate::DEP_AUTHOR_KEY_DEPS`] /
15543        // [`crate::DEP_AUTHOR_KEY_DEPS_DEV`] consts. A future drift at
15544        // the walker (a rename that reaches one arm but not the const,
15545        // or vice versa) surfaces here at build time rather than at
15546        // runtime as a `feira lint` diagnostic naming the wrong list
15547        // tag. Mirror of the peer
15548        // [`crate::Caixa::declared_servico_slots`] production tagger
15549        // pin (f49c8b0) on the sibling M2 top-level slot axis, extended
15550        // onto the two-list dep-graph gate.
15551        let deps = vec![Dep::simple("orquestra", "^0.1")];
15552        let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
15553        let DepError::DepIsSelf { list, .. } = err else {
15554            panic!("expected DepIsSelf from :deps walk");
15555        };
15556        assert_eq!(list, crate::render::DEP_AUTHOR_KEY_DEPS);
15557
15558        let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
15559        let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
15560        let DepError::DepIsSelf { list, .. } = err else {
15561            panic!("expected DepIsSelf from :deps-dev walk");
15562        };
15563        assert_eq!(list, crate::render::DEP_AUTHOR_KEY_DEPS_DEV);
15564    }
15565
15566    // ── Dep::nome accessor pins ───────────────────────────────────────
15567    //
15568    // Three coherence pins on the lifted `Dep::nome` accessor: byte-equal
15569    // projection over the plain-shorthand / explicit-git / explicit-path
15570    // fixture triad the [`Dep`] docstring lists (so the accessor's
15571    // accept-set is exercised across every author-surface `:fonte`
15572    // shape); by-borrow pointer identity so the projection stays
15573    // zero-copy at every consumer site; and validate-composition through
15574    // the [`validate_no_self_dep`] cross-slot gate reading its
15575    // parent-name equality check through the lifted accessor rather than
15576    // the raw field.
15577
15578    #[test]
15579    fn dep_nome_returns_declared_nome_across_fonte_shapes() {
15580        // Plain-shorthand form (`:fonte None`).
15581        assert_eq!(Dep::simple("caixa-teia", "^0.1").nome(), "caixa-teia");
15582        // Explicit git-source form with a tag pin — same accessor path.
15583        assert_eq!(
15584            Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0").nome(),
15585            "caixa-teia",
15586        );
15587        // Explicit path-source form.
15588        assert_eq!(
15589            Dep {
15590                nome: "caixa-teia".to_string(),
15591                versao: "0.1.0".to_string(),
15592                fonte: Some(DepSource::Path {
15593                    caminho: "../caixa-teia".to_string(),
15594                }),
15595                opcional: false,
15596                caracteristicas: Vec::new(),
15597            }
15598            .nome(),
15599            "caixa-teia",
15600        );
15601        // The empty-string `:nome` sentinel (which [`Dep::validate`]
15602        // refuses through the [`DepError::NomeEmpty`] arm) still round-
15603        // trips as an empty `&str` through the accessor — the accessor is
15604        // a projection, not a gate; the gate is [`Dep::validate`].
15605        assert_eq!(Dep::simple("", "^0.1").nome(), "");
15606    }
15607
15608    #[test]
15609    fn dep_nome_is_by_borrow_pointer_identity() {
15610        // Zero-copy pin: the accessor must borrow into the field's own
15611        // storage, not clone. If a future rewrite regresses to
15612        // `self.nome.clone().leak()` or an owned-buffer shape, the two
15613        // pointers diverge and this pin fails at build time.
15614        let d = Dep::simple("caixa-teia", "^0.1");
15615        assert!(std::ptr::eq(d.nome().as_ptr(), d.nome.as_ptr()));
15616    }
15617
15618    // ── Dep::versao_requirement accessor pins ─────────────────────────
15619    //
15620    // Three coherence pins on the lifted `Dep::versao_requirement`
15621    // accessor: byte-equal projection over the plain-shorthand /
15622    // explicit-git / explicit-path fixture triad the [`Dep`] docstring
15623    // lists plus the empty-sentinel that round-trips as `""` (the accessor
15624    // is a projection, not a gate; the gate is [`Dep::validate`]); by-
15625    // borrow pointer identity so the projection stays zero-copy at every
15626    // consumer site; and validate-composition through the
15627    // [`crate::render::require_valid_versao_requirement`] cascade reading
15628    // its requirement-shape check through the lifted accessor rather than
15629    // the raw field.
15630    #[test]
15631    fn dep_versao_requirement_returns_declared_versao_across_fonte_shapes() {
15632        // Plain-shorthand form (`:fonte None`).
15633        assert_eq!(
15634            Dep::simple("caixa-teia", "^0.1").versao_requirement(),
15635            "^0.1",
15636        );
15637        // Explicit git-source form with a tag pin — same accessor path.
15638        assert_eq!(
15639            Dep::git(
15640                "caixa-teia",
15641                "~0.1.2",
15642                "github:pleme-io/caixa-teia",
15643                "v0.1.0"
15644            )
15645            .versao_requirement(),
15646            "~0.1.2",
15647        );
15648        // Explicit path-source form.
15649        assert_eq!(
15650            Dep {
15651                nome: "caixa-teia".to_string(),
15652                versao: "0.1.0".to_string(),
15653                fonte: Some(DepSource::Path {
15654                    caminho: "../caixa-teia".to_string(),
15655                }),
15656                opcional: false,
15657                caracteristicas: Vec::new(),
15658            }
15659            .versao_requirement(),
15660            "0.1.0",
15661        );
15662        // The wildcard requirement (`"*"`) — the shorthand
15663        // `parse_requirement` accepts as `VersionReq::STAR` — round-trips
15664        // verbatim through the accessor as `"*"`, same byte-shape the
15665        // author wrote.
15666        assert_eq!(Dep::simple("caixa-teia", "*").versao_requirement(), "*");
15667        // The empty-string `:versao` sentinel (which [`Dep::validate`]
15668        // refuses through the [`DepError::VersaoEmpty`] arm) still round-
15669        // trips as an empty `&str` through the accessor — the accessor is
15670        // a projection, not a gate; the gate is [`Dep::validate`]. Peer
15671        // of the sibling [`Dep::nome`] empty-sentinel round-trip pin.
15672        assert_eq!(Dep::simple("caixa-teia", "").versao_requirement(), "");
15673    }
15674
15675    #[test]
15676    fn dep_versao_requirement_is_by_borrow_pointer_identity() {
15677        // Zero-copy pin: the accessor must borrow into the field's own
15678        // storage, not clone. If a future rewrite regresses to
15679        // `self.versao.clone().leak()` or an owned-buffer shape, the two
15680        // pointers diverge and this pin fails at build time. Peer of the
15681        // sibling [`Dep::nome`] pointer-identity pin — same by-borrow
15682        // discipline extended onto the requirement-carrying axis.
15683        let d = Dep::simple("caixa-teia", "^0.1");
15684        assert!(std::ptr::eq(
15685            d.versao_requirement().as_ptr(),
15686            d.versao.as_ptr(),
15687        ));
15688    }
15689
15690    #[test]
15691    fn dep_validate_reads_requirement_through_accessor() {
15692        // Composition pin: the [`Dep::validate`]
15693        // [`crate::render::require_valid_versao_requirement`] cascade
15694        // consumes the requirement string through the lifted accessor —
15695        // both the requirement-gate input and the
15696        // [`DepError::VersaoInvalid`] error-body carrier route through
15697        // `self.versao_requirement()`. A valid requirement passes
15698        // (positive control); a malformed-but-non-empty requirement fails
15699        // and the diagnostic quotes the offending byte-string verbatim
15700        // (same shape the accessor projects), so a future regression that
15701        // detoured the requirement carrier through a different byte-
15702        // string (say the parsed `VersionReq`'s `Display`, or a
15703        // normalized rewrite) would surface here at build time. The
15704        // empty-`:versao` arm fires the [`DepError::VersaoEmpty`] variant
15705        // ahead of the parse arm, pinning the empty-first cascade the
15706        // accessor's `""` sentinel round-trip acknowledges.
15707        Dep::simple("caixa-teia", "^0.1").validate().unwrap();
15708        let err = Dep::simple("caixa-teia", "v0.1").validate().unwrap_err();
15709        assert!(
15710            matches!(
15711                &err,
15712                DepError::VersaoInvalid {
15713                    nome,
15714                    versao,
15715                    ..
15716                } if nome == "caixa-teia" && versao == "v0.1",
15717            ),
15718            "expected VersaoInvalid quoting the accessor-projected requirement, got {err:?}",
15719        );
15720        let err = Dep::simple("caixa-teia", "").validate().unwrap_err();
15721        assert!(
15722            matches!(
15723                &err,
15724                DepError::VersaoEmpty { nome } if nome == "caixa-teia",
15725            ),
15726            "expected VersaoEmpty from the empty-first arm, got {err:?}",
15727        );
15728    }
15729
15730    // ── Dep::fonte accessor pins ──────────────────────────────────────
15731    //
15732    // Three coherence pins on the lifted `Dep::fonte` accessor: byte-
15733    // equal projection over the plain-shorthand (`:fonte None`) /
15734    // explicit-git-tag / explicit-path fixture triad the [`Dep`]
15735    // docstring lists (so the accessor's accept-set is exercised across
15736    // every author-surface `:fonte` shape and both `DepSource` variants);
15737    // pointer identity so the borrowed reference points into the field's
15738    // own `Option<DepSource>` storage (not a cloned side-buffer); and
15739    // validate-composition through the [`Dep::validate`] gate reading
15740    // its per-`:fonte` [`DepSource::validate`] delegation through the
15741    // lifted accessor rather than the raw `if let Some(ref fonte) =
15742    // self.fonte` bracket.
15743
15744    #[test]
15745    fn dep_fonte_returns_declared_source_across_shapes() {
15746        // Plain-shorthand form — `:fonte` omitted, accessor projects
15747        // the `None` partition the resolver-side default-fill treats
15748        // as "resolve through `github:<default-org>/<nome>`".
15749        assert!(Dep::simple("caixa-teia", "^0.1").fonte().is_none());
15750        // Explicit git-source form with a tag pin — same accessor path.
15751        let git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
15752        match git.fonte() {
15753            Some(DepSource::Git {
15754                repo,
15755                tag,
15756                rev,
15757                branch,
15758            }) => {
15759                assert_eq!(repo, "github:pleme-io/caixa-teia");
15760                assert_eq!(tag.as_deref(), Some("v0.1.0"));
15761                assert!(rev.is_none());
15762                assert!(branch.is_none());
15763            }
15764            other => panic!("expected explicit git :fonte, got {other:?}"),
15765        }
15766        // Explicit path-source form — the dev-only local-filesystem
15767        // arm the [`Dep`] docstring's third fixture carries.
15768        let path = Dep {
15769            nome: "caixa-teia".to_string(),
15770            versao: "0.1.0".to_string(),
15771            fonte: Some(DepSource::Path {
15772                caminho: "../caixa-teia".to_string(),
15773            }),
15774            opcional: false,
15775            caracteristicas: Vec::new(),
15776        };
15777        match path.fonte() {
15778            Some(DepSource::Path { caminho }) => {
15779                assert_eq!(caminho, "../caixa-teia");
15780            }
15781            other => panic!("expected explicit path :fonte, got {other:?}"),
15782        }
15783    }
15784
15785    #[test]
15786    fn dep_fonte_is_by_borrow_pointer_identity() {
15787        // Zero-copy pin: the accessor must borrow into the field's own
15788        // `Option<DepSource>` storage, not clone into a side buffer. If
15789        // a future rewrite regresses to `self.fonte.clone()` or an
15790        // owned-buffer shape, the two pointers diverge and this pin
15791        // fails at build time. Peer of the sibling per-`Dep` [`Dep::nome`]
15792        // (eba2cde) / [`Dep::versao_requirement`] (05529b1) pointer-
15793        // identity pins — same by-borrow discipline extended onto the
15794        // outer-`Dep` `Option<&Composite>` composite-reference axis.
15795        let d = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
15796        let accessed = d.fonte().expect("git :fonte present") as *const DepSource;
15797        let raw = d.fonte.as_ref().expect("git :fonte present") as *const DepSource;
15798        assert!(std::ptr::eq(accessed, raw));
15799    }
15800
15801    #[test]
15802    fn dep_validate_reads_fonte_through_accessor() {
15803        // Composition pin: [`Dep::validate`]'s per-`:fonte`
15804        // [`DepSource::validate`] delegation consumes the typed slot
15805        // through the lifted accessor — an author-omitted `:fonte`
15806        // still passes the outer gate (positive control), an explicit
15807        // well-formed git source with exactly one pin passes, and a
15808        // malformed git source (empty `:repo`) surfaces the
15809        // [`DepError::FonteRepoEmpty`] variant quoting the offending
15810        // dep's `:nome` verbatim so a future regression that detoured
15811        // the `:fonte` delegation through a different path (say a
15812        // per-scope override projector) would surface here at build
15813        // time. Peer of the sibling
15814        // `dep_validate_reads_requirement_through_accessor` composition
15815        // pin on the `:versao` axis.
15816        // Positive control 1: no `:fonte` at all.
15817        Dep::simple("caixa-teia", "^0.1").validate().unwrap();
15818        // Positive control 2: well-formed git source.
15819        Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0")
15820            .validate()
15821            .unwrap();
15822        // Negative control: empty `:repo` — the accessor still returns
15823        // `Some(&DepSource::Git { repo: "", … })` and the delegated
15824        // `DepSource::validate` gate raises the typed carrier.
15825        let bad = Dep {
15826            nome: "caixa-teia".to_string(),
15827            versao: "^0.1".to_string(),
15828            fonte: Some(DepSource::Git {
15829                repo: String::new(),
15830                tag: Some("v0.1.0".to_string()),
15831                rev: None,
15832                branch: None,
15833            }),
15834            opcional: false,
15835            caracteristicas: Vec::new(),
15836        };
15837        let err = bad.validate().unwrap_err();
15838        assert!(
15839            matches!(
15840                &err,
15841                DepError::FonteRepoEmpty { nome } if nome == "caixa-teia",
15842            ),
15843            "expected FonteRepoEmpty from the accessor-routed :fonte gate, got {err:?}",
15844        );
15845    }
15846
15847    #[test]
15848    fn validate_no_self_dep_reads_parent_equality_through_accessor() {
15849        // Composition pin: the cross-slot [`validate_no_self_dep`] gate
15850        // rejects a `:deps` entry whose `:nome` equals the parent caixa's
15851        // own `:nome` through the lifted accessor rather than the raw
15852        // field. Fails-before-passes-after: with the accessor lifted the
15853        // gate reads its equality check through `dep.nome() ==
15854        // parent_nome` on both the `:deps` and `:deps-dev` traversals, so
15855        // the diagnostic still names the offending list tag as expected.
15856        let deps = vec![Dep::simple("orquestra", "^0.1")];
15857        let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
15858        assert!(matches!(
15859            err,
15860            DepError::DepIsSelf {
15861                ref nome,
15862                list,
15863            } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS,
15864        ));
15865        let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
15866        let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
15867        assert!(matches!(
15868            err,
15869            DepError::DepIsSelf {
15870                ref nome,
15871                list,
15872            } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
15873        ));
15874        // A non-matching `:nome` passes through the accessor gate.
15875        let deps = vec![Dep::simple("caixa-teia", "^0.1")];
15876        validate_no_self_dep(&deps, &[], "orquestra").unwrap();
15877    }
15878
15879    // ── Dep::caracteristicas accessor pins ────────────────────────────
15880    //
15881    // Three coherence pins on the lifted `Dep::caracteristicas` accessor:
15882    // byte-equal projection over the default-empty / single-entry /
15883    // multi-entry fixture triad (so the accessor's accept-set is
15884    // exercised across every author-surface `:caracteristicas` shape,
15885    // matching the peer sibling family's fixture-triad discipline); by-
15886    // borrow pointer identity so the projection stays zero-copy at every
15887    // consumer site; and validate-composition through the
15888    // [`Dep::validate_caracteristicas`] gate reading its per-entry
15889    // linear walk through the lifted accessor rather than the raw
15890    // `for c in &self.caracteristicas` bracket.
15891
15892    #[test]
15893    fn dep_caracteristicas_returns_declared_features_across_shapes() {
15894        // Default-empty form — the [`Dep::simple`] constructor's
15895        // `Vec::new()` fill; the accessor projects the empty slice
15896        // verbatim (no `None` collapse).
15897        assert!(
15898            Dep::simple("caixa-teia", "^0.1")
15899                .caracteristicas()
15900                .is_empty(),
15901        );
15902        // Single-entry form — the canonical Cargo-shaped one-feature
15903        // enable ([`crate::render::is_cargo_feature_name`] accepts the
15904        // `"http"` byte-string as a valid feature name).
15905        let one = Dep {
15906            nome: "caixa-teia".to_string(),
15907            versao: "^0.1".to_string(),
15908            fonte: None,
15909            opcional: false,
15910            caracteristicas: vec!["http".to_string()],
15911        };
15912        assert_eq!(one.caracteristicas(), &["http".to_string()]);
15913        // Multi-entry form — the substrate's set-shaped multi-feature
15914        // enable, exercising the accessor over a length-two slice with
15915        // no duplicate collapse.
15916        let two = Dep {
15917            nome: "caixa-teia".to_string(),
15918            versao: "^0.1".to_string(),
15919            fonte: None,
15920            opcional: false,
15921            caracteristicas: vec!["http".to_string(), "json".to_string()],
15922        };
15923        assert_eq!(
15924            two.caracteristicas(),
15925            &["http".to_string(), "json".to_string()],
15926        );
15927    }
15928
15929    #[test]
15930    fn dep_caracteristicas_is_by_borrow_pointer_identity() {
15931        // Zero-copy pin: the accessor must borrow into the field's own
15932        // `Vec<String>` storage, not clone into a side buffer. If a
15933        // future rewrite regresses to `self.caracteristicas.clone()` or
15934        // an owned-buffer shape, the two pointers diverge and this pin
15935        // fails at build time. Peer of the sibling per-`Dep`
15936        // [`Dep::nome`] (eba2cde) / [`Dep::versao_requirement`] (05529b1)
15937        // / [`Dep::fonte`] (d65d1bf) pointer-identity pins — same by-
15938        // borrow discipline extended onto the outer-`Dep` `&[String]`
15939        // slice-projection axis.
15940        let d = Dep {
15941            nome: "caixa-teia".to_string(),
15942            versao: "^0.1".to_string(),
15943            fonte: None,
15944            opcional: false,
15945            caracteristicas: vec!["http".to_string(), "json".to_string()],
15946        };
15947        assert!(std::ptr::eq(
15948            d.caracteristicas().as_ptr(),
15949            d.caracteristicas.as_ptr(),
15950        ));
15951    }
15952
15953    #[test]
15954    fn dep_validate_reads_caracteristicas_through_accessor() {
15955        // Composition pin: [`Dep::validate_caracteristicas`]'s per-entry
15956        // linear walk consumes the feature-toggle list through the
15957        // lifted accessor — a well-formed `:caracteristicas` set passes
15958        // (positive control), an empty-string entry surfaces the
15959        // [`DepError::CaracteristicaEmpty`] variant quoting the offending
15960        // `Dep::nome`, and a within-list duplicate surfaces the
15961        // [`DepError::CaracteristicaDuplicate`] variant so a future
15962        // regression that detoured the walk through a different byte-
15963        // string list (say a per-scope override projector) would surface
15964        // here at build time. Peer of the sibling
15965        // `dep_validate_reads_fonte_through_accessor` /
15966        // `dep_validate_reads_requirement_through_accessor` composition
15967        // pins on the `:fonte` / `:versao` axes.
15968        // Positive control: two distinct well-formed feature names pass.
15969        Dep {
15970            nome: "caixa-teia".to_string(),
15971            versao: "^0.1".to_string(),
15972            fonte: None,
15973            opcional: false,
15974            caracteristicas: vec!["http".to_string(), "json".to_string()],
15975        }
15976        .validate()
15977        .unwrap();
15978        // Negative control 1: empty-string feature-name entry — the
15979        // accessor still returns `&[""]` and the walk raises the typed
15980        // empty-first carrier.
15981        let err = Dep {
15982            nome: "caixa-teia".to_string(),
15983            versao: "^0.1".to_string(),
15984            fonte: None,
15985            opcional: false,
15986            caracteristicas: vec![String::new()],
15987        }
15988        .validate()
15989        .unwrap_err();
15990        assert!(
15991            matches!(
15992                &err,
15993                DepError::CaracteristicaEmpty { nome } if nome == "caixa-teia",
15994            ),
15995            "expected CaracteristicaEmpty from the accessor-routed walk, got {err:?}",
15996        );
15997        // Negative control 2: within-list duplicate — the accessor's
15998        // slice view carries both entries, and the walk's dedup arm
15999        // raises the typed duplicate carrier quoting the offending
16000        // feature name verbatim.
16001        let err = Dep {
16002            nome: "caixa-teia".to_string(),
16003            versao: "^0.1".to_string(),
16004            fonte: None,
16005            opcional: false,
16006            caracteristicas: vec!["http".to_string(), "http".to_string()],
16007        }
16008        .validate()
16009        .unwrap_err();
16010        assert!(
16011            matches!(
16012                &err,
16013                DepError::CaracteristicaDuplicate {
16014                    nome,
16015                    caracteristica,
16016                } if nome == "caixa-teia" && caracteristica == "http",
16017            ),
16018            "expected CaracteristicaDuplicate from the accessor-routed dedup, got {err:?}",
16019        );
16020    }
16021
16022    // ── Dep::opcional accessor pins ───────────────────────────────────
16023    //
16024    // Two coherence pins on the lifted `Dep::opcional` accessor: byte-
16025    // equal projection over the default-`false` / explicit-`true`
16026    // fixture pair across the plain-shorthand (`:fonte None`) / explicit-
16027    // git-tag / explicit-path fixture triad the [`Dep`] docstring lists,
16028    // exercising the accessor's accept-set over every author-surface
16029    // `:fonte` shape × every author-surface `:opcional` shape; and by-
16030    // `Copy` idempotency so the projection stays value-return (no
16031    // silent detour to a fresh `&bool` borrow that would introduce a
16032    // lifetime on the return type the plain-`Copy`-scalar axis's `bool`
16033    // shape elides). No composition pin — `:opcional` does not
16034    // participate in [`Dep::validate`] (an opcional dep with any bool
16035    // value is validate-accepted; the missing-source arm is a resolver-
16036    // side runtime dispatch, not a build-time refusal), so the axis
16037    // reduces to the value-shape + `Copy` pin pair the peer
16038    // [`crate::Caixa::max_restarts`] / [`crate::Caixa::estrategia`]
16039    // outer-`Option<Copy>` accessor pins already carry.
16040
16041    #[test]
16042    fn dep_opcional_returns_declared_opcional_across_fonte_shapes() {
16043        // Default-`false` form via the [`Dep::simple`] constructor —
16044        // the accessor projects the `false` bit the default-fill sets.
16045        assert!(!Dep::simple("caixa-teia", "^0.1").opcional());
16046        // Default-`false` form via the [`Dep::git`] constructor — same
16047        // default fill; the accessor projects `false` regardless of the
16048        // `:fonte` arm.
16049        assert!(!Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0").opcional(),);
16050        // Explicit-`true` form × plain-shorthand `:fonte` — the
16051        // canonical author-surface "this dep may be missing" shape.
16052        let plain_true = Dep {
16053            nome: "caixa-teia".to_string(),
16054            versao: "^0.1".to_string(),
16055            fonte: None,
16056            opcional: true,
16057            caracteristicas: Vec::new(),
16058        };
16059        assert!(plain_true.opcional());
16060        // Explicit-`true` form × explicit git-source — the accessor
16061        // projects the bit verbatim regardless of the `:fonte` arm.
16062        let git_true = Dep {
16063            nome: "caixa-teia".to_string(),
16064            versao: "^0.1".to_string(),
16065            fonte: Some(DepSource::Git {
16066                repo: "github:pleme-io/caixa-teia".to_string(),
16067                tag: Some("v0.1.0".to_string()),
16068                rev: None,
16069                branch: None,
16070            }),
16071            opcional: true,
16072            caracteristicas: Vec::new(),
16073        };
16074        assert!(git_true.opcional());
16075        // Explicit-`true` form × explicit path-source — the dev-only
16076        // local-filesystem arm the [`Dep`] docstring's third fixture
16077        // carries.
16078        let path_true = Dep {
16079            nome: "caixa-teia".to_string(),
16080            versao: "0.1.0".to_string(),
16081            fonte: Some(DepSource::Path {
16082                caminho: "../caixa-teia".to_string(),
16083            }),
16084            opcional: true,
16085            caracteristicas: Vec::new(),
16086        };
16087        assert!(path_true.opcional());
16088    }
16089
16090    #[test]
16091    fn dep_opcional_projects_bool_by_copy() {
16092        // The by-`Copy` pin: [`Dep::opcional`] returns `bool` by value
16093        // (`bool: Copy`) — the accessor does not borrow `&self` past
16094        // the call (no lifetime on the return type), and calling the
16095        // accessor twice on the same [`Dep`] must yield discriminant-
16096        // equal values (idempotent, no side effects on `&self`). Peer
16097        // of the sibling outer-`Caixa` `Option<Copy>` by-`Copy`
16098        // `max_restarts_projects_option_by_copy` (eba5211) /
16099        // `estrategia_projects_option_by_copy` (ed04d3c) pins on the
16100        // outer-`Caixa` altitude — extended here to the outer-`Dep`
16101        // altitude's plain-`Copy` `bool` axis. The `Copy` discipline
16102        // replaces the pointer-equality claim the sibling per-`Dep`
16103        // by-borrow pins (`dep_nome_is_by_borrow_pointer_identity`
16104        // eba2cde, `dep_versao_requirement_is_by_borrow_pointer_identity`
16105        // 05529b1, `dep_fonte_is_by_borrow_pointer_identity` d65d1bf,
16106        // `dep_caracteristicas_is_by_borrow_pointer_identity` 9197944)
16107        // carry (a fresh `Copy` of a `Copy` discriminant is definitionally
16108        // the same discriminant, so the axis reduces to discriminant
16109        // equality).
16110        //
16111        // Pins against a future silent detour that returned a fresh
16112        // `&bool` reference (which would type-check but silently
16113        // introduce a borrow of `&self` past the call, collapsing the
16114        // load-bearing "no lifetime on the return type" `Copy`
16115        // projection the plain-`Copy`-scalar axis's `bool` shape
16116        // carries) or a stale-read side effect that flipped the outer
16117        // discriminant on successive calls.
16118        for opcional in [false, true] {
16119            let d = Dep {
16120                nome: "caixa-teia".to_string(),
16121                versao: "^0.1".to_string(),
16122                fonte: None,
16123                opcional,
16124                caracteristicas: Vec::new(),
16125            };
16126            let first = d.opcional();
16127            let second = d.opcional();
16128            assert_eq!(
16129                first, second,
16130                "Dep::opcional must be idempotent — two successive calls \
16131                 on the same &self must return the same bool",
16132            );
16133            assert_eq!(
16134                first, opcional,
16135                "Dep::opcional must return :opcional verbatim by Copy — \
16136                 got {first}, expected {opcional}",
16137            );
16138            assert_eq!(
16139                d.opcional(),
16140                d.opcional,
16141                "Dep::opcional accessor and self.opcional field access \
16142                 must byte-equal — a bit-flip drift would silently split \
16143                 the paired resolver-side drop-vs-error dispatch from \
16144                 the storage-side default-fill the [`Dep::simple`] / \
16145                 [`Dep::git`] constructor pair carries",
16146            );
16147        }
16148    }
16149
16150    // ── DepSource::sole_pin — sole-set git-pin accessor ─────────────────
16151
16152    #[test]
16153    fn sole_pin_returns_none_for_path_source() {
16154        // A path source carries no git-ref, so `sole_pin()` returns
16155        // `None` structurally — the sibling arm every git-fetching
16156        // consumer partitions off before reaching for a git-ref. Pins
16157        // the Path-arm branch of the accessor against a future silent
16158        // detour that treats a `Self::Path` as an unpinned-git source
16159        // and returns the wrong "no pin" signal (e.g. the empty string,
16160        // or a hard-coded `Some("HEAD")` matching the caixa-crd
16161        // path-arm `git_ref` fill).
16162        let s = DepSource::Path {
16163            caminho: "../local-caixa".to_string(),
16164        };
16165        assert_eq!(s.sole_pin(), None);
16166    }
16167
16168    #[test]
16169    fn sole_pin_returns_none_for_unpinned_git_source() {
16170        // The [`DepSource::default_github`] shorthand shape carries no
16171        // pin — every `tag`/`rev`/`branch` is `None`, and `sole_pin()`
16172        // returns `None`. This is the shape caixa-resolver's `fetch_dep`
16173        // materializes when the author omits `:fonte` entirely, then
16174        // hands to `fetch_git` which raises `ResolveError::MissingPin`
16175        // on the `None` arm — the accessor's return matches the arm
16176        // the resolver's diagnostic keys off.
16177        let s = DepSource::default_github("pleme-io", "caixa-teia");
16178        assert_eq!(s.sole_pin(), None);
16179    }
16180
16181    #[test]
16182    fn sole_pin_returns_rev_when_only_rev_is_set() {
16183        let s = DepSource::Git {
16184            repo: "github:o/x".into(),
16185            tag: None,
16186            rev: Some("deadbeefcafebabe1234567890abcdef12345678".into()),
16187            branch: None,
16188        };
16189        assert_eq!(
16190            s.sole_pin(),
16191            Some("deadbeefcafebabe1234567890abcdef12345678")
16192        );
16193    }
16194
16195    #[test]
16196    fn sole_pin_returns_tag_when_only_tag_is_set() {
16197        let s = DepSource::Git {
16198            repo: "github:o/x".into(),
16199            tag: Some("v0.1.0".into()),
16200            rev: None,
16201            branch: None,
16202        };
16203        assert_eq!(s.sole_pin(), Some("v0.1.0"));
16204    }
16205
16206    #[test]
16207    fn sole_pin_returns_branch_when_only_branch_is_set() {
16208        let s = DepSource::Git {
16209            repo: "github:o/x".into(),
16210            tag: None,
16211            rev: None,
16212            branch: Some("main".into()),
16213        };
16214        assert_eq!(s.sole_pin(), Some("main"));
16215    }
16216
16217    #[test]
16218    fn sole_pin_precedence_rev_beats_tag_and_branch() {
16219        // Precedence: rev > tag > branch. Validate() rejects
16220        // multiple-pin shapes, but the accessor's precedence is defined
16221        // for pre-validate consumers (the resolver's `MissingPin`
16222        // diagnostic path, the caixa-crd round-trip's default `"main"`
16223        // fallback) and as defense-in-depth if the gate is ever
16224        // bypassed. Pins the same precedence caixa-resolver's
16225        // `fetch_git` and caixa-crd's `dep_into_ref` already apply
16226        // inline.
16227        let s = DepSource::Git {
16228            repo: "github:o/x".into(),
16229            tag: Some("v1".into()),
16230            rev: Some("deadbeefcafebabe1234567890abcdef12345678".into()),
16231            branch: Some("main".into()),
16232        };
16233        assert_eq!(
16234            s.sole_pin(),
16235            Some("deadbeefcafebabe1234567890abcdef12345678")
16236        );
16237    }
16238
16239    #[test]
16240    fn sole_pin_precedence_tag_beats_branch_when_no_rev() {
16241        let s = DepSource::Git {
16242            repo: "github:o/x".into(),
16243            tag: Some("v1".into()),
16244            rev: None,
16245            branch: Some("main".into()),
16246        };
16247        assert_eq!(s.sole_pin(), Some("v1"));
16248    }
16249
16250    #[test]
16251    fn sole_pin_byte_equals_inline_rev_or_tag_or_branch_cascade() {
16252        // Fail-before-pass-after byte-parity pin: the substrate accessor
16253        // must return byte-identical to the inline
16254        // `rev.as_deref().or(tag.as_deref()).or(branch.as_deref())`
16255        // cascade both caixa-resolver's `fetch_git` and caixa-crd's
16256        // `dep_into_ref` open-coded pre-lift. Trips at caixa-core build
16257        // time if the accessor's precedence silently drifts from the
16258        // consumer-side cascade — the exact drift this lift converges
16259        // to one substrate primitive to close structurally.
16260        //
16261        // Iterates through the 2^3 = 8 combinations of (tag, rev,
16262        // branch) each-either-`None`-or-`Some`, so every arm of the
16263        // precedence cascade lands under the pin. `validate()` refuses
16264        // the 4 multi-pin combinations, but the accessor's return is
16265        // defined on all 8.
16266        let vals = [Some("R".to_string()), None];
16267        for tag in &vals {
16268            for rev in &vals {
16269                for branch in &vals {
16270                    let s = DepSource::Git {
16271                        repo: "github:o/x".into(),
16272                        tag: tag.clone(),
16273                        rev: rev.clone(),
16274                        branch: branch.clone(),
16275                    };
16276                    // The exact inline cascade the two pre-lift
16277                    // consumer sites hand-rolled, byte-for-byte.
16278                    let expected = rev.as_deref().or(tag.as_deref()).or(branch.as_deref());
16279                    assert_eq!(
16280                        s.sole_pin(),
16281                        expected,
16282                        "sole_pin() must byte-equal \
16283                         rev.or(tag).or(branch) for \
16284                         (tag={tag:?}, rev={rev:?}, branch={branch:?}) — \
16285                         a drift would silently split caixa-resolver's \
16286                         fetch_git checkout target from caixa-crd's \
16287                         dep_into_ref git_ref fill",
16288                    );
16289                }
16290            }
16291        }
16292    }
16293
16294    // Fail-before-pass-after pins on the eleven
16295    // [`fonte_caminho_ctors!`]-generated `DepError::fonte_caminho_*`
16296    // constructors folded from the [`DepSource::validate_caminho`]
16297    // wire-up sites. Each pins the generated ctor's output to the
16298    // pre-lift struct-literal on the same `(&str, &str)` fixture, so
16299    // any wrapper-side lowercase / trim / re-order / silent-field-swap
16300    // regression on the two-field `{ nome: nome.to_string(), caminho:
16301    // caminho.to_string() }` construction surfaces here rather than at
16302    // a downstream diagnostic-shape mismatch. Peer of the sibling
16303    // `empty_child_version_ctor_matches_struct_literal_wrap` /
16304    // `contrato_endpoint_empty_ctor_matches_struct_literal_wrap` /
16305    // `entrada_host_invalid_ctor_matches_struct_literal_wrap` /
16306    // `nome_only_ctor_routes_caixa_through_nome_accessor` equivalence
16307    // pins on the peer `SupervisorError` / `AplicacaoError` /
16308    // `LayoutError` / `LimitsError` / `UpgradeError` envelopes.
16309
16310    #[test]
16311    fn fonte_caminho_absolute_ctor_matches_struct_literal_wrap() {
16312        assert_eq!(
16313            DepError::fonte_caminho_absolute("caixa-teia", "/home/me/work/caixa-teia"),
16314            DepError::FonteCaminhoAbsolute {
16315                nome: "caixa-teia".to_string(),
16316                caminho: "/home/me/work/caixa-teia".to_string(),
16317            },
16318            "generated fonte_caminho_absolute ctor must produce byte-equal \
16319             DepError to the open-coded struct-literal wrap on the same \
16320             (&str, &str) fixture",
16321        );
16322    }
16323
16324    #[test]
16325    fn fonte_caminho_tilde_expansion_ctor_matches_struct_literal_wrap() {
16326        assert_eq!(
16327            DepError::fonte_caminho_tilde_expansion("caixa-teia", "~/work/caixa-teia"),
16328            DepError::FonteCaminhoTildeExpansion {
16329                nome: "caixa-teia".to_string(),
16330                caminho: "~/work/caixa-teia".to_string(),
16331            },
16332        );
16333    }
16334
16335    #[test]
16336    fn fonte_caminho_var_expansion_ctor_matches_struct_literal_wrap() {
16337        assert_eq!(
16338            DepError::fonte_caminho_var_expansion("caixa-teia", "$HOME/work/caixa-teia"),
16339            DepError::FonteCaminhoVarExpansion {
16340                nome: "caixa-teia".to_string(),
16341                caminho: "$HOME/work/caixa-teia".to_string(),
16342            },
16343        );
16344    }
16345
16346    #[test]
16347    fn fonte_caminho_leading_whitespace_ctor_matches_struct_literal_wrap() {
16348        assert_eq!(
16349            DepError::fonte_caminho_leading_whitespace("caixa-teia", " ../caixa-teia"),
16350            DepError::FonteCaminhoLeadingWhitespace {
16351                nome: "caixa-teia".to_string(),
16352                caminho: " ../caixa-teia".to_string(),
16353            },
16354        );
16355    }
16356
16357    #[test]
16358    fn fonte_caminho_leading_hyphen_ctor_matches_struct_literal_wrap() {
16359        assert_eq!(
16360            DepError::fonte_caminho_leading_hyphen("caixa-teia", "-rf"),
16361            DepError::FonteCaminhoLeadingHyphen {
16362                nome: "caixa-teia".to_string(),
16363                caminho: "-rf".to_string(),
16364            },
16365        );
16366    }
16367
16368    #[test]
16369    fn fonte_caminho_backslash_ctor_matches_struct_literal_wrap() {
16370        assert_eq!(
16371            DepError::fonte_caminho_backslash("caixa-teia", "..\\caixa-teia"),
16372            DepError::FonteCaminhoBackslash {
16373                nome: "caixa-teia".to_string(),
16374                caminho: "..\\caixa-teia".to_string(),
16375            },
16376        );
16377    }
16378
16379    #[test]
16380    fn fonte_caminho_shell_pipe_ctor_matches_struct_literal_wrap() {
16381        assert_eq!(
16382            DepError::fonte_caminho_shell_pipe("caixa-teia", "../caixa-teia|evil"),
16383            DepError::FonteCaminhoShellPipe {
16384                nome: "caixa-teia".to_string(),
16385                caminho: "../caixa-teia|evil".to_string(),
16386            },
16387        );
16388    }
16389
16390    #[test]
16391    fn fonte_caminho_shell_semicolon_ctor_matches_struct_literal_wrap() {
16392        assert_eq!(
16393            DepError::fonte_caminho_shell_semicolon("caixa-teia", "../caixa-teia;evil"),
16394            DepError::FonteCaminhoShellSemicolon {
16395                nome: "caixa-teia".to_string(),
16396                caminho: "../caixa-teia;evil".to_string(),
16397            },
16398        );
16399    }
16400
16401    #[test]
16402    fn fonte_caminho_shell_background_ctor_matches_struct_literal_wrap() {
16403        assert_eq!(
16404            DepError::fonte_caminho_shell_background("caixa-teia", "../caixa-teia&"),
16405            DepError::FonteCaminhoShellBackground {
16406                nome: "caixa-teia".to_string(),
16407                caminho: "../caixa-teia&".to_string(),
16408            },
16409        );
16410    }
16411
16412    #[test]
16413    fn fonte_caminho_shell_command_substitution_ctor_matches_struct_literal_wrap() {
16414        assert_eq!(
16415            DepError::fonte_caminho_shell_command_substitution(
16416                "caixa-teia",
16417                "../caixa-teia`whoami`",
16418            ),
16419            DepError::FonteCaminhoShellCommandSubstitution {
16420                nome: "caixa-teia".to_string(),
16421                caminho: "../caixa-teia`whoami`".to_string(),
16422            },
16423        );
16424    }
16425
16426    #[test]
16427    fn fonte_caminho_trailing_slash_ctor_matches_struct_literal_wrap() {
16428        assert_eq!(
16429            DepError::fonte_caminho_trailing_slash("caixa-teia", "../caixa-teia/"),
16430            DepError::FonteCaminhoTrailingSlash {
16431                nome: "caixa-teia".to_string(),
16432                caminho: "../caixa-teia/".to_string(),
16433            },
16434        );
16435    }
16436
16437    #[test]
16438    fn fonte_caminho_ctors_route_nome_and_caminho_through_to_string() {
16439        // Cross-axis pin: sweep the two constructor input axes
16440        // (`nome: &str`, `caminho: &str`) through a non-default fixture
16441        // pair against every generated arm in the
16442        // [`fonte_caminho_ctors!`] macro, so any wrapper-side lowercase
16443        // / trim / truncate / re-order on the two-field
16444        // `{ nome, caminho }` construction — or a silent field swap
16445        // between the two axes at codegen time — surfaces here rather
16446        // than at a downstream diagnostic-shape mismatch. Peer of the
16447        // sibling `supervisor_caixa_only_ctors_route_caixa_through_
16448        // to_string` cross-axis routing pin on the peer
16449        // `SupervisorError` envelope, extended here onto the
16450        // `DepError` `{ nome: String, caminho: String }` envelope so
16451        // every substrate-primitive ctor family in caixa-core
16452        // guarantees each `&str`-field construction routes the
16453        // caller's `&str` verbatim through `.to_string()`.
16454        let nome = "sibling-teia";
16455        let caminho = "../workspace/sibling";
16456        let cases: [(DepError, DepError); 11] = [
16457            (
16458                DepError::fonte_caminho_absolute(nome, caminho),
16459                DepError::FonteCaminhoAbsolute {
16460                    nome: nome.to_string(),
16461                    caminho: caminho.to_string(),
16462                },
16463            ),
16464            (
16465                DepError::fonte_caminho_tilde_expansion(nome, caminho),
16466                DepError::FonteCaminhoTildeExpansion {
16467                    nome: nome.to_string(),
16468                    caminho: caminho.to_string(),
16469                },
16470            ),
16471            (
16472                DepError::fonte_caminho_var_expansion(nome, caminho),
16473                DepError::FonteCaminhoVarExpansion {
16474                    nome: nome.to_string(),
16475                    caminho: caminho.to_string(),
16476                },
16477            ),
16478            (
16479                DepError::fonte_caminho_leading_whitespace(nome, caminho),
16480                DepError::FonteCaminhoLeadingWhitespace {
16481                    nome: nome.to_string(),
16482                    caminho: caminho.to_string(),
16483                },
16484            ),
16485            (
16486                DepError::fonte_caminho_leading_hyphen(nome, caminho),
16487                DepError::FonteCaminhoLeadingHyphen {
16488                    nome: nome.to_string(),
16489                    caminho: caminho.to_string(),
16490                },
16491            ),
16492            (
16493                DepError::fonte_caminho_backslash(nome, caminho),
16494                DepError::FonteCaminhoBackslash {
16495                    nome: nome.to_string(),
16496                    caminho: caminho.to_string(),
16497                },
16498            ),
16499            (
16500                DepError::fonte_caminho_shell_pipe(nome, caminho),
16501                DepError::FonteCaminhoShellPipe {
16502                    nome: nome.to_string(),
16503                    caminho: caminho.to_string(),
16504                },
16505            ),
16506            (
16507                DepError::fonte_caminho_shell_semicolon(nome, caminho),
16508                DepError::FonteCaminhoShellSemicolon {
16509                    nome: nome.to_string(),
16510                    caminho: caminho.to_string(),
16511                },
16512            ),
16513            (
16514                DepError::fonte_caminho_shell_background(nome, caminho),
16515                DepError::FonteCaminhoShellBackground {
16516                    nome: nome.to_string(),
16517                    caminho: caminho.to_string(),
16518                },
16519            ),
16520            (
16521                DepError::fonte_caminho_shell_command_substitution(nome, caminho),
16522                DepError::FonteCaminhoShellCommandSubstitution {
16523                    nome: nome.to_string(),
16524                    caminho: caminho.to_string(),
16525                },
16526            ),
16527            (
16528                DepError::fonte_caminho_trailing_slash(nome, caminho),
16529                DepError::FonteCaminhoTrailingSlash {
16530                    nome: nome.to_string(),
16531                    caminho: caminho.to_string(),
16532                },
16533            ),
16534        ];
16535        for (via_ctor, via_struct_literal) in cases {
16536            assert_eq!(
16537                via_ctor, via_struct_literal,
16538                "fonte_caminho_ctors!-generated ctor must route (nome, caminho) \
16539                 through `.to_string()` in declared field order — a field-swap or \
16540                 silent-conversion regression surfaces here rather than at a \
16541                 downstream diagnostic-shape mismatch",
16542            );
16543        }
16544    }
16545
16546    // ── `dep_nome_only_ctors!` — the paired `{ nome: String }` single-slot
16547    //    envelope on `DepError`, sibling of the peer `fonte_caminho_ctors!`
16548    //    (f85f145) on the `{ nome, caminho }` two-slot envelope of the same
16549    //    enum, and of `supervisor_caixa_only_ctors!` (db09650) on the peer
16550    //    `SupervisorError` envelope's `{ caixa: String }` single-slot axis.
16551
16552    #[test]
16553    fn versao_empty_ctor_matches_struct_literal_wrap() {
16554        assert_eq!(
16555            DepError::versao_empty("caixa-teia"),
16556            DepError::VersaoEmpty {
16557                nome: "caixa-teia".to_string(),
16558            },
16559        );
16560    }
16561
16562    #[test]
16563    fn fonte_repo_empty_ctor_matches_struct_literal_wrap() {
16564        assert_eq!(
16565            DepError::fonte_repo_empty("caixa-teia"),
16566            DepError::FonteRepoEmpty {
16567                nome: "caixa-teia".to_string(),
16568            },
16569        );
16570    }
16571
16572    #[test]
16573    fn fonte_pin_missing_ctor_matches_struct_literal_wrap() {
16574        assert_eq!(
16575            DepError::fonte_pin_missing("caixa-teia"),
16576            DepError::FontePinMissing {
16577                nome: "caixa-teia".to_string(),
16578            },
16579        );
16580    }
16581
16582    #[test]
16583    fn fonte_caminho_empty_ctor_matches_struct_literal_wrap() {
16584        assert_eq!(
16585            DepError::fonte_caminho_empty("caixa-teia"),
16586            DepError::FonteCaminhoEmpty {
16587                nome: "caixa-teia".to_string(),
16588            },
16589        );
16590    }
16591
16592    #[test]
16593    fn caracteristica_empty_ctor_matches_struct_literal_wrap() {
16594        assert_eq!(
16595            DepError::caracteristica_empty("caixa-teia"),
16596            DepError::CaracteristicaEmpty {
16597                nome: "caixa-teia".to_string(),
16598            },
16599        );
16600    }
16601
16602    #[test]
16603    fn dep_nome_only_ctors_route_nome_through_to_string() {
16604        // Cross-axis routing pin: sweep the single constructor input
16605        // axis (`nome: &str`) through a non-default fixture against
16606        // every generated arm in the [`dep_nome_only_ctors!`] macro, so
16607        // any wrapper-side lowercase / trim / truncate at codegen time
16608        // — or a silent field re-name away from the canonical `nome`
16609        // axis on any one variant — surfaces here rather than at a
16610        // downstream diagnostic-shape mismatch. Peer of the sibling
16611        // `fonte_caminho_ctors_route_nome_and_caminho_through_
16612        // to_string` cross-axis routing pin on the same envelope's
16613        // two-slot family (f85f145) and of the peer
16614        // `supervisor_caixa_only_ctors_route_caixa_through_to_string`
16615        // pin on the `SupervisorError` single-slot family (db09650).
16616        let nome = "sibling-teia";
16617        let cases: [(DepError, DepError); 5] = [
16618            (
16619                DepError::versao_empty(nome),
16620                DepError::VersaoEmpty {
16621                    nome: nome.to_string(),
16622                },
16623            ),
16624            (
16625                DepError::fonte_repo_empty(nome),
16626                DepError::FonteRepoEmpty {
16627                    nome: nome.to_string(),
16628                },
16629            ),
16630            (
16631                DepError::fonte_pin_missing(nome),
16632                DepError::FontePinMissing {
16633                    nome: nome.to_string(),
16634                },
16635            ),
16636            (
16637                DepError::fonte_caminho_empty(nome),
16638                DepError::FonteCaminhoEmpty {
16639                    nome: nome.to_string(),
16640                },
16641            ),
16642            (
16643                DepError::caracteristica_empty(nome),
16644                DepError::CaracteristicaEmpty {
16645                    nome: nome.to_string(),
16646                },
16647            ),
16648        ];
16649        for (via_ctor, via_struct_literal) in cases {
16650            assert_eq!(
16651                via_ctor, via_struct_literal,
16652                "dep_nome_only_ctors!-generated ctor must route `nome` \
16653                 through `.to_string()` onto the canonical `nome` field \
16654                 — a field-rename or silent-conversion regression surfaces \
16655                 here rather than at a downstream diagnostic-shape mismatch",
16656            );
16657        }
16658    }
16659
16660    // ── `dep_nome_list_ctors!` — the paired `{ nome: String, list:
16661    //    &'static str }` two-slot envelope on `DepError`, strict
16662    //    sibling of the peer `dep_nome_only_ctors!` (792aa92) on the
16663    //    same envelope's `{ nome: String }` one-slot shape and of the
16664    //    peer `supervisor_caixa_only_ctors!` (db09650) on the
16665    //    `SupervisorError` envelope's `{ caixa: String }` one-slot axis.
16666
16667    #[test]
16668    fn duplicate_nome_ctor_matches_struct_literal_wrap() {
16669        assert_eq!(
16670            DepError::duplicate_nome("caixa-teia", crate::render::DEP_AUTHOR_KEY_DEPS),
16671            DepError::DuplicateNome {
16672                nome: "caixa-teia".to_string(),
16673                list: crate::render::DEP_AUTHOR_KEY_DEPS,
16674            },
16675            "generated duplicate_nome ctor must produce byte-equal \
16676             `DepError::DuplicateNome` to the pre-lift struct-literal \
16677             wrap on the same scalar fixtures",
16678        );
16679    }
16680
16681    #[test]
16682    fn dep_is_self_ctor_matches_struct_literal_wrap() {
16683        assert_eq!(
16684            DepError::dep_is_self("orquestra", crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
16685            DepError::DepIsSelf {
16686                nome: "orquestra".to_string(),
16687                list: crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
16688            },
16689            "generated dep_is_self ctor must produce byte-equal \
16690             `DepError::DepIsSelf` to the pre-lift struct-literal \
16691             wrap on the same scalar fixtures",
16692        );
16693    }
16694
16695    #[test]
16696    fn dep_nome_list_ctors_route_nome_and_list_through_uniformly() {
16697        // Cross-axis routing pin: sweep the two constructor input axes
16698        // (`nome: &str`, `list: &'static str`) through non-default
16699        // fixtures against every generated arm in the
16700        // [`dep_nome_list_ctors!`] macro, so any wrapper-side
16701        // lowercase / trim / truncate at codegen time — or a silent
16702        // field re-name away from the canonical `nome` / `list` axes
16703        // on any one variant, or a `list` axis silently rerouted
16704        // through `.to_string()` instead of passed as `&'static str`
16705        // verbatim — surfaces here rather than at a downstream
16706        // diagnostic-shape mismatch. Peer of the sibling
16707        // `dep_nome_only_ctors_route_nome_through_to_string` pin
16708        // (792aa92) on the same envelope's one-slot family, and of the
16709        // peer
16710        // `supervisor_child_reason_ctors_route_reason_through_into_uniformly`
16711        // pin (d2ef2ec) on the sibling `SupervisorError` envelope's
16712        // two-slot `{ caixa: String, reason: String }` shape.
16713        let nome = "sibling-teia";
16714        let cases: [(DepError, DepError); 4] = [
16715            (
16716                DepError::duplicate_nome(nome, crate::render::DEP_AUTHOR_KEY_DEPS),
16717                DepError::DuplicateNome {
16718                    nome: nome.to_string(),
16719                    list: crate::render::DEP_AUTHOR_KEY_DEPS,
16720                },
16721            ),
16722            (
16723                DepError::duplicate_nome(nome, crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
16724                DepError::DuplicateNome {
16725                    nome: nome.to_string(),
16726                    list: crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
16727                },
16728            ),
16729            (
16730                DepError::dep_is_self(nome, crate::render::DEP_AUTHOR_KEY_DEPS),
16731                DepError::DepIsSelf {
16732                    nome: nome.to_string(),
16733                    list: crate::render::DEP_AUTHOR_KEY_DEPS,
16734                },
16735            ),
16736            (
16737                DepError::dep_is_self(nome, crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
16738                DepError::DepIsSelf {
16739                    nome: nome.to_string(),
16740                    list: crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
16741                },
16742            ),
16743        ];
16744        for (via_ctor, via_struct_literal) in cases {
16745            assert_eq!(
16746                via_ctor, via_struct_literal,
16747                "dep_nome_list_ctors!-generated ctor must route `nome` \
16748                 through `.to_string()` onto the canonical `nome` field \
16749                 and pass `list` verbatim onto the canonical `&'static str` \
16750                 `list` field — a field-rename, silent-conversion, or \
16751                 axis-swap regression surfaces here rather than at a \
16752                 downstream diagnostic-shape mismatch",
16753            );
16754        }
16755    }
16756
16757    // ── `fonte_pin_shape` — the paired `{ nome: String, pin: String,
16758    //    value: String, reason: String }` four-slot envelope on
16759    //    `DepError`, sibling of the peer `dep_nome_only_ctors!` (792aa92),
16760    //    `dep_nome_list_ctors!` (6f5e0cd), `fonte_caminho_ctors!` (f85f145),
16761    //    and `fonte_caminho_byte_ctors!` (0e35793) folds on the same
16762    //    envelope, and of the peer `contrato_pair_value_reason_ctors!`
16763    //    (14e13f1) four-slot fold on the sibling `AplicacaoError`
16764    //    envelope. Single-variant lift closing the last open-coded ctor
16765    //    site on the `:fonte (:tipo git …)` value-shape trajectory.
16766
16767    #[test]
16768    fn fonte_pin_shape_ctor_matches_struct_literal_wrap() {
16769        // Pre-lift equivalence pin on the [`DepError::fonte_pin_shape`]
16770        // ctor: sweep both wire-up-shape arms (the refname-pin arm
16771        // routing `":tag"` / `":branch"` value through
16772        // [`crate::render::is_git_ref_name`], and the hex-OID-pin arm
16773        // routing `":rev"` through [`crate::render::is_git_oid`]) and
16774        // assert byte-equal `PartialEq` against the pre-lift
16775        // struct-literal, so any wrapper-side field-rename /
16776        // silent-conversion regression surfaces here rather than at a
16777        // downstream diagnostic-shape mismatch. Peer of the sibling
16778        // per-envelope byte-equal ctor pins
16779        // ([`fonte_pin_missing_ctor_matches_struct_literal_wrap`],
16780        // [`duplicate_nome_ctor_matches_struct_literal_wrap`],
16781        // [`dep_is_self_ctor_matches_struct_literal_wrap`]).
16782        assert_eq!(
16783            DepError::fonte_pin_shape(
16784                "caixa-teia",
16785                ":tag",
16786                "v0.1.0 ",
16787                "trailing whitespace".to_string(),
16788            ),
16789            DepError::FontePinShape {
16790                nome: "caixa-teia".to_string(),
16791                pin: ":tag".to_string(),
16792                value: "v0.1.0 ".to_string(),
16793                reason: "trailing whitespace".to_string(),
16794            },
16795            "fonte_pin_shape ctor must produce byte-equal \
16796             `DepError::FontePinShape` to the pre-lift struct-literal \
16797             wrap on a refname-pin (`:tag` / `:branch`) fixture",
16798        );
16799        assert_eq!(
16800            DepError::fonte_pin_shape(
16801                "caixa-teia",
16802                ":rev",
16803                "DEADBEEF",
16804                "abbreviated OID rejected".to_string(),
16805            ),
16806            DepError::FontePinShape {
16807                nome: "caixa-teia".to_string(),
16808                pin: ":rev".to_string(),
16809                value: "DEADBEEF".to_string(),
16810                reason: "abbreviated OID rejected".to_string(),
16811            },
16812            "fonte_pin_shape ctor must produce byte-equal \
16813             `DepError::FontePinShape` to the pre-lift struct-literal \
16814             wrap on a hex-OID-pin (`:rev`) fixture",
16815        );
16816    }
16817
16818    #[test]
16819    fn fonte_pin_shape_ctor_routes_all_four_axes_through_to_string() {
16820        // Cross-axis routing pin: sweep every one of the four
16821        // constructor input axes (`nome: &str`, `pin: &str`,
16822        // `value: &str`, `reason: String`) through non-default
16823        // fixtures against the [`DepError::fonte_pin_shape`] ctor, so
16824        // any wrapper-side lowercase / trim / truncate at codegen time
16825        // — or a silent field re-name / axis-swap on any one of the
16826        // four fields, or a `reason` axis silently routed through
16827        // `.to_string()` instead of forwarded owned — surfaces here
16828        // rather than at a downstream diagnostic-shape mismatch. Peer
16829        // of the sibling
16830        // `dep_nome_only_ctors_route_nome_through_to_string` pin
16831        // (792aa92) and
16832        // `dep_nome_list_ctors_route_nome_and_list_through_uniformly`
16833        // pin (6f5e0cd) on the same envelope's one- and two-slot
16834        // families. Distinct-per-axis fixtures rule out any two-axis
16835        // swap (`nome` ↔ `pin`, `pin` ↔ `value`, `value` ↔ `reason`,
16836        // etc.) that would still pass a same-fixture-per-axis pin.
16837        let nome = "sibling-teia";
16838        let pin = ":branch";
16839        let value = "feature/bar";
16840        let reason = "embedded space".to_string();
16841        let via_ctor = DepError::fonte_pin_shape(nome, pin, value, reason.clone());
16842        let via_struct_literal = DepError::FontePinShape {
16843            nome: nome.to_string(),
16844            pin: pin.to_string(),
16845            value: value.to_string(),
16846            reason: reason.clone(),
16847        };
16848        assert_eq!(
16849            via_ctor, via_struct_literal,
16850            "fonte_pin_shape ctor must route `nome` / `pin` / `value` \
16851             through `.to_string()` onto their canonical fields and \
16852             forward `reason` owned onto the canonical `reason` field \
16853             — a field-rename, silent-conversion, or axis-swap \
16854             regression surfaces here rather than at a downstream \
16855             diagnostic-shape mismatch",
16856        );
16857        let DepError::FontePinShape {
16858            nome: n,
16859            pin: p,
16860            value: v,
16861            reason: r,
16862        } = via_ctor
16863        else {
16864            panic!("fonte_pin_shape ctor produced non-FontePinShape variant")
16865        };
16866        assert_eq!(n, nome);
16867        assert_eq!(p, pin);
16868        assert_eq!(v, value);
16869        assert_eq!(r, reason);
16870    }
16871
16872    // ── `fonte_caminho_byte_ctors!` — the paired `{ nome: String,
16873    //    caminho: String, byte: u8 }` three-slot envelope on `DepError`,
16874    //    strict sibling of the peer `fonte_caminho_ctors!` (f85f145) on
16875    //    the same envelope's `{ nome: String, caminho: String }` two-slot
16876    //    shape, and of the peer `dep_nome_only_ctors!` (792aa92) on the
16877    //    same envelope's `{ nome: String }` one-slot shape.
16878
16879    #[test]
16880    fn fonte_caminho_control_char_ctor_matches_struct_literal_wrap() {
16881        assert_eq!(
16882            DepError::fonte_caminho_control_char("caixa-teia", "../caixa-teia\x00foo", 0x00),
16883            DepError::FonteCaminhoControlChar {
16884                nome: "caixa-teia".to_string(),
16885                caminho: "../caixa-teia\x00foo".to_string(),
16886                byte: 0x00,
16887            },
16888        );
16889    }
16890
16891    #[test]
16892    fn fonte_caminho_shell_redirection_ctor_matches_struct_literal_wrap() {
16893        assert_eq!(
16894            DepError::fonte_caminho_shell_redirection("caixa-teia", "../caixa-teia>log", b'>'),
16895            DepError::FonteCaminhoShellRedirection {
16896                nome: "caixa-teia".to_string(),
16897                caminho: "../caixa-teia>log".to_string(),
16898                byte: b'>',
16899            },
16900        );
16901    }
16902
16903    #[test]
16904    #[allow(
16905        clippy::too_many_lines,
16906        reason = "cross-axis routing pin sweeps twelve typed variants, one per \
16907                  byte-classification arm on the {nome,caminho,byte} envelope; \
16908                  the linear per-variant repetition is exactly what the sweep \
16909                  is pinning — a helper macro would hide the shape the fold is \
16910                  keying on"
16911    )]
16912    fn fonte_caminho_byte_ctors_route_nome_caminho_and_byte_through_to_string() {
16913        // Cross-axis routing pin: sweep the three constructor input axes
16914        // (`nome: &str`, `caminho: &str`, `byte: u8`) through a
16915        // non-default fixture triple against every generated arm in the
16916        // [`fonte_caminho_byte_ctors!`] macro, so any wrapper-side
16917        // lowercase / trim / truncate on the two `&str` axes — a silent
16918        // field swap between `nome` and `caminho`, or a silent
16919        // re-classification of the offending byte — surfaces here rather
16920        // than at a downstream diagnostic-shape mismatch. Peer of the
16921        // sibling `fonte_caminho_ctors_route_nome_and_caminho_through_
16922        // to_string` cross-axis routing pin on the same envelope's
16923        // two-slot family (f85f145) and of the sibling
16924        // `dep_nome_only_ctors_route_nome_through_to_string` pin on the
16925        // same envelope's one-slot family (792aa92), extended here onto
16926        // the `{ nome: String, caminho: String, byte: u8 }` three-slot
16927        // envelope so every substrate-primitive ctor family in
16928        // caixa-core's `DepError` envelope guarantees each field routes
16929        // the caller's value verbatim through `.to_string()` (or byte-
16930        // identity for `byte: u8`) in declared field order.
16931        let nome = "sibling-teia";
16932        let caminho = "../workspace/sibling";
16933        let byte = 0x2A_u8;
16934        let cases: [(DepError, DepError); 12] = [
16935            (
16936                DepError::fonte_caminho_control_char(nome, caminho, byte),
16937                DepError::FonteCaminhoControlChar {
16938                    nome: nome.to_string(),
16939                    caminho: caminho.to_string(),
16940                    byte,
16941                },
16942            ),
16943            (
16944                DepError::fonte_caminho_shell_redirection(nome, caminho, byte),
16945                DepError::FonteCaminhoShellRedirection {
16946                    nome: nome.to_string(),
16947                    caminho: caminho.to_string(),
16948                    byte,
16949                },
16950            ),
16951            (
16952                DepError::fonte_caminho_shell_glob(nome, caminho, byte),
16953                DepError::FonteCaminhoShellGlob {
16954                    nome: nome.to_string(),
16955                    caminho: caminho.to_string(),
16956                    byte,
16957                },
16958            ),
16959            (
16960                DepError::fonte_caminho_shell_subshell_grouping(nome, caminho, byte),
16961                DepError::FonteCaminhoShellSubshellGrouping {
16962                    nome: nome.to_string(),
16963                    caminho: caminho.to_string(),
16964                    byte,
16965                },
16966            ),
16967            (
16968                DepError::fonte_caminho_shell_brace_expansion(nome, caminho, byte),
16969                DepError::FonteCaminhoShellBraceExpansion {
16970                    nome: nome.to_string(),
16971                    caminho: caminho.to_string(),
16972                    byte,
16973                },
16974            ),
16975            (
16976                DepError::fonte_caminho_shell_bracket_expansion(nome, caminho, byte),
16977                DepError::FonteCaminhoShellBracketExpansion {
16978                    nome: nome.to_string(),
16979                    caminho: caminho.to_string(),
16980                    byte,
16981                },
16982            ),
16983            (
16984                DepError::fonte_caminho_shell_quote_grouping(nome, caminho, byte),
16985                DepError::FonteCaminhoShellQuoteGrouping {
16986                    nome: nome.to_string(),
16987                    caminho: caminho.to_string(),
16988                    byte,
16989                },
16990            ),
16991            (
16992                DepError::fonte_caminho_shell_comment(nome, caminho, byte),
16993                DepError::FonteCaminhoShellComment {
16994                    nome: nome.to_string(),
16995                    caminho: caminho.to_string(),
16996                    byte,
16997                },
16998            ),
16999            (
17000                DepError::fonte_caminho_url_percent_encoding(nome, caminho, byte),
17001                DepError::FonteCaminhoUrlPercentEncoding {
17002                    nome: nome.to_string(),
17003                    caminho: caminho.to_string(),
17004                    byte,
17005                },
17006            ),
17007            (
17008                DepError::fonte_caminho_shell_variable_expansion(nome, caminho, byte),
17009                DepError::FonteCaminhoShellVariableExpansion {
17010                    nome: nome.to_string(),
17011                    caminho: caminho.to_string(),
17012                    byte,
17013                },
17014            ),
17015            (
17016                DepError::fonte_caminho_shell_history_expansion(nome, caminho, byte),
17017                DepError::FonteCaminhoShellHistoryExpansion {
17018                    nome: nome.to_string(),
17019                    caminho: caminho.to_string(),
17020                    byte,
17021                },
17022            ),
17023            (
17024                DepError::fonte_caminho_shell_history_substitution(nome, caminho, byte),
17025                DepError::FonteCaminhoShellHistorySubstitution {
17026                    nome: nome.to_string(),
17027                    caminho: caminho.to_string(),
17028                    byte,
17029                },
17030            ),
17031        ];
17032        for (via_ctor, via_struct_literal) in cases {
17033            assert_eq!(
17034                via_ctor, via_struct_literal,
17035                "fonte_caminho_byte_ctors!-generated ctor must route \
17036                 (nome, caminho, byte) through `.to_string()` / byte-\
17037                 identity in declared field order — a field-swap or \
17038                 silent-conversion regression surfaces here rather than \
17039                 at a downstream diagnostic-shape mismatch",
17040            );
17041        }
17042    }
17043}
17044
17045#[cfg(test)]
17046mod dep_source_is_variant_tests {
17047    use super::*;
17048
17049    fn all_variants() -> Vec<(DepSource, &'static str)> {
17050        vec![
17051            (
17052                DepSource::Git {
17053                    repo: "github:pleme-io/caixa-teia".into(),
17054                    tag: Some("v0.1.0".into()),
17055                    rev: None,
17056                    branch: None,
17057                },
17058                "Git",
17059            ),
17060            (
17061                DepSource::Path {
17062                    caminho: "../caixa-teia".into(),
17063                },
17064                "Path",
17065            ),
17066        ]
17067    }
17068
17069    fn predicate_row(s: &DepSource) -> [bool; 2] {
17070        [s.is_git(), s.is_path()]
17071    }
17072
17073    // Fail-before-pass-after pin on the [`gen_platform::IsVariant`]
17074    // derive-generated per-arm predicate partition — for every variant
17075    // in `all_variants()`, the observed 2-slot predicate row must equal
17076    // a one-hot row with the `true` at exactly the same index as the
17077    // variant's declaration order. Expected rows are generated live
17078    // from the enumeration rather than transcribed by hand, so a
17079    // copy-paste flip that reroutes one arm through the wrong predicate
17080    // lane trips at the identity-diagonal assertion the way every peer
17081    // sibling [`DepList`] / [`crate::CaixaKind`] / [`crate::CaixaDialeto`]
17082    // / [`crate::supervisor::RestartStrategy`] / [`crate::supervisor::RestartPolicy`]
17083    // / [`crate::upgrade::UpgradeInstruction`] /
17084    // [`crate::aplicacao::PlacementStrategy`] /
17085    // [`crate::aplicacao::RateLimitUnit`] /
17086    // [`crate::aplicacao::WitTarget`] /
17087    // [`crate::render::PathShapeViolation`] partition pin already does.
17088    #[test]
17089    fn dep_source_is_variant_predicates_partition_the_arm_set() {
17090        let variants = all_variants();
17091        for (idx, (variant, name)) in variants.iter().enumerate() {
17092            let observed = predicate_row(variant);
17093            let mut expected = [false; 2];
17094            expected[idx] = true;
17095            assert_eq!(
17096                observed, expected,
17097                "DepSource::{name} at declaration-order slot {idx} must \
17098                 satisfy exactly one is_* predicate (its own); observed \
17099                 row must equal the one-hot expected row — a drift \
17100                 would silently reroute one `:fonte`-arm consumer \
17101                 through the wrong predicate lane"
17102            );
17103        }
17104    }
17105
17106    // Byte-parity pin on the two field-agnostic `matches!` shapes the
17107    // per-arm arm-discriminator predicates replace at any future
17108    // consumer site (a `:fonte`-shape-only lint rule that flags path
17109    // deps outside dev-caixas via `dep.fonte().is_some_and(DepSource::is_path)`,
17110    // a future admission-webhook that rejects `:fonte` shapes outside
17111    // the `is_git()` accept-set, a caixa-lacre indexing pass that
17112    // dispatches on `s.is_git()` without extracting `repo` / `caminho`).
17113    // Refuses a future accidental split between the derived predicate
17114    // and its `matches!` shape — a hand-rolled shadow impl that
17115    // overrides one path, an accidental rebrand that leaves one
17116    // consumer on the raw `matches!` form — on the two load-bearing
17117    // `:fonte`-arm-discriminator axes every downstream substrate
17118    // consumer of the dep-source axis keys off.
17119    #[test]
17120    fn dep_source_is_git_and_is_path_byte_equal_matches_shape() {
17121        for (variant, name) in all_variants() {
17122            let via_matches_git = matches!(variant, DepSource::Git { .. });
17123            let via_predicate_git = variant.is_git();
17124            assert_eq!(
17125                via_predicate_git, via_matches_git,
17126                "DepSource::{name}.is_git() must byte-equal \
17127                 matches!(_, DepSource::Git {{ .. }}) — otherwise a \
17128                 future converged consumer site would silently \
17129                 disagree with its pre-lift shape"
17130            );
17131            let via_matches_path = matches!(variant, DepSource::Path { .. });
17132            let via_predicate_path = variant.is_path();
17133            assert_eq!(
17134                via_predicate_path, via_matches_path,
17135                "DepSource::{name}.is_path() must byte-equal \
17136                 matches!(_, DepSource::Path {{ .. }}) — otherwise a \
17137                 future converged consumer site would silently \
17138                 disagree with its pre-lift shape"
17139            );
17140        }
17141    }
17142
17143    // Cross-pin against every constructor path that materializes a
17144    // [`DepSource`] shape today (the [`DepSource::default_github`]
17145    // resolver-side fallback that materializes an unpinned
17146    // `github:<org>/<nome>` git shorthand, the [`Dep::git`] author-
17147    // surface constructor that materializes a pinned `:tag`-carrying
17148    // `DepSource::Git`, a hand-rolled `DepSource::Path` the dev-mode
17149    // fixture family builds inline). Every constructor's return must
17150    // satisfy the arm-discriminator predicate the constructor's
17151    // variant name matches — a future constructor addition (an
17152    // in-tree registry-fetch pin, a `DepSource::Feira` variant the
17153    // enclosing docstring already names as a trajectory item) surfaces
17154    // as a build-time failure that names the offending drift when its
17155    // return arm doesn't route through the paired predicate.
17156    #[test]
17157    fn dep_source_constructors_route_through_paired_is_variant_predicate() {
17158        let via_default_github = DepSource::default_github("pleme-io", "caixa-teia");
17159        assert!(
17160            via_default_github.is_git(),
17161            "DepSource::default_github must materialize a Git-arm shape — \
17162             a future constructor that routed through a non-Git arm \
17163             (a registry-fetch pin, a `DepSource::Feira` promotion) \
17164             would silently split the resolver's unpinned-shorthand \
17165             materializer from the sole_pin() precedence cascade"
17166        );
17167        assert!(
17168            !via_default_github.is_path(),
17169            "DepSource::default_github must NOT materialize a Path-arm \
17170             shape — the paired negation pin"
17171        );
17172
17173        let via_dep_git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0")
17174            .fonte
17175            .expect("Dep::git materializes a Some(fonte)");
17176        assert!(
17177            via_dep_git.is_git(),
17178            "Dep::git's `:fonte` materialization must land on the Git \
17179             arm — the author-surface pinned-git constructor's return \
17180             must route through the paired predicate"
17181        );
17182        assert!(!via_dep_git.is_path(), "paired negation pin");
17183
17184        let via_path = DepSource::Path {
17185            caminho: "../caixa-teia".into(),
17186        };
17187        assert!(
17188            via_path.is_path(),
17189            "the dev-mode Path-arm materialization must satisfy is_path()"
17190        );
17191        assert!(!via_path.is_git(), "paired negation pin");
17192    }
17193}