Skip to main content

caixa_core/
dep.rs

1use serde::{Deserialize, Serialize};
2use thiserror::Error;
3
4/// A single dependency declaration in a `caixa.lisp` manifest.
5///
6/// **Store model = Git, like Zig.** There is no central registry; a caixa is
7/// just a Git repo with a `caixa.lisp` at its root. When `:fonte` is omitted,
8/// the resolver falls back to `github:<default-org>/<nome>` (org defaults to
9/// `pleme-io`, override via `~/.config/caixa/config.yaml`).
10///
11/// ```lisp
12/// ;; Shorthand — resolves to github:pleme-io/caixa-teia (or your default org):
13/// (:nome "caixa-teia" :versao "^0.1")
14///
15/// ;; Explicit git source:
16/// (:nome "caixa-teia"
17///  :versao "^0.1"
18///  :fonte (:tipo git :repo "github:pleme-io/caixa-teia" :tag "v0.1.0"))
19///
20/// ;; Arbitrary git URL (not limited to GitHub):
21/// (:nome "private-caixa"
22///  :versao "*"
23///  :fonte (:tipo git :repo "ssh://git@git.example/team/priv-caixa.git" :branch "main"))
24///
25/// ;; Local path (dev only; not publishable):
26/// (:nome "caixa-teia"
27///  :versao "0.1.0"
28///  :fonte (:tipo path :caminho "../caixa-teia"))
29/// ```
30#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
31#[serde(rename_all = "camelCase")]
32pub struct Dep {
33    /// Caixa name — must match the target caixa's `:nome`.
34    pub nome: String,
35
36    /// Semver constraint string (`"^0.1"`, `"~0.1.2"`, `"0.1.0"`, `"*"`).
37    pub versao: String,
38
39    /// Where to fetch the caixa from. Defaults to the feira registry.
40    #[serde(default, skip_serializing_if = "Option::is_none")]
41    pub fonte: Option<DepSource>,
42
43    /// If true, a missing `:fonte` is not a build failure.
44    #[serde(default, skip_serializing_if = "is_false")]
45    pub opcional: bool,
46
47    /// Feature flags to enable on the target caixa.
48    #[serde(default, skip_serializing_if = "Vec::is_empty")]
49    pub caracteristicas: Vec<String>,
50}
51
52/// Where a dep is fetched from. Tagged via `:tipo` in Lisp.
53///
54/// Only two shapes — Git and local Path. No central registry variant: a caixa
55/// is just a Git repo. Omitting `:fonte` means *"use the default resolver
56/// convention"*, which is `github:<default-org>/<nome>`; the resolver fills
57/// that in when computing the lacre.
58///
59/// The [`gen_platform::IsVariant`] derive emits per-arm arm-discriminator
60/// predicates — [`Self::is_git`], [`Self::is_path`] — so every downstream
61/// consumer that only needs the arm-discriminator projection (not the
62/// borrowed field value) reaches for one typed dispatch on the substrate
63/// primitive rather than a hand-rolled `matches!(s, DepSource::X { .. })`
64/// literal. Extends the closed-set-typed-enum discipline the sibling
65/// caixa-core enums ([`crate::CaixaKind`], [`crate::CaixaDialeto`],
66/// [`crate::supervisor::RestartStrategy`], [`crate::supervisor::RestartPolicy`],
67/// [`crate::upgrade::UpgradeInstruction`], [`crate::aplicacao::PlacementStrategy`],
68/// [`crate::aplicacao::RateLimitUnit`], [`crate::aplicacao::WitTarget`],
69/// [`crate::render::PathShapeViolation`], [`DepList`]) and the sibling
70/// out-of-crate enums (caixa-arch's `InvariantKind` + `ArchVerdict`,
71/// caixa-lint's `Severity` + `FixSafety`, caixa-provedor's
72/// `FerriteRuntime`, caixa-theme's `Semantic`, caixa-flux's `GitRefSpec`,
73/// caixa-ast's `NodeKind` + `TriviaKind`) already carry onto the
74/// two-arm `:fonte` dep-source axis — the 17th closed-set typed enum
75/// on the caixa surface, and the first on the outer-`Dep` `:fonte`-slot
76/// axis every git-fetching consumer runs after the outer `:fonte` slot
77/// resolves to a shape.
78#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, gen_platform::IsVariant)]
79#[serde(tag = "tipo", rename_all = "lowercase")]
80pub enum DepSource {
81    /// Clone from Git. One of `:tag`, `:rev`, or `:branch` may be set.
82    /// `repo` can be a `github:org/repo` shorthand, a full `https://…` URL,
83    /// or any git-ssh URL.
84    Git {
85        repo: String,
86        #[serde(default, skip_serializing_if = "Option::is_none")]
87        tag: Option<String>,
88        #[serde(default, skip_serializing_if = "Option::is_none")]
89        rev: Option<String>,
90        #[serde(default, skip_serializing_if = "Option::is_none")]
91        branch: Option<String>,
92    },
93    /// Local filesystem path — dev only; cannot be published.
94    Path { caminho: String },
95}
96
97impl DepSource {
98    /// Build a registry-shorthand git source (`github:<org>/<nome>`).
99    ///
100    /// This is the resolver-side fallback for `dep.fonte: None`, not an
101    /// author-surface value — it carries no pin (`:tag`/`:rev`/`:branch`
102    /// all `None`) and is therefore rejected by [`Self::validate`]. The
103    /// resolver fills the pin in at fetch time from the resolved commit;
104    /// authors never serialize this shape as a `Dep::fonte` value.
105    #[must_use]
106    pub fn default_github(org: &str, nome: &str) -> Self {
107        Self::Git {
108            repo: format!("github:{org}/{nome}"),
109            tag: None,
110            rev: None,
111            branch: None,
112        }
113    }
114
115    /// Substrate-canonical per-`:fonte` sole-set git-pin scalar accessor
116    /// every consumer that reads "which single git ref does this source
117    /// resolve to?" keys off — returns the author-declared `:tag` /
118    /// `:rev` / `:branch` byte-string verbatim as an `Option<&str>`,
119    /// borrowed from the typed slot's own `Option<String>` storage; `None`
120    /// on [`Self::Path`] (a path source carries no git-ref) and on a
121    /// [`Self::Git`] variant whose `tag`, `rev`, and `branch` are all
122    /// `None` (the [`Self::default_github`] shorthand shape the resolver
123    /// materializes when the author omits `:fonte` — rejected by
124    /// [`Self::validate`], but the accessor's return is defined on this
125    /// arm too so pre-validate consumers reach for the same typed dispatch
126    /// as post-validate ones).
127    ///
128    /// **Precedence: rev > tag > branch.** The canonical precedence every
129    /// per-`:fonte` git-ref consumer already applies: caixa-resolver's
130    /// per-fetch `git checkout <ref>` reads through the same
131    /// `rev.or(tag).or(branch)` cascade at caixa-resolver/src/resolve.rs,
132    /// and caixa-crd's `dep_into_ref` `CaixaSource.git_ref` fill reads
133    /// through the same cascade at caixa-crd/src/conversion.rs. The
134    /// [`Self::validate`] gate enforces "exactly one pin set" — under
135    /// that invariant every accepted [`Self::Git`] carries exactly one
136    /// non-`None` pin and the precedence is unobservable, but the
137    /// precedence remains defined for pre-validate consumers (the
138    /// resolver's `MissingPin` diagnostic path, the caixa-crd
139    /// round-trip's default `"main"` fallback the author never sees a
140    /// diagnostic on) and defense-in-depth for a hypothetical future
141    /// state where multiple pins survive the gate. The precedence is
142    /// **rev before tag** because `:rev` (a git commit OID) is the
143    /// reproducibility-strongest identifier — an OID resolves to exactly
144    /// one commit regardless of which refname points at it, whereas
145    /// `:tag` and `:branch` are refnames the remote can silently move
146    /// (a tag re-push, a branch head advance); the resolver's freeze
147    /// step at fetch time promotes the resolved commit to `:rev` for
148    /// exactly this reason. **Tag before branch** because `:tag` is
149    /// conventionally immutable (a release tag) whereas `:branch` is
150    /// conventionally mutable (a tracking ref) — a caixa carrying both
151    /// a release tag and a tracking branch reads as "prefer the release
152    /// pin, fall through to the tracking pin only if the release is
153    /// missing". The cascade order also matches the byte-order every
154    /// per-`:tag`/`:rev`/`:branch` diagnostic tuple this crate emits
155    /// (`(":tag", tag), (":rev", rev), (":branch", branch)` — see
156    /// [`Self::validate`]'s `pins` array).
157    ///
158    /// Prior to this lift the "sole set pin" projection sat twice in the
159    /// workspace — inline at caixa-resolver's `fetch_git` (`let gitref =
160    /// rev.or(tag).or(branch).ok_or_else(|| ResolveError::MissingPin
161    /// { … })?;`) and at caixa-crd's `dep_into_ref`
162    /// (`git_ref: rev.clone().or(tag.clone()).or(branch.clone())
163    /// .unwrap_or_else(|| "main".to_string())`) — two open-coded copies
164    /// of the same precedence cascade with no compile-time link back to
165    /// the typed slot. A future extension of the pin axis to a richer
166    /// author surface (a `:commit` pin peer of `:rev` once the substrate
167    /// grows a signed-commit-verification pin, a `:ref` pin the M4
168    /// substrate operator resolves per-cluster ahead of fetch, a
169    /// promotion of the plain `Option<String>` pins to a typed
170    /// `GitPin::{Rev(Oid), Tag(RefName), Branch(RefName)}` newtype
171    /// once the sibling [`crate::render::is_git_oid`] /
172    /// [`crate::render::is_git_ref_name`] gates land as typed
173    /// constructors) would have had to be threaded through both
174    /// open-coded copies in lockstep or the resolver's `git checkout`
175    /// target would silently disagree with the CRD's `git_ref` fill —
176    /// an author's `(:fonte (:tipo git :repo "…" :rev "deadbeef" :tag
177    /// "v1"))` would ship with the resolver checking out `deadbeef`
178    /// while the CRD round-trip re-emitted a Dep pointing at `v1`, one
179    /// lacre closure disagreeing with the emitted K8s CR the operator
180    /// reads. Lifting the resolution to a typed method on the substrate
181    /// primitive means both downstream consumers reach for exactly one
182    /// typed dispatch — the resolver's accept-set migrates as a unit on
183    /// any future pin-axis addition.
184    ///
185    /// Peer of the sibling outer-`Dep` [`Dep::fonte`] (d65d1bf)
186    /// `Option<&DepSource>` composite-reference accessor on the outer-
187    /// `Dep` `:fonte`-slot axis — extended one nesting level down onto
188    /// the per-[`Self::Git`]-variant sole-set-pin projection axis every
189    /// git-fetching consumer runs after the outer `:fonte` slot resolves
190    /// to a [`Self::Git`] shape. Same "one typed dispatch on the
191    /// substrate primitive, thin projections at each consumer" discipline
192    /// the outer accessor family already carries.
193    #[must_use]
194    pub fn sole_pin(&self) -> Option<&str> {
195        match self {
196            Self::Git {
197                tag, rev, branch, ..
198            } => rev.as_deref().or(tag.as_deref()).or(branch.as_deref()),
199            Self::Path { .. } => None,
200        }
201    }
202
203    /// Validate the `:fonte` value-shape: every author-surface
204    /// `:fonte (:tipo git …)` must carry a non-empty `:repo` and
205    /// exactly one of `:tag` / `:rev` / `:branch` set to a non-empty
206    /// value; every `:fonte (:tipo path …)` must carry a non-empty
207    /// `:caminho`.
208    ///
209    /// Called from [`Dep::validate`] with the dep's `:nome` so every
210    /// diagnostic carries the offending entry verbatim — same
211    /// self-locating shape the `:deps :versao` (2420c44),
212    /// `:membros :versao` (9888b13), `:children :versao` (b38ff3a),
213    /// `:placement :clusters` (6cbb900), and `:membros :caixa`
214    /// (3f9d7a0) gates already expose.
215    ///
216    /// Until this gate landed `:fonte` was the only `:deps`-related
217    /// typed surface still untyped past `Caixa::from_lisp`:
218    /// - Empty `:repo` (`(:tipo git :repo "" :tag "v1")`) silently
219    ///   passed parse and surfaced as a git-clone failure at
220    ///   lacre-resolve time, far from the source caixa.lisp.
221    /// - A bare `(:tipo git :repo "…")` with no `:tag`/`:rev`/`:branch`
222    ///   passed parse and surfaced as the resolver's
223    ///   [`ResolveError::MissingPin`](../../caixa-resolver/src/resolve.rs)
224    ///   at fetch time, again far from the source caixa.lisp; lifting
225    ///   to validate-time gives the author the same diagnostic at the
226    ///   edit site.
227    /// - `(:tipo git :repo "…" :tag "v1" :branch "main")` — multiple
228    ///   pins set — passed parse and the resolver silently picked
229    ///   `:rev > :tag > :branch`, ignoring the other pins with no
230    ///   diagnostic; the author had no way to know their `:branch`
231    ///   was dropped. This is the canonical "pin drift" footgun.
232    /// - An empty pin value (`(:tipo git :repo "…" :tag "")`) silently
233    ///   passed parse and surfaced as `git checkout ""` at fetch time.
234    /// - Empty `:caminho` (`(:tipo path :caminho "")`) silently passed
235    ///   parse and surfaced as
236    ///   [`ResolveError::MissingPath`](../../caixa-resolver/src/resolve.rs)
237    ///   with `path: PathBuf("")` — not actionable.
238    ///
239    /// Each rejected shape maps to a typed
240    /// [`DepError::Fonte*`] variant that names the offending
241    /// dep's `:nome` and the specific axis, so the author can grep
242    /// their caixa.lisp for the `:nome "<nome>"` block and fix it in
243    /// one edit.
244    pub fn validate(&self, nome: &str) -> Result<(), DepError> {
245        match self {
246            Self::Git {
247                repo,
248                tag,
249                rev,
250                branch,
251            } => {
252                if repo.is_empty() {
253                    return Err(DepError::fonte_repo_empty(nome));
254                }
255                // The `:repo` value flows verbatim into the caixa-resolver's
256                // `git clone <repo>` subprocess invocation. Until this gate
257                // landed `:repo` was the last untyped `:fonte`-related axis
258                // past the empty arm: a malformed-but-non-empty repo URL
259                // (`":repo "github:p/x ""` trailing space, paste-from-doc;
260                // `":repo "-upload-pack=evil""` leading `-` — the canonical
261                // CLI-argument-injection vector at the `git clone` boundary;
262                // `":repo "pleme-io/caixa-teia""` missing scheme — `git clone`
263                // reads as a relative filesystem path rather than the
264                // GitHub-shorthand expansion; `":repo "github:p/x\n""`
265                // embedded newline; `":repo "github:café/x""` raw non-ASCII)
266                // silently passed validate and the failure surfaced at
267                // lacre-resolve time with a porcelain-quoting-confused error
268                // far from the source caixa.lisp. The lifted predicate makes
269                // the git-porcelain-URL intersection-floor a substrate-level
270                // invariant at validate time, peer with the three pin axes
271                // (`:tag` + `:branch` via [`crate::render::is_git_ref_name`],
272                // e70d213; `:rev` via [`crate::render::is_git_oid`], be07fd5)
273                // — every `:fonte (:tipo git …)` past validate is now
274                // structurally accept-shaped on every axis the resolver
275                // consumes (the `:repo` URL the `git clone` invokes against,
276                // the `:tag`/`:branch` refname `git fetch`/`git checkout`
277                // accepts, the `:rev` commit OID the lacre's content-
278                // addressing equality probe resolves), closing the
279                // `:fonte` slot's value-shape trajectory end-to-end.
280                if let Err(reason) = crate::render::is_git_repo_url(repo) {
281                    return Err(DepError::fonte_repo_shape(nome, repo, reason));
282                }
283                let pins: [(&'static str, Option<&String>); 3] = [
284                    (":tag", tag.as_ref()),
285                    (":rev", rev.as_ref()),
286                    (":branch", branch.as_ref()),
287                ];
288                let set: Vec<&'static str> =
289                    pins.iter().filter_map(|(n, v)| v.map(|_| *n)).collect();
290                match set.len() {
291                    0 => {
292                        return Err(DepError::fonte_pin_missing(nome));
293                    }
294                    1 => {
295                        for (pin, value) in pins {
296                            if value.is_some_and(String::is_empty) {
297                                return Err(DepError::fonte_pin_empty(nome, pin));
298                            }
299                        }
300                    }
301                    _ => {
302                        return Err(DepError::fonte_pin_ambiguous(nome, &set.join(", ")));
303                    }
304                }
305                // Per-pin value-shape gate. The refname-shaped axes
306                // (`:tag` + `:branch`) route through
307                // [`crate::render::is_git_ref_name`]; the hex-OID-shaped
308                // `:rev` axis routes through
309                // [`crate::render::is_git_oid`]. The two predicates
310                // partition the `:fonte` pin axes structurally — refname
311                // vs. hex commit — so a cross-axis mis-slot (the
312                // canonical "I conflated `:rev` and `:branch`" footgun:
313                // `:rev "main"` defeating the reproducibility contract,
314                // `:tag "deadbeef…"` mis-slotting a SHA into the
315                // refname-shaped axis) lands at the offending axis's
316                // predicate, not at lacre-resolve `git fetch` /
317                // `git checkout` time. Their valid sets intersect at
318                // the empty set: every refname is rejected by
319                // `is_git_oid`, every OID is rejected by
320                // `is_git_ref_name`, structurally.
321                //
322                // Until this gate landed `:tag` / `:branch` were the
323                // refname-shaped axes still untyped past the empty-pin
324                // arm: a malformed-but-non-empty refname
325                // (`:tag "v0.1.0 "` trailing space — the canonical
326                // paste-from-doc footgun; `:tag "v0.1.0.lock"` colliding
327                // with git's atomic-rename guard suffix; `:tag "../escape"`
328                // path-traversal via consecutive dots; `:branch "main "`
329                // trailing space; `:branch "feature/foo bar"` embedded
330                // space; `:branch "@"` the literal HEAD alias;
331                // `:branch "refs/heads/main"` the fully-qualified ref
332                // copied from `git show-ref` output that resolves to
333                // a literal ref named `refs/heads/refs/heads/main` on
334                // disk) silently passed validate; the `:rev` axis was
335                // the last `:fonte`-related axis still untyped past the
336                // empty-pin arm: a malformed-but-non-empty hex-OID
337                // (`:rev "main"` conflating with `:branch` — the
338                // reproducibility-contract leak; `:rev "v0.1.0"`
339                // conflating with `:tag` — the same mis-slot on the
340                // refname/OID boundary; `:rev "c0ffee"` an abbreviated
341                // 6-char prefix that's ambiguous across repo history;
342                // `:rev "DEADBEEF…"` an uppercase OID that round-trips
343                // inconsistently against `git rev-parse HEAD`'s
344                // lowercase emission) silently passed validate and the
345                // failure surfaced at lacre-resolve `git fetch` /
346                // `git checkout` time with a quoting-confused error
347                // far from the source caixa.lisp, with no field naming
348                // which `:deps` entry carried the typo. Lifting both
349                // gates to caixa-build time matches the value-shape
350                // trajectory the peer typed axes already follow
351                // (c4213a4 typed WitContract endpoint/subject/slot;
352                // eb3456d :entrada :paths; c7d05ec :entrada :host;
353                // 4f0390b :contratos :endpoint; 6226bf4 :contratos :wit;
354                // 63e18a0 :contratos :subject; 2f4316e :contratos
355                // :slot; e70d213 :fonte :tag + :branch) — the typed
356                // slot's valid set matches its downstream consumer's
357                // accepted set (here, the git porcelain's refname /
358                // commit-OID grammars at `git fetch` / `git checkout`
359                // time), structurally. Same diagnostic shape every
360                // per-axis value-shape lift already exposes
361                // (`*Invalid { axis, reason }`); the `value:` field
362                // carries the offending refname / OID verbatim so the
363                // author can grep their caixa.lisp for the
364                // `:tag "<value>"` / `:branch "<value>"` /
365                // `:rev "<value>"` literal and fix it in one edit.
366                for (pin, value) in [(":tag", tag.as_ref()), (":branch", branch.as_ref())] {
367                    if let Some(v) = value
368                        && let Err(reason) = crate::render::is_git_ref_name(v)
369                    {
370                        return Err(DepError::fonte_pin_shape(nome, pin, v, reason));
371                    }
372                }
373                if let Some(v) = rev.as_ref()
374                    && let Err(reason) = crate::render::is_git_oid(v)
375                {
376                    return Err(DepError::fonte_pin_shape(nome, ":rev", v, reason));
377                }
378                Ok(())
379            }
380            Self::Path { caminho } => Self::validate_caminho(nome, caminho),
381        }
382    }
383
384    /// Reproducibility + path-API gate on the `:fonte (:tipo path …)`
385    /// `:caminho` axis. Walks the leading-byte cascade closed by the
386    /// b94fd83 (`/`), a5c248e (`~`), and f4efe9c (`$`) arms; the
387    /// orthogonal embedded-control-byte arm (d624c8d) covering
388    /// `0x00..=0x1F` plus `0x7F` anywhere in the value; and the
389    /// embedded-`\` Windows-path-separator arm closing the
390    /// cross-host-OS-separator divergence vector on the same
391    /// THEORY.md §V.2 render-determinism axis.
392    ///
393    /// Extracted from [`Self::validate`]'s `Self::Path` arm because the
394    /// per-arm cascade now spans nine diagnostic shapes — every new
395    /// `:caminho` arm (a future `&` / `;` / `|` shell-metachar arm,
396    /// a future glob-metachar `*` / `?` arm) lands here rather than
397    /// re-inflating `Self::validate`. The
398    /// function stays a thin per-arm linear walk for one reason: each
399    /// arm's diagnostic carries a distinct typed [`DepError`] variant
400    /// rather than a parser-shaped `reason` string, so collapsing the
401    /// cascade onto a generic [`crate::render`] predicate would regress
402    /// the per-arm self-locating diagnostic that `feira lint` consumers
403    /// depend on. The wrapped predicate trajectory ([`crate::render::is_dns_1123_label`],
404    /// [`crate::render::is_git_repo_url`], etc.) lives on the
405    /// reason-string-shaped axes; the `:caminho` axis keeps its
406    /// per-arm variant shape.
407    #[allow(
408        clippy::too_many_lines,
409        reason = "the per-arm cascade is structurally flat by design — every \
410                  `:caminho` arm carries its own typed [`DepError`] variant + \
411                  per-arm Why comment, so collapsing the cascade onto a generic \
412                  [`crate::render`] predicate would regress the per-arm self-locating \
413                  diagnostic the `feira lint` consumer surface depends on"
414    )]
415    fn validate_caminho(nome: &str, caminho: &str) -> Result<(), DepError> {
416        if caminho.is_empty() {
417            return Err(DepError::fonte_caminho_empty(nome));
418        }
419        // Reproducibility gate on the `:fonte (:tipo path …)`
420        // `:caminho` axis. The lacre pipeline embeds the value
421        // verbatim in its per-dep content-address
422        // (`conteudo: format!("path:{caminho}")`,
423        // caixa-resolver/src/resolve.rs:189) and that string
424        // folds into the BLAKE3 closure the lacre keys every
425        // downstream consumer (the substrate's reproducibility
426        // contract, CAIXA-SDLC §III.2 — the lacre is the
427        // build's content-addressed identity, peer of the Nix
428        // store path) against. Until this gate landed an
429        // absolute `:caminho` (`/home/me/work/caixa-teia` — the
430        // canonical "I dragged the folder out of Finder into
431        // my editor" footgun; `/Users/alice/dev/caixa-teia` on
432        // the macOS path-layout peer; the
433        // `${WORKSPACE}/caixa-teia` shell-expanded literal
434        // pasted from a CI manifest) silently passed validate
435        // and the failure surfaced *as a successful build with
436        // a divergent lacre*: the BLAKE3 closure on Alice's
437        // workstation differed from the closure on Bob's
438        // workstation, two CI runners with different
439        // `${HOME}` layouts emitted two distinct
440        // content-addresses for the byte-identical caixa, and
441        // the substrate's "the lacre is the build's identity"
442        // contract silently broke far from the source
443        // caixa.lisp — the most insidious failure mode the
444        // typed slot can carry (no error surfaces; the
445        // divergence is invisible until two machines compare
446        // lacres). The same THEORY.md §V.2 render-determinism
447        // discipline `is_sandboxed_relative_path` already
448        // applies on the M2 typed path-slots
449        // (`:behavior :on-*`, `:upgrade-from :state-change
450        // :script`, `:bibliotecas`, `:exe`, `:servicos`), here
451        // narrowed to the absolute-vs-relative axis only:
452        // `:fonte :caminho`'s canonical author-surface form is
453        // the `..`-traversing sibling-workspace path
454        // (`"../caixa-teia"`, the in-tree dev-dep frame), so a
455        // full `is_sandboxed_relative_path` lift would
456        // structurally reject every legitimate path-fonte
457        // dep. The narrower
458        // `std::path::Path::is_absolute` cut admits the
459        // sibling-workspace form while still rejecting the
460        // host-layout-leaking absolute shape — the
461        // reproducibility contract bites at exactly the
462        // absolute boundary, and that's the axis the
463        // substrate-level invariant is meant to hold. Same
464        // diagnostic shape every per-axis value-shape lift on
465        // the surrounding [`DepError::Fonte*`] cluster carries
466        // (the offending `:nome` + offending `:caminho`
467        // quoted verbatim so the author can grep their
468        // caixa.lisp for the `:caminho "<value>"` literal and
469        // fix it in one edit). The empty arm strictly
470        // precedes this arm so the blank-string footgun
471        // surfaces the more self-locating
472        // `FonteCaminhoEmpty` diagnostic (the empty string
473        // is not absolute under `Path::new("").is_absolute()`
474        // so the precedence is a no-op at value level — the
475        // pin matters only at the diagnostic-shape level if
476        // a future codec round-trip ever produces an empty
477        // string that probes as absolute).
478        if std::path::Path::new(caminho).is_absolute() {
479            return Err(DepError::fonte_caminho_absolute(nome, caminho));
480        }
481        // Reproducibility gate's tilde-expansion arm. The b94fd83
482        // `FonteCaminhoAbsolute` closes the leading-`/`
483        // host-layout-leak; a `:caminho "~/work/caixa-teia"` (the
484        // canonical paste-from-shell-prompt / paste-from-`cd ~`-
485        // doc footgun) silently passed both the empty arm and
486        // the absolute arm because `Path::new("~").is_absolute()`
487        // returns `false` — `~` is a shell-expansion convention,
488        // not a POSIX path component, so `std::path::Path` treats
489        // it as a literal directory-name segment. The lacre
490        // pipeline then embedded the value verbatim
491        // (`conteudo: format!("path:~/work/caixa-teia")`) and the
492        // failure mode forked per consumer:
493        //
494        //   - The caixa-resolver's `Path` arm folds `:caminho`
495        //     through `Path::new(caminho).join(<file>)` without
496        //     `~`-expansion, so the build looked for a literal
497        //     `./~/work/caixa-teia` subdirectory and failed at
498        //     resolve time with a `No such file or directory`
499        //     error far from the source caixa.lisp (the lacre
500        //     itself, though, was already byte-identical across
501        //     machines — every machine emitted the same
502        //     `path:~/work/caixa-teia` content-address).
503        //   - A future caixa-resolver pass that *does* expand `~`
504        //     (the canonical shell-convention idiom every
505        //     resolver eventually reaches for once an author
506        //     reports the literal-`~`-directory bug) would re-
507        //     introduce the host-layout-leak the b94fd83 absolute
508        //     gate closes: Alice's `~` expands to `/home/alice`,
509        //     Bob's to `/home/bob`, two CI runners with different
510        //     `$HOME` layouts resolve to two distinct paths for
511        //     the byte-identical caixa, and the substrate's
512        //     "the lacre is the build's identity" contract
513        //     silently breaks far from the source caixa.lisp.
514        //
515        // Closing the gate at `DepSource::validate` (here at the
516        // canonical caixa-build-time boundary, peer with the
517        // absolute arm above) refuses both failure modes
518        // structurally: the typed accepted set excludes every
519        // `~`-prefixed authoring shape, so the resolver is
520        // free to grow `~`-expansion (or any other convention-
521        // expansion the substrate adopts) without re-opening
522        // the host-layout-leak at the typed boundary. Same
523        // diagnostic shape every per-axis value-shape gate on
524        // the surrounding [`DepError::Fonte*`] cluster carries
525        // (the offending `:nome` + offending `:caminho` quoted
526        // verbatim so the author can grep their caixa.lisp for
527        // the `:caminho "<value>"` literal and fix it in one
528        // edit).
529        //
530        // The cascade preserves narrower-diagnostic-first
531        // ordering: `FonteCaminhoEmpty` → `FonteCaminhoAbsolute`
532        // → `FonteCaminhoTildeExpansion`. The empty arm
533        // structurally precedes both (the bytes "" / "~" don't
534        // overlap), and the absolute arm structurally precedes
535        // the tilde arm (an absolute path can't start with `~`
536        // since absolute paths start with `/`; the bytes "/" /
537        // "~" don't overlap either). Both arms are
538        // value-disjoint, so the precedence is a no-op at value
539        // level — the pin matters only at the diagnostic-shape
540        // level if a future codec round-trip ever produces a
541        // value that probes as both absolute and tilde-prefixed.
542        if caminho.starts_with('~') {
543            return Err(DepError::fonte_caminho_tilde_expansion(nome, caminho));
544        }
545        // Reproducibility gate's shell-variable-expansion arm.
546        // The b94fd83 `FonteCaminhoAbsolute` closes the leading-`/`
547        // host-layout-leak; the a5c248e `FonteCaminhoTildeExpansion`
548        // closes the leading-`~` shell-home-expansion shape; the
549        // leading-`$` is the sibling shell-variable-expansion shape
550        // — same host-layout-leaking semantic, different syntactic
551        // surface. A `:caminho "$HOME/work/caixa-teia"` (the
552        // canonical paste-from-`echo $HOME`-doc footgun) and the
553        // `${VAR}`-braced variant (`"${WORKSPACE}/caixa-teia"` —
554        // the canonical paste-from-CI-manifest footgun every
555        // GitHub Actions / GitLab CI / Drone manifest carries)
556        // silently passed every prior arm because
557        // `Path::is_absolute` returns false on `$` (the `$` is a
558        // shell convention, not a POSIX path component, so
559        // `std::path::Path` treats it as a literal directory-name
560        // segment) and the tilde arm's `starts_with('~')` doesn't
561        // fire.
562        //
563        // Same per-consumer failure-fork the tilde arm closes:
564        //
565        //   - The caixa-resolver's `Path` arm folds `:caminho`
566        //     through `Path::new(caminho).join(<file>)` without
567        //     `$`-expansion, so the build looks for a literal
568        //     `./$HOME/work/caixa-teia` subdirectory and fails at
569        //     resolve time with a `No such file or directory`
570        //     error far from the source caixa.lisp.
571        //   - A future caixa-resolver pass that *does* expand
572        //     `$VAR` (the shell-convention idiom every resolver
573        //     eventually reaches for once an author reports the
574        //     literal-`$HOME`-directory bug, especially for CI's
575        //     `${WORKSPACE}` idiom) would re-introduce the host-
576        //     layout-leak the b94fd83 absolute gate closes:
577        //     Alice's `$HOME` expands to `/home/alice`, Bob's to
578        //     `/home/bob`, two CI runners with different
579        //     `${WORKSPACE}` layouts resolve to two distinct
580        //     paths for the byte-identical caixa, and the
581        //     substrate's "the lacre is the build's identity"
582        //     contract silently breaks far from the source
583        //     caixa.lisp.
584        //
585        // Closing the gate at `DepSource::validate` (here at the
586        // canonical caixa-build-time boundary, peer with the
587        // absolute + tilde arms above) refuses both failure modes
588        // structurally. Same diagnostic shape every per-axis
589        // value-shape gate on the surrounding [`DepError::Fonte*`]
590        // cluster carries (the offending `:nome` + offending
591        // `:caminho` quoted verbatim).
592        //
593        // The cascade preserves narrower-diagnostic-first ordering:
594        // `FonteCaminhoEmpty` → `FonteCaminhoAbsolute` →
595        // `FonteCaminhoTildeExpansion` → `FonteCaminhoVarExpansion`.
596        // The empty arm structurally precedes all three subsequent
597        // arms; the absolute arm structurally precedes both the
598        // tilde and the var arms (absolute paths start with `/`,
599        // the bytes `/` / `~` / `$` don't overlap at the leading
600        // position); the tilde arm structurally precedes the var
601        // arm (`~` and `$` don't overlap at the leading position).
602        // Every pair is value-disjoint, so the precedence is a
603        // no-op at value level — the pin matters only at the
604        // diagnostic-shape level if a future codec round-trip ever
605        // produces a probe-as-both value.
606        //
607        // The gate covers every leading-`$` shape: the canonical
608        // `"$HOME/work/caixa-teia"` (POSIX shell), the braced
609        // `"${HOME}/work/caixa-teia"` (POSIX shell braces), the
610        // CI-manifest idiom `"${WORKSPACE}/caixa-teia"` (the
611        // GitHub Actions / GitLab CI / Drone paste footgun), the
612        // XDG idiom `"$XDG_CONFIG_HOME/caixa"`, and the bare `$`
613        // (degenerate "I meant `$HOME` and forgot the rest"). All
614        // shapes route through the same `caminho.starts_with('$')`
615        // byte check.
616        if caminho.starts_with('$') {
617            return Err(DepError::fonte_caminho_var_expansion(nome, caminho));
618        }
619        // Reproducibility gate's leading-space arm. The b94fd83 / a5c248e /
620        // f4efe9c arms closed the leading-byte host-layout-leak shapes
621        // (`/` / `~` / `$`); the embedded-control-byte arm below closes
622        // every byte in `0x00..=0x1F` plus `0x7F` (which already includes
623        // tab `0x09`, LF `0x0A`, CR `0x0D` — every ASCII whitespace
624        // *except* the ASCII space byte `0x20`). The bare ASCII space at
625        // the leading position is the orthogonal paste-from-aligned-doc
626        // shape that silently passed every prior arm: `Path::is_absolute`
627        // returns false on `" ../caixa-teia"` (the leading byte is `0x20`
628        // not `0x2F`), `0x20` is not `~` / `$` / `\` / a control byte, and
629        // the value's last byte is not `/`, so the canonical
630        // paste-from-aligned-`caixa.lisp`-doc footgun (every `:fonte`
631        // form in a multi-entry `:deps` block sits at the same column —
632        // an author selecting `"<sp><sp><sp>../caixa-teia"` and pasting
633        // it from the rendered alignment into a fresh entry preserves the
634        // leading whitespace verbatim) silently rendered as a path with
635        // a leading-space directory component the resolver folds through
636        // `Path::join` looking for a literal `./ ../caixa-teia`
637        // subdirectory that fails at resolve time with a non-self-
638        // locating `No such file or directory` error.
639        //
640        // The lacre pipeline's reproducibility contract bites
641        // strictly at this byte: `path:" ../caixa-teia"` and
642        // `path:"../caixa-teia"` yield distinct BLAKE3 closures
643        // (`conteudo: format!("path:{caminho}")`,
644        // caixa-resolver/src/resolve.rs:189) for the byte-divergent /
645        // semantic-identical caixa, and the substrate's "the lacre is
646        // the build's identity" contract (CAIXA-SDLC §III.2) silently
647        // breaks across two workstations whose authors differ only in
648        // paste-from-aligned-doc whitespace habits — the most insidious
649        // failure mode the typed slot can carry (no error surfaces; the
650        // divergence is invisible until two machines compare lacres).
651        //
652        // The arm fires AFTER the absolute / tilde / var leading-byte
653        // arms (each names the more self-locating shell-convention
654        // diagnostic on values that probe as that arm's leading-byte
655        // sentinel followed by a leading space — e.g.
656        // `:caminho "/  /foo"` surfaces `FonteCaminhoAbsolute` because
657        // the leading byte is `/`, not space) and BEFORE the
658        // embedded-control-byte arm (a leading-space value with an
659        // embedded control byte surfaces the broader leading-space
660        // diagnostic because the cascade walks leading-byte arms first
661        // — peer with how `FonteCaminhoAbsolute` precedes
662        // `FonteCaminhoControlChar` on `"/etc/passwd\n"`).
663        //
664        // The peer single-token-shaped axes already reject leading
665        // whitespace on the same paste-from-aligned-doc contract:
666        // [`crate::render::is_git_repo_url`] rejects leading whitespace
667        // on `:fonte :repo`, [`crate::render::is_git_ref_name`] rejects
668        // leading whitespace on `:fonte :tag`/`:branch`,
669        // [`crate::render::is_chart_description_shape`] rejects leading
670        // whitespace on `:descricao`,
671        // [`crate::render::is_spdx_expression_shape`] rejects leading
672        // whitespace on `:licenca`. Closing the same byte on
673        // `:fonte :caminho` makes the substrate-wide "no leading ASCII
674        // space anywhere in a typed string slot" invariant structurally
675        // consistent across every value-shape-gated typed surface (the
676        // `:caminho` axis was the last typed string surface still
677        // admitting a leading space byte).
678        if caminho.starts_with(' ') {
679            return Err(DepError::fonte_caminho_leading_whitespace(nome, caminho));
680        }
681        // Reproducibility gate's leading-`-` CLI-argument-injection arm.
682        // The b94fd83 + a5c248e + f4efe9c + LeadingWhitespace arms closed
683        // the four prior leading-byte shapes (`/` / `~` / `$` / space);
684        // this arm closes the orthogonal leading-`-` axis on the same
685        // subprocess-argument-boundary the peer `is_git_repo_url` arm
686        // (render.rs:2037, `-upload-pack=…` on `:fonte :repo`) and
687        // `is_git_ref_name` arm (render.rs:1381, 5a28454, `-stable` on
688        // `:fonte :tag` / `:branch`) already reject.
689        //
690        // The lacre pipeline embeds `:caminho` verbatim in its per-dep
691        // content-address (`conteudo: format!("path:{caminho}")`,
692        // caixa-resolver/src/resolve.rs:189) and the resolver folds the
693        // value through `Path::join` looking for a literal `./{caminho}`
694        // subdirectory. Every downstream subprocess that consumes the
695        // resolved path — a `git -C {caminho} <verb>` invocation, a
696        // future `feira tofu` `terraform -chdir={caminho}` shell-out, a
697        // future operator-side `nix build --path {caminho}` spawn, an
698        // `xargs` / `find {caminho}` / `stat {caminho}` /
699        // `rm -rf {caminho}` cleanup — reinterprets a leading-`-` value
700        // as a CLI flag rather than a positional path when the
701        // subprocess invocation does not carry a `--` argument-list
702        // terminator between the flag block and the path argument. The
703        // canonical footguns:
704        //
705        //   - `:caminho "-rf"` — bare short-flag paste (`rm -rf` /
706        //     `find -rf` reinterpretation; the byte the peer
707        //     `FonteCaminhoShellSemicolon` arm's `; rm -rf build`
708        //     example paste-idiom carries as its first token).
709        //   - `:caminho "-C"` — `git -C` config-injection paste
710        //     (`git -C -C` reinterprets the second `-C` as another
711        //     `--change-directory` flag rather than the path
712        //     argument; the canonical `git -C <path>` porcelain
713        //     idiom every multi-repo workspace tool carries).
714        //   - `:caminho "--upload-pack=cat /etc/passwd"` — the
715        //     canonical long-flag CLI-arg-injection vector at every
716        //     git porcelain entry point (`git clone`, `git fetch`,
717        //     `git ls-remote`) that consumes a path or URL
718        //     argument; peer with `is_git_repo_url`'s leading-`-`
719        //     arm (render.rs:2037) on the sibling `:fonte :repo`
720        //     axis, which the arm's diagnostic explicitly cites.
721        //   - `:caminho "--config=…"` / `:caminho "-c"` — git-config
722        //     override paste-idiom (paste-from-`git -c foo=bar`
723        //     shell-history footgun that reinterprets the value as
724        //     a `[foo] bar` config injection on every git porcelain
725        //     entry point).
726        //
727        // POSIX `std::path::Path` treats a leading `-` as a literal
728        // filename byte, so the resolver folds `-rf` through `Path::join`
729        // and looks for a literal `./-rf` subdirectory — the failure
730        // surfaces at resolve time with a non-self-locating `No such
731        // file or directory` error far from the source caixa.lisp, and
732        // the value rides through the lacre content-address into every
733        // downstream shell-spawned subprocess. On any consumer that
734        // shells out without the `--` terminator (the common case at
735        // every porcelain entry-point) the reinterpretation is silent
736        // and the failure mode is arbitrary-argument-injection.
737        //
738        // The arm fires AFTER the absolute / tilde / var / leading-space
739        // leading-byte arms (each names the more self-locating shell-
740        // convention diagnostic on values that probe as that arm's
741        // leading-byte sentinel — the byte sets are pairwise disjoint at
742        // the leading position, so the precedence pin is a no-op at
743        // value level, but the ordering keeps every leading-byte arm's
744        // diagnostic-shape stable) and BEFORE the embedded-control-byte
745        // arm (a leading-`-` value with an embedded control byte
746        // surfaces the narrower leading-`-` diagnostic because the
747        // cascade walks leading-byte arms first — peer with how
748        // `FonteCaminhoAbsolute` precedes `FonteCaminhoControlChar` on
749        // `"/etc/passwd\n"`, and how `FonteCaminhoLeadingWhitespace`
750        // precedes `FonteCaminhoControlChar` on `" ../foo\n"`).
751        //
752        // The peer single-token-shaped axes already reject leading `-`
753        // on the same CLI-arg-injection contract:
754        // [`crate::render::is_git_repo_url`] rejects it on `:fonte :repo`
755        // (render.rs:2037), [`crate::render::is_git_ref_name`] rejects
756        // it on `:fonte :tag` / `:fonte :branch` (render.rs:1381,
757        // 5a28454), [`crate::render::is_dns_1123_label`] rejects it on
758        // every DNS-1123-shaped axis (top-level Caixa `:nome`, `:membros
759        // :caixa`, `:children :caixa`, `:deps :nome`, cluster names),
760        // [`crate::render::is_cargo_feature_name`] rejects it on
761        // `:caracteristicas`, and the feira `init` / `add <nome>`
762        // positional gate (868c191) rejects it on the CLI positional
763        // itself. Closing the same byte on `:fonte :caminho` makes the
764        // substrate-wide "no leading `-` anywhere in a typed single-
765        // token string slot routed through a subprocess argument"
766        // invariant structurally consistent across every value-shape-
767        // gated typed surface (the `:caminho` axis was the last typed
768        // string surface still admitting a leading `-` byte).
769        if caminho.starts_with('-') {
770            return Err(DepError::fonte_caminho_leading_hyphen(nome, caminho));
771        }
772        // Reproducibility gate's embedded-control-byte arm. The
773        // b94fd83 + a5c248e + f4efe9c arms closed the three
774        // leading-byte host-layout-leak shapes (`/` / `~` / `$`);
775        // this arm closes the orthogonal embedded-control-byte
776        // axis — any ASCII control byte (`0x00..=0x1F` plus
777        // `0x7F` DEL) appearing anywhere in `:caminho`. Same
778        // shape every peer single-token-typed-slot value-shape
779        // predicate the surrounding [`crate::render`] cluster
780        // gates against (the lifted `is_git_repo_url` arm on
781        // `:fonte :repo`, the `is_git_ref_name` arm on
782        // `:tag`/`:branch`, the `is_chart_description_shape` /
783        // `is_chart_maintainer_name_shape` /
784        // `is_chart_keyword_shape` arms on the
785        // Helm-chart-shaped axes); now consistent on the
786        // `:caminho` axis too.
787        //
788        // Until this gate landed any embedded control byte
789        // silently passed validate, the lacre pipeline embedded
790        // the value verbatim in its per-dep content-address
791        // (`conteudo: format!("path:{caminho}")`,
792        // caixa-resolver/src/resolve.rs:189), and the failure
793        // forked per byte and per consumer:
794        //
795        //   - NUL (`0x00`) the canonical "POSIX paths cannot
796        //     contain a NUL byte" shape: every `std::fs` syscall
797        //     routes the path through `CString::new`, which
798        //     fails with `NulError` on the first NUL byte; the
799        //     build would surface a `NulError` at resolve time
800        //     far from the source caixa.lisp.
801        //   - LF (`0x0A`) / CR (`0x0D`) the canonical paste-from-
802        //     multiline-doc footgun: a `:caminho
803        //     "../caixa-teia\nrm -rf /"` value (paste landed mid-
804        //     `:caminho` block from a multi-line code-fence)
805        //     silently round-trips through `Path::join` but the
806        //     embedded newline class is a sibling of the CRLF-at-
807        //     subprocess-argument injection vector
808        //     `is_git_repo_url` already closes on `:repo`.
809        //   - Tab (`0x09`) the canonical paste-from-aligned-table
810        //     footgun: the tab is invisible in most editors, and
811        //     the lacre embeds the value verbatim so two
812        //     paste-from-distinct-tables yield divergent lacres
813        //     across host editors that strip vs preserve tabs.
814        //   - DEL (`0x7F`) + every other `0x00..=0x1F` byte: the
815        //     paste-from-binary-blob shape every peer single-
816        //     token-shaped slot rejects under the same
817        //     `b < 0x20 || b == 0x7F` predicate.
818        //
819        // Mirrors the cascade discipline every prior `:caminho`
820        // arm establishes: `FonteCaminhoEmpty` →
821        // `FonteCaminhoAbsolute` → `FonteCaminhoTildeExpansion`
822        // → `FonteCaminhoVarExpansion` →
823        // `FonteCaminhoLeadingWhitespace` →
824        // `FonteCaminhoLeadingHyphen` → `FonteCaminhoControlChar`.
825        // The six leading-byte arms structurally precede the
826        // embedded-byte arm because the leading-byte shapes are
827        // the more self-locating diagnostic on values that probe
828        // as both (e.g. `:caminho "/etc/passwd\n"` surfaces the
829        // narrower `FonteCaminhoAbsolute` rather than the broader
830        // embedded-control-byte arm); the precedence pin matters
831        // at the diagnostic-shape level even though the empty /
832        // absolute / tilde / var arms are value-disjoint from a
833        // bare control byte (which would itself be a leading
834        // byte under the empty / absolute / tilde / var arms'
835        // leading-position semantics, but those arms guard the
836        // specific shell-convention characters `/` / `~` / `$`
837        // — a leading `0x01` byte falls through to this arm).
838        for &b in caminho.as_bytes() {
839            if b < 0x20 || b == 0x7F {
840                return Err(DepError::fonte_caminho_control_char(nome, caminho, b));
841            }
842        }
843        // Reproducibility gate's Windows-path-separator arm. The four
844        // leading-byte arms (`/` / `~` / `$`) and the embedded-
845        // control-byte arm close the host-layout-leaking + paste-from-
846        // multiline-doc shapes; the leading-`\` / embedded-`\` byte is
847        // the orthogonal cross-host-OS-separator shape — same render-
848        // determinism axis, different semantic mechanism. POSIX
849        // [`std::path::Path`] treats `\` (0x5C) as a literal byte
850        // inside a single path component (so `..\caixa-teia` is one
851        // directory named literally `..\caixa-teia`, sibling of `.`
852        // and `..`); Windows [`std::path::Path`] treats `\` as a
853        // primary path separator equal to `/` (so `..\caixa-teia` is
854        // the parent's sibling directory `caixa-teia`). The lacre
855        // pipeline embeds the value verbatim in its per-dep content-
856        // address (`conteudo: format!("path:{caminho}")`, caixa-
857        // resolver/src/resolve.rs:189), so byte-identical caixa.lisp
858        // values resolve to two distinct directories across runner
859        // OSes — the same THEORY.md §V.2 render-determinism contract
860        // the absolute / tilde / var arms protect, here against the
861        // cross-host-OS-separator divergence vector. Even on POSIX-
862        // only resolvers (the canonical pleme-io substrate posture),
863        // a `..\caixa-teia` (the Windows-Explorer "copy as path" /
864        // PowerShell `Get-Location` paste-idiom footgun) silently
865        // passes every prior arm because `Path::is_absolute` returns
866        // false on `..` and `\` is neither a leading-byte sentinel
867        // nor a control byte, then the resolver folds the value
868        // through `Path::new(caminho).join(<file>)` looking for a
869        // literal `./..\caixa-teia` subdirectory and fails at
870        // resolve time with a non-self-locating `No such file or
871        // directory` error far from the source caixa.lisp.
872        //
873        // The peer single-token-shaped axes on the same git-CLI /
874        // path-CLI consumer cluster already reject `\` under the same
875        // Windows-path-leak banner: [`crate::render::is_git_ref_name`]
876        // line 1441 (`"must not contain \\ … the canonical Windows-
877        // path-leak footgun; use / for hierarchical refs"`) gates
878        // `:fonte :tag` / `:fonte :branch` against the same byte,
879        // and [`crate::render::is_gateway_api_http_path`] line 506
880        // includes `\` in the eleven-byte RFC-3986-reserved rejection
881        // set on `:entrada :paths`. Closing the same byte on `:fonte
882        // :caminho` makes the substrate-wide "no Windows path
883        // separator anywhere in a typed string slot" invariant
884        // structurally consistent across every path-shaped typed
885        // surface (the `:caminho` axis was the last typed string
886        // surface still admitting `\`).
887        //
888        // The arm fires AFTER the control-char arm because the
889        // control-char diagnostic is the more self-locating axis on
890        // values that probe as both (`"..\caixa\0teia"` carries both
891        // a `\` and a NUL — NUL is the load-bearing POSIX-syscall-
892        // rejected byte, so `FonteCaminhoControlChar` wins). Same
893        // narrower-diagnostic-first cascade discipline every prior
894        // arm establishes. A pure-`\` value
895        // (`"..\caixa-teia"` with no control bytes) falls through
896        // every prior arm and lands here.
897        for &b in caminho.as_bytes() {
898            if b == b'\\' {
899                return Err(DepError::fonte_caminho_backslash(nome, caminho));
900            }
901        }
902        // Reproducibility gate's shell-redirection arm. The 3a4e1d7 backslash
903        // arm closes the cross-host-OS-separator vector; `<` (`0x3C`) and `>`
904        // (`0x3E`) are the orthogonal shell-redirection sentinels — same
905        // paste-from-shell-prompt footgun class, different syntactic surface.
906        // POSIX `std::path::Path` treats `<` / `>` as literal bytes inside a
907        // single path component (so `../caixa-teia>output` is one directory
908        // named literally `../caixa-teia>output`, sibling of `.` and `..`),
909        // but every interactive shell (bash / zsh / fish / nushell) lexes
910        // `<` / `>` as input / output redirection operators — a `:caminho
911        // "../caixa-teia>build.log"` (the canonical "I pasted a shell
912        // pipeline that wrote build output and forgot to trim the redirect"
913        // footgun) or `:caminho "../<input.lisp"` (the symmetric input-
914        // redirection paste idiom) silently passes every prior arm because
915        // `Path::is_absolute` returns false, `<` / `>` are neither leading-
916        // byte sentinels nor control bytes nor `\`, and the value's last byte
917        // isn't `/`. The resolver folds the value through
918        // `Path::new(caminho).join(<file>)` looking for a literal
919        // `./..\caixa-teia>build.log` subdirectory and fails at resolve time
920        // with a non-self-locating `No such file or directory` error far
921        // from the source caixa.lisp.
922        //
923        // The lacre pipeline embeds the value verbatim in its per-dep
924        // content-address (`conteudo: format!("path:{caminho}")`,
925        // caixa-resolver/src/resolve.rs:189), so a `<` / `>` byte lands in
926        // the BLAKE3 closure and rides downstream as part of the build's
927        // identity. The bytes carry a second class of hazard the prior
928        // separator-shaped arms don't: every typed-string slot whose value
929        // ever flows verbatim into a shell-spawned subprocess (the caixa-
930        // resolver's `git clone` invocation, a future `feira tofu` shell-
931        // out, a future operator-side `nix flake check` spawn) is the
932        // canonical CRLF-at-subprocess-argument / shell-metachar injection
933        // surface that every peer single-token-shaped typed slot already
934        // closes. The peer path-shaped axis `[crate::render::is_gateway_api_http_path]`
935        // (caixa-core/src/render.rs:506) rejects `<` / `>` as part of its
936        // eleven-byte RFC-3986-reserved set on `:entrada :paths`, and the
937        // peer git-ref-shaped axis `[crate::render::is_git_ref_name]` rejects
938        // `<` / `>` on `:fonte :tag` / `:fonte :branch` under the same
939        // shell-metachar-injection banner. The `:caminho` axis was the last
940        // typed string surface still admitting these two bytes; this arm
941        // closes the gap so the substrate-wide "no shell-redirection
942        // metacharacter anywhere in a typed string slot" invariant is now
943        // structurally consistent across every path-shaped typed surface.
944        //
945        // The arm fires AFTER the control-char arm + backslash arm because
946        // both prior arms carry more self-locating diagnostics on values
947        // that probe as both (`"..\foo<bar"` carries both `\` and `<` — the
948        // cross-OS-separator divergence is the load-bearing axis, so the
949        // backslash arm wins; `"../foo\n<bar"` carries both LF and `<` —
950        // the POSIX-syscall-rejected byte is the load-bearing axis, so the
951        // control-char arm wins). The arm fires BEFORE the trailing-`/` arm
952        // because the embedded redirection byte is the more semantic-
953        // locating axis on probe-as-both values (`"../foo</"` ends in `/`
954        // but the load-bearing diagnostic is the embedded `<` shell-
955        // redirection — the trailing `/` is the secondary observation, and
956        // an author who removes the `<` is likely to also tab-strip the
957        // trailing separator).
958        for &b in caminho.as_bytes() {
959            if b == b'<' || b == b'>' {
960                return Err(DepError::fonte_caminho_shell_redirection(nome, caminho, b));
961            }
962        }
963        // Reproducibility gate's shell-pipe arm. The e457141 shell-redirection
964        // arm closes the `<` / `>` input/output redirection sentinels; `|`
965        // (`0x7C`) is the orthogonal shell-pipe sentinel — same paste-from-
966        // shell-prompt footgun class, different syntactic surface. POSIX
967        // `std::path::Path` treats `|` as a literal path-component byte (so
968        // `../caixa-teia|tee` is one directory named literally
969        // `../caixa-teia|tee`, sibling of `.` and `..`), but every interactive
970        // shell (bash / zsh / fish / nushell) lexes `|` as the pipe operator
971        // — a `:caminho "../caixa-teia | grep foo"` (the canonical "I copied a
972        // `ls ../caixa-teia | grep` line out of a shell-history block and
973        // forgot to trim the pipeline tail" footgun) or `:caminho
974        // "../foo||bar"` (the symmetric "I copied a `cmd-a || cmd-b` short-
975        // circuit OR line" idiom) silently passes every prior arm because
976        // `Path::is_absolute` returns false on `..`, `|` is neither a leading-
977        // byte sentinel nor a control byte nor `\` nor `<` / `>`, and the
978        // value's last byte isn't `/`. The resolver folds the value through
979        // `Path::new(caminho).join(<file>)` looking for a literal
980        // `./../caixa-teia | grep foo` subdirectory and fails at resolve time
981        // with a non-self-locating `No such file or directory` error far
982        // from the source caixa.lisp.
983        //
984        // The lacre pipeline embeds the value verbatim in its per-dep
985        // content-address (`conteudo: format!("path:{caminho}")`,
986        // caixa-resolver/src/resolve.rs:189), so a `|` byte lands in the
987        // BLAKE3 closure and rides downstream as part of the build's identity
988        // into every shell-spawned subprocess (the caixa-resolver's `git
989        // clone` invocation, a future `feira tofu` shell-out, a future
990        // operator-side `nix flake check` spawn) as the canonical CRLF-at-
991        // subprocess-argument / shell-metachar injection surface every peer
992        // single-token-shaped typed slot already closes. The peer path-shaped
993        // axis [`crate::render::is_gateway_api_http_path`]
994        // (caixa-core/src/render.rs:506) rejects `|` as part of its eleven-
995        // byte RFC-3986-reserved set on `:entrada :paths`. The `:caminho`
996        // axis was the last typed path-string surface still admitting this
997        // byte; this arm closes the gap so the substrate-wide "no shell-
998        // composition metacharacter anywhere in a typed string slot that
999        // flows verbatim into a shell-spawned subprocess" invariant extends
1000        // from shell-redirection (`<` / `>`) to shell-pipe (`|`) on the
1001        // `:caminho` axis.
1002        //
1003        // The arm fires AFTER the shell-redirection arm because the prior
1004        // arm's two-byte `byte: u8` payload is the more self-locating axis on
1005        // values that probe as both (`"../caixa-teia<input|tee"` carries both
1006        // `<` and `|` — the input-redirection-paste idiom is the load-bearing
1007        // root-cause edit, so `FonteCaminhoShellRedirection` wins; same
1008        // cascade discipline every prior `:caminho` arm establishes). The arm
1009        // fires BEFORE the trailing-`/` arm because the embedded pipe byte is
1010        // the more semantic-locating axis on probe-as-both values
1011        // (`"../foo|tee/"` ends in `/` but the load-bearing diagnostic is the
1012        // embedded `|` shell-pipe — the trailing `/` is the secondary
1013        // observation, and an author who removes the `|` is likely to also
1014        // tab-strip the trailing separator).
1015        for &b in caminho.as_bytes() {
1016            if b == b'|' {
1017                return Err(DepError::fonte_caminho_shell_pipe(nome, caminho));
1018            }
1019        }
1020        // Reproducibility gate's shell-command-separator arm. The 124106f
1021        // shell-pipe arm closes the `|` byte; `;` (`0x3B`) is the orthogonal
1022        // shell-command-separator sentinel — same paste-from-shell-prompt
1023        // footgun class, different syntactic surface. POSIX `std::path::Path`
1024        // treats `;` as a literal path-component byte (so
1025        // `../caixa-teia;rm -rf /` is one directory named literally
1026        // `../caixa-teia;rm -rf /`, sibling of `.` and `..`), but every
1027        // interactive shell (bash / zsh / fish / nushell) lexes `;` as the
1028        // sequential-command terminator that fires the next command
1029        // regardless of the prior command's exit status — a `:caminho
1030        // "../caixa-teia; rm -rf build"` (the canonical "I pasted a shell
1031        // one-liner that chained a cleanup tail after the directory name"
1032        // footgun) or `:caminho "../foo;;bar"` (the symmetric "I copied a
1033        // POSIX `case` arm's `;;` terminator into the middle of a path"
1034        // idiom) silently passes every prior arm because `Path::is_absolute`
1035        // returns false on `..`, `;` is neither a leading-byte sentinel nor a
1036        // control byte nor `\` nor `<` / `>` nor `|`, and the value's last
1037        // byte isn't `/`. The resolver folds the value through
1038        // `Path::new(caminho).join(<file>)` looking for a literal
1039        // `./../caixa-teia; rm -rf build` subdirectory and fails at resolve
1040        // time with a non-self-locating `No such file or directory` error far
1041        // from the source caixa.lisp.
1042        //
1043        // The lacre pipeline embeds the value verbatim in its per-dep
1044        // content-address (`conteudo: format!("path:{caminho}")`,
1045        // caixa-resolver/src/resolve.rs:189), so a `;` byte lands in the
1046        // BLAKE3 closure and rides downstream as part of the build's identity
1047        // into every shell-spawned subprocess (the caixa-resolver's `git
1048        // clone` invocation, a future `feira tofu` shell-out, a future
1049        // operator-side `nix flake check` spawn) as the canonical
1050        // shell-metachar injection surface every peer single-token-shaped
1051        // typed slot already closes. The peer path-shaped axis
1052        // [`crate::render::is_gateway_api_http_path`]
1053        // (caixa-core/src/render.rs:506) rejects `;` as part of its eleven-
1054        // byte RFC-3986-reserved set on `:entrada :paths`. The `:caminho`
1055        // axis was the last typed path-string surface still admitting this
1056        // byte; this arm closes the gap so the substrate-wide "no shell-
1057        // composition metacharacter anywhere in a typed string slot that
1058        // flows verbatim into a shell-spawned subprocess" invariant extends
1059        // from shell-pipe (`|`) to shell-command-separator (`;`) on the
1060        // `:caminho` axis.
1061        //
1062        // The arm fires AFTER the shell-pipe arm because the prior arm's
1063        // canonical-cmd-a-|-cmd-b shape is the more common shell-history
1064        // paste idiom on values that probe as both (`"../caixa-teia | tee;
1065        // rm"` carries both `|` and `;` — the pipeline-tail paste is the
1066        // load-bearing root-cause edit, so `FonteCaminhoShellPipe` wins; same
1067        // cascade discipline every prior `:caminho` arm establishes). The arm
1068        // fires BEFORE the trailing-`/` arm because the embedded
1069        // command-separator byte is the more semantic-locating axis on
1070        // probe-as-both values (`"../foo;rm/"` ends in `/` but the
1071        // load-bearing diagnostic is the embedded `;` shell-command-
1072        // separator — the trailing `/` is the secondary observation, and an
1073        // author who removes the `;` is likely to also tab-strip the trailing
1074        // separator).
1075        for &b in caminho.as_bytes() {
1076            if b == b';' {
1077                return Err(DepError::fonte_caminho_shell_semicolon(nome, caminho));
1078            }
1079        }
1080        // Reproducibility gate's shell-background / logical-AND arm. The
1081        // 05c358e shell-command-separator arm closes the `;` byte; `&`
1082        // (`0x26`) is the orthogonal shell-background / list-AND sentinel
1083        // — same paste-from-shell-prompt footgun class, different
1084        // syntactic surface. POSIX `std::path::Path` treats `&` as a
1085        // literal path-component byte (so `../caixa-teia & sleep 1` is
1086        // one directory named literally `../caixa-teia & sleep 1`,
1087        // sibling of `.` and `..`), but every interactive shell
1088        // (bash / zsh / fish / nushell) lexes `&` two ways:
1089        //
1090        //   - Single `&` as the background-task terminator that detaches
1091        //     the prior command into the background and returns control
1092        //     to the prompt immediately (the canonical `cmd &` idiom
1093        //     every long-running pipeline uses);
1094        //   - Double `&&` as the logical-AND list operator that fires
1095        //     the next command only if the prior command succeeded (the
1096        //     canonical `make && make install` idiom every build script
1097        //     carries).
1098        //
1099        // A `:caminho "../caixa-teia & sleep 1"` (the canonical "I
1100        // pasted a `cd path & sleep 1` background-launch into the
1101        // `:caminho` slot" footgun) or `:caminho "../caixa-teia && make"`
1102        // (the symmetric "I copied a `cd path && make` build chain"
1103        // idiom) silently passes every prior arm because
1104        // `Path::is_absolute` returns false on `..`, `&` is neither a
1105        // leading-byte sentinel nor a control byte nor `\` nor
1106        // `<` / `>` nor `|` nor `;`, and the value's last byte isn't `/`.
1107        // The resolver folds the value through
1108        // `Path::new(caminho).join(<file>)` looking for a literal
1109        // `./../caixa-teia & sleep 1` subdirectory and fails at resolve
1110        // time with a non-self-locating `No such file or directory`
1111        // error far from the source caixa.lisp.
1112        //
1113        // The lacre pipeline embeds the value verbatim in its per-dep
1114        // content-address (`conteudo: format!("path:{caminho}")`,
1115        // caixa-resolver/src/resolve.rs:189), so an `&` byte lands in
1116        // the BLAKE3 closure and rides downstream as part of the build's
1117        // identity into every shell-spawned subprocess (the
1118        // caixa-resolver's `git clone` invocation, a future `feira tofu`
1119        // shell-out, a future operator-side `nix flake check` spawn) as
1120        // the canonical shell-metachar injection surface every peer
1121        // single-token-shaped typed slot already closes. The peer
1122        // path-shaped axis [`crate::render::is_gateway_api_http_path`]
1123        // (caixa-core/src/render.rs:506) rejects `&` as part of its
1124        // eleven-byte RFC-3986-reserved set on `:entrada :paths`. The
1125        // `:caminho` axis was the last typed path-string surface still
1126        // admitting this byte; this arm closes the gap so the
1127        // substrate-wide "no shell-composition metacharacter anywhere
1128        // in a typed string slot that flows verbatim into a
1129        // shell-spawned subprocess" invariant extends from
1130        // shell-command-separator (`;`) to shell-background /
1131        // logical-AND (`&`) on the `:caminho` axis.
1132        //
1133        // The arm fires AFTER the shell-command-separator arm because
1134        // the prior arm's `cmd-a; cmd-b` shape is the more common
1135        // shell-history paste idiom on values that probe as both
1136        // (`"../caixa-teia; rm & sleep"` carries both `;` and `&` — the
1137        // command-separator-tail paste is the load-bearing root-cause
1138        // edit, so `FonteCaminhoShellSemicolon` wins; same cascade
1139        // discipline every prior `:caminho` arm establishes). The arm
1140        // fires BEFORE the trailing-`/` arm because the embedded
1141        // background / list-AND byte is the more semantic-locating axis
1142        // on probe-as-both values (`"../foo&bar/"` ends in `/` but the
1143        // load-bearing diagnostic is the embedded `&` shell-background
1144        // / logical-AND metachar — the trailing `/` is the secondary
1145        // observation, and an author who removes the `&` is likely to
1146        // also tab-strip the trailing separator).
1147        for &b in caminho.as_bytes() {
1148            if b == b'&' {
1149                return Err(DepError::fonte_caminho_shell_background(nome, caminho));
1150            }
1151        }
1152        // Reproducibility gate's shell-command-substitution arm. The
1153        // e12e4f3 shell-background / logical-AND arm closes the `&`
1154        // byte; the backtick (`0x60`) is the orthogonal POSIX legacy
1155        // command-substitution sentinel — every POSIX shell (sh /
1156        // bash / zsh / dash / ksh / fish / nushell) lexes the byte as
1157        // the canonical legacy wrapper that runs the enclosed command
1158        // and substitutes its standard-output verbatim into the
1159        // surrounding word (a `whoami` wrapped in backticks expands
1160        // to the current user's name; a `cat /etc/passwd` wrapped in
1161        // backticks expands to the file's contents — the canonical
1162        // CWE-78 shell-command-injection vector every shell-side
1163        // hardening guide enumerates first). POSIX
1164        // `std::path::Path` treats backtick as a literal path-
1165        // component byte (so `../caixa-teia/<backtick>whoami<backtick>`
1166        // is one directory named literally that, sibling of `.` and
1167        // `..`).
1168        //
1169        // A `:caminho "../caixa-teia/<backtick>whoami<backtick>"` (the
1170        // canonical "I pasted a shell one-liner carrying a backticked
1171        // `whoami` command-substitution expansion into the `:caminho`
1172        // slot" footgun) or `:caminho "<backtick>pwd<backtick>/caixa-
1173        // teia"` (the symmetric "I copied a `<backtick>pwd<backtick>/
1174        // path` working-directory expansion") silently passes every
1175        // prior arm because `Path::is_absolute` returns false on
1176        // `..`, the backtick byte is neither a leading-byte sentinel
1177        // (the f4efe9c `FonteCaminhoVarExpansion` arm catches the
1178        // modern `$()` form at leading position only; backtick is
1179        // the orthogonal legacy form) nor a control byte nor `\` nor
1180        // `<` / `>` nor `|` nor `;` nor `&`, and the value's last
1181        // byte isn't `/`. The resolver folds the value through
1182        // `Path::new(caminho).join(<file>)` looking for a literal
1183        // subdirectory whose name embeds the backticked token and
1184        // fails at resolve time with a non-self-locating `No such
1185        // file or directory` error far from the source caixa.lisp.
1186        //
1187        // The lacre pipeline embeds the value verbatim in its per-
1188        // dep content-address (`conteudo: format!("path:{caminho}")`,
1189        // caixa-resolver/src/resolve.rs:189), so a backtick byte
1190        // lands in the BLAKE3 closure and rides downstream as part
1191        // of the build's identity into every shell-spawned
1192        // subprocess (the caixa-resolver's `git clone` invocation, a
1193        // future `feira tofu` shell-out, a future operator-side
1194        // `nix flake check` spawn) as the canonical shell-metachar
1195        // injection surface every peer single-token-shaped typed
1196        // slot already closes. The peer path-shaped axis
1197        // [`crate::render::is_gateway_api_http_path`]
1198        // (caixa-core/src/render.rs:506) rejects backtick as part of
1199        // its eleven-byte RFC-3986-reserved set on `:entrada
1200        // :paths`. The `:caminho` axis was the last typed path-
1201        // string surface still admitting this byte; this arm closes
1202        // the gap so the substrate-wide "no shell-composition
1203        // metacharacter anywhere in a typed string slot that flows
1204        // verbatim into a shell-spawned subprocess" invariant
1205        // extends from shell-background / logical-AND (`&`) to
1206        // shell-command-substitution (backtick) on the `:caminho`
1207        // axis.
1208        //
1209        // The arm fires AFTER the shell-background arm because the
1210        // prior arm's `cmd & sleep` shape is the more common shell-
1211        // history paste idiom on values that probe as both (a
1212        // `"../caixa-teia & <backtick>whoami<backtick>"` carries
1213        // both `&` and a backtick — the background-launch tail is
1214        // the load-bearing root-cause edit, so
1215        // `FonteCaminhoShellBackground` wins; same cascade
1216        // discipline every prior `:caminho` arm establishes). The
1217        // arm fires BEFORE the trailing-`/` arm because the
1218        // embedded command-substitution byte is the more semantic-
1219        // locating axis on probe-as-both values (a
1220        // `"../<backtick>whoami<backtick>/"` ends in `/` but the
1221        // load-bearing diagnostic is the embedded backtick shell-
1222        // command-substitution metachar — the trailing `/` is the
1223        // secondary observation, and an author who removes the
1224        // backtick is likely to also tab-strip the trailing
1225        // separator).
1226        for &b in caminho.as_bytes() {
1227            if b == b'`' {
1228                return Err(DepError::fonte_caminho_shell_command_substitution(
1229                    nome, caminho,
1230                ));
1231            }
1232        }
1233        // Reproducibility gate's shell-glob arm. The c4d62b3 shell-command-
1234        // substitution arm closes the backtick byte; `*` (`0x2A`) and `?`
1235        // (`0x3F`) are the orthogonal POSIX glob-expansion sentinels — same
1236        // paste-from-shell-prompt footgun class, different syntactic surface.
1237        // Every POSIX shell (sh / bash / zsh / dash / ksh / fish / nushell)
1238        // lexes `*` and `?` as pathname-expansion wildcards: `*` matches any
1239        // sequence of characters in a path component (including the empty
1240        // sequence), `?` matches exactly one character. POSIX
1241        // `std::path::Path` treats both bytes as literal path-component bytes
1242        // (so `../caixa-teia/*.lisp` is one directory named literally
1243        // `../caixa-teia/*.lisp`, sibling of `.` and `..`).
1244        //
1245        // A `:caminho "../caixa-teia/*"` (the canonical "I pasted a
1246        // `ls ../caixa-teia/*` shell-listing one-liner into the `:caminho`
1247        // slot" footgun) or `:caminho "../foo?"` (the symmetric "I copied a
1248        // `rm foo?` single-char-wildcard removal idiom") silently passes
1249        // every prior arm because `Path::is_absolute` returns false on `..`,
1250        // `*` / `?` are neither leading-byte sentinels nor control bytes nor
1251        // `\` nor `<` / `>` nor `|` nor `;` nor `&` nor backtick, and the
1252        // value's last byte isn't `/`. The resolver folds the value through
1253        // `Path::new(caminho).join(<file>)` looking for a literal
1254        // `./../caixa-teia/*` subdirectory and fails at resolve time with a
1255        // non-self-locating `No such file or directory` error far from the
1256        // source caixa.lisp.
1257        //
1258        // The lacre pipeline embeds the value verbatim in its per-dep
1259        // content-address (`conteudo: format!("path:{caminho}")`,
1260        // caixa-resolver/src/resolve.rs:189), so a `*` or `?` byte lands in
1261        // the BLAKE3 closure and rides downstream as part of the build's
1262        // identity into every shell-spawned subprocess (the caixa-resolver's
1263        // `git clone` invocation, a future `feira tofu` shell-out, a future
1264        // operator-side `nix flake check` spawn) as the canonical
1265        // shell-metachar / pathname-expansion surface every peer
1266        // single-token-shaped typed slot already closes. The peer path-shaped
1267        // axis [`crate::render::is_gateway_api_http_path`]
1268        // (caixa-core/src/render.rs:506) rejects `*` and `?` as part of its
1269        // eleven-byte RFC-3986-reserved set on `:entrada :paths`. The
1270        // `:caminho` axis was the last typed path-string surface still
1271        // admitting these two bytes; this arm closes the gap so the
1272        // substrate-wide "no shell-composition / glob-expansion
1273        // metacharacter anywhere in a typed string slot that flows verbatim
1274        // into a shell-spawned subprocess" invariant extends from
1275        // shell-command-substitution (backtick) to glob-expansion
1276        // (`*` / `?`) on the `:caminho` axis.
1277        //
1278        // The arm fires AFTER the backtick arm because the prior arm's
1279        // CWE-78 shell-command-injection vector is the load-bearing
1280        // diagnostic on values that probe as both (a `"../`whoami`/*"`
1281        // carries both backtick and `*` — the command-substitution paste
1282        // is the load-bearing root-cause edit, so
1283        // `FonteCaminhoShellCommandSubstitution` wins; same cascade
1284        // discipline every prior `:caminho` arm establishes). The arm
1285        // fires BEFORE the trailing-`/` arm because the embedded glob
1286        // byte is the more semantic-locating axis on probe-as-both values
1287        // (`"../foo*/"` ends in `/` but the load-bearing diagnostic is the
1288        // embedded `*` glob metachar — the trailing `/` is the secondary
1289        // observation, and an author who removes the `*` is likely to
1290        // also tab-strip the trailing separator).
1291        for &b in caminho.as_bytes() {
1292            if b == b'*' || b == b'?' {
1293                return Err(DepError::fonte_caminho_shell_glob(nome, caminho, b));
1294            }
1295        }
1296        // Reproducibility gate's shell-subshell-grouping arm. The cf9034b
1297        // shell-glob arm closes the `*` / `?` pathname-expansion sentinels;
1298        // `(` (`0x28`) and `)` (`0x29`) are the orthogonal POSIX subshell-
1299        // grouping sentinels — same paste-from-shell-prompt footgun class,
1300        // different syntactic surface. Every POSIX shell (sh / bash / zsh /
1301        // dash / ksh / fish / nushell) lexes the parenthesis pair as the
1302        // subshell-grouping operator: `(<cmd>)` runs `<cmd>` in a child
1303        // shell with a fresh environment scope (the canonical sandboxing
1304        // idiom every shell-history `(cd <path> && <cmd>)` one-liner uses
1305        // to scope a `cd` to one subshell without disturbing the parent's
1306        // working directory), and `$(<cmd>)` is the modern Bourne
1307        // command-substitution shape the upstream f4efe9c
1308        // `FonteCaminhoVarExpansion` arm closes the leading `$` byte of —
1309        // the closing `)` byte completes that substitution shape and must
1310        // be refused on the same axis (peer with the
1311        // [`crate::render::is_git_repo_url`] 3b99147 arm that closes the
1312        // same byte-pair on the sibling `:fonte :repo` axis under the
1313        // same shell-subshell-grouping + RFC-3986-sub-delims banner).
1314        // POSIX `std::path::Path` treats both bytes as literal path-
1315        // component bytes (so `../caixa-teia/(date)` is one directory
1316        // named literally `../caixa-teia/(date)`, sibling of `.` and
1317        // `..`).
1318        //
1319        // A `:caminho "../caixa-teia/$(date)/build"` (the canonical "I
1320        // pasted a `cd ../caixa-teia/$(date)/build` shell-history one-
1321        // liner whose modern command-substitution expansion lands the
1322        // current date as a subdirectory name" footgun) or `:caminho
1323        // "../(cd foo && pwd)/caixa-teia"` (the symmetric "I copied a
1324        // `(cd foo && pwd)` subshell-grouping working-directory probe
1325        // idiom") silently passes every prior arm because
1326        // `Path::is_absolute` returns false on `..`, `(` / `)` are
1327        // neither leading-byte sentinels nor control bytes nor `\` nor
1328        // `<` / `>` nor `|` nor `;` nor `&` nor backtick nor `*` / `?`,
1329        // and the value's last byte isn't `/`. The resolver folds the
1330        // value through `Path::new(caminho).join(<file>)` looking for a
1331        // literal `./../caixa-teia/$(date)/build` subdirectory and fails
1332        // at resolve time with a non-self-locating `No such file or
1333        // directory` error far from the source caixa.lisp.
1334        //
1335        // The lacre pipeline embeds the value verbatim in its per-dep
1336        // content-address (`conteudo: format!("path:{caminho}")`,
1337        // caixa-resolver/src/resolve.rs:189), so a `(` or `)` byte lands
1338        // in the BLAKE3 closure and rides downstream as part of the
1339        // build's identity into every shell-spawned subprocess (the
1340        // caixa-resolver's `git clone` invocation, a future `feira tofu`
1341        // shell-out, a future operator-side `nix flake check` spawn) as
1342        // the canonical shell-metachar / subshell-grouping surface every
1343        // peer single-token-shaped typed slot already closes. The peer
1344        // git-source axis [`crate::render::is_git_repo_url`] (3b99147)
1345        // rejects the same byte pair on `:fonte :repo` under the same
1346        // shell-subshell-grouping / RFC-3986-sub-delims banner. The
1347        // `:caminho` axis was the last typed path-string surface still
1348        // admitting these two bytes;
1349        // this arm closes the gap so the substrate-wide "no shell-
1350        // composition metacharacter anywhere in a typed string slot that
1351        // flows verbatim into a shell-spawned subprocess" invariant
1352        // extends from shell-glob (`*` / `?`) to shell-subshell-grouping
1353        // (`(` / `)`) on the `:caminho` axis. Together with the f4efe9c
1354        // leading-`$` arm, the typed `:caminho` accepted set now
1355        // structurally excludes the entire modern Bourne
1356        // command-substitution surface — leading `$` closes the
1357        // leading byte of every `$(<cmd>)` shape, this arm closes the
1358        // trailing `)` boundary.
1359        //
1360        // The arm fires AFTER the shell-glob arm because the prior arm's
1361        // `*` / `?` pathname-expansion shape is the more common shell-
1362        // history paste idiom on values that probe as both
1363        // (`"../caixa-teia/*(date)"` carries both `*` and `(` — the
1364        // glob-paste-tail is the load-bearing root-cause edit, so
1365        // `FonteCaminhoShellGlob` wins; same cascade discipline every
1366        // prior `:caminho` arm establishes). The arm fires BEFORE the
1367        // trailing-`/` arm because the embedded subshell-grouping byte
1368        // is the more semantic-locating axis on probe-as-both values
1369        // (`"../foo(date)/"` ends in `/` but the load-bearing diagnostic
1370        // is the embedded `(` shell-subshell-grouping metachar — the
1371        // trailing `/` is the secondary observation, and an author who
1372        // removes the `(` is likely to also tab-strip the trailing
1373        // separator).
1374        for &b in caminho.as_bytes() {
1375            if b == b'(' || b == b')' {
1376                return Err(DepError::fonte_caminho_shell_subshell_grouping(
1377                    nome, caminho, b,
1378                ));
1379            }
1380        }
1381        // Reproducibility gate's shell-brace-expansion arm. The 0633c91
1382        // shell-subshell-grouping arm closes `(` / `)`; `{` (`0x7b`) and
1383        // `}` (`0x7d`) are the orthogonal shell-brace-expansion /
1384        // URI-Template-placeholder byte pair — same paste-from-shell-
1385        // prompt + paste-from-templated-doc footgun class, different
1386        // syntactic surface. Every POSIX-derived shell that implements
1387        // brace expansion (bash / zsh / ksh / fish; the canonical
1388        // `mkdir -p ../{caixa-teia,caixa-helm,caixa-flux}` /
1389        // `cp file{,.bak}` idiom every shell-history block carries)
1390        // expands `{a,b,c}` to the cross-product of its comma-separated
1391        // members and `{1..10}` to the integer range; RFC 6570 reserves
1392        // the matched pair for URI Template placeholders (the canonical
1393        // `https://{host}/{org}/{repo}` substitution shape every
1394        // OpenAPI / Swagger / Postman / GitHub Octokit client /
1395        // Helm chart-URL fragment / Mustache `{{org}}` doubled-brace
1396        // form carries), and Tera / Jinja2 / Handlebars / Go html/template
1397        // every IaC tool (Helm, Kustomize, Terraform's `${var}` cousin
1398        // shape) emit. POSIX `std::path::Path` treats both bytes as
1399        // literal path-component bytes (so `../{caixa-teia,caixa-helm}`
1400        // is one directory named literally `../{caixa-teia,caixa-helm}`,
1401        // sibling of `.` and `..`).
1402        //
1403        // A `:caminho "../{caixa-teia,caixa-helm}/build"` (the canonical
1404        // "I pasted a `cd ../{caixa-teia,caixa-helm}` shell brace-
1405        // expansion one-liner that fans across two siblings" footgun)
1406        // or `:caminho "../{{org}}/caixa-teia"` (the symmetric "I copied
1407        // a `{{org}}` Mustache / Helm template placeholder out of a
1408        // README quick-start and forgot to substitute") silently passes
1409        // every prior arm because `Path::is_absolute` returns false on
1410        // `..`, `{` / `}` are neither leading-byte sentinels nor control
1411        // bytes nor `\` nor `<` / `>` nor `|` nor `;` nor `&` nor
1412        // backtick nor `*` / `?` nor `(` / `)`, and the value's last
1413        // byte isn't `/`. The resolver folds the value through
1414        // `Path::new(caminho).join(<file>)` looking for a literal
1415        // `./../{caixa-teia,caixa-helm}/build` subdirectory and fails
1416        // at resolve time with a non-self-locating `No such file or
1417        // directory` error far from the source caixa.lisp.
1418        //
1419        // The lacre pipeline embeds the value verbatim in its per-dep
1420        // content-address (`conteudo: format!("path:{caminho}")`,
1421        // caixa-resolver/src/resolve.rs:189), so a `{` or `}` byte
1422        // lands in the BLAKE3 closure and rides downstream as part of
1423        // the build's identity into every shell-spawned subprocess
1424        // (the caixa-resolver's `git clone` invocation, a future
1425        // `feira tofu` shell-out, a future operator-side `nix flake
1426        // check` spawn) as the canonical shell-metachar / brace-
1427        // expansion surface every peer single-token-shaped typed
1428        // slot already closes. The peer git-source axis
1429        // [`crate::render::is_git_repo_url`] (42d8f9d — the URI Template
1430        // placeholder arm) rejects the same byte pair on `:fonte :repo`
1431        // under the same RFC-3986-'delims' / RFC-6570-URI-Template /
1432        // shell-brace-expansion banner. The `:caminho` axis was the last
1433        // typed path-string surface still admitting these two bytes;
1434        // this arm closes the gap so the substrate-wide "no shell-
1435        // composition metacharacter anywhere in a typed string slot
1436        // that flows verbatim into a shell-spawned subprocess"
1437        // invariant extends from shell-subshell-grouping (`(` / `)`)
1438        // to shell-brace-expansion (`{` / `}`) on the `:caminho` axis,
1439        // and the typed `:caminho` accepted set now also structurally
1440        // excludes the URI Template / templating-engine placeholder
1441        // surface that would silently round-trip through any
1442        // downstream IaC templating-engine layer.
1443        //
1444        // The arm fires AFTER the shell-subshell-grouping arm because
1445        // the prior arm's `(` / `)` shape is the more semantic-locating
1446        // axis on values that probe as both (`"../{cd foo}(date)"`
1447        // carries both `{` and `(` — the parenthesis-pair is the
1448        // load-bearing modern-Bourne-command-substitution surface the
1449        // prior arm closes; same cascade discipline every prior
1450        // `:caminho` arm establishes). The arm fires BEFORE the
1451        // trailing-`/` arm because the embedded brace-expansion byte
1452        // is the more semantic-locating axis on probe-as-both values
1453        // (`"../{caixa-teia,caixa-helm}/"` ends in `/` but the
1454        // load-bearing diagnostic is the embedded `{` brace-expansion
1455        // metachar — the trailing `/` is the secondary observation,
1456        // and an author who removes the `{` is likely to also tab-
1457        // strip the trailing separator).
1458        for &b in caminho.as_bytes() {
1459            if b == b'{' || b == b'}' {
1460                return Err(DepError::fonte_caminho_shell_brace_expansion(
1461                    nome, caminho, b,
1462                ));
1463            }
1464        }
1465        // Reproducibility gate's shell-bracket-expansion arm. The 598b770
1466        // shell-brace-expansion arm closes `{` / `}`; `[` (`0x5b`) and
1467        // `]` (`0x5d`) are the orthogonal POSIX glob-character-class /
1468        // shell-`test`-builtin byte pair — same paste-from-shell-prompt
1469        // footgun class, different syntactic surface. Every POSIX shell
1470        // (sh / bash / zsh / dash / ksh / fish / nushell) lexes the
1471        // bracket pair as the glob character-class operator: `[abc]`
1472        // matches one of `a`, `b`, `c`; `[a-z]` matches any lowercase
1473        // ASCII letter; `[^x]` negates (the canonical
1474        // `ls *.[ch]` C-source-file glob and the `cd ../[a-z]*`
1475        // lowercase-sibling glob every shell-history block carries —
1476        // the orthogonal axis to the cf9034b `*` / `?` shell-glob arm
1477        // closing the unbounded pathname-expansion sentinels). The
1478        // bracket pair additionally carries the POSIX `test` /
1479        // `[` builtin command (`[ -d ../caixa-teia ] && cd ...` —
1480        // the canonical idiom every shell-script conditional uses) and
1481        // bash's `[[ ... ]]` extended-test grammar. Beyond shell, the
1482        // bracket pair is the TOML inline-array delimiter
1483        // (`features = ["a", "b"]` — the canonical paste-from-Cargo-
1484        // manifest cross-idiom-leak vector), the YAML flow-sequence
1485        // delimiter (`paths: [/a, /b]` — the canonical paste-from-
1486        // values.yaml cross-idiom leak), the JSON array delimiter,
1487        // and the POSIX-ERE / PCRE bracket-expression / character-
1488        // class anchor (the canonical paste-from-regex-doc shape).
1489        // POSIX `std::path::Path` treats both bytes as literal path-
1490        // component bytes (so `../[caixa-teia]` is one directory
1491        // named literally `../[caixa-teia]`, sibling of `.` and
1492        // `..`).
1493        //
1494        // A `:caminho "../caixa-[a-z]/build"` (the canonical "I
1495        // pasted a `cd ../caixa-[a-z]/build` glob-character-class
1496        // one-liner that matches every lowercase-sibling-suffix
1497        // sibling directory" footgun), `:caminho "../[caixa-teia]/
1498        // build"` (the symmetric "I pasted a TOML inline-array /
1499        // YAML flow-sequence shape out of an aligned manifest"
1500        // idiom), or `:caminho "../caixa-[ch]"` (the canonical
1501        // `*.[ch]` C-source character-class paste-from-shell-history
1502        // shape) silently passes every prior arm because
1503        // `Path::is_absolute` returns false on `..`, `[` / `]` are
1504        // neither leading-byte sentinels nor control bytes nor `\`
1505        // nor `<` / `>` nor `|` nor `;` nor `&` nor backtick nor
1506        // `*` / `?` nor `(` / `)` nor `{` / `}`, and the value's
1507        // last byte isn't `/`. The resolver folds the value through
1508        // `Path::new(caminho).join(<file>)` looking for a literal
1509        // `./../caixa-[a-z]/build` subdirectory and fails at resolve
1510        // time with a non-self-locating `No such file or directory`
1511        // error far from the source caixa.lisp.
1512        //
1513        // The lacre pipeline embeds the value verbatim in its per-dep
1514        // content-address (`conteudo: format!("path:{caminho}")`,
1515        // caixa-resolver/src/resolve.rs:189), so a `[` or `]` byte
1516        // lands in the BLAKE3 closure and rides downstream as part of
1517        // the build's identity into every shell-spawned subprocess
1518        // (the caixa-resolver's `git clone` invocation, a future
1519        // `feira tofu` shell-out, a future operator-side `nix flake
1520        // check` spawn) as the canonical shell-metachar / glob-
1521        // character-class / TOML-array surface every peer single-
1522        // token-shaped typed slot already closes. The `:caminho` axis
1523        // was the last typed path-string surface still admitting
1524        // these two bytes; this arm closes the gap so the substrate-
1525        // wide "no shell-composition metacharacter anywhere in a
1526        // typed string slot that flows verbatim into a shell-spawned
1527        // subprocess" invariant extends from shell-brace-expansion
1528        // (`{` / `}`) to shell-bracket-expansion (`[` / `]`) on the
1529        // `:caminho` axis. Together with the cf9034b `*` / `?` arm,
1530        // the typed `:caminho` accepted set now structurally excludes
1531        // the entire POSIX pathname-expansion / glob surface —
1532        // unbounded glob (`*` / `?`) AND bounded character-class
1533        // (`[abc]` / `[a-z]`).
1534        //
1535        // The arm fires AFTER the shell-brace-expansion arm because
1536        // the prior arm's `{` / `}` shape is the more semantic-
1537        // locating axis on values that probe as both
1538        // (`"../{a,b}[ch]"` carries both `{` and `[` — the brace-
1539        // expansion fan is the load-bearing root-cause edit, so
1540        // `FonteCaminhoShellBraceExpansion` wins; same cascade
1541        // discipline every prior `:caminho` arm establishes). The arm
1542        // fires BEFORE the trailing-`/` arm because the embedded
1543        // bracket-expansion byte is the more semantic-locating axis
1544        // on probe-as-both values (`"../[a-z]/"` ends in `/` but the
1545        // load-bearing diagnostic is the embedded `[` glob-character-
1546        // class metachar — the trailing `/` is the secondary
1547        // observation, and an author who removes the `[` is likely
1548        // to also tab-strip the trailing separator).
1549        for &b in caminho.as_bytes() {
1550            if b == b'[' || b == b']' {
1551                return Err(DepError::fonte_caminho_shell_bracket_expansion(
1552                    nome, caminho, b,
1553                ));
1554            }
1555        }
1556        // Reproducibility gate's shell-quote-grouping arm. The 986963b
1557        // shell-bracket-expansion arm closes `[` / `]`; `'` (`0x27`) and
1558        // `"` (`0x22`) are the orthogonal POSIX shell-string-literal
1559        // delimiter pair — same paste-from-shell-prompt footgun class,
1560        // different syntactic surface. Every POSIX shell (sh / bash /
1561        // zsh / dash / ksh / fish / nushell) lexes the pair as the
1562        // string-literal quoting operator: `'…'` is the strong
1563        // (no-expansion) single-quoted string and `"…"` is the weak
1564        // (variable-/command-substitution-preserving) double-quoted
1565        // string — the canonical `cd '../caixa-teia'` shell-history
1566        // idiom every path-with-embedded-whitespace paste block carries,
1567        // and the symmetric `git clone "$REPO"` weak-quoted CI-manifest
1568        // shape. Beyond shell, the two bytes carry the JSON string-literal
1569        // delimiter (`"key": "value"` — the canonical paste-from-JSON-
1570        // config cross-idiom-leak vector), the YAML double-quoted +
1571        // single-quoted flow-scalar delimiters (`path: "../caixa-teia"`
1572        // — the canonical paste-from-values.yaml / paste-from-K8s-YAML-
1573        // manifest cross-idiom leak), the TOML basic + literal string
1574        // delimiters (`path = "../caixa-teia"` — the canonical paste-
1575        // from-Cargo-manifest cross-idiom-leak vector), the tatara-lisp
1576        // string-literal delimiter itself (`(:caminho "../caixa-teia")`
1577        // — the canonical "I copied the entire `:caminho "..."` slot
1578        // rather than just the string body" author-surface footgun),
1579        // and RFC 3986 §2.2's `gen-delims` / `sub-delims` grammar which
1580        // excludes both bytes from the `unreserved / pct-encoded /
1581        // sub-delims / ":" / "@"` `pchar` production. POSIX
1582        // `std::path::Path` treats both bytes as literal path-component
1583        // bytes (so `../"caixa-teia"` is one directory named literally
1584        // `../"caixa-teia"`, sibling of `.` and `..`).
1585        //
1586        // A `:caminho "'../caixa-teia'"` (the canonical "I pasted a
1587        // `cd '../caixa-teia'` shell-history one-liner whose strong-
1588        // quoting preserved the sibling-workspace path verbatim across
1589        // the whitespace paste boundary" footgun), `:caminho
1590        // "\"../caixa-teia\""` (the symmetric weak-quoted paste-from-
1591        // JSON / paste-from-YAML flow-scalar / paste-from-TOML basic-
1592        // string / paste-from-tatara-lisp string-literal cross-idiom-
1593        // leak shape), or `:caminho "../\"caixa-teia\""` (the embedded-
1594        // quote "I pasted a JSON key-value pair fragment into the
1595        // middle of the path" idiom) silently passes every prior arm
1596        // because `Path::is_absolute` returns false on `..` / `'` /
1597        // `"`, `'` / `"` are neither leading-byte sentinels nor
1598        // control bytes nor `\` nor `<` / `>` nor `|` nor `;` nor `&`
1599        // nor backtick nor `*` / `?` nor `(` / `)` nor `{` / `}` nor
1600        // `[` / `]`, and the value's last byte isn't `/`. The resolver
1601        // folds the value through `Path::new(caminho).join(<file>)`
1602        // looking for a literal `./'../caixa-teia'` subdirectory and
1603        // fails at resolve time with a non-self-locating `No such file
1604        // or directory` error far from the source caixa.lisp.
1605        //
1606        // The lacre pipeline embeds the value verbatim in its per-dep
1607        // content-address (`conteudo: format!("path:{caminho}")`,
1608        // caixa-resolver/src/resolve.rs:189), so a `'` or `"` byte
1609        // lands in the BLAKE3 closure and rides downstream as part of
1610        // the build's identity into every shell-spawned subprocess
1611        // (the caixa-resolver's `git clone` invocation, a future
1612        // `feira tofu` shell-out, a future operator-side `nix flake
1613        // check` spawn) as the canonical shell-metachar / string-
1614        // literal-delimiter surface every peer single-token-shaped
1615        // typed slot already closes. The peer `:fonte :repo` axis
1616        // closes both bytes under the same shell-quote-grouping /
1617        // RFC-3986-sub-delims banner (e7a109f `'` shell-single-quote
1618        // + 4267d8b `"` shell-double-quote on `is_git_repo_url`). The
1619        // `:caminho` axis was the last typed path-string surface
1620        // still admitting these two bytes; this arm closes the gap
1621        // so the substrate-wide "no shell-composition metacharacter
1622        // anywhere in a typed string slot that flows verbatim into a
1623        // shell-spawned subprocess" invariant extends from shell-
1624        // bracket-expansion (`[` / `]`) to shell-quote-grouping (`'`
1625        // / `"`) on the `:caminho` axis. Together with the peer
1626        // JSON / YAML / TOML string-literal delimiters closing at
1627        // this arm and the 598b770 `{` / `}` brace-expansion arm
1628        // closing the templating-engine-placeholder boundary, the
1629        // typed `:caminho` accepted set now structurally excludes
1630        // the entire cross-config-DSL string-literal / templating
1631        // paste-from-aligned-manifest cross-idiom-leak surface that
1632        // would silently round-trip through any downstream JSON /
1633        // YAML / TOML / HCL / tatara-lisp parsing layer.
1634        //
1635        // The arm fires AFTER the shell-bracket-expansion arm because
1636        // the prior arm's `[` / `]` shape is the more semantic-
1637        // locating axis on values that probe as both (`"../[a-z]'x'"`
1638        // carries both `[` and `'` — the glob-character-class
1639        // expansion is the load-bearing root-cause edit, so
1640        // `FonteCaminhoShellBracketExpansion` wins; same cascade
1641        // discipline every prior `:caminho` arm establishes). The arm
1642        // fires BEFORE the trailing-`/` arm because the embedded
1643        // quote-grouping byte is the more semantic-locating axis on
1644        // probe-as-both values (`"../'caixa-teia'/"` ends in `/` but
1645        // the load-bearing diagnostic is the embedded `'` shell-
1646        // string-literal metachar — the trailing `/` is the secondary
1647        // observation, and an author who removes the `'` is likely to
1648        // also tab-strip the trailing separator).
1649        for &b in caminho.as_bytes() {
1650            if b == b'\'' || b == b'"' {
1651                return Err(DepError::fonte_caminho_shell_quote_grouping(
1652                    nome, caminho, b,
1653                ));
1654            }
1655        }
1656        // Reproducibility gate's shell-comment / URL-fragment / YAML-comment arm.
1657        // The d14cbc5 shell-quote-grouping arm closes `'` / `"`; `#` (`0x23`) is
1658        // the orthogonal "byte at which four distinct downstream parsers all
1659        // truncate the value at the first occurrence" surface, and no prior arm
1660        // has covered it on the `:caminho` axis. Every POSIX shell (sh / bash /
1661        // zsh / dash / ksh / fish / nushell) lexes an unquoted `#` at the head
1662        // of a word (or after unquoted whitespace) as the comment-lead: from
1663        // that byte to the end of the physical line is a comment discarded
1664        // before command parsing (`cd ../caixa-teia  # legacy sibling` — the
1665        // canonical paste-from-shell-history-with-trailing-annotation shape
1666        // every operator-notebook and CI-manifest carries; POSIX.1-2017 §2.3
1667        // Token Recognition step 6). YAML 1.2 §6.6 makes `#` the comment lead
1668        // at any position preceded by whitespace or at line-start (`path:
1669        // ../caixa-teia  # pin` — the canonical paste-from-values.yaml /
1670        // paste-from-K8s-manifest cross-idiom-leak shape). tatara-lisp itself
1671        // treats `;` as the comment-lead but a growing number of consumer
1672        // config-DSL layers (HCL, Terraform, Nix flake attributes, .env
1673        // dotenv-style files, gitconfig / .gitignore, ini / TOML) use `#` as
1674        // the comment-lead too — the pair extends the cross-config-DSL
1675        // paste-idiom surface the d14cbc5 quote-grouping arm and the 598b770
1676        // brace-expansion arm already cover on adjacent axes. RFC 3986 §3.5
1677        // reserves `#` as the URL fragment-identifier delimiter (the canonical
1678        // paste-from-browser-address-bar `github.com/foo/bar#readme` /
1679        // `github.com/foo/bar#L42` permalink shape, and the symmetric
1680        // Nix-flake-ref cross-idiom leak `github:foo/bar#packageName` where
1681        // `#` selects a flake output — the same axis the peer
1682        // [`crate::render::is_git_repo_url`] closes on the `:fonte :repo`
1683        // surface at a68f818 with the same downstream-drops-the-tail
1684        // rationale).
1685        //
1686        // POSIX `std::path::Path` treats `#` as a literal path-component byte,
1687        // so a `:caminho "../caixa-teia # legacy sibling"` (the canonical
1688        // paste-from-shell-history-with-trailing-annotation footgun),
1689        // `:caminho "../caixa-teia  # pin"` (the symmetric YAML flow-scalar
1690        // paste-with-trailing-comment shape), or `:caminho "../caixa-teia
1691        // #readme"` (the URL fragment paste-from-browser-address-bar shape)
1692        // silently passes every prior arm because `Path::is_absolute` returns
1693        // false on `..`, `#` is neither a leading-byte sentinel nor a control
1694        // byte nor `\` nor `<` / `>` nor `|` nor `;` nor `&` nor backtick nor
1695        // `*` / `?` nor `(` / `)` nor `{` / `}` nor `[` / `]` nor `'` / `"`,
1696        // and the value's last byte isn't `/`. The resolver folds the value
1697        // through `Path::new(caminho).join(<file>)` looking for a literal
1698        // subdirectory named `../caixa-teia # legacy sibling` and fails at
1699        // resolve time with a non-self-locating `No such file or directory`
1700        // error far from the source caixa.lisp — while every downstream
1701        // shell / YAML / URL parser silently truncates the value at the `#`
1702        // byte to `../caixa-teia`, so a `feira tofu` shell-out to a
1703        // `cd '{caminho}'` command line and a `nix flake check` invocation on
1704        // an emitted YAML `path:` scalar disagree with the resolver on which
1705        // directory the value names. Two workstations whose downstream
1706        // shell / YAML / URL parsing layers differ in unquoted-`#`
1707        // recognition emit divergent build artifacts for the byte-identical
1708        // caixa.lisp value.
1709        //
1710        // The lacre pipeline embeds the value verbatim in its per-dep
1711        // content-address (`conteudo: format!("path:{caminho}")`,
1712        // caixa-resolver/src/resolve.rs:189), so the byte lands in the BLAKE3
1713        // closure and rides downstream as part of the build's identity into
1714        // every shell-spawned subprocess (the caixa-resolver's `git clone`
1715        // invocation, a future `feira tofu` shell-out, a future operator-side
1716        // `nix flake check` spawn) as the canonical shell-metachar /
1717        // comment-lead / URL-fragment-delimiter surface every peer
1718        // single-token-shaped typed slot already closes. The peer `:fonte
1719        // :repo` axis closes the byte under the URL-fragment-identifier
1720        // banner (a68f818 `#` on `is_git_repo_url`); the `:caminho` axis was
1721        // the last typed path-string surface still admitting the byte. This
1722        // arm closes the gap so the substrate-wide "no shell-composition
1723        // metacharacter / comment-lead / URL-fragment-delimiter anywhere in a
1724        // typed string slot that flows verbatim into a shell-spawned
1725        // subprocess or downstream YAML / URL parser" invariant extends from
1726        // shell-quote-grouping (`'` / `"`) to shell-comment / URL-fragment
1727        // (`#`) on the `:caminho` axis. Together with the peer JSON / YAML /
1728        // TOML string-literal delimiters the d14cbc5 quote-grouping arm
1729        // closes and the 598b770 `{` / `}` brace-expansion arm closes on the
1730        // templating-engine-placeholder boundary, the typed `:caminho`
1731        // accepted set now structurally excludes the entire
1732        // paste-with-trailing-annotation / paste-from-URL-permalink /
1733        // paste-from-YAML-comment cross-idiom-leak surface that would
1734        // silently round-trip through any downstream shell / YAML / URL /
1735        // dotenv / gitconfig / HCL parsing layer to a different value than
1736        // the resolver's `Path::join` sees.
1737        //
1738        // The arm fires AFTER the shell-quote-grouping arm because the prior
1739        // arm's `'` / `"` shape is the more semantic-locating axis on values
1740        // that probe as both (`"../'x'#pin"` carries both `'` and `#` — the
1741        // shell-string-literal-delimiter is the load-bearing root-cause edit,
1742        // so `FonteCaminhoShellQuoteGrouping` wins; same cascade discipline
1743        // every prior `:caminho` arm establishes). The arm fires BEFORE the
1744        // trailing-`/` arm because the embedded comment-lead / fragment-
1745        // delimiter byte is the more semantic-locating axis on probe-as-both
1746        // values (`"../caixa-teia#pin/"` ends in `/` but the load-bearing
1747        // diagnostic is the embedded `#` — the trailing `/` is the secondary
1748        // observation, and an author who removes the `#pin` fragment is
1749        // likely to also tab-strip the trailing separator).
1750        for &b in caminho.as_bytes() {
1751            if b == b'#' {
1752                return Err(DepError::fonte_caminho_shell_comment(nome, caminho, b));
1753            }
1754        }
1755        // Reproducibility gate's URL-percent-encoding-escape arm. The 6622063
1756        // shell-comment arm closes the `#` URL-fragment-identifier byte; `%`
1757        // (`0x25`) is the orthogonal RFC 3986 §2.1 URL percent-encoding-escape
1758        // byte — the mandatory encoding mechanism for every byte outside the
1759        // `unreserved` alphanumeric / `-` / `.` / `_` / `~` set, and `%`
1760        // itself must be percent-encoded as `%25` to appear literally inside
1761        // a URL value. The byte carries three distinct render-determinism
1762        // hazards on the `:caminho` axis, no prior arm has covered it, and
1763        // the peer `:fonte :repo` axis (a323db8 `%` on `is_git_repo_url`)
1764        // already closes the same byte under the same URL-percent-encoding
1765        // banner — the `:caminho` axis was the last typed path-string surface
1766        // still admitting the byte.
1767        //
1768        // First, the paste-from-browser-address-bar percent-encoded-space
1769        // footgun: an author copies `../caixa%20teia` out of a URL-encoded
1770        // README hyperlink / a browser address bar / a percent-encoded
1771        // permalink expecting `%20` to decode to a literal space at the
1772        // filesystem layer. POSIX `std::path::Path` treats the byte as a
1773        // literal path-component byte, so `Path::join` looks for a literal
1774        // `./../caixa%20teia` subdirectory and fails at resolve time with a
1775        // non-self-locating `No such file or directory` error far from the
1776        // source caixa.lisp — while the author's mental model was
1777        // `../caixa teia`, the decoded shape. Two authors whose only
1778        // difference is percent-encoding presence resolve to two distinct
1779        // BLAKE3 closures (`path:../caixa%20teia` vs `path:../caixa teia`)
1780        // for what they intended as the byte-identical sibling-workspace
1781        // dep. The lacre pipeline embeds the value verbatim in its per-dep
1782        // content-address (`conteudo: format!("path:{caminho}")`,
1783        // caixa-resolver/src/resolve.rs:189), so the divergence rides
1784        // downstream into the BLAKE3 closure and locks the substrate's
1785        // "the lacre is the build's identity" contract (CAIXA-SDLC §III.2)
1786        // to the wrong encoding — the same THEORY.md §V.2 render-
1787        // determinism vector every prior `:caminho` arm protects.
1788        //
1789        // Second, the printf-format-specifier lead footgun: `%` is the C /
1790        // POSIX printf format-directive lead-in (`%s`, `%d`, `%02x`, the
1791        // canonical `printf "path=%s\n" ../caixa-teia` invocation every
1792        // shell-diagnostic one-liner carries) and the printf builtin is
1793        // wired into every POSIX shell (bash / zsh / dash / ksh / busybox
1794        // ash) as the format-string lead. A `:caminho "../caixa-%s-teia"`
1795        // value flowing into any future `feira` verb that shells out with a
1796        // printf-formatted path template silently gets reinterpreted as a
1797        // format-directive rather than a literal byte — the canonical
1798        // CWE-134 format-string-injection vector.
1799        //
1800        // Third, the bash-job-control-specifier lead footgun: bash / zsh /
1801        // ksh reserve `%N` at word-start as the job-control specifier —
1802        // `%1` names "job 1", `%%` names "the current job", `%foo` names
1803        // "the most recent job whose command started with `foo`". A future
1804        // `feira` verb that invokes `kill %1` on a caminho-scoped
1805        // subprocess would silently redirect the signal to a wrong target.
1806        //
1807        // Beyond the three shell-side hazards, `%` is a first-class parser
1808        // byte in three cross-config-DSL layers the substrate's paste-idiom
1809        // surface routinely crosses: YAML 1.2 §6.8.1 lexes `%` at
1810        // line-start as the directive lead (`%YAML 1.2` / `%TAG` — a
1811        // `:caminho "%YAML/1.2/../caixa-teia"` paste from a top-of-doc
1812        // YAML directive block silently trips the YAML directive parser on
1813        // any downstream emitted YAML manifest); Prometheus / Grafana
1814        // template syntax uses `%(var)s` as the substitution lead; and Nix
1815        // interpolation uses `${var}` (not `%`) but Envsubst /
1816        // Kubernetes / OpenShift template layers use `%VAR%` as the
1817        // Windows-shell env-var-reference lead — the paste-from-`.bat` /
1818        // paste-from-PowerShell-`%env:PATH%` cross-idiom leak.
1819        //
1820        // The three malformed-`%HH` classes documented on the peer
1821        // `is_git_repo_url` `%` arm (a323db8) apply here too:
1822        //
1823        //   - The lone-`%` malformed-escape shape (`"../caixa-teia%foo"`
1824        //     where `%` isn't followed by two hex digits) — every WHATWG-
1825        //     conformant URL parser rejects the value at parse time per
1826        //     RFC 3986 §2.1, but the byte rides into the lacre before
1827        //     the resolver subprocess crosses the URL-parser boundary.
1828        //   - The over-encoded path-separator shape (`"../caixa%2Fteia"`
1829        //     intending the `%2F` as the URL encoding of `/`) locks a
1830        //     `path:../caixa%2Fteia` BLAKE3 closure that diverges from
1831        //     the byte-identical `path:../caixa/teia` form.
1832        //   - The double-encoded shape (`"../caixa%2520teia"` — the `%25`
1833        //     already itself an encoded `%`, so the intent was likely a
1834        //     literal `%20` that survived one round-trip through a
1835        //     URL-encoder that shouldn't have run) locks a triply-
1836        //     divergent closure across the encoded / once-decoded /
1837        //     twice-decoded chain.
1838        //
1839        // POSIX `std::path::Path` treats the byte as a literal path-
1840        // component byte, so a `:caminho "../caixa%20teia"` (the canonical
1841        // paste-from-browser-address-bar percent-encoded-space footgun),
1842        // `:caminho "%YAML/../caixa-teia"` (the symmetric paste-from-YAML-
1843        // directive-block cross-idiom leak), or `:caminho
1844        // "../caixa-%s-teia"` (the printf-format-specifier paste-from-
1845        // shell-diagnostic-one-liner shape) silently passes every prior arm
1846        // because `Path::is_absolute` returns false on `..`, `%` is neither
1847        // a leading-byte sentinel nor a control byte nor `\` nor `<` / `>`
1848        // nor `|` nor `;` nor `&` nor backtick nor `*` / `?` nor `(` / `)`
1849        // nor `{` / `}` nor `[` / `]` nor `'` / `"` nor `#`, and the
1850        // value's last byte isn't `/`. The resolver folds the value through
1851        // `Path::new(caminho).join(<file>)` looking for a literal
1852        // subdirectory named `../caixa%20teia` and fails at resolve time
1853        // with a non-self-locating `No such file or directory` error far
1854        // from the source caixa.lisp — while every downstream URL parser /
1855        // shell printf builtin / YAML directive parser silently
1856        // reinterprets the byte to a different value than the resolver's
1857        // `Path::join` sees. Two workstations whose downstream URL / shell
1858        // / YAML layers differ in `%HH` recognition emit divergent build
1859        // artifacts for the byte-identical caixa.lisp value.
1860        //
1861        // The lacre pipeline embeds the value verbatim in its per-dep
1862        // content-address (`conteudo: format!("path:{caminho}")`, caixa-
1863        // resolver/src/resolve.rs:189), so the byte lands in the BLAKE3
1864        // closure and rides into every shell-spawned subprocess (the
1865        // resolver's `git clone`, a future `feira tofu` shell-out, a
1866        // future operator-side `nix flake check` spawn) as the canonical
1867        // URL-percent-encoding-escape / printf-format-specifier / bash-
1868        // job-control-specifier surface every peer single-token-shaped
1869        // typed slot already closes. This arm closes the gap so the
1870        // substrate-wide "no URL-percent-encoding-escape / printf-format-
1871        // specifier / job-control-specifier / YAML-directive-lead byte
1872        // anywhere in a typed string slot that flows verbatim into a
1873        // shell-spawned subprocess or downstream URL / printf / YAML
1874        // parser" invariant extends from shell-comment / URL-fragment
1875        // (`#` — 6622063) to URL-percent-encoding-escape (`%`) on the
1876        // `:caminho` axis.
1877        //
1878        // The arm fires AFTER the shell-comment arm because the prior
1879        // arm's `#` shape is the more semantic-locating axis on values
1880        // that probe as both (`"../caixa%20teia#pin"` carries both `%`
1881        // and `#` — the URL-fragment-identifier is the load-bearing
1882        // downstream-truncation edit, so `FonteCaminhoShellComment` wins;
1883        // same cascade discipline every prior `:caminho` arm establishes).
1884        // The arm fires BEFORE the trailing-`/` arm because the embedded
1885        // percent-encoding-escape byte is the more semantic-locating axis
1886        // on probe-as-both values (`"../caixa%20teia/"` ends in `/` but
1887        // the load-bearing diagnostic is the embedded `%` percent-
1888        // encoding-escape — the trailing `/` is the secondary observation,
1889        // and an author who decodes the `%20` to a literal space is
1890        // likely to also tab-strip the trailing separator).
1891        for &b in caminho.as_bytes() {
1892            if b == b'%' {
1893                return Err(DepError::fonte_caminho_url_percent_encoding(
1894                    nome, caminho, b,
1895                ));
1896            }
1897        }
1898        // Reproducibility gate's embedded-`$` shell-variable-expansion /
1899        // command-substitution / arithmetic-expansion arm. The f4efe9c
1900        // leading-`$` arm at line 540 routes `caminho.starts_with('$')`
1901        // through `FonteCaminhoVarExpansion` under the leading-byte-
1902        // sentinel host-layout-leak banner (peer with the b94fd83
1903        // absolute / a5c248e tilde leading-byte arms), but the arm
1904        // fires only at position 0 — a `:caminho "../foo$HOME/bar"`
1905        // (embedded `$HOME` in a nested path segment — the canonical
1906        // paste-from-`ls ../foo$HOME/bar`-shell-one-liner footgun where
1907        // an author copies a partially-substituted shell one-liner and
1908        // the leading segment is a literal `../foo` while the mid
1909        // segment carries the un-substituted `$HOME` template), a
1910        // `:caminho "../foo${WORKSPACE}/bar"` (the symmetric braced-CI-
1911        // manifest paste-from-`.gitlab-ci.yml` / paste-from-GitHub-
1912        // Actions-workflow shape), a `:caminho "../foo$(whoami)/bar"`
1913        // (the paste-from-shell-prompt command-substitution idiom), or
1914        // a `:caminho "../foo$((1+2))/bar"` (the arithmetic-expansion
1915        // idiom) silently passes every prior arm because
1916        // `Path::is_absolute` returns false on `..`, `$` is neither a
1917        // leading-byte sentinel (the f4efe9c arm fires only at position
1918        // 0) nor a control byte nor `\` nor `<` / `>` nor `|` nor `;`
1919        // nor `&` nor backtick nor `*` / `?` nor `(` / `)` nor `{` /
1920        // `}` nor `[` / `]` nor `'` / `"` nor `#` nor `%`, and the
1921        // value's last byte isn't `/`. Note that `$(...)` command-
1922        // substitution and `$((...))` arithmetic-expansion each carry
1923        // an embedded `(` byte that the 0633c91 shell-subshell-grouping
1924        // arm catches structurally at the earlier `(` position — but
1925        // an author who reaches for the sh-brace-substitution
1926        // `${VAR}` or the bare `$VAR` shape carries only the `$` byte,
1927        // which no prior arm covers. This arm closes the last
1928        // positional gap on the `$` byte on the `:caminho` axis so
1929        // every position — leading (`FonteCaminhoVarExpansion`) and
1930        // embedded (`FonteCaminhoShellVariableExpansion`) — is
1931        // structurally rejected.
1932        //
1933        // Every POSIX shell (sh / bash / zsh / dash / ksh / busybox
1934        // ash / fish / nushell) lexes `$` as the variable-expansion /
1935        // command-substitution / arithmetic-expansion operator per
1936        // POSIX.1-2017 §2.6 (Word Expansions): `$<name>` (Parameter
1937        // Expansion) expands a named variable, `${<name>}` (Parameter
1938        // Expansion braced form) does the same with an explicit token
1939        // boundary, `$(<cmd>)` (Command Substitution modern form,
1940        // `` `<cmd>` `` legacy form which the c370458 backtick arm
1941        // already closes) runs a subshell and substitutes its stdout,
1942        // and `$((<expr>))` (Arithmetic Expansion) evaluates an
1943        // arithmetic expression. Every form is a host-layout /
1944        // environment-state / shell-subprocess-side-effect leak when
1945        // the byte lands in a value the resolver passes to a shell-
1946        // spawned subprocess. Beyond the POSIX shell layer, `$` is
1947        // the Nix `${var}` string-interpolation lead (the paste-from-
1948        // `flake.nix` / paste-from-`.nix`-attribute cross-idiom leak
1949        // where an author copies `"${pkgs.hello}/bin/hello"` out of a
1950        // nix expression), the Make `$(var)` / `$@` / `$<` automatic-
1951        // variable lead (the paste-from-`Makefile` shape), the
1952        // JavaScript / TypeScript template-literal `${expr}` interp
1953        // lead (the paste-from-JS-template-string idiom in a
1954        // multi-lang-monorepo where a `path` attribute gets copied out
1955        // of a `package.json` script or a Vite config), the envsubst /
1956        // Kubernetes / OpenShift template `${VAR}` interp lead (the
1957        // paste-from-Helm-values / paste-from-K8s-manifest cross-idiom
1958        // leak), the PHP variable lead (`$_GET`, `$_ENV` — the paste-
1959        // from-`.php`-config footgun), the Perl scalar-variable lead
1960        // (`$foo`), the SASS / SCSS variable lead (`$primary-color`),
1961        // and the SQL bind-parameter lead in PostgreSQL / SQLite
1962        // (`$1`, `$2` — the paste-from-`.sql`-migration idiom). The
1963        // cross-idiom paste-footgun surface is broader than any single
1964        // shell layer — `$` is a first-class parser byte in nearly
1965        // every config / templating / build-system DSL the substrate's
1966        // paste-idiom surface routinely crosses. The peer `:fonte
1967        // :repo` axis closes the byte under the shell-variable-
1968        // expansion / URL-sub-delim banner (b9d187c `$` on
1969        // `is_git_repo_url`), the peer `:fonte :tag` / `:fonte :branch`
1970        // axes close `$` as part of `is_git_ref_name`'s printable-
1971        // ASCII-restricted grammar (`git check-ref-format` rejects the
1972        // byte outright), and the peer `:entrada :paths` axis closes
1973        // `$` via `is_gateway_api_http_path`'s eleven-byte RFC-3986-
1974        // reserved set. The `:caminho` axis was the last typed path-
1975        // string surface still admitting `$` at positions other than 0.
1976        //
1977        // POSIX `std::path::Path` treats `$` as a literal path-
1978        // component byte, so `:caminho "../foo$HOME/bar"` silently
1979        // routes through `Path::new(caminho).join(<file>)` looking for
1980        // a literal `./{caminho}` subdirectory that fails at resolve
1981        // time with a non-self-locating `No such file or directory`
1982        // error far from the source caixa.lisp. But every downstream
1983        // shell / envsubst / Nix / Make / K8s-template parser silently
1984        // reinterprets the byte to a different value than the
1985        // resolver's `Path::join` sees — so a `feira tofu` shell-out
1986        // to a `cd '{caminho}'` command line, a `nix flake check`
1987        // invocation on an emitted YAML `path:` scalar folded through
1988        // envsubst, or a `helm template` invocation with a
1989        // `values.yaml` `path: {caminho}` embedded in a `{{`-quoted
1990        // template all disagree with the resolver on which directory
1991        // the value names. Two workstations whose downstream shell /
1992        // envsubst / Nix / Make / K8s-template parsing layers differ
1993        // in `$VAR` recognition (or, worse, expand the byte against
1994        // divergent environments — Alice's `$HOME=/home/alice`, Bob's
1995        // `$HOME=/home/bob`) emit divergent build artifacts for the
1996        // byte-identical caixa.lisp value. Even in the case where the
1997        // resolver strictly does NOT expand `$VAR` (the current
1998        // implementation) the divergence still bites at the lacre-
1999        // identity axis: the lacre pipeline embeds the value verbatim
2000        // in its per-dep content-address (`conteudo:
2001        // format!("path:{caminho}")`, caixa-resolver/src/resolve.rs:189),
2002        // so `path:../foo$HOME/bar` locks a BLAKE3 closure distinct
2003        // from the byte-identical-semantic `path:../foo/home/alice/bar`
2004        // one author would have produced by substituting the literal
2005        // value at author time, defeating the THEORY.md §V.2 render-
2006        // determinism contract on the same axis every prior `:caminho`
2007        // arm protects.
2008        //
2009        // Beyond the render-determinism / host-layout-leak vectors,
2010        // `$` at any position in a value flowing verbatim into a
2011        // shell-spawned subprocess is the canonical CWE-78 shell-
2012        // command-injection surface every peer single-token-shaped
2013        // typed slot already closes. A `:caminho "../foo$(whoami)/bar"`
2014        // that rides into a future `feira tofu` shell-out as `cd
2015        // '../foo$(whoami)/bar'` gets substituted by the shell at
2016        // subprocess-argument-expansion time even inside single quotes
2017        // in fewer positions than one might expect (the substitution
2018        // fires only outside single-quoting per POSIX §2.2.2, but
2019        // eval-style wrappers and `sh -c` layers that route the value
2020        // through re-parsing round-trip the substitution — the same
2021        // vector the c370458 backtick arm closes at the sibling
2022        // command-substitution-legacy-form surface). Every future
2023        // `feira` verb that shells out with a `caminho`-formatted
2024        // subprocess argument silently inherits this substitution
2025        // vector unless the typed slot's accepted set structurally
2026        // excludes the byte.
2027        //
2028        // Frontier inspiration: OTP's `gen_server` return-value grammar
2029        // rejects mid-tuple shell-metachar bytes by construction —
2030        // `{noreply, State}` never carries a raw `$` because the
2031        // Erlang term type system has no notion of "string that gets
2032        // shelled out"; caixa's typed slots inherit the same
2033        // structural discipline (types-are-theorems, the compounding
2034        // mandate's leverage-point-1) by refusing values that would
2035        // silently reinterpret at any downstream layer. Peer with
2036        // Unison's content-addressed code (no ambient environment —
2037        // every reference is a hash, no `$VAR` substitution possible)
2038        // and Pony's capabilities (a path capability that carries a
2039        // `$` would be ill-typed at the reference layer).
2040        //
2041        // The arm fires AFTER the URL-percent-encoding-escape arm (the
2042        // e3558fa `%` arm) because a value carrying both `%` and `$`
2043        // (`"../foo%20$HOME/bar"` — the canonical "I pasted a percent-
2044        // encoded space next to a `$HOME` template") surfaces the
2045        // narrower URL-encoding diagnostic first — the paste-from-
2046        // browser-address-bar shape is the load-bearing self-locating
2047        // edit on every probe-as-both value; same cascade discipline
2048        // every prior `:caminho` arm establishes (a323db8 %  before
2049        // this arm, this arm before trailing-`/`). The arm fires
2050        // BEFORE the trailing-`/` arm because the embedded shell-
2051        // variable-expansion byte is the more semantic-locating axis
2052        // on probe-as-both values (`"../foo$HOME/bar/"` ends in `/`
2053        // but the load-bearing diagnostic is the embedded `$` — the
2054        // trailing `/` is the secondary observation, and an author
2055        // who substitutes the `$HOME` template with a literal value is
2056        // likely to also tab-strip the trailing separator).
2057        for &b in caminho.as_bytes() {
2058            if b == b'$' {
2059                return Err(DepError::fonte_caminho_shell_variable_expansion(
2060                    nome, caminho, b,
2061                ));
2062            }
2063        }
2064        // Reproducibility gate's shell-history-expansion / RFC-3986-sub-delims
2065        // arm. The immediate-predecessor `$` embedded arm closes the shell-
2066        // variable-expansion / command-substitution byte; `!` (`0x21`) is the
2067        // orthogonal POSIX shell-history-expansion sentinel every interactive
2068        // shell with history enabled (bash / ksh / zsh's `bashcompat` /
2069        // csh / tcsh) lexes as the history-expansion prefix: `!command`
2070        // re-runs the most recent history entry beginning with `command`,
2071        // `!!` re-runs the prior command verbatim, `!$` substitutes the
2072        // last word of the prior command, `!:N` substitutes the Nth word,
2073        // `^old^new` rewrites the prior command's `old` to `new` (the
2074        // canonical set of `set -o histexpand` operators bash's default
2075        // interactive session enables). Beyond the shell-history layer,
2076        // RFC 3986 §2.2 lists `!` in the `sub-delims` set (the URL grammar
2077        // admits the byte inside a path segment, but every WHATWG-conformant
2078        // special-scheme URL parser percent-encodes it inside a query
2079        // component via the 'special-query percent-encode set' the peer
2080        // `is_git_repo_url` `*` / `(` / `)` / `'` arms close on); the byte
2081        // is also the C / C++ / Rust / JavaScript / Python bang-operator
2082        // (logical-negation prefix — the paste-from-source-code idiom where
2083        // an author copies `!path.exists()` out of a Rust snippet and the
2084        // trailing punctuation crosses the string-literal boundary); the
2085        // canonical English-typography emphasis / exclamation mark (the
2086        // paste-from-prose enthusiasm-form idiom where an author writes
2087        // `:caminho "../caixa-teia!"` expecting the substrate to coerce it
2088        // to a kebab-case slug); and the Nix flake-ref import-attribute
2089        // `import ./foo.nix { … }` sibling operator surface.
2090        //
2091        // POSIX `std::path::Path` treats `!` as a literal path-component
2092        // byte, so a `:caminho "../caixa-teia!sudo"` (the canonical paste-
2093        // from-shell-history footgun where the author copies a `cd
2094        // ../caixa-teia && !sudo make install` one-liner from a quick-
2095        // start README and the trailing `!sudo` rides in verbatim as a
2096        // history-expansion reference), a `:caminho "../foo!!/bar"` (the
2097        // `!!` repeat-prior-command paste idiom), a `:caminho
2098        // "../caixa-teia!"` (the English-typography enthusiasm-form
2099        // paste-from-prose footgun), or a `:caminho "../foo!$"` (the
2100        // last-word-substitution shape) silently pass every prior arm
2101        // because `Path::is_absolute` returns false on `..`, `!` is neither
2102        // a leading-byte sentinel nor a control byte nor `\` nor `<` / `>`
2103        // nor `|` nor `;` nor `&` nor backtick nor `*` / `?` nor `(` / `)`
2104        // nor `{` / `}` nor `[` / `]` nor `'` / `"` nor `#` nor `%` nor `$`,
2105        // and the value's last byte isn't `/`. The resolver folds the value
2106        // through `Path::new(caminho).join(<file>)` looking for a literal
2107        // `./../caixa-teia!sudo` subdirectory and fails at resolve time
2108        // with a non-self-locating `No such file or directory` error far
2109        // from the source caixa.lisp — while every downstream interactive
2110        // shell with `set -o histexpand` reinterprets the byte as the
2111        // history-expansion prefix, and the failure mode forks per
2112        // consumer: a `feira tofu` shell-out to a `cd '{caminho}'` command
2113        // line executed under `bash -i` (the operator-notebook interactive
2114        // shell) substitutes the `!sudo` reference to the most recent
2115        // history entry starting with `sudo`, silently invoking whatever
2116        // privileged command that entry named.
2117        //
2118        // The lacre pipeline embeds the value verbatim in its per-dep
2119        // content-address (`conteudo: format!("path:{caminho}")`,
2120        // caixa-resolver/src/resolve.rs:189), so the byte lands in the
2121        // BLAKE3 closure and rides into every shell-spawned subprocess
2122        // (the resolver's `git clone`, a future `feira tofu` shell-out,
2123        // a future operator-side `nix flake check` spawn) as the
2124        // canonical shell-history-expansion / RFC-3986-sub-delims surface
2125        // every peer single-token-shaped typed slot already closes. The
2126        // peer `:fonte :repo` axis closes the byte under the same shell-
2127        // history-expansion / RFC-3986-sub-delims banner (7d53c68 `!` on
2128        // `is_git_repo_url`); the `:caminho` axis was the last typed
2129        // path-string surface still admitting the byte. This arm closes
2130        // the gap so the substrate-wide "no shell-composition
2131        // metacharacter / history-expansion sentinel anywhere in a typed
2132        // string slot that flows verbatim into a shell-spawned subprocess"
2133        // invariant extends from shell-variable-expansion (`$`) to shell-
2134        // history-expansion (`!`) on the `:caminho` axis. Together with
2135        // the peer c370458 backtick command-substitution-legacy-form arm
2136        // and the b9d187c-`$`-embedded-variable-expansion arm on the
2137        // sibling `:repo` axis, the typed `:caminho` accepted set now
2138        // structurally excludes every byte the POSIX shell §2.6 Word
2139        // Expansions section, §2.3 Token Recognition step 6, and every
2140        // history-expansion / brace-expansion / pathname-expansion /
2141        // parameter-expansion / command-substitution / arithmetic-
2142        // expansion operator lexes as a first-class parser byte.
2143        //
2144        // Frontier inspiration: Unison's content-addressed code (no
2145        // ambient environment — every reference is a hash, no `!<num>`
2146        // history-index substitution possible; the caixa substrate's
2147        // lacre discipline arrives at the same guarantee by refusing
2148        // bytes at manifest-parse time that would reinterpret against
2149        // ambient shell history state); Pony's capabilities (a path
2150        // capability that carries a `!` would be ill-typed at the
2151        // reference layer).
2152        //
2153        // The arm fires AFTER the shell-variable-expansion arm because a
2154        // value carrying both `$` and `!` (`"../foo$HOME/bar!sudo"` — the
2155        // canonical "I pasted a `$HOME`-templated path adjacent to a
2156        // trailing `!sudo` history-expansion") surfaces the narrower
2157        // shell-variable-expansion diagnostic first — the paste-from-CI-
2158        // manifest-with-`$VAR`-template shape is the load-bearing self-
2159        // locating edit on every probe-as-both value; same cascade
2160        // discipline every prior `:caminho` arm establishes. The arm
2161        // fires BEFORE the trailing-`/` arm because the embedded shell-
2162        // history-expansion byte is the more semantic-locating axis on
2163        // probe-as-both values (`"../foo!sudo/"` ends in `/` but the
2164        // load-bearing diagnostic is the embedded `!` — the trailing `/`
2165        // is the secondary observation, and an author who removes the
2166        // `!sudo` history reference is likely to also tab-strip the
2167        // trailing separator).
2168        for &b in caminho.as_bytes() {
2169            if b == b'!' {
2170                return Err(DepError::fonte_caminho_shell_history_expansion(
2171                    nome, caminho, b,
2172                ));
2173            }
2174        }
2175        // Reproducibility gate's shell-history-substitution / RFC-3986-unwise
2176        // / regex-anchor arm. The immediate-predecessor `!` arm closes the
2177        // POSIX `!command` / `!!` / `!$` history-expansion prefix; `^`
2178        // (`0x5E`) is the paired-operator half of the same bash-reference
2179        // §9.3 histexpand feature — the `^old^new^` "quick substitution"
2180        // form (POSIX bash rewrites the prior command's `old` string to
2181        // `new` and re-executes it, the canonical typo-correction one-
2182        // liner idiom `git clone <bad-url>` → `^bad^good` that pastes the
2183        // trailing substitution fragment verbatim into a `:caminho` value
2184        // when the author trims only the leading `git clone` prefix). The
2185        // peer `:fonte :repo` axis closes the byte under the same
2186        // shell-history-substitution / RFC-3986-unwise banner (49e142f `^`
2187        // on `is_git_repo_url`); the `:caminho` axis was the last typed
2188        // path-string surface still admitting the byte after 6a04767
2189        // landed the `!` arm.
2190        //
2191        // Beyond bash history-substitution, `^` carries five distinct
2192        // downstream-reinterpretation surfaces the typed slot's accepted
2193        // set must structurally exclude:
2194        //
2195        // 1. **RFC 3986 §2 'unwise' set** — the four-byte cross-transport
2196        //    layer set (`{`, `}`, `|`, `\`) plus `^` every URL parser is
2197        //    required to percent-encode-or-refuse at the wire boundary.
2198        //    The WHATWG URL spec's 'fragment percent-encode set' maps
2199        //    `^` → `%5E` at the query / fragment component transition;
2200        //    libcurl silently percent-encodes the byte on the wire, so a
2201        //    `:caminho "../foo^bar"` value the resolver's `Path::join`
2202        //    sees as a literal `./../foo^bar` subdirectory diverges from
2203        //    the byte-transformed `%5E` shape any downstream `feira tofu`
2204        //    curl-invocation or artifact-registry-fetch would emit — the
2205        //    canonical wire-boundary divergence vector the peer
2206        //    `{`, `}`, `|`, `\` `:caminho` arms already close (
2207        //    `FonteCaminhoShellBraceExpansion` at 598b770,
2208        //    `FonteCaminhoShellPipe` at the pipe arm,
2209        //    `FonteCaminhoBackslash` at the backslash arm).
2210        // 2. **Regex character-class negation prefix `[^abc]`** — the
2211        //    canonical paste-from-doc-regex-pipeline footgun where an
2212        //    author copies a `grep '[^abc]'` idiom from a docs quick-
2213        //    listing and the character-class negation byte rides in
2214        //    verbatim.
2215        // 3. **Bitwise XOR operator** in C / C++ / Rust / Python /
2216        //    JavaScript / Nix / Go — the paste-from-source-code idiom
2217        //    where an author copies an `x ^ y`-shaped expression out of
2218        //    a source snippet and the operator crosses the string-
2219        //    literal boundary.
2220        // 4. **Windows `cmd.exe` escape metacharacter** — the byte
2221        //    escapes the next character in a `cmd.exe` batch context (a
2222        //    peer of the backslash arm's Windows-separator-leak vector).
2223        //    A `:caminho "..^&whoami"` cross-platform paste-from-batch-
2224        //    file footgun reinterprets at every `cmd.exe`-spawned
2225        //    subprocess (the resolver's future Windows-runner shell-out,
2226        //    the operator's WinRM path, a future PowerShell-embedded
2227        //    invocation).
2228        // 5. **LaTeX / Markdown / BibTeX superscript operator** — the
2229        //    paste-from-typeset-doc footgun where a mathematical
2230        //    superscript notation (`x^2` / `M^T`) leaks from prose.
2231        //
2232        // POSIX `std::path::Path` treats `^` as a literal path-component
2233        // byte, so `:caminho "../foo^bar/baz"` (embedded quick-
2234        // substitution), `:caminho "../foo^"` (trailing history-
2235        // substitution-open shape), `:caminho "../[^a-z]/foo"` (regex-
2236        // negation-prefix paste from a grep pipeline; note the `[` / `]`
2237        // arm at 986963b fires first on this shape), or `:caminho
2238        // "../x^y"` (XOR-expression paste-from-source) all silently pass
2239        // every prior arm (`^` isn't `\` / `<` / `>` / `|` / `;` / `&` /
2240        // backtick / `*` / `?` / `(` / `)` / `{` / `}` / `[` / `]` / `'`
2241        // / `"` / `#` / `%` / `$` / `!`) and route through
2242        // `Path::new(caminho).join(<file>)` looking for a literal
2243        // `./{caminho}` subdirectory that fails at resolve time with a
2244        // non-self-locating `No such file or directory` error far from
2245        // the source caixa.lisp — while every downstream shell / curl /
2246        // regex / `cmd.exe` layer reinterprets the byte to its own
2247        // semantic.
2248        //
2249        // The lacre pipeline embeds the value verbatim in its per-dep
2250        // content-address (`conteudo: format!("path:{caminho}")`,
2251        // caixa-resolver/src/resolve.rs:189), so the byte lands in the
2252        // BLAKE3 closure and rides into every shell-spawned subprocess
2253        // (the resolver's `git clone`, a future `feira tofu` shell-out,
2254        // a future operator-side `nix flake check` spawn) as the
2255        // canonical shell-history-substitution / RFC-3986-unwise /
2256        // regex-negation surface every peer single-token-shaped typed
2257        // slot already closes. This arm together with the immediate-
2258        // predecessor `!` arm (6a04767) closes the full `set -o
2259        // histexpand` operator surface on the `:caminho` axis — the
2260        // `!command` / `!!` / `!$` prefix form via `!`, the `^old^new^`
2261        // quick-substitution form via `^` — so the substrate-wide "no
2262        // shell-history operator anywhere in a typed string slot that
2263        // flows verbatim into a shell-spawned subprocess" invariant
2264        // extends from the `!` prefix half to the `^` quick-substitution
2265        // half. Every peer bash-history operator now fails at manifest-
2266        // parse time with a self-locating diagnostic naming the offending
2267        // caixa.lisp rather than at resolve-time as a `Path::join`-
2268        // derived `No such file or directory` (harmless but non-self-
2269        // locating) or worse riding into a downstream `bash -i` context
2270        // that reinterprets the byte-pair against ambient history state.
2271        //
2272        // Frontier inspiration: bash reference §9.3 HISTORY EXPANSION
2273        // "Quick substitution. Repeat the previous command, replacing
2274        // string1 with string2." + RFC 3986 §2 'unwise' set
2275        // ("characters that gateways and other transport agents are
2276        // known to sometimes modify") + Pony's capabilities (a path
2277        // capability that carries a `^` would be ill-typed at the
2278        // reference layer, matching the same structural discipline the
2279        // sibling `!` history-expansion arm inherits from Unison's
2280        // content-addressed no-ambient-history discipline).
2281        //
2282        // The arm fires AFTER the shell-history-expansion `!` arm because
2283        // a value carrying both `!` and `^` (`"../foo!sudo^bad^good"` —
2284        // the canonical "I pasted a `!sudo` history-reference next to a
2285        // `^bad^good` quick-substitution") surfaces the narrower prefix-
2286        // form `!` diagnostic first — the `!` form is the load-bearing
2287        // self-locating edit on every probe-as-both value (an author who
2288        // removes the `!sudo` reference is likely to also strip the
2289        // paired `^` substitution fragment); same cascade discipline
2290        // every prior `:caminho` arm establishes. The arm fires BEFORE
2291        // the trailing-`/` arm because the embedded shell-history-
2292        // substitution byte is the more semantic-locating axis on
2293        // probe-as-both values (`"../foo^bar/"` ends in `/` but the
2294        // load-bearing diagnostic is the embedded `^` — the trailing `/`
2295        // is the secondary observation, and an author who removes the
2296        // `^bar` substitution fragment is likely to also tab-strip the
2297        // trailing separator).
2298        for &b in caminho.as_bytes() {
2299            if b == b'^' {
2300                return Err(DepError::fonte_caminho_shell_history_substitution(
2301                    nome, caminho, b,
2302                ));
2303            }
2304        }
2305        // Reproducibility gate's trailing-`/` arm. The b94fd83 absolute arm
2306        // closes the leading-`/` host-layout-leak; the embedded-control-byte
2307        // arm closes any byte-in-the-`0x00..=0x1F` / `0x7F` range; the
2308        // backslash arm closes the cross-host-OS-separator vector. The
2309        // trailing-`/` is the orthogonal shell-tab-completion-on-a-directory
2310        // footgun — `Path::join("../caixa-teia")` and
2311        // `Path::join("../caixa-teia/")` resolve to the same directory
2312        // (POSIX path-component-walk treats trailing `/` as a no-op for
2313        // directory targets, which `:caminho` always names — the sibling-
2314        // workspace dep root is structurally a directory). The lacre
2315        // pipeline embeds the value verbatim in its per-dep content-address
2316        // (`conteudo: format!("path:{caminho}")`,
2317        // caixa-resolver/src/resolve.rs:189), so byte-identical caixa
2318        // semantic-meaning yields two distinct BLAKE3 closures depending on
2319        // whether the author shell-tab-completed the path (every interactive
2320        // shell appends `/` on tab-completing a directory, idiomatic in
2321        // bash / zsh / fish / nushell), pasted from `pwd` (which on most
2322        // shells emits without trailing `/`, but `realpath -e -m` on a
2323        // directory with trailing `/` preserves it), or copied a Cargo
2324        // `path = "../caixa-teia/"` entry from cross-substrate documentation
2325        // (Cargo accepts both shapes and folds them the same way). Two
2326        // workstations whose authors differ only in tab-completion habits
2327        // emit byte-divergent lacres for the byte-identical-semantic caixa,
2328        // and the substrate's "the lacre is the build's identity" contract
2329        // (CAIXA-SDLC §III.2) silently breaks far from the source caixa.lisp.
2330        //
2331        // Same THEORY.md §V.2 render-determinism axis every prior `:caminho`
2332        // arm protects, here against the trailing-separator divergence
2333        // vector: every typed slot's accepted set excludes byte-divergent
2334        // values that round-trip to the same downstream semantic. The peer
2335        // path-shaped axes already reject trailing separators on the same
2336        // contract: [`crate::render::is_gateway_api_http_path`] gates
2337        // `:entrada :paths` against any non-canonical normalization, and
2338        // [`crate::render::is_sandboxed_relative_path`] gates the M2 typed
2339        // path-slots (`:behavior :on-*`, `:upgrade-from :state-change
2340        // :script`, `:bibliotecas`, `:exe`, `:servicos`) against shapes
2341        // whose canonical form would re-introduce determinism divergence.
2342        //
2343        // The arm fires last in the cascade because every prior arm carries
2344        // a more self-locating diagnostic on values that probe as both
2345        // (e.g. `:caminho "../foo/\0/"` ends in `/` but the load-bearing
2346        // diagnostic is the NUL byte's POSIX-syscall-rejection — the
2347        // control-char arm wins; `:caminho "/etc/passwd/"` ends in `/` but
2348        // the load-bearing diagnostic is the absolute host-layout-leak —
2349        // the absolute arm wins; `:caminho "..\caixa-teia/"` ends in `/`
2350        // but the load-bearing diagnostic is the Windows-separator cross-
2351        // OS divergence — the backslash arm wins). The arm covers every
2352        // shape where the last byte is `/` regardless of length, including
2353        // the degenerate single-`/` (which the absolute arm catches first)
2354        // and the consecutive-`//` (where every prior arm passes on the
2355        // bytes other than the trailing `/`).
2356        if caminho.as_bytes().last() == Some(&b'/') {
2357            return Err(DepError::fonte_caminho_trailing_slash(nome, caminho));
2358        }
2359        Ok(())
2360    }
2361}
2362
2363impl Dep {
2364    /// Substrate-canonical per-`:deps` / `:deps-dev` entry `:nome` scalar
2365    /// accessor every consumer of the dep-graph identity axis keys off —
2366    /// returns the author-declared `:nome` byte-string verbatim as a
2367    /// `&str`, borrowed from the typed slot's own [`String`] storage.
2368    ///
2369    /// The `:deps :nome` / `:deps-dev :nome` slot carries the DNS-1123
2370    /// label that names the target caixa (validated by [`Self::validate`]
2371    /// through the shared [`crate::render::is_dns_1123_label`] predicate,
2372    /// same accept-set the peer caixa-identifier axes carry — top-level
2373    /// [`crate::Caixa::nome`], per-`:membros` [`crate::Membro::nome`],
2374    /// per-`:children` [`crate::supervisor::ChildSpec::nome`]). Every
2375    /// downstream consumer that fans on the dep's name-identity keys off
2376    /// this scalar: the [`crate::Caixa::validate_deps`] per-list
2377    /// [`crate::render::insert_first_seen`] dedup key + the paired
2378    /// [`DepError::DuplicateNome`] carrier the walk raises on collision,
2379    /// the cross-list [`validate_no_self_dep`] parent-name equality gate
2380    /// on both `:deps` and `:deps-dev` traversals, the `caixa-resolver`
2381    /// pipeline's `HashSet<String>` seen-set the closure walker gates
2382    /// requeueing off (`caixa-resolver/src/resolve.rs:55`), the resolver's
2383    /// per-transitive-target requeue path (`resolve.rs:63,66`), the
2384    /// [`crate::DepSource::default_github`]-shaped resolver-side shorthand
2385    /// fill-in that folds `:nome` into the fetched-git-URL (`resolve.rs:147`),
2386    /// every `caixa-resolver` `ResolveError::MissingPath` /
2387    /// `ResolveError::MissingPin` carrier that names the offending dep
2388    /// (`resolve.rs:177,206`), each resolved
2389    /// `caixa-lacre::LacreEntry` `nome:` field the closure hash keys off
2390    /// (`resolve.rs:108,113`), and the peer `feira lock` stub-resolver's
2391    /// `LacreEntry` emitter (`caixa-feira/src/cmd/lock.rs:59,61,64`).
2392    ///
2393    /// Prior to this lift the `.nome` byte-string was read inline at every
2394    /// production site — the [`crate::Caixa::validate_deps`] paired
2395    /// `dep.nome.as_str()` / `dep.nome.clone()` accesses on both `:deps`
2396    /// and `:deps-dev` traversals, the [`validate_no_self_dep`] pair of
2397    /// parent-equality checks, and every caixa-resolver / caixa-feira
2398    /// site enumerated above — open-coded field-accesses that expressed
2399    /// no compile-time link back to the typed slot. A future extension of
2400    /// the `:deps :nome` axis to a richer author surface (a per-scope
2401    /// alias table the resolver folds through the `~/.config/caixa/config.yaml`
2402    /// entry the [`crate::dep::Dep`] docstring already acknowledges, a
2403    /// namespace-qualified rewrite the future M4 lacre-federation layer
2404    /// applies per-cluster, a promotion of the plain [`String`] byte-string
2405    /// to a richer scoped-identifier newtype once cross-registry federation
2406    /// lands) would have had to be threaded through every open-coded copy
2407    /// in lockstep or two consumers would silently disagree on which caixa
2408    /// a given dep resolves to — the [`crate::Caixa::validate_deps`] dedup
2409    /// set treating the name as `"caixa-teia"` while the caixa-resolver
2410    /// closure walker treated it as `"tenant-a/caixa-teia"` would silently
2411    /// split the [`DepError::DuplicateNome`] refusal from the resolver's
2412    /// requeue-suppression seen-set, one build-time diagnostic
2413    /// disagreeing with the run-time closure the substrate's lacre
2414    /// pipeline actually materializes. Lifting the resolution rule to a
2415    /// typed method on the substrate primitive means every downstream
2416    /// consumer of the caixa's per-`:deps` identity surface reaches for
2417    /// exactly one typed dispatch — the resolver's accept-set migrates as
2418    /// a unit on any future axis addition.
2419    ///
2420    /// First accessor on the outer `Dep` type — opens the outer-`Dep`
2421    /// `&str`-return required-scalar projection pattern the sibling
2422    /// per-`Dep` `:versao` future lift folds on. Peer of the sibling
2423    /// per-`:membros` [`crate::Membro::nome`] (4a32abf) /
2424    /// per-`:children` [`crate::supervisor::ChildSpec::nome`] (dfb4a81)
2425    /// / top-level [`crate::Caixa::nome`] (e6b7d97) caixa-identity scalar
2426    /// accessors — same "one typed dispatch on the substrate primitive,
2427    /// thin projections at each consumer" discipline extended onto the
2428    /// third named-caixa-referencing axis (`:deps` / `:deps-dev`), the
2429    /// remaining unlifted caixa-name-referencing accessor family in the
2430    /// substrate. Named `nome()` to match the tatara-lisp author-surface
2431    /// term the field's docstring already reaches for ("Caixa name — must
2432    /// match the target caixa's `:nome`") and the peer caixa-identity
2433    /// accessor family the substrate already carries.
2434    #[must_use]
2435    pub const fn nome(&self) -> &str {
2436        self.nome.as_str()
2437    }
2438
2439    /// Substrate-canonical per-`:deps` / `:deps-dev` entry `:versao`
2440    /// Cargo-shaped semver-requirement scalar accessor every consumer of
2441    /// the dep-graph version-pin axis keys off — returns the author-
2442    /// declared `:versao` requirement byte-string verbatim as a `&str`,
2443    /// borrowed from the typed slot's own [`String`] storage.
2444    ///
2445    /// The `:deps :versao` / `:deps-dev :versao` slot carries the
2446    /// Cargo-shaped semver requirement string (`"^0.1"`, `"~0.1.2"`,
2447    /// `"0.1.0"`, `"*"`) the shared [`crate::version::parse_requirement`]
2448    /// entry-point consumes — same accept-set the peer requirement-
2449    /// carrying axes carry (per-`:membros`
2450    /// [`crate::Membro::versao_requirement`], per-`:children`
2451    /// [`crate::supervisor::ChildSpec::versao_requirement`]), validated
2452    /// through the shared
2453    /// [`crate::render::require_valid_versao_requirement`] cascade in
2454    /// [`Self::validate`]. Every downstream consumer that fans on the
2455    /// dep's version-pin keys off this scalar: the [`Self::validate`]
2456    /// `require_valid_versao_requirement` gate + the paired
2457    /// [`DepError::VersaoInvalid`] carrier the cascade raises on
2458    /// requirement-shape rejection, the `feira lock` stub-resolver's
2459    /// `format!("{}@{}", dep.nome(), dep.versao_requirement())`
2460    /// `conteudo` hash-input interpolation and the paired
2461    /// `LacreEntry.versao:` `String`-carry fill (`caixa-feira/src/cmd/lock.rs`),
2462    /// and the peer `feira lock` end-to-end fixture in `caixa-feira/tests/feira_e2e.rs`.
2463    ///
2464    /// Prior to this lift the `.versao` byte-string was read inline at
2465    /// every production site — the [`Self::validate`] paired
2466    /// `&self.versao` requirement-gate reference and `self.versao.clone()`
2467    /// error-body carrier, the `caixa-feira/src/cmd/lock.rs` paired
2468    /// `format!("{}@{}", dep.nome(), dep.versao)` `conteudo` interpolation
2469    /// and `versao: dep.versao.clone()` `LacreEntry` fill, and the
2470    /// `caixa-feira/tests/feira_e2e.rs` end-to-end fixture's pair of the
2471    /// same shapes — open-coded field-accesses that expressed no
2472    /// compile-time link back to the typed slot. A future extension of
2473    /// the `:deps :versao` axis to a richer author surface (a per-scope
2474    /// version-lock overlay the resolver folds through the
2475    /// `~/.config/caixa/config.yaml` entry the [`crate::dep::Dep`]
2476    /// docstring already acknowledges, a per-cluster canary-version
2477    /// overlay per MESH-COMPOSITION §III.2, a promotion of the plain
2478    /// [`String`] requirement to a richer parsed-`VersionReq` newtype
2479    /// once cross-registry federation lands) would have had to be
2480    /// threaded through every open-coded copy in lockstep or two
2481    /// consumers would silently disagree on which release constraint a
2482    /// given dep resolves to — the [`Self::validate`] requirement-gate
2483    /// call reading `"^0.1"` while the `feira lock` stub-resolver's
2484    /// `conteudo` hash-input read `"tenant-a-pin/^0.1"` would silently
2485    /// split the [`DepError::VersaoInvalid`] refusal from the lacre's
2486    /// content-addressed hash the substrate's fetch pipeline actually
2487    /// materializes, one build-time diagnostic disagreeing with the
2488    /// run-time closure. Lifting the resolution rule to a typed method
2489    /// on the substrate primitive means every downstream consumer of
2490    /// the caixa's per-`:deps` version-pin surface reaches for exactly
2491    /// one typed dispatch — the resolver's accept-set migrates as a
2492    /// unit on any future axis addition.
2493    ///
2494    /// Second accessor on the outer `Dep` type — folds on the outer-
2495    /// `Dep` `&str`-return required-scalar projection pattern the
2496    /// sibling per-`Dep` [`Self::nome`] (eba2cde) accessor opened. Peer
2497    /// of the per-`:membros` [`crate::Membro::versao_requirement`]
2498    /// (a40b0e3) / per-`:children`
2499    /// [`crate::supervisor::ChildSpec::versao_requirement`] (7844f4e
2500    /// family) member/child version-pin accessors — the three
2501    /// requirement-carrying axes (`Dep::versao_requirement` on the
2502    /// per-caixa dep-graph edge, `Membro::versao_requirement` on the M3
2503    /// Aplicacao side, `ChildSpec::versao_requirement` on the M2
2504    /// Supervisor side) now share one accessor discipline for the
2505    /// shared substrate concept "another caixa referenced by a
2506    /// Cargo-shaped semver requirement". The pair
2507    /// `(nome(), versao_requirement())` jointly projects the
2508    /// `(nome, versao)` field pair every dep-graph consumer that fans
2509    /// on per-dep identity + version pin keys off. Named
2510    /// `versao_requirement()` rather than `versao()` because the field's
2511    /// storage-side `.versao` label is already the author-surface term
2512    /// (`:versao`); the accessor's name carries the semantic role — the
2513    /// semver *requirement* string the shared
2514    /// [`crate::version::parse_requirement`] entry-point consumes — so a
2515    /// raw field access and a typed dispatch read differently at every
2516    /// consumer site. Matches the peer
2517    /// [`crate::Membro::versao_requirement`] /
2518    /// [`crate::supervisor::ChildSpec::versao_requirement`] naming
2519    /// discipline verbatim.
2520    #[must_use]
2521    pub const fn versao_requirement(&self) -> &str {
2522        self.versao.as_str()
2523    }
2524
2525    /// Substrate-canonical per-`:deps` / `:deps-dev` entry `:fonte`
2526    /// Zig-store-model per-dep source-tuple optional-composite-reference
2527    /// accessor every consumer of the dep-graph fetch-source axis keys
2528    /// off — returns the author-declared `:fonte` typed [`DepSource`]
2529    /// verbatim as an `Option<&DepSource>` borrowed from the typed slot's
2530    /// own `Option<DepSource>` storage, with `None` naming the "author
2531    /// omitted `:fonte`" shorthand every resolver-side default-fill
2532    /// (`caixa-feira/src/cmd/lock.rs`'s stub, `caixa-resolver/src/resolve.rs`'s
2533    /// canonical fetcher, per the [`DepSource::default_github`] fallback
2534    /// the [`Dep::fonte`] field docstring already documents) treats as
2535    /// the "resolve through the configured default host / org
2536    /// (`github:<default-org>/<nome>`)" partition.
2537    ///
2538    /// The `:deps :fonte` / `:deps-dev :fonte` slot carries the two-
2539    /// arm typed [`DepSource`] the `Zig-style git-only store model` the
2540    /// enclosing [`Dep`] docstring names — `DepSource::Git { repo, tag,
2541    /// rev, branch }` for the git-clone arm every published caixa
2542    /// resolves through, `DepSource::Path { caminho }` for the dev-only
2543    /// local-filesystem arm every unpublishable in-tree checkout
2544    /// resolves through. Every downstream consumer that fans on the
2545    /// dep's fetch-source keys off this accessor: [`Self::validate`]'s
2546    /// per-`:fonte` [`DepSource::validate`] delegation (which raises
2547    /// the empty-`:repo` / missing-pin / multiple-pin / empty-`:caminho`
2548    /// diagnostics through the [`DepError::Fonte*`] carrier family
2549    /// naming the offending `Dep::nome`), the caixa-crd conversion
2550    /// crate's `dep_into_ref` two-arm projection into the `CaixaSource`
2551    /// `{repo, git_ref}` pair the K8s-CR side consumes
2552    /// (`caixa-crd/src/conversion.rs`), and — through the paired
2553    /// resolver-side default-fill's `Option::unwrap_or_else` — every
2554    /// `caixa-feira` / `caixa-resolver` fetch site that requires a
2555    /// concrete `DepSource` at run time.
2556    ///
2557    /// Prior to this lift the `.fonte` typed slot was read inline at
2558    /// every production site — the [`Self::validate`]
2559    /// `if let Some(ref fonte) = self.fonte` bracket the per-`:fonte`
2560    /// gate delegates through, the caixa-crd `dep_into_ref`
2561    /// `d.fonte.as_ref().and_then(...)` two-arm `CaixaSource` projector,
2562    /// the resolver-side `caixa-feira/src/cmd/lock.rs` / `caixa-resolver/src/resolve.rs`
2563    /// `dep.fonte.clone().unwrap_or_else(...)` default-fill pair — open-
2564    /// coded field-accesses that expressed no compile-time link back to
2565    /// the typed slot. A future extension of the `:deps :fonte` axis
2566    /// to a richer author surface (a per-scope source-override table
2567    /// the resolver folds through the `~/.config/caixa/config.yaml`
2568    /// entry the [`Dep`] docstring already acknowledges, a per-org
2569    /// mirror-fallback list the future M4 lacre-federation resolver
2570    /// consults ahead of the `default_github` fallback, a promotion of
2571    /// the plain `Option<DepSource>` to a richer
2572    /// `{primary, mirrors, integrity}` triple once cross-registry
2573    /// federation lands, a per-dep `sri:sha256-…` integrity slot the
2574    /// M4 lacre gate binds against ahead of the git-fetch) would have
2575    /// had to be threaded through every open-coded copy in lockstep or
2576    /// two consumers would silently disagree on which fetch source a
2577    /// given dep resolves to — the [`Self::validate`] per-`:fonte`
2578    /// gate reading the author-declared source while the caixa-crd
2579    /// projector read a per-scope-override-resolved source would
2580    /// silently split the build-time refusal from the CR the
2581    /// substrate's admission pipeline actually materializes, one
2582    /// build-time diagnostic disagreeing with the run-time closure.
2583    /// Lifting the resolution rule to a typed method on the substrate
2584    /// primitive means every downstream consumer of the caixa's per-
2585    /// `:deps` fetch-source surface reaches for exactly one typed
2586    /// dispatch — the resolver's accept-set migrates as a unit on any
2587    /// future axis addition.
2588    ///
2589    /// First outer-`Dep` `Option<&Composite>`-return composite-reference
2590    /// accessor — opens the outer-`Dep` `Option<&Composite>` composite-
2591    /// reference projection pattern the sibling per-`Dep` `:opcional`
2592    /// (`Option<Copy>` — the plain-bool axis) / `:caracteristicas`
2593    /// (`&[String]` — the feature-flag list) future outer scalar / slice
2594    /// lifts fold on. Peer of the outer-top-level [`crate::Caixa`]
2595    /// `Option<&Composite>` composite-reference sub-family the
2596    /// [`crate::Caixa::limits`] (b2bd9d7) / [`crate::Caixa::behavior`]
2597    /// (35d8b52) / [`crate::Caixa::politicas`] (5d23d29) /
2598    /// [`crate::Caixa::placement`] (4fb8074) / [`crate::Caixa::entrada`]
2599    /// (e4128e4) accessors already close on the outer [`crate::Caixa`]
2600    /// altitude, and of the outer M3 mesh-slot [`crate::AplicacaoSpec`]
2601    /// altitude the sibling [`crate::AplicacaoSpec::entrada`] (d32111c)
2602    /// accessor already carries — extends that "one typed dispatch on
2603    /// the substrate primitive, thin projections at each consumer"
2604    /// discipline onto the third outer typed-slot altitude that carries
2605    /// an `Option<Composite>` axis (`Dep`, the outer per-dep-list-entry
2606    /// slot). Returns `Option<&DepSource>` (not the owning composite by
2607    /// copy or clone) because every downstream consumer of the fonte
2608    /// composite treats it as a read-only per-arm dispatch source — the
2609    /// reference-view is the narrowest borrow that supports every
2610    /// present + roadmapped consumer (per-arm match projection at the
2611    /// caixa-crd `CaixaSource` two-arm emitter, presence-probe early
2612    /// return on the "author-omitted `:fonte` ⇒ resolver-side
2613    /// `default_github` fill applies" partition every resolver
2614    /// consults, `.cloned()`-on-demand for the two resolver-side
2615    /// default-fill call sites that require an owned `DepSource` for
2616    /// `Option::unwrap_or_else`) without cloning the composite through
2617    /// every consumer's fast path. The `Option` half of the return-type
2618    /// preserves the load-bearing "author-omitted `:fonte` ⇒ resolver-
2619    /// side default applies" partition (not a default composite the
2620    /// downstream must reject on emptiness) — the accessor projects the
2621    /// raw `Option<DepSource>` slot's presence bit through the
2622    /// reference-return unchanged. Named `fonte()` to match the storage
2623    /// field's name verbatim and the tatara-lisp author-surface term
2624    /// (`:fonte`) the field's own docstring already carries.
2625    ///
2626    /// Declared `pub const fn` — the body projects through
2627    /// `Option::<DepSource>::as_ref`, const-stable since Rust 1.83 and
2628    /// well within the workspace MSRV, so every downstream `const`-
2629    /// context consumer of the per-`Dep` `:fonte` composite-reference
2630    /// accessor reaches through the same typed dispatch on the
2631    /// substrate primitive at const-eval time as at runtime. The
2632    /// paired [`dep_outer_accessor_family_is_const_fn`][pin] pin
2633    /// (a `const fn <name>_via_const_fn(d: &Dep) -> …` wrapper family
2634    /// that forwards through each lifted accessor) locks the posture
2635    /// load-bearing at caixa-core build time — any future accidental
2636    /// downgrade to non-`const` fails the wrapper with E0015
2637    /// (`cannot call non-const method`), strictly stronger than a
2638    /// runtime `assert!` and side-stepping the destructor-in-const
2639    /// restriction the `Dep` fixture's `String` / `Option<DepSource>`
2640    /// / `Vec<String>` carriers rule out. Peer of the sibling per-
2641    /// `WitContract` pre-projection accessor family's `const`-eval-
2642    /// surface pass (279823b) and of the outer-`Caixa` slice-return
2643    /// accessor family's parallel pass (231a968) — same "one canonical
2644    /// dispatch per axis, `const`-eval posture pinned at the substrate
2645    /// primitive, thin projections at each consumer" discipline
2646    /// extended onto the outer per-dep-list-entry [`Dep`] altitude.
2647    ///
2648    /// [pin]: tests::dep_outer_accessor_family_is_const_fn
2649    #[must_use]
2650    pub const fn fonte(&self) -> Option<&DepSource> {
2651        self.fonte.as_ref()
2652    }
2653
2654    /// Substrate-canonical per-`:deps` / `:deps-dev` entry
2655    /// `:caracteristicas` Cargo-shaped feature-toggle-set slice accessor
2656    /// every consumer of the dep-graph feature-flag axis keys off —
2657    /// returns the author-declared `:caracteristicas` feature-name list
2658    /// verbatim as a `&[String]` slice-view over the same backing buffer
2659    /// the raw `self.caracteristicas.as_slice()` field access borrows
2660    /// from. Empty-list-carrying (`:caracteristicas` is a default-empty
2661    /// axis every `Dep` supplies with `Vec::new()` when the author omits
2662    /// the slot; the [`crate::Caixa::from_lisp`] derive folds an omitted
2663    /// `:caracteristicas` through `#[serde(default)]` to `Vec::new()`,
2664    /// so a `Dep` past parse definitionally carries a `Vec<String>` slot
2665    /// — possibly empty — and the returned `&[String]` degenerates to
2666    /// an empty slice on that arm without any silent `None` collapse).
2667    ///
2668    /// The `:deps :caracteristicas` / `:deps-dev :caracteristicas` slot
2669    /// carries the set-shaped feature-toggle list the substrate walks
2670    /// through the [`Self::validate_caracteristicas`] per-entry shape +
2671    /// duplicate cascade — same Cargo `[dependencies.<dep>.features]`
2672    /// accept-set (per-entry Cargo-feature-name grammar via the shared
2673    /// [`crate::render::is_cargo_feature_name`] predicate, cross-entry
2674    /// uniqueness via the shared [`crate::render::insert_first_seen`]
2675    /// walk, empty-first / value-shape-second / duplicate-third
2676    /// precedence via the peer per-axis two-arm cascade discipline every
2677    /// substrate-blessed Vec-keyed-by-name slot already follows).
2678    /// Every downstream consumer that fans on the dep's feature-toggle
2679    /// keys off this accessor: [`Self::validate_caracteristicas`]'s
2680    /// per-entry linear walk that gates each feature-name byte-string
2681    /// through the empty / value-shape / duplicate arms (raising the
2682    /// [`DepError::CaracteristicaEmpty`] / [`DepError::CaracteristicaInvalid`]
2683    /// / [`DepError::CaracteristicaDuplicate`] carrier family naming the
2684    /// offending `Dep::nome`), and every future
2685    /// per-`Caixa`-manifest / caixa-resolver / caixa-crd feature-toggle-
2686    /// facing consumer the CAIXA-SDLC §I roadmap acknowledges (the
2687    /// future caixa-resolver per-dep feature-projection walk that folds
2688    /// the toggle set into the resolved [`crate::Caixa`]'s activated
2689    /// [`crate::render::CARGO_FEATURE_NAME_MAX_LEN`]-bounded feature
2690    /// closure ahead of the lacre hash, the future caixa-crd per-`spec.deps`
2691    /// features slice the K8s-CR admission gate consumes, the future
2692    /// per-cluster feature-overlay the M4 lacre-federation resolver
2693    /// composes ahead of the substrate-wide feature-name accept-set).
2694    ///
2695    /// Prior to this lift the `.caracteristicas` byte-string list was
2696    /// read inline at the [`Self::validate_caracteristicas`] `for c in
2697    /// &self.caracteristicas` walk — the only in-crate consumer of the
2698    /// raw field beyond the per-`Dep` constructor pair
2699    /// ([`Self::simple`] / [`Self::git`]) and the paired serde
2700    /// round-trip / per-test fixture-mutation paths — an open-coded
2701    /// field-access that expressed no compile-time link back to the
2702    /// typed slot. A future extension of the `:caracteristicas` axis to
2703    /// a richer author surface (a per-scope feature-overlay the resolver
2704    /// folds through the `~/.config/caixa/config.yaml` entry the
2705    /// [`Dep`] docstring already acknowledges, a per-cluster feature-
2706    /// activation overlay the future M4 lacre-federation layer applies
2707    /// per-CR, a promotion of the plain `Vec<String>` byte-string list
2708    /// to a richer parsed-feature-set newtype once the Cargo-shaped
2709    /// namespaced-dep `dep/feat` syntax the value-shape gate's
2710    /// docstring anticipates lands) would have had to be threaded
2711    /// through every open-coded copy in lockstep or two consumers
2712    /// would silently disagree on which feature closure a given dep
2713    /// activates — the [`Self::validate_caracteristicas`] gate walking
2714    /// the author-declared list while a downstream caixa-resolver
2715    /// consumer walked a per-scope-override-resolved list would
2716    /// silently split the build-time refusal from the lacre closure
2717    /// the substrate's fetch pipeline actually materializes, one
2718    /// build-time diagnostic disagreeing with the run-time closure.
2719    /// Lifting the resolution rule to a typed method on the substrate
2720    /// primitive means every downstream consumer of the caixa's per-
2721    /// `:deps` feature-toggle surface reaches for exactly one typed
2722    /// dispatch — the resolver's accept-set migrates as a unit on any
2723    /// future axis addition.
2724    ///
2725    /// First outer-`Dep` `&[T]`-return slice accessor — opens the
2726    /// outer-`Dep` `&[String]` slice projection pattern the sibling
2727    /// per-`Dep` `:opcional` (`bool` — the plain-`Copy`-scalar axis)
2728    /// future outer scalar lift folds on and closes the outer-`Dep`
2729    /// slot-family the sibling [`Self::nome`] (eba2cde) /
2730    /// [`Self::versao_requirement`] (05529b1) / [`Self::fonte`] (d65d1bf)
2731    /// accessors already open, leaving the `:opcional` `Copy`-scalar arm
2732    /// as the sole remaining unlifted outer-`Dep` slot. Peer of the
2733    /// outer top-level [`crate::Caixa`] `&[String]`-return foreign-code-
2734    /// slot sub-family ([`crate::Caixa::bibliotecas`] 8a36c23,
2735    /// [`crate::Caixa::exe`] 65d9527, [`crate::Caixa::servicos`]
2736    /// 611f78b) and the outer top-level [`crate::Caixa`] universal-axis
2737    /// text-tag family ([`crate::Caixa::autores`] b5d813f,
2738    /// [`crate::Caixa::etiquetas`] 78c7d3c) that already carry the
2739    /// `&[String]` slice-projection discipline on the outer-`Caixa`
2740    /// altitude — extends the "one typed dispatch on the substrate
2741    /// primitive, thin projections at each consumer" discipline onto the
2742    /// outer per-dep-list-entry [`Dep`] altitude's set-shaped byte-
2743    /// string list slot. Returns `&[String]` (not `&Vec<String>`)
2744    /// because every downstream consumer of the feature-toggle list
2745    /// treats it as a read-only sequence — the slice-view is the
2746    /// narrowest borrow that supports every present + roadmapped
2747    /// consumer (`.iter()`, `.len()`, `.is_empty()`) without leaking
2748    /// the backing `Vec`'s grow/push/reserve surface no consumer of
2749    /// the typed view reaches for (the storage-side `Vec` remains
2750    /// reachable through the `pub caracteristicas` field for the
2751    /// mutation-carrying serde round-trip and per-test fixture-mutation
2752    /// paths). Named `caracteristicas()` to match the storage field's
2753    /// name verbatim and the tatara-lisp author-surface term
2754    /// (`:caracteristicas`) the field's own docstring already carries.
2755    ///
2756    /// Declared `pub const fn` — the body projects through
2757    /// `Vec::<String>::as_slice`, const-stable since Rust 1.83 and
2758    /// well within the workspace MSRV, so every downstream `const`-
2759    /// context consumer of the per-`Dep` `:caracteristicas` slice-
2760    /// accessor reaches through the same typed dispatch on the
2761    /// substrate primitive at const-eval time as at runtime. Pinned
2762    /// load-bearing by the paired
2763    /// [`dep_outer_accessor_family_is_const_fn`][pin] wrapper family
2764    /// alongside its sibling [`Self::fonte`] — see [`Self::fonte`] for
2765    /// the full pin-shape rationale.
2766    ///
2767    /// [pin]: tests::dep_outer_accessor_family_is_const_fn
2768    #[must_use]
2769    pub const fn caracteristicas(&self) -> &[String] {
2770        self.caracteristicas.as_slice()
2771    }
2772
2773    /// Substrate-canonical per-`:deps` / `:deps-dev` entry `:opcional`
2774    /// missing-source-tolerance flag scalar accessor every consumer of
2775    /// the dep-graph opt-in-fetch axis keys off — returns the author-
2776    /// declared `:opcional` `bool` verbatim, `Copy`-projected from the
2777    /// typed slot's own `bool` storage (no borrow of `&self` past the
2778    /// call; the `Copy`-return arm matches the peer
2779    /// [`crate::Caixa::max_restarts`] (eba5211) `Option<u32>` `Copy`-
2780    /// projected sibling discipline the outer flat-spread family
2781    /// already carries). Default-`false` (`#[serde(default,
2782    /// skip_serializing_if = "is_false")]` on the storage slot, so a
2783    /// `Dep` past parse definitionally carries a `bool` — `false` when
2784    /// the author omits `:opcional` — and the returned value degenerates
2785    /// to `false` on that arm without any silent `None` collapse).
2786    ///
2787    /// The `:deps :opcional` / `:deps-dev :opcional` slot carries the
2788    /// per-entry "if this dep's `:fonte` cannot be resolved, treat the
2789    /// missing-source arm as a soft-fail rather than a build refusal"
2790    /// bit — the same Cargo-shaped `[dependencies.<dep>.optional = true]`
2791    /// accept-set (an opcional dep whose `:fonte` fails to resolve is
2792    /// dropped from the resolved dep-graph rather than tripping the
2793    /// build-refusal edge that a mandatory `:opcional false` entry
2794    /// would). Every downstream consumer that fans on the dep's
2795    /// missing-source-tolerance keys off this accessor: the future
2796    /// caixa-resolver's per-`:fonte` resolve-fail arm (drop-vs-error
2797    /// dispatch on the opcional bit ahead of the lacre closure
2798    /// materialization), the future caixa-crd per-`spec.deps`
2799    /// `optional` boolean the K8s-CR admission gate consumes on the
2800    /// per-dep partition, and the future feira / caixa-resolver /
2801    /// caixa-crd feature-projection walk that folds the opcional bit
2802    /// into the resolved feature-closure the future M4 lacre-federation
2803    /// layer emits.
2804    ///
2805    /// Prior to this lift the `.opcional` `bool` slot was read inline
2806    /// at the sole in-crate consumer site — the tests-module
2807    /// `registry_dep_is_minimal` fixture's `assert!(!d.opcional)` gate
2808    /// pinning the [`Self::simple`] constructor's default-`false` fill
2809    /// (the only in-crate read of the raw field beyond the per-`Dep`
2810    /// constructor pair [`Self::simple`] / [`Self::git`] and the paired
2811    /// serde round-trip / per-test fixture-mutation paths) — an open-
2812    /// coded field-access that expressed no compile-time link back to
2813    /// the typed slot. A future extension of the `:opcional` axis to a
2814    /// richer author surface (a per-scope opcional-override the resolver
2815    /// folds through the `~/.config/caixa/config.yaml` entry the [`Dep`]
2816    /// docstring already acknowledges, a per-cluster opcional-override
2817    /// the future M4 lacre-federation layer applies per-CR, a promotion
2818    /// of the plain `bool` to a richer `OpcionalPolicy { drop, warn,
2819    /// error }` tri-state once the CAIXA-SDLC §II opcional-policy
2820    /// roadmap lands) would have had to be threaded through every open-
2821    /// coded copy in lockstep or two consumers would silently disagree
2822    /// on which missing-source arm a given dep resolves to — the
2823    /// [`Self::simple`] constructor's default-`false` fill reading
2824    /// verbatim while a downstream caixa-resolver consumer read a per-
2825    /// scope-override-resolved bit would silently split the build-time
2826    /// arm from the lacre closure the substrate's fetch pipeline
2827    /// actually materializes, one build-time diagnostic disagreeing
2828    /// with the run-time closure. Lifting the resolution rule to a
2829    /// typed method on the substrate primitive means every downstream
2830    /// consumer of the caixa's per-`:deps` opcional-tolerance surface
2831    /// reaches for exactly one typed dispatch — the resolver's accept-
2832    /// set migrates as a unit on any future axis addition.
2833    ///
2834    /// Fifth and final outer-`Dep` accessor — closes the outer-`Dep`
2835    /// slot-family the sibling per-`Dep` [`Self::nome`] (eba2cde) /
2836    /// [`Self::versao_requirement`] (05529b1) / [`Self::fonte`] (d65d1bf)
2837    /// / [`Self::caracteristicas`] (9197944) accessors opened, so every
2838    /// outer-`Dep` slot (`:nome`, `:versao`, `:fonte`, `:opcional`,
2839    /// `:caracteristicas`) now routes through exactly one typed
2840    /// dispatch on the substrate primitive. First outer-`Dep`
2841    /// `bool`-return / plain-`Copy`-scalar accessor — opens the
2842    /// outer-`Dep` `Copy`-scalar projection pattern that folds on the
2843    /// peer outer-top-level [`crate::Caixa`] `Option<Copy>`
2844    /// flat-spread sub-family ([`crate::Caixa::max_restarts`] eba5211,
2845    /// [`crate::Caixa::estrategia`] ed04d3c) the outer-`Caixa` altitude
2846    /// already carries — extends the "one typed dispatch on the
2847    /// substrate primitive, thin projections at each consumer"
2848    /// discipline onto the outer per-dep-list-entry [`Dep`] altitude's
2849    /// bool-shaped missing-source-tolerance slot. Returns `bool` by
2850    /// `Copy` (not by `&bool` reference) because `bool` is `Copy` and
2851    /// every downstream consumer treats it as a plain discriminant
2852    /// value — the by-value return is the narrowest return-shape that
2853    /// supports every present + roadmapped consumer (`.then(…)` early
2854    /// return on the resolver-side drop-vs-error partition, direct
2855    /// bool composition with a per-scope-override projector, plain
2856    /// `if dep.opcional() { … }` early return at every future admission
2857    /// gate) without leaking the storage field's `bool`-in-`&self`
2858    /// lifetime the by-value return elides. Marked `pub const fn` so
2859    /// the accessor is `const`-callable — same discipline the peer
2860    /// [`crate::Caixa::max_restarts`] `Option<u32>` `Copy`-return
2861    /// accessor carries. Named `opcional()` to match the storage
2862    /// field's name verbatim and the tatara-lisp author-surface term
2863    /// (`:opcional`) the field's own docstring already carries.
2864    #[must_use]
2865    pub const fn opcional(&self) -> bool {
2866        self.opcional
2867    }
2868
2869    /// Build a minimal registry-sourced dep.
2870    #[must_use]
2871    pub fn simple(nome: impl Into<String>, versao: impl Into<String>) -> Self {
2872        Self {
2873            nome: nome.into(),
2874            versao: versao.into(),
2875            fonte: None,
2876            opcional: false,
2877            caracteristicas: Vec::new(),
2878        }
2879    }
2880
2881    /// Build a Git-sourced dep (tag-based).
2882    #[must_use]
2883    pub fn git(
2884        nome: impl Into<String>,
2885        versao: impl Into<String>,
2886        repo: impl Into<String>,
2887        tag: impl Into<String>,
2888    ) -> Self {
2889        Self {
2890            nome: nome.into(),
2891            versao: versao.into(),
2892            fonte: Some(DepSource::Git {
2893                repo: repo.into(),
2894                tag: Some(tag.into()),
2895                rev: None,
2896                branch: None,
2897            }),
2898            opcional: false,
2899            caracteristicas: Vec::new(),
2900        }
2901    }
2902
2903    /// Reject dependency entries whose `:nome` or `:versao` are empty,
2904    /// whose `:nome` is non-empty but not a valid DNS-1123 label,
2905    /// or whose `:versao` is non-empty but not a valid Cargo-shaped
2906    /// semver requirement.
2907    ///
2908    /// The author surface for `:deps :versao` (and `:deps-dev :versao`)
2909    /// is the same Cargo-shaped requirement string `:membros :versao`
2910    /// (validated at [`crate::AplicacaoSpec::validate`] since 9888b13)
2911    /// and `:children :versao` (validated at
2912    /// [`crate::SupervisorSpec::validate`] since b38ff3a) carry — and
2913    /// the lacre pipeline resolves all three axes through the same
2914    /// [`crate::parse_requirement`] entry-point. Until 2420c44 landed
2915    /// `:deps :versao` was the last `:versao` axis untyped past
2916    /// `Caixa::from_lisp`: a malformed-but-non-empty requirement
2917    /// (`"^bad-version"`, `"^^0.1"`, the canonical git-tag-shape-
2918    /// leaking-into-:versao `"v0.1"` typo, the accidental
2919    /// `"not-a-req"`) silently passed parse and the `semver::Error`
2920    /// surfaced at lacre-resolve time, far from the source
2921    /// caixa.lisp, with no field naming which `:deps` entry carried
2922    /// the typo. The diagnostic [`DepError::VersaoInvalid`] carries
2923    /// the offending entry's `:nome` + the offending `:versao`
2924    /// verbatim + the parser's own wording in `reason`, so the
2925    /// author's grep target is unambiguous.
2926    ///
2927    /// The author surface for `:deps :nome` is the same DNS-1123 label
2928    /// the peer caixa-identifier axes carry — top-level Caixa `:nome`
2929    /// (validated at [`crate::Caixa::validate_nome`] since 6c992f8),
2930    /// `:membros :caixa` (validated at
2931    /// [`crate::AplicacaoSpec::validate_membros`] since 3f9d7a0),
2932    /// `:children :caixa` (validated at
2933    /// [`crate::SupervisorSpec::validate`] since 31bfa43). A `:deps
2934    /// :nome` value flows verbatim through the lacre pipeline as the
2935    /// target caixa's `:nome` (which the gate at the *target* side now
2936    /// rejects if non-DNS-1123) and lands as the rendered caixa's
2937    /// `lareira-<nome>` Helm chart name segment, the per-dep
2938    /// `LABEL_PROGRAM` label value, and the `caixa-resolver`'s
2939    /// `~/.cache/caixa/<org>/<nome>` checkout-directory leaf. Until
2940    /// this gate landed `:deps :nome` was the fourth and last
2941    /// DNS-1123-shaped caixa-identifier axis still untyped past
2942    /// `Caixa::from_lisp`: a syntactically wrong dep name (`"Caixa-
2943    /// Teia"` uppercase — the canonical "I copied the README header"
2944    /// typo; `"caixa_teia"` underscore — the Go module / Python
2945    /// identifier leak; `"caixa-teia."` trailing dot — the FQDN
2946    /// confusion; `"-caixa-teia"` leading hyphen; a 64-byte slug)
2947    /// silently passed parse and surfaced at lacre-resolve time when
2948    /// the resolved target caixa's `:nome` failed *its* DNS-1123 gate
2949    /// — far from the source `:deps` entry, with a diagnostic naming
2950    /// the *target's* `:nome` rather than the dep entry that referenced
2951    /// it. Mirroring the 3f9d7a0 / 31bfa43 / 6c992f8 trajectory through
2952    /// the lifted [`crate::render::is_dns_1123_label`] predicate (the
2953    /// "before its third occurrence" PRIME DIRECTIVE boundary, THEORY.md
2954    /// §I.3.5): every `Dep::nome` past validate is DNS-1123-label-shaped,
2955    /// so every downstream consumer (caixa-resolver's lacre fetch,
2956    /// caixa-helm's `lareira-<nome>` chart name, the future M4 per-dep
2957    /// fan-out emitter) reaches for the name knowing the value is
2958    /// apiserver-valid without re-validating.
2959    ///
2960    /// Empty checks fire first (narrower diagnostic), parse last —
2961    /// same ordering discipline as
2962    /// [`crate::AplicacaoSpec::validate_membros`] and
2963    /// [`crate::SupervisorSpec::validate`]. `parse_requirement("")`
2964    /// returns `Ok(VersionReq::STAR)`, so the empty-`:versao` arm is
2965    /// structurally necessary even with the parse arm in place. The
2966    /// `:nome` shape gate runs after the `:nome` empty gate and before
2967    /// the `:versao` checks so a one-entry caixa.lisp with both wrong
2968    /// sees the name-side diagnostic first (the name is the
2969    /// self-locating axis — without it, the parse diagnostic can't
2970    /// quote `:nome "<bad>"`).
2971    pub fn validate(&self) -> Result<(), DepError> {
2972        if self.nome.is_empty() {
2973            return Err(DepError::NomeEmpty);
2974        }
2975        if let Err(reason) = crate::render::is_dns_1123_label(&self.nome) {
2976            return Err(DepError::nome_invalid(&self.nome, reason));
2977        }
2978        // Delegate the empty-first + `parse_requirement` cascade to the
2979        // shared [`crate::render::require_valid_versao_requirement`]
2980        // helper — same two-arm shape the peer
2981        // [`crate::AplicacaoSpec::validate_membros`] on `:membros
2982        // :versao` and [`crate::SupervisorSpec::validate`] on `:children
2983        // :versao` route through, so drift between the three axes'
2984        // accepted requirement sets is structurally impossible and the
2985        // parse-side no-op the empty-first arm closes (semver's empty
2986        // parse yields an implicit `*`) lives in exactly one predicate.
2987        crate::render::require_valid_versao_requirement(
2988            self.versao_requirement(),
2989            || DepError::versao_empty(&self.nome),
2990            |reason| DepError::versao_invalid(&self.nome, self.versao_requirement(), reason),
2991        )?;
2992        if let Some(fonte) = self.fonte() {
2993            fonte.validate(&self.nome)?;
2994        }
2995        self.validate_caracteristicas()?;
2996        Ok(())
2997    }
2998
2999    /// Reject per-entry `:caracteristicas` (feature-flag) values that
3000    /// are operationally meaningless. The `:caracteristicas` slot is
3001    /// a set of feature toggles to enable on the target caixa — same
3002    /// shape as Cargo's `[dependencies.<dep>.features]` list — and
3003    /// two structural footguns close here:
3004    ///
3005    ///   - empty-string entry (`(:caracteristicas (""))`): the future
3006    ///     caixa-resolver lacre pipeline would consume the empty
3007    ///     identifier as a no-op feature enable, silently dropping the
3008    ///     author's intent far from the source `caixa.lisp`;
3009    ///   - duplicate entry within one dep (`(:caracteristicas ("http"
3010    ///     "http"))`): the feature-toggle slot is set-shaped (enabling
3011    ///     a feature twice has no additional semantic — there is no
3012    ///     `feature × 2`), so two entries naming the same feature are
3013    ///     a silent miscount, the same set-not-multiset distinction
3014    ///     every peer Vec-keyed-by-name axis already closes
3015    ///     ([`crate::SupervisorError::DuplicateChildCaixa`] on
3016    ///     `:children :caixa`, [`crate::AplicacaoError::MembroDuplicate`]
3017    ///     on `:membros :caixa`, [`crate::AplicacaoError::ContratoDuplicate`]
3018    ///     on `:contratos`, [`crate::AplicacaoError::PlacementClusterDuplicate`]
3019    ///     on `:placement :clusters`, [`crate::AplicacaoError::EntradaPathDuplicate`]
3020    ///     on `:entrada :paths`, [`crate::UpgradeError::DuplicateFrom`]
3021    ///     on `:upgrade-from :from`, [`crate::UpgradeError::DuplicateLoadModule`]
3022    ///     / [`crate::UpgradeError::DuplicateStateChange`] /
3023    ///     [`crate::UpgradeError::DuplicateCleanup`] on the within-
3024    ///     entry `:upgrade-from` axes, and [`DepError::DuplicateNome`]
3025    ///     on the cross-entry `:deps`/`:deps-dev` `:nome` axis the
3026    ///     immediate-predecessor 359fba5 closed).
3027    ///
3028    /// Same linear-walk + `HashSet` + first-collision diagnostic shape
3029    /// every peer set-not-multiset gate uses; the empty arm fires
3030    /// before the duplicate arm so an entry with both an empty feature
3031    /// *and* a duplicate of some later feature surfaces the empty-
3032    /// shape diagnostic first (the empty-feature axis is the
3033    /// more-actionable defect since the missing-name renders the
3034    /// duplicate-key arm ambiguous: two `""` entries would both report
3035    /// `caracteristica: ""` with no way to distinguish the offending
3036    /// site). Empty-first cascade discipline mirrors every peer per-
3037    /// entry shape + duplicate gate
3038    /// (`SupervisorSpec::validate`'s `EmptyChildName` before
3039    /// `DuplicateChildCaixa`; `validate_membros`'s `MembroCaixaEmpty`
3040    /// before `MembroDuplicate`).
3041    ///
3042    /// The per-entry value-shape gate (Cargo-feature-name grammar via
3043    /// the lifted [`crate::render::is_cargo_feature_name`] predicate)
3044    /// fires between the empty arm and the duplicate arm — the
3045    /// canonical per-entry-shape-before-cross-entry-uniqueness
3046    /// precedence every peer two-arm + value-shape gate establishes
3047    /// ([`crate::SupervisorSpec::validate`]'s `EmptyChildName` →
3048    /// `ChildCaixaInvalid` → `DuplicateChildCaixa`,
3049    /// [`crate::AplicacaoSpec::validate_membros`]'s `MembroCaixaEmpty`
3050    /// → `MembroCaixaInvalid` → `MembroDuplicate`, [`Dep::validate`]'s
3051    /// `NomeEmpty` → `NomeInvalid` → cross-list `DuplicateNome`).
3052    /// Until the value-shape arm landed `:caracteristicas` accepted
3053    /// every non-empty distinct string — a structurally invalid
3054    /// feature name (`"http feature"` whitespace, `"+http"` the
3055    /// canonical paste-from-`+optional-feature` doc activation-form
3056    /// footgun, `"-flag"` leading hyphen, `".feat"` leading dot,
3057    /// `"http/json"` Cargo's `dep/feat` namespaced-dep syntax that
3058    /// only applies inside list-grammar contexts, `"http,json"`
3059    /// list-separator-belongs-to-the-list-grammar miscomprehension,
3060    /// `"café"` un-percent-encoded non-ASCII silently round-tripping
3061    /// inconsistently across NFC/NFD normalization, the 65-byte
3062    /// paste-from-binary slug) silently passed validate and the
3063    /// failure surfaced at `cargo metadata` time as the
3064    /// `restricted_names::validate_feature_name` parser's rejection,
3065    /// far from the source `caixa.lisp`, with no field naming which
3066    /// `:deps` entry's `:caracteristicas` carried the typo. The
3067    /// lifted predicate makes the Cargo-feature-name-grammar
3068    /// intersection-floor a substrate-level invariant at validate
3069    /// time — same trajectory as the eight peer
3070    /// [`crate::render`] value-shape predicates each typed surface
3071    /// downstream of a structured grammar already follows
3072    /// ([`is_dns_1123_label`](crate::render::is_dns_1123_label),
3073    /// [`is_gateway_api_http_path`](crate::render::is_gateway_api_http_path),
3074    /// [`is_wit_world_ref`](crate::render::is_wit_world_ref),
3075    /// [`is_nats_subject`](crate::render::is_nats_subject),
3076    /// [`is_wasi_keyvalue_slot`](crate::render::is_wasi_keyvalue_slot),
3077    /// [`is_git_ref_name`](crate::render::is_git_ref_name),
3078    /// [`is_git_oid`](crate::render::is_git_oid),
3079    /// [`is_git_repo_url`](crate::render::is_git_repo_url)).
3080    fn validate_caracteristicas(&self) -> Result<(), DepError> {
3081        let mut seen = std::collections::HashSet::new();
3082        for c in self.caracteristicas() {
3083            if c.is_empty() {
3084                return Err(DepError::caracteristica_empty(&self.nome));
3085            }
3086            if let Err(reason) = crate::render::is_cargo_feature_name(c) {
3087                return Err(DepError::caracteristica_invalid(&self.nome, c, reason));
3088            }
3089            crate::render::insert_first_seen(&mut seen, c.as_str(), || {
3090                DepError::caracteristica_duplicate(&self.nome, c)
3091            })?;
3092        }
3093        Ok(())
3094    }
3095}
3096
3097/// Cross-slot coherence gate on the dep-graph axis: no `:deps` or
3098/// `:deps-dev` entry may name the caixa's own `:nome`.
3099///
3100/// A caixa that lists itself as a dep is a degenerate self-edge in the
3101/// lacre closure's dep-graph — the closure is a DAG rooted at the
3102/// caixa's `:nome`, and the caixa-resolver's lacre pipeline traverses
3103/// every `:deps` / `:deps-dev` entry's target by name. A self-dep
3104/// hands the resolver a node that is its own parent: a one-node cycle
3105/// it either rejects mid-traversal far from the source `caixa.lisp`
3106/// (the resolver detecting infinite recursion on the closure walk) or,
3107/// worse, recurses on until it exhausts its stack. Because every
3108/// `:nome` is a globally-unique substrate identity (DNS-1123 label +
3109/// lacre closure root), a dep entry whose `:nome` equals the caixa's
3110/// own `:nome` *is* the caixa itself, not a coincidentally-named peer.
3111///
3112/// Lives outside [`Caixa::validate_deps`] because the dep-list view
3113/// carries the entries but not the parent `:nome`; mirrors the
3114/// cross-slot self-edge gates [`crate::supervisor::validate_no_self_supervision`]
3115/// (ad4abf1) on the `:children :caixa` axis and
3116/// [`crate::aplicacao::validate_no_self_membership`] on the
3117/// `:membros :caixa` axis — the same "an edge from a graph node to
3118/// itself is structurally not a tree/graph edge" discipline, here on
3119/// the third typed-name-graph axis (the dep closure; the supervision
3120/// tree and the Aplicacao membership set were the prior two).
3121///
3122/// Walks `:deps` first then `:deps-dev` so the diagnostic for a caixa
3123/// that self-references on both axes surfaces the `:deps` arm first —
3124/// the load-bearing axis the lacre closure resolves at every build,
3125/// peer with the canonical [`Caixa::validate_deps`] walk order
3126/// (`:deps` → `:deps-dev`).
3127///
3128/// Carries the offending list tag (`":deps"` or `":deps-dev"`)
3129/// verbatim into the diagnostic so the author can grep their
3130/// `caixa.lisp` for the offending block in one edit — same
3131/// `list: &'static str` shape [`DepError::DuplicateNome`] (359fba5)
3132/// uses on the cross-list duplicate-name axis.
3133///
3134/// `Code paths` (`:bibliotecas` / `:exe` / `:servicos`) are the
3135/// substrate-blessed shape for referencing the caixa's *own* code, so
3136/// the diagnostic names them as the corrective surface — every
3137/// legitimate "I want to use code from this caixa" authoring intent
3138/// routes through one of those three slots, not a self-dep.
3139pub fn validate_no_self_dep(
3140    deps: &[Dep],
3141    deps_dev: &[Dep],
3142    parent_nome: &str,
3143) -> Result<(), DepError> {
3144    for dep in deps {
3145        if dep.nome() == parent_nome {
3146            return Err(DepError::dep_is_self(
3147                parent_nome,
3148                crate::render::DEP_AUTHOR_KEY_DEPS,
3149            ));
3150        }
3151    }
3152    for dep in deps_dev {
3153        if dep.nome() == parent_nome {
3154            return Err(DepError::dep_is_self(
3155                parent_nome,
3156                crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
3157            ));
3158        }
3159    }
3160    Ok(())
3161}
3162
3163/// Closed-set typed enum for the two dep-list author-surface axes every
3164/// top-level [`crate::Caixa`] carries — the runtime-closure `:deps` slot
3165/// (`Prod`) and the dev-only-closure `:deps-dev` slot (`Dev`). Every
3166/// substrate consumer that dispatches on "which of the two dep-lists"
3167/// (the `feira add` mutation head, the future per-cluster dev-closure-
3168/// audit overlay the M4 CR materializer resolves per-CR, the future
3169/// `caixa app graph` per-list dep summary, every future
3170/// `Caixa::push_dep` / `Caixa::deps_by_list` typed-method dispatch a
3171/// caller reaches for) reads through this enum rather than through a
3172/// bare `&'static str` — the closed-set is expressed at the type layer,
3173/// so a future third dep-list axis (a `:deps-build` build-only closure
3174/// once the substrate grows cross-artifact heterogeneous dep-graphs,
3175/// per CAIXA-SDLC §I) is one variant plus one arm per method and the
3176/// compiler enforces exhaustiveness on every consumer's `match` arms.
3177///
3178/// The wire byte-string [`Self::as_str`] returns is the same author-
3179/// surface tag the sibling [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3180/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] constants carry — the
3181/// [`DepError::DuplicateNome`] / [`DepError::DepIsSelf`] `list:
3182/// &'static str` payload family the substrate already emits routes
3183/// through the same source of truth (an author reading a
3184/// [`DepError::DuplicateNome`] refusal can grep their `caixa.lisp`
3185/// for the offending `:deps` / `:deps-dev` block in one edit whether
3186/// the diagnostic came from a `Caixa::validate_deps` walk or a
3187/// `Caixa::push_dep` mutation).
3188///
3189/// Same "closed-set typed-enum discriminator with canonical
3190/// projections per axis" discipline the sibling closed-set typed enums
3191/// on the caixa typed surface carry
3192/// ([`crate::aplicacao::PlacementStrategy`] cc8f749,
3193/// [`crate::aplicacao::RateLimitUnit`] 6bce03d,
3194/// [`crate::supervisor::RestartStrategy`],
3195/// [`crate::supervisor::RestartPolicy`],
3196/// [`crate::upgrade::UpgradeInstruction`], [`crate::CaixaKind`])
3197/// — extended onto the outer-`Caixa` two-list dep-graph axis, the
3198/// substrate's last unlifted closed-set-shaped `&'static str`-carrying
3199/// axis on the top-level manifest surface.
3200#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, gen_platform::IsVariant)]
3201pub enum DepList {
3202    /// Runtime-closure `:deps` axis — the load-bearing dep-list the
3203    /// lacre closure resolves at every build. Wire-format
3204    /// [`crate::render::DEP_AUTHOR_KEY_DEPS`].
3205    Prod,
3206    /// Dev-only-closure `:deps-dev` axis — Cargo's `[dev-dependencies]`
3207    /// table's dev-time-only visibility contract per CAIXA-SDLC §I.
3208    /// Wire-format [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`].
3209    Dev,
3210}
3211
3212impl DepList {
3213    /// Exhaustive iteration surface for every consumer that reads the
3214    /// full closed-set (the future M4 admission webhook's per-list
3215    /// summary rejection body, any future round-trip pin harness). A
3216    /// future variant addition extends this slice as a single edit and
3217    /// every consumer picks up the new entry by construction — the
3218    /// compiler-checked exhaustiveness on the sibling method `match`
3219    /// arms is the build-time guarantee that no arm forgets to grow.
3220    pub const ALL: &'static [Self] = &[Self::Prod, Self::Dev];
3221
3222    /// Canonical author-surface tag every substrate consumer that
3223    /// names the offending dep-list in a diagnostic reaches for —
3224    /// [`crate::render::DEP_AUTHOR_KEY_DEPS`] for [`Self::Prod`] and
3225    /// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] for [`Self::Dev`],
3226    /// the same `&'static str` payload the sibling
3227    /// [`DepError::DuplicateNome`] and [`DepError::DepIsSelf`] variants
3228    /// already carry. Routing every dep-list diagnostic through the
3229    /// closed-set enum's `as_str` closes the last `&'static str`-shape
3230    /// literal-carry axis on the two-list dep-graph surface — a
3231    /// future kebab-case rebrand (`":deps"` → `":packages"`) or a
3232    /// wire-format promotion (a distinct diagnostic form for the
3233    /// `Dev` arm) reaches every consumer through one edit on the
3234    /// canonical constant, not a coordinated rewrite across the
3235    /// substrate's dep-graph consumers.
3236    #[must_use]
3237    pub const fn as_str(self) -> &'static str {
3238        match self {
3239            Self::Prod => crate::render::DEP_AUTHOR_KEY_DEPS,
3240            Self::Dev => crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
3241        }
3242    }
3243
3244    /// Substrate-canonical reverse projection on the two-list dep-graph
3245    /// axis — parses the author-surface wire tag back to the typed
3246    /// variant, or `None` when `s` is outside the closed-set arm-string
3247    /// set [`Self::as_str`] emits. Dispatches on the same lifted
3248    /// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3249    /// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] constants the
3250    /// [`Self::as_str`] emitter walks, so the parse and emit halves of
3251    /// the round-trip migrate through one caixa-core edit on any future
3252    /// list-axis addition.
3253    ///
3254    /// Prior to this lift the substrate carried only the forward
3255    /// `Self → &str` projection on the two-list dep-graph axis (the
3256    /// [`Self::as_str`] emitter, the [`std::fmt::Display`] impl routed
3257    /// through it, the two [`DepError::DuplicateNome`] /
3258    /// [`DepError::DepIsSelf`] variants that carry the wire tag verbatim
3259    /// as a `&'static str` `list:` field). Every future consumer that
3260    /// wanted to promote the wire tag back to the typed enum (a future
3261    /// `feira dep --list <deps|deps-dev>` CLI arg-parse that binds the
3262    /// wire form into the typed enum before dispatching to
3263    /// [`crate::Caixa::deps_of`] / [`crate::Caixa::push_dep`], the M4
3264    /// `mesh.pleme.io/v1alpha1/Caixa` CR materializer's admission-time
3265    /// wire re-parse of the per-list diagnostic body, a future
3266    /// [`DepError`] widening that promotes the two `list: &'static str`
3267    /// fields to a typed `list: DepList` carry so downstream consumers
3268    /// dispatch on the enum rather than string-comparing the wire
3269    /// scalar) would have had to re-inline a two-arm `match s { ":deps"
3270    /// => …, ":deps-dev" => …, _ => … }` cascade that expressed no
3271    /// compile-time link back to the typed [`DepList`] enum. A future
3272    /// variant addition (a `:build-dep` or `:test-dep` third list once
3273    /// the substrate grows Cargo-style split-graphs, a `:tool-dep` for
3274    /// build-time-only tooling per the peer Cargo `[build-dependencies]`
3275    /// / `[target.<cfg>.dev-dependencies]` future admission surface)
3276    /// would silently split the wire byte-string the emitter walks from
3277    /// the parser's arm-set — the round-trip would carry the new list
3278    /// through the forward projection but land on the fallback silently
3279    /// at every non-updated reverse parser, far from the arm-addition
3280    /// commit that caused the drift. Lifting the resolver to a typed
3281    /// method on the substrate primitive closes the drift footgun by
3282    /// construction: the parser's accept-set is the same set the
3283    /// [`Self::as_str`] emitter walks (routed through the same lifted
3284    /// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3285    /// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] consts), so both halves
3286    /// of the round-trip migrate through one caixa-core edit on any
3287    /// future list-axis addition.
3288    ///
3289    /// Same closed-set-reverse-projection discipline the sibling
3290    /// [`crate::CaixaKind::from_wire`] (2aa6d23) /
3291    /// [`crate::supervisor::RestartStrategy::from_wire`] (4eec29c) /
3292    /// [`crate::supervisor::RestartPolicy::from_wire`] (dd32ccf) /
3293    /// [`crate::aplicacao::PlacementStrategy::from_wire`] (18c7342) /
3294    /// [`crate::aplicacao::RateLimitUnit::from_suffix`] typed enums
3295    /// carry on the peer wire-side `str → Self` axes — extended onto
3296    /// the two-list dep-graph closed-set axis, the sixth substrate-side
3297    /// closed-set typed enum on the caixa surface to converge on the
3298    /// two-way `str ↔ Self` round-trip. Method-named `from_wire` (not
3299    /// `from_str`) to match the peer shapes verbatim and side-step the
3300    /// derived [`std::str::FromStr`] impls the sibling
3301    /// [`gen_platform::FromStrKind`]-carrying axes install on their
3302    /// kebab-case dispatcher-catalog identity. Returns `Option<Self>`
3303    /// (rather than `Result<Self, _>`) to match the peer shapes: the
3304    /// caller picks the diagnostic form appropriate for its use site —
3305    /// a future `feira dep --list …` arg-parse that surfaces
3306    /// `unknown list: <arg>` at the CLI builds one on top by iterating
3307    /// [`Self::ALL`], while the future M4 admission-webhook's rejection
3308    /// path folds `None` onto its per-CR structured refusal body.
3309    #[must_use]
3310    pub fn from_wire(s: &str) -> Option<Self> {
3311        match s {
3312            crate::render::DEP_AUTHOR_KEY_DEPS => Some(Self::Prod),
3313            crate::render::DEP_AUTHOR_KEY_DEPS_DEV => Some(Self::Dev),
3314            _ => None,
3315        }
3316    }
3317}
3318
3319/// Route [`std::fmt::Display`] through [`DepList::as_str`], so every
3320/// consumer that formats the axis as user-facing text (a future
3321/// `feira app graph` per-list summary, a future M4 admission-webhook
3322/// rejection body naming the offending list, this crate's own
3323/// [`DepError`] `#[error(...)]` templates when they widen to carry a
3324/// typed [`DepList`]) lands on the same author-surface tag the
3325/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3326/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] constants carry. Same
3327/// as-str-through-Display convergence discipline the sibling
3328/// [`crate::aplicacao::PlacementStrategy`],
3329/// [`crate::aplicacao::RateLimitUnit`],
3330/// [`crate::supervisor::RestartStrategy`],
3331/// [`crate::supervisor::RestartPolicy`], and [`crate::CaixaKind`]
3332/// closed-set typed enums carry.
3333impl std::fmt::Display for DepList {
3334    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3335        f.write_str(self.as_str())
3336    }
3337}
3338
3339/// Errors raised by [`Dep::validate`].
3340///
3341/// Mirrors the per-axis error families the other `:versao`-carrying
3342/// typed surfaces expose
3343/// ([`crate::AplicacaoError::MembroVersaoEmpty`] /
3344/// [`crate::AplicacaoError::MembroVersaoInvalid`],
3345/// [`crate::SupervisorError::EmptyChildVersion`] /
3346/// [`crate::SupervisorError::ChildVersaoInvalid`]) so a future top-
3347/// level `CaixaError` (M4) sums these without reshaping the diagnostic.
3348#[derive(Debug, Error, PartialEq, Eq)]
3349pub enum DepError {
3350    #[error(
3351        ":deps entry has empty :nome (every dep must name a target caixa; \
3352         omit the entry instead of carrying an empty name)"
3353    )]
3354    NomeEmpty,
3355    #[error(
3356        ":deps entry :nome {nome:?} is not a valid DNS-1123 label: {reason} \
3357         (the value flows verbatim as the target caixa's `:nome`, the rendered \
3358         `lareira-<nome>` Helm chart name segment, the `LABEL_PROGRAM` label \
3359         value, and the resolver's checkout-directory leaf — each apiserver-side \
3360         schema rejects non-DNS-1123 names at admission time; use a lowercase \
3361         RFC 1123 label like `\"caixa-teia\"` or `\"pleme-mesh\"`, 1..=63 bytes, \
3362         pattern `^[a-z0-9]([-a-z0-9]*[a-z0-9])?$`)"
3363    )]
3364    NomeInvalid { nome: String, reason: String },
3365    #[error(
3366        ":deps entry {nome:?} has empty :versao (every dep must pin a semver \
3367         constraint that resolves through the lacre pipeline)"
3368    )]
3369    VersaoEmpty { nome: String },
3370    #[error(
3371        ":deps entry {nome:?} :versao {versao:?} is not a valid semver \
3372         requirement: {reason} (use Cargo-shaped forms like `\"^0.1\"`, \
3373         `\"~0.1.2\"`, `\"0.1.0\"`, or `\"*\"` — the same shape `:membros :versao` \
3374         and `:children :versao` carry; the lacre pipeline resolves all three \
3375         through the same parser)"
3376    )]
3377    VersaoInvalid {
3378        nome: String,
3379        versao: String,
3380        reason: String,
3381    },
3382    #[error(
3383        ":deps entry {nome:?} :fonte (:tipo git …) has empty :repo \
3384         (every git source must name a repo — use a `github:org/repo` \
3385         shorthand, an `https://…` URL, or an ssh-git URL; omit the \
3386         entire :fonte block to fall back to the default-host resolver \
3387         convention)"
3388    )]
3389    FonteRepoEmpty { nome: String },
3390    #[error(
3391        ":deps entry {nome:?} :fonte (:tipo git …) :repo {repo:?} has \
3392         invalid value-shape: {reason} (the value flows verbatim into the \
3393         caixa-resolver's `git clone <repo>` subprocess invocation; every \
3394         documented form carries a `:` separator and no whitespace / \
3395         control / non-ASCII bytes — use a `github:org/repo` shorthand, \
3396         an `https://host/path` / `ssh://[user@]host/path` / \
3397         `git://host/path` / `file:///path` URL, or the `git@host:path` \
3398         scp-style SSH form)"
3399    )]
3400    FonteRepoShape {
3401        nome: String,
3402        repo: String,
3403        reason: String,
3404    },
3405    #[error(
3406        ":deps entry {nome:?} :fonte (:tipo git …) has no pin set \
3407         (set exactly one of :tag, :rev, or :branch so the resolver \
3408         can pick a reproducible commit; omit the entire :fonte block \
3409         to fall back to the default-host resolver convention, which \
3410         resolves the latest tag matching :versao)"
3411    )]
3412    FontePinMissing { nome: String },
3413    #[error(
3414        ":deps entry {nome:?} :fonte (:tipo git …) has multiple pins \
3415         set ({pins}); exactly one of :tag, :rev, or :branch must be \
3416         set so the resolver's checkout target is unambiguous (the \
3417         resolver's silent precedence is :rev > :tag > :branch — if \
3418         you intended one specifically, drop the others)"
3419    )]
3420    FontePinAmbiguous { nome: String, pins: String },
3421    #[error(
3422        ":deps entry {nome:?} :fonte (:tipo git …) has empty {pin} \
3423         (a set pin must name a non-empty git ref; drop the {pin} key \
3424         entirely to fall through to another pin axis)"
3425    )]
3426    FontePinEmpty { nome: String, pin: String },
3427    #[error(
3428        ":deps entry {nome:?} :fonte (:tipo git …) {pin} {value:?} has invalid \
3429         value-shape: {reason} (the git porcelain enforces the same shape at \
3430         `git fetch` / `git checkout` time on every pin; use a leaf refname \
3431         like `\"v0.1.0\"` for `:tag` or `\"main\"` / `\"feature/foo\"` for \
3432         `:branch`, or a full 40/64 lowercase-hex commit OID for `:rev` — \
3433         drop any `refs/heads/` or `refs/tags/` prefix the caixa-resolver \
3434         prepends at clone time, and avoid abbreviated SHAs which are \
3435         ambiguous across repository history)"
3436    )]
3437    FontePinShape {
3438        nome: String,
3439        pin: String,
3440        value: String,
3441        reason: String,
3442    },
3443    #[error(
3444        ":deps entry {nome:?} :fonte (:tipo path …) has empty :caminho \
3445         (every path source must name a non-empty filesystem path; \
3446         omit the entire :fonte block to fall back to the default-host \
3447         resolver convention)"
3448    )]
3449    FonteCaminhoEmpty { nome: String },
3450    #[error(
3451        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} is \
3452         absolute (the lacre pipeline embeds the value verbatim in its \
3453         per-dep content-address `path:{caminho}` at \
3454         caixa-resolver/src/resolve.rs:189, so an absolute path makes the \
3455         BLAKE3 closure differ across machines — defeating the \
3456         reproducibility contract that's load-bearing for CSE; express \
3457         the path relative to the caixa.lisp location, e.g. \
3458         \"../caixa-teia\" for a sibling workspace dep)"
3459    )]
3460    FonteCaminhoAbsolute { nome: String, caminho: String },
3461    #[error(
3462        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
3463         with `~` (the leading-tilde is a shell-expansion convention, not a \
3464         POSIX path component — `Path::is_absolute` returns false on it, so \
3465         the b94fd83 absolute-path gate doesn't catch it, but the lacre \
3466         pipeline embeds the value verbatim in its per-dep content-address \
3467         `path:{caminho}` at caixa-resolver/src/resolve.rs:189 and the \
3468         caixa-resolver folds it through `Path::join` without `~`-expansion, \
3469         so the build looks for a literal `./{caminho}` subdirectory and \
3470         fails at resolve time far from the source caixa.lisp; even worse, a \
3471         future caixa-resolver pass that *does* expand `~` would silently \
3472         re-open the host-layout-leak the b94fd83 absolute gate closes — \
3473         Alice's `~` resolves to `/home/alice`, Bob's to `/home/bob`, two CI \
3474         runners with different `$HOME` layouts resolve to two distinct paths \
3475         for the byte-identical caixa, defeating the THEORY.md §V.2 render-\
3476         determinism contract; express the path relative to the caixa.lisp \
3477         location, e.g. \"../caixa-teia\" for a sibling workspace dep, or \
3478         spell out the full relative path explicitly if a workstation-rooted \
3479         dep is genuinely intended)"
3480    )]
3481    FonteCaminhoTildeExpansion { nome: String, caminho: String },
3482    #[error(
3483        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
3484         with `$` (the leading-`$` is a shell-variable-expansion convention, \
3485         not a POSIX path component — `Path::is_absolute` returns false on it \
3486         and the a5c248e tilde gate doesn't catch it, but the lacre pipeline \
3487         embeds the value verbatim in its per-dep content-address \
3488         `path:{caminho}` at caixa-resolver/src/resolve.rs:189 and the \
3489         caixa-resolver folds it through `Path::join` without `$`-expansion, \
3490         so the build looks for a literal `./{caminho}` subdirectory and \
3491         fails at resolve time far from the source caixa.lisp; even worse, a \
3492         future caixa-resolver pass that *does* expand `$VAR` (the canonical \
3493         shell-convention idiom that CI's `${{WORKSPACE}}` paste-idiom \
3494         invites) would silently re-open the host-layout-leak the b94fd83 \
3495         absolute gate closes — Alice's `$HOME` resolves to `/home/alice`, \
3496         Bob's to `/home/bob`, two CI runners with different `${{WORKSPACE}}` \
3497         layouts resolve to two distinct paths for the byte-identical caixa, \
3498         defeating the THEORY.md §V.2 render-determinism contract; express \
3499         the path relative to the caixa.lisp location, e.g. \"../caixa-teia\" \
3500         for a sibling workspace dep, or spell out the full relative path \
3501         explicitly if a workstation-rooted dep is genuinely intended)"
3502    )]
3503    FonteCaminhoVarExpansion { nome: String, caminho: String },
3504    #[error(
3505        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
3506         with a space (the leading ASCII space `0x20` is the orthogonal \
3507         paste-from-aligned-doc footgun that silently passes \
3508         `Path::is_absolute` and every prior leading-byte arm — \
3509         `\" ../caixa-teia\"` resolves via `Path::join` to a literal \
3510         `./ ../caixa-teia` subdirectory the resolver fails to find at \
3511         resolve time with a non-self-locating `No such file or directory` \
3512         error far from the source caixa.lisp; the lacre pipeline embeds \
3513         the value verbatim in its per-dep content-address `path:{caminho}` \
3514         at caixa-resolver/src/resolve.rs:189, so byte-divergent / \
3515         semantic-identical caixa values (` ../caixa-teia` vs \
3516         `../caixa-teia`) yield two distinct BLAKE3 closures across two \
3517         workstations whose authors differ only in paste-from-aligned- \
3518         caixa.lisp-doc whitespace habits — the most insidious failure \
3519         mode the typed slot can carry (no error surfaces; the divergence \
3520         is invisible until two machines compare lacres), defeating the \
3521         THEORY.md §V.2 render-determinism contract. The canonical \
3522         paste-from-aligned-`:deps`-block footgun (every `:fonte` form in \
3523         a multi-entry `:deps` block sits at the same column — an author \
3524         selecting `\"<sp><sp><sp>../caixa-teia\"` and pasting it from \
3525         the rendered alignment into a fresh entry preserves the leading \
3526         whitespace verbatim); peer `:fonte :repo` axis already rejects \
3527         leading whitespace via `is_git_repo_url`, `:fonte :tag` / \
3528         `:fonte :branch` via `is_git_ref_name`, `:descricao` via \
3529         `is_chart_description_shape`, `:licenca` via \
3530         `is_spdx_expression_shape`. Drop the leading space; express the \
3531         path as a bare relative single-token like \"../caixa-teia\")"
3532    )]
3533    FonteCaminhoLeadingWhitespace { nome: String, caminho: String },
3534    #[error(
3535        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
3536         with `-` (the canonical CLI-argument-injection footgun on the \
3537         `:caminho` axis — the lacre pipeline embeds the value verbatim in \
3538         its per-dep content-address `path:{caminho}` at \
3539         caixa-resolver/src/resolve.rs:189 and the caixa-resolver folds it \
3540         through `Path::join` looking for a literal `./{caminho}` \
3541         subdirectory. Every downstream subprocess that consumes the resolved \
3542         path — `git -C {caminho} <verb>`, `terraform -chdir={caminho}`, \
3543         `nix build --path {caminho}`, `find {caminho}`, `stat {caminho}`, \
3544         `cp -r {caminho} …`, `rm -rf {caminho}` — reinterprets a leading-`-` \
3545         value as a CLI flag rather than a positional path when the invocation \
3546         does not carry a `--` argument-list terminator between the flag block \
3547         and the path (the common case at every porcelain entry point). The \
3548         canonical footguns: `:caminho \"-rf\"` (bare short-flag paste), \
3549         `:caminho \"-C\"` (`git -C -C` config-injection paste), \
3550         `:caminho \"--upload-pack=cat /etc/passwd\"` (the canonical long-flag \
3551         CLI-arg-injection vector at every git porcelain entry point that \
3552         consumes a path or URL argument, peer with is_git_repo_url's \
3553         leading-`-` arm on the sibling `:fonte :repo` axis), \
3554         `:caminho \"--config=…\"` (`git -c foo=bar` config-override paste). \
3555         POSIX `std::path::Path` treats a leading `-` as a literal filename \
3556         byte so the resolver folds `\"-rf\"` through `Path::join` and looks \
3557         for a literal `./-rf` subdirectory that fails at resolve time with a \
3558         non-self-locating `No such file or directory` error far from the \
3559         source caixa.lisp — but on any downstream shell-out without `--` the \
3560         reinterpretation is silent and the failure mode is arbitrary-\
3561         argument-injection. Peer arms: `is_git_repo_url` (render.rs:2037) \
3562         rejects leading `-` on `:fonte :repo` for `git clone <repo>` CLI-\
3563         arg-injection; `is_git_ref_name` (render.rs:1381, 5a28454) rejects \
3564         leading `-` on `:fonte :tag` / `:branch` for `git checkout <ref>` \
3565         CLI-arg-injection; `is_dns_1123_label` rejects leading `-` on every \
3566         DNS-1123-shaped axis (top-level Caixa `:nome`, `:membros :caixa`, \
3567         `:children :caixa`, `:deps :nome`, cluster names); \
3568         `is_cargo_feature_name` rejects leading `-` on `:caracteristicas`; \
3569         the feira `init` / `add <nome>` positional gate (868c191) rejects \
3570         leading `-` on the CLI positional itself. Express the path as a bare \
3571         relative single-token like \"../caixa-teia\" — the sibling-workspace \
3572         directory name carries no leading-hyphen semantic, and `./` / `../` \
3573         prefixes structurally partition the leading-byte set to safe values.)"
3574    )]
3575    FonteCaminhoLeadingHyphen { nome: String, caminho: String },
3576    #[error(
3577        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains \
3578         ASCII control byte 0x{byte:02x} (POSIX paths reject NUL `0x00` outright — \
3579         every `std::fs` syscall routes the path through `CString::new` which \
3580         fails with `NulError` at resolve time; the lacre pipeline embeds the \
3581         value verbatim in its per-dep content-address `path:{caminho}` at \
3582         caixa-resolver/src/resolve.rs:189 so a control byte anywhere in the \
3583         value lands in the BLAKE3 closure and breaks the THEORY.md §V.2 render-\
3584         determinism contract — the canonical paste-from-multiline-doc \
3585         (`\\n`/`\\r`), paste-from-aligned-table (`\\t`), or paste-from-binary-\
3586         blob (`0x00`-DEL) footgun every peer single-token-shaped axis \
3587         (`:fonte :repo`, `:fonte :tag`/`:branch`, the Helm chart-string axes) \
3588         already gates against. Express the path as a relative single-line ASCII \
3589         string, e.g. \"../caixa-teia\" for a sibling workspace dep)"
3590    )]
3591    FonteCaminhoControlChar {
3592        nome: String,
3593        caminho: String,
3594        byte: u8,
3595    },
3596    #[error(
3597        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains `\\` \
3598         (POSIX `std::path::Path` treats `\\` as a literal byte inside a single path \
3599         component, so `..\\caixa-teia` is one directory named literally `..\\caixa-teia` — \
3600         not the parent's sibling — and the caixa-resolver folds the value through \
3601         `Path::join` looking for a literal `./{caminho}` subdirectory that fails at \
3602         resolve time with a non-self-locating `No such file or directory` error far \
3603         from the source caixa.lisp; Windows `std::path::Path` treats `\\` as a \
3604         primary path separator equal to `/`, so byte-identical caixa.lisp values \
3605         resolve to two distinct directories across runner OSes — the lacre pipeline \
3606         embeds the value verbatim in its per-dep content-address `path:{caminho}` at \
3607         caixa-resolver/src/resolve.rs:189, defeating the THEORY.md §V.2 render-\
3608         determinism contract via the cross-host-OS-separator divergence vector. The \
3609         canonical Windows-Explorer `Copy as path` / PowerShell `Get-Location` \
3610         paste-idiom footgun; peer `:fonte :tag` / `:fonte :branch` axis already \
3611         rejects `\\` via `is_git_ref_name` for the same Windows-path-leak reason, \
3612         and `:entrada :paths` rejects `\\` via `is_gateway_api_http_path`'s eleven-\
3613         byte RFC-3986-reserved set. Express the path with `/` as the separator, e.g. \
3614         \"../caixa-teia\" for a sibling workspace dep)"
3615    )]
3616    FonteCaminhoBackslash { nome: String, caminho: String },
3617    #[error(
3618        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3619         redirection metacharacter 0x{byte:02x} `{ch}` (every interactive shell — bash / \
3620         zsh / fish / nushell — lexes `<` and `>` as input / output redirection \
3621         operators, so `:caminho \"../caixa-teia>build.log\"` is the canonical \
3622         paste-from-shell-pipeline footgun where an author copies a `command > log` \
3623         tail without trimming the redirect; POSIX `std::path::Path` treats both bytes \
3624         as literal path-component bytes, so the resolver folds the value through \
3625         `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
3626         subdirectory and fails at resolve time with a non-self-locating `No such \
3627         file or directory` error far from the source caixa.lisp. The lacre pipeline \
3628         embeds the value verbatim in its per-dep content-address `path:{caminho}` at \
3629         caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure \
3630         and rides into every shell-spawned subprocess (the resolver's `git clone`, a \
3631         future `feira tofu` shell-out, a future operator-side `nix` spawn) as the \
3632         canonical CRLF-at-subprocess-argument / shell-metachar injection surface every \
3633         peer single-token-shaped typed slot already closes. The peer `:fonte :tag` / \
3634         `:fonte :branch` axis already rejects `<` / `>` via `is_git_ref_name`, and \
3635         `:entrada :paths` rejects them via `is_gateway_api_http_path`'s eleven-byte \
3636         RFC-3986-reserved set. Express the path as a bare relative single-token like \
3637         \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
3638         redirection semantic.",
3639        ch = *byte as char
3640    )]
3641    FonteCaminhoShellRedirection {
3642        nome: String,
3643        caminho: String,
3644        byte: u8,
3645    },
3646    #[error(
3647        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-pipe \
3648         metacharacter `|` (every interactive shell — bash / zsh / fish / nushell — lexes \
3649         `|` as the pipe operator that wires one command's stdout to the next command's \
3650         stdin, so `:caminho \"../caixa-teia | grep foo\"` is the canonical paste-from-\
3651         shell-history footgun where an author copies a `ls ../caixa-teia | grep` line \
3652         without trimming the pipeline tail, and `:caminho \"../foo||bar\"` is the \
3653         symmetric `cmd-a || cmd-b` short-circuit-OR paste shape; POSIX `std::path::Path` \
3654         treats `|` as a literal path-component byte, so the resolver folds the value \
3655         through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
3656         subdirectory and fails at resolve time with a non-self-locating `No such file or \
3657         directory` error far from the source caixa.lisp. The lacre pipeline embeds the \
3658         value verbatim in its per-dep content-address `path:{caminho}` at caixa-resolver/\
3659         src/resolve.rs:189, so the byte lands in the BLAKE3 closure and rides into every \
3660         shell-spawned subprocess (the resolver's `git clone`, a future `feira tofu` \
3661         shell-out, a future operator-side `nix` spawn) as the canonical CRLF-at-\
3662         subprocess-argument / shell-metachar injection surface every peer single-token-\
3663         shaped typed slot already closes. The peer `:entrada :paths` axis rejects `|` \
3664         via `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the \
3665         path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
3666         workspace directory name carries no shell-pipe semantic."
3667    )]
3668    FonteCaminhoShellPipe { nome: String, caminho: String },
3669    #[error(
3670        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3671         command-separator metacharacter `;` (every interactive shell — bash / zsh / fish \
3672         / nushell — lexes `;` as the sequential-command terminator that fires the next \
3673         command regardless of the prior command's exit status, so `:caminho \
3674         \"../caixa-teia; rm -rf build\"` is the canonical paste-from-shell-one-liner \
3675         footgun where an author copies a `cd path; do-thing` chain without trimming \
3676         the cleanup tail, and `:caminho \"../foo;;bar\"` is the symmetric POSIX `case` \
3677         arm `;;` terminator paste shape; POSIX `std::path::Path` treats `;` as a \
3678         literal path-component byte, so the resolver folds the value through \
3679         `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 \
3681         or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
3682         the value verbatim in its per-dep content-address `path:{caminho}` at \
3683         caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
3684         rides into every shell-spawned subprocess (the resolver's `git clone`, a \
3685         future `feira tofu` shell-out, a future operator-side `nix` spawn) as the \
3686         canonical shell-metachar injection surface every peer single-token-shaped \
3687         typed slot already closes. The peer `:entrada :paths` axis rejects `;` via \
3688         `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-command-separator semantic."
3691    )]
3692    FonteCaminhoShellSemicolon { nome: String, caminho: String },
3693    #[error(
3694        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3695         background / list-AND metacharacter `&` (every interactive shell — bash / zsh \
3696         / fish / nushell — lexes `&` two ways: single `&` as the background-task \
3697         terminator detaching the prior command and returning control immediately to \
3698         the prompt, double `&&` as the logical-AND list operator firing the next \
3699         command only if the prior succeeded; POSIX `std::path::Path` treats it as a \
3700         literal byte. The canonical paste-from-shell-prompt footgun is a `cd path & \
3701         sleep 1` background-launch one-liner or a `cd path && make install` build-\
3702         chain idiom selected whole into the `:caminho` slot — the prior `;` arm at \
3703         05c358e closed the sequential-command-separator vector, this arm closes the \
3704         orthogonal background-task / logical-AND vector on the same paste-from-shell-\
3705         prompt class. The lacre pipeline embeds the value verbatim in its per-dep \
3706         content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the \
3707         byte lands in the BLAKE3 closure and rides into every shell-spawned \
3708         subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a \
3709         future operator-side `nix` spawn) as the canonical shell-metachar injection \
3710         surface every peer single-token-shaped typed slot already closes. The peer \
3711         `:entrada :paths` axis rejects `&` via `is_gateway_api_http_path`'s eleven-\
3712         byte RFC-3986-reserved set. Express the path as a bare relative single-token \
3713         like \"../caixa-teia\" — the sibling-workspace directory name carries no \
3714         shell-background / logical-AND semantic."
3715    )]
3716    FonteCaminhoShellBackground { nome: String, caminho: String },
3717    #[error(
3718        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3719         command-substitution metacharacter `` ` `` (every POSIX shell — sh / bash / zsh / \
3720         dash / ksh / fish / nushell — lexes the byte as the legacy command-substitution \
3721         wrapper that runs the enclosed command and substitutes its standard-output \
3722         verbatim into the surrounding word, so a backticked `whoami` expands to the \
3723         current user's name and a backticked `cat /etc/passwd` expands to the file's \
3724         contents — the canonical CWE-78 shell-command-injection vector; POSIX \
3725         `std::path::Path` treats the byte as a literal path-component byte. The canonical \
3726         paste-from-shell-prompt footgun is a `cd ../path/<backtick>whoami<backtick>` legacy substitution \
3727         one-liner or a `cd <backtick>pwd<backtick>/path` working-directory expansion idiom selected whole \
3728         into the `:caminho` slot — the prior `&` arm at e12e4f3 closed the shell-\
3729         background / logical-AND vector, this arm closes the orthogonal command-\
3730         substitution vector on the same paste-from-shell-prompt class (the modern `$()` \
3731         form is gated at leading position by the f4efe9c `FonteCaminhoVarExpansion` arm; \
3732         the legacy backtick form is the orthogonal axis). The lacre pipeline embeds the \
3733         value verbatim in its per-dep content-address `path:{caminho}` at \
3734         caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
3735         rides into every shell-spawned subprocess (the resolver's `git clone`, a future \
3736         `feira tofu` shell-out, a future operator-side `nix` spawn) as the canonical \
3737         shell-metachar injection surface every peer single-token-shaped typed slot \
3738         already closes. The peer `:entrada :paths` axis rejects the byte via \
3739         `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the path \
3740         as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
3741         directory name carries no shell-command-substitution semantic."
3742    )]
3743    FonteCaminhoShellCommandSubstitution { nome: String, caminho: String },
3744    #[error(
3745        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3746         glob / pathname-expansion metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — \
3747         sh / bash / zsh / dash / ksh / fish / nushell — lexes `*` and `?` as pathname-\
3748         expansion wildcards: `*` matches any sequence of characters in a path component \
3749         and `?` matches exactly one character, so a `:caminho \"../caixa-teia/*\"` is the \
3750         canonical paste-from-shell-listing footgun where an author copies a \
3751         `ls ../caixa-teia/*` listing without trimming the wildcard, and `:caminho \
3752         \"../foo?\"` is the symmetric single-char-wildcard paste shape; POSIX \
3753         `std::path::Path` treats both bytes as literal path-component bytes, so the \
3754         resolver folds the value through `Path::new(caminho).join(<file>)` looking for \
3755         a literal `./{caminho}` subdirectory and fails at resolve time with a non-self-\
3756         locating `No such file or directory` error far from the source caixa.lisp. The \
3757         lacre pipeline embeds the value verbatim in its per-dep content-address \
3758         `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in the \
3759         BLAKE3 closure and rides into every shell-spawned subprocess (the resolver's \
3760         `git clone`, a future `feira tofu` shell-out, a future operator-side `nix` \
3761         spawn) as the canonical shell-metachar / glob-expansion surface every peer \
3762         single-token-shaped typed slot already closes. The peer `:entrada :paths` axis \
3763         rejects `*` and `?` via `is_gateway_api_http_path`'s eleven-byte RFC-3986-\
3764         reserved set. Express the path as a bare relative single-token like \
3765         \"../caixa-teia\" — the sibling-workspace directory name carries no shell-glob \
3766         / pathname-expansion semantic.",
3767        ch = *byte as char
3768    )]
3769    FonteCaminhoShellGlob {
3770        nome: String,
3771        caminho: String,
3772        byte: u8,
3773    },
3774    #[error(
3775        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3776         subshell-grouping metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / \
3777         zsh / dash / ksh / fish / nushell — lexes `(` and `)` as the subshell-grouping \
3778         operator: `(<cmd>)` runs `<cmd>` in a child shell with a fresh environment scope \
3779         (the canonical `(cd <path> && <cmd>)` shell-history one-liner scopes a `cd` to one \
3780         subshell without disturbing the parent's working directory), and `$(<cmd>)` is the \
3781         modern Bourne command-substitution shape the leading-`$` `FonteCaminhoVarExpansion` \
3782         arm closes the leading byte of — together the two arms now structurally exclude the \
3783         entire `$(<cmd>)` substitution surface from the typed `:caminho` accepted set. \
3784         POSIX `std::path::Path` treats the byte as a literal path-component byte, so a \
3785         `:caminho \"../caixa-teia/$(date)/build\"` (the canonical paste-from-shell-history \
3786         modern-command-substitution footgun) or `:caminho \"../(cd foo && pwd)/caixa-teia\"` \
3787         (the symmetric subshell-grouping working-directory-probe paste idiom) silently passes \
3788         every prior arm and the resolver folds the value through `Path::new(caminho).join(\
3789         <file>)` looking for a literal subdirectory and fails at resolve time with a non-\
3790         self-locating `No such file or directory` error far from the source caixa.lisp. The \
3791         lacre pipeline embeds the value verbatim in its per-dep content-address `path:\
3792         {caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 \
3793         closure and rides into every shell-spawned subprocess (the resolver's `git clone`, a \
3794         future `feira tofu` shell-out, a future operator-side `nix` spawn) as the canonical \
3795         shell-metachar / subshell-grouping surface every peer single-token-shaped typed slot \
3796         already closes. The peer `:fonte :repo` axis (3b99147) closes the same byte under the \
3797         same shell-subshell-grouping / RFC-3986-sub-delims banner on `is_git_repo_url`, \
3798         together with the leading-`$` `FonteCaminhoVarExpansion` arm closing the leading byte \
3799         of every `$(<cmd>)` shape. Express the path as a bare relative single-token \
3800         like \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
3801         subshell-grouping semantic.",
3802        ch = *byte as char
3803    )]
3804    FonteCaminhoShellSubshellGrouping {
3805        nome: String,
3806        caminho: String,
3807        byte: u8,
3808    },
3809    #[error(
3810        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3811         brace-expansion / URI-Template placeholder metacharacter 0x{byte:02x} `{ch}` \
3812         (every POSIX-derived brace-expanding shell — bash / zsh / ksh / fish — lexes `{{` / \
3813         `}}` as the brace-expansion operator: `{{a,b,c}}` expands to the cross-product of \
3814         comma-separated members and `{{1..10}}` expands to the integer range — the \
3815         canonical `mkdir -p ../{{caixa-teia,caixa-helm,caixa-flux}}` / `cp file{{,.bak}}` \
3816         idiom every shell-history block carries; RFC 6570 reserves the matched pair for \
3817         URI Template placeholders (the canonical `https://{{host}}/{{org}}/{{repo}}` \
3818         substitution shape every OpenAPI / Swagger / Postman / GitHub Octokit client \
3819         library / Helm chart-URL fragment carries) and the Mustache / Handlebars / \
3820         Tera / Jinja2 / Go html/template doubled-brace substitution form every IaC \
3821         templating engine (Helm, Kustomize, Terraform's `${{var}}` cousin) emits. POSIX \
3822         `std::path::Path` treats the byte as a literal path-component byte, so a \
3823         `:caminho \"../{{caixa-teia,caixa-helm}}/build\"` (the canonical paste-from-\
3824         shell-history brace-expansion fan-across-siblings footgun) or `:caminho \"../{{{{org}}}}/\
3825         caixa-teia\"` (the symmetric paste-from-templated-doc URI-Template placeholder \
3826         idiom every README quick-start / OpenAPI spec / Helm chart `home:` field carries) \
3827         silently passes every prior arm and the resolver folds the value through \
3828         `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
3829         resolve time with a non-self-locating `No such file or directory` error far from \
3830         the source caixa.lisp. The lacre pipeline embeds the value verbatim in its \
3831         per-dep content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, \
3832         so the byte lands in the BLAKE3 closure and rides into every shell-spawned \
3833         subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a \
3834         future operator-side `nix` spawn) as the canonical shell-metachar / brace-\
3835         expansion / URI-Template-placeholder surface every peer single-token-shaped \
3836         typed slot already closes. The peer `:fonte :repo` axis (42d8f9d) closes the \
3837         same byte pair on `is_git_repo_url` under the same RFC-3986-'delims' / \
3838         RFC-6570-URI-Template / shell-brace-expansion banner. Express the path as a \
3839         bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
3840         directory name carries no shell-brace-expansion / URI-Template-placeholder \
3841         semantic; if two siblings actually need pinning, author two separate `:deps` \
3842         entries rather than one brace-expanded `:caminho` value.",
3843        ch = *byte as char
3844    )]
3845    FonteCaminhoShellBraceExpansion {
3846        nome: String,
3847        caminho: String,
3848        byte: u8,
3849    },
3850    #[error(
3851        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3852         bracket-expansion / POSIX glob-character-class / shell-`test`-builtin metacharacter \
3853         0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / nushell \
3854         — lexes the bracket pair as the glob character-class operator: `[abc]` matches one of \
3855         `a` / `b` / `c`, `[a-z]` matches any lowercase ASCII letter, `[^x]` negates — the \
3856         canonical `ls *.[ch]` C-source-file glob and `cd ../caixa-[a-z]*` lowercase-sibling \
3857         glob every shell-history block carries; the bracket pair additionally carries the \
3858         POSIX `test` / `[` builtin command (`[ -d ../caixa-teia ] && cd ...` every shell-\
3859         script conditional uses) and bash's `[[ ... ]]` extended-test grammar; beyond shell \
3860         the pair is the TOML inline-array delimiter (`features = [\"a\", \"b\"]` — the \
3861         canonical paste-from-Cargo-manifest cross-idiom-leak vector), the YAML flow-sequence \
3862         delimiter (`paths: [/a, /b]` — the canonical paste-from-values.yaml cross-idiom \
3863         leak), the JSON array delimiter, and the POSIX-ERE / PCRE bracket-expression anchor. \
3864         POSIX `std::path::Path` treats the byte as a literal path-component byte, so a \
3865         `:caminho \"../caixa-[a-z]/build\"` (the canonical paste-from-shell-history glob-\
3866         character-class fan-across-siblings footgun) or `:caminho \"../[caixa-teia]/build\"` \
3867         (the symmetric paste-from-TOML-array / paste-from-YAML-flow-sequence cross-idiom \
3868         leak) silently passes every prior arm and the resolver folds the value through \
3869         `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
3870         resolve time with a non-self-locating `No such file or directory` error far from \
3871         the source caixa.lisp. The lacre pipeline embeds the value verbatim in its per-dep \
3872         content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte \
3873         lands in the BLAKE3 closure and rides into every shell-spawned subprocess (the \
3874         resolver's `git clone`, a future `feira tofu` shell-out, a future operator-side \
3875         `nix` spawn) as the canonical shell-metachar / glob-character-class / TOML-array \
3876         surface every peer single-token-shaped typed slot already closes. Express the path \
3877         as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
3878         directory name carries no shell-bracket-expansion / glob-character-class / array-\
3879         literal semantic; if a family of sibling caixas actually needs pinning, author \
3880         separate `:deps` entries rather than one character-class-expanded `:caminho` value.",
3881        ch = *byte as char
3882    )]
3883    FonteCaminhoShellBracketExpansion {
3884        nome: String,
3885        caminho: String,
3886        byte: u8,
3887    },
3888    #[error(
3889        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3890         quote-grouping / cross-config-DSL string-literal-delimiter metacharacter \
3891         0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / \
3892         nushell — lexes `'` as the strong string-literal delimiter (`'…'` — no expansion) \
3893         and `\"` as the weak string-literal delimiter (`\"…\"` — variable- / command-\
3894         substitution-preserving); the canonical `cd '../caixa-teia'` shell-history idiom \
3895         every path-with-embedded-whitespace paste block carries and the symmetric \
3896         `git clone \"$REPO\"` weak-quoted CI-manifest shape both leak the pair verbatim. \
3897         Beyond shell the pair is the JSON string-literal delimiter (`\"key\": \"value\"` — \
3898         the canonical paste-from-JSON-config cross-idiom-leak vector), the YAML double- \
3899         and single-quoted flow-scalar delimiter (`path: \"../caixa-teia\"` — the canonical \
3900         paste-from-values.yaml / paste-from-K8s-YAML-manifest cross-idiom leak), the TOML \
3901         basic and literal string delimiter (`path = \"../caixa-teia\"` — the canonical \
3902         paste-from-Cargo-manifest cross-idiom leak), the tatara-lisp string-literal \
3903         delimiter itself (`(:caminho \"../caixa-teia\")` — the canonical \"I copied the \
3904         entire `:caminho \"...\"` slot rather than just the string body\" author-surface \
3905         footgun), and RFC 3986 §2.2's `gen-delims` / `sub-delims` grammar which excludes \
3906         both bytes from the `pchar = unreserved / pct-encoded / sub-delims / \":\" / \"@\"` \
3907         production. POSIX `std::path::Path` treats the byte as a literal path-component \
3908         byte, so a `:caminho \"'../caixa-teia'\"` (the canonical paste-from-shell-history \
3909         strong-quoted sibling-workspace path footgun) or `:caminho \"\\\"../caixa-teia\\\"\"` \
3910         (the symmetric weak-quoted paste-from-JSON / paste-from-YAML flow-scalar / paste-\
3911         from-TOML basic-string / paste-from-tatara-lisp string-literal cross-idiom-leak \
3912         shape) silently passes every prior arm and the resolver folds the value through \
3913         `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
3914         resolve time with a non-self-locating `No such file or directory` error far from \
3915         the source caixa.lisp. The lacre pipeline embeds the value verbatim in its per-dep \
3916         content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte \
3917         lands in the BLAKE3 closure and rides into every shell-spawned subprocess (the \
3918         resolver's `git clone`, a future `feira tofu` shell-out, a future operator-side \
3919         `nix` spawn) as the canonical shell-metachar / string-literal-delimiter surface \
3920         every peer single-token-shaped typed slot already closes. The peer `:fonte :repo` \
3921         axis closes both bytes under the same shell-quote-grouping / RFC-3986-sub-delims \
3922         banner (e7a109f `'` shell-single-quote + 4267d8b `\"` shell-double-quote on \
3923         `is_git_repo_url`). Express the path as a bare relative single-token like \
3924         \"../caixa-teia\" — the sibling-workspace directory name carries no shell-quote-\
3925         grouping / string-literal-delimiter semantic; strip the outer quote pair from the \
3926         paste (the tatara-lisp `:caminho \"...\"` slot already carries the string-literal \
3927         quoting on the outer syntactic layer, so an inner quote pair would nest and \
3928         desugar to a broken layer).",
3929        ch = *byte as char
3930    )]
3931    FonteCaminhoShellQuoteGrouping {
3932        nome: String,
3933        caminho: String,
3934        byte: u8,
3935    },
3936    #[error(
3937        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3938         comment / URL-fragment-identifier / YAML-comment cross-config-DSL metacharacter \
3939         0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / \
3940         nushell — lexes an unquoted `#` at the head of a word or after unquoted \
3941         whitespace as the comment-lead per POSIX.1-2017 §2.3 Token Recognition step 6, \
3942         discarding the byte and everything after it to the end of the physical line \
3943         before command parsing (`cd ../caixa-teia  # legacy sibling` — the canonical \
3944         paste-from-shell-history-with-trailing-annotation shape every operator-notebook \
3945         and CI-manifest carries); YAML 1.2 §6.6 makes `#` the comment-lead at any \
3946         position preceded by whitespace or at line-start (`path: ../caixa-teia  # pin` \
3947         — the canonical paste-from-values.yaml / paste-from-K8s-manifest cross-idiom-\
3948         leak); RFC 3986 §3.5 reserves `#` as the URL fragment-identifier delimiter (the \
3949         canonical paste-from-browser-address-bar `github.com/foo/bar#readme` / \
3950         `github.com/foo/bar#L42` permalink shape, and the symmetric Nix-flake-ref \
3951         cross-idiom leak `github:foo/bar#packageName` where `#` selects a flake \
3952         output); the same cross-config-DSL surface extends to HCL / Terraform / Nix \
3953         flake attributes / dotenv `.env` / gitconfig / .gitignore / ini / TOML where \
3954         `#` is likewise the comment-lead. POSIX `std::path::Path` treats the byte as a \
3955         literal path-component byte, so a `:caminho \"../caixa-teia # legacy sibling\"` \
3956         (the canonical paste-from-shell-history-with-trailing-annotation footgun), \
3957         `:caminho \"../caixa-teia  # pin\"` (the symmetric YAML flow-scalar paste-with-\
3958         trailing-comment shape), or `:caminho \"../caixa-teia#readme\"` (the URL \
3959         fragment paste-from-browser-address-bar shape) silently passes every prior arm \
3960         and the resolver folds the value through `Path::new(caminho).join(<file>)` \
3961         looking for a literal subdirectory named `../caixa-teia # legacy sibling` and \
3962         fails at resolve time with a non-self-locating `No such file or directory` \
3963         error far from the source caixa.lisp — while every downstream shell / YAML / \
3964         URL parser silently truncates the value at the `#` byte to `../caixa-teia`, so \
3965         a `feira tofu` shell-out and a `nix flake check` on an emitted YAML `path:` \
3966         scalar disagree with the resolver on which directory the value names. The \
3967         lacre pipeline embeds the value verbatim in its per-dep content-address \
3968         `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in \
3969         the BLAKE3 closure and rides into every shell-spawned subprocess (the \
3970         resolver's `git clone`, a future `feira tofu` shell-out, a future operator-\
3971         side `nix` spawn) as the canonical shell-metachar / comment-lead / URL-\
3972         fragment-delimiter surface every peer single-token-shaped typed slot already \
3973         closes. The peer `:fonte :repo` axis closes the byte under the same URL-\
3974         fragment-identifier banner (a68f818 `#` on `is_git_repo_url`). Express the \
3975         path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
3976         workspace directory name carries no shell-comment / URL-fragment / YAML-\
3977         comment semantic; move any trailing annotation to a tatara-lisp `;`-comment \
3978         on the surrounding form (`;; legacy sibling` above the `(:caminho ...)` slot) \
3979         and drop any `#fragment` tail entirely (fragment identifiers select \
3980         renderings, not directories, and `:caminho` names a directory).",
3981        ch = *byte as char
3982    )]
3983    FonteCaminhoShellComment {
3984        nome: String,
3985        caminho: String,
3986        byte: u8,
3987    },
3988    #[error(
3989        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains URL-\
3990         percent-encoding-escape / printf-format-specifier / bash-job-control-specifier \
3991         / YAML-directive-lead metacharacter 0x{byte:02x} `{ch}` (RFC 3986 §2.1 reserves \
3992         `%` as the URL percent-encoding-escape — `%HH` is the mandatory encoding \
3993         mechanism for every byte outside the `unreserved` alphanumeric / `-` / `.` / \
3994         `_` / `~` set, and `%` itself must be percent-encoded as `%25` to appear \
3995         literally inside a URL value. The canonical paste-from-browser-address-bar \
3996         percent-encoded-space footgun (an author copies `../caixa%20teia` out of a URL-\
3997         encoded README hyperlink / browser address bar / percent-encoded permalink \
3998         expecting `%20` to decode to a literal space at the filesystem layer) locks two \
3999         distinct BLAKE3 closures (`path:../caixa%20teia` vs `path:../caixa teia`) for \
4000         what the author intended as the byte-identical sibling-workspace dep. POSIX \
4001         `std::path::Path` treats the byte as a literal path-component byte, so \
4002         `Path::join` looks for a literal `./{caminho}` subdirectory and fails at \
4003         resolve time with a non-self-locating `No such file or directory` error far \
4004         from the source caixa.lisp — while every downstream URL parser / shell printf \
4005         builtin / YAML directive parser silently reinterprets the byte to a different \
4006         value than the resolver's `Path::join` sees. Beyond the URL-encoding hazard, \
4007         `%` is the C / POSIX printf format-directive lead-in (`%s`, `%d`, `%02x` — \
4008         wired into every POSIX shell's `printf` builtin, the canonical CWE-134 format-\
4009         string-injection vector); the bash / zsh / ksh job-control-specifier lead-in \
4010         (`%1` names \"job 1\", `%%` names \"the current job\", `%foo` names \"the most \
4011         recent job whose command started with `foo`\" — a future `kill %1` invocation \
4012         silently redirects the signal to a wrong target); the YAML 1.2 §6.8.1 \
4013         directive lead-in (`%YAML 1.2` / `%TAG` — the paste-from-top-of-doc YAML \
4014         directive block cross-idiom leak); and the Windows-shell env-var-reference \
4015         lead-in (`%PATH%` — the paste-from-`.bat` / paste-from-PowerShell-`%env:PATH%` \
4016         cross-idiom leak). The lacre pipeline embeds the value verbatim in its per-dep \
4017         content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the \
4018         byte lands in the BLAKE3 closure and rides into every shell-spawned subprocess \
4019         (the resolver's `git clone`, a future `feira tofu` shell-out, a future \
4020         operator-side `nix` spawn) as the canonical URL-percent-encoding-escape / \
4021         printf-format-specifier / job-control-specifier surface every peer single-\
4022         token-shaped typed slot already closes. The peer `:fonte :repo` axis closes \
4023         the byte under the same URL-percent-encoding-escape banner (a323db8 `%` on \
4024         `is_git_repo_url`). Express the path as a bare relative single-token like \
4025         \"../caixa-teia\" — the sibling-workspace directory name carries no URL-\
4026         percent-encoding-escape / format-specifier / job-control semantic; substitute \
4027         any `%20` percent-encoded-space with a literal space then reject the whole \
4028         value at the leading-whitespace / embedded-`?` arm on the same axis (a caixa \
4029         directory name never carries an embedded space in practice); drop any \
4030         `%2F`-encoded path separator in favor of a literal `/`; and drop any leading \
4031         `%YAML` / `%PATH%` cross-idiom-leak prefix entirely.",
4032        ch = *byte as char
4033    )]
4034    FonteCaminhoUrlPercentEncoding {
4035        nome: String,
4036        caminho: String,
4037        byte: u8,
4038    },
4039    #[error(
4040        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4041         variable-expansion / command-substitution / arithmetic-expansion / cross-config-\
4042         DSL-interpolation metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — sh / \
4043         bash / zsh / dash / ksh / busybox ash / fish / nushell — lexes `$` per \
4044         POSIX.1-2017 §2.6 as the variable-expansion `$<name>` / braced-form `${{<name>}}` \
4045         / command-substitution `$(<cmd>)` / arithmetic-expansion `$((<expr>))` operator; \
4046         Nix uses `${{var}}` as the string-interpolation lead, Make uses `$(var)` / `$@` \
4047         / `$<` for variables and automatic-variables, JavaScript / TypeScript template \
4048         literals use `${{expr}}` for interpolation, envsubst / Kubernetes / OpenShift \
4049         templates use `${{VAR}}` for env-var-reference, PHP uses `$_GET` / `$_ENV` for \
4050         superglobals, Perl uses `$foo` for scalars, SASS / SCSS uses `$primary-color` \
4051         for variables, and PostgreSQL / SQLite use `$1` / `$2` for bind parameters — \
4052         the byte is a first-class parser byte in nearly every config / templating / \
4053         build-system DSL the substrate's paste-idiom surface routinely crosses. POSIX \
4054         `std::path::Path` treats the byte as a literal path-component byte, so the \
4055         canonical paste-from-shell-one-liner `:caminho \"../foo$HOME/bar\"` / paste-\
4056         from-CI-manifest `:caminho \"../foo${{WORKSPACE}}/bar\"` / paste-from-shell-\
4057         prompt `:caminho \"../foo$(whoami)/bar\"` footguns silently pass every prior \
4058         cascade arm (`$` isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / \
4059         `?` / `(` / `)` / `{{` / `}}` / `[` / `]` / `'` / `\"` / `#` / `%`) and route \
4060         through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
4061         subdirectory that fails at resolve time with a non-self-locating `No such file \
4062         or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
4063         the value verbatim in its per-dep content-address `path:{caminho}` at \
4064         caixa-resolver/src/resolve.rs:189, so byte-identical caixa.lisp values differing \
4065         only in whether the author substituted `$HOME` / `${{WORKSPACE}}` at author \
4066         time lock to two distinct BLAKE3 closures across two workstations whose \
4067         downstream envsubst / Nix / Make / K8s-template layers differ in `$VAR` \
4068         recognition — defeating the THEORY.md §V.2 render-determinism contract on the \
4069         same axis every prior `:caminho` arm protects. Beyond the determinism vector, \
4070         `$` at any position in a value flowing verbatim into a shell-spawned subprocess \
4071         is the canonical CWE-78 shell-command-injection surface every peer single-\
4072         token-shaped typed slot already closes: peer `:fonte :repo` axis rejects `$` \
4073         under the shell-variable-expansion / URL-sub-delim banner via `is_git_repo_url` \
4074         (b9d187c), peer `:fonte :tag` / `:fonte :branch` axes reject `$` as part of \
4075         `is_git_ref_name`'s printable-ASCII-restricted grammar (`git check-ref-format` \
4076         rejects the byte outright), and peer `:entrada :paths` axis rejects `$` via \
4077         `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. The leading-`$` \
4078         position on the same axis routes through `FonteCaminhoVarExpansion` at the \
4079         f4efe9c leading-byte arm; this arm closes the last positional gap on the byte \
4080         so every position — leading and embedded — is structurally rejected. Substitute \
4081         the `$VAR` / `${{VAR}}` / `$(cmd)` template with the literal value at author \
4082         time, or express the path as a bare relative single-token like \
4083         \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
4084         variable-expansion / command-substitution / arithmetic-expansion semantic.",
4085        ch = *byte as char
4086    )]
4087    FonteCaminhoShellVariableExpansion {
4088        nome: String,
4089        caminho: String,
4090        byte: u8,
4091    },
4092    #[error(
4093        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4094         history-expansion / RFC-3986-sub-delims / bang-operator metacharacter 0x{byte:02x} \
4095         `{ch}` (every interactive POSIX shell with history enabled — bash / ksh / zsh's \
4096         `bashcompat` / csh / tcsh — lexes `!` as the history-expansion prefix per bash \
4097         reference §9.3: `!command` re-runs the most recent history entry beginning with \
4098         `command`, `!!` re-runs the prior command verbatim, `!$` substitutes the last \
4099         word of the prior command, `!:N` substitutes the Nth word of the prior command, \
4100         and the substitution fires at every history-expansion-enabled shell context — \
4101         `set -o histexpand` is bash's default for interactive sessions and the layer \
4102         every `feira tofu` / `git clone` / `nix flake check` subprocess-argument \
4103         invocation crosses when spawned under `bash -i`. Beyond shell history, RFC 3986 \
4104         §2.2 lists `!` in the `sub-delims` set (the URL grammar admits the byte inside \
4105         a path segment, but every WHATWG-conformant special-scheme URL parser percent-\
4106         encodes it inside a query component via the 'special-query percent-encode set' \
4107         the peer `is_git_repo_url` `*` / `(` / `)` / `'` arms close on); the byte is \
4108         also the C / C++ / Rust / JavaScript / Python bang-operator (logical-negation \
4109         prefix — the paste-from-source-code idiom where an author copies \
4110         `!path.exists()` out of a Rust snippet and the trailing punctuation crosses \
4111         the string-literal boundary); the canonical English-typography emphasis / \
4112         exclamation mark (the paste-from-prose enthusiasm-form idiom where an author \
4113         writes `:caminho \"../caixa-teia!\"` expecting the substrate to coerce it to a \
4114         kebab-case slug); and the Nix flake-ref attribute-selection operator surface. \
4115         POSIX `std::path::Path` treats `!` as a literal path-component byte, so the \
4116         canonical paste-from-shell-history footgun `:caminho \"../caixa-teia!sudo\"` \
4117         (an author copies a `cd ../caixa-teia && !sudo make install` one-liner from a \
4118         quick-start README and the trailing `!sudo` rides in verbatim as a history-\
4119         expansion reference), the symmetric `:caminho \"../foo!!/bar\"` (the `!!` \
4120         repeat-prior-command paste idiom), the English-typography `:caminho \
4121         \"../caixa-teia!\"` (paste-from-prose enthusiasm-form), and the last-word-\
4122         substitution `:caminho \"../foo!$\"` shape silently pass every prior cascade \
4123         arm (`!` isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / `?` / `(` \
4124         / `)` / `{{` / `}}` / `[` / `]` / `'` / `\"` / `#` / `%` / `$`) and route \
4125         through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
4126         subdirectory that fails at resolve time with a non-self-locating `No such file \
4127         or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
4128         the value verbatim in its per-dep content-address `path:{caminho}` at \
4129         caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
4130         rides into every shell-spawned subprocess (the resolver's `git clone`, a \
4131         future `feira tofu` shell-out, a future operator-side `nix flake check` spawn) \
4132         as the canonical shell-history-expansion / RFC-3986-sub-delims surface every \
4133         peer single-token-shaped typed slot already closes. The peer `:fonte :repo` \
4134         axis closes the byte under the same shell-history-expansion / RFC-3986-sub-\
4135         delims banner (7d53c68 `!` on `is_git_repo_url`). Express the path as a bare \
4136         relative single-token like \"../caixa-teia\" — the sibling-workspace directory \
4137         name carries no shell-history-expansion / bang-operator semantic; drop any \
4138         `!sudo` / `!!` / `!$` history-expansion trailing paste-from-shell-history \
4139         idiom; and drop any trailing English-typography exclamation mark that pasted \
4140         from prose.",
4141        ch = *byte as char
4142    )]
4143    FonteCaminhoShellHistoryExpansion {
4144        nome: String,
4145        caminho: String,
4146        byte: u8,
4147    },
4148    #[error(
4149        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4150         history-substitution / RFC-3986-'unwise' / regex-negation metacharacter 0x{byte:02x} \
4151         `{ch}` (POSIX bash's `set -o histexpand` mode — the default for every interactive \
4152         session and every `bash -i` subprocess-argument context `feira tofu` / `git clone` / \
4153         `nix flake check` cross — lexes `^old^new^` per bash reference §9.3 as the 'quick \
4154         substitution' history operator that rewrites the prior command's `old` string to \
4155         `new` and re-executes it verbatim, the canonical typo-correction one-liner idiom \
4156         (`git clone <bad-url>` → `^bad^good` typo-fix-and-rerun the paste-from-shell-\
4157         history author trims only the leading `git clone` prefix from). RFC 3986 §2 lists \
4158         `^` in the 'unwise' set every URL parser is required to percent-encode-or-refuse at \
4159         the wire boundary, and the WHATWG URL spec's 'fragment percent-encode set' maps \
4160         `^` → `%5E` at the query / fragment component transition, so `Path::join` on the \
4161         literal value diverges from every downstream `feira tofu` curl-invocation / \
4162         artifact-registry-fetch that percent-encodes the byte before the wire. `^` is also \
4163         the regex character-class negation prefix (`[^abc]`), the bitwise XOR operator in \
4164         C / C++ / Rust / Python / JavaScript / Nix / Go, the Windows `cmd.exe` escape \
4165         metacharacter, and the LaTeX / Markdown / BibTeX superscript operator. POSIX \
4166         `std::path::Path` treats `^` as a literal path-component byte, so \
4167         `:caminho \"../foo^bar/baz\"` (embedded quick-substitution), `:caminho \
4168         \"../foo^\"` (trailing history-substitution-open shape), or `:caminho \"../x^y\"` \
4169         (XOR-expression paste-from-source) silently pass every prior cascade arm (`^` \
4170         isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / `?` / `(` / `)` / `{{` \
4171         / `}}` / `[` / `]` / `'` / `\"` / `#` / `%` / `$` / `!`) and route through \
4172         `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` subdirectory \
4173         that fails at resolve time with a non-self-locating `No such file or directory` \
4174         error far from the source caixa.lisp. The lacre pipeline embeds the value verbatim \
4175         in its per-dep content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, \
4176         so the byte lands in the BLAKE3 closure and rides into every shell-spawned \
4177         subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a future \
4178         operator-side `nix flake check` spawn) as the canonical shell-history-substitution \
4179         / RFC-3986-unwise surface every peer single-token-shaped typed slot already closes. \
4180         The peer `:fonte :repo` axis closes the byte under the same shell-history-\
4181         substitution / RFC-3986-unwise banner (49e142f `^` on `is_git_repo_url`). Together \
4182         with the immediate-predecessor `!` arm (6a04767) this arm closes the full `set -o \
4183         histexpand` operator surface on the `:caminho` axis — the `!command` / `!!` / `!$` \
4184         prefix form via `!`, the `^old^new^` quick-substitution form via `^`. Express the \
4185         path as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
4186         directory name carries no shell-history-substitution / regex-negation / XOR-operator \
4187         semantic; drop any `^old^new` history-substitution paste-from-shell-history idiom; \
4188         drop any trailing `^` history-substitution-open fragment.",
4189        ch = *byte as char
4190    )]
4191    FonteCaminhoShellHistorySubstitution {
4192        nome: String,
4193        caminho: String,
4194        byte: u8,
4195    },
4196    #[error(
4197        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} has a trailing \
4198         `/` (the resolver's `Path::join` resolves `\"../caixa-teia\"` and \
4199         `\"../caixa-teia/\"` to the same directory, but the lacre pipeline embeds the \
4200         value verbatim in its per-dep content-address `path:{caminho}` at \
4201         caixa-resolver/src/resolve.rs:189, so two authors whose only difference is \
4202         shell tab-completion emit byte-divergent BLAKE3 closures for the same caixa — \
4203         defeating the THEORY.md §V.2 render-determinism contract via the trailing-\
4204         separator vector (the canonical paste-from-shell-tab-completion + paste-from-\
4205         `pwd`-with-`/`-suffix footgun, and the canonical Cargo-style `path = \
4206         \"../caixa-teia/\"` paste-from-Cargo-manifest cross-idiom leak). Drop the \
4207         trailing `/`; every `:caminho` value names a sibling-workspace directory \
4208         already, so the trailing separator carries no information. Use \
4209         `\"../caixa-teia\"` rather than `\"../caixa-teia/\"`)"
4210    )]
4211    FonteCaminhoTrailingSlash { nome: String, caminho: String },
4212    #[error(
4213        "{list} carries duplicate entry :nome {nome:?} — every dep list keys its \
4214         entries by caixa name (Cargo's [dependencies] / [dev-dependencies] tables \
4215         apply the same set-not-multiset discipline; one package per table), and \
4216         two entries naming the same caixa carry two version constraints / source \
4217         pins / feature sets for one identity. The caixa-resolver's lacre pipeline \
4218         consumes the list as a `HashMap`-keyed-by-`:nome` lookup: the second entry \
4219         silently overwrites the first at the resolver-side `concrete_versao` step, \
4220         and the dropped entry's pin / features never reach the closure — far from \
4221         the source caixa.lisp, with no field naming which `:deps` entry was the \
4222         silent loser. If two version constraints are genuinely needed (the rare \
4223         multi-version closure case the lacre pipeline doesn't yet support), the \
4224         author surface is two distinct caixa names (e.g. a `caixa-teia-v01` / \
4225         `caixa-teia-v02` aliased pair); within one list, one entry per caixa name."
4226    )]
4227    DuplicateNome { nome: String, list: &'static str },
4228    #[error(
4229        ":deps entry {nome:?} has empty :caracteristicas entry — every feature flag must \
4230         name a non-empty identifier on the target caixa (Cargo's [dependencies.<dep>.features] \
4231         applies the same per-entry non-empty discipline). An empty feature flag reaches the \
4232         caixa-resolver's lacre pipeline as a no-op feature enable, silently dropping the \
4233         author's intent far from the source caixa.lisp; drop the empty entry, or replace it \
4234         with the canonical kebab-case feature name the target caixa declares."
4235    )]
4236    CaracteristicaEmpty { nome: String },
4237    #[error(
4238        ":deps entry {nome:?} :caracteristicas entry {caracteristica:?} is not a valid Cargo \
4239         feature name: {reason} (the value flows verbatim into Cargo's \
4240         [dependencies.<dep>.features] list and Cargo's `restricted_names::validate_feature_name` \
4241         parser enforces the same shape at `cargo metadata` time; use a single-token \
4242         identifier like `\"http\"`, `\"derive\"`, or `\"runtime-tokio\"` — kebab-case ASCII \
4243         alphanumeric with `-`, `_`, `+`, or `.` as continuation characters, starting with \
4244         an ASCII alphanumeric or `_`)"
4245    )]
4246    CaracteristicaInvalid {
4247        nome: String,
4248        caracteristica: String,
4249        reason: String,
4250    },
4251    #[error(
4252        ":deps entry {nome:?} :caracteristicas carries duplicate feature {caracteristica:?} — \
4253         every feature-flag list keys its entries by name (Cargo's \
4254         [dependencies.<dep>.features] applies the same set-not-multiset discipline; one entry \
4255         per feature per dep), and two entries naming the same feature are a redundant \
4256         set-membership declaration for one identity (the feature-toggle slot is set-shaped; \
4257         enabling a feature twice has no additional semantic). The caixa-resolver's lacre \
4258         pipeline consumes the list as a set-shaped feature toggle — the resolver enables the \
4259         feature once regardless of declaration count, so the duplicate's pin / position never \
4260         reaches the closure with no field naming the silent loser. One entry per feature per \
4261         dep; if two distinct features are intended, name each verbatim."
4262    )]
4263    CaracteristicaDuplicate {
4264        nome: String,
4265        caracteristica: String,
4266    },
4267    #[error(
4268        "{list} entry :nome {nome:?} names the caixa itself — a caixa cannot depend \
4269         on itself (the lacre closure's dep-graph traversal is rooted at the caixa's \
4270         :nome, and a self-dep would be a one-node cycle the caixa-resolver either \
4271         rejects mid-traversal far from the source caixa.lisp or recurses on until \
4272         it exhausts its stack). Every :nome is globally-unique substrate identity, \
4273         so a :deps / :deps-dev entry whose :nome equals the parent caixa's :nome \
4274         *is* the parent itself, not a coincidentally-named peer. Drop the \
4275         self-referential dep entry — to reference code from this caixa, use \
4276         :bibliotecas / :exe / :servicos (the substrate-blessed shape for \
4277         referencing the caixa's own code surface) instead."
4278    )]
4279    DepIsSelf { nome: String, list: &'static str },
4280}
4281
4282// Fold the eleven `DepError::FonteCaminho<Variant> { nome: nome.to_string(),
4283// caminho: caminho.to_string() }` two-slot struct-variant wire-up sites at
4284// [`DepSource::validate_caminho`] onto one substrate primitive per typed
4285// variant — the paired `{ nome: String, caminho: String }` two-slot family
4286// on [`DepError`], sibling of the peer
4287// [`crate::supervisor::supervisor_caixa_only_ctors!`] (db09650, 3 variants
4288// on `{ caixa: String }`) on the `SupervisorError` envelope, the peer
4289// [`crate::aplicacao::contrato_empty_pair_ctors!`] (8580068, 4 variants on
4290// `{ de, para }`), [`crate::aplicacao::aplicacao_field_reason_ctors!`]
4291// (981060b, 7 variants on `{ <field>: String, reason: String }`),
4292// [`crate::aplicacao::contrato_target_ctors!`] (14b81d5, 2 variants on
4293// `{ de, para, wit, expected }`), and
4294// [`crate::aplicacao::contrato_pair_value_reason_ctors!`] (14e13f1, 3
4295// variants on `{ de, para, <field>: String, reason: String }`) on the
4296// `AplicacaoError` envelopes, the peer
4297// [`crate::layout::layout_violation_ctors!`] (131ca0d, 16 variants on
4298// `{ caixa, issue }`), [`crate::layout::layout_slot_kind_ctors!`]
4299// (0419438, 4 variants on `{ caixa, kind, slots }`),
4300// [`crate::LayoutError::missing_entry`] (1b09f9d, one variant on
4301// `{ kind, path }`), and [`crate::layout::layout_nome_only_ctors!`]
4302// (3fe3dd7, 6 variants on `<Variant>(String)`) on the `LayoutError`
4303// envelopes, the peer three [`crate::limits::limits_codec_value_*_ctors!`]
4304// codec-family macros (81c856c, 12 wire-ups) on the `LimitsError`
4305// envelope, and the peer [`crate::upgrade::upgrade_from_script_ctors!`]
4306// (8e67041, 3 variants on `{ from: String, script: PathBuf }`) on the
4307// `UpgradeError` envelope. First fold family on this `DepError` envelope.
4308//
4309// Each of the eleven wire-up sites on this shape (the leading-byte cascade
4310// closing the seven `FonteCaminho{Absolute, TildeExpansion, VarExpansion,
4311// LeadingWhitespace, LeadingHyphen}` arms; the orthogonal single-metachar
4312// cascade closing `FonteCaminhoBackslash` on `\`; the shell-lexer-metachar
4313// cascade closing `FonteCaminhoShell{Pipe, Semicolon, Background,
4314// CommandSubstitution}` on the four single-byte shell operators; and the
4315// trailing-`/` reproducibility arm closing `FonteCaminhoTrailingSlash`)
4316// opened the identical `DepError::FonteCaminho<Variant> { nome:
4317// nome.to_string(), caminho: caminho.to_string() }` four-line
4318// struct-literal against the same `(nome: &str, caminho: &str)` local pair
4319// — the exact "same block re-inlined at every consumer" shape the PRIME
4320// DIRECTIVE names as a bug, on the same altitude the peer `LayoutError` /
4321// `AplicacaoError` / `SupervisorError` / `LimitsError` / `UpgradeError`
4322// families each closed on their sibling envelopes. The eleven variants
4323// share one `{ nome: String, caminho: String }` shape, so the fold routes
4324// each wire-up site through one dispatch per typed variant.
4325//
4326// The macro below generates one `#[must_use]` inherent constructor per
4327// variant of shape `fn <ctor>(nome: &str, caminho: &str) -> Self`, so every
4328// wire-up site collapses onto one dispatch:
4329// `DepError::<ctor>(nome, caminho)`, byte-equal to the pre-lift
4330// struct-literal on the same `(&str, &str)` fixture. The uniform two-field
4331// construction (`nome.to_string()` / `caminho.to_string()`) is spelled
4332// once — inside the macro — rather than at every wire-up site.
4333//
4334// The twelve `FonteCaminho<Variant> { nome, caminho, byte }` three-field
4335// shapes at the per-byte-classification arms — the
4336// `FonteCaminho{ControlChar,ShellRedirection,ShellGlob,
4337// ShellSubshellGrouping,ShellBraceExpansion,ShellBracketExpansion,
4338// ShellQuoteGrouping,ShellComment,UrlPercentEncoding,
4339// ShellVariableExpansion,ShellHistoryExpansion,ShellHistorySubstitution}`
4340// cluster — carry an additional `byte: u8` naming the offending byte and
4341// so would break the uniform-two-field routing this macro promises. They
4342// instead fold onto the sibling three-field envelope through
4343// [`fonte_caminho_byte_ctors!`] (this-commit-lift, 12 variants on the
4344// `{ nome, caminho, byte }` shape), whose sole additional axis over this
4345// two-slot family is the `byte: u8` classification the arms carry. The
4346// remaining `FonteCaminhoEmpty` one-field `{ nome }` shape at the empty-
4347// first arm folds instead onto the peer [`dep_nome_only_ctors!`]
4348// (792aa92, 5 variants on `{ nome: String }`) sibling family of this
4349// envelope.
4350//
4351// Every future consumer that wants to construct one of these eleven
4352// variants outside the current in-crate [`DepSource::validate_caminho`]
4353// wire-up sites (a deferred `caixa-resolver` per-`:caminho` re-validator
4354// at lacre-resolve time re-checking the same value-shape axes the resolver
4355// consumes, a future `feira validate --deps` per-caixa admission verb
4356// re-checking the `:fonte :caminho` axis, a per-lacre overlay resolver
4357// rejecting a `:caminho` value against a cluster-local snapshot) now
4358// reaches each variant through one call rather than re-inlining the
4359// four-line struct-literal in lockstep with the eleven in-crate wire-up
4360// sites.
4361macro_rules! fonte_caminho_ctors {
4362    ($($ctor:ident => $variant:ident),* $(,)?) => {
4363        impl DepError {
4364            $(
4365                #[doc = concat!(
4366                    "Construct a [`DepError::",
4367                    stringify!($variant),
4368                    "`] naming the offending `:deps :nome` + `:fonte ",
4369                    "(:tipo path …) :caminho` pair. Folds the uniform ",
4370                    "`Self::",
4371                    stringify!($variant),
4372                    " { nome: nome.to_string(), caminho: caminho.to_string() }` ",
4373                    "two-slot struct-literal onto one substrate primitive so ",
4374                    "every [`DepSource::validate_caminho`] wire-up on this ",
4375                    "variant reads through one dispatch rather than the ",
4376                    "pre-lift four-line open-coded block."
4377                )]
4378                #[must_use]
4379                pub fn $ctor(nome: &str, caminho: &str) -> Self {
4380                    Self::$variant {
4381                        nome: nome.to_string(),
4382                        caminho: caminho.to_string(),
4383                    }
4384                }
4385            )*
4386        }
4387    };
4388}
4389
4390fonte_caminho_ctors! {
4391    fonte_caminho_absolute => FonteCaminhoAbsolute,
4392    fonte_caminho_tilde_expansion => FonteCaminhoTildeExpansion,
4393    fonte_caminho_var_expansion => FonteCaminhoVarExpansion,
4394    fonte_caminho_leading_whitespace => FonteCaminhoLeadingWhitespace,
4395    fonte_caminho_leading_hyphen => FonteCaminhoLeadingHyphen,
4396    fonte_caminho_backslash => FonteCaminhoBackslash,
4397    fonte_caminho_shell_pipe => FonteCaminhoShellPipe,
4398    fonte_caminho_shell_semicolon => FonteCaminhoShellSemicolon,
4399    fonte_caminho_shell_background => FonteCaminhoShellBackground,
4400    fonte_caminho_shell_command_substitution => FonteCaminhoShellCommandSubstitution,
4401    fonte_caminho_trailing_slash => FonteCaminhoTrailingSlash,
4402}
4403
4404// Fold the twelve `DepError::FonteCaminho<Variant> { nome: nome.to_string(),
4405// caminho: caminho.to_string(), byte: b }` three-slot struct-variant wire-up
4406// sites at [`DepSource::validate_caminho`] onto one substrate primitive per
4407// typed variant — the paired `{ nome: String, caminho: String, byte: u8 }`
4408// three-slot family on [`DepError`], strict sibling of the peer
4409// [`fonte_caminho_ctors!`] (f85f145, 11 variants on the two-slot
4410// `{ nome: String, caminho: String }` envelope) of this envelope. Extends
4411// that fold onto the `byte`-classifying arms whose additional `byte: u8`
4412// axis broke its uniform-two-field routing — the exact "future compounding
4413// work" the pre-lift `fonte_caminho_ctors!` prose named as deferred, closed
4414// here. Third fold family on this `DepError` envelope, sibling of the peer
4415// two-slot [`fonte_caminho_ctors!`] and one-slot [`dep_nome_only_ctors!`]
4416// (792aa92, 5 variants on the `{ nome: String }` envelope) families on the
4417// same enum.
4418//
4419// Each of the twelve wire-up sites on this shape (the control-byte arm
4420// closing `FonteCaminhoControlChar` on the sub-`0x20` / `0x7F` cluster; the
4421// shell-lexer-metachar cascade closing `FonteCaminhoShellRedirection` on
4422// `< >`, `FonteCaminhoShellGlob` on `* ?`, `FonteCaminhoShellSubshellGrouping`
4423// on `( )`, `FonteCaminhoShellBraceExpansion` on `{ }`,
4424// `FonteCaminhoShellBracketExpansion` on `[ ]`, and
4425// `FonteCaminhoShellQuoteGrouping` on `' "`; the single-metachar arms
4426// closing `FonteCaminhoShellComment` on `#`, `FonteCaminhoUrlPercentEncoding`
4427// on `%`, `FonteCaminhoShellVariableExpansion` on `$`,
4428// `FonteCaminhoShellHistoryExpansion` on `!`, and
4429// `FonteCaminhoShellHistorySubstitution` on `^`) opened the identical
4430// `DepError::FonteCaminho<Variant> { nome: nome.to_string(),
4431// caminho: caminho.to_string(), byte: b }` five-line struct-literal against
4432// the same `(nome: &str, caminho: &str, b: u8)` local triple — the exact
4433// "same block re-inlined at every consumer" shape the PRIME DIRECTIVE names
4434// as a bug, on the same altitude the peer two-slot `fonte_caminho_ctors!`
4435// closed on the sibling two-field envelope of this same enum. The twelve
4436// variants share one `{ nome: String, caminho: String, byte: u8 }` shape, so
4437// the fold routes each wire-up site through one dispatch per typed variant.
4438//
4439// The macro below generates one `#[must_use]` inherent constructor per
4440// variant of shape `fn <ctor>(nome: &str, caminho: &str, byte: u8) -> Self`,
4441// so every wire-up site collapses onto one dispatch:
4442// `DepError::<ctor>(nome, caminho, b)`, byte-equal to the pre-lift
4443// struct-literal on the same `(&str, &str, u8)` fixture. The uniform
4444// three-field construction (`nome.to_string()` / `caminho.to_string()` /
4445// `byte`) is spelled once — inside the macro — rather than at every wire-up
4446// site.
4447//
4448// Every future consumer that wants to construct one of these twelve
4449// variants outside the current in-crate [`DepSource::validate_caminho`]
4450// wire-up sites (a deferred `caixa-resolver` per-`:caminho` re-validator
4451// at lacre-resolve time re-checking the same value-shape axes the resolver
4452// consumes, a future `feira validate --deps` per-caixa admission verb
4453// re-checking the `:fonte :caminho` axis against the shell-metachar
4454// classification bytes this cluster catches, a per-lacre overlay resolver
4455// rejecting a `:caminho` value against a cluster-local snapshot) now
4456// reaches each variant through one call rather than re-inlining the
4457// five-line struct-literal in lockstep with the twelve in-crate wire-up
4458// sites.
4459macro_rules! fonte_caminho_byte_ctors {
4460    ($($ctor:ident => $variant:ident),* $(,)?) => {
4461        impl DepError {
4462            $(
4463                #[doc = concat!(
4464                    "Construct a [`DepError::",
4465                    stringify!($variant),
4466                    "`] naming the offending `:deps :nome` + `:fonte ",
4467                    "(:tipo path …) :caminho` pair + the offending `byte: u8` ",
4468                    "classification. Folds the uniform `Self::",
4469                    stringify!($variant),
4470                    " { nome: nome.to_string(), caminho: caminho.to_string(), ",
4471                    "byte }` three-slot struct-literal onto one substrate ",
4472                    "primitive so every [`DepSource::validate_caminho`] wire-up ",
4473                    "on this variant reads through one dispatch rather than ",
4474                    "the pre-lift five-line open-coded block."
4475                )]
4476                #[must_use]
4477                pub fn $ctor(nome: &str, caminho: &str, byte: u8) -> Self {
4478                    Self::$variant {
4479                        nome: nome.to_string(),
4480                        caminho: caminho.to_string(),
4481                        byte,
4482                    }
4483                }
4484            )*
4485        }
4486    };
4487}
4488
4489fonte_caminho_byte_ctors! {
4490    fonte_caminho_control_char => FonteCaminhoControlChar,
4491    fonte_caminho_shell_redirection => FonteCaminhoShellRedirection,
4492    fonte_caminho_shell_glob => FonteCaminhoShellGlob,
4493    fonte_caminho_shell_subshell_grouping => FonteCaminhoShellSubshellGrouping,
4494    fonte_caminho_shell_brace_expansion => FonteCaminhoShellBraceExpansion,
4495    fonte_caminho_shell_bracket_expansion => FonteCaminhoShellBracketExpansion,
4496    fonte_caminho_shell_quote_grouping => FonteCaminhoShellQuoteGrouping,
4497    fonte_caminho_shell_comment => FonteCaminhoShellComment,
4498    fonte_caminho_url_percent_encoding => FonteCaminhoUrlPercentEncoding,
4499    fonte_caminho_shell_variable_expansion => FonteCaminhoShellVariableExpansion,
4500    fonte_caminho_shell_history_expansion => FonteCaminhoShellHistoryExpansion,
4501    fonte_caminho_shell_history_substitution => FonteCaminhoShellHistorySubstitution,
4502}
4503
4504// Fold the five `DepError::<Variant> { nome: <owner>.clone_or_to_string() }`
4505// single-slot struct-variant wire-up sites scattered across
4506// [`Dep::validate`] / [`Dep::validate_caracteristicas`] /
4507// [`DepSource::validate`] / [`DepSource::validate_caminho`] onto one
4508// substrate primitive per typed variant — the paired `{ nome: String }`
4509// single-slot family on [`DepError`], sibling of the peer
4510// [`fonte_caminho_ctors!`] (f85f145, 11 variants on
4511// `{ nome: String, caminho: String }`) on the sibling two-slot envelope of
4512// the same enum, and of the peer
4513// [`crate::supervisor::supervisor_caixa_only_ctors!`] (db09650, 3 variants
4514// on `{ caixa: String }`) on the `SupervisorError` envelope's single-slot
4515// axis. Second fold family on this `DepError` envelope, and the first on
4516// the single-`{ nome }` shape.
4517//
4518// The five wire-up sites this fold closes each opened the identical
4519// `DepError::<Variant> { nome: <owner>.to_string_or_clone() }` three-line
4520// struct-literal against the same `nome: &str` (or `self.nome: &String`)
4521// local — the exact "same block re-inlined at every consumer" shape the
4522// PRIME DIRECTIVE names as a bug. The five variants share one
4523// `{ nome: String }` shape, so the fold routes each wire-up site through
4524// one dispatch per typed variant.
4525//
4526// The macro below generates one `#[must_use]` inherent constructor per
4527// variant of shape `fn <ctor>(nome: &str) -> Self`, so every wire-up site
4528// collapses onto one dispatch: `DepError::<ctor>(nome)`, byte-equal to the
4529// pre-lift struct-literal on the same `&str` fixture. The uniform
4530// one-field construction (`nome.to_string()`) is spelled once — inside
4531// the macro — rather than at every wire-up site. Callers that hold a
4532// `String` (`self.nome`) pass `&self.nome`, which auto-derefs to `&str`
4533// and lets the macro-owned `.to_string()` produce the fresh owning copy
4534// the enum variant needs; the semantics collapse onto the same
4535// `.clone()`-equivalent one this fold replaces at every site.
4536//
4537// The sibling `NomeEmpty` unit-variant (`enum DepError { NomeEmpty, … }`)
4538// on the same envelope stays on its pre-lift open-coded wire-up shape —
4539// it carries no `nome` field (the offending `:nome` value *is* the empty
4540// string this variant catches) so the uniform `fn(nome: &str) -> Self`
4541// signature this macro promises does not apply. Every future consumer
4542// that wants to construct one of these five variants outside the current
4543// in-crate wire-up sites (a deferred `caixa-resolver` per-`:versao` /
4544// `:caracteristicas` / `:fonte :repo` / `:fonte :pin` / `:fonte :caminho`
4545// re-validator at lacre-resolve time, a future `feira validate --deps`
4546// per-caixa admission verb, a per-lacre overlay resolver rejecting one of
4547// these empty-value shapes against a cluster-local snapshot) now reaches
4548// each variant through one call rather than re-inlining the three-line
4549// struct-literal in lockstep with the five in-crate wire-up sites.
4550macro_rules! dep_nome_only_ctors {
4551    ($($ctor:ident => $variant:ident),* $(,)?) => {
4552        impl DepError {
4553            $(
4554                #[doc = concat!(
4555                    "Construct a [`DepError::",
4556                    stringify!($variant),
4557                    "`] naming the offending `:deps :nome`. Folds the ",
4558                    "uniform `Self::",
4559                    stringify!($variant),
4560                    " { nome: nome.to_string() }` one-field ",
4561                    "struct-literal onto one substrate primitive so every ",
4562                    "in-crate wire-up on this variant reads through one ",
4563                    "dispatch rather than the pre-lift three-line ",
4564                    "open-coded block."
4565                )]
4566                #[must_use]
4567                pub fn $ctor(nome: &str) -> Self {
4568                    Self::$variant { nome: nome.to_string() }
4569                }
4570            )*
4571        }
4572    };
4573}
4574
4575dep_nome_only_ctors! {
4576    versao_empty => VersaoEmpty,
4577    fonte_repo_empty => FonteRepoEmpty,
4578    fonte_pin_missing => FontePinMissing,
4579    fonte_caminho_empty => FonteCaminhoEmpty,
4580    caracteristica_empty => CaracteristicaEmpty,
4581}
4582
4583// Fold the four `DepError::{DuplicateNome, DepIsSelf}` struct-variant
4584// wire-up sites at [`crate::manifest::Caixa::push_dep`] +
4585// [`crate::manifest::Caixa::validate_deps`] +
4586// [`validate_no_self_dep`] onto one substrate-primitive family per
4587// typed variant — the `DepError`-side siblings of the peer
4588// [`crate::supervisor::supervisor_caixa_only_ctors!`] macro (db09650)
4589// on the `SupervisorError { caixa: String }` one-slot envelope and of
4590// the peer [`dep_nome_only_ctors!`] macro (792aa92) on the
4591// `DepError { nome: String }` one-slot envelope. The two variants
4592// carry the same `{ nome: String, list: &'static str }` two-slot
4593// shape: the `nome` field names the offending dep the diagnostic
4594// points the author back at, and the `list` field carries the
4595// `":deps"` / `":deps-dev"` author-surface tag verbatim (via
4596// [`crate::dep::DepList::as_str`] on the [`push_dep`] /
4597// [`validate_deps`] arms, and via the paired
4598// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
4599// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `&'static str`
4600// canonicals on the [`validate_no_self_dep`] arm) so the author can
4601// grep their caixa.lisp for the offending list block in one edit.
4602//
4603// Each of the four wire-up sites opened the same struct-literal
4604// `DepError::<Variant> { nome: <name>.to_string(), list: <tag> }`
4605// two-line block — the exact "same block re-inlined at every
4606// consumer" shape the PRIME DIRECTIVE names as a bug, on the same
4607// altitude the peer `DepError` / `SupervisorError` /
4608// `AplicacaoError` / `LayoutError` / `LimitsError` ctor families
4609// already closed on their sibling envelopes. The two `#[must_use]`
4610// inherent constructors below fold each wire-up onto one dispatch:
4611// `DepError::duplicate_nome(<nome>, <list>)` and
4612// `DepError::dep_is_self(<nome>, <list>)`, byte-equal to the
4613// pre-lift struct-literal on the same scalar fixtures. The `list:
4614// &'static str` parameter (not `impl Into<String>`) preserves the
4615// exact wire tag every consumer already passes verbatim — no
4616// downstream diagnostic reshaping at the lift, matching the peer
4617// `DepList::as_str` / `DEP_AUTHOR_KEY_DEPS*` `&'static str`
4618// contract each wire-up site already keys off.
4619macro_rules! dep_nome_list_ctors {
4620    ($($ctor:ident => $variant:ident),* $(,)?) => {
4621        impl DepError {
4622            $(
4623                #[doc = concat!(
4624                    "Construct a [`DepError::",
4625                    stringify!($variant),
4626                    "`] naming the offending `:deps :nome` and the ",
4627                    "author-surface list tag (`:deps` vs. `:deps-dev`) ",
4628                    "the diagnostic points the author back at. Folds ",
4629                    "the uniform `Self::",
4630                    stringify!($variant),
4631                    " { nome: nome.to_string(), list }` two-field ",
4632                    "struct-literal onto one substrate primitive so ",
4633                    "every in-crate wire-up on this variant reads ",
4634                    "through one dispatch rather than the pre-lift ",
4635                    "open-coded struct-literal block."
4636                )]
4637                #[must_use]
4638                pub fn $ctor(nome: &str, list: &'static str) -> Self {
4639                    Self::$variant { nome: nome.to_string(), list }
4640                }
4641            )*
4642        }
4643    };
4644}
4645
4646dep_nome_list_ctors! {
4647    duplicate_nome => DuplicateNome,
4648    dep_is_self => DepIsSelf,
4649}
4650
4651// Fold the three `DepError::{VersaoInvalid, FonteRepoShape,
4652// CaracteristicaInvalid} { nome: <nome>.to_string(), <axis>:
4653// <value>.to_string(), reason }` struct-variant wire-up sites at
4654// [`Dep::validate`]'s `:versao` requirement-shape gate + [`DepSource::validate`]'s
4655// `:fonte (:tipo git …) :repo` value-shape gate + [`Dep::validate_caracteristicas`]'s
4656// per-entry `:caracteristicas` feature-name-shape gate onto one substrate-
4657// primitive family per typed variant — the `DepError`-side siblings of the
4658// peer [`dep_nome_only_ctors!`] (792aa92) on the one-slot `{ nome }`
4659// envelope, [`dep_nome_list_ctors!`] (6f5e0cd) on the two-slot `{ nome,
4660// list: &'static str }` envelope, [`fonte_caminho_ctors!`] (f85f145) on
4661// the two-slot `{ nome, caminho }` envelope, and
4662// [`fonte_caminho_byte_ctors!`] (0e35793) on the three-slot `{ nome,
4663// caminho, byte }` envelope. The three variants share the same
4664// `{ nome: String, <axis>: String, reason: String }` three-slot shape —
4665// the `nome` field names the offending dep the diagnostic points the
4666// author back at, the middle `<axis>: String` field carries the offending
4667// axis value verbatim (`:versao` requirement scalar on `VersaoInvalid`,
4668// `:repo` URL scalar on `FonteRepoShape`, `:caracteristicas` per-entry
4669// feature-name scalar on `CaracteristicaInvalid`), and the `reason: String`
4670// field carries the parser-shaped rejection sentence the paired
4671// [`crate::render::require_valid_versao_requirement`] /
4672// [`crate::render::is_git_repo_url`] /
4673// [`crate::render::is_cargo_feature_name`] predicate returned. The middle
4674// axis-field name differs across variants (`versao` / `repo` /
4675// `caracteristica`) so the ctor family below takes the axis field name as
4676// a macro parameter (`$axis:ident`) alongside the ctor + variant names,
4677// generating one `pub fn $ctor(nome: &str, $axis: &str, reason: String)
4678// -> Self` inherent constructor per typed variant that spells the uniform
4679// three-field construction (`nome.to_string()` / `<axis>.to_string()` /
4680// `reason` forwarded owned) exactly once. Peer of the sibling
4681// [`crate::aplicacao::aplicacao_field_reason_ctors!`] (981060b) macro
4682// family on the `AplicacaoError` envelope's mirror-symmetric
4683// `{ <field>: String, reason: String }` two-slot shape — same
4684// `<axis>: <value>.to_string()` + `reason` owned-forward payload shape,
4685// one `nome`-axis added at the per-dep-owned altitude the `DepError`
4686// envelope keys off (every `DepError` variant carries the offending
4687// `:deps :nome` verbatim so the author can grep their caixa.lisp for the
4688// offending block in one edit).
4689//
4690// The three wire-up sites this fold closes are:
4691// - [`DepSource::validate`]'s `:repo` value-shape arm
4692//   (`Err(DepError::FonteRepoShape { nome: nome.to_string(), repo:
4693//   repo.clone(), reason })` after [`crate::render::is_git_repo_url`]
4694//   rejects the offending URL);
4695// - [`Dep::validate`]'s `:versao` requirement-shape arm
4696//   (`|reason| DepError::VersaoInvalid { nome: self.nome.clone(), versao:
4697//   self.versao_requirement().to_string(), reason }` inside the
4698//   [`crate::render::require_valid_versao_requirement`] callback pair);
4699// - [`Dep::validate_caracteristicas`]'s per-entry feature-name-shape arm
4700//   (`Err(DepError::CaracteristicaInvalid { nome: self.nome.clone(),
4701//   caracteristica: c.clone(), reason })` after
4702//   [`crate::render::is_cargo_feature_name`] rejects the offending
4703//   feature-name).
4704//
4705// Each opened the identical five-line struct-literal against the same
4706// `(nome, <axis>, reason)` local triple — the exact "same block re-inlined
4707// at every consumer" shape the PRIME DIRECTIVE names as a bug, on the
4708// same altitude the peer four already-lifted `DepError` ctor families
4709// closed on their sibling shape-envelopes. The three variant / axis-field
4710// discriminators are the only things that vary between them; the rest of
4711// the struct-literal is a byte-for-byte re-inline.
4712//
4713// Every future consumer wanting to raise one of these three diagnostics
4714// (a deferred `caixa-resolver` per-`:deps` re-validator at lacre-resolve
4715// time re-checking each declared dep against the same requirement +
4716// git-URL + feature-name value-shape cascade, a future `feira validate
4717// --deps` per-caixa admission verb re-running the shape gates on demand,
4718// a per-lacre overlay resolver rejecting an author-supplied dep against a
4719// cluster-local snapshot) now reaches one dispatch rather than re-inlining
4720// the five-line struct-literal in lockstep with the three in-crate
4721// wire-up sites.
4722macro_rules! dep_nome_axis_reason_ctors {
4723    ($($ctor:ident => $variant:ident { $axis:ident }),* $(,)?) => {
4724        impl DepError {
4725            $(
4726                #[doc = concat!(
4727                    "Construct a [`DepError::",
4728                    stringify!($variant),
4729                    "`] naming the offending `:deps :nome`, the offending ",
4730                    "`:", stringify!($axis), "` axis value, and the ",
4731                    "parser-shaped rejection `reason`. Folds the uniform ",
4732                    "`Self::",
4733                    stringify!($variant),
4734                    " { nome: nome.to_string(), ",
4735                    stringify!($axis),
4736                    ": ",
4737                    stringify!($axis),
4738                    ".to_string(), reason }` three-field struct-literal ",
4739                    "onto one substrate primitive so every in-crate ",
4740                    "wire-up on this variant reads through one dispatch ",
4741                    "rather than the pre-lift five-line open-coded block. ",
4742                    "The `nome: &str` and `",
4743                    stringify!($axis),
4744                    ": &str` parameters accept `&str` literals and ",
4745                    "`&String` (via Deref coercion) so every existing ",
4746                    "wire-up threads through the ctor without a ",
4747                    "pre-conversion; the `reason: String` parameter takes ",
4748                    "an owned `String` (not `impl Into<String>`) matching ",
4749                    "the paired `crate::render::*` predicate's ",
4750                    "`Result<(), String>` return shape every wire-up ",
4751                    "already holds owned at the call site."
4752                )]
4753                #[must_use]
4754                pub fn $ctor(nome: &str, $axis: &str, reason: String) -> Self {
4755                    Self::$variant {
4756                        nome: nome.to_string(),
4757                        $axis: $axis.to_string(),
4758                        reason,
4759                    }
4760                }
4761            )*
4762        }
4763    };
4764}
4765
4766dep_nome_axis_reason_ctors! {
4767    versao_invalid => VersaoInvalid { versao },
4768    fonte_repo_shape => FonteRepoShape { repo },
4769    caracteristica_invalid => CaracteristicaInvalid { caracteristica },
4770}
4771
4772// Fold the three `DepError::{FontePinEmpty, FontePinAmbiguous,
4773// CaracteristicaDuplicate} { nome: <nome>.to_string(), <axis>:
4774// <value>.to_string() }` struct-variant wire-up sites at
4775// [`DepSource::validate`]'s per-`:fonte` git-pin single-pin-empty +
4776// multi-pin-ambiguous cascade and [`Dep::validate_caracteristicas`]'s
4777// per-entry set-not-multiset dedup closure onto one substrate-primitive
4778// family per typed variant — the missing two-slot rung on the
4779// `DepError`-side four-family ladder ([`dep_nome_only_ctors!`] (792aa92)
4780// one-slot `{ nome }` → this two-slot `{ nome, <axis>: String }` →
4781// [`dep_nome_list_ctors!`] (6f5e0cd) two-slot `{ nome, list: &'static
4782// str }` → [`dep_nome_axis_reason_ctors!`] (5621f8a) three-slot
4783// `{ nome, <axis>: String, reason: String }` → [`fonte_pin_shape`]
4784// (86e2a17) four-slot `{ nome, pin, value, reason }`), and mirror-
4785// symmetric sibling of the peer
4786// [`crate::aplicacao::aplicacao_field_reason_ctors!`] (981060b) two-slot
4787// `{ <field>: String, reason: String }` fold on the `AplicacaoError`
4788// envelope — same `<axis>: <value>.to_string()` owned-forward payload
4789// shape, `reason` axis removed and `nome`-axis added at the per-dep-
4790// owned altitude the `DepError` envelope keys off (every `DepError`
4791// variant carries the offending `:deps :nome` verbatim so the author
4792// can grep their caixa.lisp for the offending block in one edit). The
4793// three variants share the same `{ nome: String, <axis>: String }`
4794// two-slot shape: the `nome` field names the offending dep the
4795// diagnostic points the author back at, and the middle `<axis>:
4796// String` field carries the offending per-envelope axis value verbatim
4797// (`:fonte` per-pin author-surface tag on `FontePinEmpty`, the
4798// comma-joined multi-pin ambiguity report on `FontePinAmbiguous`, the
4799// duplicate `:caracteristicas` entry on `CaracteristicaDuplicate`).
4800// The middle axis-field name differs across variants (`pin` / `pins` /
4801// `caracteristica`) so the ctor family below takes the axis field name
4802// as a macro parameter (`$axis:ident`) alongside the ctor + variant
4803// names, generating one `pub fn $ctor(nome: &str, $axis: &str) ->
4804// Self` inherent constructor per typed variant that spells the
4805// uniform two-field construction (`nome.to_string()` /
4806// `<axis>.to_string()`) exactly once.
4807//
4808// The three wire-up sites this fold closes are:
4809// - [`DepSource::validate`]'s per-`:fonte` set-of-one empty-pin arm
4810//   (`return Err(DepError::FontePinEmpty { nome: nome.to_string(), pin:
4811//   pin.to_string() });` inside the `set.len() == 1` branch after the
4812//   `is_some_and(String::is_empty)` iterator);
4813// - [`DepSource::validate`]'s per-`:fonte` set-of-two-or-more
4814//   ambiguity arm (`return Err(DepError::FontePinAmbiguous { nome:
4815//   nome.to_string(), pins: set.join(", ") });` inside the `_` branch);
4816// - [`Dep::validate_caracteristicas`]'s per-entry
4817//   set-not-multiset-dedup closure (`|| DepError::CaracteristicaDuplicate
4818//   { nome: self.nome.clone(), caracteristica: c.clone() }` passed to
4819//   [`crate::render::insert_first_seen`]).
4820//
4821// Each opened the identical four-line struct-literal against the same
4822// `(nome, <axis>)` local pair — the exact "same block re-inlined at
4823// every consumer" shape the PRIME DIRECTIVE names as a bug, on the
4824// same altitude the peer four already-lifted `DepError` ctor families
4825// closed on their sibling shape-envelopes. The three variant / axis-
4826// field discriminators are the only things that vary between them;
4827// the rest of the struct-literal is a byte-for-byte re-inline.
4828//
4829// Every future consumer wanting to raise one of these three
4830// diagnostics (a deferred `caixa-resolver` per-`:deps` re-validator
4831// at lacre-resolve time re-checking each declared dep against the
4832// same `:fonte` set-of-one / set-of-many + `:caracteristicas`
4833// set-not-multiset cascade, a future `feira validate --deps` per-
4834// caixa admission verb re-running the shape gates on demand, a
4835// per-lacre overlay resolver rejecting an author-supplied dep against
4836// a cluster-local snapshot the M4 CR materializer projects) now
4837// reaches one dispatch rather than re-inlining the four-line struct-
4838// literal in lockstep with the three in-crate wire-up sites.
4839macro_rules! dep_nome_axis_ctors {
4840    ($($ctor:ident => $variant:ident { $axis:ident }),* $(,)?) => {
4841        impl DepError {
4842            $(
4843                #[doc = concat!(
4844                    "Construct a [`DepError::",
4845                    stringify!($variant),
4846                    "`] naming the offending `:deps :nome` and the ",
4847                    "offending `:", stringify!($axis), "` axis value. ",
4848                    "Folds the uniform `Self::",
4849                    stringify!($variant),
4850                    " { nome: nome.to_string(), ",
4851                    stringify!($axis),
4852                    ": ",
4853                    stringify!($axis),
4854                    ".to_string() }` two-field struct-literal onto one ",
4855                    "substrate primitive so every in-crate wire-up on ",
4856                    "this variant reads through one dispatch rather than ",
4857                    "the pre-lift four-line open-coded block. Both `nome: ",
4858                    "&str` and `",
4859                    stringify!($axis),
4860                    ": &str` parameters accept `&str` literals and ",
4861                    "`&String` (via Deref coercion) so every existing ",
4862                    "wire-up threads through the ctor without a pre-",
4863                    "conversion."
4864                )]
4865                #[must_use]
4866                pub fn $ctor(nome: &str, $axis: &str) -> Self {
4867                    Self::$variant {
4868                        nome: nome.to_string(),
4869                        $axis: $axis.to_string(),
4870                    }
4871                }
4872            )*
4873        }
4874    };
4875}
4876
4877dep_nome_axis_ctors! {
4878    fonte_pin_empty => FontePinEmpty { pin },
4879    fonte_pin_ambiguous => FontePinAmbiguous { pins },
4880    caracteristica_duplicate => CaracteristicaDuplicate { caracteristica },
4881}
4882
4883// Fold the two `DepError::FontePinShape { nome: nome.to_string(),
4884// pin: <pin>.to_string(), value: v.clone(), reason }` four-slot
4885// struct-variant wire-up sites at [`DepSource::validate`]'s
4886// per-`:fonte` git-pin value-shape gate onto one substrate primitive on
4887// the `DepError` envelope — the last open-coded ctor site remaining on
4888// the `:fonte (:tipo git …)` value-shape trajectory this envelope
4889// carries, and the single-variant sibling of the peer four already-
4890// lifted [`DepError`] ctor families ([`fonte_caminho_ctors!`] f85f145
4891// on the two-slot `{ nome, caminho }` envelope,
4892// [`fonte_caminho_byte_ctors!`] 0e35793 on the three-slot
4893// `{ nome, caminho, byte }` envelope, [`dep_nome_only_ctors!`] 792aa92
4894// on the one-slot `{ nome }` envelope, and [`dep_nome_list_ctors!`]
4895// 6f5e0cd on the two-slot `{ nome, list }` envelope). Peer of the
4896// sibling [`crate::aplicacao::contrato_pair_value_reason_ctors!`]
4897// (14e13f1) four-slot fold on the `AplicacaoError` envelope — same
4898// `{ …, value: String, reason: String }` payload shape, one axis
4899// removed at the `nome`-only-owner altitude the `DepError` envelope
4900// keys off (no `edge_pair()` de/para pair).
4901//
4902// The two wire-up sites this fold closes are the paired refname-pin
4903// arm (`|| DepError::FontePinShape { nome: nome.to_string(),
4904// pin: pin.to_string(), value: v.clone(), reason }` inside the
4905// `[(":tag", tag), (":branch", branch)]` iterator against
4906// [`crate::render::is_git_ref_name`]) and the hex-OID-pin arm
4907// (`|| DepError::FontePinShape { nome: nome.to_string(),
4908// pin: ":rev".to_string(), value: v.clone(), reason }` against
4909// [`crate::render::is_git_oid`]) — each opened the identical
4910// `DepError::FontePinShape { … }` six-line struct-literal against the
4911// same `(nome: &str, pin: &str, v: &String, reason: String)` local
4912// tuple, the exact "same block re-inlined at every consumer" shape
4913// the PRIME DIRECTIVE names as a bug. The `pin` axis discriminator is
4914// the only thing that varies between them (`":tag"`/`":branch"` on
4915// the refname arm, `":rev"` on the hex-OID arm); the rest of the
4916// struct-literal is a byte-for-byte re-inline. Refname/hex-OID both
4917// route through the same ctor because their `pin` field carries the
4918// author-surface tag verbatim (matching the `FontePinEmpty` /
4919// `FontePinAmbiguous` sibling variants' `pin: String` axis
4920// convention), so the offending author can grep their caixa.lisp for
4921// the offending `:tag "<value>"` / `:branch "<value>"` /
4922// `:rev "<value>"` literal in one edit.
4923//
4924// The single ctor below folds each wire-up onto one dispatch:
4925// `DepError::fonte_pin_shape(nome, pin, v, reason)`, byte-equal to
4926// the pre-lift struct-literal on the same `(&str, &str, &str,
4927// String)` fixture. The uniform four-field construction
4928// (`nome.to_string()` / `pin.to_string()` / `value.to_string()` /
4929// `reason` forwarded owned) is spelled once here rather than at every
4930// wire-up site. The `reason: String` field takes an owned `String`
4931// (not `impl Into<String>`) matching the two call sites' pre-existing
4932// `let Err(reason) = crate::render::is_git_ref_name(v)` /
4933// `let Err(reason) = crate::render::is_git_oid(v)` shape — both
4934// predicates return `Result<(), String>`, so the caller always holds
4935// an owned `String` at the wire-up site and threading it through the
4936// ctor without a `.into()` shim keeps the routing shape byte-equal to
4937// the pre-lift block. The `value: &str` parameter accepts both `&str`
4938// literals (unused today) and `&String` (from the caller-held
4939// `v: &String` on each arm, via Deref coercion), so every existing
4940// wire-up threads through the ctor without a pre-conversion.
4941//
4942// Every future consumer that wants to construct this variant outside
4943// the two in-crate [`DepSource::validate`] wire-up sites (a deferred
4944// `caixa-resolver` per-`:fonte` re-validator at lacre-resolve time
4945// re-checking the same value-shape axes the resolver consumes, a
4946// future `feira validate --deps` per-caixa admission verb re-checking
4947// the `:fonte :tag`/`:branch`/`:rev` axes, a per-lacre overlay
4948// resolver rejecting a git-pin value against a cluster-local
4949// snapshot) now reaches this variant through one call rather than
4950// re-inlining the six-line struct-literal in lockstep with the two
4951// in-crate wire-up sites.
4952impl DepError {
4953    /// Construct a [`DepError::FontePinShape`] naming the offending
4954    /// `:deps :nome`, the offending `:fonte (:tipo git …) :<pin>`
4955    /// axis tag, the offending value, and the parser-shaped `reason`.
4956    /// Folds the uniform
4957    /// `Self::FontePinShape { nome: nome.to_string(),
4958    /// pin: pin.to_string(), value: value.to_string(), reason }`
4959    /// four-field struct-literal onto one substrate primitive so
4960    /// every [`DepSource::validate`] wire-up on this variant reads
4961    /// through one dispatch rather than the pre-lift six-line
4962    /// open-coded block. The `nome` string threads verbatim from
4963    /// [`Dep::nome`] at the call site; the `pin` string carries the
4964    /// author-surface `:tag` / `:branch` / `:rev` tag verbatim; the
4965    /// `value` string carries the offending refname / hex-OID
4966    /// verbatim; and `reason` forwards the owned `String` returned
4967    /// by [`crate::render::is_git_ref_name`] /
4968    /// [`crate::render::is_git_oid`] without a `.into()` shim.
4969    #[must_use]
4970    pub fn fonte_pin_shape(nome: &str, pin: &str, value: &str, reason: String) -> Self {
4971        Self::FontePinShape {
4972            nome: nome.to_string(),
4973            pin: pin.to_string(),
4974            value: value.to_string(),
4975            reason,
4976        }
4977    }
4978
4979    /// Construct a [`DepError::NomeInvalid`] naming the offending
4980    /// `:deps :nome` byte-string and the parser-shaped rejection
4981    /// `reason` returned by [`crate::render::is_dns_1123_label`].
4982    ///
4983    /// Folds the uniform
4984    /// `Self::NomeInvalid { nome: nome.to_string(), reason }` two-field
4985    /// struct-literal onto one substrate primitive so every wire-up on
4986    /// this variant reads through one dispatch rather than the pre-lift
4987    /// four-line open-coded `DepError::NomeInvalid { nome:
4988    /// self.nome.clone(), reason }` block inside [`Dep::validate`]. The
4989    /// missing two-slot `{ nome, reason }` rung on the `DepError`-side
4990    /// ctor-family ladder (`{ nome }` one-slot →
4991    /// [`dep_nome_only_ctors!`] (792aa92); `{ nome, <axis>: String }`
4992    /// two-slot → [`dep_nome_axis_ctors!`] (7f7c950); `{ nome, list:
4993    /// &'static str }` two-slot → [`dep_nome_list_ctors!`] (6f5e0cd);
4994    /// `{ nome, <axis>: String, reason: String }` three-slot →
4995    /// [`dep_nome_axis_reason_ctors!`] (5621f8a); `{ nome, pin, value,
4996    /// reason }` four-slot → [`DepError::fonte_pin_shape`] (86e2a17))
4997    /// — the sole variant on the envelope carrying the
4998    /// `{ nome: String, reason: String }` two-slot shape without a
4999    /// middle axis, matching the peer
5000    /// [`crate::manifest::ManifestError::NomeInvalid`] +
5001    /// [`crate::aplicacao::AplicacaoError::MembroCaixaInvalid`] +
5002    /// [`crate::supervisor::SupervisorError::ChildCaixaInvalid`]
5003    /// four-axis DNS-1123 caixa-identifier diagnostic family the
5004    /// existing `nome_invalid_diagnostic_carries_offending_name` test
5005    /// pins on this envelope.
5006    ///
5007    /// The `nome: &str` parameter accepts `&str` literals and `&String`
5008    /// (via Deref coercion) so the sole in-crate wire-up threads through
5009    /// the ctor without a pre-conversion; the `reason: String`
5010    /// parameter takes an owned `String` (not `impl Into<String>`)
5011    /// matching the [`crate::render::is_dns_1123_label`] predicate's
5012    /// `Result<(), String>` return shape the sole wire-up site already
5013    /// holds owned at the call site, keeping the routing byte-equal to
5014    /// the pre-lift block. Same owned-`String`-forward `reason` payload
5015    /// discipline as the sibling three-slot family
5016    /// [`dep_nome_axis_reason_ctors!`] on `{ nome, <axis>, reason }`
5017    /// and the four-slot [`DepError::fonte_pin_shape`] on
5018    /// `{ nome, pin, value, reason }`.
5019    ///
5020    /// Every future consumer that raises the same diagnostic outside
5021    /// [`Dep::validate`] — a deferred `caixa-resolver` per-`:deps`
5022    /// re-validator at lacre-resolve time re-checking each declared
5023    /// dep's `:nome` against the same DNS-1123 predicate the apiserver-
5024    /// side schema uses (the `:nome` value flows verbatim as the target
5025    /// caixa's `:nome`, the rendered `lareira-<nome>` Helm chart name
5026    /// segment, the `LABEL_PROGRAM` label value, and the resolver's
5027    /// checkout-directory leaf), a future `feira validate --deps`
5028    /// per-caixa admission verb re-running the shape gate on demand, a
5029    /// per-lacre overlay resolver rejecting an author-supplied dep's
5030    /// `:nome` against a cluster-local snapshot the M4 CR materializer
5031    /// projects, a future authoring-surface widening the field into a
5032    /// `(String, Vec<Suggestion>)` pair carrying a
5033    /// "did-you-mean-<nearest-valid-label>" hint — now reaches this
5034    /// variant through one call rather than re-inlining the four-line
5035    /// struct-literal in lockstep with the one in-crate wire-up site.
5036    #[must_use]
5037    pub fn nome_invalid(nome: &str, reason: String) -> Self {
5038        Self::NomeInvalid {
5039            nome: nome.to_string(),
5040            reason,
5041        }
5042    }
5043}
5044
5045#[allow(clippy::trivially_copy_pass_by_ref)]
5046fn is_false(b: &bool) -> bool {
5047    !*b
5048}
5049
5050#[cfg(test)]
5051mod tests {
5052    use super::*;
5053
5054    #[test]
5055    fn registry_dep_is_minimal() {
5056        let d = Dep::simple("caixa-teia", "^0.1");
5057        assert_eq!(d.nome, "caixa-teia");
5058        assert_eq!(d.versao, "^0.1");
5059        assert!(d.fonte.is_none());
5060        assert!(!d.opcional());
5061        assert!(d.caracteristicas().is_empty());
5062    }
5063
5064    #[test]
5065    fn dep_string_scalar_accessor_pair_is_const_fn() {
5066        // Fail-before-pass-after pin on [`Dep::nome`] +
5067        // [`Dep::versao_requirement`]'s `const`-eval-surface posture.
5068        // Each accessor projects the per-`:deps` / per-`:deps-dev`
5069        // entry's [`String`] storage through the `pub const fn`
5070        // [`String::as_str`] (const-stable since Rust 1.87, well
5071        // within the workspace MSRV) — any future accidental
5072        // downgrade to non-`const` fails the corresponding
5073        // `<name>_via_const_fn` wrapper at caixa-core build time with
5074        // E0015 (`cannot call non-const method`), strictly stronger
5075        // than a runtime `assert!`. Sibling of the peer
5076        // per-M2/M3/universal-axis `String → &str` scalar-accessor
5077        // family pins on the sibling `const`-eval-surface passes
5078        // ([`crate::Caixa::nome`] / [`crate::Caixa::versao`] at the
5079        // top-level manifest, [`crate::CaixaVersion::as_str`] at the
5080        // typed-newtype wrapper, [`crate::aplicacao::Membro::nome`] /
5081        // [`crate::aplicacao::Membro::versao_requirement`] at the M3
5082        // membership axis, [`crate::aplicacao::Entrada::hostname`] /
5083        // [`crate::aplicacao::Entrada::destination`] at the M3
5084        // ingress axis, [`crate::supervisor::ChildSpec::nome`] /
5085        // [`crate::supervisor::ChildSpec::versao_requirement`] at the
5086        // M2 supervisor-tree axis,
5087        // [`crate::upgrade::UpgradeFromEntry::prior_versao`] at the
5088        // M2 upgrade axis, and the per-`:contratos`
5089        // [`crate::aplicacao::WitContract::source`] /
5090        // [`crate::aplicacao::WitContract::destination`] /
5091        // [`crate::aplicacao::WitContract::world_ref`] trio the
5092        // sibling pin at 279823b already anchors).
5093        const fn nome_via_const_fn(d: &Dep) -> &str {
5094            d.nome()
5095        }
5096        const fn versao_via_const_fn(d: &Dep) -> &str {
5097            d.versao_requirement()
5098        }
5099        for (nome, versao) in [
5100            ("caixa-teia", "^0.1"),
5101            ("caixa-mesh", "~0.2.3"),
5102            ("caixa-helm", "*"),
5103        ] {
5104            let d = Dep::simple(nome, versao);
5105            assert_eq!(nome_via_const_fn(&d), d.nome());
5106            assert_eq!(versao_via_const_fn(&d), d.versao_requirement());
5107            assert_eq!(d.nome(), nome);
5108            assert_eq!(d.versao_requirement(), versao);
5109        }
5110    }
5111
5112    #[test]
5113    fn dep_outer_accessor_family_is_const_fn() {
5114        // Fail-before-pass-after pin on [`Dep::fonte`] +
5115        // [`Dep::caracteristicas`]'s `const`-eval-surface posture.
5116        // Each accessor projects the per-`:deps` / per-`:deps-dev`
5117        // entry's composite / list storage through a `pub const fn`
5118        // stdlib method (`Option::<DepSource>::as_ref` /
5119        // `Vec::<String>::as_slice`, both const-stable since Rust
5120        // 1.83, well within the workspace MSRV). Any future
5121        // accidental downgrade to non-`const` fails the corresponding
5122        // `<name>_via_const_fn` wrapper at caixa-core build time with
5123        // E0015 (`cannot call non-const method`), strictly stronger
5124        // than a runtime `assert!` and side-stepping the destructor-
5125        // in-const restriction the `Dep` fixture's `String` /
5126        // `Option<DepSource>` / `Vec<String>` carriers rule out on the
5127        // direct-`const _: () = assert!(...)` residence.
5128        //
5129        // Peer of the sibling per-`Dep` scalar-accessor pair pin
5130        // [`dep_string_scalar_accessor_pair_is_const_fn`] on the same
5131        // outer per-dep-list-entry [`Dep`] altitude — this pin extends
5132        // the `const`-eval-surface discipline onto the composite-
5133        // reference and slice-return arms of the outer-`Dep` accessor
5134        // family, closing the four-slot outer surface (`:nome` +
5135        // `:versao` + `:fonte` + `:caracteristicas`) on the `const`-fn
5136        // posture. The `:opcional` `bool` arm already carries the
5137        // posture through [`Dep::opcional`]'s prior `pub const fn`
5138        // declaration, so this pin lands the last two unlifted
5139        // outer-`Dep` accessors and closes the family.
5140        const fn fonte_via_const_fn(d: &Dep) -> Option<&DepSource> {
5141            d.fonte()
5142        }
5143        const fn caracteristicas_via_const_fn(d: &Dep) -> &[String] {
5144            d.caracteristicas()
5145        }
5146        // `Dep::simple` — no `:fonte`, empty `:caracteristicas`.
5147        let empty = Dep::simple("caixa-teia", "^0.1");
5148        assert!(fonte_via_const_fn(&empty).is_none());
5149        assert_eq!(fonte_via_const_fn(&empty), empty.fonte());
5150        assert!(caracteristicas_via_const_fn(&empty).is_empty());
5151        assert_eq!(
5152            caracteristicas_via_const_fn(&empty),
5153            empty.caracteristicas()
5154        );
5155        // `Dep::git` — `:fonte` is `Some(Git{…})`, `:caracteristicas`
5156        // still empty.
5157        let git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
5158        assert!(fonte_via_const_fn(&git).is_some());
5159        assert_eq!(fonte_via_const_fn(&git), git.fonte());
5160        assert_eq!(caracteristicas_via_const_fn(&git), git.caracteristicas());
5161        // Populated `:caracteristicas` — exercise the non-empty
5162        // slice-view arm to pin the accessor's borrow shape against
5163        // both a `Vec::new()` empty backing buffer and a populated one.
5164        let mut with_features = Dep::simple("caixa-teia", "^0.1");
5165        with_features.caracteristicas = vec!["feat-a".into(), "feat-b".into()];
5166        assert_eq!(caracteristicas_via_const_fn(&with_features).len(), 2);
5167        assert_eq!(
5168            caracteristicas_via_const_fn(&with_features),
5169            with_features.caracteristicas()
5170        );
5171    }
5172
5173    #[test]
5174    fn git_dep_carries_tag() {
5175        let d = Dep::git("t", "*", "github:o/r", "v1");
5176        match d.fonte {
5177            Some(DepSource::Git {
5178                ref repo, ref tag, ..
5179            }) => {
5180                assert_eq!(repo, "github:o/r");
5181                assert_eq!(tag.as_deref(), Some("v1"));
5182            }
5183            _ => panic!("expected Git source"),
5184        }
5185    }
5186
5187    #[test]
5188    fn validate_accepts_simple_dep() {
5189        Dep::simple("caixa-teia", "^0.1").validate().unwrap();
5190    }
5191
5192    #[test]
5193    fn validate_rejects_empty_nome() {
5194        // The fail-before-pass-after pin for `:nome ""`: the empty-name
5195        // arm fires first so the per-entry parse-side diagnostic doesn't
5196        // emit a useless `nome: ""` reference.
5197        let mut d = Dep::simple("placeholder", "^0.1");
5198        d.nome = String::new();
5199        assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
5200    }
5201
5202    #[test]
5203    fn validate_rejects_empty_versao() {
5204        // `parse_requirement("")` returns `Ok(VersionReq::STAR)` (the
5205        // semver crate accepts the empty string as a wildcard match),
5206        // so the empty-`:versao` arm is structurally necessary even
5207        // with the parse arm in place — mirrors `MembroVersaoEmpty` /
5208        // `EmptyChildVersion` ordering on the other two `:versao` axes.
5209        let mut d = Dep::simple("caixa-teia", "ignored");
5210        d.versao = String::new();
5211        let err = d.validate().unwrap_err();
5212        assert!(
5213            matches!(err, DepError::VersaoEmpty { ref nome } if nome == "caixa-teia"),
5214            "got {err:?}"
5215        );
5216    }
5217
5218    // ── value-shape: DNS-1123 label on :deps :nome ────────────────────────
5219
5220    #[test]
5221    fn validate_rejects_nome_with_uppercase() {
5222        // The fail-before-pass-after pin: a non-empty but uppercase
5223        // `:nome` silently passed `validate()` on every pre-gate
5224        // codebase because the prior shape only refused the empty
5225        // string. The DNS-1123 violation surfaced far downstream at
5226        // lacre-resolve time when the *target* caixa's `:nome` failed
5227        // its own gate — far from the `:deps` entry, with a diagnostic
5228        // naming the target rather than the dep entry that referenced
5229        // it. Same fail-before-pass-after fixture pinned for
5230        // `:membros :caixa` (3f9d7a0), `:children :caixa` (31bfa43),
5231        // and Caixa `:nome` (6c992f8).
5232        let d = Dep::simple("Caixa-Teia", "^0.1");
5233        let err = d.validate().unwrap_err();
5234        assert!(
5235            matches!(
5236                err,
5237                DepError::NomeInvalid { ref nome, ref reason }
5238                    if nome == "Caixa-Teia" && reason.contains("uppercase")
5239            ),
5240            "got {err:?}"
5241        );
5242    }
5243
5244    #[test]
5245    fn validate_rejects_nome_with_underscore() {
5246        // RFC 1123 allows `[a-z0-9-]` only; underscore is the canonical
5247        // "I'm thinking of Go module names / Python identifiers" leak.
5248        // Same fixture pinned for the peer caixa-identifier axes.
5249        let d = Dep::simple("caixa_teia", "^0.1");
5250        let err = d.validate().unwrap_err();
5251        assert!(
5252            matches!(
5253                err,
5254                DepError::NomeInvalid { ref nome, ref reason }
5255                    if nome == "caixa_teia" && reason.contains('_')
5256            ),
5257            "got {err:?}"
5258        );
5259    }
5260
5261    #[test]
5262    fn validate_rejects_nome_with_dot() {
5263        // A `:deps :nome` is a single DNS-1123 *label*, not a
5264        // subdomain — dots are rejected. The `"caixa.teia"` shape is
5265        // the canonical "I confused the dep name with the FQDN /
5266        // namespace" footgun, distinct from the legitimate
5267        // `:fonte :repo "github:org/caixa-teia"` axis.
5268        let d = Dep::simple("caixa.teia", "^0.1");
5269        let err = d.validate().unwrap_err();
5270        assert!(
5271            matches!(
5272                err,
5273                DepError::NomeInvalid { ref nome, ref reason }
5274                    if nome == "caixa.teia" && reason.contains('.')
5275            ),
5276            "got {err:?}"
5277        );
5278    }
5279
5280    #[test]
5281    fn validate_rejects_nome_with_leading_hyphen() {
5282        // RFC 1123 requires alphanumeric at both label boundaries.
5283        // Pinned in parity with the peer DNS-1123 fixtures.
5284        let d = Dep::simple("-caixa-teia", "^0.1");
5285        let err = d.validate().unwrap_err();
5286        assert!(
5287            matches!(
5288                err,
5289                DepError::NomeInvalid { ref nome, ref reason }
5290                    if nome == "-caixa-teia" && reason.contains("alphanumeric")
5291            ),
5292            "got {err:?}"
5293        );
5294    }
5295
5296    #[test]
5297    fn validate_rejects_nome_with_trailing_hyphen() {
5298        let d = Dep::simple("caixa-teia-", "^0.1");
5299        let err = d.validate().unwrap_err();
5300        assert!(
5301            matches!(
5302                err,
5303                DepError::NomeInvalid { ref nome, ref reason }
5304                    if nome == "caixa-teia-" && reason.contains("alphanumeric")
5305            ),
5306            "got {err:?}"
5307        );
5308    }
5309
5310    #[test]
5311    fn validate_rejects_nome_with_slash() {
5312        // The canonical "I copied the GitHub repo path into `:nome`
5313        // instead of `:fonte :repo`" typo. A `/` in the name leaks the
5314        // lacre-side `:repositorio` shape (`pleme-io/caixa-teia`) into
5315        // the local-name slot. Same fixture pinned for `:membros
5316        // :caixa` (3f9d7a0).
5317        let d = Dep::simple("pleme-io/caixa-teia", "^0.1");
5318        let err = d.validate().unwrap_err();
5319        assert!(
5320            matches!(
5321                err,
5322                DepError::NomeInvalid { ref nome, ref reason }
5323                    if nome == "pleme-io/caixa-teia" && reason.contains('/')
5324            ),
5325            "got {err:?}"
5326        );
5327    }
5328
5329    #[test]
5330    fn validate_rejects_nome_too_long() {
5331        // 64-byte label — one over the RFC 1035 / RFC 1123 label cap.
5332        // Built from a valid character set so the length-bound
5333        // diagnostic surfaces before any per-character check (the
5334        // order pin parallel to the per-character predicates inside
5335        // [`crate::render::is_dns_1123_label`]).
5336        let long = "a".repeat(64);
5337        let d = Dep::simple(&long, "^0.1");
5338        let err = d.validate().unwrap_err();
5339        assert!(
5340            matches!(
5341                err,
5342                DepError::NomeInvalid { ref nome, ref reason }
5343                    if nome.len() == 64 && reason.contains("max length of 63")
5344            ),
5345            "got {err:?}"
5346        );
5347    }
5348
5349    #[test]
5350    fn validate_accepts_canonical_nome_labels() {
5351        // Positive-control sweep — every form the K8s apiserver
5352        // accepts as a DNS-1123 label must round-trip through
5353        // validate. Covers a hyphen-bearing label, a numeric-suffix
5354        // label, a leading-digit label, a single-character label, and
5355        // a 63-byte (exactly the cap) label — the same fixture set
5356        // the peer `:membros :caixa` / `:children :caixa` positive
5357        // controls pin.
5358        for nome in [
5359            "caixa-teia",
5360            "caixa-resolver2",
5361            "2nd-tier-cache",
5362            "x",
5363            "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0",
5364        ] {
5365            Dep::simple(nome, "^0.1")
5366                .validate()
5367                .unwrap_or_else(|e| panic!("canonical label {nome:?} must validate, got {e:?}"));
5368        }
5369    }
5370
5371    #[test]
5372    fn nome_empty_takes_precedence_over_nome_invalid() {
5373        // Ordering pin: `NomeEmpty` is the more self-locating
5374        // diagnostic on `""` and must lead — `is_dns_1123_label` is
5375        // only reached after the empty-check fires at the call site.
5376        // Mirrors `membro_caixa_empty_takes_precedence_over_invalid`
5377        // (3f9d7a0) on the peer caixa-identifier axis.
5378        let mut d = Dep::simple("placeholder", "^0.1");
5379        d.nome = String::new();
5380        assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
5381    }
5382
5383    #[test]
5384    fn nome_invalid_fires_before_versao_empty() {
5385        // Ordering pin: a malformed `:nome` fires before any `:versao`
5386        // axis check on the *same* entry — the per-entry shape gates
5387        // run top-to-bottom (nome empty → nome shape → versao empty →
5388        // versao parse → fonte shape), so a one-entry caixa.lisp with
5389        // both wrong sees the name-side diagnostic first (the name is
5390        // the self-locating axis — without a valid name, the parse
5391        // diagnostic can't quote `:nome "<bad>"`). Same ordering
5392        // discipline as `membro_caixa_invalid_fires_before_versao_check`
5393        // (3f9d7a0).
5394        let mut d = Dep::simple("Caixa-Teia", "^0.1");
5395        d.versao = String::new();
5396        let err = d.validate().unwrap_err();
5397        assert!(
5398            matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
5399            "got {err:?}"
5400        );
5401    }
5402
5403    #[test]
5404    fn nome_invalid_fires_before_versao_invalid() {
5405        // Ordering pin: a malformed `:nome` fires before the `:versao`
5406        // parse-side check on the *same* entry. Pin separately from
5407        // the empty-versao ordering so a future re-ordering surfaces
5408        // here, parallel to the b0c8389 / c4213a4 trajectory.
5409        let d = Dep::simple("Caixa-Teia", "^^0.1");
5410        let err = d.validate().unwrap_err();
5411        assert!(
5412            matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
5413            "got {err:?}"
5414        );
5415    }
5416
5417    #[test]
5418    fn nome_invalid_fires_before_fonte_invalid() {
5419        // Ordering pin: a malformed `:nome` fires before the `:fonte`
5420        // shape check on the *same* entry. The `:fonte` diagnostic
5421        // names the offending dep's `:nome` verbatim (via
5422        // `DepSource::validate(&self.nome)`), so a non-self-locating
5423        // name would taint the downstream diagnostic too — the gate
5424        // ordering keeps both diagnostics individually self-locating.
5425        let mut d = Dep::simple("Caixa-Teia", "^0.1");
5426        d.fonte = Some(DepSource::Git {
5427            repo: String::new(),
5428            tag: None,
5429            rev: None,
5430            branch: None,
5431        });
5432        let err = d.validate().unwrap_err();
5433        assert!(
5434            matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
5435            "got {err:?}"
5436        );
5437    }
5438
5439    #[test]
5440    fn nome_invalid_diagnostic_carries_offending_name() {
5441        // The diagnostic-shape pin: the error names the offending
5442        // `:nome` value verbatim so the author can grep their
5443        // caixa.lisp without re-running the build, and carries a
5444        // non-empty `reason` from `is_dns_1123_label` so the
5445        // predicate's own wording flows through to the diagnostic.
5446        // Same shape as `MembroCaixaInvalid` (3f9d7a0),
5447        // `ChildCaixaInvalid` (31bfa43), `ManifestError::NomeInvalid`
5448        // (6c992f8) — the four DNS-1123 caixa-identifier axes now
5449        // share a structurally-equivalent diagnostic family.
5450        let d = Dep::simple("Caixa_Teia", "^0.1");
5451        let err = d.validate().unwrap_err();
5452        let DepError::NomeInvalid { nome, reason } = err else {
5453            panic!("expected NomeInvalid, got other variant");
5454        };
5455        assert_eq!(nome, "Caixa_Teia");
5456        assert!(
5457            !reason.is_empty(),
5458            "NomeInvalid `reason` must carry the predicate's wording verbatim"
5459        );
5460    }
5461
5462    #[test]
5463    fn validate_rejects_invalid_versao_requirement() {
5464        // The fail-before-pass-after pin: a non-empty but malformed
5465        // requirement (`"^bad-version"`) silently passed every pre-gate
5466        // codebase because `:deps :versao` wasn't validated. The parse
5467        // failure surfaced far downstream at lacre-resolve time with a
5468        // `semver::Error` that didn't name which `:deps` entry carried
5469        // the typo. The new gate moves the check to caixa-build time
5470        // at the source caixa.lisp.
5471        let d = Dep::simple("caixa-teia", "^bad-version");
5472        let err = d.validate().unwrap_err();
5473        assert!(
5474            matches!(
5475                err,
5476                DepError::VersaoInvalid { ref nome, ref versao, .. }
5477                    if nome == "caixa-teia" && versao == "^bad-version"
5478            ),
5479            "got {err:?}"
5480        );
5481    }
5482
5483    #[test]
5484    fn validate_rejects_versao_with_double_caret_typo() {
5485        // `"^^0.1"` is the canonical doubled-caret typo — looks like a
5486        // Cargo-shaped requirement on first glance but fails the parser
5487        // because semver doesn't accept stacked operators. Pin this
5488        // adjacent-shape footgun explicitly so a future relaxation that
5489        // accepts "looks-canonical-but-isn't" forms surfaces here, in
5490        // parity with the `:membros` / `:children` fixtures.
5491        let d = Dep::simple("caixa-teia", "^^0.1");
5492        let err = d.validate().unwrap_err();
5493        assert!(
5494            matches!(
5495                err,
5496                DepError::VersaoInvalid { ref nome, ref versao, .. }
5497                    if nome == "caixa-teia" && versao == "^^0.1"
5498            ),
5499            "got {err:?}"
5500        );
5501    }
5502
5503    #[test]
5504    fn validate_rejects_versao_with_v_prefixed_tag() {
5505        // `"v0.1"` is the canonical "git-tag-shape leaking into the
5506        // semver requirement slot" typo — an author copies the
5507        // publish-side git-tag string verbatim into `:versao`, but
5508        // Cargo's semver parser rejects the leading `v`. Same fixture
5509        // pinned for `:membros :versao` (9888b13) and `:children
5510        // :versao` (b38ff3a). (Bare `x`-glob shorthands like `^0.1.x`
5511        // are *accepted* by the semver crate as an `*` wildcard on the
5512        // patch axis — they're a Cargo-side valid shape, not a typo.)
5513        let d = Dep::simple("caixa-teia", "v0.1");
5514        let err = d.validate().unwrap_err();
5515        assert!(
5516            matches!(
5517                err,
5518                DepError::VersaoInvalid { ref nome, ref versao, .. }
5519                    if nome == "caixa-teia" && versao == "v0.1"
5520            ),
5521            "got {err:?}"
5522        );
5523    }
5524
5525    #[test]
5526    fn validate_accepts_canonical_versao_forms() {
5527        // The five Cargo-shaped requirement forms `:membros :versao`
5528        // and `:children :versao` already accept via
5529        // `crate::parse_requirement` must pass the deps gate without
5530        // re-validating at the resolver layer. Pin every leg so a
5531        // future tightening of the canonical set surfaces here as a
5532        // test failure.
5533        for form in [
5534            "^0.1",      // caret — minor-range pin (the most common shape)
5535            "~0.1.2",    // tilde — patch-range pin
5536            "0.1.0",     // exact — single-version pin
5537            "*",         // wildcard — explicitly any-version
5538            ">=0.1, <2", // multi-range — comma-separated comparators
5539        ] {
5540            Dep::simple("caixa-teia", form)
5541                .validate()
5542                .unwrap_or_else(|e| panic!("canonical form {form:?} must validate, got {e:?}"));
5543        }
5544    }
5545
5546    #[test]
5547    fn versao_empty_takes_precedence_over_invalid() {
5548        // Order pin: the existing `VersaoEmpty` diagnostic (which
5549        // doesn't try to parse) fires before the new `VersaoInvalid`
5550        // parse-side diagnostic, so an empty `:versao` keeps its
5551        // narrower error message — `parse_requirement("")` would
5552        // otherwise return `Ok(STAR)` and silently pass, but the empty
5553        // arm catches it first.
5554        let mut d = Dep::simple("caixa-teia", "ignored");
5555        d.versao = String::new();
5556        let err = d.validate().unwrap_err();
5557        assert!(
5558            matches!(err, DepError::VersaoEmpty { ref nome } if nome == "caixa-teia"),
5559            "got {err:?}"
5560        );
5561    }
5562
5563    #[test]
5564    fn nome_empty_takes_precedence_over_versao_invalid() {
5565        // Order pin: even when `:versao` is malformed and would raise
5566        // its own diagnostic, `:nome ""` fires first because the
5567        // per-entry parse diagnostic needs a non-empty name to be
5568        // self-locating. Mirrors the
5569        // `membros_validation_runs_before_contratos_membership_check`
5570        // ordering on the typed-graph layer.
5571        let mut d = Dep::simple("placeholder", "^bad");
5572        d.nome = String::new();
5573        let err = d.validate().unwrap_err();
5574        assert_eq!(err, DepError::NomeEmpty);
5575    }
5576
5577    #[test]
5578    fn versao_invalid_diagnostic_carries_offending_versao() {
5579        // The diagnostic-shape pin: the error names the offending
5580        // `:versao` value verbatim so the author can grep their
5581        // caixa.lisp without re-running the build, and carries a
5582        // non-empty `reason` from `semver::VersionReq::parse` so the
5583        // parser's own wording flows through to the diagnostic.
5584        let d = Dep::simple("caixa-teia", "not-a-req");
5585        let err = d.validate().unwrap_err();
5586        let DepError::VersaoInvalid {
5587            nome,
5588            versao,
5589            reason,
5590        } = err
5591        else {
5592            panic!("expected VersaoInvalid, got other variant");
5593        };
5594        assert_eq!(nome, "caixa-teia");
5595        assert_eq!(versao, "not-a-req");
5596        assert!(
5597            !reason.is_empty(),
5598            "VersaoInvalid `reason` must carry the parser's wording verbatim"
5599        );
5600    }
5601
5602    // -- :fonte value-shape gate ------------------------------------------
5603
5604    fn dep_with_fonte(fonte: DepSource) -> Dep {
5605        let mut d = Dep::simple("caixa-teia", "^0.1");
5606        d.fonte = Some(fonte);
5607        d
5608    }
5609
5610    #[test]
5611    fn validate_accepts_git_fonte_with_tag() {
5612        // The positive-control pin on the canonical git source — exactly
5613        // one of :tag/:rev/:branch set, non-empty :repo. Mirrors the
5614        // shape every existing caixa-resolver integration test uses.
5615        let d = dep_with_fonte(DepSource::Git {
5616            repo: "github:pleme-io/caixa-teia".into(),
5617            tag: Some("v0.1.0".into()),
5618            rev: None,
5619            branch: None,
5620        });
5621        d.validate().unwrap();
5622    }
5623
5624    #[test]
5625    fn validate_accepts_git_fonte_with_rev() {
5626        // Each of the three pin axes is independently a valid single-pin
5627        // shape; pin the :rev arm so a future relaxation that only
5628        // accepts :tag surfaces here. The value is a full 40-hex SHA-1
5629        // OID — the canonical `git rev-parse HEAD` emission shape the
5630        // `crate::render::is_git_oid` value-shape gate now requires;
5631        // abbreviated OIDs are ambiguous across repo history and
5632        // rejected at this gate (pinned separately by
5633        // `validate_rejects_git_fonte_with_rev_abbreviated_prefix`).
5634        let d = dep_with_fonte(DepSource::Git {
5635            repo: "github:pleme-io/caixa-teia".into(),
5636            tag: None,
5637            rev: Some("c0ffee0123abcdef0123456789abcdef01234567".into()),
5638            branch: None,
5639        });
5640        d.validate().unwrap();
5641    }
5642
5643    #[test]
5644    fn validate_accepts_git_fonte_with_branch() {
5645        // The :branch arm is the third valid single-pin shape — pinned
5646        // separately so the gate-accepts-all-three-pin-axes contract is
5647        // a build-error to relax.
5648        let d = dep_with_fonte(DepSource::Git {
5649            repo: "github:pleme-io/caixa-teia".into(),
5650            tag: None,
5651            rev: None,
5652            branch: Some("main".into()),
5653        });
5654        d.validate().unwrap();
5655    }
5656
5657    #[test]
5658    fn validate_accepts_path_fonte() {
5659        // The positive-control pin on the path source — non-empty
5660        // :caminho, no pin axes (paths have no commit identity). Pinned
5661        // so a future "paths must also pin a rev" tightening surfaces
5662        // here as a structural decision, not a silent break.
5663        let d = dep_with_fonte(DepSource::Path {
5664            caminho: "../caixa-teia".into(),
5665        });
5666        d.validate().unwrap();
5667    }
5668
5669    #[test]
5670    fn validate_rejects_git_fonte_with_empty_repo() {
5671        // The fail-before-pass-after pin for `(:tipo git :repo "" :tag
5672        // "v1")`: the empty-repo shape silently passed every pre-gate
5673        // codebase because `:fonte` wasn't validated. The git-clone
5674        // failure surfaced far downstream at lacre-resolve time with no
5675        // field naming which `:deps` entry carried the typo. The new
5676        // gate moves the check to caixa-build time at the source
5677        // caixa.lisp.
5678        let d = dep_with_fonte(DepSource::Git {
5679            repo: String::new(),
5680            tag: Some("v0.1.0".into()),
5681            rev: None,
5682            branch: None,
5683        });
5684        let err = d.validate().unwrap_err();
5685        assert!(
5686            matches!(err, DepError::FonteRepoEmpty { ref nome } if nome == "caixa-teia"),
5687            "got {err:?}"
5688        );
5689    }
5690
5691    // -- :repo value-shape gate -------------------------------------------
5692    //
5693    // The `:fonte (:tipo git :repo …)` value flows verbatim into the
5694    // caixa-resolver's `git clone <repo>` subprocess. The pre-gate
5695    // codebase admitted any non-empty string; the new
5696    // [`crate::render::is_git_repo_url`] predicate gates the git-porcelain
5697    // URL intersection-floor at validate time, peer with the three pin
5698    // axes (`:tag` + `:branch` via `is_git_ref_name`, `:rev` via
5699    // `is_git_oid`). Every test in this section is a fail-before /
5700    // pass-after pin on a specific authoring footgun.
5701
5702    #[test]
5703    fn validate_rejects_git_fonte_with_repo_carrying_trailing_space() {
5704        // The canonical paste-from-doc footgun on `:repo` — an author
5705        // copies `"github:pleme-io/caixa-teia "` (trailing space) out of
5706        // a doc paragraph. Until this gate landed the empty-repo arm
5707        // passed (the string isn't empty), the resolver issued
5708        // `git clone 'github:pleme-io/caixa-teia '`, and the failure
5709        // surfaced at clone time with a quoting-confused error far from
5710        // the source caixa.lisp. Same paste-from-doc footgun the
5711        // `:tag "v0.1.0 "` gate (e70d213) closes on the peer refname
5712        // axis — now closed on the `:repo` URL axis too.
5713        let d = dep_with_fonte(DepSource::Git {
5714            repo: "github:pleme-io/caixa-teia ".into(),
5715            tag: Some("v0.1.0".into()),
5716            rev: None,
5717            branch: None,
5718        });
5719        let err = d.validate().unwrap_err();
5720        let DepError::FonteRepoShape { nome, repo, reason } = err else {
5721            panic!("expected FonteRepoShape, got other variant");
5722        };
5723        assert_eq!(nome, "caixa-teia");
5724        assert_eq!(repo, "github:pleme-io/caixa-teia ");
5725        assert!(
5726            reason.contains("whitespace"),
5727            "reason must surface the whitespace arm, got {reason:?}"
5728        );
5729    }
5730
5731    #[test]
5732    fn validate_rejects_git_fonte_with_repo_starting_with_dash() {
5733        // The canonical CLI-argument-injection footgun at the `git clone`
5734        // subprocess boundary — `:repo "-upload-pack=evil"` makes git's
5735        // argv parser read the value as a CLI flag, escaping the
5736        // subprocess argument boundary. The `--` separator workaround
5737        // does not fix the typed slot's accepted set; the gate rejects
5738        // the shape upstream at validate time so the resolver never
5739        // invokes a `git clone -…` subprocess.
5740        let d = dep_with_fonte(DepSource::Git {
5741            repo: "-upload-pack=evil".into(),
5742            tag: Some("v0.1.0".into()),
5743            rev: None,
5744            branch: None,
5745        });
5746        let err = d.validate().unwrap_err();
5747        let DepError::FonteRepoShape { repo, reason, .. } = err else {
5748            panic!("expected FonteRepoShape, got other variant");
5749        };
5750        assert_eq!(repo, "-upload-pack=evil");
5751        assert!(
5752            reason.contains("must not start with `-`"),
5753            "reason must surface the leading-`-` arm, got {reason:?}"
5754        );
5755    }
5756
5757    #[test]
5758    fn validate_rejects_git_fonte_with_repo_carrying_embedded_newline() {
5759        // The canonical paste-from-multiline-doc footgun — a `:repo`
5760        // string with an embedded `\n` silently breaks git's URL parser
5761        // and is a class of CRLF-injection at the subprocess-argument
5762        // boundary. Caught by the control-char arm (0x0A < 0x20).
5763        let d = dep_with_fonte(DepSource::Git {
5764            repo: "github:pleme-io/caixa-teia\nrm -rf /".into(),
5765            tag: Some("v0.1.0".into()),
5766            rev: None,
5767            branch: None,
5768        });
5769        let err = d.validate().unwrap_err();
5770        let DepError::FonteRepoShape { reason, .. } = err else {
5771            panic!("expected FonteRepoShape, got other variant");
5772        };
5773        assert!(
5774            reason.contains("control character"),
5775            "reason must surface the control-char arm, got {reason:?}"
5776        );
5777    }
5778
5779    #[test]
5780    fn validate_rejects_git_fonte_with_repo_carrying_tab() {
5781        // Tab is the sibling whitespace footgun (the canonical
5782        // copy-from-aligned-table paste); pinned separately from the
5783        // space arm so a future relaxation that only catches one
5784        // surfaces here.
5785        let d = dep_with_fonte(DepSource::Git {
5786            repo: "github:pleme-io/caixa-teia\t".into(),
5787            tag: Some("v0.1.0".into()),
5788            rev: None,
5789            branch: None,
5790        });
5791        let err = d.validate().unwrap_err();
5792        assert!(
5793            matches!(
5794                err,
5795                DepError::FonteRepoShape { ref reason, .. }
5796                    if reason.contains("whitespace")
5797            ),
5798            "got {err:?}"
5799        );
5800    }
5801
5802    #[test]
5803    fn validate_rejects_git_fonte_with_repo_carrying_non_ascii() {
5804        // IDN hosts must be pre-encoded as Punycode (`xn--…`) — raw
5805        // non-ASCII silently breaks at git's URL parser and round-trips
5806        // inconsistently across NFC/NFD normalization on APFS /
5807        // case-folding filesystems. Same intersection-floor
5808        // [`is_git_ref_name`] enforces on the refname axes.
5809        let d = dep_with_fonte(DepSource::Git {
5810            repo: "https://github.com/pleme-io/café".into(),
5811            tag: Some("v0.1.0".into()),
5812            rev: None,
5813            branch: None,
5814        });
5815        let err = d.validate().unwrap_err();
5816        assert!(
5817            matches!(
5818                err,
5819                DepError::FonteRepoShape { ref reason, .. }
5820                    if reason.contains("non-ASCII")
5821            ),
5822            "got {err:?}"
5823        );
5824    }
5825
5826    #[test]
5827    fn validate_rejects_git_fonte_with_repo_carrying_fragment_anchor() {
5828        // The fail-before-pass-after pin for the canonical paste-from-
5829        // browser-address-bar footgun on `:repo`: an author copies a
5830        // GitHub permalink to a README anchor / line-permalink and
5831        // forgets to trim the `#fragment` tail. Until this arm landed
5832        // `:repo "https://github.com/pleme-io/caixa-teia#readme"`
5833        // silently passed every prior arm (no whitespace, no control
5834        // chars, no non-ASCII, contains a `:`, doesn't start with `-`
5835        // or `:`), libcurl's URL parser stripped the `#readme` tail
5836        // before opening the HTTPS transport, and the lacre embedded
5837        // the value verbatim in its per-dep BLAKE3 closure — two
5838        // authors whose values differ only in their fragment anchor
5839        // (`#readme` vs `#L42`) resolve to the byte-identical upstream
5840        // `git clone` but lock to two distinct lacres, defeating the
5841        // THEORY.md §V.2 render-determinism contract. Same value-shape
5842        // axis-floor every peer typed surface enforces; peer `:fonte
5843        // :tag` / `:fonte :branch` already reject the byte-class through
5844        // `is_git_ref_name`'s alphabet (refs are leaf identifiers, no
5845        // URL grammar admitted) and `:entrada :paths` rejects `#` as
5846        // part of `is_gateway_api_http_path`'s RFC-3986-reserved set.
5847        let d = dep_with_fonte(DepSource::Git {
5848            repo: "https://github.com/pleme-io/caixa-teia#readme".into(),
5849            tag: Some("v0.1.0".into()),
5850            rev: None,
5851            branch: None,
5852        });
5853        let err = d.validate().unwrap_err();
5854        let DepError::FonteRepoShape { nome, repo, reason } = err else {
5855            panic!("expected FonteRepoShape, got other variant");
5856        };
5857        assert_eq!(nome, "caixa-teia");
5858        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia#readme");
5859        assert!(
5860            reason.contains("must not contain `#`"),
5861            "reason must surface the fragment-`#` arm, got {reason:?}"
5862        );
5863        assert!(
5864            reason.contains("fragment"),
5865            "reason must name the URL fragment grammar, got {reason:?}"
5866        );
5867    }
5868
5869    #[test]
5870    fn validate_rejects_git_fonte_with_repo_carrying_flake_ref_fragment() {
5871        // The symmetric paste-from-Nix-flake-ref footgun — an author
5872        // confuses the Nix flake-reference idiom (`github:foo/
5873        // bar#packageName`, where `#packageName` selects a flake
5874        // output) with the bare git `:repo` shape. The pleme-io
5875        // substrate authors compose flakes downstream of caixa
5876        // (caixa-flake renders a flake.nix), so the cross-idiom leak
5877        // is the canonical near-miss: the author writes the
5878        // flake-ref shape into a git `:repo` slot. Pinned separately
5879        // from the HTTPS-anchor arm so a future relaxation that
5880        // narrows to one URL scheme surfaces here.
5881        let d = dep_with_fonte(DepSource::Git {
5882            repo: "github:pleme-io/caixa-teia#caixa-teia".into(),
5883            tag: Some("v0.1.0".into()),
5884            rev: None,
5885            branch: None,
5886        });
5887        let err = d.validate().unwrap_err();
5888        let DepError::FonteRepoShape { reason, .. } = err else {
5889            panic!("expected FonteRepoShape, got other variant");
5890        };
5891        assert!(
5892            reason.contains("must not contain `#`"),
5893            "reason must surface the fragment-`#` arm, got {reason:?}"
5894        );
5895        assert!(
5896            reason.contains("Nix flake"),
5897            "reason must name the Nix-flake-ref cross-idiom footgun, got {reason:?}"
5898        );
5899    }
5900
5901    #[test]
5902    fn validate_rejects_git_fonte_with_repo_carrying_query_string() {
5903        // The fail-before-pass-after pin for the canonical paste-from-
5904        // browser-address-bar footgun on `:repo` (peer with the
5905        // a68f818 fragment-`#` arm on the same axis). An author
5906        // copies a GitHub tab deep-link out of the address bar and
5907        // forgets to trim the `?tab=…` query tail. Until this arm
5908        // landed `:repo "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file"`
5909        // silently passed every prior arm (no whitespace, no control
5910        // chars, no non-ASCII, no `#` fragment, contains a `:`,
5911        // doesn't start with `-` or `:`); GitHub silently ignored
5912        // the `?query` tail and served the same repo regardless;
5913        // the lacre embedded the value verbatim in its per-dep
5914        // BLAKE3 closure — two authors whose values differ only in
5915        // their query tail (`?tab=readme-ov-file` vs `?ref=main` vs
5916        // `?utm_source=twitter`) resolve to the byte-identical
5917        // upstream `git clone` but lock to two distinct lacres,
5918        // defeating the THEORY.md §V.2 render-determinism contract
5919        // on the same axis the `#` fragment arm closes. Same value-
5920        // shape axis-floor every peer typed surface enforces; peer
5921        // `:fonte :tag` / `:fonte :branch` already reject the byte-
5922        // class through `is_git_ref_name`'s alphabet (refspec glob
5923        // wildcards, caixa-core/src/render.rs:1426) and `:entrada
5924        // :paths` rejects `?` as the query separator in
5925        // `is_gateway_api_http_path` (caixa-core/src/render.rs:473).
5926        let d = dep_with_fonte(DepSource::Git {
5927            repo: "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file".into(),
5928            tag: Some("v0.1.0".into()),
5929            rev: None,
5930            branch: None,
5931        });
5932        let err = d.validate().unwrap_err();
5933        let DepError::FonteRepoShape { nome, repo, reason } = err else {
5934            panic!("expected FonteRepoShape, got other variant");
5935        };
5936        assert_eq!(nome, "caixa-teia");
5937        assert_eq!(
5938            repo,
5939            "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file"
5940        );
5941        assert!(
5942            reason.contains("must not contain `?`"),
5943            "reason must surface the query-`?` arm, got {reason:?}"
5944        );
5945        assert!(
5946            reason.contains("query"),
5947            "reason must name the URL query grammar, got {reason:?}"
5948        );
5949    }
5950
5951    #[test]
5952    fn validate_rejects_git_fonte_with_repo_carrying_utm_tracker() {
5953        // The symmetric paste-from-social-share footgun — an author
5954        // copies a repo URL out of a Slack unfurl / Twitter share /
5955        // newsletter link / Discord embed and forgets to trim the
5956        // `?utm_source=…` / `?utm_medium=…` / `?utm_campaign=…`
5957        // campaign-tracker tail. Every major social-share / unfurl /
5958        // newsletter platform appends these UTM parameters; the
5959        // canonical near-miss on the `:repo` axis. Pinned separately
5960        // from the GitHub-tab-deep-link arm so a future relaxation
5961        // that narrows to one query-parameter class surfaces here.
5962        let d = dep_with_fonte(DepSource::Git {
5963            repo: "https://github.com/pleme-io/caixa-teia?utm_source=twitter&utm_campaign=launch"
5964                .into(),
5965            tag: Some("v0.1.0".into()),
5966            rev: None,
5967            branch: None,
5968        });
5969        let err = d.validate().unwrap_err();
5970        let DepError::FonteRepoShape { reason, .. } = err else {
5971            panic!("expected FonteRepoShape, got other variant");
5972        };
5973        assert!(
5974            reason.contains("must not contain `?`"),
5975            "reason must surface the query-`?` arm, got {reason:?}"
5976        );
5977        assert!(
5978            reason.contains("campaign-tracker"),
5979            "reason must name the campaign-tracker paste footgun, got {reason:?}"
5980        );
5981    }
5982
5983    #[test]
5984    fn fonte_repo_fragment_fires_before_query_when_fragment_first() {
5985        // Cascade pin: the fragment-`#` arm and the query-`?` arm are
5986        // both per-byte arms inside the same `for &b in s.as_bytes()`
5987        // loop, so the byte that appears first in the value's byte
5988        // order wins. A `:repo "https://github.com/p/x#readme?ref=main"`
5989        // (fragment before query — unusual URL-grammar but value-
5990        // disjoint at byte level) carries both `#` and `?`; the `#`
5991        // byte appears first, so the fragment-`#` arm fires, surfacing
5992        // the more self-locating diagnostic on the byte the author
5993        // pasted earliest in the URL. Mirrors the peer cascade
5994        // discipline `fonte_repo_control_char_fires_before_fragment`
5995        // pins on the prior `:repo` byte-class arm.
5996        let d = dep_with_fonte(DepSource::Git {
5997            repo: "https://github.com/pleme-io/caixa-teia#readme?ref=main".into(),
5998            tag: Some("v0.1.0".into()),
5999            rev: None,
6000            branch: None,
6001        });
6002        let err = d.validate().unwrap_err();
6003        let DepError::FonteRepoShape { reason, .. } = err else {
6004            panic!("expected FonteRepoShape, got other variant");
6005        };
6006        assert!(
6007            reason.contains("must not contain `#`"),
6008            "reason must surface the fragment-`#` arm (fires before query-`?` when \
6009             `#` byte appears first in value), got {reason:?}"
6010        );
6011    }
6012
6013    #[test]
6014    fn fonte_repo_control_char_fires_before_fragment() {
6015        // Cascade pin: the control-char arm structurally precedes the
6016        // fragment-`#` arm. A value like `"github:p/x\n#readme"` probes
6017        // positive on both arms (contains LF and `#`), but the narrower
6018        // POSIX-syscall-rejected / CRLF-injection-class diagnostic
6019        // (`control character`) wins so the author sees the more
6020        // self-locating arm first. Mirrors the peer cascade discipline
6021        // every prior `:repo` byte-class arm establishes.
6022        let d = dep_with_fonte(DepSource::Git {
6023            repo: "github:pleme-io/caixa-teia\n#readme".into(),
6024            tag: Some("v0.1.0".into()),
6025            rev: None,
6026            branch: None,
6027        });
6028        let err = d.validate().unwrap_err();
6029        let DepError::FonteRepoShape { reason, .. } = err else {
6030            panic!("expected FonteRepoShape, got other variant");
6031        };
6032        assert!(
6033            reason.contains("control character"),
6034            "reason must surface the control-char arm, got {reason:?}"
6035        );
6036    }
6037
6038    #[test]
6039    fn validate_rejects_git_fonte_with_repo_carrying_embedded_backslash() {
6040        // The fail-before-pass-after pin for the canonical Windows-
6041        // file-path-confusion footgun on `:repo` (peer with the 3a4e1d7
6042        // backslash arm on the sibling `:caminho` path-fonte axis).
6043        // An author pastes a Windows Explorer address-bar / PowerShell
6044        // `Get-Location` output into a `file://` URL slot, producing
6045        // `file:///C:\Users\me\caixa-teia`. Until this arm landed the
6046        // value silently passed every prior arm (no whitespace, no
6047        // control chars, no non-ASCII, no `#`, no `?`, doesn't start
6048        // with `-` or `:`); libcurl's URL parser silently translates
6049        // `\` → `/` on some platforms and refuses it on others, so
6050        // the byte rides verbatim into the lacre's per-dep content-
6051        // address but is silently rewritten / rejected at the wire —
6052        // two authors whose `:repo` values differ only in backslash-
6053        // vs-forward-slash (`file:///C:\path` vs `file:///C:/path`)
6054        // resolve to the byte-identical local clone but lock to two
6055        // distinct BLAKE3 closures, defeating the THEORY.md §V.2
6056        // render-determinism contract on the same axis the `#`
6057        // fragment and `?` query arms close. Same value-shape axis-
6058        // floor every peer typed surface enforces; the `:caminho`
6059        // 3a4e1d7 arm closes the same byte on the path-fonte axis.
6060        let d = dep_with_fonte(DepSource::Git {
6061            repo: "file:///C:\\Users\\me\\caixa-teia".into(),
6062            tag: Some("v0.1.0".into()),
6063            rev: None,
6064            branch: None,
6065        });
6066        let err = d.validate().unwrap_err();
6067        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6068            panic!("expected FonteRepoShape, got other variant");
6069        };
6070        assert_eq!(nome, "caixa-teia");
6071        assert_eq!(repo, "file:///C:\\Users\\me\\caixa-teia");
6072        assert!(
6073            reason.contains("must not contain `\\`"),
6074            "reason must surface the backslash-`\\` arm, got {reason:?}"
6075        );
6076        assert!(
6077            reason.contains("Windows"),
6078            "reason must name the Windows-path-confusion footgun, got {reason:?}"
6079        );
6080    }
6081
6082    #[test]
6083    fn validate_rejects_git_fonte_with_repo_carrying_mangled_https_backslashes() {
6084        // The symmetric Win32-shell-mangled-slashes footgun — an author
6085        // copies `https://github.com/foo/bar` into a Win32 shell that
6086        // rewrites every `/` to `\` (the canonical `cmd.exe` path-
6087        // separator-coercion bug), pastes the result into a `:repo`
6088        // slot, and produces `https:\\github.com\foo\bar`. Pinned
6089        // separately from the `file://` Explorer-paste arm so a future
6090        // relaxation that narrows to one URL scheme surfaces here.
6091        let d = dep_with_fonte(DepSource::Git {
6092            repo: "https:\\\\github.com\\pleme-io\\caixa-teia".into(),
6093            tag: Some("v0.1.0".into()),
6094            rev: None,
6095            branch: None,
6096        });
6097        let err = d.validate().unwrap_err();
6098        let DepError::FonteRepoShape { reason, .. } = err else {
6099            panic!("expected FonteRepoShape, got other variant");
6100        };
6101        assert!(
6102            reason.contains("must not contain `\\`"),
6103            "reason must surface the backslash-`\\` arm, got {reason:?}"
6104        );
6105        assert!(
6106            reason.contains("path separator") || reason.contains("path-segment separator"),
6107            "reason must name the URL path-segment separator grammar, got {reason:?}"
6108        );
6109    }
6110
6111    #[test]
6112    fn fonte_repo_fragment_fires_before_backslash_when_fragment_first() {
6113        // Cascade pin: the fragment-`#` arm and the backslash-`\` arm
6114        // are both per-byte arms inside the same `for &b in s.as_bytes()`
6115        // loop, so the byte that appears first in the value's byte order
6116        // wins. A `:repo "https://github.com/p/x#readme\\foo"` carries
6117        // both `#` and `\`; the `#` byte appears first, so the fragment-
6118        // `#` arm fires, surfacing the more self-locating diagnostic on
6119        // the byte the author pasted earliest in the URL. Mirrors the
6120        // peer cascade discipline `fonte_repo_fragment_fires_before_query_when_fragment_first`
6121        // pins on the prior `:repo` byte-class arm.
6122        let d = dep_with_fonte(DepSource::Git {
6123            repo: "https://github.com/pleme-io/caixa-teia#readme\\foo".into(),
6124            tag: Some("v0.1.0".into()),
6125            rev: None,
6126            branch: None,
6127        });
6128        let err = d.validate().unwrap_err();
6129        let DepError::FonteRepoShape { reason, .. } = err else {
6130            panic!("expected FonteRepoShape, got other variant");
6131        };
6132        assert!(
6133            reason.contains("must not contain `#`"),
6134            "reason must surface the fragment-`#` arm (fires before backslash-`\\` when \
6135             `#` byte appears first in value), got {reason:?}"
6136        );
6137    }
6138
6139    #[test]
6140    fn validate_rejects_git_fonte_with_repo_carrying_uri_template_placeholder() {
6141        // The fail-before-pass-after pin for the canonical URI Template
6142        // (RFC 6570) placeholder footgun on `:repo`. An author copies a
6143        // README quick-start snippet / OpenAPI `servers:` URL / Helm
6144        // chart `home:` template that carries unresolved
6145        // `{org}` / `{repo}` placeholders and pastes the raw template
6146        // into the `:repo` slot, expecting the substrate to resolve the
6147        // placeholder downstream. Until this arm landed the value
6148        // silently passed every prior arm (no whitespace, no control
6149        // chars, no non-ASCII, no `#`, no `?`, no `\`, doesn't start
6150        // with `-` or `:`); libcurl percent-encodes `{` / `}` to `%7B`
6151        // / `%7D` on the wire, so the byte rides verbatim into the
6152        // lacre's per-dep content-address but round-trips inconsistently
6153        // between the lacre's per-dep content-address and the
6154        // resolver's `git clone <repo>` invocation, defeating the
6155        // THEORY.md §V.2 render-determinism contract on the same axis
6156        // the `#` fragment, `?` query, and `\` backslash arms close;
6157        // every git porcelain entry-point additionally fetches a
6158        // nonexistent literal-`{placeholder}`-named path far from the
6159        // source caixa.lisp.
6160        let d = dep_with_fonte(DepSource::Git {
6161            repo: "https://github.com/{org}/caixa-teia".into(),
6162            tag: Some("v0.1.0".into()),
6163            rev: None,
6164            branch: None,
6165        });
6166        let err = d.validate().unwrap_err();
6167        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6168            panic!("expected FonteRepoShape, got other variant");
6169        };
6170        assert_eq!(nome, "caixa-teia");
6171        assert_eq!(repo, "https://github.com/{org}/caixa-teia");
6172        assert!(
6173            reason.contains("must not contain `{`"),
6174            "reason must surface the open-brace `{{` arm, got {reason:?}"
6175        );
6176        assert!(
6177            reason.contains("URI Template") || reason.contains("RFC 6570"),
6178            "reason must name the RFC 6570 URI Template grammar, got {reason:?}"
6179        );
6180    }
6181
6182    #[test]
6183    fn validate_rejects_git_fonte_with_repo_carrying_handlebars_doubled_brace() {
6184        // The symmetric Mustache / Handlebars doubled-brace
6185        // substitution-form footgun every CI / IaC templating engine
6186        // (Argo Workflows, Jinja2, Liquid, Vue / Angular interpolation,
6187        // GitHub Actions `${{ … }}` even though Actions uses `${{`) /
6188        // chart README quick-start snippet emits. Pinned separately
6189        // from the single-`{` `{org}` arm so a future relaxation that
6190        // narrows to one substitution-form surfaces here.
6191        let d = dep_with_fonte(DepSource::Git {
6192            repo: "https://github.com/{{org}}/caixa-teia".into(),
6193            tag: Some("v0.1.0".into()),
6194            rev: None,
6195            branch: None,
6196        });
6197        let err = d.validate().unwrap_err();
6198        let DepError::FonteRepoShape { reason, .. } = err else {
6199            panic!("expected FonteRepoShape, got other variant");
6200        };
6201        assert!(
6202            reason.contains("must not contain `{`"),
6203            "reason must surface the open-brace `{{` arm, got {reason:?}"
6204        );
6205    }
6206
6207    #[test]
6208    fn validate_rejects_git_fonte_with_repo_carrying_closing_brace_only() {
6209        // Asymmetric `}`-only shape — covers the closing-brace-by-
6210        // itself footgun (an author truncated `{org}/{repo}` mid-edit
6211        // and left a trailing `}` from the prior template fragment,
6212        // or pasted a value that included a closing brace from a
6213        // surrounding shell context). Pinned to ensure the predicate
6214        // refuses each brace independently rather than only when both
6215        // appear — a future regression that ANDs the two byte tests
6216        // surfaces here.
6217        let d = dep_with_fonte(DepSource::Git {
6218            repo: "https://github.com/pleme-io/caixa-teia}".into(),
6219            tag: Some("v0.1.0".into()),
6220            rev: None,
6221            branch: None,
6222        });
6223        let err = d.validate().unwrap_err();
6224        let DepError::FonteRepoShape { reason, .. } = err else {
6225            panic!("expected FonteRepoShape, got other variant");
6226        };
6227        assert!(
6228            reason.contains("must not contain `}`"),
6229            "reason must surface the close-brace `}}` arm, got {reason:?}"
6230        );
6231    }
6232
6233    #[test]
6234    fn fonte_repo_fragment_fires_before_template_placeholder_when_fragment_first() {
6235        // Cascade pin: the fragment-`#` arm and the template-`{` /
6236        // `}` arm are both per-byte arms inside the same
6237        // `for &b in s.as_bytes()` loop, so the byte that appears
6238        // first in the value's byte order wins. A `:repo
6239        // "https://github.com/p/x#readme{org}"` carries both `#` and
6240        // `{`; the `#` byte appears first, so the fragment-`#` arm
6241        // fires, surfacing the more self-locating diagnostic on the
6242        // byte the author pasted earliest in the URL. Mirrors the
6243        // peer cascade discipline `fonte_repo_fragment_fires_before_backslash_when_fragment_first`
6244        // pins on the prior `:repo` byte-class arm.
6245        let d = dep_with_fonte(DepSource::Git {
6246            repo: "https://github.com/pleme-io/caixa-teia#readme{org}".into(),
6247            tag: Some("v0.1.0".into()),
6248            rev: None,
6249            branch: None,
6250        });
6251        let err = d.validate().unwrap_err();
6252        let DepError::FonteRepoShape { reason, .. } = err else {
6253            panic!("expected FonteRepoShape, got other variant");
6254        };
6255        assert!(
6256            reason.contains("must not contain `#`"),
6257            "reason must surface the fragment-`#` arm (fires before template-`{{` when \
6258             `#` byte appears first in value), got {reason:?}"
6259        );
6260    }
6261
6262    #[test]
6263    fn validate_rejects_git_fonte_with_repo_carrying_output_redirection() {
6264        // The fail-before-pass-after pin for the canonical
6265        // shell-output-redirection footgun on `:repo`: an author
6266        // pastes a shell-pipeline tail (`git clone <repo> > build.log`
6267        // / `… >output.txt`) into the `:repo` slot without trimming
6268        // the redirect. Until this arm landed the value silently
6269        // passed every prior arm (no whitespace, no control chars,
6270        // no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, doesn't
6271        // start with `-` or `:`); RFC 3986 §2 lists `<` / `>` in the
6272        // 'delims' / 'unwise' set and the WHATWG URL spec's fragment
6273        // percent-encode set maps `>` → `%3E` on the wire, so the
6274        // byte rides verbatim into the lacre's per-dep BLAKE3 closure
6275        // but is silently rewritten or rejected at libcurl's URL-
6276        // parser layer — two authors whose values differ only in
6277        // their redirect tail (`>build.log` vs nothing) resolve to
6278        // the byte-identical upstream `git clone` but lock to two
6279        // distinct lacres, defeating the THEORY.md §V.2 render-
6280        // determinism contract. Peer with the `:caminho` axis's
6281        // `FonteCaminhoShellRedirection` arm (e457141) on the sibling
6282        // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
6283        // byte RFC-3986-reserved set on `:entrada :paths`.
6284        let d = dep_with_fonte(DepSource::Git {
6285            repo: "https://github.com/pleme-io/caixa-teia>build.log".into(),
6286            tag: Some("v0.1.0".into()),
6287            rev: None,
6288            branch: None,
6289        });
6290        let err = d.validate().unwrap_err();
6291        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6292            panic!("expected FonteRepoShape, got other variant");
6293        };
6294        assert_eq!(nome, "caixa-teia");
6295        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia>build.log");
6296        assert!(
6297            reason.contains("must not contain `>`"),
6298            "reason must surface the output-redirection `>` arm, got {reason:?}"
6299        );
6300        assert!(
6301            reason.contains("redirection") || reason.contains("'delims'"),
6302            "reason must name the shell-redirection / RFC-3986-unwise rationale, got {reason:?}"
6303        );
6304    }
6305
6306    #[test]
6307    fn validate_rejects_git_fonte_with_repo_carrying_input_redirection() {
6308        // The symmetric shell-input-redirection footgun — an author
6309        // pastes a shell-pipeline head (`git clone <input.url` /
6310        // `cat <README.md`) into the `:repo` slot. Pinned separately
6311        // from the `>`-output arm so a future relaxation that only
6312        // catches one of the two redirect bytes surfaces here. Peer
6313        // with the `:caminho` axis's `FonteCaminhoShellRedirection`
6314        // arm which closes both `<` and `>` under the same banner.
6315        let d = dep_with_fonte(DepSource::Git {
6316            repo: "https://github.com/pleme-io/caixa-teia<input.url".into(),
6317            tag: Some("v0.1.0".into()),
6318            rev: None,
6319            branch: None,
6320        });
6321        let err = d.validate().unwrap_err();
6322        let DepError::FonteRepoShape { reason, .. } = err else {
6323            panic!("expected FonteRepoShape, got other variant");
6324        };
6325        assert!(
6326            reason.contains("must not contain `<`"),
6327            "reason must surface the input-redirection `<` arm, got {reason:?}"
6328        );
6329        assert!(
6330            reason.contains("RFC 3986") || reason.contains("'unwise'"),
6331            "reason must name the RFC 3986 'unwise' grammar, got {reason:?}"
6332        );
6333    }
6334
6335    #[test]
6336    fn validate_rejects_git_fonte_with_repo_carrying_backtick_command_substitution() {
6337        // The fail-before-pass-after pin for the canonical
6338        // paste-from-shell-prompt-with-backticked-substitution footgun
6339        // on `:repo` (peer with the c4d62b3 backtick arm on the sibling
6340        // `:caminho` path-fonte axis). An author pastes a URL whose
6341        // segment carries a backticked command-substitution wrapper
6342        // (`` `whoami` ``, `` `git config user.name` ``, `` `pwd` ``)
6343        // from a doc / README quick-start snippet that expected the
6344        // substrate to substitute the value downstream. Until this arm
6345        // landed the value silently passed every prior arm (no
6346        // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
6347        // no `\`, no `{`/`}`, no `<`/`>`, doesn't start with `-` or
6348        // `:`); RFC 3986 §2 lists the backtick byte in the 'delims' /
6349        // 'unwise' set and the WHATWG URL spec's fragment percent-
6350        // encode set maps `` ` `` → `%60` on the wire, so the byte
6351        // rides verbatim into the lacre's per-dep BLAKE3 closure but
6352        // is silently rewritten or rejected at libcurl's URL-parser
6353        // layer — two authors whose values differ only in their
6354        // backtick wrapper (`` `whoami` `` vs nothing) resolve to the
6355        // byte-identical upstream `git clone` but lock to two distinct
6356        // lacres, defeating the THEORY.md §V.2 render-determinism
6357        // contract. Peer with the `:caminho` axis's
6358        // `FonteCaminhoShellCommandSubstitution` arm (c4d62b3) on the
6359        // sibling path-fonte axis, and `is_gateway_api_http_path`'s
6360        // eleven-byte RFC-3986-reserved set on `:entrada :paths`.
6361        let d = dep_with_fonte(DepSource::Git {
6362            repo: "https://github.com/pleme-io/`whoami`/caixa-teia".into(),
6363            tag: Some("v0.1.0".into()),
6364            rev: None,
6365            branch: None,
6366        });
6367        let err = d.validate().unwrap_err();
6368        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6369            panic!("expected FonteRepoShape, got other variant");
6370        };
6371        assert_eq!(nome, "caixa-teia");
6372        assert_eq!(repo, "https://github.com/pleme-io/`whoami`/caixa-teia");
6373        assert!(
6374            reason.contains("must not contain `` ` ``"),
6375            "reason must surface the backtick command-substitution arm, got {reason:?}"
6376        );
6377        assert!(
6378            reason.contains("command-substitution") || reason.contains("'unwise'"),
6379            "reason must name the shell-command-substitution / RFC-3986-unwise rationale, \
6380             got {reason:?}"
6381        );
6382    }
6383
6384    #[test]
6385    fn fonte_repo_fragment_fires_before_backtick_when_fragment_first() {
6386        // Cascade pin: the fragment-`#` arm and the backtick command-
6387        // substitution arm are both per-byte arms inside the same
6388        // `for &b in s.as_bytes()` loop, so the byte that appears first
6389        // in the value's byte order wins. A `:repo
6390        // "https://github.com/p/x#readme/`whoami`"` carries both `#`
6391        // and backtick; the `#` byte appears first, so the fragment-
6392        // `#` arm fires, surfacing the more self-locating diagnostic
6393        // on the byte the author pasted earliest in the URL. Mirrors
6394        // the peer cascade discipline
6395        // `fonte_repo_fragment_fires_before_shell_redirection_when_fragment_first`
6396        // pins on the prior `:repo` byte-class arm.
6397        let d = dep_with_fonte(DepSource::Git {
6398            repo: "https://github.com/pleme-io/caixa-teia#readme/`whoami`".into(),
6399            tag: Some("v0.1.0".into()),
6400            rev: None,
6401            branch: None,
6402        });
6403        let err = d.validate().unwrap_err();
6404        let DepError::FonteRepoShape { reason, .. } = err else {
6405            panic!("expected FonteRepoShape, got other variant");
6406        };
6407        assert!(
6408            reason.contains("must not contain `#`"),
6409            "reason must surface the fragment-`#` arm (fires before backtick when `#` byte \
6410             appears first in value), got {reason:?}"
6411        );
6412    }
6413
6414    #[test]
6415    fn fonte_repo_shell_redirection_fires_before_backtick_when_redirection_first() {
6416        // Cascade pin: the shell-redirection `<` / `>` arm and the
6417        // backtick command-substitution arm are both per-byte arms
6418        // inside the same `for &b in s.as_bytes()` loop, so the byte
6419        // that appears first in the value's byte order wins. A `:repo
6420        // "https://github.com/p/x>build.log/`whoami`"` carries both
6421        // `>` and backtick; the `>` byte appears first, so the
6422        // shell-redirection arm fires, surfacing the more self-
6423        // locating diagnostic on the byte the author pasted earliest
6424        // in the URL. Pins the natural-order cascade so a future
6425        // reorder of the per-byte arms surfaces here.
6426        let d = dep_with_fonte(DepSource::Git {
6427            repo: "https://github.com/pleme-io/caixa-teia>build.log/`whoami`".into(),
6428            tag: Some("v0.1.0".into()),
6429            rev: None,
6430            branch: None,
6431        });
6432        let err = d.validate().unwrap_err();
6433        let DepError::FonteRepoShape { reason, .. } = err else {
6434            panic!("expected FonteRepoShape, got other variant");
6435        };
6436        assert!(
6437            reason.contains("must not contain `>`"),
6438            "reason must surface the shell-redirection `>` arm (fires before backtick when \
6439             `>` byte appears first in value), got {reason:?}"
6440        );
6441    }
6442
6443    #[test]
6444    fn fonte_repo_fragment_fires_before_shell_redirection_when_fragment_first() {
6445        // Cascade pin: the fragment-`#` arm and the shell-redirection
6446        // `<` / `>` arm are both per-byte arms inside the same
6447        // `for &b in s.as_bytes()` loop, so the byte that appears
6448        // first in the value's byte order wins. A `:repo
6449        // "https://github.com/p/x#readme>build.log"` carries both
6450        // `#` and `>`; the `#` byte appears first, so the fragment-
6451        // `#` arm fires, surfacing the more self-locating diagnostic
6452        // on the byte the author pasted earliest in the URL. Mirrors
6453        // the peer cascade discipline
6454        // `fonte_repo_fragment_fires_before_template_placeholder_when_fragment_first`
6455        // pins on the prior `:repo` byte-class arm.
6456        let d = dep_with_fonte(DepSource::Git {
6457            repo: "https://github.com/pleme-io/caixa-teia#readme>build.log".into(),
6458            tag: Some("v0.1.0".into()),
6459            rev: None,
6460            branch: None,
6461        });
6462        let err = d.validate().unwrap_err();
6463        let DepError::FonteRepoShape { reason, .. } = err else {
6464            panic!("expected FonteRepoShape, got other variant");
6465        };
6466        assert!(
6467            reason.contains("must not contain `#`"),
6468            "reason must surface the fragment-`#` arm (fires before shell-redirection `>` when \
6469             `#` byte appears first in value), got {reason:?}"
6470        );
6471    }
6472
6473    #[test]
6474    fn validate_rejects_git_fonte_with_repo_carrying_shell_pipe() {
6475        // The fail-before-pass-after pin for the canonical
6476        // paste-from-shell-prompt-with-piped-pipeline footgun on
6477        // `:repo` (peer with the 124106f pipe arm on the sibling
6478        // `:caminho` path-fonte axis). An author pastes a shell
6479        // pipeline (`git clone <url> | tee build.log`,
6480        // `git ls-remote <url> | head`) into the `:repo` slot,
6481        // forgetting to trim the `| <consumer>` tail. Until this arm
6482        // landed the value silently passed every prior arm (no
6483        // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
6484        // no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, doesn't start
6485        // with `-` or `:`); RFC 3986 §2 lists the pipe byte in the
6486        // 'unwise' set and the WHATWG URL spec's fragment percent-
6487        // encode set maps `|` → `%7C` on the wire, so the byte rides
6488        // verbatim into the lacre's per-dep BLAKE3 closure but is
6489        // silently rewritten or rejected at libcurl's URL-parser
6490        // layer — two authors whose values differ only in their pipe
6491        // tail (`|tee build.log` vs nothing) resolve to the byte-
6492        // identical upstream `git clone` but lock to two distinct
6493        // lacres, defeating the THEORY.md §V.2 render-determinism
6494        // contract. Peer with the `:caminho` axis's
6495        // `FonteCaminhoShellPipe` arm (124106f) on the sibling path-
6496        // fonte axis, and `is_gateway_api_http_path`'s eleven-byte
6497        // RFC-3986-reserved set on `:entrada :paths`.
6498        let d = dep_with_fonte(DepSource::Git {
6499            repo: "https://github.com/pleme-io/caixa-teia|tee build.log".into(),
6500            tag: Some("v0.1.0".into()),
6501            rev: None,
6502            branch: None,
6503        });
6504        let err = d.validate().unwrap_err();
6505        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6506            panic!("expected FonteRepoShape, got other variant");
6507        };
6508        assert_eq!(nome, "caixa-teia");
6509        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia|tee build.log");
6510        assert!(
6511            reason.contains("must not contain `|`"),
6512            "reason must surface the shell-pipe arm, got {reason:?}"
6513        );
6514        assert!(
6515            reason.contains("pipe") || reason.contains("'unwise'"),
6516            "reason must name the shell-pipe / RFC-3986-unwise rationale, got {reason:?}"
6517        );
6518    }
6519
6520    #[test]
6521    fn fonte_repo_fragment_fires_before_pipe_when_fragment_first() {
6522        // Cascade pin: the fragment-`#` arm and the pipe arm are both
6523        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
6524        // so the byte that appears first in the value's byte order
6525        // wins. A `:repo "https://github.com/p/x#readme|tee"` carries
6526        // both `#` and `|`; the `#` byte appears first, so the
6527        // fragment-`#` arm fires, surfacing the more self-locating
6528        // diagnostic on the byte the author pasted earliest in the
6529        // URL. Mirrors the peer cascade discipline
6530        // `fonte_repo_fragment_fires_before_backtick_when_fragment_first`
6531        // pins on the prior `:repo` byte-class arm.
6532        let d = dep_with_fonte(DepSource::Git {
6533            repo: "https://github.com/pleme-io/caixa-teia#readme|tee".into(),
6534            tag: Some("v0.1.0".into()),
6535            rev: None,
6536            branch: None,
6537        });
6538        let err = d.validate().unwrap_err();
6539        let DepError::FonteRepoShape { reason, .. } = err else {
6540            panic!("expected FonteRepoShape, got other variant");
6541        };
6542        assert!(
6543            reason.contains("must not contain `#`"),
6544            "reason must surface the fragment-`#` arm (fires before pipe when `#` byte \
6545             appears first in value), got {reason:?}"
6546        );
6547    }
6548
6549    #[test]
6550    fn fonte_repo_backtick_fires_before_pipe_when_backtick_first() {
6551        // Cascade pin: the backtick arm and the pipe arm are both per-
6552        // byte arms inside the same `for &b in s.as_bytes()` loop, so
6553        // the byte that appears first in the value's byte order wins.
6554        // A `:repo "https://github.com/p/x/`whoami`|tee"` carries both
6555        // `` ` `` and `|`; the backtick byte appears first, so the
6556        // backtick arm fires, surfacing the more self-locating
6557        // diagnostic on the byte the author pasted earliest in the
6558        // URL. Pins the natural-order cascade so a future reorder of
6559        // the per-byte arms surfaces here.
6560        let d = dep_with_fonte(DepSource::Git {
6561            repo: "https://github.com/pleme-io/caixa-teia/`whoami`|tee".into(),
6562            tag: Some("v0.1.0".into()),
6563            rev: None,
6564            branch: None,
6565        });
6566        let err = d.validate().unwrap_err();
6567        let DepError::FonteRepoShape { reason, .. } = err else {
6568            panic!("expected FonteRepoShape, got other variant");
6569        };
6570        assert!(
6571            reason.contains("must not contain `` ` ``"),
6572            "reason must surface the backtick arm (fires before pipe when `` ` `` byte \
6573             appears first in value), got {reason:?}"
6574        );
6575    }
6576
6577    #[test]
6578    fn validate_rejects_git_fonte_with_repo_carrying_shell_command_separator() {
6579        // The fail-before-pass-after pin for the canonical
6580        // paste-from-shell-prompt-with-sequential-command-tail footgun
6581        // on `:repo` (peer with the 05c358e `;` arm on the sibling
6582        // `:caminho` path-fonte axis). An author pastes a shell
6583        // one-liner that chained a cleanup tail after the URL
6584        // (`git clone <url>; rm -rf build`, `git ls-remote <url>;
6585        // echo done`) into the `:repo` slot, forgetting to trim the
6586        // `; <cmd>` tail. Until this arm landed the value silently
6587        // passed every prior `is_git_repo_url` arm (no whitespace, no
6588        // control chars, no non-ASCII, no `#`, no `?`, no `\`, no
6589        // `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, doesn't start with
6590        // `-` or `:`); RFC 3986 §2 lists `;` in the 'sub-delims' /
6591        // reserved set and the WHATWG URL spec's fragment percent-
6592        // encode set maps `;` → `%3B` on the wire, so the byte rides
6593        // verbatim into the lacre's per-dep BLAKE3 closure but is
6594        // silently rewritten at libcurl's URL-parser layer — two
6595        // authors whose values differ only in their sequential-command
6596        // tail (`; rm -rf build` vs nothing) resolve to the byte-
6597        // identical upstream `git clone` but lock to two distinct
6598        // lacres, defeating the THEORY.md §V.2 render-determinism
6599        // contract. Peer with the `:caminho` axis's
6600        // `FonteCaminhoShellSemicolon` arm (05c358e) on the sibling
6601        // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
6602        // byte RFC-3986-reserved set on `:entrada :paths`.
6603        let d = dep_with_fonte(DepSource::Git {
6604            repo: "https://github.com/pleme-io/caixa-teia; rm -rf build".into(),
6605            tag: Some("v0.1.0".into()),
6606            rev: None,
6607            branch: None,
6608        });
6609        let err = d.validate().unwrap_err();
6610        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6611            panic!("expected FonteRepoShape, got other variant");
6612        };
6613        assert_eq!(nome, "caixa-teia");
6614        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia; rm -rf build");
6615        assert!(
6616            reason.contains("must not contain `;`"),
6617            "reason must surface the shell-command-separator arm, got {reason:?}"
6618        );
6619        assert!(
6620            reason.contains("sequential-command") || reason.contains("'sub-delims'"),
6621            "reason must name the shell-command-separator / RFC-3986-sub-delims \
6622             rationale, got {reason:?}"
6623        );
6624    }
6625
6626    #[test]
6627    fn fonte_repo_fragment_fires_before_semicolon_when_fragment_first() {
6628        // Cascade pin: the fragment-`#` arm and the semicolon arm are
6629        // both per-byte arms inside the same `for &b in s.as_bytes()`
6630        // loop, so the byte that appears first in the value's byte
6631        // order wins. A `:repo "https://github.com/p/x#readme; rm"`
6632        // carries both `#` and `;`; the `#` byte appears first, so the
6633        // fragment-`#` arm fires, surfacing the more self-locating
6634        // diagnostic on the byte the author pasted earliest in the URL.
6635        // Mirrors the peer cascade discipline
6636        // `fonte_repo_fragment_fires_before_pipe_when_fragment_first`
6637        // pins on the prior `:repo` byte-class arm.
6638        let d = dep_with_fonte(DepSource::Git {
6639            repo: "https://github.com/pleme-io/caixa-teia#readme; rm".into(),
6640            tag: Some("v0.1.0".into()),
6641            rev: None,
6642            branch: None,
6643        });
6644        let err = d.validate().unwrap_err();
6645        let DepError::FonteRepoShape { reason, .. } = err else {
6646            panic!("expected FonteRepoShape, got other variant");
6647        };
6648        assert!(
6649            reason.contains("must not contain `#`"),
6650            "reason must surface the fragment-`#` arm (fires before semicolon when `#` \
6651             byte appears first in value), got {reason:?}"
6652        );
6653    }
6654
6655    #[test]
6656    fn fonte_repo_pipe_fires_before_semicolon_when_pipe_first() {
6657        // Cascade pin: the pipe arm and the semicolon arm are both
6658        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
6659        // so the byte that appears first in the value's byte order
6660        // wins. A `:repo "https://github.com/p/x|tee; rm"` carries
6661        // both `|` and `;`; the `|` byte appears first, so the
6662        // pipe arm fires, surfacing the more self-locating diagnostic
6663        // on the byte the author pasted earliest in the URL. Pins the
6664        // natural-order cascade so a future reorder of the per-byte
6665        // arms surfaces here.
6666        let d = dep_with_fonte(DepSource::Git {
6667            repo: "https://github.com/pleme-io/caixa-teia|tee; rm".into(),
6668            tag: Some("v0.1.0".into()),
6669            rev: None,
6670            branch: None,
6671        });
6672        let err = d.validate().unwrap_err();
6673        let DepError::FonteRepoShape { reason, .. } = err else {
6674            panic!("expected FonteRepoShape, got other variant");
6675        };
6676        assert!(
6677            reason.contains("must not contain `|`"),
6678            "reason must surface the pipe arm (fires before semicolon when `|` byte \
6679             appears first in value), got {reason:?}"
6680        );
6681    }
6682
6683    #[test]
6684    fn validate_rejects_git_fonte_with_repo_carrying_shell_background() {
6685        // The fail-before-pass-after pin for the canonical
6686        // paste-from-shell-prompt-with-background-launch-tail footgun
6687        // on `:repo` (peer with the e12e4f3 `&` arm on the sibling
6688        // `:caminho` path-fonte axis). An author pastes a shell one-
6689        // liner that detached the clone into the background
6690        // (`git clone <url> & sleep 1`, `git clone <url> && cd …`)
6691        // into the `:repo` slot, forgetting to trim the `& <cmd>` /
6692        // `&& <cmd>` tail. Until this arm landed the value silently
6693        // passed every prior `is_git_repo_url` arm (no whitespace,
6694        // no control chars, no non-ASCII, no `#`, no `?`, no `\`,
6695        // no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no `;`,
6696        // doesn't start with `-` or `:`); RFC 3986 §2 lists `&` in
6697        // the 'sub-delims' / reserved set and the WHATWG URL spec's
6698        // fragment percent-encode set maps `&` → `%26` on the wire,
6699        // so the byte rides verbatim into the lacre's per-dep
6700        // BLAKE3 closure but is silently rewritten at libcurl's
6701        // URL-parser layer — two authors whose values differ only
6702        // in their background-launch tail (`& sleep 1` vs nothing)
6703        // resolve to the byte-identical upstream `git clone` but
6704        // lock to two distinct lacres, defeating the THEORY.md
6705        // §V.2 render-determinism contract. Peer with the
6706        // `:caminho` axis's `FonteCaminhoShellBackground` arm
6707        // (e12e4f3) on the sibling path-fonte axis, and
6708        // `is_gateway_api_http_path`'s eleven-byte RFC-3986-
6709        // reserved set on `:entrada :paths`.
6710        let d = dep_with_fonte(DepSource::Git {
6711            repo: "https://github.com/pleme-io/caixa-teia&sleep".into(),
6712            tag: Some("v0.1.0".into()),
6713            rev: None,
6714            branch: None,
6715        });
6716        let err = d.validate().unwrap_err();
6717        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6718            panic!("expected FonteRepoShape, got other variant");
6719        };
6720        assert_eq!(nome, "caixa-teia");
6721        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia&sleep");
6722        assert!(
6723            reason.contains("must not contain `&`"),
6724            "reason must surface the shell-background / logical-AND arm, got {reason:?}"
6725        );
6726        assert!(
6727            reason.contains("background-task") || reason.contains("'sub-delims'"),
6728            "reason must name the shell-background / RFC-3986-sub-delims rationale, \
6729             got {reason:?}"
6730        );
6731    }
6732
6733    #[test]
6734    fn validate_rejects_git_fonte_with_repo_carrying_logical_and() {
6735        // The fail-before-pass-after pin for the symmetric `&&`
6736        // logical-AND build-chain paste footgun: an author pastes
6737        // a `git clone <url> && cd <repo>` build-chain one-liner
6738        // and forgets to trim the `&& <cmd>` tail. The `&&` shape
6739        // is the same `&` byte twice in a row; the per-byte arm
6740        // fires on the first `&` it sees. Pinned separately from
6741        // the single-`&` background-launch shape so a future
6742        // diagnostic-surface change that special-cased the
6743        // doubled-byte form surfaces here.
6744        let d = dep_with_fonte(DepSource::Git {
6745            repo: "github:pleme-io/caixa-teia&&echo".into(),
6746            tag: Some("v0.1.0".into()),
6747            rev: None,
6748            branch: None,
6749        });
6750        let err = d.validate().unwrap_err();
6751        let DepError::FonteRepoShape { reason, .. } = err else {
6752            panic!("expected FonteRepoShape, got other variant");
6753        };
6754        assert!(
6755            reason.contains("must not contain `&`"),
6756            "reason must surface the shell-background / logical-AND arm on the doubled-`&&` \
6757             shape too, got {reason:?}"
6758        );
6759    }
6760
6761    #[test]
6762    fn fonte_repo_fragment_fires_before_background_when_fragment_first() {
6763        // Cascade pin: the fragment-`#` arm and the background-`&`
6764        // arm are both per-byte arms inside the same `for &b in
6765        // s.as_bytes()` loop, so the byte that appears first in the
6766        // value's byte order wins. A `:repo
6767        // "https://github.com/p/x#readme & sleep"` carries both `#`
6768        // and `&`; the `#` byte appears first, so the fragment-`#`
6769        // arm fires, surfacing the more self-locating diagnostic on
6770        // the byte the author pasted earliest in the URL. Mirrors
6771        // the peer cascade discipline
6772        // `fonte_repo_fragment_fires_before_semicolon_when_fragment_first`
6773        // on the prior `:repo` byte-class arm.
6774        let d = dep_with_fonte(DepSource::Git {
6775            repo: "https://github.com/pleme-io/caixa-teia#readme&sleep".into(),
6776            tag: Some("v0.1.0".into()),
6777            rev: None,
6778            branch: None,
6779        });
6780        let err = d.validate().unwrap_err();
6781        let DepError::FonteRepoShape { reason, .. } = err else {
6782            panic!("expected FonteRepoShape, got other variant");
6783        };
6784        assert!(
6785            reason.contains("must not contain `#`"),
6786            "reason must surface the fragment-`#` arm (fires before background-`&` when `#` \
6787             byte appears first in value), got {reason:?}"
6788        );
6789    }
6790
6791    #[test]
6792    fn fonte_repo_semicolon_fires_before_background_when_semicolon_first() {
6793        // Cascade pin: the semicolon arm and the background-`&` arm
6794        // are both per-byte arms inside the same `for &b in
6795        // s.as_bytes()` loop, so the byte that appears first in the
6796        // value's byte order wins. A `:repo
6797        // "https://github.com/p/x; rm & sleep"` carries both `;` and
6798        // `&`; the `;` byte appears first, so the semicolon arm
6799        // fires, surfacing the more self-locating diagnostic on the
6800        // byte the author pasted earliest in the URL. Pins the
6801        // natural-order cascade so a future reorder of the per-byte
6802        // arms surfaces here.
6803        let d = dep_with_fonte(DepSource::Git {
6804            repo: "https://github.com/pleme-io/caixa-teia;rm&sleep".into(),
6805            tag: Some("v0.1.0".into()),
6806            rev: None,
6807            branch: None,
6808        });
6809        let err = d.validate().unwrap_err();
6810        let DepError::FonteRepoShape { reason, .. } = err else {
6811            panic!("expected FonteRepoShape, got other variant");
6812        };
6813        assert!(
6814            reason.contains("must not contain `;`"),
6815            "reason must surface the semicolon arm (fires before background-`&` when `;` \
6816             byte appears first in value), got {reason:?}"
6817        );
6818    }
6819
6820    #[test]
6821    fn validate_rejects_git_fonte_with_repo_carrying_shell_variable_expansion() {
6822        // The fail-before-pass-after pin for the canonical
6823        // paste-from-shell-prompt-with-unsubstituted-variable footgun
6824        // on `:repo` (peer with the f4efe9c `$` arm on the sibling
6825        // `:caminho` path-fonte axis). An author pastes a shell one-
6826        // liner that referenced an environment variable
6827        // (`git clone https://github.com/$ORG/x`, `git clone
6828        // github:$USER/repo`) into the `:repo` slot, forgetting to
6829        // substitute the literal value at author time. Until this arm
6830        // landed the value silently passed every prior
6831        // `is_git_repo_url` arm (no whitespace, no control chars, no
6832        // non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no `<`/`>`,
6833        // no `` ` ``, no `|`, no `;`, no `&`, doesn't start with `-`
6834        // or `:`); RFC 3986 §2 lists `$` in the 'sub-delims' /
6835        // reserved set and the WHATWG URL spec's fragment percent-
6836        // encode set maps `$` → `%24` on the wire, so the byte rides
6837        // verbatim into the lacre's per-dep BLAKE3 closure but is
6838        // silently rewritten at libcurl's URL-parser layer — two
6839        // authors whose values differ only in their `$VAR` /
6840        // `${VAR}` / `$(cmd)` expansion tail resolve to the byte-
6841        // identical upstream `git clone` but lock to two distinct
6842        // lacres, defeating the THEORY.md §V.2 render-determinism
6843        // contract. Beyond determinism, the value is a structural
6844        // host-layout leak: two authors with the same `:repo` slot
6845        // but different `$ORG` / `$HOME` / `$WORKSPACE` resolve
6846        // different upstreams. Peer with the `:caminho` axis's
6847        // `FonteCaminhoVarExpansion` arm (f4efe9c) on the sibling
6848        // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
6849        // byte RFC-3986-reserved set on `:entrada :paths`.
6850        let d = dep_with_fonte(DepSource::Git {
6851            repo: "https://github.com/$ORG/caixa-teia".into(),
6852            tag: Some("v0.1.0".into()),
6853            rev: None,
6854            branch: None,
6855        });
6856        let err = d.validate().unwrap_err();
6857        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6858            panic!("expected FonteRepoShape, got other variant");
6859        };
6860        assert_eq!(nome, "caixa-teia");
6861        assert_eq!(repo, "https://github.com/$ORG/caixa-teia");
6862        assert!(
6863            reason.contains("must not contain `$`"),
6864            "reason must surface the shell-variable-expansion arm, got {reason:?}"
6865        );
6866        assert!(
6867            reason.contains("variable-expansion") || reason.contains("'sub-delims'"),
6868            "reason must name the shell-variable-expansion / RFC-3986-sub-delims \
6869             rationale, got {reason:?}"
6870        );
6871    }
6872
6873    #[test]
6874    fn validate_rejects_git_fonte_with_repo_carrying_braced_variable_expansion() {
6875        // The fail-before-pass-after pin for the symmetric POSIX-
6876        // shell braced `${VAR}` expansion paste footgun: an author
6877        // pastes a CI-manifest line `git clone
6878        // https://github.com/${WORKSPACE}/x` (the canonical GitHub
6879        // Actions / GitLab CI / Drone shape) and forgets to
6880        // substitute the literal value. The `${...}` shape is the
6881        // same `$` byte at the leading position of the expansion;
6882        // the per-byte arm fires on the `$`. Pinned separately from
6883        // the bare-`$VAR` shape so a future diagnostic-surface
6884        // change that special-cased the braced form surfaces here.
6885        let d = dep_with_fonte(DepSource::Git {
6886            repo: "https://github.com/${WORKSPACE}/caixa-teia".into(),
6887            tag: Some("v0.1.0".into()),
6888            rev: None,
6889            branch: None,
6890        });
6891        let err = d.validate().unwrap_err();
6892        let DepError::FonteRepoShape { reason, .. } = err else {
6893            panic!("expected FonteRepoShape, got other variant");
6894        };
6895        assert!(
6896            reason.contains("must not contain `$`"),
6897            "reason must surface the shell-variable-expansion arm on the braced `${{...}}` \
6898             shape too, got {reason:?}"
6899        );
6900    }
6901
6902    #[test]
6903    fn fonte_repo_fragment_fires_before_var_expansion_when_fragment_first() {
6904        // Cascade pin: the fragment-`#` arm and the var-expansion-`$`
6905        // arm are both per-byte arms inside the same `for &b in
6906        // s.as_bytes()` loop, so the byte that appears first in the
6907        // value's byte order wins. A `:repo
6908        // "https://github.com/p/x#readme$HOME"` carries both `#` and
6909        // `$`; the `#` byte appears first, so the fragment-`#` arm
6910        // fires, surfacing the more self-locating diagnostic on the
6911        // byte the author pasted earliest in the URL. Mirrors the
6912        // peer cascade discipline
6913        // `fonte_repo_fragment_fires_before_background_when_fragment_first`
6914        // on the prior `:repo` byte-class arm.
6915        let d = dep_with_fonte(DepSource::Git {
6916            repo: "https://github.com/pleme-io/caixa-teia#readme$HOME".into(),
6917            tag: Some("v0.1.0".into()),
6918            rev: None,
6919            branch: None,
6920        });
6921        let err = d.validate().unwrap_err();
6922        let DepError::FonteRepoShape { reason, .. } = err else {
6923            panic!("expected FonteRepoShape, got other variant");
6924        };
6925        assert!(
6926            reason.contains("must not contain `#`"),
6927            "reason must surface the fragment-`#` arm (fires before var-expansion-`$` when \
6928             `#` byte appears first in value), got {reason:?}"
6929        );
6930    }
6931
6932    #[test]
6933    fn fonte_repo_background_fires_before_var_expansion_when_background_first() {
6934        // Cascade pin: the background-`&` arm and the
6935        // var-expansion-`$` arm are both per-byte arms inside the
6936        // same `for &b in s.as_bytes()` loop, so the byte that
6937        // appears first in the value's byte order wins. A `:repo
6938        // "https://github.com/p/x&sleep$HOME"` carries both `&` and
6939        // `$`; the `&` byte appears first, so the background arm
6940        // fires, surfacing the more self-locating diagnostic on the
6941        // byte the author pasted earliest in the URL. Pins the
6942        // natural-order cascade so a future reorder of the per-byte
6943        // arms surfaces here — `$` is the most recent byte-class arm,
6944        // so the cascade-pin sweep extends to cover every immediately
6945        // prior byte arm (`#`, `&`) firing first when ordered ahead
6946        // of `$` in the value.
6947        let d = dep_with_fonte(DepSource::Git {
6948            repo: "https://github.com/pleme-io/caixa-teia&sleep$HOME".into(),
6949            tag: Some("v0.1.0".into()),
6950            rev: None,
6951            branch: None,
6952        });
6953        let err = d.validate().unwrap_err();
6954        let DepError::FonteRepoShape { reason, .. } = err else {
6955            panic!("expected FonteRepoShape, got other variant");
6956        };
6957        assert!(
6958            reason.contains("must not contain `&`"),
6959            "reason must surface the background-`&` arm (fires before var-expansion-`$` when \
6960             `&` byte appears first in value), got {reason:?}"
6961        );
6962    }
6963
6964    #[test]
6965    fn validate_rejects_git_fonte_with_repo_carrying_shell_glob_wildcard() {
6966        // The fail-before-pass-after pin for the canonical
6967        // paste-from-shell-prompt glob footgun on `:repo` (peer with
6968        // the cf9034b `*` / `?` arm on the sibling `:caminho`
6969        // path-fonte axis). An author pastes a shell one-liner that
6970        // referenced a glob expansion (`ls
6971        // github.com/pleme-io/caixa-*`, `git clone
6972        // github:pleme-io/caixa-*`) into the `:repo` slot, forgetting
6973        // to substitute the literal repo name. Until this arm landed
6974        // the `*` byte silently passed every prior `is_git_repo_url`
6975        // arm (no whitespace, no control chars, no non-ASCII, no `#`,
6976        // no `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`,
6977        // no `;`, no `&`, no `$`, doesn't start with `-` or `:`); RFC
6978        // 3986 §2 lists `*` in the 'sub-delims' / reserved set and
6979        // the WHATWG URL spec's special-query percent-encode set maps
6980        // `*` → `%2A` on the wire, so the byte rides verbatim into
6981        // the lacre's per-dep BLAKE3 closure but is silently
6982        // rewritten at libcurl's URL-parser layer — two authors
6983        // whose values differ only in their asterisk presence
6984        // resolve to the byte-identical upstream `git clone` but
6985        // lock to two distinct lacres, defeating the THEORY.md §V.2
6986        // render-determinism contract. Peer with the `:caminho`
6987        // axis's `FonteCaminhoShellGlob` arm (cf9034b) on the
6988        // sibling path-fonte axis, and the `is_git_ref_name`
6989        // refspec-wildcard cascade on the `:fonte :tag` / `:branch`
6990        // axes.
6991        let d = dep_with_fonte(DepSource::Git {
6992            repo: "https://github.com/pleme-io/caixa-*".into(),
6993            tag: Some("v0.1.0".into()),
6994            rev: None,
6995            branch: None,
6996        });
6997        let err = d.validate().unwrap_err();
6998        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6999            panic!("expected FonteRepoShape, got other variant");
7000        };
7001        assert_eq!(nome, "caixa-teia");
7002        assert_eq!(repo, "https://github.com/pleme-io/caixa-*");
7003        assert!(
7004            reason.contains("must not contain `*`"),
7005            "reason must surface the shell-glob arm, got {reason:?}"
7006        );
7007        assert!(
7008            reason.contains("pathname-expansion") || reason.contains("'sub-delims'"),
7009            "reason must name the shell-glob / pathname-expansion / \
7010             RFC-3986-sub-delims rationale, got {reason:?}"
7011        );
7012    }
7013
7014    #[test]
7015    fn validate_rejects_git_fonte_with_repo_carrying_recursive_shell_glob() {
7016        // The fail-before-pass-after pin for the symmetric bash
7017        // `globstar` recursive-glob paste footgun: an author pastes
7018        // a `ls github.com/pleme-io/**/x` (the canonical
7019        // `globstar`-shopt-enabled recursive-listing tail) into the
7020        // `:repo` slot. The `**` shape is two `*` bytes adjacent;
7021        // the per-byte arm fires on the first `*`. Pinned
7022        // separately from the single-`*` shape so a future
7023        // diagnostic-surface change that special-cased the
7024        // double-`*` form surfaces here.
7025        let d = dep_with_fonte(DepSource::Git {
7026            repo: "https://github.com/pleme-io/**/caixa-teia".into(),
7027            tag: Some("v0.1.0".into()),
7028            rev: None,
7029            branch: None,
7030        });
7031        let err = d.validate().unwrap_err();
7032        let DepError::FonteRepoShape { reason, .. } = err else {
7033            panic!("expected FonteRepoShape, got other variant");
7034        };
7035        assert!(
7036            reason.contains("must not contain `*`"),
7037            "reason must surface the shell-glob arm on the `**` recursive-glob shape too, \
7038             got {reason:?}"
7039        );
7040    }
7041
7042    #[test]
7043    fn fonte_repo_fragment_fires_before_glob_when_fragment_first() {
7044        // Cascade pin: the fragment-`#` arm and the glob-`*` arm are
7045        // both per-byte arms inside the same `for &b in s.as_bytes()`
7046        // loop, so the byte that appears first in the value's byte
7047        // order wins. A `:repo
7048        // "https://github.com/p/x#readme*tail"` carries both `#` and
7049        // `*`; the `#` byte appears first, so the fragment-`#` arm
7050        // fires, surfacing the more self-locating diagnostic on the
7051        // byte the author pasted earliest in the URL. Mirrors the
7052        // peer cascade discipline
7053        // `fonte_repo_fragment_fires_before_var_expansion_when_fragment_first`
7054        // on the prior `:repo` byte-class arm.
7055        let d = dep_with_fonte(DepSource::Git {
7056            repo: "https://github.com/pleme-io/caixa-teia#readme*tail".into(),
7057            tag: Some("v0.1.0".into()),
7058            rev: None,
7059            branch: None,
7060        });
7061        let err = d.validate().unwrap_err();
7062        let DepError::FonteRepoShape { reason, .. } = err else {
7063            panic!("expected FonteRepoShape, got other variant");
7064        };
7065        assert!(
7066            reason.contains("must not contain `#`"),
7067            "reason must surface the fragment-`#` arm (fires before glob-`*` when `#` byte \
7068             appears first in value), got {reason:?}"
7069        );
7070    }
7071
7072    #[test]
7073    fn fonte_repo_var_expansion_fires_before_glob_when_var_expansion_first() {
7074        // Cascade pin: the var-expansion-`$` arm and the glob-`*`
7075        // arm are both per-byte arms inside the same `for &b in
7076        // s.as_bytes()` loop, so the byte that appears first in the
7077        // value's byte order wins. A `:repo
7078        // "https://github.com/p/$ORG-*"` carries both `$` and `*`;
7079        // the `$` byte appears first, so the var-expansion arm
7080        // fires, surfacing the more self-locating diagnostic on the
7081        // byte the author pasted earliest in the URL. Pins the
7082        // natural-order cascade so a future reorder of the per-byte
7083        // arms surfaces here — `*` is the most recent byte-class
7084        // arm, so the cascade-pin sweep extends to cover the
7085        // immediately prior `$` byte arm firing first when ordered
7086        // ahead of `*` in the value.
7087        let d = dep_with_fonte(DepSource::Git {
7088            repo: "https://github.com/pleme-io/$ORG-caixa-*".into(),
7089            tag: Some("v0.1.0".into()),
7090            rev: None,
7091            branch: None,
7092        });
7093        let err = d.validate().unwrap_err();
7094        let DepError::FonteRepoShape { reason, .. } = err else {
7095            panic!("expected FonteRepoShape, got other variant");
7096        };
7097        assert!(
7098            reason.contains("must not contain `$`"),
7099            "reason must surface the var-expansion-`$` arm (fires before glob-`*` when `$` \
7100             byte appears first in value), got {reason:?}"
7101        );
7102    }
7103
7104    #[test]
7105    fn validate_rejects_git_fonte_with_repo_carrying_subshell_open_paren() {
7106        // The fail-before-pass-after pin for the canonical paste-from-
7107        // shell-prompt subshell-grouping footgun on `:repo`. An author
7108        // pastes a doc / README snippet carrying a regex-alternation
7109        // grouping shape (`https://github.com/(foo|bar)/repo`) or a
7110        // dynamic-config-substitution wrapper (`$(<cmd>)`) into the
7111        // `:repo` slot, forgetting to substitute one literal org name.
7112        // Until this arm landed the `(` byte silently passed every
7113        // prior `is_git_repo_url` arm (no whitespace, no control
7114        // chars, no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no
7115        // `<`/`>`, no `` ` ``, no `|`, no `;`, no `&`, no `$`, no
7116        // `*`, doesn't start with `-` or `:`); RFC 3986 §2 lists `(`
7117        // / `)` in the 'sub-delims' / reserved set, and the WHATWG
7118        // URL spec's special-query percent-encode set maps `(` →
7119        // `%28` and `)` → `%29` on the wire, so the byte rides
7120        // verbatim into the lacre's per-dep BLAKE3 closure but is
7121        // silently rewritten at libcurl's URL-parser layer —
7122        // defeating the THEORY.md §V.2 render-determinism contract on
7123        // the same axis the prior twelve byte-class arms close.
7124        let d = dep_with_fonte(DepSource::Git {
7125            repo: "https://github.com/(foo|bar)/caixa-teia".into(),
7126            tag: Some("v0.1.0".into()),
7127            rev: None,
7128            branch: None,
7129        });
7130        let err = d.validate().unwrap_err();
7131        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7132            panic!("expected FonteRepoShape, got other variant");
7133        };
7134        assert_eq!(nome, "caixa-teia");
7135        assert_eq!(repo, "https://github.com/(foo|bar)/caixa-teia");
7136        assert!(
7137            reason.contains("must not contain `(`"),
7138            "reason must surface the subshell-open-paren arm, got {reason:?}"
7139        );
7140        assert!(
7141            reason.contains("subshell-grouping") || reason.contains("'sub-delims'"),
7142            "reason must name the shell-subshell-grouping / RFC-3986-sub-delims rationale, \
7143             got {reason:?}"
7144        );
7145    }
7146
7147    #[test]
7148    fn validate_rejects_git_fonte_with_repo_carrying_subshell_close_paren() {
7149        // The symmetric arm pin on the closing `)` byte: an author
7150        // pastes a `$(date)` command-substitution wrapper or a
7151        // regex-alternation `(foo|bar)` tail into the `:repo` slot.
7152        // Pinned separately from the opening `(` shape so a future
7153        // diagnostic-surface change that only checked one boundary
7154        // surfaces here. The `(` byte appears earlier in the
7155        // canonical regex / subshell wrapper so the per-byte loop
7156        // fires on `(` first; this test exercises a `:repo` value
7157        // carrying only the closing `)` byte (no opening paren) so
7158        // the `)` arm fires directly — pinning the byte-class arm
7159        // independent of order.
7160        let d = dep_with_fonte(DepSource::Git {
7161            repo: "github:pleme-io/caixa-teia)tail".into(),
7162            tag: Some("v0.1.0".into()),
7163            rev: None,
7164            branch: None,
7165        });
7166        let err = d.validate().unwrap_err();
7167        let DepError::FonteRepoShape { reason, .. } = err else {
7168            panic!("expected FonteRepoShape, got other variant");
7169        };
7170        assert!(
7171            reason.contains("must not contain `)`"),
7172            "reason must surface the subshell-close-paren arm on the bare `)` shape, \
7173             got {reason:?}"
7174        );
7175    }
7176
7177    #[test]
7178    fn fonte_repo_fragment_fires_before_subshell_when_fragment_first() {
7179        // Cascade pin: the fragment-`#` arm and the subshell-`(` arm
7180        // are both per-byte arms inside the same `for &b in
7181        // s.as_bytes()` loop, so the byte that appears first in the
7182        // value's byte order wins. A `:repo
7183        // "https://github.com/p/x#readme(tail)"` carries both `#` and
7184        // `(`; the `#` byte appears first, so the fragment-`#` arm
7185        // fires, surfacing the more self-locating diagnostic on the
7186        // byte the author pasted earliest in the URL. Mirrors the
7187        // peer cascade discipline
7188        // `fonte_repo_fragment_fires_before_glob_when_fragment_first`
7189        // on the prior `:repo` byte-class arm.
7190        let d = dep_with_fonte(DepSource::Git {
7191            repo: "https://github.com/pleme-io/caixa-teia#readme(tail)".into(),
7192            tag: Some("v0.1.0".into()),
7193            rev: None,
7194            branch: None,
7195        });
7196        let err = d.validate().unwrap_err();
7197        let DepError::FonteRepoShape { reason, .. } = err else {
7198            panic!("expected FonteRepoShape, got other variant");
7199        };
7200        assert!(
7201            reason.contains("must not contain `#`"),
7202            "reason must surface the fragment-`#` arm (fires before subshell-`(` when `#` \
7203             byte appears first in value), got {reason:?}"
7204        );
7205    }
7206
7207    #[test]
7208    fn fonte_repo_glob_fires_before_subshell_when_glob_first() {
7209        // Cascade pin: the glob-`*` arm (the immediate-predecessor
7210        // byte-class arm, 3902a9a) and the subshell-`(` arm are both
7211        // per-byte arms inside the same `for &b in s.as_bytes()`
7212        // loop, so the byte that appears first in the value's byte
7213        // order wins. A `:repo
7214        // "https://github.com/p/x-*-(date)"` carries both `*` and
7215        // `(`; the `*` byte appears first, so the glob arm fires,
7216        // surfacing the more self-locating diagnostic on the byte
7217        // the author pasted earliest in the URL. Pins the natural-
7218        // order cascade so a future reorder of the per-byte arms
7219        // surfaces here — `(` is the most recent byte-class arm,
7220        // so the cascade-pin sweep extends to cover the immediately
7221        // prior `*` byte arm firing first when ordered ahead of `(`
7222        // in the value.
7223        let d = dep_with_fonte(DepSource::Git {
7224            repo: "https://github.com/pleme-io/caixa-teia-*-(date)".into(),
7225            tag: Some("v0.1.0".into()),
7226            rev: None,
7227            branch: None,
7228        });
7229        let err = d.validate().unwrap_err();
7230        let DepError::FonteRepoShape { reason, .. } = err else {
7231            panic!("expected FonteRepoShape, got other variant");
7232        };
7233        assert!(
7234            reason.contains("must not contain `*`"),
7235            "reason must surface the glob-`*` arm (fires before subshell-`(` when `*` byte \
7236             appears first in value), got {reason:?}"
7237        );
7238    }
7239
7240    #[test]
7241    fn validate_rejects_git_fonte_with_repo_carrying_shell_double_quote() {
7242        // The fail-before-pass-after pin for the canonical paste-from-
7243        // doc-shell-quoting footgun on `:repo`. An author copies a
7244        // README quick-start snippet (`$ git clone "https://github.com/
7245        // foo/bar"`) and keeps the surrounding double-quote bytes when
7246        // pasting into the `:repo` slot — the doc wraps the URL in
7247        // double quotes so the shell doesn't re-lex metachars inside,
7248        // but the typed slot is itself a byte-level string parser, not
7249        // a shell context, so the quote bytes ride into the value
7250        // verbatim. Until this arm landed the `"` byte silently passed
7251        // every prior `is_git_repo_url` arm (no whitespace, no control
7252        // chars, no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no
7253        // `<`/`>`, no `` ` ``, no `|`, no `;`, no `&`, no `$`, no `*`,
7254        // no `(`/`)`, doesn't start with `-` or `:`); RFC 3986 §2 lists
7255        // `"` in the strict four-byte 'delims' subset (with `<`, `>`,
7256        // `` ` ``) every URL parser is required to refuse or percent-
7257        // encode, and the WHATWG URL spec's 'C0 control percent-encode
7258        // set' maps `"` → `%22` on the wire, so the byte rides verbatim
7259        // into the lacre's per-dep BLAKE3 closure but is silently
7260        // rewritten at libcurl's URL-parser layer, defeating the
7261        // THEORY.md §V.2 render-determinism contract.
7262        let d = dep_with_fonte(DepSource::Git {
7263            repo: "\"https://github.com/pleme-io/caixa-teia\"".into(),
7264            tag: Some("v0.1.0".into()),
7265            rev: None,
7266            branch: None,
7267        });
7268        let err = d.validate().unwrap_err();
7269        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7270            panic!("expected FonteRepoShape, got other variant");
7271        };
7272        assert_eq!(nome, "caixa-teia");
7273        assert_eq!(repo, "\"https://github.com/pleme-io/caixa-teia\"");
7274        assert!(
7275            reason.contains("must not contain `\"`"),
7276            "reason must surface the shell-double-quote arm, got {reason:?}"
7277        );
7278        assert!(
7279            reason.contains("double-quote") || reason.contains("'delims'"),
7280            "reason must name the shell-double-quote / RFC-3986-delims rationale, \
7281             got {reason:?}"
7282        );
7283    }
7284
7285    #[test]
7286    fn validate_rejects_git_fonte_with_repo_carrying_stray_trailing_double_quote() {
7287        // The symmetric stray-quote tail pin: an author pastes only a
7288        // closing `"` from a shell-history line like `git clone
7289        // "https://github.com/foo/bar" && cd …` (the trim went too
7290        // far in one direction but not the other) into the `:repo`
7291        // slot. Pinned separately from the wrapped-quote shape so a
7292        // future diagnostic-surface change that only checked one
7293        // boundary (only leading, only trailing, only paired) surfaces
7294        // here — the per-byte arm fires anywhere `"` appears.
7295        let d = dep_with_fonte(DepSource::Git {
7296            repo: "github:pleme-io/caixa-teia\"".into(),
7297            tag: Some("v0.1.0".into()),
7298            rev: None,
7299            branch: None,
7300        });
7301        let err = d.validate().unwrap_err();
7302        let DepError::FonteRepoShape { reason, .. } = err else {
7303            panic!("expected FonteRepoShape, got other variant");
7304        };
7305        assert!(
7306            reason.contains("must not contain `\"`"),
7307            "reason must surface the shell-double-quote arm on the trailing-`\"` shape, \
7308             got {reason:?}"
7309        );
7310    }
7311
7312    #[test]
7313    fn fonte_repo_fragment_fires_before_double_quote_when_fragment_first() {
7314        // Cascade pin: the fragment-`#` arm and the double-quote arm
7315        // are both per-byte arms inside the same `for &b in
7316        // s.as_bytes()` loop, so the byte that appears first in the
7317        // value's byte order wins. A `:repo
7318        // "https://github.com/p/x#readme\"tail"` carries both `#` and
7319        // `"`; the `#` byte appears first, so the fragment-`#` arm
7320        // fires, surfacing the more self-locating diagnostic on the
7321        // byte the author pasted earliest in the URL.
7322        let d = dep_with_fonte(DepSource::Git {
7323            repo: "https://github.com/pleme-io/caixa-teia#readme\"tail".into(),
7324            tag: Some("v0.1.0".into()),
7325            rev: None,
7326            branch: None,
7327        });
7328        let err = d.validate().unwrap_err();
7329        let DepError::FonteRepoShape { reason, .. } = err else {
7330            panic!("expected FonteRepoShape, got other variant");
7331        };
7332        assert!(
7333            reason.contains("must not contain `#`"),
7334            "reason must surface the fragment-`#` arm (fires before double-quote when `#` \
7335             byte appears first in value), got {reason:?}"
7336        );
7337    }
7338
7339    #[test]
7340    fn fonte_repo_subshell_fires_before_double_quote_when_subshell_first() {
7341        // Cascade pin: the subshell-`(` arm (the immediate-predecessor
7342        // byte-class arm, 3b99147) and the double-quote arm are both
7343        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
7344        // so the byte that appears first in the value's byte order
7345        // wins. A `:repo "github:p/x(date)\"tail"` carries both `(`
7346        // and `"`; the `(` byte appears first, so the subshell arm
7347        // fires, surfacing the more self-locating diagnostic on the
7348        // byte the author pasted earliest in the URL. Pins the natural-
7349        // order cascade so a future reorder of the per-byte arms
7350        // surfaces here — `"` is the most recent byte-class arm, so
7351        // the cascade-pin sweep extends to cover the immediately prior
7352        // `(` byte arm firing first when ordered ahead of `"` in the
7353        // value.
7354        let d = dep_with_fonte(DepSource::Git {
7355            repo: "github:pleme-io/caixa-teia(date)\"tail".into(),
7356            tag: Some("v0.1.0".into()),
7357            rev: None,
7358            branch: None,
7359        });
7360        let err = d.validate().unwrap_err();
7361        let DepError::FonteRepoShape { reason, .. } = err else {
7362            panic!("expected FonteRepoShape, got other variant");
7363        };
7364        assert!(
7365            reason.contains("must not contain `(`"),
7366            "reason must surface the subshell-`(` arm (fires before double-quote when `(` \
7367             byte appears first in value), got {reason:?}"
7368        );
7369    }
7370
7371    #[test]
7372    fn validate_rejects_git_fonte_with_repo_carrying_shell_single_quote() {
7373        // The fail-before-pass-after pin for the canonical paste-from-
7374        // doc-strong-quoting footgun on `:repo`. An author copies a
7375        // security-conscious README quick-start snippet (`$ git clone
7376        // 'https://github.com/foo/bar'`) and keeps the surrounding
7377        // single-quote bytes when pasting into the `:repo` slot — the
7378        // doc strong-quotes the URL so the shell suppresses every form
7379        // of expansion on the bytes inside (no `$`, no backtick, no
7380        // glob, no word-splitting), but the typed slot is itself a
7381        // byte-level string parser, not a shell context, so the quote
7382        // bytes ride into the value verbatim. Until this arm landed the
7383        // `'` byte silently passed every prior `is_git_repo_url` arm
7384        // (no whitespace, no control chars, no non-ASCII, no `#`, no
7385        // `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no
7386        // `;`, no `&`, no `$`, no `*`, no `(`/`)`, no `"`, doesn't start
7387        // with `-` or `:`); RFC 3986 §2.2 lists `'` in the 'sub-delims'
7388        // set, peer with the `\"` 'delims' double-quote arm and the
7389        // partner ASCII shell-string-delimiter byte every byte-level
7390        // string parser sharing a value-shape with a shell argument
7391        // must refuse on a URL-shaped slot.
7392        let d = dep_with_fonte(DepSource::Git {
7393            repo: "'https://github.com/pleme-io/caixa-teia'".into(),
7394            tag: Some("v0.1.0".into()),
7395            rev: None,
7396            branch: None,
7397        });
7398        let err = d.validate().unwrap_err();
7399        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7400            panic!("expected FonteRepoShape, got other variant");
7401        };
7402        assert_eq!(nome, "caixa-teia");
7403        assert_eq!(repo, "'https://github.com/pleme-io/caixa-teia'");
7404        assert!(
7405            reason.contains("must not contain `'`"),
7406            "reason must surface the shell-single-quote arm, got {reason:?}"
7407        );
7408        assert!(
7409            reason.contains("single-quote") || reason.contains("strong-quote"),
7410            "reason must name the shell-single-quote / strong-quote rationale, \
7411             got {reason:?}"
7412        );
7413    }
7414
7415    #[test]
7416    fn validate_rejects_git_fonte_with_repo_carrying_english_apostrophe() {
7417        // The symmetric English-typography pin: an author writes
7418        // `:repo "github:p/repo's-fork"` (the possessive-form paste-
7419        // from-prose idiom every README / commit-message / chat-thread
7420        // reference to a repo carries) expecting the substrate to
7421        // coerce it to a kebab-case slug — but the byte rides into the
7422        // lacre verbatim. Pinned separately from the wrapped-quote
7423        // shape so a future diagnostic-surface change that only checked
7424        // the boundary positions (only leading, only trailing, only
7425        // paired) surfaces here — the per-byte arm fires anywhere `'`
7426        // appears in the value.
7427        let d = dep_with_fonte(DepSource::Git {
7428            repo: "github:pleme-io/repo's-fork".into(),
7429            tag: Some("v0.1.0".into()),
7430            rev: None,
7431            branch: None,
7432        });
7433        let err = d.validate().unwrap_err();
7434        let DepError::FonteRepoShape { reason, .. } = err else {
7435            panic!("expected FonteRepoShape, got other variant");
7436        };
7437        assert!(
7438            reason.contains("must not contain `'`"),
7439            "reason must surface the shell-single-quote arm on the mid-string \
7440             apostrophe shape, got {reason:?}"
7441        );
7442    }
7443
7444    #[test]
7445    fn fonte_repo_fragment_fires_before_single_quote_when_fragment_first() {
7446        // Cascade pin: the fragment-`#` arm and the single-quote arm
7447        // are both per-byte arms inside the same `for &b in
7448        // s.as_bytes()` loop, so the byte that appears first in the
7449        // value's byte order wins. A `:repo
7450        // "https://github.com/p/x#readme'tail"` carries both `#` and
7451        // `'`; the `#` byte appears first, so the fragment-`#` arm
7452        // fires, surfacing the more self-locating diagnostic on the
7453        // byte the author pasted earliest in the URL.
7454        let d = dep_with_fonte(DepSource::Git {
7455            repo: "https://github.com/pleme-io/caixa-teia#readme'tail".into(),
7456            tag: Some("v0.1.0".into()),
7457            rev: None,
7458            branch: None,
7459        });
7460        let err = d.validate().unwrap_err();
7461        let DepError::FonteRepoShape { reason, .. } = err else {
7462            panic!("expected FonteRepoShape, got other variant");
7463        };
7464        assert!(
7465            reason.contains("must not contain `#`"),
7466            "reason must surface the fragment-`#` arm (fires before single-quote when `#` \
7467             byte appears first in value), got {reason:?}"
7468        );
7469    }
7470
7471    #[test]
7472    fn fonte_repo_double_quote_fires_before_single_quote_when_double_quote_first() {
7473        // Cascade pin: the double-quote-`"` arm (the immediate-predecessor
7474        // byte-class arm, 4267d8b) and the single-quote arm are both
7475        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
7476        // so the byte that appears first in the value's byte order
7477        // wins. A `:repo "github:p/x\"mid'tail"` carries both `"` and
7478        // `'`; the `"` byte appears first, so the double-quote arm
7479        // fires, surfacing the more self-locating diagnostic on the
7480        // byte the author pasted earliest in the URL. Pins the natural-
7481        // order cascade so a future reorder of the per-byte arms
7482        // surfaces here — `'` is the most recent byte-class arm, so
7483        // the cascade-pin sweep extends to cover the immediately prior
7484        // `"` byte arm firing first when ordered ahead of `'` in the
7485        // value.
7486        let d = dep_with_fonte(DepSource::Git {
7487            repo: "github:pleme-io/caixa-teia\"mid'tail".into(),
7488            tag: Some("v0.1.0".into()),
7489            rev: None,
7490            branch: None,
7491        });
7492        let err = d.validate().unwrap_err();
7493        let DepError::FonteRepoShape { reason, .. } = err else {
7494            panic!("expected FonteRepoShape, got other variant");
7495        };
7496        assert!(
7497            reason.contains("must not contain `\"`"),
7498            "reason must surface the double-quote arm (fires before single-quote when `\"` \
7499             byte appears first in value), got {reason:?}"
7500        );
7501    }
7502
7503    #[test]
7504    fn validate_rejects_git_fonte_with_repo_carrying_shell_history_expansion() {
7505        // The fail-before-pass-after pin for the canonical paste-from-
7506        // shell-history footgun on `:repo`. An author copies a `git
7507        // clone <url>!sudo make install` one-liner from a README's
7508        // quick-start snippet, intending the trailing `!sudo` as a
7509        // shell-history-expansion reference but the typed slot is itself
7510        // a byte-level string parser, not a shell context, so the byte
7511        // rides into the value verbatim. Until this arm landed the `!`
7512        // byte silently passed every prior `is_git_repo_url` arm (no
7513        // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
7514        // no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no `;`,
7515        // no `&`, no `$`, no `*`, no `(`/`)`, no `"`, no `'`, doesn't
7516        // start with `-` or `:`); bash with the default `histexpand`
7517        // mode rewrites `!command` to the most recent history entry
7518        // beginning with `command`, the canonical RCE-class injection
7519        // vector when the byte rides into a shell argument.
7520        let d = dep_with_fonte(DepSource::Git {
7521            repo: "https://github.com/pleme-io/caixa-teia!sudo".into(),
7522            tag: Some("v0.1.0".into()),
7523            rev: None,
7524            branch: None,
7525        });
7526        let err = d.validate().unwrap_err();
7527        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7528            panic!("expected FonteRepoShape, got other variant");
7529        };
7530        assert_eq!(nome, "caixa-teia");
7531        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia!sudo");
7532        assert!(
7533            reason.contains("must not contain `!`"),
7534            "reason must surface the shell-history-expansion arm, got {reason:?}"
7535        );
7536        assert!(
7537            reason.contains("history-expansion") || reason.contains("bang"),
7538            "reason must name the shell-history-expansion / bang rationale, got {reason:?}"
7539        );
7540    }
7541
7542    #[test]
7543    fn validate_rejects_git_fonte_with_repo_carrying_double_bang_history_reference() {
7544        // The symmetric `!!` repeat-prior-command pin: an author paste-
7545        // trims a `git clone <url>` retry idiom from shell history that
7546        // expands to the previous command via `!!`. Pinned separately
7547        // from the wrapped `!command` shape so a future diagnostic-
7548        // surface change that only checked the leading or paired-bang
7549        // position surfaces here — the per-byte arm fires anywhere `!`
7550        // appears in the value.
7551        let d = dep_with_fonte(DepSource::Git {
7552            repo: "github:pleme-io/caixa-teia!!".into(),
7553            tag: Some("v0.1.0".into()),
7554            rev: None,
7555            branch: None,
7556        });
7557        let err = d.validate().unwrap_err();
7558        let DepError::FonteRepoShape { reason, .. } = err else {
7559            panic!("expected FonteRepoShape, got other variant");
7560        };
7561        assert!(
7562            reason.contains("must not contain `!`"),
7563            "reason must surface the shell-history-expansion arm on the trailing-`!!` shape, \
7564             got {reason:?}"
7565        );
7566    }
7567
7568    #[test]
7569    fn fonte_repo_fragment_fires_before_bang_when_fragment_first() {
7570        // Cascade pin: the fragment-`#` arm and the bang arm are both
7571        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
7572        // so the byte that appears first in the value's byte order
7573        // wins. A `:repo "https://github.com/p/x#readme!tail"` carries
7574        // both `#` and `!`; the `#` byte appears first, so the
7575        // fragment-`#` arm fires, surfacing the more self-locating
7576        // diagnostic on the byte the author pasted earliest in the URL.
7577        let d = dep_with_fonte(DepSource::Git {
7578            repo: "https://github.com/pleme-io/caixa-teia#readme!tail".into(),
7579            tag: Some("v0.1.0".into()),
7580            rev: None,
7581            branch: None,
7582        });
7583        let err = d.validate().unwrap_err();
7584        let DepError::FonteRepoShape { reason, .. } = err else {
7585            panic!("expected FonteRepoShape, got other variant");
7586        };
7587        assert!(
7588            reason.contains("must not contain `#`"),
7589            "reason must surface the fragment-`#` arm (fires before bang when `#` byte \
7590             appears first in value), got {reason:?}"
7591        );
7592    }
7593
7594    #[test]
7595    fn fonte_repo_single_quote_fires_before_bang_when_single_quote_first() {
7596        // Cascade pin: the single-quote-`'` arm (the immediate-predecessor
7597        // byte-class arm, e7a109f) and the bang arm are both per-byte
7598        // arms inside the same `for &b in s.as_bytes()` loop, so the
7599        // byte that appears first in the value's byte order wins. A
7600        // `:repo "github:p/x'mid!tail"` carries both `'` and `!`; the
7601        // `'` byte appears first, so the single-quote arm fires,
7602        // surfacing the more self-locating diagnostic on the byte the
7603        // author pasted earliest in the URL. Pins the natural-order
7604        // cascade so a future reorder of the per-byte arms surfaces
7605        // here — `!` is the most recent byte-class arm, so the
7606        // cascade-pin sweep extends to cover the immediately prior `'`
7607        // byte arm firing first when ordered ahead of `!` in the value.
7608        let d = dep_with_fonte(DepSource::Git {
7609            repo: "github:pleme-io/caixa-teia'mid!tail".into(),
7610            tag: Some("v0.1.0".into()),
7611            rev: None,
7612            branch: None,
7613        });
7614        let err = d.validate().unwrap_err();
7615        let DepError::FonteRepoShape { reason, .. } = err else {
7616            panic!("expected FonteRepoShape, got other variant");
7617        };
7618        assert!(
7619            reason.contains("must not contain `'`"),
7620            "reason must surface the single-quote arm (fires before bang when `'` byte \
7621             appears first in value), got {reason:?}"
7622        );
7623    }
7624
7625    #[test]
7626    fn validate_rejects_git_fonte_with_repo_carrying_list_separator_comma() {
7627        // The fail-before-pass-after pin for the canonical
7628        // list-separator-belongs-to-list-grammar footgun on `:repo`.
7629        // An author copies a `git clone <a>, <b>, <c>` paste-from-CSV
7630        // one-liner from a multi-repo bootstrap doc, intending the
7631        // comma to separate multiple repo entries but the typed
7632        // `:repo` slot names *one* repo (the list-separator belongs
7633        // to the `:deps` list grammar, not to the value). Until this
7634        // arm landed the `,` byte silently passed every prior
7635        // `is_git_repo_url` arm (no whitespace, no control chars, no
7636        // non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no `<`/`>`,
7637        // no `` ` ``, no `|`, no `;`, no `&`, no `$`, no `*`, no
7638        // `(`/`)`, no `"`, no `'`, no `!`, doesn't start with `-` or
7639        // `:`); the byte rode into the lacre's per-dep content-
7640        // address and the resolver's `git clone <repo>` subprocess
7641        // invocation, where no host's repo registry resolved the
7642        // comma-bearing slug.
7643        let d = dep_with_fonte(DepSource::Git {
7644            repo: "github:pleme-io/caixa-teia,github:pleme-io/caixa-feira".into(),
7645            tag: Some("v0.1.0".into()),
7646            rev: None,
7647            branch: None,
7648        });
7649        let err = d.validate().unwrap_err();
7650        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7651            panic!("expected FonteRepoShape, got other variant");
7652        };
7653        assert_eq!(nome, "caixa-teia");
7654        assert_eq!(
7655            repo,
7656            "github:pleme-io/caixa-teia,github:pleme-io/caixa-feira"
7657        );
7658        assert!(
7659            reason.contains("must not contain `,`"),
7660            "reason must surface the list-separator-comma arm, got {reason:?}"
7661        );
7662        assert!(
7663            reason.contains("list-separator") || reason.contains("sub-delims"),
7664            "reason must name the list-separator / RFC-3986-sub-delims rationale, \
7665             got {reason:?}"
7666        );
7667    }
7668
7669    #[test]
7670    fn validate_rejects_git_fonte_with_repo_carrying_trailing_comma() {
7671        // The symmetric trailing-`,` paste-from-prose pin: an author
7672        // writes `:repo "github:pleme-io/caixa-feira,"` (the trailing
7673        // comma every README-prose list-of-projects sentence carries,
7674        // mistakenly retained when the slug is pasted mid-sentence)
7675        // expecting the substrate to coerce it to a kebab-case slug.
7676        // Pinned separately from the wrapped mid-token shape so a
7677        // future diagnostic-surface change that only checked the
7678        // leading or paired-comma position surfaces here — the
7679        // per-byte arm fires anywhere `,` appears in the value.
7680        let d = dep_with_fonte(DepSource::Git {
7681            repo: "github:pleme-io/caixa-feira,".into(),
7682            tag: Some("v0.1.0".into()),
7683            rev: None,
7684            branch: None,
7685        });
7686        let err = d.validate().unwrap_err();
7687        let DepError::FonteRepoShape { reason, .. } = err else {
7688            panic!("expected FonteRepoShape, got other variant");
7689        };
7690        assert!(
7691            reason.contains("must not contain `,`"),
7692            "reason must surface the list-separator-comma arm on the trailing-`,` shape, \
7693             got {reason:?}"
7694        );
7695    }
7696
7697    #[test]
7698    fn fonte_repo_fragment_fires_before_comma_when_fragment_first() {
7699        // Cascade pin: the fragment-`#` arm and the comma arm are
7700        // both per-byte arms inside the same `for &b in s.as_bytes()`
7701        // loop, so the byte that appears first in the value's byte
7702        // order wins. A `:repo "https://github.com/p/x#readme,tail"`
7703        // carries both `#` and `,`; the `#` byte appears first, so
7704        // the fragment-`#` arm fires, surfacing the more self-
7705        // locating diagnostic on the byte the author pasted earliest
7706        // in the URL.
7707        let d = dep_with_fonte(DepSource::Git {
7708            repo: "https://github.com/pleme-io/caixa-teia#readme,tail".into(),
7709            tag: Some("v0.1.0".into()),
7710            rev: None,
7711            branch: None,
7712        });
7713        let err = d.validate().unwrap_err();
7714        let DepError::FonteRepoShape { reason, .. } = err else {
7715            panic!("expected FonteRepoShape, got other variant");
7716        };
7717        assert!(
7718            reason.contains("must not contain `#`"),
7719            "reason must surface the fragment-`#` arm (fires before comma when `#` byte \
7720             appears first in value), got {reason:?}"
7721        );
7722    }
7723
7724    #[test]
7725    fn fonte_repo_bang_fires_before_comma_when_bang_first() {
7726        // Cascade pin: the bang-`!` arm (the immediate-predecessor
7727        // byte-class arm, 7d53c68) and the comma arm are both
7728        // per-byte arms inside the same `for &b in s.as_bytes()`
7729        // loop, so the byte that appears first in the value's byte
7730        // order wins. A `:repo "github:p/x!mid,tail"` carries both
7731        // `!` and `,`; the `!` byte appears first, so the bang arm
7732        // fires, surfacing the more self-locating diagnostic on the
7733        // byte the author pasted earliest in the URL. Pins the
7734        // natural-order cascade so a future reorder of the per-byte
7735        // arms surfaces here — `,` is the most recent byte-class
7736        // arm, so the cascade-pin sweep extends to cover the
7737        // immediately prior `!` byte arm firing first when ordered
7738        // ahead of `,` in the value.
7739        let d = dep_with_fonte(DepSource::Git {
7740            repo: "github:pleme-io/caixa-teia!mid,tail".into(),
7741            tag: Some("v0.1.0".into()),
7742            rev: None,
7743            branch: None,
7744        });
7745        let err = d.validate().unwrap_err();
7746        let DepError::FonteRepoShape { reason, .. } = err else {
7747            panic!("expected FonteRepoShape, got other variant");
7748        };
7749        assert!(
7750            reason.contains("must not contain `!`"),
7751            "reason must surface the bang arm (fires before comma when `!` byte \
7752             appears first in value), got {reason:?}"
7753        );
7754    }
7755
7756    #[test]
7757    fn validate_rejects_git_fonte_with_repo_carrying_shell_env_var_assignment() {
7758        // The fail-before-pass-after pin for the canonical
7759        // shell-env-var-assignment-belongs-to-shell-grammar footgun
7760        // on `:repo`. An author copies
7761        // `GIT_TERMINAL_PROMPT=0 git clone <url>` (or
7762        // `GIT_SSL_NO_VERIFY=1 git clone <url>`, `HTTPS_PROXY=…
7763        // git clone <url>`, etc. — the canonical
7764        // git-troubleshooting README idiom for a one-shot env-var
7765        // scoped to the `git clone` invocation) from a shell-prompt
7766        // one-liner, intending the `KEY=VALUE` prefix as a shell-
7767        // grammar env-var assignment but the typed `:repo` slot is
7768        // a value parser, not a shell context, so the bytes ride
7769        // into the value verbatim. Until this arm landed the `=`
7770        // byte silently passed every prior `is_git_repo_url` arm
7771        // (no whitespace, no control chars, no non-ASCII, no `#`,
7772        // no `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no
7773        // `|`, no `;`, no `&`, no `$`, no `*`, no `(`/`)`, no `"`,
7774        // no `'`, no `!`, no `,`, doesn't start with `-` or `:`);
7775        // the byte rode into the lacre's per-dep content-address
7776        // and the resolver's `git clone <repo>` subprocess
7777        // invocation, where the upstream host's git porcelain
7778        // fetched a literal `GIT_TERMINAL_PROMPT=0 https://…`-shaped
7779        // path that no host's repo registry resolves.
7780        let d = dep_with_fonte(DepSource::Git {
7781            repo: "GIT_TERMINAL_PROMPT=0 https://github.com/pleme-io/caixa-teia".into(),
7782            tag: Some("v0.1.0".into()),
7783            rev: None,
7784            branch: None,
7785        });
7786        let err = d.validate().unwrap_err();
7787        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7788            panic!("expected FonteRepoShape, got other variant");
7789        };
7790        assert_eq!(nome, "caixa-teia");
7791        assert_eq!(
7792            repo,
7793            "GIT_TERMINAL_PROMPT=0 https://github.com/pleme-io/caixa-teia"
7794        );
7795        // The `=` byte at position 19 of `GIT_TERMINAL_PROMPT=0 …`
7796        // appears before the ` ` byte at position 21, so the `=`
7797        // arm fires (not the whitespace arm) — both arms guard
7798        // the slot, but the per-byte for-loop scans left-to-right
7799        // and the first matching byte wins.
7800        assert!(
7801            reason.contains("must not contain `=`"),
7802            "reason must surface the equals-`=` arm on the env-var-assignment \
7803             paste shape, got {reason:?}"
7804        );
7805        assert!(
7806            reason.contains("env-var-assignment") || reason.contains("KEY=VALUE"),
7807            "reason must name the shell-env-var-assignment rationale, got {reason:?}"
7808        );
7809    }
7810
7811    #[test]
7812    fn validate_rejects_git_fonte_with_repo_carrying_gitconfig_url_key_prefix() {
7813        // The symmetric paste-from-gitconfig pin: an author copies
7814        // `url=https://github.com/p/x` from `git config --get-all
7815        // remote.origin.url` output, a `.gitconfig` `[remote
7816        // "origin"] url = https://…` ini-stanza paste, or a
7817        // `git config remote.origin.url <value>` doc snippet,
7818        // intending the `url=` prefix as the ini-key but the typed
7819        // `:repo` slot is a URL value parser, not a gitconfig
7820        // grammar. With no leading whitespace and no earlier-arm
7821        // bytes in the value, the `=` arm itself fires (rather
7822        // than cascading to the whitespace arm as in the env-var
7823        // paste shape). Pinned separately so a future diagnostic-
7824        // surface change that only checked the whitespace-leading
7825        // shape surfaces here — the per-byte arm fires anywhere
7826        // `=` appears in the value.
7827        let d = dep_with_fonte(DepSource::Git {
7828            repo: "url=https://github.com/pleme-io/caixa-feira".into(),
7829            tag: Some("v0.1.0".into()),
7830            rev: None,
7831            branch: None,
7832        });
7833        let err = d.validate().unwrap_err();
7834        let DepError::FonteRepoShape { reason, .. } = err else {
7835            panic!("expected FonteRepoShape, got other variant");
7836        };
7837        assert!(
7838            reason.contains("must not contain `=`"),
7839            "reason must surface the equals-`=` arm on the `url=…` gitconfig \
7840             paste shape, got {reason:?}"
7841        );
7842        assert!(
7843            reason.contains("key-value-separator") || reason.contains("sub-delims"),
7844            "reason must name the key-value-separator / RFC-3986-sub-delims \
7845             rationale, got {reason:?}"
7846        );
7847    }
7848
7849    #[test]
7850    fn fonte_repo_fragment_fires_before_equals_when_fragment_first() {
7851        // Cascade pin: the fragment-`#` arm and the `=` arm are
7852        // both per-byte arms inside the same `for &b in s.as_bytes()`
7853        // loop, so the byte that appears first in the value's byte
7854        // order wins. A `:repo "https://github.com/p/x#readme=tail"`
7855        // carries both `#` and `=`; the `#` byte appears first, so
7856        // the fragment-`#` arm fires, surfacing the more self-
7857        // locating diagnostic on the byte the author pasted earliest
7858        // in the URL.
7859        let d = dep_with_fonte(DepSource::Git {
7860            repo: "https://github.com/pleme-io/caixa-teia#readme=tail".into(),
7861            tag: Some("v0.1.0".into()),
7862            rev: None,
7863            branch: None,
7864        });
7865        let err = d.validate().unwrap_err();
7866        let DepError::FonteRepoShape { reason, .. } = err else {
7867            panic!("expected FonteRepoShape, got other variant");
7868        };
7869        assert!(
7870            reason.contains("must not contain `#`"),
7871            "reason must surface the fragment-`#` arm (fires before equals when \
7872             `#` byte appears first in value), got {reason:?}"
7873        );
7874    }
7875
7876    #[test]
7877    fn fonte_repo_comma_fires_before_equals_when_comma_first() {
7878        // Cascade pin: the comma-`,` arm (the immediate-predecessor
7879        // byte-class arm, 775b80e) and the `=` arm are both per-byte
7880        // arms inside the same `for &b in s.as_bytes()` loop, so
7881        // the byte that appears first in the value's byte order
7882        // wins. A `:repo "github:p/x,mid=tail"` carries both `,`
7883        // and `=`; the `,` byte appears first, so the comma arm
7884        // fires, surfacing the more self-locating diagnostic on
7885        // the byte the author pasted earliest in the URL. Pins the
7886        // natural-order cascade so a future reorder of the per-byte
7887        // arms surfaces here — `=` is the most recent byte-class
7888        // arm, so the cascade-pin sweep extends to cover the
7889        // immediately prior `,` byte arm firing first when ordered
7890        // ahead of `=` in the value.
7891        let d = dep_with_fonte(DepSource::Git {
7892            repo: "github:pleme-io/caixa-teia,mid=tail".into(),
7893            tag: Some("v0.1.0".into()),
7894            rev: None,
7895            branch: None,
7896        });
7897        let err = d.validate().unwrap_err();
7898        let DepError::FonteRepoShape { reason, .. } = err else {
7899            panic!("expected FonteRepoShape, got other variant");
7900        };
7901        assert!(
7902            reason.contains("must not contain `,`"),
7903            "reason must surface the comma arm (fires before equals when `,` byte \
7904             appears first in value), got {reason:?}"
7905        );
7906    }
7907
7908    #[test]
7909    fn validate_rejects_git_fonte_with_repo_carrying_percent_encoded_space() {
7910        // The fail-before-pass-after pin for the canonical paste-from-
7911        // browser-address-bar percent-encoded-space footgun on `:repo`.
7912        // An author copies `https://github.com/p/x%20test` from a
7913        // browser address bar (or a percent-encoded README hyperlink,
7914        // or a `curl --data-urlencode` shell-pipeline output)
7915        // intending `%20` as the URL encoding of a literal space; the
7916        // typed `:repo` slot already rejects the literal space byte
7917        // (the whitespace arm at the top of `is_git_repo_url`), so an
7918        // author trying to express "I really meant a space" reaches
7919        // for percent-encoding. Until this arm landed the `%` byte
7920        // silently passed every prior `is_git_repo_url` arm and rode
7921        // verbatim into the lacre's per-dep content-address — but
7922        // libcurl re-percent-encodes `%` to `%25` on the wire (since
7923        // `%` is reserved as the escape-sequence lead-in), so the
7924        // wire request becomes `https://github.com/p/x%2520test`, a
7925        // path the lacre's content-address never names. The classic
7926        // render-determinism violation on the encoding-mechanism axis
7927        // itself.
7928        let d = dep_with_fonte(DepSource::Git {
7929            repo: "https://github.com/pleme-io/caixa-teia%20test".into(),
7930            tag: Some("v0.1.0".into()),
7931            rev: None,
7932            branch: None,
7933        });
7934        let err = d.validate().unwrap_err();
7935        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7936            panic!("expected FonteRepoShape, got other variant");
7937        };
7938        assert_eq!(nome, "caixa-teia");
7939        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia%20test");
7940        assert!(
7941            reason.contains("must not contain `%`"),
7942            "reason must surface the percent-`%` arm on the percent-encoded-space \
7943             paste shape, got {reason:?}"
7944        );
7945        assert!(
7946            reason.contains("percent-encoding") || reason.contains("%25"),
7947            "reason must name the percent-encoding / `%25` re-encoding rationale, \
7948             got {reason:?}"
7949        );
7950    }
7951
7952    #[test]
7953    fn validate_rejects_git_fonte_with_repo_carrying_percent_encoded_slash() {
7954        // The symmetric over-encoded-path-separator pin: an author
7955        // writes `:repo "https://github.com/p%2Fx"` intending the
7956        // `%2F` as the URL encoding of `/` (the canonical
7957        // paste-from-OpenAPI-spec / paste-from-percent-encoded-template
7958        // footgun every API client library and OAuth redirect-URI
7959        // documentation surfaces — the `/` is the URL-path-separator
7960        // and some templates percent-encode it to escape interpretation
7961        // as a path separator). The GitHub Smart-HTTP transport
7962        // resolves the URL's path-segment grammar before the
7963        // percent-decoding pass, so the value identifies a different
7964        // resource on the wire than the literal-`/` form the lacre's
7965        // content-address must agree with — two authors whose `:repo`
7966        // values differ only in their `/` vs `%2F` presence lock to
7967        // two distinct BLAKE3 closures for the byte-identical upstream
7968        // `git clone`. Pinned separately so a future diagnostic
7969        // surface that only catches the `%20` shape surfaces here too.
7970        let d = dep_with_fonte(DepSource::Git {
7971            repo: "https://github.com/pleme-io%2Fcaixa-teia".into(),
7972            tag: Some("v0.1.0".into()),
7973            rev: None,
7974            branch: None,
7975        });
7976        let err = d.validate().unwrap_err();
7977        let DepError::FonteRepoShape { reason, .. } = err else {
7978            panic!("expected FonteRepoShape, got other variant");
7979        };
7980        assert!(
7981            reason.contains("must not contain `%`"),
7982            "reason must surface the percent-`%` arm on the over-encoded-path \
7983             shape, got {reason:?}"
7984        );
7985        assert!(
7986            reason.contains("render-determinism") || reason.contains("BLAKE3"),
7987            "reason must name the render-determinism / BLAKE3-closure rationale, \
7988             got {reason:?}"
7989        );
7990    }
7991
7992    #[test]
7993    fn fonte_repo_fragment_fires_before_percent_when_fragment_first() {
7994        // Cascade pin: the fragment-`#` arm and the `%` arm are both
7995        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
7996        // so the byte that appears first in the value's byte order
7997        // wins. A `:repo "https://github.com/p/x#sec%20tail"` carries
7998        // both `#` and `%`; the `#` byte appears first, so the
7999        // fragment-`#` arm fires, surfacing the more self-locating
8000        // diagnostic on the byte the author pasted earliest in the URL.
8001        let d = dep_with_fonte(DepSource::Git {
8002            repo: "https://github.com/pleme-io/caixa-teia#sec%20tail".into(),
8003            tag: Some("v0.1.0".into()),
8004            rev: None,
8005            branch: None,
8006        });
8007        let err = d.validate().unwrap_err();
8008        let DepError::FonteRepoShape { reason, .. } = err else {
8009            panic!("expected FonteRepoShape, got other variant");
8010        };
8011        assert!(
8012            reason.contains("must not contain `#`"),
8013            "reason must surface the fragment-`#` arm (fires before percent when \
8014             `#` byte appears first in value), got {reason:?}"
8015        );
8016    }
8017
8018    #[test]
8019    fn fonte_repo_equals_fires_before_percent_when_equals_first() {
8020        // Cascade pin: the equals-`=` arm (the immediate-predecessor
8021        // byte-class arm, acf99af) and the `%` arm are both per-byte
8022        // arms inside the same `for &b in s.as_bytes()` loop, so the
8023        // byte that appears first in the value's byte order wins.
8024        // A `:repo "github:p/x=mid%20tail"` carries both `=` and `%`;
8025        // the `=` byte appears first, so the equals arm fires,
8026        // surfacing the more self-locating diagnostic on the byte the
8027        // author pasted earliest in the URL. Pins the natural-order
8028        // cascade so a future reorder of the per-byte arms surfaces
8029        // here — `%` is the most recent byte-class arm, so the
8030        // cascade-pin sweep extends to cover the immediately prior
8031        // `=` byte arm firing first when ordered ahead of `%` in the
8032        // value.
8033        let d = dep_with_fonte(DepSource::Git {
8034            repo: "github:pleme-io/caixa-teia=mid%20tail".into(),
8035            tag: Some("v0.1.0".into()),
8036            rev: None,
8037            branch: None,
8038        });
8039        let err = d.validate().unwrap_err();
8040        let DepError::FonteRepoShape { reason, .. } = err else {
8041            panic!("expected FonteRepoShape, got other variant");
8042        };
8043        assert!(
8044            reason.contains("must not contain `=`"),
8045            "reason must surface the equals arm (fires before percent when `=` byte \
8046             appears first in value), got {reason:?}"
8047        );
8048    }
8049
8050    #[test]
8051    fn validate_rejects_git_fonte_with_repo_carrying_caret_history_substitution() {
8052        // The fail-before-pass-after pin for the canonical paste-from-
8053        // shell-history footgun on `:repo`. An author copies a
8054        // `git clone <url>` line from their terminal followed by a
8055        // bash / ksh / zsh `^typo^fix^` quick-edit-and-rerun shell-
8056        // history shorthand (the `^old^new^` form re-runs the prior
8057        // history entry with the first `old` substituted by `new`,
8058        // bash's default behavior on interactive sessions with
8059        // `set -o histexpand`), forgetting to trim the trailing
8060        // `^...^...` shell-history fragment from the URL value. The
8061        // `^` byte sits in the RFC 3986 §2 'unwise' set (peer with
8062        // `{`, `}`, `|`, `\\` — the strictest of the §2 reserved
8063        // classes), the WHATWG URL spec's 'fragment percent-encode
8064        // set' maps `^` → `%5E` on the wire, so the byte rides
8065        // verbatim into the lacre's per-dep content-address but
8066        // libcurl re-encodes it to `%5E` at `git clone` time — the
8067        // classic render-determinism violation on the same axis the
8068        // peer `%`, `=`, `,`, `!`, `'`, `"`, `(`, `)`, `*`, `$`,
8069        // `&`, `;`, `|`, backtick, `<`, `>`, `{`, `}`, `\\`, `?`,
8070        // `#` arms close.
8071        let d = dep_with_fonte(DepSource::Git {
8072            repo: "https://github.com/pleme-io/caixa-teia^typo^fix".into(),
8073            tag: Some("v0.1.0".into()),
8074            rev: None,
8075            branch: None,
8076        });
8077        let err = d.validate().unwrap_err();
8078        let DepError::FonteRepoShape { nome, repo, reason } = err else {
8079            panic!("expected FonteRepoShape, got other variant");
8080        };
8081        assert_eq!(nome, "caixa-teia");
8082        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia^typo^fix");
8083        assert!(
8084            reason.contains("must not contain `^`"),
8085            "reason must surface the caret-`^` arm on the paste-from-shell-history \
8086             shape, got {reason:?}"
8087        );
8088        assert!(
8089            reason.contains("history-substitution") || reason.contains("%5E"),
8090            "reason must name the shell-history-substitution / `%5E` wire-encoding \
8091             rationale, got {reason:?}"
8092        );
8093    }
8094
8095    #[test]
8096    fn validate_rejects_git_fonte_with_repo_carrying_caret_regex_anchor() {
8097        // The symmetric paste-from-doc-grep-pipeline footgun: an
8098        // author writes `:repo "github:p/^archived"` after copying a
8099        // `grep '^archived'` regex-anchor / negation idiom from a
8100        // doc / README quick-listing snippet, expecting the substrate
8101        // to coerce it to a literal repo name. The byte rides
8102        // verbatim into the lacre's per-dep content-address and
8103        // diverges from the byte-identical literal `archived` form
8104        // every other author authored — the canonical render-
8105        // determinism violation pin on the second footgun shape the
8106        // caret-`^` arm closes.
8107        let d = dep_with_fonte(DepSource::Git {
8108            repo: "github:pleme-io/^archived".into(),
8109            tag: Some("v0.1.0".into()),
8110            rev: None,
8111            branch: None,
8112        });
8113        let err = d.validate().unwrap_err();
8114        let DepError::FonteRepoShape { reason, .. } = err else {
8115            panic!("expected FonteRepoShape, got other variant");
8116        };
8117        assert!(
8118            reason.contains("must not contain `^`"),
8119            "reason must surface the caret-`^` arm on the regex-anchor shape, \
8120             got {reason:?}"
8121        );
8122        assert!(
8123            reason.contains("render-determinism") || reason.contains("BLAKE3"),
8124            "reason must name the render-determinism / BLAKE3-closure rationale, \
8125             got {reason:?}"
8126        );
8127    }
8128
8129    #[test]
8130    fn fonte_repo_percent_fires_before_caret_when_percent_first() {
8131        // Cascade pin: the `%` arm (the immediate-predecessor byte-
8132        // class arm, a323db8) and the `^` arm are both per-byte arms
8133        // inside the same `for &b in s.as_bytes()` loop, so the byte
8134        // that appears first in the value's byte order wins. A
8135        // `:repo "https://github.com/p/x%20mid^tail"` carries both
8136        // `%` and `^`; the `%` byte appears first, so the percent
8137        // arm fires, surfacing the more self-locating diagnostic on
8138        // the byte the author pasted earliest in the URL. Pins the
8139        // natural-order cascade so a future reorder of the per-byte
8140        // arms surfaces here — `^` is the most recent byte-class arm,
8141        // so the cascade-pin sweep extends to cover the immediately
8142        // prior `%` byte arm firing first when ordered ahead of `^`
8143        // in the value.
8144        let d = dep_with_fonte(DepSource::Git {
8145            repo: "https://github.com/pleme-io/caixa-teia%20mid^tail".into(),
8146            tag: Some("v0.1.0".into()),
8147            rev: None,
8148            branch: None,
8149        });
8150        let err = d.validate().unwrap_err();
8151        let DepError::FonteRepoShape { reason, .. } = err else {
8152            panic!("expected FonteRepoShape, got other variant");
8153        };
8154        assert!(
8155            reason.contains("must not contain `%`"),
8156            "reason must surface the percent arm (fires before caret when `%` byte \
8157             appears first in value), got {reason:?}"
8158        );
8159    }
8160
8161    #[test]
8162    fn validate_rejects_git_fonte_with_repo_missing_colon_separator() {
8163        // The "I dropped the scheme" footgun — `:repo "pleme-io/caixa-teia"`
8164        // (no `github:` prefix, no scheme). Every documented form
8165        // carries a `:` (`github:`, `https://`, `ssh://`, `git://`,
8166        // `file://`, or `git@host:path`); a bare `org/repo` is
8167        // ambiguous (`git clone` reads as a relative filesystem path
8168        // rather than the GitHub-shorthand expansion the author
8169        // probably intended) and the gate rejects the shape upstream.
8170        let d = dep_with_fonte(DepSource::Git {
8171            repo: "pleme-io/caixa-teia".into(),
8172            tag: Some("v0.1.0".into()),
8173            rev: None,
8174            branch: None,
8175        });
8176        let err = d.validate().unwrap_err();
8177        let DepError::FonteRepoShape { reason, .. } = err else {
8178            panic!("expected FonteRepoShape, got other variant");
8179        };
8180        assert!(
8181            reason.contains("must contain a `:`"),
8182            "reason must surface the missing-`:` arm, got {reason:?}"
8183        );
8184        assert!(
8185            reason.contains("github:"),
8186            "reason must name the canonical `github:` shorthand prefix, got {reason:?}"
8187        );
8188    }
8189
8190    #[test]
8191    fn validate_rejects_git_fonte_with_repo_leading_colon() {
8192        // The "empty scheme" footgun — `:repo ":foo"` has a zero-length
8193        // scheme that no git porcelain entry-point accepts. Pinned
8194        // separately from the missing-`:` arm because a value with a
8195        // leading `:` does technically contain a `:` separator; the
8196        // shape gate rejects on a dedicated arm so the diagnostic
8197        // names the specific footgun.
8198        let d = dep_with_fonte(DepSource::Git {
8199            repo: ":pleme-io/caixa-teia".into(),
8200            tag: Some("v0.1.0".into()),
8201            rev: None,
8202            branch: None,
8203        });
8204        let err = d.validate().unwrap_err();
8205        let DepError::FonteRepoShape { reason, .. } = err else {
8206            panic!("expected FonteRepoShape, got other variant");
8207        };
8208        assert!(
8209            reason.contains("must not start with `:`"),
8210            "reason must surface the leading-`:` arm, got {reason:?}"
8211        );
8212    }
8213
8214    #[test]
8215    fn validate_rejects_git_fonte_with_repo_too_long() {
8216        // The cap arm — a `:repo` value longer than
8217        // [`crate::render::GIT_REPO_URL_MAX_LEN`] (2048) bytes is
8218        // structurally untenable on every realistic landing site (the
8219        // resolver's `git clone` invocation, the future M4 CR
8220        // materializer's per-dep `repo:` axis); a value of that length
8221        // is almost certainly a paste-from-binary slug.
8222        let too_long = format!(
8223            "github:pleme-io/{}",
8224            "x".repeat(crate::render::GIT_REPO_URL_MAX_LEN)
8225        );
8226        let d = dep_with_fonte(DepSource::Git {
8227            repo: too_long.clone(),
8228            tag: Some("v0.1.0".into()),
8229            rev: None,
8230            branch: None,
8231        });
8232        let err = d.validate().unwrap_err();
8233        let DepError::FonteRepoShape { reason, .. } = err else {
8234            panic!("expected FonteRepoShape, got other variant");
8235        };
8236        assert!(
8237            reason.contains("2048"),
8238            "reason must name the cap, got {reason:?}"
8239        );
8240    }
8241
8242    #[test]
8243    fn validate_accepts_canonical_git_fonte_repo_shapes() {
8244        // The positive-control sweep: every documented author shape on
8245        // the `:fonte :repo` axis ([`crate::DepSource::Git`] doc comment)
8246        // must pass the value-shape gate. Pinned so a future tightening
8247        // (e.g. forbidding `http://` in favor of `https://`-only) surfaces
8248        // here as a structural decision. Each form is exercised with the
8249        // same canonical `:tag` pin so only the `:repo` axis varies.
8250        for repo in [
8251            // The pleme-io registry-shorthand convention — `github:org/repo`.
8252            "github:pleme-io/caixa-teia",
8253            // Other host-aliased shorthands (the resolver's pluggable
8254            // host-prefix table).
8255            "gitlab:pleme-io/caixa-teia",
8256            "codeberg:pleme-io/caixa-teia",
8257            "sourcehut:~pleme-io/caixa-teia",
8258            // Full HTTPS URL with and without `.git` suffix.
8259            "https://github.com/pleme-io/caixa-teia",
8260            "https://github.com/pleme-io/caixa-teia.git",
8261            // HTTP (rare; dev / mirror).
8262            "http://example.com/pleme-io/caixa-teia.git",
8263            // SSH URL.
8264            "ssh://git@github.com/pleme-io/caixa-teia.git",
8265            "ssh://git@git.example.com:2222/pleme-io/caixa-teia.git",
8266            // Scp-style SSH — the canonical `git@host:path` short form.
8267            "git@github.com:pleme-io/caixa-teia.git",
8268            "git@git.example.com:team/private.git",
8269            // Anonymous git protocol.
8270            "git://git.example.com/pleme-io/caixa-teia.git",
8271            // Local file URL (dev path).
8272            "file:///tmp/caixa-teia",
8273        ] {
8274            let d = dep_with_fonte(DepSource::Git {
8275                repo: repo.into(),
8276                tag: Some("v0.1.0".into()),
8277                rev: None,
8278                branch: None,
8279            });
8280            d.validate()
8281                .unwrap_or_else(|e| panic!("canonical repo {repo:?} must validate, got {e:?}"));
8282        }
8283    }
8284
8285    #[test]
8286    fn fonte_repo_empty_takes_precedence_over_shape() {
8287        // Order pin: the existing `FonteRepoEmpty` diagnostic (narrower
8288        // diagnostic; doesn't try to parse the URL shape) fires before
8289        // the new `FonteRepoShape` per-axis gate, so an empty `:repo`
8290        // keeps its narrower error message. Mirrors
8291        // `fonte_repo_empty_fires_before_pin_missing` (already pinned)
8292        // on the ordering layer.
8293        let d = dep_with_fonte(DepSource::Git {
8294            repo: String::new(),
8295            tag: Some("v0.1.0".into()),
8296            rev: None,
8297            branch: None,
8298        });
8299        let err = d.validate().unwrap_err();
8300        assert!(
8301            matches!(err, DepError::FonteRepoEmpty { .. }),
8302            "got {err:?}"
8303        );
8304    }
8305
8306    #[test]
8307    fn fonte_repo_shape_fires_before_pin_missing() {
8308        // Order pin: a malformed `:repo` value on a dep with no pin set
8309        // surfaces the `:repo` shape diagnostic (the more self-locating
8310        // axis — the `:repo` is the load-bearing identity of the source;
8311        // a missing pin is downstream from "do we even know the repo")
8312        // rather than collapsing onto the pin-missing diagnostic. The
8313        // shape gate runs inline before the pin enumeration in
8314        // `DepSource::validate`.
8315        let d = dep_with_fonte(DepSource::Git {
8316            repo: "pleme-io/caixa-teia".into(), // missing `:` separator
8317            tag: None,
8318            rev: None,
8319            branch: None,
8320        });
8321        let err = d.validate().unwrap_err();
8322        assert!(
8323            matches!(err, DepError::FonteRepoShape { .. }),
8324            "got {err:?}"
8325        );
8326    }
8327
8328    #[test]
8329    fn fonte_repo_shape_diagnostic_carries_offending_repo_verbatim() {
8330        // The diagnostic-shape pin: the error names the offending
8331        // `:repo` value verbatim plus a non-empty parser-shaped `reason`
8332        // so the author can grep their caixa.lisp without re-running
8333        // the build. Mirrors the diagnostic-shape sweep on every prior
8334        // value-shape gate (3f9d7a0, 6cbb900, c7d05ec, e70d213, be07fd5).
8335        let d = dep_with_fonte(DepSource::Git {
8336            repo: "pleme-io/caixa-teia".into(),
8337            tag: Some("v0.1.0".into()),
8338            rev: None,
8339            branch: None,
8340        });
8341        let err = d.validate().unwrap_err();
8342        let DepError::FonteRepoShape { nome, repo, reason } = err else {
8343            panic!("expected FonteRepoShape, got other variant");
8344        };
8345        assert_eq!(nome, "caixa-teia");
8346        assert_eq!(repo, "pleme-io/caixa-teia");
8347        assert!(
8348            !reason.is_empty(),
8349            "FonteRepoShape `reason` must carry the predicate's wording verbatim"
8350        );
8351    }
8352
8353    #[test]
8354    fn validate_rejects_git_fonte_with_no_pin() {
8355        // The fail-before-pass-after pin for the canonical
8356        // `(:tipo git :repo "github:pleme-io/x")` shape with no
8357        // :tag/:rev/:branch — until this gate landed the resolver's
8358        // ResolveError::MissingPin surfaced at fetch time, far from the
8359        // source caixa.lisp. The new gate moves the check to validate
8360        // time and names the offending dep.
8361        let d = dep_with_fonte(DepSource::Git {
8362            repo: "github:pleme-io/caixa-teia".into(),
8363            tag: None,
8364            rev: None,
8365            branch: None,
8366        });
8367        let err = d.validate().unwrap_err();
8368        assert!(
8369            matches!(err, DepError::FontePinMissing { ref nome } if nome == "caixa-teia"),
8370            "got {err:?}"
8371        );
8372    }
8373
8374    #[test]
8375    fn validate_rejects_git_fonte_with_ambiguous_tag_and_branch() {
8376        // The canonical "pin drift" footgun: an author writes
8377        // `:tag "v1"` and later adds `:branch "main"` without removing
8378        // the :tag, and the resolver silently picks :tag (precedence
8379        // :rev > :tag > :branch). The :branch was dropped with no
8380        // diagnostic. The gate now rejects multi-pin shapes so the
8381        // author makes the precedence explicit at the source.
8382        let d = dep_with_fonte(DepSource::Git {
8383            repo: "github:pleme-io/caixa-teia".into(),
8384            tag: Some("v0.1.0".into()),
8385            rev: None,
8386            branch: Some("main".into()),
8387        });
8388        let err = d.validate().unwrap_err();
8389        let DepError::FontePinAmbiguous { nome, pins } = err else {
8390            panic!("expected FontePinAmbiguous");
8391        };
8392        assert_eq!(nome, "caixa-teia");
8393        assert!(pins.contains(":tag"));
8394        assert!(pins.contains(":branch"));
8395        assert!(!pins.contains(":rev"));
8396    }
8397
8398    #[test]
8399    fn validate_rejects_git_fonte_with_ambiguous_tag_and_rev() {
8400        // Sibling arm of the pin-drift footgun: :tag + :rev set
8401        // simultaneously. Pinned separately so a future relaxation
8402        // that only catches the (:tag, :branch) pair surfaces here.
8403        let d = dep_with_fonte(DepSource::Git {
8404            repo: "github:pleme-io/caixa-teia".into(),
8405            tag: Some("v0.1.0".into()),
8406            rev: Some("c0ffee".into()),
8407            branch: None,
8408        });
8409        let err = d.validate().unwrap_err();
8410        let DepError::FontePinAmbiguous { nome, pins } = err else {
8411            panic!("expected FontePinAmbiguous");
8412        };
8413        assert_eq!(nome, "caixa-teia");
8414        assert!(pins.contains(":tag"));
8415        assert!(pins.contains(":rev"));
8416    }
8417
8418    #[test]
8419    fn validate_rejects_git_fonte_with_all_three_pins() {
8420        // The maximal ambiguity case — every pin axis set. Pinned so a
8421        // future relaxation that only catches pairs surfaces here. The
8422        // diagnostic must enumerate every offending axis so the author
8423        // sees the full set, not just the first match.
8424        let d = dep_with_fonte(DepSource::Git {
8425            repo: "github:pleme-io/caixa-teia".into(),
8426            tag: Some("v0.1.0".into()),
8427            rev: Some("c0ffee".into()),
8428            branch: Some("main".into()),
8429        });
8430        let err = d.validate().unwrap_err();
8431        let DepError::FontePinAmbiguous { nome, pins } = err else {
8432            panic!("expected FontePinAmbiguous");
8433        };
8434        assert_eq!(nome, "caixa-teia");
8435        assert!(pins.contains(":tag"));
8436        assert!(pins.contains(":rev"));
8437        assert!(pins.contains(":branch"));
8438    }
8439
8440    #[test]
8441    fn validate_rejects_git_fonte_with_empty_tag_pin() {
8442        // The empty-pin arm: exactly one pin axis is `Some(_)`, but its
8443        // inner string is empty. Distinct from FontePinMissing (where
8444        // every axis is None) — pinned separately so a future
8445        // tightening collapsing them surfaces here as a structural
8446        // decision.
8447        let d = dep_with_fonte(DepSource::Git {
8448            repo: "github:pleme-io/caixa-teia".into(),
8449            tag: Some(String::new()),
8450            rev: None,
8451            branch: None,
8452        });
8453        let err = d.validate().unwrap_err();
8454        let DepError::FontePinEmpty { nome, pin } = err else {
8455            panic!("expected FontePinEmpty");
8456        };
8457        assert_eq!(nome, "caixa-teia");
8458        assert_eq!(pin, ":tag");
8459    }
8460
8461    #[test]
8462    fn validate_rejects_git_fonte_with_empty_rev_pin() {
8463        // Sibling arm — the empty-pin diagnostic names which axis
8464        // carries the empty value, so the author's grep target is
8465        // unambiguous.
8466        let d = dep_with_fonte(DepSource::Git {
8467            repo: "github:pleme-io/caixa-teia".into(),
8468            tag: None,
8469            rev: Some(String::new()),
8470            branch: None,
8471        });
8472        let err = d.validate().unwrap_err();
8473        let DepError::FontePinEmpty { nome, pin } = err else {
8474            panic!("expected FontePinEmpty");
8475        };
8476        assert_eq!(nome, "caixa-teia");
8477        assert_eq!(pin, ":rev");
8478    }
8479
8480    #[test]
8481    fn validate_rejects_path_fonte_with_empty_caminho() {
8482        // The fail-before-pass-after pin for `(:tipo path :caminho "")`:
8483        // until this gate landed the resolver's
8484        // ResolveError::MissingPath surfaced with `path: PathBuf("")` at
8485        // fetch time — not actionable. The new gate moves the check to
8486        // validate time and names the offending dep.
8487        let d = dep_with_fonte(DepSource::Path {
8488            caminho: String::new(),
8489        });
8490        let err = d.validate().unwrap_err();
8491        assert!(
8492            matches!(err, DepError::FonteCaminhoEmpty { ref nome } if nome == "caixa-teia"),
8493            "got {err:?}"
8494        );
8495    }
8496
8497    #[test]
8498    fn validate_rejects_path_fonte_with_absolute_caminho() {
8499        // The fail-before-pass-after pin for the absolute-`:caminho`
8500        // shape: `(:tipo path :caminho "/home/me/work/caixa-teia")`.
8501        // Until this gate landed an absolute `:caminho` silently
8502        // passed validate; the lacre pipeline embedded the
8503        // host-specific filesystem path verbatim in its
8504        // content-address (`conteudo: format!("path:{caminho}")`,
8505        // caixa-resolver/src/resolve.rs:189), so the BLAKE3 closure
8506        // differed per machine — the build succeeded but two CI
8507        // runners with different `${HOME}` layouts emitted two
8508        // distinct lacres for the byte-identical caixa, silently
8509        // breaking the THEORY.md §V.2 render-determinism contract
8510        // far from the source caixa.lisp. The new gate moves the
8511        // check to validate time and names the offending dep +
8512        // caminho verbatim.
8513        let d = dep_with_fonte(DepSource::Path {
8514            caminho: "/home/me/work/caixa-teia".into(),
8515        });
8516        let err = d.validate().unwrap_err();
8517        let DepError::FonteCaminhoAbsolute { nome, caminho } = err else {
8518            panic!("expected FonteCaminhoAbsolute, got other variant");
8519        };
8520        assert_eq!(nome, "caixa-teia");
8521        assert_eq!(caminho, "/home/me/work/caixa-teia");
8522    }
8523
8524    #[test]
8525    fn validate_accepts_path_fonte_with_parent_escape_caminho() {
8526        // The canonical sibling-workspace dep form
8527        // (`:caminho "../caixa-teia"`) remains accepted. The
8528        // absolute-path gate above is specifically narrower than the
8529        // shared [`crate::render::is_sandboxed_relative_path`]
8530        // predicate (which additionally forbids `..` traversal): a
8531        // local-path dep's canonical author surface is the in-tree
8532        // sibling-workspace path, so a full sandboxed-relative-path
8533        // lift would structurally reject every legitimate path-fonte
8534        // dep. Pinned so a future tightening to the full predicate
8535        // surfaces here as a structural decision, not a silent break.
8536        let d = dep_with_fonte(DepSource::Path {
8537            caminho: "../caixa-teia".into(),
8538        });
8539        d.validate().unwrap();
8540    }
8541
8542    #[test]
8543    fn validate_accepts_path_fonte_with_deeply_nested_relative_caminho() {
8544        // A multi-segment relative `:caminho`
8545        // (`"vendor/forks/caixa-teia"`) remains accepted — the
8546        // absolute-path gate brackets the host-layout-leaking shape
8547        // at the leading-`/` boundary only; every relative shape past
8548        // the empty arm continues to pass. Pinned alongside the
8549        // `..`-traversal positive control so a future tightening
8550        // surfaces the full set of legitimate relative forms here
8551        // rather than at a downstream consumer.
8552        let d = dep_with_fonte(DepSource::Path {
8553            caminho: "vendor/forks/caixa-teia".into(),
8554        });
8555        d.validate().unwrap();
8556    }
8557
8558    #[test]
8559    fn validate_rejects_path_fonte_with_tilde_prefix_caminho() {
8560        // The fail-before-pass-after pin for the tilde-expansion
8561        // `:caminho` shape: `(:tipo path :caminho "~/work/caixa-teia")`.
8562        // Until this gate landed the b94fd83 absolute arm let `~/foo`
8563        // through (`Path::is_absolute` returns false on a leading `~`
8564        // — the tilde is a shell-expansion convention, not a POSIX
8565        // path component), so the lacre embedded the value verbatim
8566        // and the resolver folded it through `Path::join` without
8567        // expansion, looking for a literal `./~/work/caixa-teia`
8568        // subdirectory and failing at resolve time with a
8569        // `No such file or directory` error far from the source
8570        // caixa.lisp. The new gate moves the check to validate time
8571        // and names the offending dep + caminho verbatim.
8572        let d = dep_with_fonte(DepSource::Path {
8573            caminho: "~/work/caixa-teia".into(),
8574        });
8575        let err = d.validate().unwrap_err();
8576        let DepError::FonteCaminhoTildeExpansion { nome, caminho } = err else {
8577            panic!("expected FonteCaminhoTildeExpansion, got {err:?}");
8578        };
8579        assert_eq!(nome, "caixa-teia");
8580        assert_eq!(caminho, "~/work/caixa-teia");
8581    }
8582
8583    #[test]
8584    fn validate_rejects_path_fonte_with_bare_tilde_caminho() {
8585        // The bare `~` form (canonical "I meant `$HOME` and forgot
8586        // the rest"): both the leading-tilde arm catches it and the
8587        // canonical-user-tilde shell idiom (`~alice/dev/caixa-teia`)
8588        // sweeps through the same arm. Pinned both to ensure the
8589        // gate doesn't narrow to `~/` only.
8590        for s in ["~", "~alice/dev/caixa-teia", "~/", "~root/work"] {
8591            let d = dep_with_fonte(DepSource::Path { caminho: s.into() });
8592            let err = d.validate().unwrap_err();
8593            assert!(
8594                matches!(err, DepError::FonteCaminhoTildeExpansion { .. }),
8595                "{s:?} → {err:?}",
8596            );
8597        }
8598    }
8599
8600    #[test]
8601    fn validate_accepts_path_fonte_with_mid_path_tilde_caminho() {
8602        // The leading-`~` is the canonical shell-expansion footgun —
8603        // a tilde mid-path (`"../foo~bar/caixa-teia"` — the canonical
8604        // backup-file-suffix idiom) is a legitimate POSIX path byte
8605        // with no shell-expansion semantic at the leading position.
8606        // Pinned so the gate doesn't widen to a full no-tilde-anywhere
8607        // sweep that would break every legitimate-shape backup-file
8608        // path.
8609        let d = dep_with_fonte(DepSource::Path {
8610            caminho: "../foo~bar/caixa-teia".into(),
8611        });
8612        d.validate().unwrap();
8613    }
8614
8615    #[test]
8616    fn fonte_caminho_empty_fires_before_tilde_expansion() {
8617        // Cascade pin: the empty arm structurally precedes the
8618        // tilde arm (the bytes `""` and `"~"` don't overlap), but the
8619        // pin establishes the precedence at the diagnostic-shape
8620        // level should a future codec round-trip ever produce a
8621        // probe-as-both value. Mirrors the peer
8622        // `fonte_repo_empty_fires_before_pin_missing` cascade
8623        // discipline.
8624        let d = dep_with_fonte(DepSource::Path {
8625            caminho: String::new(),
8626        });
8627        let err = d.validate().unwrap_err();
8628        assert!(
8629            matches!(err, DepError::FonteCaminhoEmpty { .. }),
8630            "got {err:?}",
8631        );
8632    }
8633
8634    #[test]
8635    fn fonte_caminho_tilde_diagnostic_carries_offending_dep_and_caminho() {
8636        // Diagnostic-shape pin (peer with
8637        // `validate_rejects_path_fonte_with_absolute_caminho`'s
8638        // payload assertion): the error's Display surfaces both the
8639        // offending `:nome` and the offending `:caminho` verbatim
8640        // so a `feira lint` run can render the diagnostic without
8641        // re-parsing.
8642        let d = dep_with_fonte(DepSource::Path {
8643            caminho: "~alice/dev/caixa-teia".into(),
8644        });
8645        let rendered = d.validate().unwrap_err().to_string();
8646        assert!(
8647            rendered.contains("caixa-teia"),
8648            "diagnostic must name the offending dep: {rendered}",
8649        );
8650        assert!(
8651            rendered.contains("~alice/dev/caixa-teia"),
8652            "diagnostic must quote the offending caminho: {rendered}",
8653        );
8654        assert!(
8655            rendered.contains('~'),
8656            "diagnostic must reference the tilde footgun: {rendered}",
8657        );
8658    }
8659
8660    #[test]
8661    fn validate_rejects_path_fonte_with_dollar_prefix_caminho() {
8662        // The fail-before-pass-after pin for the shell-variable-
8663        // expansion `:caminho` shape: `(:tipo path :caminho
8664        // "$HOME/work/caixa-teia")`. Until this gate landed the
8665        // b94fd83 absolute arm + the a5c248e tilde arm both let
8666        // `$HOME/foo` through (`Path::is_absolute` returns false on
8667        // a leading `$` — the `$` is a shell convention, not a POSIX
8668        // path component; `starts_with('~')` returns false too), so
8669        // the lacre embedded the value verbatim and the resolver
8670        // folded it through `Path::join` without `$`-expansion,
8671        // looking for a literal `./$HOME/work/caixa-teia`
8672        // subdirectory and failing at resolve time with a
8673        // `No such file or directory` error far from the source
8674        // caixa.lisp. The new gate moves the check to validate time
8675        // and names the offending dep + caminho verbatim.
8676        let d = dep_with_fonte(DepSource::Path {
8677            caminho: "$HOME/work/caixa-teia".into(),
8678        });
8679        let err = d.validate().unwrap_err();
8680        let DepError::FonteCaminhoVarExpansion { nome, caminho } = err else {
8681            panic!("expected FonteCaminhoVarExpansion, got {err:?}");
8682        };
8683        assert_eq!(nome, "caixa-teia");
8684        assert_eq!(caminho, "$HOME/work/caixa-teia");
8685    }
8686
8687    #[test]
8688    fn validate_rejects_path_fonte_with_dollar_brace_prefix_caminho() {
8689        // Sweep over every leading-`$` shape: the `${VAR}`-braced
8690        // form (canonical "paste-from-CI-manifest" footgun every
8691        // GitHub Actions / GitLab CI / Drone manifest carries on
8692        // `${WORKSPACE}`), the XDG idiom (`$XDG_CONFIG_HOME/caixa`,
8693        // canonical "I'm referencing a per-user config dir"),
8694        // and the bare `$` (canonical "I meant `$HOME` and forgot
8695        // the rest"). All shapes route through the same gate's
8696        // byte check. Pinned so the gate doesn't narrow to a
8697        // single shape (e.g. `$HOME/` only).
8698        for s in [
8699            "${HOME}/work/caixa-teia",
8700            "${WORKSPACE}/caixa-teia",
8701            "$XDG_CONFIG_HOME/caixa",
8702            "$",
8703        ] {
8704            let d = dep_with_fonte(DepSource::Path { caminho: s.into() });
8705            let err = d.validate().unwrap_err();
8706            assert!(
8707                matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
8708                "{s:?} → {err:?}",
8709            );
8710        }
8711    }
8712
8713    #[test]
8714    fn validate_rejects_path_fonte_with_mid_path_dollar_caminho() {
8715        // The `$` byte is the canonical shell-variable-expansion /
8716        // command-substitution / arithmetic-expansion sentinel and
8717        // is rejected at *every* position on the `:caminho` axis: the
8718        // leading arm surfaces `FonteCaminhoVarExpansion`, the
8719        // embedded arm surfaces `FonteCaminhoShellVariableExpansion`
8720        // (6620f39). Pinned so a future arm doesn't narrow the gate
8721        // back to the leading position and re-open the paste-from-
8722        // shell-one-liner `"../foo$HOME/bar"` / paste-from-CI-
8723        // manifest `"../foo${WORKSPACE}/bar"` / paste-from-shell-
8724        // prompt `"../foo$(whoami)/bar"` cross-idiom-leak surface on
8725        // the lacre content-address (`path:{caminho}`,
8726        // caixa-resolver/src/resolve.rs:189).
8727        let d = dep_with_fonte(DepSource::Path {
8728            caminho: "../foo$bar/caixa-teia".into(),
8729        });
8730        let err = d.validate().unwrap_err();
8731        assert!(
8732            matches!(
8733                err,
8734                DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
8735            ),
8736            "got {err:?}",
8737        );
8738    }
8739
8740    #[test]
8741    fn fonte_caminho_tilde_fires_before_var_expansion() {
8742        // Cascade pin: the tilde arm structurally precedes the var
8743        // arm (the bytes `~` and `$` don't overlap at the leading
8744        // position), but the pin establishes the precedence at the
8745        // diagnostic-shape level should a future codec round-trip
8746        // ever produce a probe-as-both value. Mirrors the peer
8747        // `fonte_caminho_empty_fires_before_tilde_expansion` cascade
8748        // discipline on the immediate-predecessor arm.
8749        let d = dep_with_fonte(DepSource::Path {
8750            caminho: "~/work/caixa-teia".into(),
8751        });
8752        let err = d.validate().unwrap_err();
8753        assert!(
8754            matches!(err, DepError::FonteCaminhoTildeExpansion { .. }),
8755            "got {err:?}",
8756        );
8757    }
8758
8759    #[test]
8760    fn fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho() {
8761        // Diagnostic-shape pin (peer with
8762        // `fonte_caminho_tilde_diagnostic_carries_offending_dep_and_caminho`'s
8763        // payload assertion on the immediate-predecessor arm): the
8764        // error's Display surfaces both the offending `:nome` and
8765        // the offending `:caminho` verbatim plus the `$` footgun
8766        // character itself so a `feira lint` run can render the
8767        // diagnostic without re-parsing.
8768        let d = dep_with_fonte(DepSource::Path {
8769            caminho: "${WORKSPACE}/caixa-teia".into(),
8770        });
8771        let rendered = d.validate().unwrap_err().to_string();
8772        assert!(
8773            rendered.contains("caixa-teia"),
8774            "diagnostic must name the offending dep: {rendered}",
8775        );
8776        assert!(
8777            rendered.contains("${WORKSPACE}/caixa-teia"),
8778            "diagnostic must quote the offending caminho: {rendered}",
8779        );
8780        assert!(
8781            rendered.contains('$'),
8782            "diagnostic must reference the dollar footgun: {rendered}",
8783        );
8784    }
8785
8786    #[test]
8787    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_nul() {
8788        // The fail-before-pass-after pin for the load-bearing NUL byte:
8789        // POSIX paths cannot contain `0x00` (every `std::fs` syscall
8790        // routes the path through `CString::new` which fails with
8791        // `NulError`); until this gate landed a `:caminho
8792        // "../caixa\0teia"` silently passed validate, the lacre
8793        // pipeline embedded the value verbatim, and the failure
8794        // surfaced at the resolver's `Path::join` → `CString::new`
8795        // boundary with a non-self-locating `NulError` far from the
8796        // source caixa.lisp. The new gate moves the check to validate
8797        // time and names the offending dep + caminho + offending byte
8798        // verbatim.
8799        let d = dep_with_fonte(DepSource::Path {
8800            caminho: "../caixa\0teia".into(),
8801        });
8802        let err = d.validate().unwrap_err();
8803        let DepError::FonteCaminhoControlChar {
8804            nome,
8805            caminho,
8806            byte,
8807        } = err
8808        else {
8809            panic!("expected FonteCaminhoControlChar, got {err:?}");
8810        };
8811        assert_eq!(nome, "caixa-teia");
8812        assert_eq!(caminho, "../caixa\0teia");
8813        assert_eq!(byte, 0x00);
8814    }
8815
8816    #[test]
8817    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_newline() {
8818        // The canonical paste-from-multiline-doc footgun on `:caminho`
8819        // — author copies `"../caixa-teia\n"` (trailing newline) out
8820        // of a multi-line code-fence or, worse, a `:caminho
8821        // "../caixa-teia\nrm -rf /"` value (CRLF-at-subprocess-argument
8822        // injection sibling on the path axis the `is_git_repo_url`
8823        // control-char arm already closes on `:repo`). Pinned
8824        // separately from the NUL arm so a future relaxation that
8825        // catches one but not the other surfaces here.
8826        let d = dep_with_fonte(DepSource::Path {
8827            caminho: "../caixa-teia\n".into(),
8828        });
8829        let err = d.validate().unwrap_err();
8830        let DepError::FonteCaminhoControlChar { byte, .. } = err else {
8831            panic!("expected FonteCaminhoControlChar, got {err:?}");
8832        };
8833        assert_eq!(byte, 0x0A);
8834    }
8835
8836    #[test]
8837    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_carriage_return() {
8838        // The CRLF sibling of the LF arm — Windows-line-ending
8839        // paste-from-multiline-doc on a `\r\n`-terminated buffer
8840        // leaves a stray `\r` mid-string after the LF strip. Pinned
8841        // separately from the LF arm so a future relaxation that
8842        // only catches LF surfaces here.
8843        let d = dep_with_fonte(DepSource::Path {
8844            caminho: "../caixa-teia\r".into(),
8845        });
8846        let err = d.validate().unwrap_err();
8847        let DepError::FonteCaminhoControlChar { byte, .. } = err else {
8848            panic!("expected FonteCaminhoControlChar, got {err:?}");
8849        };
8850        assert_eq!(byte, 0x0D);
8851    }
8852
8853    #[test]
8854    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_tab() {
8855        // The canonical paste-from-aligned-table footgun — a `\t`
8856        // mid-`:caminho` is invisible in most editors but rides
8857        // through the lacre's content-address verbatim, so two
8858        // paste-from-distinct-tables (one editor strips tabs, one
8859        // preserves them) yield divergent lacres for the byte-
8860        // identical-looking caixa. Pinned separately from the
8861        // whitespace-shaped LF/CR arms so a future relaxation that
8862        // narrows to line-terminator-only surfaces here.
8863        let d = dep_with_fonte(DepSource::Path {
8864            caminho: "../caixa\tteia".into(),
8865        });
8866        let err = d.validate().unwrap_err();
8867        let DepError::FonteCaminhoControlChar { byte, .. } = err else {
8868            panic!("expected FonteCaminhoControlChar, got {err:?}");
8869        };
8870        assert_eq!(byte, 0x09);
8871    }
8872
8873    #[test]
8874    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_del() {
8875        // The DEL byte (`0x7F`) closes the upper-end paste-from-
8876        // binary-blob footgun — the gate's contract is `b < 0x20 ||
8877        // b == 0x7F`, matching the `is_git_repo_url` /
8878        // `is_git_ref_name` predicates' control-char arms. Pinned
8879        // separately from the lower-range arms so a future narrowing
8880        // to `< 0x20` only surfaces here.
8881        let d = dep_with_fonte(DepSource::Path {
8882            caminho: "../caixa\x7fteia".into(),
8883        });
8884        let err = d.validate().unwrap_err();
8885        let DepError::FonteCaminhoControlChar { byte, .. } = err else {
8886            panic!("expected FonteCaminhoControlChar, got {err:?}");
8887        };
8888        assert_eq!(byte, 0x7F);
8889    }
8890
8891    #[test]
8892    fn validate_accepts_path_fonte_with_caminho_carrying_high_bit_utf8() {
8893        // The control-byte arm targets `0x00..=0x1F` + `0x7F` only —
8894        // high-bit / non-ASCII UTF-8 bytes are not gated. POSIX paths
8895        // are opaque byte sequences and UTF-8 multi-byte sequences
8896        // are a legitimate filename shape (the `café-teia/foo` idiom).
8897        // Pinned so the gate doesn't widen to a full ASCII-only sweep
8898        // that would break every legitimate-shape UTF-8 path.
8899        let d = dep_with_fonte(DepSource::Path {
8900            caminho: "../café-teia/foo".into(),
8901        });
8902        d.validate().unwrap();
8903    }
8904
8905    #[test]
8906    fn fonte_caminho_var_fires_before_control_char() {
8907        // Cascade pin: the var-expansion arm structurally precedes the
8908        // control-char arm. A value like `"$\n"` probes positive on
8909        // both arms (`starts_with('$')` and contains LF), but the
8910        // narrower leading-byte diagnostic (`FonteCaminhoVarExpansion`)
8911        // wins so the author sees the more self-locating shell-
8912        // expansion arm first. Mirrors the
8913        // `fonte_caminho_tilde_fires_before_var_expansion` cascade
8914        // discipline on the immediate-predecessor arm.
8915        let d = dep_with_fonte(DepSource::Path {
8916            caminho: "$HOME\n".into(),
8917        });
8918        let err = d.validate().unwrap_err();
8919        assert!(
8920            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
8921            "got {err:?}",
8922        );
8923    }
8924
8925    #[test]
8926    fn validate_rejects_path_fonte_with_leading_space_caminho() {
8927        // The fail-before-pass-after pin for the leading ASCII space
8928        // `:caminho` shape: `(:tipo path :caminho " ../caixa-teia")`.
8929        // Until this gate landed the b94fd83 absolute arm + the a5c248e
8930        // tilde arm + the f4efe9c var arm + the d624c8d control-byte arm
8931        // all let `" ../caixa-teia"` through: `Path::is_absolute` returns
8932        // false on a leading space (the leading byte is `0x20`, not `0x2F`),
8933        // `starts_with('~')` / `starts_with('$')` return false, and `0x20`
8934        // is not in the `0x00..=0x1F` plus `0x7F` control-byte set (the
8935        // four ASCII whitespace bytes `0x09` tab, `0x0A` LF, `0x0D` CR
8936        // are caught, but the most common whitespace `0x20` space is
8937        // not). The lacre embedded the value verbatim and the resolver
8938        // folded it through `Path::join` looking for a literal `./ ../
8939        // caixa-teia` subdirectory and failing at resolve time with a
8940        // non-self-locating `No such file or directory` error far from
8941        // the source caixa.lisp. The new gate moves the check to
8942        // validate time and names the offending dep + caminho verbatim.
8943        let d = dep_with_fonte(DepSource::Path {
8944            caminho: " ../caixa-teia".into(),
8945        });
8946        let err = d.validate().unwrap_err();
8947        let DepError::FonteCaminhoLeadingWhitespace { nome, caminho } = err else {
8948            panic!("expected FonteCaminhoLeadingWhitespace, got {err:?}");
8949        };
8950        assert_eq!(nome, "caixa-teia");
8951        assert_eq!(caminho, " ../caixa-teia");
8952    }
8953
8954    #[test]
8955    fn validate_rejects_path_fonte_with_multiple_leading_spaces_caminho() {
8956        // The aligned-doc paste footgun sweep: more than one leading
8957        // space (`"   ../caixa-teia"` — the canonical "I selected the
8958        // aligned column from a four-`:fonte`-entry `:deps` block"
8959        // paste) routes through the same gate's `starts_with(' ')`
8960        // byte check. Pinned so the gate doesn't narrow to a
8961        // single-space prefix.
8962        let d = dep_with_fonte(DepSource::Path {
8963            caminho: "   ../caixa-teia".into(),
8964        });
8965        let err = d.validate().unwrap_err();
8966        assert!(
8967            matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
8968            "got {err:?}",
8969        );
8970    }
8971
8972    #[test]
8973    fn validate_accepts_path_fonte_with_mid_path_space_caminho() {
8974        // The leading-space is the canonical paste-from-aligned-doc
8975        // footgun — a space mid-path (`"../my dir/caixa-teia"` — the
8976        // canonical "I have a directory with a space in its name"
8977        // idiom; ASCII `0x20` is a valid POSIX filename byte) is a
8978        // legitimate path with no whitespace-leak semantic at the
8979        // non-leading position. Pinned so the gate doesn't widen to a
8980        // full no-space-anywhere sweep that would break every
8981        // legitimate-shape space-in-filename path.
8982        let d = dep_with_fonte(DepSource::Path {
8983            caminho: "../my dir/caixa-teia".into(),
8984        });
8985        d.validate().unwrap();
8986    }
8987
8988    #[test]
8989    fn fonte_caminho_var_fires_before_leading_whitespace() {
8990        // Cascade pin: the var-expansion arm structurally precedes the
8991        // leading-whitespace arm. A value like `"$ "` would probe positive
8992        // on var (`starts_with('$')`) but the leading-byte arms walk
8993        // left-to-right so the var arm fires on the leading `$` before
8994        // the leading-whitespace arm probes. Mirrors the
8995        // `fonte_caminho_tilde_fires_before_var_expansion` cascade
8996        // discipline on the immediate-predecessor arms.
8997        let d = dep_with_fonte(DepSource::Path {
8998            caminho: "$VAR".into(),
8999        });
9000        let err = d.validate().unwrap_err();
9001        assert!(
9002            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
9003            "got {err:?}",
9004        );
9005    }
9006
9007    #[test]
9008    fn fonte_caminho_leading_whitespace_fires_before_control_char() {
9009        // Cascade pin: the leading-whitespace arm structurally precedes
9010        // the control-char arm. A value like `" ../foo\n"` probes
9011        // positive on both (starts with space AND contains LF), but
9012        // the narrower leading-byte diagnostic
9013        // (`FonteCaminhoLeadingWhitespace`) wins so the author sees the
9014        // more self-locating paste-from-aligned-doc arm first. Mirrors
9015        // the `fonte_caminho_var_fires_before_control_char` cascade
9016        // discipline on the immediate-predecessor arm.
9017        let d = dep_with_fonte(DepSource::Path {
9018            caminho: " ../foo\n".into(),
9019        });
9020        let err = d.validate().unwrap_err();
9021        assert!(
9022            matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
9023            "got {err:?}",
9024        );
9025    }
9026
9027    #[test]
9028    fn fonte_caminho_leading_whitespace_diagnostic_carries_offending_dep_and_caminho() {
9029        // Diagnostic-shape pin (peer with
9030        // `fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho`'s
9031        // payload assertion on the immediate-predecessor arm): the
9032        // error's Display surfaces both the offending `:nome` and the
9033        // offending `:caminho` verbatim, so a `feira lint` run can
9034        // render the diagnostic without re-parsing and the author can
9035        // grep their caixa.lisp for `:caminho "<value>"` and fix it in
9036        // one edit.
9037        let d = dep_with_fonte(DepSource::Path {
9038            caminho: " ../caixa-teia".into(),
9039        });
9040        let rendered = d.validate().unwrap_err().to_string();
9041        assert!(
9042            rendered.contains("caixa-teia"),
9043            "diagnostic must name the offending dep: {rendered}",
9044        );
9045        assert!(
9046            rendered.contains(" ../caixa-teia"),
9047            "diagnostic must quote the offending caminho: {rendered}",
9048        );
9049        assert!(
9050            rendered.contains("space"),
9051            "diagnostic must name the space footgun: {rendered}",
9052        );
9053    }
9054
9055    #[test]
9056    fn fonte_caminho_absolute_fires_before_control_char() {
9057        // Cascade pin on the sibling leading-byte arm: a leading `/`
9058        // value with embedded control byte (`"/etc/passwd\n"`) routes
9059        // through `FonteCaminhoAbsolute` not `FonteCaminhoControlChar`
9060        // — the host-layout-leak diagnostic is the load-bearing axis,
9061        // the control byte is the secondary observation. Same precedence
9062        // logic on every prior leading-byte arm.
9063        let d = dep_with_fonte(DepSource::Path {
9064            caminho: "/etc/passwd\n".into(),
9065        });
9066        let err = d.validate().unwrap_err();
9067        assert!(
9068            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
9069            "got {err:?}",
9070        );
9071    }
9072
9073    #[test]
9074    fn validate_rejects_path_fonte_with_leading_hyphen_caminho() {
9075        // The fail-before-pass-after pin for the leading-`-` CLI-arg-
9076        // injection `:caminho` shape sweep. Until this gate landed
9077        // every prior leading-byte arm passed a leading-`-` value
9078        // through: `Path::is_absolute` returns false on `-` (the
9079        // leading byte is `0x2D`, not `0x2F`), `starts_with('~')` /
9080        // `starts_with('$')` / `starts_with(' ')` all return false,
9081        // and `0x2D` sits outside the control-byte set. The lacre
9082        // embedded the value verbatim and the resolver folded it
9083        // through `Path::join` looking for a literal `./-rf` /
9084        // `./-C` / `./--upload-pack=…` subdirectory; the failure at
9085        // `Path::join` time is non-self-locating but harmless, while
9086        // the failure at every downstream `git -C {caminho}` /
9087        // `terraform -chdir={caminho}` / `find {caminho}` shell-out
9088        // is arbitrary-CLI-arg-injection because none of those
9089        // porcelains carry a `--` argument-list terminator between
9090        // the flag block and the path argument. The new arm moves the
9091        // rejection to `Caixa::from_lisp` boundary time and names
9092        // the offending dep + caminho verbatim.
9093        //
9094        // Sweep spans the canonical CLI-arg-injection shapes matching
9095        // the peer sweep on the sibling `is_git_ref_name` /
9096        // `is_git_repo_url` axes: short-flag `-rf` (the `rm -rf` /
9097        // `find -rf` reinterpretation vector), `-C` (the `git -C`
9098        // change-directory-config-injection paste), long-flag
9099        // `--upload-pack=cat /etc/passwd` (the canonical
9100        // arbitrary-command-execution vector on every git porcelain
9101        // entry point), git-config-injection `--config=core.merge=ours`,
9102        // and the degenerate single-byte `-` value.
9103        for caminho in [
9104            "-rf",
9105            "-C",
9106            "--upload-pack=cat /etc/passwd",
9107            "--config=core.merge=ours",
9108            "-",
9109        ] {
9110            let d = dep_with_fonte(DepSource::Path {
9111                caminho: caminho.into(),
9112            });
9113            let err = d.validate().unwrap_err();
9114            let DepError::FonteCaminhoLeadingHyphen { nome, caminho: got } = err else {
9115                panic!("expected FonteCaminhoLeadingHyphen for {caminho:?}, got {err:?}");
9116            };
9117            assert_eq!(nome, "caixa-teia");
9118            assert_eq!(got, caminho);
9119        }
9120    }
9121
9122    #[test]
9123    fn validate_accepts_path_fonte_with_mid_path_hyphen_caminho() {
9124        // The leading-`-` is the canonical CLI-arg-injection footgun
9125        // — a `-` anywhere else in the path (`"../caixa-teia"` — the
9126        // canonical kebab-separator-between-alphanumeric-segments
9127        // shape every DNS-1123-shaped caixa name carries; `"../-hidden"`
9128        // — a mid-path segment starting with `-`, still a legitimate
9129        // POSIX filename byte at that non-leading position because the
9130        // subprocess reads the whole `{caminho}` value as one positional
9131        // argument, so only the very first byte of the composite path
9132        // string is at the CLI-arg-injection boundary) is a legitimate
9133        // path with no CLI-flag-reinterpretation semantic at the non-
9134        // leading position of the top-level value. Pinned so the gate
9135        // doesn't widen to a full no-`-`-anywhere sweep that would
9136        // break every legitimate-shape kebab-in-filename path (i.e.
9137        // essentially every sibling-workspace caixa dep).
9138        for caminho in [
9139            "../caixa-teia",
9140            "../caixa-teia/-hidden",
9141            "./my-lib",
9142            "../foo-bar/baz",
9143        ] {
9144            let d = dep_with_fonte(DepSource::Path {
9145                caminho: caminho.into(),
9146            });
9147            d.validate()
9148                .unwrap_or_else(|e| panic!("mid-path `-` caminho {caminho:?} must pass: {e:?}"));
9149        }
9150    }
9151
9152    #[test]
9153    fn fonte_caminho_leading_whitespace_fires_before_leading_hyphen() {
9154        // Cascade pin: the leading-whitespace arm structurally precedes
9155        // the leading-hyphen arm. A value like `" -rf"` probes positive
9156        // on both (leading space AND, one byte in, a `-` — though the
9157        // leading-hyphen arm probes only the very first byte so it
9158        // wouldn't fire on this value; the pin instead documents the
9159        // arm order on the more common "leading space then a hyphen"
9160        // paste-from-aligned-doc paste-flag-shell-one-liner idiom).
9161        // The narrower leading-space diagnostic (the paste-from-aligned-
9162        // doc footgun) wins so the author sees the more self-locating
9163        // whitespace arm first. Mirrors the
9164        // `fonte_caminho_var_fires_before_leading_whitespace` cascade
9165        // discipline on the immediate-predecessor arm.
9166        let d = dep_with_fonte(DepSource::Path {
9167            caminho: " -rf".into(),
9168        });
9169        let err = d.validate().unwrap_err();
9170        assert!(
9171            matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
9172            "got {err:?}",
9173        );
9174    }
9175
9176    #[test]
9177    fn fonte_caminho_leading_hyphen_fires_before_control_char() {
9178        // Cascade pin: the leading-hyphen arm structurally precedes
9179        // the control-char arm. A value like `"-rf\n"` probes positive
9180        // on both (starts with `-` AND contains LF), but the narrower
9181        // leading-byte diagnostic (`FonteCaminhoLeadingHyphen`) wins so
9182        // the author sees the more self-locating CLI-arg-injection arm
9183        // first. Mirrors the
9184        // `fonte_caminho_leading_whitespace_fires_before_control_char`
9185        // cascade discipline on the immediate-predecessor arm.
9186        let d = dep_with_fonte(DepSource::Path {
9187            caminho: "-rf\n".into(),
9188        });
9189        let err = d.validate().unwrap_err();
9190        assert!(
9191            matches!(err, DepError::FonteCaminhoLeadingHyphen { .. }),
9192            "got {err:?}",
9193        );
9194    }
9195
9196    #[test]
9197    fn fonte_caminho_leading_hyphen_diagnostic_carries_offending_dep_and_caminho() {
9198        // Diagnostic-shape pin (peer with
9199        // `fonte_caminho_leading_whitespace_diagnostic_carries_offending_dep_and_caminho`'s
9200        // payload assertion on the immediate-predecessor arm): the
9201        // error's Display surfaces both the offending `:nome` and the
9202        // offending `:caminho` verbatim plus the CLI-argument-injection
9203        // vocabulary, so a `feira lint` run can render the diagnostic
9204        // without re-parsing and the author can grep their caixa.lisp
9205        // for `:caminho "<value>"` and fix it in one edit.
9206        let d = dep_with_fonte(DepSource::Path {
9207            caminho: "--upload-pack=cat /etc/passwd".into(),
9208        });
9209        let rendered = d.validate().unwrap_err().to_string();
9210        assert!(
9211            rendered.contains("caixa-teia"),
9212            "diagnostic must name the offending dep: {rendered}",
9213        );
9214        assert!(
9215            rendered.contains("--upload-pack=cat /etc/passwd"),
9216            "diagnostic must quote the offending caminho: {rendered}",
9217        );
9218        assert!(
9219            rendered.contains("CLI-argument-injection"),
9220            "diagnostic must name the CLI-argument-injection vector: {rendered}",
9221        );
9222        assert!(
9223            rendered.contains("`-`"),
9224            "diagnostic must name the offending byte: {rendered}",
9225        );
9226    }
9227
9228    #[test]
9229    fn fonte_caminho_control_diagnostic_carries_offending_dep_caminho_byte() {
9230        // Diagnostic-shape pin (peer with
9231        // `fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho`'s
9232        // payload assertion on the immediate-predecessor arm): the
9233        // error's Display surfaces the offending `:nome`, the
9234        // offending `:caminho` verbatim, and the offending byte in
9235        // hex form (`0x09` for tab) so a `feira lint` run can render
9236        // the diagnostic without re-parsing.
9237        let d = dep_with_fonte(DepSource::Path {
9238            caminho: "../caixa\tteia".into(),
9239        });
9240        let rendered = d.validate().unwrap_err().to_string();
9241        assert!(
9242            rendered.contains("caixa-teia"),
9243            "diagnostic must name the offending dep: {rendered}",
9244        );
9245        assert!(
9246            rendered.contains("../caixa\tteia"),
9247            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
9248        );
9249        assert!(
9250            rendered.contains("0x09"),
9251            "diagnostic must name the offending byte in hex: {rendered:?}",
9252        );
9253    }
9254
9255    #[test]
9256    fn validate_rejects_path_fonte_with_caminho_carrying_backslash() {
9257        // The fail-before-pass-after pin for the canonical Windows-
9258        // path-separator paste footgun: an author who pastes a path
9259        // from Windows-Explorer's `Copy as path`, PowerShell's
9260        // `Get-Location`, or any CMD/Cygwin/MSYS shell prompt
9261        // produces `..\caixa-teia`-shape values that silently passed
9262        // every prior arm (`Path::is_absolute("..\\caixa-teia")` is
9263        // false; `\` is neither a leading-byte sentinel nor a
9264        // control byte). On POSIX resolvers the value rides through
9265        // `Path::join` as a literal directory name and fails at
9266        // resolve time with `No such file or directory`; on Windows
9267        // resolvers the value resolves to the parent's sibling — two
9268        // distinct directories for the byte-identical caixa.lisp.
9269        // The new arm moves the rejection to validate time and names
9270        // the offending dep + caminho verbatim.
9271        let d = dep_with_fonte(DepSource::Path {
9272            caminho: "..\\caixa-teia".into(),
9273        });
9274        let err = d.validate().unwrap_err();
9275        let DepError::FonteCaminhoBackslash { nome, caminho } = err else {
9276            panic!("expected FonteCaminhoBackslash, got {err:?}");
9277        };
9278        assert_eq!(nome, "caixa-teia");
9279        assert_eq!(caminho, "..\\caixa-teia");
9280    }
9281
9282    #[test]
9283    fn validate_rejects_path_fonte_with_caminho_carrying_windows_drive_letter() {
9284        // The Windows drive-letter paste shape (`C:\work\caixa-teia`
9285        // out of Explorer / `cd`-and-`pwd`-on-Windows). On POSIX
9286        // hosts `Path::is_absolute("C:\\work\\caixa-teia")` returns
9287        // false (POSIX absolute paths start with `/`, drive letters
9288        // are not a POSIX concept), so the b94fd83 absolute arm
9289        // doesn't fire; the value contains `\` bytes that this arm
9290        // now catches with the more self-locating Windows-path-
9291        // separator diagnostic. Pinned separately from the bare
9292        // `..\caixa-teia` shape so a future arm that targets only
9293        // leading-`..\` doesn't regress the drive-letter coverage.
9294        let d = dep_with_fonte(DepSource::Path {
9295            caminho: "C:\\work\\caixa-teia".into(),
9296        });
9297        let err = d.validate().unwrap_err();
9298        assert!(
9299            matches!(err, DepError::FonteCaminhoBackslash { .. }),
9300            "got {err:?}",
9301        );
9302    }
9303
9304    #[test]
9305    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_backslash() {
9306        // The trailing-`\` shape (`..\caixa-teia\` — the canonical
9307        // PowerShell tab-completion-on-a-directory append). Pinned
9308        // separately from the embedded-`\` shape so the gate's
9309        // contract is "any `\` anywhere", not "any `\` not at end".
9310        let d = dep_with_fonte(DepSource::Path {
9311            caminho: "..\\caixa-teia\\".into(),
9312        });
9313        let err = d.validate().unwrap_err();
9314        assert!(
9315            matches!(err, DepError::FonteCaminhoBackslash { .. }),
9316            "got {err:?}",
9317        );
9318    }
9319
9320    #[test]
9321    fn validate_accepts_path_fonte_with_caminho_carrying_legitimate_forward_slash() {
9322        // The positive-control pin: the gate targets `\` only,
9323        // never `/`. The canonical relative POSIX path
9324        // (`../caixa-teia/foo/bar`) must continue to validate cleanly
9325        // so legitimate nested-directory deps aren't broken. Pinned
9326        // so the gate doesn't accidentally widen to a "no path
9327        // separators at all" sweep.
9328        let d = dep_with_fonte(DepSource::Path {
9329            caminho: "../caixa-teia/foo/bar".into(),
9330        });
9331        d.validate().unwrap();
9332    }
9333
9334    #[test]
9335    fn fonte_caminho_control_char_fires_before_backslash() {
9336        // Cascade pin: the control-char arm structurally precedes the
9337        // backslash arm. A value like `"..\caixa\0teia"` probes
9338        // positive on both (`\` byte + NUL byte), but the control-
9339        // char diagnostic wins so the author sees the more self-
9340        // locating POSIX-syscall-rejected-byte diagnostic first
9341        // (NUL outright breaks `CString::new` at every `std::fs`
9342        // syscall boundary; the `\` divergence is the cross-OS-
9343        // separator axis). Mirrors the
9344        // `fonte_caminho_var_fires_before_control_char` cascade
9345        // discipline on the immediate-predecessor arm.
9346        let d = dep_with_fonte(DepSource::Path {
9347            caminho: "..\\caixa\0teia".into(),
9348        });
9349        let err = d.validate().unwrap_err();
9350        assert!(
9351            matches!(err, DepError::FonteCaminhoControlChar { .. }),
9352            "got {err:?}",
9353        );
9354    }
9355
9356    #[test]
9357    fn fonte_caminho_absolute_fires_before_backslash() {
9358        // Cascade pin on the load-bearing leading-byte arm: a leading
9359        // `/` value with embedded `\` (`/etc/passwd\foo`) routes
9360        // through `FonteCaminhoAbsolute` not `FonteCaminhoBackslash`
9361        // — the host-layout-leak diagnostic is the load-bearing
9362        // axis, the `\` byte is the secondary observation. Same
9363        // precedence logic as every prior leading-byte arm.
9364        let d = dep_with_fonte(DepSource::Path {
9365            caminho: "/etc/passwd\\foo".into(),
9366        });
9367        let err = d.validate().unwrap_err();
9368        assert!(
9369            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
9370            "got {err:?}",
9371        );
9372    }
9373
9374    #[test]
9375    fn fonte_caminho_var_fires_before_backslash() {
9376        // Cascade pin on the var-expansion arm: a leading-`$` value
9377        // with embedded `\` (`$WORKSPACE\caixa-teia` — the canonical
9378        // PowerShell-env-var paste-from-CI-manifest footgun) routes
9379        // through `FonteCaminhoVarExpansion` not `FonteCaminhoBackslash`.
9380        // The shell-expansion diagnostic is the more self-locating
9381        // axis since both the leading `$` and the embedded `\`
9382        // are Windows-shell artifacts but the `$` is the root-cause
9383        // surface (an author who removes the `$` is likely to leave
9384        // the `\` too).
9385        let d = dep_with_fonte(DepSource::Path {
9386            caminho: "$WORKSPACE\\caixa-teia".into(),
9387        });
9388        let err = d.validate().unwrap_err();
9389        assert!(
9390            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
9391            "got {err:?}",
9392        );
9393    }
9394
9395    #[test]
9396    fn fonte_caminho_backslash_diagnostic_carries_offending_dep_and_caminho() {
9397        // Diagnostic-shape pin (peer with the prior
9398        // `fonte_caminho_*_diagnostic_carries_*` payload assertions
9399        // on every preceding arm): the error's Display surfaces the
9400        // offending `:nome` and the offending `:caminho` verbatim
9401        // so a `feira lint` run can render the diagnostic without
9402        // re-parsing.
9403        let d = dep_with_fonte(DepSource::Path {
9404            caminho: "..\\caixa-teia".into(),
9405        });
9406        let rendered = d.validate().unwrap_err().to_string();
9407        assert!(
9408            rendered.contains("caixa-teia"),
9409            "diagnostic must name the offending dep: {rendered}",
9410        );
9411        assert!(
9412            rendered.contains("..\\caixa-teia"),
9413            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
9414        );
9415        assert!(
9416            rendered.contains('\\'),
9417            "diagnostic must reference the backslash footgun: {rendered:?}",
9418        );
9419    }
9420
9421    #[test]
9422    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_slash() {
9423        // The fail-before-pass-after pin for the canonical trailing-`/`
9424        // paste footgun: an author who shell-tab-completes a sibling
9425        // directory (every interactive shell — bash/zsh/fish/nushell —
9426        // appends `/` on tab-completing a directory) produces
9427        // `"../caixa-teia/"`-shape values that silently passed every
9428        // prior arm (the leading byte is `.`, no control bytes, no
9429        // backslash). `Path::join` resolves both shapes to the same
9430        // directory at the resolver, but the lacre embeds the value
9431        // verbatim and the BLAKE3 closures diverge across two
9432        // workstations whose authors differ only in tab-completion
9433        // habits.
9434        let d = dep_with_fonte(DepSource::Path {
9435            caminho: "../caixa-teia/".into(),
9436        });
9437        let err = d.validate().unwrap_err();
9438        let DepError::FonteCaminhoTrailingSlash { nome, caminho } = err else {
9439            panic!("expected FonteCaminhoTrailingSlash, got {err:?}");
9440        };
9441        assert_eq!(nome, "caixa-teia");
9442        assert_eq!(caminho, "../caixa-teia/");
9443    }
9444
9445    #[test]
9446    fn validate_rejects_path_fonte_with_caminho_carrying_bare_dot_slash() {
9447        // The `"./"` shape (the canonical "I meant the caixa.lisp's own
9448        // directory and tab-completed it" footgun). Pinned separately
9449        // from the canonical `"../caixa-teia/"` shape so the gate's
9450        // contract is "any trailing `/`", not "trailing `/` after a leaf
9451        // name".
9452        let d = dep_with_fonte(DepSource::Path {
9453            caminho: "./".into(),
9454        });
9455        let err = d.validate().unwrap_err();
9456        assert!(
9457            matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
9458            "got {err:?}",
9459        );
9460    }
9461
9462    #[test]
9463    fn validate_rejects_path_fonte_with_caminho_carrying_consecutive_trailing_slashes() {
9464        // The `"foo//"` shape (the canonical "I pasted from a CI manifest
9465        // that double-templated `${VAR}/` over an already-`/`-suffixed
9466        // path" footgun). The gate fires on the last byte being `/`
9467        // regardless of how many `/` precede it; the arm contract is
9468        // "the value ends with `/`", structurally.
9469        let d = dep_with_fonte(DepSource::Path {
9470            caminho: "../caixa-teia//".into(),
9471        });
9472        let err = d.validate().unwrap_err();
9473        assert!(
9474            matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
9475            "got {err:?}",
9476        );
9477    }
9478
9479    #[test]
9480    fn validate_rejects_path_fonte_with_caminho_carrying_dotdot_trailing_slash() {
9481        // The `"../"` shape (the canonical "I want the parent" tab-
9482        // completion footgun on a bare `..` path). Pinned separately so
9483        // the gate doesn't accidentally narrow to "trailing `/` only on
9484        // multi-segment paths".
9485        let d = dep_with_fonte(DepSource::Path {
9486            caminho: "../".into(),
9487        });
9488        let err = d.validate().unwrap_err();
9489        assert!(
9490            matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
9491            "got {err:?}",
9492        );
9493    }
9494
9495    #[test]
9496    fn validate_accepts_path_fonte_with_caminho_carrying_internal_slashes() {
9497        // The positive-control pin: the gate targets the trailing byte
9498        // only, never internal `/` separators. The canonical nested
9499        // relative POSIX path (`"../caixa-teia/foo/bar"`) must continue
9500        // to validate cleanly so legitimate deeply-nested deps aren't
9501        // broken. Pinned so the gate doesn't accidentally widen to a
9502        // "no `/` separators anywhere" sweep that would defeat the
9503        // entire path-fonte author surface.
9504        let d = dep_with_fonte(DepSource::Path {
9505            caminho: "../caixa-teia/foo/bar".into(),
9506        });
9507        d.validate().unwrap();
9508    }
9509
9510    #[test]
9511    fn validate_accepts_path_fonte_with_caminho_carrying_bare_dot() {
9512        // The positive-control pin on the degenerate single-`.` shape
9513        // (the canonical "the caixa.lisp's own directory" idiom). The
9514        // gate fires on the trailing byte being `/`, not on the path
9515        // being short, so `"."` (one byte, not `/`) must continue to
9516        // validate cleanly.
9517        let d = dep_with_fonte(DepSource::Path {
9518            caminho: ".".into(),
9519        });
9520        d.validate().unwrap();
9521    }
9522
9523    #[test]
9524    fn fonte_caminho_control_char_fires_before_trailing_slash() {
9525        // Cascade pin: the control-char arm structurally precedes the
9526        // trailing-slash arm. A value like `"../foo\n/"` ends in `/`
9527        // but the embedded LF (`0x0A`) is the load-bearing diagnostic
9528        // (control bytes are the paste-from-multiline-doc footgun the
9529        // d624c8d arm already closes). Mirrors the
9530        // `fonte_caminho_control_char_fires_before_backslash` cascade
9531        // discipline on the immediate-predecessor arm.
9532        let d = dep_with_fonte(DepSource::Path {
9533            caminho: "../foo\n/".into(),
9534        });
9535        let err = d.validate().unwrap_err();
9536        assert!(
9537            matches!(err, DepError::FonteCaminhoControlChar { .. }),
9538            "got {err:?}",
9539        );
9540    }
9541
9542    #[test]
9543    fn fonte_caminho_backslash_fires_before_trailing_slash() {
9544        // Cascade pin on the backslash arm: a value like `"..\foo/"`
9545        // ends in `/` but the embedded `\` is the load-bearing
9546        // diagnostic (the cross-host-OS-separator divergence vector
9547        // the 3a4e1d7 arm closes). Same precedence logic as the prior
9548        // narrower-diagnostic-first cascade.
9549        let d = dep_with_fonte(DepSource::Path {
9550            caminho: "..\\caixa-teia/".into(),
9551        });
9552        let err = d.validate().unwrap_err();
9553        assert!(
9554            matches!(err, DepError::FonteCaminhoBackslash { .. }),
9555            "got {err:?}",
9556        );
9557    }
9558
9559    #[test]
9560    fn fonte_caminho_absolute_fires_before_trailing_slash() {
9561        // Cascade pin on the load-bearing leading-byte arm: a leading
9562        // `/` value with a trailing `/` (`"/etc/passwd/"`) routes
9563        // through `FonteCaminhoAbsolute` not `FonteCaminhoTrailingSlash`
9564        // — the host-layout-leak diagnostic is the load-bearing axis,
9565        // the trailing `/` is the secondary observation. Same
9566        // precedence logic as every prior leading-byte arm.
9567        let d = dep_with_fonte(DepSource::Path {
9568            caminho: "/etc/passwd/".into(),
9569        });
9570        let err = d.validate().unwrap_err();
9571        assert!(
9572            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
9573            "got {err:?}",
9574        );
9575    }
9576
9577    #[test]
9578    fn fonte_caminho_trailing_slash_diagnostic_carries_offending_dep_and_caminho() {
9579        // Diagnostic-shape pin (peer with the prior
9580        // `fonte_caminho_*_diagnostic_carries_*` payload assertions on
9581        // every preceding arm): the error's Display surfaces the
9582        // offending `:nome` and the offending `:caminho` verbatim so a
9583        // `feira lint` run can render the diagnostic without re-parsing.
9584        let d = dep_with_fonte(DepSource::Path {
9585            caminho: "../caixa-teia/".into(),
9586        });
9587        let rendered = d.validate().unwrap_err().to_string();
9588        assert!(
9589            rendered.contains("caixa-teia"),
9590            "diagnostic must name the offending dep: {rendered}",
9591        );
9592        assert!(
9593            rendered.contains("../caixa-teia/"),
9594            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
9595        );
9596        assert!(
9597            rendered.contains("trailing"),
9598            "diagnostic must reference the trailing-slash footgun: {rendered:?}",
9599        );
9600    }
9601
9602    // -- :caminho shell-redirection metacharacter arm -----------------------
9603
9604    #[test]
9605    fn validate_rejects_path_fonte_with_caminho_carrying_gt_redirection() {
9606        // The fail-before-pass-after pin for the canonical output-redirection
9607        // paste footgun: an author copies a shell pipeline tail
9608        // (`"../caixa-teia>build.log"` — the canonical "I selected the whole
9609        // line including the `> build.log` redirect" idiom) and silently
9610        // passed every prior arm (`Path::is_absolute` false on `..`, no
9611        // control bytes, no backslash, doesn't end in `/`). The lacre
9612        // embedded the value verbatim, the resolver folded it through
9613        // `Path::join` looking for a literal `./../caixa-teia>build.log`
9614        // subdirectory, and the failure surfaced at resolve time with a
9615        // non-self-locating `No such file or directory` error. The new arm
9616        // moves the rejection to validate time and names the offending dep
9617        // + caminho + byte verbatim.
9618        let d = dep_with_fonte(DepSource::Path {
9619            caminho: "../caixa-teia>build.log".into(),
9620        });
9621        let err = d.validate().unwrap_err();
9622        let DepError::FonteCaminhoShellRedirection {
9623            nome,
9624            caminho,
9625            byte,
9626        } = err
9627        else {
9628            panic!("expected FonteCaminhoShellRedirection, got {err:?}");
9629        };
9630        assert_eq!(nome, "caixa-teia");
9631        assert_eq!(caminho, "../caixa-teia>build.log");
9632        assert_eq!(byte, b'>');
9633    }
9634
9635    #[test]
9636    fn validate_rejects_path_fonte_with_caminho_carrying_lt_redirection() {
9637        // The symmetric input-redirection paste shape
9638        // (`"../caixa-teia<input.lisp"` — the canonical "I copied a
9639        // `command < input.lisp` line from a tatara-lisp REPL log"
9640        // idiom). Pinned separately from the `>` shape so the gate's
9641        // contract is "any `<` or `>` anywhere", not single-byte coverage.
9642        let d = dep_with_fonte(DepSource::Path {
9643            caminho: "../caixa-teia<input.lisp".into(),
9644        });
9645        let err = d.validate().unwrap_err();
9646        let DepError::FonteCaminhoShellRedirection { byte, .. } = err else {
9647            panic!("expected FonteCaminhoShellRedirection, got {err:?}");
9648        };
9649        assert_eq!(byte, b'<');
9650    }
9651
9652    #[test]
9653    fn validate_rejects_path_fonte_with_caminho_carrying_leading_gt_redirection() {
9654        // Leading-position `>` shape (`">../caixa-teia"` — the degenerate
9655        // "I forgot the source side of the redirect" idiom). Pinned
9656        // separately from the embedded-byte shapes so the gate covers
9657        // every position, not only mid-path.
9658        let d = dep_with_fonte(DepSource::Path {
9659            caminho: ">../caixa-teia".into(),
9660        });
9661        let err = d.validate().unwrap_err();
9662        assert!(
9663            matches!(
9664                err,
9665                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
9666            ),
9667            "got {err:?}",
9668        );
9669    }
9670
9671    #[test]
9672    fn validate_rejects_path_fonte_with_caminho_carrying_double_gt_append() {
9673        // The bash append-redirection shape (`"../caixa-teia>>build.log"` —
9674        // the canonical "I copied a `>>` append redirect" idiom). The arm
9675        // fires on the first `>` encountered; pinned so a future arm that
9676        // tries to distinguish `>` from `>>` doesn't break the broader
9677        // contract.
9678        let d = dep_with_fonte(DepSource::Path {
9679            caminho: "../caixa-teia>>build.log".into(),
9680        });
9681        let err = d.validate().unwrap_err();
9682        assert!(
9683            matches!(
9684                err,
9685                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
9686            ),
9687            "got {err:?}",
9688        );
9689    }
9690
9691    #[test]
9692    fn validate_accepts_path_fonte_with_caminho_carrying_no_redirection() {
9693        // The positive-control pin: the gate targets only `<` / `>`,
9694        // never adjacent printable ASCII or POSIX-valid bytes. The
9695        // canonical relative POSIX path (`"../caixa-teia"`) and a
9696        // nested deeply-pathed variant (`"../caixa-teia/foo/bar"`) must
9697        // continue to validate cleanly so the gate doesn't widen to a
9698        // "no printable punctuation anywhere" sweep that would defeat
9699        // the entire path-fonte author surface.
9700        let d = dep_with_fonte(DepSource::Path {
9701            caminho: "../caixa-teia/foo/bar".into(),
9702        });
9703        d.validate().unwrap();
9704    }
9705
9706    #[test]
9707    fn fonte_caminho_backslash_fires_before_shell_redirection() {
9708        // Cascade pin on the immediate-predecessor arm: a value carrying
9709        // both `\` and `<` / `>` (`"..\caixa-teia>build.log"` — the
9710        // canonical "I pasted a Windows-shell command with output
9711        // redirect" footgun) routes through `FonteCaminhoBackslash` not
9712        // `FonteCaminhoShellRedirection`. The cross-host-OS-separator
9713        // divergence is the load-bearing axis (an author who removes
9714        // the `\` is the root-cause edit; the `>` falls away in the
9715        // same edit since it's downstream of the Windows-shell
9716        // convention).
9717        let d = dep_with_fonte(DepSource::Path {
9718            caminho: "..\\caixa-teia>build.log".into(),
9719        });
9720        let err = d.validate().unwrap_err();
9721        assert!(
9722            matches!(err, DepError::FonteCaminhoBackslash { .. }),
9723            "got {err:?}",
9724        );
9725    }
9726
9727    #[test]
9728    fn fonte_caminho_control_char_fires_before_shell_redirection() {
9729        // Cascade pin on the embedded-control-byte arm: a value carrying
9730        // both a control byte and `<` / `>` (`"../foo\n>bar"` — the
9731        // canonical paste-from-multiline-doc footgun where a newline
9732        // landed mid-caminho) routes through `FonteCaminhoControlChar`
9733        // not `FonteCaminhoShellRedirection`. The POSIX-syscall-
9734        // rejected-byte / NUL-`CString::new`-fail diagnostic is the
9735        // load-bearing axis on every value that probes positive for
9736        // both — mirrors the cascade discipline on every prior arm.
9737        let d = dep_with_fonte(DepSource::Path {
9738            caminho: "../foo\n>bar".into(),
9739        });
9740        let err = d.validate().unwrap_err();
9741        assert!(
9742            matches!(err, DepError::FonteCaminhoControlChar { .. }),
9743            "got {err:?}",
9744        );
9745    }
9746
9747    #[test]
9748    fn fonte_caminho_absolute_fires_before_shell_redirection() {
9749        // Cascade pin on the load-bearing leading-byte arm: a leading
9750        // `/` value with embedded `<` / `>` (`"/etc/passwd>out"`)
9751        // routes through `FonteCaminhoAbsolute` not
9752        // `FonteCaminhoShellRedirection` — the host-layout-leak
9753        // diagnostic is the load-bearing axis, the `>` byte is the
9754        // secondary observation. Same precedence logic as every prior
9755        // leading-byte arm.
9756        let d = dep_with_fonte(DepSource::Path {
9757            caminho: "/etc/passwd>out".into(),
9758        });
9759        let err = d.validate().unwrap_err();
9760        assert!(
9761            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
9762            "got {err:?}",
9763        );
9764    }
9765
9766    #[test]
9767    fn fonte_caminho_shell_redirection_fires_before_trailing_slash() {
9768        // Cascade pin on the immediate-successor arm: a value carrying
9769        // both `<` / `>` and a trailing `/` (`"../foo></"` — the
9770        // canonical "I tab-completed a path that already had a
9771        // redirect" footgun) routes through `FonteCaminhoShellRedirection`
9772        // not `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
9773        // the more semantic-locating axis (an author who removes the
9774        // `<` / `>` typically also drops the trailing separator since
9775        // both are paste-from-shell artifacts).
9776        let d = dep_with_fonte(DepSource::Path {
9777            caminho: "../foo></".into(),
9778        });
9779        let err = d.validate().unwrap_err();
9780        assert!(
9781            matches!(
9782                err,
9783                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
9784            ),
9785            "got {err:?}",
9786        );
9787    }
9788
9789    #[test]
9790    fn fonte_caminho_shell_redirection_diagnostic_carries_offending_dep_caminho_byte() {
9791        // Diagnostic-shape pin (peer with
9792        // `fonte_caminho_control_diagnostic_carries_offending_dep_caminho_byte`'s
9793        // payload assertion on the closest peer arm that also carries a
9794        // `byte` field): the error's Display surfaces the offending
9795        // `:nome`, the offending `:caminho` verbatim, and the offending
9796        // byte in hex (`0x3c` for `<`, `0x3e` for `>`) so a `feira lint`
9797        // run can render the diagnostic without re-parsing.
9798        let d = dep_with_fonte(DepSource::Path {
9799            caminho: "../caixa-teia>build.log".into(),
9800        });
9801        let rendered = d.validate().unwrap_err().to_string();
9802        assert!(
9803            rendered.contains("caixa-teia"),
9804            "diagnostic must name the offending dep: {rendered}",
9805        );
9806        assert!(
9807            rendered.contains("../caixa-teia>build.log"),
9808            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
9809        );
9810        assert!(
9811            rendered.contains("0x3e"),
9812            "diagnostic must name the offending byte in hex: {rendered:?}",
9813        );
9814        assert!(
9815            rendered.contains("redirection"),
9816            "diagnostic must name the shell-redirection footgun: {rendered:?}",
9817        );
9818    }
9819
9820    // -- :caminho shell-pipe metacharacter arm ----------------------------
9821
9822    #[test]
9823    fn validate_rejects_path_fonte_with_caminho_carrying_pipe() {
9824        // The fail-before-pass-after pin for the canonical shell-pipe
9825        // paste footgun: an author copies a shell-history line
9826        // (`"../caixa-teia | grep foo"` — the canonical "I selected
9827        // the whole `ls dir | grep` line out of zsh history") and
9828        // silently passed every prior arm (`Path::is_absolute` false
9829        // on `..`, no control bytes, no backslash, no `<` / `>`,
9830        // doesn't end in `/`). The lacre embedded the value verbatim,
9831        // the resolver folded it through `Path::join` looking for a
9832        // literal `./../caixa-teia | grep foo` subdirectory, and the
9833        // failure surfaced at resolve time with a non-self-locating
9834        // `No such file or directory` error. The new arm moves the
9835        // rejection to validate time and names the offending dep +
9836        // caminho verbatim.
9837        let d = dep_with_fonte(DepSource::Path {
9838            caminho: "../caixa-teia | grep foo".into(),
9839        });
9840        let err = d.validate().unwrap_err();
9841        let DepError::FonteCaminhoShellPipe { nome, caminho } = err else {
9842            panic!("expected FonteCaminhoShellPipe, got {err:?}");
9843        };
9844        assert_eq!(nome, "caixa-teia");
9845        assert_eq!(caminho, "../caixa-teia | grep foo");
9846    }
9847
9848    #[test]
9849    fn validate_rejects_path_fonte_with_caminho_carrying_leading_pipe() {
9850        // Leading-position `|` shape (`"|../caixa-teia"` — the
9851        // degenerate "I forgot the source side of the pipe" idiom).
9852        // Pinned separately from the embedded-byte shape so the gate
9853        // covers every position, not only mid-path.
9854        let d = dep_with_fonte(DepSource::Path {
9855            caminho: "|../caixa-teia".into(),
9856        });
9857        let err = d.validate().unwrap_err();
9858        assert!(
9859            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
9860            "got {err:?}",
9861        );
9862    }
9863
9864    #[test]
9865    fn validate_rejects_path_fonte_with_caminho_carrying_double_pipe_or() {
9866        // The bash short-circuit-OR shape (`"../caixa-teia||fallback"`
9867        // — the canonical "I copied a `cmd-a || cmd-b` fallback line"
9868        // idiom). The arm fires on the first `|` encountered; pinned
9869        // so a future arm that tries to distinguish `|` from `||`
9870        // doesn't break the broader contract.
9871        let d = dep_with_fonte(DepSource::Path {
9872            caminho: "../caixa-teia||fallback".into(),
9873        });
9874        let err = d.validate().unwrap_err();
9875        assert!(
9876            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
9877            "got {err:?}",
9878        );
9879    }
9880
9881    #[test]
9882    fn validate_accepts_path_fonte_with_caminho_carrying_no_pipe() {
9883        // The positive-control pin: the gate targets only `|`, never
9884        // adjacent printable ASCII or POSIX-valid bytes. The canonical
9885        // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
9886        // pathed variant with adjacent printable punctuation
9887        // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
9888        // cleanly so the gate doesn't widen to a "no printable
9889        // punctuation anywhere" sweep that would defeat the entire
9890        // path-fonte author surface.
9891        let d = dep_with_fonte(DepSource::Path {
9892            caminho: "../caixa-teia/sub-dir.v2".into(),
9893        });
9894        d.validate().unwrap();
9895    }
9896
9897    #[test]
9898    fn fonte_caminho_shell_redirection_fires_before_shell_pipe() {
9899        // Cascade pin on the immediate-predecessor arm: a value carrying
9900        // both `<` / `>` and `|` (`"../caixa-teia<input|tee"` — the
9901        // canonical "I pasted a `cmd < input | tee` pipeline tail"
9902        // footgun) routes through `FonteCaminhoShellRedirection` not
9903        // `FonteCaminhoShellPipe`. The input/output redirection
9904        // metachar carries the more self-locating `byte: u8` payload
9905        // (it names which of `<` or `>` triggered), so the prior arm
9906        // wins on every probe-as-both value — same cascade discipline
9907        // every prior `:caminho` arm establishes.
9908        let d = dep_with_fonte(DepSource::Path {
9909            caminho: "../caixa-teia<input|tee".into(),
9910        });
9911        let err = d.validate().unwrap_err();
9912        assert!(
9913            matches!(
9914                err,
9915                DepError::FonteCaminhoShellRedirection { byte: b'<', .. }
9916            ),
9917            "got {err:?}",
9918        );
9919    }
9920
9921    #[test]
9922    fn fonte_caminho_backslash_fires_before_shell_pipe() {
9923        // Cascade pin on the upstream backslash arm: a value carrying
9924        // both `\` and `|` (`"..\caixa-teia|tee"` — the canonical
9925        // "I pasted a Windows-shell command with pipe to tee"
9926        // footgun) routes through `FonteCaminhoBackslash` not
9927        // `FonteCaminhoShellPipe`. The cross-host-OS-separator
9928        // divergence is the load-bearing axis on every probe-as-both
9929        // value (an author who removes the `\` is the root-cause edit;
9930        // the `|` falls away in the same edit since it's downstream of
9931        // the Windows-shell convention).
9932        let d = dep_with_fonte(DepSource::Path {
9933            caminho: "..\\caixa-teia|tee".into(),
9934        });
9935        let err = d.validate().unwrap_err();
9936        assert!(
9937            matches!(err, DepError::FonteCaminhoBackslash { .. }),
9938            "got {err:?}",
9939        );
9940    }
9941
9942    #[test]
9943    fn fonte_caminho_control_char_fires_before_shell_pipe() {
9944        // Cascade pin on the embedded-control-byte arm: a value
9945        // carrying both a control byte and `|` (`"../foo\n|bar"` —
9946        // the canonical paste-from-multiline-doc footgun where a
9947        // newline landed mid-caminho) routes through
9948        // `FonteCaminhoControlChar` not `FonteCaminhoShellPipe`. The
9949        // POSIX-syscall-rejected-byte / NUL-`CString::new`-fail
9950        // diagnostic is the load-bearing axis on every value that
9951        // probes positive for both — mirrors the cascade discipline
9952        // on every prior arm.
9953        let d = dep_with_fonte(DepSource::Path {
9954            caminho: "../foo\n|bar".into(),
9955        });
9956        let err = d.validate().unwrap_err();
9957        assert!(
9958            matches!(err, DepError::FonteCaminhoControlChar { .. }),
9959            "got {err:?}",
9960        );
9961    }
9962
9963    #[test]
9964    fn fonte_caminho_absolute_fires_before_shell_pipe() {
9965        // Cascade pin on the load-bearing leading-byte arm: a leading
9966        // `/` value with embedded `|` (`"/etc/passwd|tee"`) routes
9967        // through `FonteCaminhoAbsolute` not `FonteCaminhoShellPipe`
9968        // — the host-layout-leak diagnostic is the load-bearing axis,
9969        // the `|` byte is the secondary observation. Same precedence
9970        // logic as every prior leading-byte arm.
9971        let d = dep_with_fonte(DepSource::Path {
9972            caminho: "/etc/passwd|tee".into(),
9973        });
9974        let err = d.validate().unwrap_err();
9975        assert!(
9976            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
9977            "got {err:?}",
9978        );
9979    }
9980
9981    #[test]
9982    fn fonte_caminho_shell_pipe_fires_before_trailing_slash() {
9983        // Cascade pin on the immediate-successor arm: a value carrying
9984        // both `|` and a trailing `/` (`"../foo|tee/"` — the canonical
9985        // "I tab-completed a path that already had a pipeline tail"
9986        // footgun) routes through `FonteCaminhoShellPipe` not
9987        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
9988        // the more semantic-locating axis (an author who removes the
9989        // `|` typically also drops the trailing separator since both
9990        // are paste-from-shell artifacts).
9991        let d = dep_with_fonte(DepSource::Path {
9992            caminho: "../foo|tee/".into(),
9993        });
9994        let err = d.validate().unwrap_err();
9995        assert!(
9996            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
9997            "got {err:?}",
9998        );
9999    }
10000
10001    #[test]
10002    fn fonte_caminho_shell_pipe_diagnostic_carries_offending_dep_and_caminho() {
10003        // Diagnostic-shape pin (peer with
10004        // `fonte_caminho_backslash_diagnostic_carries_offending_dep_and_caminho`
10005        // on the closest single-byte peer arm): the error's Display
10006        // surfaces the offending `:nome` and the offending `:caminho`
10007        // verbatim, and names the shell-pipe footgun explicitly so a
10008        // `feira lint` run can render the diagnostic without
10009        // re-parsing.
10010        let d = dep_with_fonte(DepSource::Path {
10011            caminho: "../caixa-teia | grep foo".into(),
10012        });
10013        let rendered = d.validate().unwrap_err().to_string();
10014        assert!(
10015            rendered.contains("caixa-teia"),
10016            "diagnostic must name the offending dep: {rendered}",
10017        );
10018        assert!(
10019            rendered.contains("../caixa-teia | grep foo"),
10020            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10021        );
10022        assert!(
10023            rendered.contains('|'),
10024            "diagnostic must reference the pipe footgun: {rendered:?}",
10025        );
10026        assert!(
10027            rendered.contains("pipe"),
10028            "diagnostic must name the shell-pipe footgun: {rendered:?}",
10029        );
10030    }
10031
10032    // -- :caminho shell-command-separator metacharacter arm ---------------
10033
10034    #[test]
10035    fn validate_rejects_path_fonte_with_caminho_carrying_semicolon() {
10036        // The fail-before-pass-after pin for the canonical shell-command-
10037        // separator paste footgun: an author copies a shell one-liner
10038        // (`"../caixa-teia; rm -rf build"` — the canonical "I selected the
10039        // whole `cd path; do-thing` chain out of a shell-history block")
10040        // and silently passed every prior arm (`Path::is_absolute` false
10041        // on `..`, no control bytes, no backslash, no `<` / `>`, no `|`,
10042        // doesn't end in `/`). The lacre embedded the value verbatim, the
10043        // resolver folded it through `Path::join` looking for a literal
10044        // `./../caixa-teia; rm -rf build` subdirectory, and the failure
10045        // surfaced at resolve time with a non-self-locating `No such file
10046        // or directory` error. The new arm moves the rejection to validate
10047        // time and names the offending dep + caminho verbatim.
10048        let d = dep_with_fonte(DepSource::Path {
10049            caminho: "../caixa-teia; rm -rf build".into(),
10050        });
10051        let err = d.validate().unwrap_err();
10052        let DepError::FonteCaminhoShellSemicolon { nome, caminho } = err else {
10053            panic!("expected FonteCaminhoShellSemicolon, got {err:?}");
10054        };
10055        assert_eq!(nome, "caixa-teia");
10056        assert_eq!(caminho, "../caixa-teia; rm -rf build");
10057    }
10058
10059    #[test]
10060    fn validate_rejects_path_fonte_with_caminho_carrying_leading_semicolon() {
10061        // Leading-position `;` shape (`";../caixa-teia"` — the degenerate
10062        // "I forgot the prior command side of the separator" idiom).
10063        // Pinned separately from the embedded-byte shape so the gate
10064        // covers every position, not only mid-path.
10065        let d = dep_with_fonte(DepSource::Path {
10066            caminho: ";../caixa-teia".into(),
10067        });
10068        let err = d.validate().unwrap_err();
10069        assert!(
10070            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
10071            "got {err:?}",
10072        );
10073    }
10074
10075    #[test]
10076    fn validate_rejects_path_fonte_with_caminho_carrying_double_semicolon() {
10077        // The POSIX `case` arm `;;` terminator shape
10078        // (`"../caixa-teia;;next"` — the canonical "I copied a `case`
10079        // arm tail" idiom). The arm fires on the first `;` encountered;
10080        // pinned so a future arm that tries to distinguish `;` from `;;`
10081        // doesn't break the broader contract.
10082        let d = dep_with_fonte(DepSource::Path {
10083            caminho: "../caixa-teia;;next".into(),
10084        });
10085        let err = d.validate().unwrap_err();
10086        assert!(
10087            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
10088            "got {err:?}",
10089        );
10090    }
10091
10092    #[test]
10093    fn validate_accepts_path_fonte_with_caminho_carrying_no_semicolon() {
10094        // The positive-control pin: the gate targets only `;`, never
10095        // adjacent printable ASCII or POSIX-valid bytes. The canonical
10096        // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
10097        // pathed variant with adjacent printable punctuation
10098        // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
10099        // cleanly so the gate doesn't widen to a "no printable
10100        // punctuation anywhere" sweep that would defeat the entire
10101        // path-fonte author surface.
10102        let d = dep_with_fonte(DepSource::Path {
10103            caminho: "../caixa-teia/sub-dir.v2".into(),
10104        });
10105        d.validate().unwrap();
10106    }
10107
10108    #[test]
10109    fn fonte_caminho_shell_pipe_fires_before_shell_semicolon() {
10110        // Cascade pin on the immediate-predecessor arm: a value carrying
10111        // both `|` and `;` (`"../caixa-teia | tee; rm"` — the canonical
10112        // "I pasted a `cmd | tee; cleanup` chain" footgun) routes through
10113        // `FonteCaminhoShellPipe` not `FonteCaminhoShellSemicolon`. The
10114        // pipeline-tail paste is the load-bearing root-cause edit on
10115        // every probe-as-both value (an author who removes the `|`
10116        // typically also drops the trailing `; cleanup` since both are
10117        // the same paste-from-shell-history artifact) — same cascade
10118        // discipline every prior `:caminho` arm establishes.
10119        let d = dep_with_fonte(DepSource::Path {
10120            caminho: "../caixa-teia | tee; rm".into(),
10121        });
10122        let err = d.validate().unwrap_err();
10123        assert!(
10124            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10125            "got {err:?}",
10126        );
10127    }
10128
10129    #[test]
10130    fn fonte_caminho_shell_redirection_fires_before_shell_semicolon() {
10131        // Cascade pin on the upstream shell-redirection arm: a value
10132        // carrying both `<` / `>` and `;` (`"../caixa-teia>log; rm"` —
10133        // the canonical "I pasted a `cmd > log; cleanup` chain"
10134        // footgun) routes through `FonteCaminhoShellRedirection` not
10135        // `FonteCaminhoShellSemicolon`. The input/output redirection
10136        // metachar carries the more self-locating `byte: u8` payload
10137        // (it names which of `<` or `>` triggered), so the prior arm
10138        // wins on every probe-as-both value.
10139        let d = dep_with_fonte(DepSource::Path {
10140            caminho: "../caixa-teia>log; rm".into(),
10141        });
10142        let err = d.validate().unwrap_err();
10143        assert!(
10144            matches!(
10145                err,
10146                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
10147            ),
10148            "got {err:?}",
10149        );
10150    }
10151
10152    #[test]
10153    fn fonte_caminho_backslash_fires_before_shell_semicolon() {
10154        // Cascade pin on the upstream backslash arm: a value carrying
10155        // both `\` and `;` (`"..\caixa-teia;rm"` — the canonical "I
10156        // pasted a Windows-shell `cd ..\path; cleanup` chain") routes
10157        // through `FonteCaminhoBackslash` not `FonteCaminhoShellSemicolon`.
10158        // The cross-host-OS-separator divergence is the load-bearing axis
10159        // on every probe-as-both value (an author who removes the `\` is
10160        // the root-cause edit; the `;` falls away in the same edit since
10161        // it's downstream of the Windows-shell convention).
10162        let d = dep_with_fonte(DepSource::Path {
10163            caminho: "..\\caixa-teia;rm".into(),
10164        });
10165        let err = d.validate().unwrap_err();
10166        assert!(
10167            matches!(err, DepError::FonteCaminhoBackslash { .. }),
10168            "got {err:?}",
10169        );
10170    }
10171
10172    #[test]
10173    fn fonte_caminho_control_char_fires_before_shell_semicolon() {
10174        // Cascade pin on the embedded-control-byte arm: a value carrying
10175        // both a control byte and `;` (`"../foo\n;bar"` — the canonical
10176        // paste-from-multiline-doc footgun where a newline landed mid-
10177        // caminho) routes through `FonteCaminhoControlChar` not
10178        // `FonteCaminhoShellSemicolon`. The POSIX-syscall-rejected-byte
10179        // / NUL-`CString::new`-fail diagnostic is the load-bearing axis
10180        // on every value that probes positive for both — mirrors the
10181        // cascade discipline on every prior arm.
10182        let d = dep_with_fonte(DepSource::Path {
10183            caminho: "../foo\n;bar".into(),
10184        });
10185        let err = d.validate().unwrap_err();
10186        assert!(
10187            matches!(err, DepError::FonteCaminhoControlChar { .. }),
10188            "got {err:?}",
10189        );
10190    }
10191
10192    #[test]
10193    fn fonte_caminho_absolute_fires_before_shell_semicolon() {
10194        // Cascade pin on the load-bearing leading-byte arm: a leading
10195        // `/` value with embedded `;` (`"/etc/passwd;rm"`) routes
10196        // through `FonteCaminhoAbsolute` not `FonteCaminhoShellSemicolon`
10197        // — the host-layout-leak diagnostic is the load-bearing axis,
10198        // the `;` byte is the secondary observation. Same precedence
10199        // logic as every prior leading-byte arm.
10200        let d = dep_with_fonte(DepSource::Path {
10201            caminho: "/etc/passwd;rm".into(),
10202        });
10203        let err = d.validate().unwrap_err();
10204        assert!(
10205            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10206            "got {err:?}",
10207        );
10208    }
10209
10210    #[test]
10211    fn fonte_caminho_shell_semicolon_fires_before_trailing_slash() {
10212        // Cascade pin on the immediate-successor arm: a value carrying
10213        // both `;` and a trailing `/` (`"../foo;rm/"` — the canonical
10214        // "I tab-completed a path that already had a `; cleanup` tail"
10215        // footgun) routes through `FonteCaminhoShellSemicolon` not
10216        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
10217        // the more semantic-locating axis (an author who removes the
10218        // `;` typically also drops the trailing separator since both
10219        // are paste-from-shell artifacts).
10220        let d = dep_with_fonte(DepSource::Path {
10221            caminho: "../foo;rm/".into(),
10222        });
10223        let err = d.validate().unwrap_err();
10224        assert!(
10225            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
10226            "got {err:?}",
10227        );
10228    }
10229
10230    #[test]
10231    fn fonte_caminho_shell_semicolon_diagnostic_carries_offending_dep_and_caminho() {
10232        // Diagnostic-shape pin (peer with
10233        // `fonte_caminho_shell_pipe_diagnostic_carries_offending_dep_and_caminho`
10234        // on the closest single-byte peer arm): the error's Display
10235        // surfaces the offending `:nome` and the offending `:caminho`
10236        // verbatim, and names the shell-command-separator footgun
10237        // explicitly so a `feira lint` run can render the diagnostic
10238        // without re-parsing.
10239        let d = dep_with_fonte(DepSource::Path {
10240            caminho: "../caixa-teia; rm -rf build".into(),
10241        });
10242        let rendered = d.validate().unwrap_err().to_string();
10243        assert!(
10244            rendered.contains("caixa-teia"),
10245            "diagnostic must name the offending dep: {rendered}",
10246        );
10247        assert!(
10248            rendered.contains("../caixa-teia; rm -rf build"),
10249            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10250        );
10251        assert!(
10252            rendered.contains(';'),
10253            "diagnostic must reference the semicolon footgun: {rendered:?}",
10254        );
10255        assert!(
10256            rendered.contains("command-separator"),
10257            "diagnostic must name the shell-command-separator footgun: {rendered:?}",
10258        );
10259    }
10260
10261    #[test]
10262    fn validate_rejects_path_fonte_with_caminho_carrying_ampersand() {
10263        // The fail-before-pass-after pin for the canonical shell-
10264        // background-task paste footgun: an author copies a shell one-
10265        // liner (`"../caixa-teia & sleep 1"` — the canonical "I selected
10266        // the whole `cd path & sleep 1` background-launch out of a
10267        // shell-history block") and silently passed every prior arm
10268        // (`Path::is_absolute` false on `..`, no control bytes, no
10269        // backslash, no `<` / `>`, no `|`, no `;`, doesn't end in `/`).
10270        // The lacre embedded the value verbatim, the resolver folded it
10271        // through `Path::join` looking for a literal `./../caixa-teia &
10272        // sleep 1` subdirectory, and the failure surfaced at resolve
10273        // time with a non-self-locating `No such file or directory`
10274        // error. The new arm moves the rejection to validate time and
10275        // names the offending dep + caminho verbatim.
10276        let d = dep_with_fonte(DepSource::Path {
10277            caminho: "../caixa-teia & sleep 1".into(),
10278        });
10279        let err = d.validate().unwrap_err();
10280        let DepError::FonteCaminhoShellBackground { nome, caminho } = err else {
10281            panic!("expected FonteCaminhoShellBackground, got {err:?}");
10282        };
10283        assert_eq!(nome, "caixa-teia");
10284        assert_eq!(caminho, "../caixa-teia & sleep 1");
10285    }
10286
10287    #[test]
10288    fn validate_rejects_path_fonte_with_caminho_carrying_leading_ampersand() {
10289        // Leading-position `&` shape (`"&../caixa-teia"` — the
10290        // degenerate "I forgot the prior command side of the
10291        // background terminator" idiom). Pinned separately from the
10292        // embedded-byte shape so the gate covers every position, not
10293        // only mid-path.
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::FonteCaminhoShellBackground { .. }),
10300            "got {err:?}",
10301        );
10302    }
10303
10304    #[test]
10305    fn validate_rejects_path_fonte_with_caminho_carrying_double_ampersand() {
10306        // The logical-AND `&&` shape (`"../caixa-teia && make"` — the
10307        // canonical "I copied a `cd path && make` build chain" idiom
10308        // every Makefile / shell-script wraps). The arm fires on the
10309        // first `&` encountered; pinned so a future arm that tries to
10310        // distinguish `&` from `&&` doesn't break the broader contract.
10311        let d = dep_with_fonte(DepSource::Path {
10312            caminho: "../caixa-teia && make".into(),
10313        });
10314        let err = d.validate().unwrap_err();
10315        assert!(
10316            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
10317            "got {err:?}",
10318        );
10319    }
10320
10321    #[test]
10322    fn validate_accepts_path_fonte_with_caminho_carrying_no_ampersand() {
10323        // The positive-control pin: the gate targets only `&`, never
10324        // adjacent printable ASCII or POSIX-valid bytes. The canonical
10325        // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
10326        // pathed variant with adjacent printable punctuation
10327        // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
10328        // cleanly so the gate doesn't widen to a "no printable
10329        // punctuation anywhere" sweep that would defeat the entire
10330        // path-fonte author surface.
10331        let d = dep_with_fonte(DepSource::Path {
10332            caminho: "../caixa-teia/sub-dir.v2".into(),
10333        });
10334        d.validate().unwrap();
10335    }
10336
10337    #[test]
10338    fn fonte_caminho_shell_semicolon_fires_before_shell_background() {
10339        // Cascade pin on the immediate-predecessor arm: a value carrying
10340        // both `;` and `&` (`"../caixa-teia; rm & sleep"` — the
10341        // canonical "I pasted a `cmd; cleanup & sleep` chain" footgun)
10342        // routes through `FonteCaminhoShellSemicolon` not
10343        // `FonteCaminhoShellBackground`. The sequential-command-
10344        // separator paste is the more common shell-history paste idiom
10345        // on every probe-as-both value (an author who removes the `;`
10346        // typically also drops the trailing `& sleep` since both are
10347        // paste-from-shell-history artifacts) — same cascade discipline
10348        // every prior `:caminho` arm establishes.
10349        let d = dep_with_fonte(DepSource::Path {
10350            caminho: "../caixa-teia; rm & sleep".into(),
10351        });
10352        let err = d.validate().unwrap_err();
10353        assert!(
10354            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
10355            "got {err:?}",
10356        );
10357    }
10358
10359    #[test]
10360    fn fonte_caminho_shell_pipe_fires_before_shell_background() {
10361        // Cascade pin on the upstream shell-pipe arm: a value carrying
10362        // both `|` and `&` (`"../caixa-teia | tee & sleep"` — the
10363        // canonical "I pasted a `cmd | tee & sleep` background-pipeline
10364        // chain" footgun) routes through `FonteCaminhoShellPipe` not
10365        // `FonteCaminhoShellBackground`. The pipeline-tail paste is the
10366        // load-bearing root-cause edit on every probe-as-both value.
10367        let d = dep_with_fonte(DepSource::Path {
10368            caminho: "../caixa-teia | tee & sleep".into(),
10369        });
10370        let err = d.validate().unwrap_err();
10371        assert!(
10372            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10373            "got {err:?}",
10374        );
10375    }
10376
10377    #[test]
10378    fn fonte_caminho_shell_redirection_fires_before_shell_background() {
10379        // Cascade pin on the upstream shell-redirection arm: a value
10380        // carrying both `>` and `&` (`"../caixa-teia>log & sleep"` —
10381        // the canonical "I pasted a `cmd > log & sleep` background-
10382        // redirect chain" footgun) routes through
10383        // `FonteCaminhoShellRedirection` not
10384        // `FonteCaminhoShellBackground`. The input/output redirection
10385        // metachar carries the more self-locating `byte: u8` payload
10386        // (it names which of `<` or `>` triggered), so the prior arm
10387        // wins on every probe-as-both value.
10388        let d = dep_with_fonte(DepSource::Path {
10389            caminho: "../caixa-teia>log & sleep".into(),
10390        });
10391        let err = d.validate().unwrap_err();
10392        assert!(
10393            matches!(
10394                err,
10395                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
10396            ),
10397            "got {err:?}",
10398        );
10399    }
10400
10401    #[test]
10402    fn fonte_caminho_backslash_fires_before_shell_background() {
10403        // Cascade pin on the upstream backslash arm: a value carrying
10404        // both `\` and `&` (`"..\caixa-teia & sleep"` — the canonical
10405        // "I pasted a Windows-shell `cd ..\path & sleep` background-
10406        // launch chain") routes through `FonteCaminhoBackslash` not
10407        // `FonteCaminhoShellBackground`. The cross-host-OS-separator
10408        // divergence is the load-bearing axis on every probe-as-both
10409        // value (an author who removes the `\` is the root-cause edit;
10410        // the `&` falls away in the same edit since it's downstream of
10411        // the Windows-shell convention).
10412        let d = dep_with_fonte(DepSource::Path {
10413            caminho: "..\\caixa-teia & sleep".into(),
10414        });
10415        let err = d.validate().unwrap_err();
10416        assert!(
10417            matches!(err, DepError::FonteCaminhoBackslash { .. }),
10418            "got {err:?}",
10419        );
10420    }
10421
10422    #[test]
10423    fn fonte_caminho_control_char_fires_before_shell_background() {
10424        // Cascade pin on the embedded-control-byte arm: a value
10425        // carrying both a control byte and `&` (`"../foo\n&sleep"` —
10426        // the canonical paste-from-multiline-doc footgun where a
10427        // newline landed mid-caminho) routes through
10428        // `FonteCaminhoControlChar` not `FonteCaminhoShellBackground`.
10429        // The POSIX-syscall-rejected-byte / NUL-`CString::new`-fail
10430        // diagnostic is the load-bearing axis on every value that
10431        // probes positive for both — mirrors the cascade discipline on
10432        // every prior arm.
10433        let d = dep_with_fonte(DepSource::Path {
10434            caminho: "../foo\n&sleep".into(),
10435        });
10436        let err = d.validate().unwrap_err();
10437        assert!(
10438            matches!(err, DepError::FonteCaminhoControlChar { .. }),
10439            "got {err:?}",
10440        );
10441    }
10442
10443    #[test]
10444    fn fonte_caminho_absolute_fires_before_shell_background() {
10445        // Cascade pin on the load-bearing leading-byte arm: a leading
10446        // `/` value with embedded `&` (`"/etc/passwd & sleep"`) routes
10447        // through `FonteCaminhoAbsolute` not
10448        // `FonteCaminhoShellBackground` — the host-layout-leak
10449        // diagnostic is the load-bearing axis, the `&` byte is the
10450        // secondary observation. Same precedence logic as every prior
10451        // leading-byte arm.
10452        let d = dep_with_fonte(DepSource::Path {
10453            caminho: "/etc/passwd & sleep".into(),
10454        });
10455        let err = d.validate().unwrap_err();
10456        assert!(
10457            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10458            "got {err:?}",
10459        );
10460    }
10461
10462    #[test]
10463    fn fonte_caminho_shell_background_fires_before_trailing_slash() {
10464        // Cascade pin on the immediate-successor arm: a value carrying
10465        // both `&` and a trailing `/` (`"../foo&sleep/"` — the
10466        // canonical "I tab-completed a path that already had a `&
10467        // sleep` background-launch tail" footgun) routes through
10468        // `FonteCaminhoShellBackground` not `FonteCaminhoTrailingSlash`.
10469        // The embedded shell-metachar is the more semantic-locating
10470        // axis (an author who removes the `&` typically also drops
10471        // the trailing separator since both are paste-from-shell
10472        // artifacts).
10473        let d = dep_with_fonte(DepSource::Path {
10474            caminho: "../foo&sleep/".into(),
10475        });
10476        let err = d.validate().unwrap_err();
10477        assert!(
10478            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
10479            "got {err:?}",
10480        );
10481    }
10482
10483    #[test]
10484    fn fonte_caminho_shell_background_diagnostic_carries_offending_dep_and_caminho() {
10485        // Diagnostic-shape pin (peer with
10486        // `fonte_caminho_shell_semicolon_diagnostic_carries_offending_dep_and_caminho`
10487        // on the closest single-byte peer arm): the error's Display
10488        // surfaces the offending `:nome` and the offending `:caminho`
10489        // verbatim, and names the shell-background / logical-AND
10490        // footgun explicitly so a `feira lint` run can render the
10491        // diagnostic without re-parsing.
10492        let d = dep_with_fonte(DepSource::Path {
10493            caminho: "../caixa-teia & sleep 1".into(),
10494        });
10495        let rendered = d.validate().unwrap_err().to_string();
10496        assert!(
10497            rendered.contains("caixa-teia"),
10498            "diagnostic must name the offending dep: {rendered}",
10499        );
10500        assert!(
10501            rendered.contains("../caixa-teia & sleep 1"),
10502            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10503        );
10504        assert!(
10505            rendered.contains('&'),
10506            "diagnostic must reference the ampersand footgun: {rendered:?}",
10507        );
10508        assert!(
10509            rendered.contains("background") || rendered.contains("list-AND"),
10510            "diagnostic must name the shell-background / logical-AND footgun: {rendered:?}",
10511        );
10512    }
10513
10514    #[test]
10515    fn validate_rejects_path_fonte_with_caminho_carrying_backtick() {
10516        // The fail-before-pass-after pin for the canonical shell-
10517        // command-substitution paste footgun: an author copies a
10518        // POSIX legacy backticked one-liner (`"../caixa-teia/`whoami`"`
10519        // — the canonical "I pasted a path that included a `pwd`
10520        // / `whoami` / `date` legacy command-substitution expansion
10521        // out of a shell-history block") and silently passed every
10522        // prior arm (`Path::is_absolute` false on `..`, no control
10523        // bytes, no `\`, no `<` / `>`, no `|`, no `;`, no `&`, doesn't
10524        // end in `/`). The lacre embedded the value verbatim, the
10525        // resolver folded it through `Path::join` looking for a
10526        // literal `./../caixa-teia/`whoami`` subdirectory, and the
10527        // failure surfaced at resolve time with a non-self-locating
10528        // `No such file or directory` error. The new arm moves the
10529        // rejection to validate time and names the offending dep +
10530        // caminho verbatim.
10531        let d = dep_with_fonte(DepSource::Path {
10532            caminho: "../caixa-teia/`whoami`".into(),
10533        });
10534        let err = d.validate().unwrap_err();
10535        let DepError::FonteCaminhoShellCommandSubstitution { nome, caminho } = err else {
10536            panic!("expected FonteCaminhoShellCommandSubstitution, got {err:?}");
10537        };
10538        assert_eq!(nome, "caixa-teia");
10539        assert_eq!(caminho, "../caixa-teia/`whoami`");
10540    }
10541
10542    #[test]
10543    fn validate_rejects_path_fonte_with_caminho_carrying_leading_backtick() {
10544        // Leading-position backtick shape (``"`pwd`/caixa-teia"`` —
10545        // the canonical `<backtick>pwd<backtick>/path` working-
10546        // directory expansion shape every shell-side path-composition
10547        // idiom carries). Pinned separately from the embedded-byte
10548        // shape so the gate covers every position, not only mid-path.
10549        let d = dep_with_fonte(DepSource::Path {
10550            caminho: "`pwd`/caixa-teia".into(),
10551        });
10552        let err = d.validate().unwrap_err();
10553        assert!(
10554            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
10555            "got {err:?}",
10556        );
10557    }
10558
10559    #[test]
10560    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_backtick() {
10561        // Trailing-position backtick shape (`"../caixa-teia`"` — the
10562        // degenerate "I selected an unbalanced backtick out of a
10563        // shell-history block" idiom that probes for the cascade's
10564        // last-byte handling). The trailing-`/` arm fires only on
10565        // last-byte `/`; an unbalanced trailing backtick must route
10566        // through this arm regardless of position.
10567        let d = dep_with_fonte(DepSource::Path {
10568            caminho: "../caixa-teia`".into(),
10569        });
10570        let err = d.validate().unwrap_err();
10571        assert!(
10572            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
10573            "got {err:?}",
10574        );
10575    }
10576
10577    #[test]
10578    fn validate_rejects_path_fonte_with_caminho_carrying_balanced_backtick_pair() {
10579        // The canonical balanced-pair shape (``"../<backtick>cat
10580        // /etc/passwd<backtick>"`` — the canonical CWE-78 shell-
10581        // command-injection paste idiom every shell-side hardening
10582        // guide enumerates first). The arm fires on the first
10583        // backtick encountered; pinned so a future arm that tries to
10584        // distinguish the opening from the closing byte doesn't break
10585        // the broader contract.
10586        let d = dep_with_fonte(DepSource::Path {
10587            caminho: "../`cat /etc/passwd`".into(),
10588        });
10589        let err = d.validate().unwrap_err();
10590        assert!(
10591            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
10592            "got {err:?}",
10593        );
10594    }
10595
10596    #[test]
10597    fn validate_accepts_path_fonte_with_caminho_carrying_no_backtick() {
10598        // The positive-control pin: the gate targets only the
10599        // backtick byte, never adjacent printable ASCII or POSIX-
10600        // valid bytes. The canonical relative POSIX path
10601        // (`"../caixa-teia"`) and a nested deeply-pathed variant with
10602        // adjacent printable punctuation
10603        // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
10604        // cleanly so the gate doesn't widen to a "no printable
10605        // punctuation anywhere" sweep that would defeat the entire
10606        // path-fonte author surface.
10607        let d = dep_with_fonte(DepSource::Path {
10608            caminho: "../caixa-teia/sub-dir.v2".into(),
10609        });
10610        d.validate().unwrap();
10611    }
10612
10613    #[test]
10614    fn fonte_caminho_shell_background_fires_before_shell_command_substitution() {
10615        // Cascade pin on the immediate-predecessor arm: a value
10616        // carrying both `&` and a backtick (``"../caixa-teia &
10617        // <backtick>sleep 1<backtick>"`` — the canonical "I pasted a
10618        // `cmd & <backtick>sleep N<backtick>` background-launch +
10619        // command-substitution chain" footgun) routes through
10620        // `FonteCaminhoShellBackground` not
10621        // `FonteCaminhoShellCommandSubstitution`. The background-
10622        // launch tail is the more common shell-history paste idiom
10623        // on every probe-as-both value — same cascade discipline
10624        // every prior `:caminho` arm establishes.
10625        let d = dep_with_fonte(DepSource::Path {
10626            caminho: "../caixa-teia & `sleep 1`".into(),
10627        });
10628        let err = d.validate().unwrap_err();
10629        assert!(
10630            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
10631            "got {err:?}",
10632        );
10633    }
10634
10635    #[test]
10636    fn fonte_caminho_shell_semicolon_fires_before_shell_command_substitution() {
10637        // Cascade pin on the upstream shell-semicolon arm: a value
10638        // carrying both `;` and a backtick (``"../caixa-teia;
10639        // <backtick>whoami<backtick>"`` — the canonical "I pasted a
10640        // `cmd; <backtick>follow-up<backtick>` sequential-chain
10641        // footgun) routes through `FonteCaminhoShellSemicolon` not
10642        // `FonteCaminhoShellCommandSubstitution`. The sequential-
10643        // command-separator paste is the load-bearing root-cause
10644        // edit on every probe-as-both value.
10645        let d = dep_with_fonte(DepSource::Path {
10646            caminho: "../caixa-teia; `whoami`".into(),
10647        });
10648        let err = d.validate().unwrap_err();
10649        assert!(
10650            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
10651            "got {err:?}",
10652        );
10653    }
10654
10655    #[test]
10656    fn fonte_caminho_shell_pipe_fires_before_shell_command_substitution() {
10657        // Cascade pin on the upstream shell-pipe arm: a value
10658        // carrying both `|` and a backtick (``"../caixa-teia |
10659        // <backtick>tee log<backtick>"`` — the canonical pipeline-to-
10660        // command-substitution paste idiom) routes through
10661        // `FonteCaminhoShellPipe` not
10662        // `FonteCaminhoShellCommandSubstitution`. The pipeline-tail
10663        // paste is the load-bearing root-cause edit on every
10664        // probe-as-both value.
10665        let d = dep_with_fonte(DepSource::Path {
10666            caminho: "../caixa-teia | `tee log`".into(),
10667        });
10668        let err = d.validate().unwrap_err();
10669        assert!(
10670            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10671            "got {err:?}",
10672        );
10673    }
10674
10675    #[test]
10676    fn fonte_caminho_shell_redirection_fires_before_shell_command_substitution() {
10677        // Cascade pin on the upstream shell-redirection arm: a value
10678        // carrying both `>` and a backtick (``"../caixa-teia>log
10679        // <backtick>date<backtick>"`` — the canonical "I pasted a
10680        // `cmd > log <backtick>date<backtick>` redirect-plus-
10681        // substitution chain" footgun) routes through
10682        // `FonteCaminhoShellRedirection` not
10683        // `FonteCaminhoShellCommandSubstitution`. The input/output
10684        // redirection metachar carries the more self-locating `byte`
10685        // payload (it names which of `<` or `>` triggered), so the
10686        // prior arm wins on every probe-as-both value.
10687        let d = dep_with_fonte(DepSource::Path {
10688            caminho: "../caixa-teia>log `date`".into(),
10689        });
10690        let err = d.validate().unwrap_err();
10691        assert!(
10692            matches!(
10693                err,
10694                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
10695            ),
10696            "got {err:?}",
10697        );
10698    }
10699
10700    #[test]
10701    fn fonte_caminho_backslash_fires_before_shell_command_substitution() {
10702        // Cascade pin on the upstream backslash arm: a value
10703        // carrying both `\` and a backtick (``"..\caixa-teia
10704        // <backtick>whoami<backtick>"`` — the canonical "I pasted a
10705        // Windows-shell `cd ..\path <backtick>whoami<backtick>`
10706        // chain") routes through `FonteCaminhoBackslash` not
10707        // `FonteCaminhoShellCommandSubstitution`. The cross-host-OS-
10708        // separator divergence is the load-bearing axis on every
10709        // probe-as-both value (an author who removes the `\` is the
10710        // root-cause edit; the backtick falls away in the same edit
10711        // since it's downstream of the Windows-shell convention).
10712        let d = dep_with_fonte(DepSource::Path {
10713            caminho: "..\\caixa-teia `whoami`".into(),
10714        });
10715        let err = d.validate().unwrap_err();
10716        assert!(
10717            matches!(err, DepError::FonteCaminhoBackslash { .. }),
10718            "got {err:?}",
10719        );
10720    }
10721
10722    #[test]
10723    fn fonte_caminho_control_char_fires_before_shell_command_substitution() {
10724        // Cascade pin on the embedded-control-byte arm: a value
10725        // carrying both a control byte and a backtick (`"../foo\n
10726        // `whoami`"` — the canonical paste-from-multiline-doc
10727        // footgun where a newline landed mid-caminho between two
10728        // paste fragments) routes through `FonteCaminhoControlChar`
10729        // not `FonteCaminhoShellCommandSubstitution`. The POSIX-
10730        // syscall-rejected-byte / NUL-`CString::new`-fail diagnostic
10731        // is the load-bearing axis on every value that probes
10732        // positive for both — mirrors the cascade discipline on
10733        // every prior arm.
10734        let d = dep_with_fonte(DepSource::Path {
10735            caminho: "../foo\n`whoami`".into(),
10736        });
10737        let err = d.validate().unwrap_err();
10738        assert!(
10739            matches!(err, DepError::FonteCaminhoControlChar { .. }),
10740            "got {err:?}",
10741        );
10742    }
10743
10744    #[test]
10745    fn fonte_caminho_absolute_fires_before_shell_command_substitution() {
10746        // Cascade pin on the load-bearing leading-byte arm: a
10747        // leading `/` value with embedded backtick (``"/etc/passwd
10748        // <backtick>whoami<backtick>"``) routes through
10749        // `FonteCaminhoAbsolute` not
10750        // `FonteCaminhoShellCommandSubstitution` — the host-layout-
10751        // leak diagnostic is the load-bearing axis, the backtick
10752        // byte is the secondary observation. Same precedence logic
10753        // as every prior leading-byte arm.
10754        let d = dep_with_fonte(DepSource::Path {
10755            caminho: "/etc/passwd `whoami`".into(),
10756        });
10757        let err = d.validate().unwrap_err();
10758        assert!(
10759            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10760            "got {err:?}",
10761        );
10762    }
10763
10764    #[test]
10765    fn fonte_caminho_shell_command_substitution_fires_before_trailing_slash() {
10766        // Cascade pin on the immediate-successor arm: a value
10767        // carrying both a backtick and a trailing `/`
10768        // (``"../`whoami`/"`` — the canonical "I tab-completed a
10769        // path that already had a backticked `whoami` substitution
10770        // tail" footgun) routes through
10771        // `FonteCaminhoShellCommandSubstitution` not
10772        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
10773        // is the more semantic-locating axis (an author who removes
10774        // the backtick typically also drops the trailing separator
10775        // since both are paste-from-shell artifacts).
10776        let d = dep_with_fonte(DepSource::Path {
10777            caminho: "../`whoami`/".into(),
10778        });
10779        let err = d.validate().unwrap_err();
10780        assert!(
10781            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
10782            "got {err:?}",
10783        );
10784    }
10785
10786    #[test]
10787    fn fonte_caminho_shell_command_substitution_diagnostic_carries_offending_dep_and_caminho() {
10788        // Diagnostic-shape pin (peer with
10789        // `fonte_caminho_shell_background_diagnostic_carries_offending_dep_and_caminho`
10790        // on the closest single-byte peer arm): the error's Display
10791        // surfaces the offending `:nome` and the offending `:caminho`
10792        // verbatim, and names the shell-command-substitution footgun
10793        // explicitly so a `feira lint` run can render the diagnostic
10794        // without re-parsing.
10795        let d = dep_with_fonte(DepSource::Path {
10796            caminho: "../caixa-teia/`whoami`".into(),
10797        });
10798        let rendered = d.validate().unwrap_err().to_string();
10799        assert!(
10800            rendered.contains("caixa-teia"),
10801            "diagnostic must name the offending dep: {rendered}",
10802        );
10803        assert!(
10804            rendered.contains("../caixa-teia/`whoami`"),
10805            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10806        );
10807        assert!(
10808            rendered.contains('`'),
10809            "diagnostic must reference the backtick footgun: {rendered:?}",
10810        );
10811        assert!(
10812            rendered.contains("command-substitution"),
10813            "diagnostic must name the shell-command-substitution footgun: {rendered:?}",
10814        );
10815    }
10816
10817    #[test]
10818    fn validate_rejects_path_fonte_with_caminho_carrying_star_glob() {
10819        // The fail-before-pass-after pin for the canonical pathname-
10820        // expansion paste footgun: an author copies an `ls
10821        // ../caixa-teia/*` shell-listing tail into the `:caminho`
10822        // slot and silently passes every prior arm
10823        // (`Path::is_absolute` false on `..`, no control bytes, no
10824        // `\`, no `<` / `>`, no `|`, no `;`, no `&`, no backtick,
10825        // doesn't end in `/`). The lacre embedded the value
10826        // verbatim, the resolver folded it through `Path::join`
10827        // looking for a literal `./../caixa-teia/*` subdirectory,
10828        // and the failure surfaced at resolve time with a non-self-
10829        // locating `No such file or directory` error. The new arm
10830        // moves the rejection to validate time and names the
10831        // offending dep + caminho + byte verbatim.
10832        let d = dep_with_fonte(DepSource::Path {
10833            caminho: "../caixa-teia/*".into(),
10834        });
10835        let err = d.validate().unwrap_err();
10836        let DepError::FonteCaminhoShellGlob {
10837            nome,
10838            caminho,
10839            byte,
10840        } = err
10841        else {
10842            panic!("expected FonteCaminhoShellGlob, got {err:?}");
10843        };
10844        assert_eq!(nome, "caixa-teia");
10845        assert_eq!(caminho, "../caixa-teia/*");
10846        assert_eq!(byte, b'*');
10847    }
10848
10849    #[test]
10850    fn validate_rejects_path_fonte_with_caminho_carrying_question_glob() {
10851        // The symmetric single-char-wildcard paste shape
10852        // (`"../foo?"` — the canonical "I copied a `rm foo?` line
10853        // out of shell history" idiom). Pinned separately from the
10854        // `*` shape so the gate's contract is "any `*` or `?`
10855        // anywhere", not single-byte coverage.
10856        let d = dep_with_fonte(DepSource::Path {
10857            caminho: "../foo?".into(),
10858        });
10859        let err = d.validate().unwrap_err();
10860        let DepError::FonteCaminhoShellGlob { byte, .. } = err else {
10861            panic!("expected FonteCaminhoShellGlob, got {err:?}");
10862        };
10863        assert_eq!(byte, b'?');
10864    }
10865
10866    #[test]
10867    fn validate_rejects_path_fonte_with_caminho_carrying_leading_star_glob() {
10868        // Leading-position `*` shape (`"*/caixa-teia"` — the
10869        // degenerate "I selected only the wildcard prefix out of a
10870        // shell-glob expression" idiom). Pinned separately from the
10871        // embedded-byte shapes so the gate covers every position,
10872        // not only mid-path.
10873        let d = dep_with_fonte(DepSource::Path {
10874            caminho: "*/caixa-teia".into(),
10875        });
10876        let err = d.validate().unwrap_err();
10877        assert!(
10878            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
10879            "got {err:?}",
10880        );
10881    }
10882
10883    #[test]
10884    fn validate_rejects_path_fonte_with_caminho_carrying_double_star_recursive_glob() {
10885        // The bash/zsh `globstar` recursive-glob shape
10886        // (`"../caixa-teia/**/foo"` — the canonical "I copied a
10887        // `find ../caixa-teia/**/foo` recursive expansion" idiom).
10888        // The arm fires on the first `*` encountered; pinned so a
10889        // future arm that tries to distinguish single `*` from
10890        // double `**` doesn't break the broader contract.
10891        let d = dep_with_fonte(DepSource::Path {
10892            caminho: "../caixa-teia/**/foo".into(),
10893        });
10894        let err = d.validate().unwrap_err();
10895        assert!(
10896            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
10897            "got {err:?}",
10898        );
10899    }
10900
10901    #[test]
10902    fn validate_rejects_path_fonte_with_caminho_carrying_dotted_extension_glob() {
10903        // The canonical extension-glob shape (`"../caixa-teia/*.lisp"`
10904        // — the "I selected `*.lisp` to mean every Lisp source file
10905        // in the dep root" footgun the prior arms structurally
10906        // cannot catch since `.` is a POSIX-valid path-component
10907        // byte). Pinned so the gate's contract covers the most
10908        // idiomatic glob-paste shape every author meets first.
10909        let d = dep_with_fonte(DepSource::Path {
10910            caminho: "../caixa-teia/*.lisp".into(),
10911        });
10912        let err = d.validate().unwrap_err();
10913        assert!(
10914            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
10915            "got {err:?}",
10916        );
10917    }
10918
10919    #[test]
10920    fn validate_accepts_path_fonte_with_caminho_carrying_no_glob() {
10921        // The positive-control pin: the gate targets only `*` /
10922        // `?`, never adjacent printable ASCII or POSIX-valid bytes.
10923        // The canonical relative POSIX path (`"../caixa-teia"`) and
10924        // a nested deeply-pathed variant with adjacent printable
10925        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
10926        // to validate cleanly so the gate doesn't widen to a "no
10927        // printable punctuation anywhere" sweep that would defeat
10928        // the entire path-fonte author surface.
10929        let d = dep_with_fonte(DepSource::Path {
10930            caminho: "../caixa-teia/sub-dir.v2".into(),
10931        });
10932        d.validate().unwrap();
10933    }
10934
10935    #[test]
10936    fn fonte_caminho_shell_command_substitution_fires_before_shell_glob() {
10937        // Cascade pin on the immediate-predecessor arm: a value
10938        // carrying both a backtick and `*` (``"../`whoami`/*"`` —
10939        // the canonical "I pasted a `cd <backtick>whoami<backtick>/*`
10940        // command-substitution + glob chain") routes through
10941        // `FonteCaminhoShellCommandSubstitution` not
10942        // `FonteCaminhoShellGlob`. The CWE-78 shell-command-
10943        // injection vector is the load-bearing root-cause edit on
10944        // every probe-as-both value — same cascade discipline every
10945        // prior `:caminho` arm establishes.
10946        let d = dep_with_fonte(DepSource::Path {
10947            caminho: "../`whoami`/*".into(),
10948        });
10949        let err = d.validate().unwrap_err();
10950        assert!(
10951            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
10952            "got {err:?}",
10953        );
10954    }
10955
10956    #[test]
10957    fn fonte_caminho_shell_background_fires_before_shell_glob() {
10958        // Cascade pin on the upstream shell-background arm: a value
10959        // carrying both `&` and `*` (`"../caixa-teia & ls /*"` — the
10960        // canonical "I pasted a `cmd & ls /*` background + glob
10961        // chain" footgun) routes through `FonteCaminhoShellBackground`
10962        // not `FonteCaminhoShellGlob`. The background-launch tail is
10963        // the load-bearing root-cause edit on every probe-as-both
10964        // value.
10965        let d = dep_with_fonte(DepSource::Path {
10966            caminho: "../caixa-teia & ls /*".into(),
10967        });
10968        let err = d.validate().unwrap_err();
10969        assert!(
10970            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
10971            "got {err:?}",
10972        );
10973    }
10974
10975    #[test]
10976    fn fonte_caminho_shell_semicolon_fires_before_shell_glob() {
10977        // Cascade pin on the upstream shell-semicolon arm: a value
10978        // carrying both `;` and `*` (`"../caixa-teia; rm *"` — the
10979        // canonical sequential-cleanup + glob paste idiom) routes
10980        // through `FonteCaminhoShellSemicolon` not
10981        // `FonteCaminhoShellGlob`. The sequential-command-separator
10982        // paste is the load-bearing root-cause edit on every
10983        // probe-as-both value.
10984        let d = dep_with_fonte(DepSource::Path {
10985            caminho: "../caixa-teia; rm *".into(),
10986        });
10987        let err = d.validate().unwrap_err();
10988        assert!(
10989            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
10990            "got {err:?}",
10991        );
10992    }
10993
10994    #[test]
10995    fn fonte_caminho_shell_pipe_fires_before_shell_glob() {
10996        // Cascade pin on the upstream shell-pipe arm: a value
10997        // carrying both `|` and `*` (`"../caixa-teia | ls *"` — the
10998        // canonical pipeline-to-glob paste idiom) routes through
10999        // `FonteCaminhoShellPipe` not `FonteCaminhoShellGlob`. The
11000        // pipeline-tail paste is the load-bearing root-cause edit
11001        // on every probe-as-both value.
11002        let d = dep_with_fonte(DepSource::Path {
11003            caminho: "../caixa-teia | ls *".into(),
11004        });
11005        let err = d.validate().unwrap_err();
11006        assert!(
11007            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11008            "got {err:?}",
11009        );
11010    }
11011
11012    #[test]
11013    fn fonte_caminho_shell_redirection_fires_before_shell_glob() {
11014        // Cascade pin on the upstream shell-redirection arm: a value
11015        // carrying both `>` and `*` (`"../caixa-teia>log *"` — the
11016        // canonical "I pasted a `cmd > log *` redirect-plus-glob
11017        // chain" footgun) routes through
11018        // `FonteCaminhoShellRedirection` not `FonteCaminhoShellGlob`.
11019        // The input/output redirection metachar carries the more
11020        // self-locating `byte` payload (it names which of `<` or `>`
11021        // triggered), so the prior arm wins on every probe-as-both
11022        // value.
11023        let d = dep_with_fonte(DepSource::Path {
11024            caminho: "../caixa-teia>log *".into(),
11025        });
11026        let err = d.validate().unwrap_err();
11027        assert!(
11028            matches!(
11029                err,
11030                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11031            ),
11032            "got {err:?}",
11033        );
11034    }
11035
11036    #[test]
11037    fn fonte_caminho_backslash_fires_before_shell_glob() {
11038        // Cascade pin on the upstream backslash arm: a value
11039        // carrying both `\` and `*` (`"..\caixa-teia\*"` — the
11040        // canonical "I pasted a Windows-shell `cd ..\path\*` glob
11041        // expression" footgun) routes through
11042        // `FonteCaminhoBackslash` not `FonteCaminhoShellGlob`. The
11043        // cross-host-OS-separator divergence is the load-bearing
11044        // axis on every probe-as-both value (an author who removes
11045        // the `\` is the root-cause edit; the `*` falls away in the
11046        // same edit since it's downstream of the Windows-shell
11047        // convention).
11048        let d = dep_with_fonte(DepSource::Path {
11049            caminho: "..\\caixa-teia\\*".into(),
11050        });
11051        let err = d.validate().unwrap_err();
11052        assert!(
11053            matches!(err, DepError::FonteCaminhoBackslash { .. }),
11054            "got {err:?}",
11055        );
11056    }
11057
11058    #[test]
11059    fn fonte_caminho_control_char_fires_before_shell_glob() {
11060        // Cascade pin on the embedded-control-byte arm: a value
11061        // carrying both a control byte and `*` (`"../foo\n*"` — the
11062        // canonical paste-from-multiline-doc footgun where a
11063        // newline landed mid-caminho between two paste fragments)
11064        // routes through `FonteCaminhoControlChar` not
11065        // `FonteCaminhoShellGlob`. The POSIX-syscall-rejected-byte /
11066        // NUL-`CString::new`-fail diagnostic is the load-bearing
11067        // axis on every value that probes positive for both —
11068        // mirrors the cascade discipline on every prior arm.
11069        let d = dep_with_fonte(DepSource::Path {
11070            caminho: "../foo\n*".into(),
11071        });
11072        let err = d.validate().unwrap_err();
11073        assert!(
11074            matches!(err, DepError::FonteCaminhoControlChar { .. }),
11075            "got {err:?}",
11076        );
11077    }
11078
11079    #[test]
11080    fn fonte_caminho_absolute_fires_before_shell_glob() {
11081        // Cascade pin on the load-bearing leading-byte arm: a
11082        // leading `/` value with embedded `*` (`"/etc/*"`) routes
11083        // through `FonteCaminhoAbsolute` not `FonteCaminhoShellGlob`
11084        // — the host-layout-leak diagnostic is the load-bearing
11085        // axis, the glob byte is the secondary observation. Same
11086        // precedence logic as every prior leading-byte arm.
11087        let d = dep_with_fonte(DepSource::Path {
11088            caminho: "/etc/*".into(),
11089        });
11090        let err = d.validate().unwrap_err();
11091        assert!(
11092            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11093            "got {err:?}",
11094        );
11095    }
11096
11097    #[test]
11098    fn fonte_caminho_shell_glob_fires_before_trailing_slash() {
11099        // Cascade pin on the immediate-successor arm: a value
11100        // carrying both `*` and a trailing `/` (`"../foo*/"` — the
11101        // canonical "I tab-completed a path that already had a
11102        // glob-expansion tail" footgun) routes through
11103        // `FonteCaminhoShellGlob` not `FonteCaminhoTrailingSlash`.
11104        // The embedded shell-metachar is the more semantic-locating
11105        // axis (an author who removes the `*` typically also drops
11106        // the trailing separator since both are paste-from-shell
11107        // artifacts).
11108        let d = dep_with_fonte(DepSource::Path {
11109            caminho: "../foo*/".into(),
11110        });
11111        let err = d.validate().unwrap_err();
11112        assert!(
11113            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
11114            "got {err:?}",
11115        );
11116    }
11117
11118    #[test]
11119    fn fonte_caminho_shell_glob_diagnostic_carries_offending_dep_caminho_and_byte() {
11120        // Diagnostic-shape pin (peer with
11121        // `fonte_caminho_shell_redirection_diagnostic_*` on the
11122        // closest two-byte peer arm): the error's Display surfaces
11123        // the offending `:nome`, the offending `:caminho` verbatim,
11124        // the offending byte's hex / character form, and names the
11125        // shell-glob / pathname-expansion footgun explicitly so a
11126        // `feira lint` run can render the diagnostic without
11127        // re-parsing.
11128        let d = dep_with_fonte(DepSource::Path {
11129            caminho: "../caixa-teia/*.lisp".into(),
11130        });
11131        let rendered = d.validate().unwrap_err().to_string();
11132        assert!(
11133            rendered.contains("caixa-teia"),
11134            "diagnostic must name the offending dep: {rendered}",
11135        );
11136        assert!(
11137            rendered.contains("../caixa-teia/*.lisp"),
11138            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11139        );
11140        assert!(
11141            rendered.contains("0x2a"),
11142            "diagnostic must surface the offending byte hex: {rendered:?}",
11143        );
11144        assert!(
11145            rendered.contains("glob"),
11146            "diagnostic must name the shell-glob footgun: {rendered:?}",
11147        );
11148        assert!(
11149            rendered.contains("pathname-expansion"),
11150            "diagnostic must reference the POSIX pathname-expansion vocabulary: {rendered:?}",
11151        );
11152    }
11153
11154    #[test]
11155    fn validate_rejects_path_fonte_with_caminho_carrying_modern_command_substitution() {
11156        // The fail-before-pass-after pin for the canonical modern-Bourne
11157        // command-substitution paste footgun: an author copies a
11158        // `cd ../caixa-teia/$(date)/build` shell-history one-liner whose
11159        // `$(<cmd>)` expansion would land the current date as a
11160        // subdirectory name and silently passed every prior arm
11161        // (`Path::is_absolute` false on `..`, no control bytes, no `\`,
11162        // no `<` / `>`, no `|`, no `;`, no `&`, no backtick, no `*` /
11163        // `?`, doesn't end in `/`; the leading-`$` f4efe9c
11164        // `FonteCaminhoVarExpansion` arm doesn't fire because the `$`
11165        // sits mid-path). The lacre embedded the value verbatim, the
11166        // resolver folded it through `Path::join` looking for a literal
11167        // `./../caixa-teia/$(date)/build` subdirectory, and the failure
11168        // surfaced at resolve time with a non-self-locating `No such
11169        // file or directory` error. The new arm moves the rejection to
11170        // validate time and names the offending dep + caminho + byte
11171        // verbatim. The arm fires on the first `(` encountered (the
11172        // opening byte of `$(date)`).
11173        let d = dep_with_fonte(DepSource::Path {
11174            caminho: "../caixa-teia/$(date)/build".into(),
11175        });
11176        let err = d.validate().unwrap_err();
11177        let DepError::FonteCaminhoShellSubshellGrouping {
11178            nome,
11179            caminho,
11180            byte,
11181        } = err
11182        else {
11183            panic!("expected FonteCaminhoShellSubshellGrouping, got {err:?}");
11184        };
11185        assert_eq!(nome, "caixa-teia");
11186        assert_eq!(caminho, "../caixa-teia/$(date)/build");
11187        assert_eq!(byte, b'(');
11188    }
11189
11190    #[test]
11191    fn validate_rejects_path_fonte_with_caminho_carrying_close_paren() {
11192        // The symmetric close-paren paste shape (`"../caixa-teia)"` —
11193        // the degenerate "I selected an unbalanced closing paren out of
11194        // a shell-history block" idiom that probes for the cascade's
11195        // last-byte handling on a value carrying only the closing byte).
11196        // Pinned separately from the open-paren shape so the gate's
11197        // contract is "any `(` or `)` anywhere", not single-byte
11198        // coverage. Mirrors the peer `validate_rejects_path_fonte_with_\
11199        // caminho_carrying_question_glob` shape on the immediate-
11200        // predecessor `FonteCaminhoShellGlob` arm.
11201        let d = dep_with_fonte(DepSource::Path {
11202            caminho: "../caixa-teia)".into(),
11203        });
11204        let err = d.validate().unwrap_err();
11205        let DepError::FonteCaminhoShellSubshellGrouping { byte, .. } = err else {
11206            panic!("expected FonteCaminhoShellSubshellGrouping, got {err:?}");
11207        };
11208        assert_eq!(byte, b')');
11209    }
11210
11211    #[test]
11212    fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_paren() {
11213        // Leading-position `(` shape (`"(cd foo)/caixa-teia"` — the
11214        // canonical "I selected a `(cd foo)` subshell-grouping prefix
11215        // out of a `(cd foo) && cmd` shell-history one-liner" idiom).
11216        // Pinned separately from the embedded-byte shape so the gate
11217        // covers every position, not only mid-path.
11218        let d = dep_with_fonte(DepSource::Path {
11219            caminho: "(cd foo)/caixa-teia".into(),
11220        });
11221        let err = d.validate().unwrap_err();
11222        assert!(
11223            matches!(
11224                err,
11225                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
11226            ),
11227            "got {err:?}",
11228        );
11229    }
11230
11231    #[test]
11232    fn validate_rejects_path_fonte_with_caminho_carrying_balanced_subshell_grouping_pair() {
11233        // The canonical balanced-pair shape (`"../(pwd)/caixa-teia"`
11234        // — the canonical "I copied a `(pwd)` working-directory-probe
11235        // subshell-grouping idiom every shell-history block carries"
11236        // footgun). The value carries no other cascade-preceding
11237        // shell metachar (`&` / `;` / `|` / `<` / `>` / backtick /
11238        // `*` / `?`) so the arm fires on the first `(` encountered;
11239        // pinned so a future arm that tries to distinguish the
11240        // opening from the closing byte doesn't break the broader
11241        // contract. Mirrors the peer
11242        // `validate_rejects_path_fonte_with_caminho_carrying_balanced_\
11243        // backtick_pair` shape on the upstream `FonteCaminhoShell\
11244        // CommandSubstitution` arm.
11245        let d = dep_with_fonte(DepSource::Path {
11246            caminho: "../(pwd)/caixa-teia".into(),
11247        });
11248        let err = d.validate().unwrap_err();
11249        assert!(
11250            matches!(
11251                err,
11252                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
11253            ),
11254            "got {err:?}",
11255        );
11256    }
11257
11258    #[test]
11259    fn validate_accepts_path_fonte_with_caminho_carrying_no_subshell_grouping() {
11260        // The positive-control pin: the gate targets only `(` / `)`,
11261        // never adjacent printable ASCII or POSIX-valid bytes. The
11262        // canonical relative POSIX path (`"../caixa-teia"`) and a
11263        // nested deeply-pathed variant with adjacent printable
11264        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue to
11265        // validate cleanly so the gate doesn't widen to a "no printable
11266        // punctuation anywhere" sweep that would defeat the entire
11267        // path-fonte author surface.
11268        let d = dep_with_fonte(DepSource::Path {
11269            caminho: "../caixa-teia/sub-dir.v2".into(),
11270        });
11271        d.validate().unwrap();
11272    }
11273
11274    #[test]
11275    fn fonte_caminho_shell_glob_fires_before_shell_subshell_grouping() {
11276        // Cascade pin on the immediate-predecessor arm: a value
11277        // carrying both `*` and `(` (`"../caixa-teia/*(date)"` — the
11278        // canonical "I pasted a glob expansion followed by a
11279        // subshell-grouping tail" footgun) routes through
11280        // `FonteCaminhoShellGlob` not
11281        // `FonteCaminhoShellSubshellGrouping`. The pathname-expansion
11282        // shape is the more common shell-history paste idiom on every
11283        // probe-as-both value — same cascade discipline every prior
11284        // `:caminho` arm establishes.
11285        let d = dep_with_fonte(DepSource::Path {
11286            caminho: "../caixa-teia/*(date)".into(),
11287        });
11288        let err = d.validate().unwrap_err();
11289        assert!(
11290            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
11291            "got {err:?}",
11292        );
11293    }
11294
11295    #[test]
11296    fn fonte_caminho_shell_command_substitution_fires_before_shell_subshell_grouping() {
11297        // Cascade pin on the upstream shell-command-substitution arm: a
11298        // value carrying both a backtick and `(` (``"../`whoami`/$(date)"``
11299        // — the canonical "I pasted a legacy-backtick + modern-paren
11300        // command-substitution chain" footgun) routes through
11301        // `FonteCaminhoShellCommandSubstitution` not
11302        // `FonteCaminhoShellSubshellGrouping`. The CWE-78 shell-
11303        // command-injection vector is the load-bearing root-cause edit
11304        // on every probe-as-both value.
11305        let d = dep_with_fonte(DepSource::Path {
11306            caminho: "../`whoami`/$(date)".into(),
11307        });
11308        let err = d.validate().unwrap_err();
11309        assert!(
11310            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11311            "got {err:?}",
11312        );
11313    }
11314
11315    #[test]
11316    fn fonte_caminho_shell_background_fires_before_shell_subshell_grouping() {
11317        // Cascade pin on the upstream shell-background arm: a value
11318        // carrying both `&` and `(` (`"../caixa-teia & (cd foo)"` —
11319        // the canonical "I pasted a `cmd & (cd foo)` background-launch
11320        // + subshell-grouping chain" footgun) routes through
11321        // `FonteCaminhoShellBackground` not
11322        // `FonteCaminhoShellSubshellGrouping`. The background-launch
11323        // tail is the load-bearing root-cause edit on every probe-as-
11324        // both value.
11325        let d = dep_with_fonte(DepSource::Path {
11326            caminho: "../caixa-teia & (cd foo)".into(),
11327        });
11328        let err = d.validate().unwrap_err();
11329        assert!(
11330            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11331            "got {err:?}",
11332        );
11333    }
11334
11335    #[test]
11336    fn fonte_caminho_shell_semicolon_fires_before_shell_subshell_grouping() {
11337        // Cascade pin on the upstream shell-semicolon arm: a value
11338        // carrying both `;` and `(` (`"../caixa-teia; (cd foo)"` —
11339        // the canonical sequential-cleanup + subshell-grouping paste
11340        // idiom) routes through `FonteCaminhoShellSemicolon` not
11341        // `FonteCaminhoShellSubshellGrouping`. The sequential-command-
11342        // separator paste is the load-bearing root-cause edit on
11343        // every probe-as-both value.
11344        let d = dep_with_fonte(DepSource::Path {
11345            caminho: "../caixa-teia; (cd foo)".into(),
11346        });
11347        let err = d.validate().unwrap_err();
11348        assert!(
11349            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11350            "got {err:?}",
11351        );
11352    }
11353
11354    #[test]
11355    fn fonte_caminho_shell_pipe_fires_before_shell_subshell_grouping() {
11356        // Cascade pin on the upstream shell-pipe arm: a value carrying
11357        // both `|` and `(` (`"../caixa-teia | (tee log)"` — the
11358        // canonical pipeline-to-subshell-grouping paste idiom) routes
11359        // through `FonteCaminhoShellPipe` not
11360        // `FonteCaminhoShellSubshellGrouping`. The pipeline-tail paste
11361        // is the load-bearing root-cause edit on every probe-as-both
11362        // value.
11363        let d = dep_with_fonte(DepSource::Path {
11364            caminho: "../caixa-teia | (tee log)".into(),
11365        });
11366        let err = d.validate().unwrap_err();
11367        assert!(
11368            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11369            "got {err:?}",
11370        );
11371    }
11372
11373    #[test]
11374    fn fonte_caminho_shell_redirection_fires_before_shell_subshell_grouping() {
11375        // Cascade pin on the upstream shell-redirection arm: a value
11376        // carrying both `>` and `(` (`"../caixa-teia>log (cd foo)"` —
11377        // the canonical "I pasted a `cmd > log (cd foo)` redirect-
11378        // plus-subshell-grouping chain" footgun) routes through
11379        // `FonteCaminhoShellRedirection` not
11380        // `FonteCaminhoShellSubshellGrouping`. The input/output
11381        // redirection metachar carries the more self-locating `byte`
11382        // payload (it names which of `<` or `>` triggered), so the
11383        // prior arm wins on every probe-as-both value.
11384        let d = dep_with_fonte(DepSource::Path {
11385            caminho: "../caixa-teia>log (cd foo)".into(),
11386        });
11387        let err = d.validate().unwrap_err();
11388        assert!(
11389            matches!(
11390                err,
11391                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11392            ),
11393            "got {err:?}",
11394        );
11395    }
11396
11397    #[test]
11398    fn fonte_caminho_backslash_fires_before_shell_subshell_grouping() {
11399        // Cascade pin on the upstream backslash arm: a value carrying
11400        // both `\` and `(` (`"..\caixa-teia\(cd foo)"` — the canonical
11401        // "I pasted a Windows-shell `cd ..\path\(cmd)` chain") routes
11402        // through `FonteCaminhoBackslash` not
11403        // `FonteCaminhoShellSubshellGrouping`. The cross-host-OS-
11404        // separator divergence is the load-bearing axis on every
11405        // probe-as-both value (an author who removes the `\` is the
11406        // root-cause edit; the `(` falls away in the same edit since
11407        // it's downstream of the Windows-shell convention).
11408        let d = dep_with_fonte(DepSource::Path {
11409            caminho: "..\\caixa-teia\\(cd foo)".into(),
11410        });
11411        let err = d.validate().unwrap_err();
11412        assert!(
11413            matches!(err, DepError::FonteCaminhoBackslash { .. }),
11414            "got {err:?}",
11415        );
11416    }
11417
11418    #[test]
11419    fn fonte_caminho_control_char_fires_before_shell_subshell_grouping() {
11420        // Cascade pin on the embedded-control-byte arm: a value
11421        // carrying both a control byte and `(` (`"../foo\n(cd bar)"` —
11422        // the canonical paste-from-multiline-doc footgun where a
11423        // newline landed mid-caminho between two paste fragments)
11424        // routes through `FonteCaminhoControlChar` not
11425        // `FonteCaminhoShellSubshellGrouping`. The POSIX-syscall-
11426        // rejected-byte / NUL-`CString::new`-fail diagnostic is the
11427        // load-bearing axis on every value that probes positive for
11428        // both — mirrors the cascade discipline on every prior arm.
11429        let d = dep_with_fonte(DepSource::Path {
11430            caminho: "../foo\n(cd bar)".into(),
11431        });
11432        let err = d.validate().unwrap_err();
11433        assert!(
11434            matches!(err, DepError::FonteCaminhoControlChar { .. }),
11435            "got {err:?}",
11436        );
11437    }
11438
11439    #[test]
11440    fn fonte_caminho_absolute_fires_before_shell_subshell_grouping() {
11441        // Cascade pin on the load-bearing leading-byte arm: a leading
11442        // `/` value with embedded `(` (`"/etc/(cd foo)"`) routes
11443        // through `FonteCaminhoAbsolute` not
11444        // `FonteCaminhoShellSubshellGrouping` — the host-layout-leak
11445        // diagnostic is the load-bearing axis, the subshell-grouping
11446        // byte is the secondary observation. Same precedence logic as
11447        // every prior leading-byte arm.
11448        let d = dep_with_fonte(DepSource::Path {
11449            caminho: "/etc/(cd foo)".into(),
11450        });
11451        let err = d.validate().unwrap_err();
11452        assert!(
11453            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11454            "got {err:?}",
11455        );
11456    }
11457
11458    #[test]
11459    fn fonte_caminho_var_expansion_fires_before_shell_subshell_grouping() {
11460        // Cascade pin on the upstream leading-`$` var-expansion arm: a
11461        // value carrying both a leading `$` and a `(` (`"$(date)/\
11462        // caixa-teia"` — the canonical "I pasted a `$(date)` modern-
11463        // command-substitution at the head of a sibling-workspace
11464        // path" footgun) routes through `FonteCaminhoVarExpansion` not
11465        // `FonteCaminhoShellSubshellGrouping`. The leading-byte
11466        // shell-variable-expansion is the more self-locating diagnostic
11467        // on values that probe as both — same load-bearing-leading-
11468        // byte cascade discipline every prior `:caminho` arm
11469        // establishes. Closing both halves of `$(<cmd>)` structurally
11470        // (leading `$` here, trailing `)` on the new arm) excludes the
11471        // entire modern Bourne command-substitution surface from the
11472        // typed `:caminho` accepted set; the cascade preserves the
11473        // narrower leading-byte diagnostic on values that probe both
11474        // halves at the canonical leading position.
11475        let d = dep_with_fonte(DepSource::Path {
11476            caminho: "$(date)/caixa-teia".into(),
11477        });
11478        let err = d.validate().unwrap_err();
11479        assert!(
11480            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
11481            "got {err:?}",
11482        );
11483    }
11484
11485    #[test]
11486    fn fonte_caminho_shell_subshell_grouping_fires_before_trailing_slash() {
11487        // Cascade pin on the immediate-successor arm: a value carrying
11488        // both `(` and a trailing `/` (`"../(cd foo)/"` — the canonical
11489        // "I tab-completed a path that already had a subshell-grouping
11490        // expansion tail" footgun) routes through
11491        // `FonteCaminhoShellSubshellGrouping` not
11492        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
11493        // the more semantic-locating axis (an author who removes the
11494        // `(` typically also drops the trailing separator since both
11495        // are paste-from-shell artifacts).
11496        let d = dep_with_fonte(DepSource::Path {
11497            caminho: "../(cd foo)/".into(),
11498        });
11499        let err = d.validate().unwrap_err();
11500        assert!(
11501            matches!(
11502                err,
11503                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
11504            ),
11505            "got {err:?}",
11506        );
11507    }
11508
11509    #[test]
11510    fn fonte_caminho_shell_subshell_grouping_diagnostic_carries_offending_dep_caminho_and_byte() {
11511        // Diagnostic-shape pin (peer with
11512        // `fonte_caminho_shell_glob_diagnostic_carries_offending_dep_caminho_and_byte`
11513        // on the closest two-byte peer arm): the error's Display
11514        // surfaces the offending `:nome`, the offending `:caminho`
11515        // verbatim, the offending byte's hex / character form, and
11516        // names the shell-subshell-grouping footgun explicitly so a
11517        // `feira lint` run can render the diagnostic without re-
11518        // parsing.
11519        let d = dep_with_fonte(DepSource::Path {
11520            caminho: "../caixa-teia/$(date)/build".into(),
11521        });
11522        let rendered = d.validate().unwrap_err().to_string();
11523        assert!(
11524            rendered.contains("caixa-teia"),
11525            "diagnostic must name the offending dep: {rendered}",
11526        );
11527        assert!(
11528            rendered.contains("../caixa-teia/$(date)/build"),
11529            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11530        );
11531        assert!(
11532            rendered.contains("0x28"),
11533            "diagnostic must surface the offending byte hex: {rendered:?}",
11534        );
11535        assert!(
11536            rendered.contains("subshell-grouping"),
11537            "diagnostic must name the shell-subshell-grouping footgun: {rendered:?}",
11538        );
11539        assert!(
11540            rendered.contains("command-substitution"),
11541            "diagnostic must reference the `$(<cmd>)` command-substitution vocabulary: \
11542             {rendered:?}",
11543        );
11544    }
11545
11546    // ── shell-brace-expansion / URI-Template-placeholder arm ───────────
11547    //
11548    // Peer with the prior `FonteCaminhoShellSubshellGrouping` (`(` /
11549    // `)`) byte-pair arm: the same per-byte cascade with the same
11550    // self-locating `byte: u8` diagnostic on the orthogonal `{` /
11551    // `}` brace-expansion / URI-Template placeholder axis. The peer
11552    // [`crate::render::is_git_repo_url`] (42d8f9d) closes the same
11553    // byte pair on the sibling `:fonte :repo` axis under the same
11554    // banner.
11555
11556    #[test]
11557    fn validate_rejects_path_fonte_with_caminho_carrying_brace_expansion_fan_across_siblings() {
11558        // The fail-before-pass-after pin for the canonical paste-from-
11559        // shell-history brace-expansion footgun: an author copies a
11560        // `cd ../{caixa-teia,caixa-helm}/build` shell-history one-
11561        // liner whose `{a,b}` brace expansion fans across two siblings
11562        // and silently passed every prior arm (`Path::is_absolute`
11563        // false on `..`, no control bytes, no `\`, no `<` / `>`, no
11564        // `|`, no `;`, no `&`, no backtick, no `*` / `?`, no `(` /
11565        // `)`, doesn't end in `/`; the leading-`$` f4efe9c
11566        // `FonteCaminhoVarExpansion` arm doesn't fire because the
11567        // value starts with `..` not `$`). The lacre embedded the
11568        // value verbatim, the resolver folded it through `Path::join`
11569        // looking for a literal `./../{caixa-teia,caixa-helm}/build`
11570        // subdirectory, and the failure surfaced at resolve time with
11571        // a non-self-locating `No such file or directory` error. The
11572        // new arm moves the rejection to validate time and names the
11573        // offending dep + caminho + byte verbatim. The arm fires on
11574        // the first `{` encountered.
11575        let d = dep_with_fonte(DepSource::Path {
11576            caminho: "../{caixa-teia,caixa-helm}/build".into(),
11577        });
11578        let err = d.validate().unwrap_err();
11579        let DepError::FonteCaminhoShellBraceExpansion {
11580            nome,
11581            caminho,
11582            byte,
11583        } = err
11584        else {
11585            panic!("expected FonteCaminhoShellBraceExpansion, got {err:?}");
11586        };
11587        assert_eq!(nome, "caixa-teia");
11588        assert_eq!(caminho, "../{caixa-teia,caixa-helm}/build");
11589        assert_eq!(byte, b'{');
11590    }
11591
11592    #[test]
11593    fn validate_rejects_path_fonte_with_caminho_carrying_close_brace() {
11594        // The symmetric close-brace paste shape (`"../caixa-teia}"` —
11595        // the degenerate "I selected an unbalanced closing brace out
11596        // of a shell-history block" idiom that probes for the
11597        // cascade's last-byte handling on a value carrying only the
11598        // closing byte). Pinned separately from the open-brace shape
11599        // so the gate's contract is "any `{` or `}` anywhere", not
11600        // single-byte coverage. Mirrors the peer
11601        // `validate_rejects_path_fonte_with_caminho_carrying_close_paren`
11602        // shape on the immediate-predecessor `FonteCaminhoShellSubshellGrouping`
11603        // arm.
11604        let d = dep_with_fonte(DepSource::Path {
11605            caminho: "../caixa-teia}".into(),
11606        });
11607        let err = d.validate().unwrap_err();
11608        let DepError::FonteCaminhoShellBraceExpansion { byte, .. } = err else {
11609            panic!("expected FonteCaminhoShellBraceExpansion, got {err:?}");
11610        };
11611        assert_eq!(byte, b'}');
11612    }
11613
11614    #[test]
11615    fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_brace() {
11616        // Leading-position `{` shape (`"{caixa-teia,caixa-helm}/build"`
11617        // — the canonical "I selected a `{a,b}` brace-expansion prefix
11618        // out of a shell-history one-liner" idiom). Pinned separately
11619        // from the embedded-byte shape so the gate covers every
11620        // position, not only mid-path.
11621        let d = dep_with_fonte(DepSource::Path {
11622            caminho: "{caixa-teia,caixa-helm}/build".into(),
11623        });
11624        let err = d.validate().unwrap_err();
11625        assert!(
11626            matches!(
11627                err,
11628                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
11629            ),
11630            "got {err:?}",
11631        );
11632    }
11633
11634    #[test]
11635    fn validate_rejects_path_fonte_with_caminho_carrying_uri_template_placeholder() {
11636        // The canonical URI-Template / Mustache / Helm doubled-brace
11637        // placeholder shape (`"../{{org}}/caixa-teia"` — the canonical
11638        // "I copied a `https://github.com/{{org}}/caixa-teia` README
11639        // quick-start / OpenAPI spec / Helm chart `home:` template
11640        // and forgot to substitute the placeholder" footgun). The arm
11641        // fires on the first `{` encountered; pinned so the gate's
11642        // coverage extends from the bare-brace shell-history shape to
11643        // the doubled-brace URI-Template / templating-engine shape.
11644        // Mirrors the peer 42d8f9d `is_git_repo_url` arm on the
11645        // sibling `:fonte :repo` axis.
11646        let d = dep_with_fonte(DepSource::Path {
11647            caminho: "../{{org}}/caixa-teia".into(),
11648        });
11649        let err = d.validate().unwrap_err();
11650        assert!(
11651            matches!(
11652                err,
11653                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
11654            ),
11655            "got {err:?}",
11656        );
11657    }
11658
11659    #[test]
11660    fn validate_rejects_path_fonte_with_caminho_carrying_brace_range_expansion() {
11661        // The canonical bash brace-range-expansion shape (`"../caixa-
11662        // v{1..10}"` — the `{1..10}` sequence expansion every bash /
11663        // zsh `for i in {1..10}; do …; done` idiom uses, the symmetric
11664        // sequence-range form to the `{a,b,c}` comma-separated form).
11665        // The arm fires on the first `{` encountered; pinned so the
11666        // gate's coverage extends from the comma-separated form to
11667        // the integer-range form.
11668        let d = dep_with_fonte(DepSource::Path {
11669            caminho: "../caixa-v{1..10}".into(),
11670        });
11671        let err = d.validate().unwrap_err();
11672        assert!(
11673            matches!(
11674                err,
11675                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
11676            ),
11677            "got {err:?}",
11678        );
11679    }
11680
11681    #[test]
11682    fn validate_accepts_path_fonte_with_caminho_carrying_no_brace_expansion() {
11683        // The positive-control pin: the gate targets only `{` / `}`,
11684        // never adjacent printable ASCII or POSIX-valid bytes. The
11685        // canonical relative POSIX path (`"../caixa-teia"`) and a
11686        // nested deeply-pathed variant with adjacent printable
11687        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue to
11688        // validate cleanly so the gate doesn't widen to a "no
11689        // printable punctuation anywhere" sweep that would defeat
11690        // the entire path-fonte author surface. Peer with
11691        // `validate_accepts_path_fonte_with_caminho_carrying_no_subshell_grouping`
11692        // on the immediate-predecessor arm.
11693        let d = dep_with_fonte(DepSource::Path {
11694            caminho: "../caixa-teia/sub-dir.v2".into(),
11695        });
11696        d.validate().unwrap();
11697    }
11698
11699    #[test]
11700    fn fonte_caminho_shell_subshell_grouping_fires_before_shell_brace_expansion() {
11701        // Cascade pin on the immediate-predecessor arm: a value
11702        // carrying both `(` and `{` (`"../(cd foo)/{a,b}"` — the
11703        // canonical "I pasted a subshell-grouping followed by a
11704        // brace-expansion tail" footgun) routes through
11705        // `FonteCaminhoShellSubshellGrouping` not
11706        // `FonteCaminhoShellBraceExpansion`. The subshell-grouping
11707        // shape is the more semantic-locating axis on every probe-
11708        // as-both value because it closes both halves of the modern
11709        // Bourne `$(<cmd>)` command-substitution surface — same
11710        // cascade discipline every prior `:caminho` arm establishes.
11711        let d = dep_with_fonte(DepSource::Path {
11712            caminho: "../(cd foo)/{a,b}".into(),
11713        });
11714        let err = d.validate().unwrap_err();
11715        assert!(
11716            matches!(
11717                err,
11718                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
11719            ),
11720            "got {err:?}",
11721        );
11722    }
11723
11724    #[test]
11725    fn fonte_caminho_shell_glob_fires_before_shell_brace_expansion() {
11726        // Cascade pin on the upstream shell-glob arm: a value carrying
11727        // both `*` and `{` (`"../caixa-teia/*{a,b}"` — the canonical
11728        // "I pasted a glob expansion followed by a brace-expansion
11729        // tail" footgun) routes through `FonteCaminhoShellGlob` not
11730        // `FonteCaminhoShellBraceExpansion`. The pathname-expansion
11731        // shape is the load-bearing root-cause edit on every
11732        // probe-as-both value.
11733        let d = dep_with_fonte(DepSource::Path {
11734            caminho: "../caixa-teia/*{a,b}".into(),
11735        });
11736        let err = d.validate().unwrap_err();
11737        assert!(
11738            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
11739            "got {err:?}",
11740        );
11741    }
11742
11743    #[test]
11744    fn fonte_caminho_shell_command_substitution_fires_before_shell_brace_expansion() {
11745        // Cascade pin on the upstream shell-command-substitution arm:
11746        // a value carrying both a backtick and `{` (``"../`whoami`/{a,b}"``
11747        // — the canonical "I pasted a legacy-backtick command-
11748        // substitution followed by a brace-expansion fan-out" footgun)
11749        // routes through `FonteCaminhoShellCommandSubstitution` not
11750        // `FonteCaminhoShellBraceExpansion`. The CWE-78 shell-
11751        // command-injection vector is the load-bearing root-cause
11752        // edit on every probe-as-both value.
11753        let d = dep_with_fonte(DepSource::Path {
11754            caminho: "../`whoami`/{a,b}".into(),
11755        });
11756        let err = d.validate().unwrap_err();
11757        assert!(
11758            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11759            "got {err:?}",
11760        );
11761    }
11762
11763    #[test]
11764    fn fonte_caminho_shell_background_fires_before_shell_brace_expansion() {
11765        // Cascade pin on the upstream shell-background arm: a value
11766        // carrying both `&` and `{` (`"../caixa-teia & {a,b}"` — the
11767        // canonical "I pasted a `cmd & {fork-fan}` background-launch
11768        // + brace-expansion chain" footgun) routes through
11769        // `FonteCaminhoShellBackground` not
11770        // `FonteCaminhoShellBraceExpansion`. The background-launch
11771        // tail is the load-bearing root-cause edit on every
11772        // probe-as-both value.
11773        let d = dep_with_fonte(DepSource::Path {
11774            caminho: "../caixa-teia & {a,b}".into(),
11775        });
11776        let err = d.validate().unwrap_err();
11777        assert!(
11778            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11779            "got {err:?}",
11780        );
11781    }
11782
11783    #[test]
11784    fn fonte_caminho_shell_semicolon_fires_before_shell_brace_expansion() {
11785        // Cascade pin on the upstream shell-semicolon arm: a value
11786        // carrying both `;` and `{` (`"../caixa-teia; {a,b}"` — the
11787        // canonical sequential-cleanup + brace-expansion paste
11788        // idiom) routes through `FonteCaminhoShellSemicolon` not
11789        // `FonteCaminhoShellBraceExpansion`. The sequential-command-
11790        // separator paste is the load-bearing root-cause edit on
11791        // every probe-as-both value.
11792        let d = dep_with_fonte(DepSource::Path {
11793            caminho: "../caixa-teia; {a,b}".into(),
11794        });
11795        let err = d.validate().unwrap_err();
11796        assert!(
11797            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11798            "got {err:?}",
11799        );
11800    }
11801
11802    #[test]
11803    fn fonte_caminho_shell_pipe_fires_before_shell_brace_expansion() {
11804        // Cascade pin on the upstream shell-pipe arm: a value
11805        // carrying both `|` and `{` (`"../caixa-teia | {tee,cat}"`
11806        // — the canonical pipeline-to-brace-expansion paste idiom)
11807        // routes through `FonteCaminhoShellPipe` not
11808        // `FonteCaminhoShellBraceExpansion`. The pipeline-tail paste
11809        // is the load-bearing root-cause edit on every probe-as-
11810        // both value.
11811        let d = dep_with_fonte(DepSource::Path {
11812            caminho: "../caixa-teia | {tee,cat}".into(),
11813        });
11814        let err = d.validate().unwrap_err();
11815        assert!(
11816            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11817            "got {err:?}",
11818        );
11819    }
11820
11821    #[test]
11822    fn fonte_caminho_shell_redirection_fires_before_shell_brace_expansion() {
11823        // Cascade pin on the upstream shell-redirection arm: a value
11824        // carrying both `>` and `{` (`"../caixa-teia>log {a,b}"` —
11825        // the canonical "I pasted a `cmd > log {a,b}` redirect-
11826        // plus-brace-expansion chain" footgun) routes through
11827        // `FonteCaminhoShellRedirection` not
11828        // `FonteCaminhoShellBraceExpansion`. The input/output
11829        // redirection metachar carries the more self-locating
11830        // `byte` payload, so the prior arm wins on every probe-
11831        // as-both value.
11832        let d = dep_with_fonte(DepSource::Path {
11833            caminho: "../caixa-teia>log {a,b}".into(),
11834        });
11835        let err = d.validate().unwrap_err();
11836        assert!(
11837            matches!(
11838                err,
11839                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11840            ),
11841            "got {err:?}",
11842        );
11843    }
11844
11845    #[test]
11846    fn fonte_caminho_backslash_fires_before_shell_brace_expansion() {
11847        // Cascade pin on the upstream backslash arm: a value
11848        // carrying both `\` and `{` (`"..\caixa-teia\{a,b}"` — the
11849        // canonical "I pasted a Windows-shell `cd ..\path\{a,b}`
11850        // chain") routes through `FonteCaminhoBackslash` not
11851        // `FonteCaminhoShellBraceExpansion`. The cross-host-OS-
11852        // separator divergence is the load-bearing axis on every
11853        // probe-as-both value.
11854        let d = dep_with_fonte(DepSource::Path {
11855            caminho: "..\\caixa-teia\\{a,b}".into(),
11856        });
11857        let err = d.validate().unwrap_err();
11858        assert!(
11859            matches!(err, DepError::FonteCaminhoBackslash { .. }),
11860            "got {err:?}",
11861        );
11862    }
11863
11864    #[test]
11865    fn fonte_caminho_control_char_fires_before_shell_brace_expansion() {
11866        // Cascade pin on the embedded-control-byte arm: a value
11867        // carrying both a control byte and `{` (`"../foo\n{a,b}"` —
11868        // the canonical paste-from-multiline-doc footgun where a
11869        // newline landed mid-caminho between two paste fragments)
11870        // routes through `FonteCaminhoControlChar` not
11871        // `FonteCaminhoShellBraceExpansion`. The POSIX-syscall-
11872        // rejected-byte / NUL-`CString::new`-fail diagnostic is the
11873        // load-bearing axis on every value that probes positive for
11874        // both — mirrors the cascade discipline on every prior arm.
11875        let d = dep_with_fonte(DepSource::Path {
11876            caminho: "../foo\n{a,b}".into(),
11877        });
11878        let err = d.validate().unwrap_err();
11879        assert!(
11880            matches!(err, DepError::FonteCaminhoControlChar { .. }),
11881            "got {err:?}",
11882        );
11883    }
11884
11885    #[test]
11886    fn fonte_caminho_absolute_fires_before_shell_brace_expansion() {
11887        // Cascade pin on the load-bearing leading-byte arm: a
11888        // leading `/` value with embedded `{` (`"/etc/{a,b}"`)
11889        // routes through `FonteCaminhoAbsolute` not
11890        // `FonteCaminhoShellBraceExpansion` — the host-layout-leak
11891        // diagnostic is the load-bearing axis, the brace-expansion
11892        // byte is the secondary observation. Same precedence logic
11893        // as every prior leading-byte arm.
11894        let d = dep_with_fonte(DepSource::Path {
11895            caminho: "/etc/{a,b}".into(),
11896        });
11897        let err = d.validate().unwrap_err();
11898        assert!(
11899            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11900            "got {err:?}",
11901        );
11902    }
11903
11904    #[test]
11905    fn fonte_caminho_var_expansion_fires_before_shell_brace_expansion() {
11906        // Cascade pin on the upstream leading-`$` var-expansion
11907        // arm: a value carrying both a leading `$` and a `{`
11908        // (`"${ORG}/caixa-teia"` — the canonical "I pasted a
11909        // `${ORG}` shell-variable + curly-brace expansion at the
11910        // head of a sibling-workspace path" footgun) routes through
11911        // `FonteCaminhoVarExpansion` not
11912        // `FonteCaminhoShellBraceExpansion`. The leading-byte
11913        // shell-variable-expansion is the more self-locating
11914        // diagnostic on values that probe as both — same
11915        // load-bearing-leading-byte cascade discipline every prior
11916        // `:caminho` arm establishes.
11917        let d = dep_with_fonte(DepSource::Path {
11918            caminho: "${ORG}/caixa-teia".into(),
11919        });
11920        let err = d.validate().unwrap_err();
11921        assert!(
11922            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
11923            "got {err:?}",
11924        );
11925    }
11926
11927    #[test]
11928    fn fonte_caminho_shell_brace_expansion_fires_before_trailing_slash() {
11929        // Cascade pin on the immediate-successor arm: a value
11930        // carrying both `{` and a trailing `/`
11931        // (`"../{caixa-teia,caixa-helm}/"` — the canonical "I
11932        // tab-completed a path that already had a brace-expansion
11933        // expansion tail" footgun) routes through
11934        // `FonteCaminhoShellBraceExpansion` not
11935        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
11936        // is the more semantic-locating axis (an author who removes
11937        // the `{` typically also drops the trailing separator since
11938        // both are paste-from-shell artifacts).
11939        let d = dep_with_fonte(DepSource::Path {
11940            caminho: "../{caixa-teia,caixa-helm}/".into(),
11941        });
11942        let err = d.validate().unwrap_err();
11943        assert!(
11944            matches!(
11945                err,
11946                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
11947            ),
11948            "got {err:?}",
11949        );
11950    }
11951
11952    #[test]
11953    fn fonte_caminho_shell_brace_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
11954        // Diagnostic-shape pin (peer with
11955        // `fonte_caminho_shell_subshell_grouping_diagnostic_carries_offending_dep_caminho_and_byte`
11956        // on the closest two-byte peer arm): the error's Display
11957        // surfaces the offending `:nome`, the offending `:caminho`
11958        // verbatim, the offending byte's hex / character form, and
11959        // names the shell-brace-expansion / URI-Template footgun
11960        // explicitly so a `feira lint` run can render the diagnostic
11961        // without re-parsing.
11962        let d = dep_with_fonte(DepSource::Path {
11963            caminho: "../{caixa-teia,caixa-helm}/build".into(),
11964        });
11965        let rendered = d.validate().unwrap_err().to_string();
11966        assert!(
11967            rendered.contains("caixa-teia"),
11968            "diagnostic must name the offending dep: {rendered}",
11969        );
11970        assert!(
11971            rendered.contains("../{caixa-teia,caixa-helm}/build"),
11972            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11973        );
11974        assert!(
11975            rendered.contains("0x7b"),
11976            "diagnostic must surface the offending byte hex: {rendered:?}",
11977        );
11978        assert!(
11979            rendered.contains("brace-expansion"),
11980            "diagnostic must name the shell-brace-expansion footgun: {rendered:?}",
11981        );
11982        assert!(
11983            rendered.contains("URI Template"),
11984            "diagnostic must reference the RFC-6570 URI-Template-placeholder vocabulary: \
11985             {rendered:?}",
11986        );
11987    }
11988
11989    #[test]
11990    fn validate_rejects_path_fonte_with_caminho_carrying_bracket_glob_character_class() {
11991        // The canonical paste-from-shell-history bracket-glob /
11992        // character-class footgun: an author copies a
11993        // `cd ../caixa-[a-z]/build` shell-history one-liner whose
11994        // `[a-z]` POSIX glob character-class matches every lowercase-
11995        // ASCII-suffix sibling caixa directory and silently passed
11996        // every prior arm (`Path::is_absolute` false on `..`, no
11997        // control bytes, no `\`, no `<` / `>`, no `|`, no `;`, no
11998        // `&`, no backtick, no `*` / `?`, no `(` / `)`, no `{` /
11999        // `}`, doesn't end in `/`; the leading-`$` f4efe9c
12000        // `FonteCaminhoVarExpansion` arm doesn't fire because the
12001        // value starts with `..` not `$`). The lacre embedded the
12002        // value verbatim, the resolver folded it through
12003        // `Path::join` looking for a literal `./../caixa-[a-z]/
12004        // build` subdirectory, and the failure surfaced at resolve
12005        // time with a non-self-locating `No such file or directory`
12006        // error. The new arm moves the rejection to validate time
12007        // and names the offending dep + caminho + byte verbatim.
12008        // The arm fires on the first `[` encountered.
12009        let d = dep_with_fonte(DepSource::Path {
12010            caminho: "../caixa-[a-z]/build".into(),
12011        });
12012        let err = d.validate().unwrap_err();
12013        let DepError::FonteCaminhoShellBracketExpansion {
12014            nome,
12015            caminho,
12016            byte,
12017        } = err
12018        else {
12019            panic!("expected FonteCaminhoShellBracketExpansion, got {err:?}");
12020        };
12021        assert_eq!(nome, "caixa-teia");
12022        assert_eq!(caminho, "../caixa-[a-z]/build");
12023        assert_eq!(byte, b'[');
12024    }
12025
12026    #[test]
12027    fn validate_rejects_path_fonte_with_caminho_carrying_close_bracket() {
12028        // The symmetric close-bracket paste shape (`"../caixa-teia]"`
12029        // — the degenerate "I selected an unbalanced closing bracket
12030        // out of a glob character-class block" idiom that probes for
12031        // the cascade's last-byte handling on a value carrying only
12032        // the closing byte). Pinned separately from the open-bracket
12033        // shape so the gate's contract is "any `[` or `]` anywhere",
12034        // not single-byte coverage. Mirrors the peer
12035        // `validate_rejects_path_fonte_with_caminho_carrying_close_brace`
12036        // shape on the immediate-predecessor
12037        // `FonteCaminhoShellBraceExpansion` arm.
12038        let d = dep_with_fonte(DepSource::Path {
12039            caminho: "../caixa-teia]".into(),
12040        });
12041        let err = d.validate().unwrap_err();
12042        let DepError::FonteCaminhoShellBracketExpansion { byte, .. } = err else {
12043            panic!("expected FonteCaminhoShellBracketExpansion, got {err:?}");
12044        };
12045        assert_eq!(byte, b']');
12046    }
12047
12048    #[test]
12049    fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_bracket() {
12050        // Leading-position `[` shape (`"[caixa-teia]/build"` — the
12051        // canonical "I selected a `[caixa-teia]` TOML-table-header /
12052        // glob-character-class prefix out of an aligned config /
12053        // shell-history one-liner" idiom). Pinned separately from
12054        // the embedded-byte shape so the gate covers every position,
12055        // not only mid-path.
12056        let d = dep_with_fonte(DepSource::Path {
12057            caminho: "[caixa-teia]/build".into(),
12058        });
12059        let err = d.validate().unwrap_err();
12060        assert!(
12061            matches!(
12062                err,
12063                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
12064            ),
12065            "got {err:?}",
12066        );
12067    }
12068
12069    #[test]
12070    fn validate_rejects_path_fonte_with_caminho_carrying_toml_inline_array() {
12071        // The canonical TOML inline-array / YAML flow-sequence
12072        // paste shape (`"../[\"a\", \"b\"]/caixa-teia"` — the
12073        // canonical "I copied a `features = [\"a\", \"b\"]` TOML
12074        // inline-array out of a sibling-Cargo manifest" cross-idiom
12075        // leak; the symmetric YAML flow-sequence form `paths: [/a,
12076        // /b]` paste-from-values.yaml shape carries the same
12077        // bracket pair). The arm fires on the first `[` encountered;
12078        // pinned so the gate's coverage extends from the bare-
12079        // bracket glob-character-class shape to the TOML / YAML /
12080        // JSON array-literal shape.
12081        let d = dep_with_fonte(DepSource::Path {
12082            caminho: "../[\"a\", \"b\"]/caixa-teia".into(),
12083        });
12084        let err = d.validate().unwrap_err();
12085        assert!(
12086            matches!(
12087                err,
12088                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
12089            ),
12090            "got {err:?}",
12091        );
12092    }
12093
12094    #[test]
12095    fn validate_rejects_path_fonte_with_caminho_carrying_shell_test_builtin() {
12096        // The canonical POSIX `test` / `[` builtin command paste
12097        // shape (`"../[ -d caixa-teia ]"` — the `[ <expr> ]` shell-
12098        // script conditional every paste-from-shell-script idiom
12099        // carries; bash's `[[ <expr> ]]` extended-test grammar
12100        // would surface the same byte pair). The arm fires on the
12101        // first `[` encountered; pinned so the gate's coverage
12102        // extends from the embedded-glob-character-class shape to
12103        // the leading-`test`-builtin / extended-test form.
12104        let d = dep_with_fonte(DepSource::Path {
12105            caminho: "../[ -d caixa-teia ]".into(),
12106        });
12107        let err = d.validate().unwrap_err();
12108        assert!(
12109            matches!(
12110                err,
12111                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
12112            ),
12113            "got {err:?}",
12114        );
12115    }
12116
12117    #[test]
12118    fn validate_accepts_path_fonte_with_caminho_carrying_no_bracket_expansion() {
12119        // The positive-control pin: the gate targets only `[` /
12120        // `]`, never adjacent printable ASCII or POSIX-valid bytes.
12121        // The canonical relative POSIX path (`"../caixa-teia"`) and
12122        // a nested deeply-pathed variant with adjacent printable
12123        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
12124        // to validate cleanly so the gate doesn't widen to a "no
12125        // printable punctuation anywhere" sweep that would defeat
12126        // the entire path-fonte author surface. Peer with
12127        // `validate_accepts_path_fonte_with_caminho_carrying_no_brace_expansion`
12128        // on the immediate-predecessor arm.
12129        let d = dep_with_fonte(DepSource::Path {
12130            caminho: "../caixa-teia/sub-dir.v2".into(),
12131        });
12132        d.validate().unwrap();
12133    }
12134
12135    #[test]
12136    fn fonte_caminho_shell_brace_expansion_fires_before_shell_bracket_expansion() {
12137        // Cascade pin on the immediate-predecessor arm: a value
12138        // carrying both `{` and `[` (`"../{a,b}[ch]"` — the
12139        // canonical "I pasted a brace-expansion fan followed by a
12140        // glob-character-class tail" footgun) routes through
12141        // `FonteCaminhoShellBraceExpansion` not
12142        // `FonteCaminhoShellBracketExpansion`. The brace-expansion
12143        // fan is the load-bearing root-cause edit on every
12144        // probe-as-both value because the bracket-class tail
12145        // typically rides on a prior brace-expansion expansion;
12146        // same cascade discipline every prior `:caminho` arm
12147        // establishes.
12148        let d = dep_with_fonte(DepSource::Path {
12149            caminho: "../{a,b}[ch]".into(),
12150        });
12151        let err = d.validate().unwrap_err();
12152        assert!(
12153            matches!(
12154                err,
12155                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
12156            ),
12157            "got {err:?}",
12158        );
12159    }
12160
12161    #[test]
12162    fn fonte_caminho_shell_subshell_grouping_fires_before_shell_bracket_expansion() {
12163        // Cascade pin on the upstream shell-subshell-grouping arm:
12164        // a value carrying both `(` and `[` (`"../(cd foo)/[ch]"` —
12165        // the canonical "I pasted a subshell-grouping followed by
12166        // a glob-character-class tail" footgun) routes through
12167        // `FonteCaminhoShellSubshellGrouping` not
12168        // `FonteCaminhoShellBracketExpansion`. The modern Bourne
12169        // `$(<cmd>)` command-substitution boundary is the load-
12170        // bearing axis on every probe-as-both value.
12171        let d = dep_with_fonte(DepSource::Path {
12172            caminho: "../(cd foo)/[ch]".into(),
12173        });
12174        let err = d.validate().unwrap_err();
12175        assert!(
12176            matches!(
12177                err,
12178                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
12179            ),
12180            "got {err:?}",
12181        );
12182    }
12183
12184    #[test]
12185    fn fonte_caminho_shell_glob_fires_before_shell_bracket_expansion() {
12186        // Cascade pin on the upstream shell-glob arm: a value
12187        // carrying both `*` and `[` (`"../caixa-teia/*[ch]"` — the
12188        // canonical "I pasted a `*.[ch]` C-source-file glob whose
12189        // unbounded `*` precedes the bracket character-class"
12190        // footgun) routes through `FonteCaminhoShellGlob` not
12191        // `FonteCaminhoShellBracketExpansion`. The unbounded
12192        // pathname-expansion sentinel is the load-bearing root-
12193        // cause edit on every probe-as-both value — the unbounded
12194        // `*` carries the more aggressive expansion vector than
12195        // the bounded `[ch]` class, so the prior arm wins.
12196        let d = dep_with_fonte(DepSource::Path {
12197            caminho: "../caixa-teia/*[ch]".into(),
12198        });
12199        let err = d.validate().unwrap_err();
12200        assert!(
12201            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12202            "got {err:?}",
12203        );
12204    }
12205
12206    #[test]
12207    fn fonte_caminho_shell_command_substitution_fires_before_shell_bracket_expansion() {
12208        // Cascade pin on the upstream shell-command-substitution
12209        // arm: a value carrying both a backtick and `[`
12210        // (``"../`whoami`/[ch]"`` — the canonical "I pasted a
12211        // legacy-backtick command-substitution followed by a
12212        // glob-character-class tail" footgun) routes through
12213        // `FonteCaminhoShellCommandSubstitution` not
12214        // `FonteCaminhoShellBracketExpansion`. The CWE-78 shell-
12215        // command-injection vector is the load-bearing root-cause
12216        // edit on every probe-as-both value.
12217        let d = dep_with_fonte(DepSource::Path {
12218            caminho: "../`whoami`/[ch]".into(),
12219        });
12220        let err = d.validate().unwrap_err();
12221        assert!(
12222            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
12223            "got {err:?}",
12224        );
12225    }
12226
12227    #[test]
12228    fn fonte_caminho_shell_background_fires_before_shell_bracket_expansion() {
12229        // Cascade pin on the upstream shell-background arm: a
12230        // value carrying both `&` and `[` (`"../caixa-teia & [ch]"`
12231        // — the canonical "I pasted a `cmd & [glob]` background-
12232        // launch + bracket-class chain" footgun) routes through
12233        // `FonteCaminhoShellBackground` not
12234        // `FonteCaminhoShellBracketExpansion`. The background-
12235        // launch tail is the load-bearing root-cause edit on
12236        // every probe-as-both value.
12237        let d = dep_with_fonte(DepSource::Path {
12238            caminho: "../caixa-teia & [ch]".into(),
12239        });
12240        let err = d.validate().unwrap_err();
12241        assert!(
12242            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
12243            "got {err:?}",
12244        );
12245    }
12246
12247    #[test]
12248    fn fonte_caminho_shell_semicolon_fires_before_shell_bracket_expansion() {
12249        // Cascade pin on the upstream shell-semicolon arm: a value
12250        // carrying both `;` and `[` (`"../caixa-teia; [ch]"` — the
12251        // canonical sequential-cleanup + bracket-class paste
12252        // idiom) routes through `FonteCaminhoShellSemicolon` not
12253        // `FonteCaminhoShellBracketExpansion`. The sequential-
12254        // command-separator paste is the load-bearing root-cause
12255        // edit on every probe-as-both value.
12256        let d = dep_with_fonte(DepSource::Path {
12257            caminho: "../caixa-teia; [ch]".into(),
12258        });
12259        let err = d.validate().unwrap_err();
12260        assert!(
12261            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
12262            "got {err:?}",
12263        );
12264    }
12265
12266    #[test]
12267    fn fonte_caminho_shell_pipe_fires_before_shell_bracket_expansion() {
12268        // Cascade pin on the upstream shell-pipe arm: a value
12269        // carrying both `|` and `[` (`"../caixa-teia | [tee]"` —
12270        // the canonical pipeline-to-bracket-class paste idiom)
12271        // routes through `FonteCaminhoShellPipe` not
12272        // `FonteCaminhoShellBracketExpansion`. The pipeline-tail
12273        // paste is the load-bearing root-cause edit on every
12274        // probe-as-both value.
12275        let d = dep_with_fonte(DepSource::Path {
12276            caminho: "../caixa-teia | [tee]".into(),
12277        });
12278        let err = d.validate().unwrap_err();
12279        assert!(
12280            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
12281            "got {err:?}",
12282        );
12283    }
12284
12285    #[test]
12286    fn fonte_caminho_shell_redirection_fires_before_shell_bracket_expansion() {
12287        // Cascade pin on the upstream shell-redirection arm: a
12288        // value carrying both `>` and `[` (`"../caixa-teia>log
12289        // [ch]"` — the canonical "I pasted a `cmd > log [glob]`
12290        // redirect-plus-bracket chain" footgun) routes through
12291        // `FonteCaminhoShellRedirection` not
12292        // `FonteCaminhoShellBracketExpansion`. The input/output
12293        // redirection metachar carries the more self-locating
12294        // `byte` payload, so the prior arm wins on every
12295        // probe-as-both value.
12296        let d = dep_with_fonte(DepSource::Path {
12297            caminho: "../caixa-teia>log [ch]".into(),
12298        });
12299        let err = d.validate().unwrap_err();
12300        assert!(
12301            matches!(
12302                err,
12303                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
12304            ),
12305            "got {err:?}",
12306        );
12307    }
12308
12309    #[test]
12310    fn fonte_caminho_backslash_fires_before_shell_bracket_expansion() {
12311        // Cascade pin on the upstream backslash arm: a value
12312        // carrying both `\` and `[` (`"..\caixa-teia\[ch]"` — the
12313        // canonical "I pasted a Windows-shell `cd ..\path\[glob]`
12314        // chain") routes through `FonteCaminhoBackslash` not
12315        // `FonteCaminhoShellBracketExpansion`. The cross-host-OS-
12316        // separator divergence is the load-bearing axis on every
12317        // probe-as-both value.
12318        let d = dep_with_fonte(DepSource::Path {
12319            caminho: "..\\caixa-teia\\[ch]".into(),
12320        });
12321        let err = d.validate().unwrap_err();
12322        assert!(
12323            matches!(err, DepError::FonteCaminhoBackslash { .. }),
12324            "got {err:?}",
12325        );
12326    }
12327
12328    #[test]
12329    fn fonte_caminho_control_char_fires_before_shell_bracket_expansion() {
12330        // Cascade pin on the embedded-control-byte arm: a value
12331        // carrying both a control byte and `[` (`"../foo\n[ch]"` —
12332        // the canonical paste-from-multiline-doc footgun where a
12333        // newline landed mid-caminho between two paste fragments)
12334        // routes through `FonteCaminhoControlChar` not
12335        // `FonteCaminhoShellBracketExpansion`. The POSIX-syscall-
12336        // rejected-byte / NUL-`CString::new`-fail diagnostic is
12337        // the load-bearing axis on every value that probes
12338        // positive for both — mirrors the cascade discipline on
12339        // every prior arm.
12340        let d = dep_with_fonte(DepSource::Path {
12341            caminho: "../foo\n[ch]".into(),
12342        });
12343        let err = d.validate().unwrap_err();
12344        assert!(
12345            matches!(err, DepError::FonteCaminhoControlChar { .. }),
12346            "got {err:?}",
12347        );
12348    }
12349
12350    #[test]
12351    fn fonte_caminho_absolute_fires_before_shell_bracket_expansion() {
12352        // Cascade pin on the load-bearing leading-byte arm: a
12353        // leading `/` value with embedded `[` (`"/etc/[ch]"`)
12354        // routes through `FonteCaminhoAbsolute` not
12355        // `FonteCaminhoShellBracketExpansion` — the host-layout-
12356        // leak diagnostic is the load-bearing axis, the bracket-
12357        // expansion byte is the secondary observation. Same
12358        // precedence logic as every prior leading-byte arm.
12359        let d = dep_with_fonte(DepSource::Path {
12360            caminho: "/etc/[ch]".into(),
12361        });
12362        let err = d.validate().unwrap_err();
12363        assert!(
12364            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
12365            "got {err:?}",
12366        );
12367    }
12368
12369    #[test]
12370    fn fonte_caminho_var_expansion_fires_before_shell_bracket_expansion() {
12371        // Cascade pin on the upstream leading-`$` var-expansion
12372        // arm: a value carrying both a leading `$` and a `[`
12373        // (`"$DIR/[ch]"` — the canonical "I pasted a `$DIR` shell-
12374        // variable + bracket-class at the head of a sibling-
12375        // workspace path" footgun) routes through
12376        // `FonteCaminhoVarExpansion` not
12377        // `FonteCaminhoShellBracketExpansion`. The leading-byte
12378        // shell-variable-expansion is the more self-locating
12379        // diagnostic on values that probe as both — same
12380        // load-bearing-leading-byte cascade discipline every
12381        // prior `:caminho` arm establishes.
12382        let d = dep_with_fonte(DepSource::Path {
12383            caminho: "$DIR/[ch]".into(),
12384        });
12385        let err = d.validate().unwrap_err();
12386        assert!(
12387            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
12388            "got {err:?}",
12389        );
12390    }
12391
12392    #[test]
12393    fn fonte_caminho_shell_bracket_expansion_fires_before_trailing_slash() {
12394        // Cascade pin on the immediate-successor arm: a value
12395        // carrying both `[` and a trailing `/` (`"../[a-z]/"` —
12396        // the canonical "I tab-completed a path that already had
12397        // a bracket-glob-character-class expansion tail" footgun)
12398        // routes through `FonteCaminhoShellBracketExpansion` not
12399        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
12400        // is the more semantic-locating axis (an author who
12401        // removes the `[` typically also drops the trailing
12402        // separator since both are paste-from-shell artifacts).
12403        let d = dep_with_fonte(DepSource::Path {
12404            caminho: "../[a-z]/".into(),
12405        });
12406        let err = d.validate().unwrap_err();
12407        assert!(
12408            matches!(
12409                err,
12410                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
12411            ),
12412            "got {err:?}",
12413        );
12414    }
12415
12416    #[test]
12417    fn fonte_caminho_shell_bracket_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
12418        // Diagnostic-shape pin (peer with
12419        // `fonte_caminho_shell_brace_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
12420        // on the closest two-byte peer arm): the error's Display
12421        // surfaces the offending `:nome`, the offending `:caminho`
12422        // verbatim, the offending byte's hex / character form, and
12423        // names the shell-bracket-expansion / glob-character-class
12424        // footgun explicitly so a `feira lint` run can render the
12425        // diagnostic without re-parsing.
12426        let d = dep_with_fonte(DepSource::Path {
12427            caminho: "../caixa-[a-z]/build".into(),
12428        });
12429        let rendered = d.validate().unwrap_err().to_string();
12430        assert!(
12431            rendered.contains("caixa-teia"),
12432            "diagnostic must name the offending dep: {rendered}",
12433        );
12434        assert!(
12435            rendered.contains("../caixa-[a-z]/build"),
12436            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
12437        );
12438        assert!(
12439            rendered.contains("0x5b"),
12440            "diagnostic must surface the offending byte hex: {rendered:?}",
12441        );
12442        assert!(
12443            rendered.contains("bracket-expansion"),
12444            "diagnostic must name the shell-bracket-expansion footgun: {rendered:?}",
12445        );
12446        assert!(
12447            rendered.contains("glob-character-class"),
12448            "diagnostic must reference the POSIX glob-character-class vocabulary: \
12449             {rendered:?}",
12450        );
12451    }
12452
12453    #[test]
12454    fn validate_rejects_path_fonte_with_caminho_carrying_single_quote_grouping() {
12455        // The canonical paste-from-shell-history strong-quoted
12456        // sibling-workspace-path footgun: an author copies a
12457        // `cd '../caixa-teia'` shell-history one-liner whose strong-
12458        // quoting preserved the path across a whitespace paste
12459        // boundary and silently passed every prior arm
12460        // (`Path::is_absolute` false on `'..`, no control bytes, no
12461        // `\`, no `<` / `>`, no `|`, no `;`, no `&`, no backtick, no
12462        // `*` / `?`, no `(` / `)`, no `{` / `}`, no `[` / `]`,
12463        // doesn't end in `/`; the leading-`$` f4efe9c
12464        // `FonteCaminhoVarExpansion` arm doesn't fire because the
12465        // value starts with `'` not `$`). The lacre embedded the
12466        // value verbatim, the resolver folded it through
12467        // `Path::join` looking for a literal `./'../caixa-teia'`
12468        // subdirectory, and the failure surfaced at resolve time
12469        // with a non-self-locating `No such file or directory`
12470        // error. The new arm moves the rejection to validate time
12471        // and names the offending dep + caminho + byte verbatim.
12472        // The arm fires on the first `'` encountered.
12473        let d = dep_with_fonte(DepSource::Path {
12474            caminho: "'../caixa-teia'".into(),
12475        });
12476        let err = d.validate().unwrap_err();
12477        let DepError::FonteCaminhoShellQuoteGrouping {
12478            nome,
12479            caminho,
12480            byte,
12481        } = err
12482        else {
12483            panic!("expected FonteCaminhoShellQuoteGrouping, got {err:?}");
12484        };
12485        assert_eq!(nome, "caixa-teia");
12486        assert_eq!(caminho, "'../caixa-teia'");
12487        assert_eq!(byte, b'\'');
12488    }
12489
12490    #[test]
12491    fn validate_rejects_path_fonte_with_caminho_carrying_double_quote_grouping() {
12492        // The symmetric weak-quoted paste shape (`"\"../caixa-teia\""`
12493        // — the canonical paste-from-JSON-config / paste-from-YAML-
12494        // flow-scalar / paste-from-TOML-basic-string / paste-from-
12495        // tatara-lisp-string-literal cross-idiom leak). Pinned
12496        // separately from the single-quote shape so the gate's
12497        // contract is "any `'` or `\"` anywhere", not single-byte
12498        // coverage. Mirrors the peer
12499        // `validate_rejects_path_fonte_with_caminho_carrying_close_bracket`
12500        // shape on the immediate-predecessor
12501        // `FonteCaminhoShellBracketExpansion` arm.
12502        let d = dep_with_fonte(DepSource::Path {
12503            caminho: "\"../caixa-teia\"".into(),
12504        });
12505        let err = d.validate().unwrap_err();
12506        let DepError::FonteCaminhoShellQuoteGrouping { byte, .. } = err else {
12507            panic!("expected FonteCaminhoShellQuoteGrouping, got {err:?}");
12508        };
12509        assert_eq!(byte, b'"');
12510    }
12511
12512    #[test]
12513    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_double_quote() {
12514        // Embedded-position `"` shape (`"../\"caixa-teia\""` — the
12515        // canonical "I pasted a JSON key-value pair fragment into
12516        // the middle of the path" idiom). Pinned separately from
12517        // the leading-byte shape so the gate covers every position,
12518        // not only leading.
12519        let d = dep_with_fonte(DepSource::Path {
12520            caminho: "../\"caixa-teia\"".into(),
12521        });
12522        let err = d.validate().unwrap_err();
12523        assert!(
12524            matches!(
12525                err,
12526                DepError::FonteCaminhoShellQuoteGrouping { byte: b'"', .. },
12527            ),
12528            "got {err:?}",
12529        );
12530    }
12531
12532    #[test]
12533    fn validate_rejects_path_fonte_with_caminho_carrying_yaml_flow_scalar_paste() {
12534        // The canonical YAML double-quoted flow-scalar cross-idiom
12535        // leak shape (`"path: \"../caixa-teia\""` — the "I copied a
12536        // `path: \"...\"` YAML flow-scalar entry out of an aligned
12537        // values.yaml / K8s manifest and dropped it verbatim into
12538        // the `:caminho` slot including the `path: ` key prefix"
12539        // paste-idiom). The arm fires on the first `"` encountered;
12540        // pinned so the gate's coverage extends from the bare-quote
12541        // paste shape to the aligned-YAML-manifest cross-idiom-leak
12542        // shape.
12543        let d = dep_with_fonte(DepSource::Path {
12544            caminho: "path: \"../caixa-teia\"".into(),
12545        });
12546        let err = d.validate().unwrap_err();
12547        assert!(
12548            matches!(
12549                err,
12550                DepError::FonteCaminhoShellQuoteGrouping { byte: b'"', .. },
12551            ),
12552            "got {err:?}",
12553        );
12554    }
12555
12556    #[test]
12557    fn validate_accepts_path_fonte_with_caminho_carrying_no_quote_grouping() {
12558        // The positive-control pin: the gate targets only `'` /
12559        // `"`, never adjacent printable ASCII or POSIX-valid bytes.
12560        // The canonical relative POSIX path (`"../caixa-teia"`) and
12561        // a nested deeply-pathed variant with adjacent printable
12562        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
12563        // to validate cleanly so the gate doesn't widen to a "no
12564        // printable punctuation anywhere" sweep that would defeat
12565        // the entire path-fonte author surface. Peer with
12566        // `validate_accepts_path_fonte_with_caminho_carrying_no_bracket_expansion`
12567        // on the immediate-predecessor arm.
12568        let d = dep_with_fonte(DepSource::Path {
12569            caminho: "../caixa-teia/sub-dir.v2".into(),
12570        });
12571        d.validate().unwrap();
12572    }
12573
12574    #[test]
12575    fn fonte_caminho_shell_bracket_expansion_fires_before_shell_quote_grouping() {
12576        // Cascade pin on the immediate-predecessor arm: a value
12577        // carrying both `[` and `'` (`"../[a-z]'x'"` — the canonical
12578        // "I pasted a glob-character-class followed by a strong-
12579        // quoted literal tail" footgun) routes through
12580        // `FonteCaminhoShellBracketExpansion` not
12581        // `FonteCaminhoShellQuoteGrouping`. The glob-character-class
12582        // expansion is the load-bearing root-cause edit on every
12583        // probe-as-both value; same cascade discipline every prior
12584        // `:caminho` arm establishes.
12585        let d = dep_with_fonte(DepSource::Path {
12586            caminho: "../[a-z]'x'".into(),
12587        });
12588        let err = d.validate().unwrap_err();
12589        assert!(
12590            matches!(
12591                err,
12592                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
12593            ),
12594            "got {err:?}",
12595        );
12596    }
12597
12598    #[test]
12599    fn fonte_caminho_shell_brace_expansion_fires_before_shell_quote_grouping() {
12600        // Cascade pin on the upstream shell-brace-expansion arm: a
12601        // value carrying both `{` and `'` (`"../{a,b}'x'"` — the
12602        // canonical "I pasted a brace-expansion fan followed by a
12603        // strong-quoted literal tail" footgun) routes through
12604        // `FonteCaminhoShellBraceExpansion` not
12605        // `FonteCaminhoShellQuoteGrouping`. The brace-expansion fan
12606        // is the load-bearing root-cause edit on every probe-as-
12607        // both value.
12608        let d = dep_with_fonte(DepSource::Path {
12609            caminho: "../{a,b}'x'".into(),
12610        });
12611        let err = d.validate().unwrap_err();
12612        assert!(
12613            matches!(
12614                err,
12615                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
12616            ),
12617            "got {err:?}",
12618        );
12619    }
12620
12621    #[test]
12622    fn fonte_caminho_shell_subshell_grouping_fires_before_shell_quote_grouping() {
12623        // Cascade pin on the upstream shell-subshell-grouping arm:
12624        // a value carrying both `(` and `'` (`"../(cd foo)/'x'"` —
12625        // the canonical "I pasted a subshell-grouping followed by
12626        // a strong-quoted literal tail" footgun) routes through
12627        // `FonteCaminhoShellSubshellGrouping` not
12628        // `FonteCaminhoShellQuoteGrouping`. The modern Bourne
12629        // `$(<cmd>)` command-substitution boundary is the load-
12630        // bearing axis on every probe-as-both value.
12631        let d = dep_with_fonte(DepSource::Path {
12632            caminho: "../(cd foo)/'x'".into(),
12633        });
12634        let err = d.validate().unwrap_err();
12635        assert!(
12636            matches!(
12637                err,
12638                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
12639            ),
12640            "got {err:?}",
12641        );
12642    }
12643
12644    #[test]
12645    fn fonte_caminho_shell_glob_fires_before_shell_quote_grouping() {
12646        // Cascade pin on the upstream shell-glob arm: a value
12647        // carrying both `*` and `'` (`"../caixa-teia/*'x'"` — the
12648        // canonical "I pasted a `*` unbounded pathname-expansion
12649        // followed by a strong-quoted literal tail" footgun) routes
12650        // through `FonteCaminhoShellGlob` not
12651        // `FonteCaminhoShellQuoteGrouping`. The unbounded pathname-
12652        // expansion sentinel is the load-bearing root-cause edit
12653        // on every probe-as-both value.
12654        let d = dep_with_fonte(DepSource::Path {
12655            caminho: "../caixa-teia/*'x'".into(),
12656        });
12657        let err = d.validate().unwrap_err();
12658        assert!(
12659            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12660            "got {err:?}",
12661        );
12662    }
12663
12664    #[test]
12665    fn fonte_caminho_shell_command_substitution_fires_before_shell_quote_grouping() {
12666        // Cascade pin on the upstream shell-command-substitution
12667        // arm: a value carrying both a backtick and `'`
12668        // (``"../`whoami`/'x'"`` — the canonical "I pasted a
12669        // legacy-backtick command-substitution followed by a
12670        // strong-quoted literal tail" footgun) routes through
12671        // `FonteCaminhoShellCommandSubstitution` not
12672        // `FonteCaminhoShellQuoteGrouping`. The CWE-78 shell-
12673        // command-injection vector is the load-bearing root-cause
12674        // edit on every probe-as-both value.
12675        let d = dep_with_fonte(DepSource::Path {
12676            caminho: "../`whoami`/'x'".into(),
12677        });
12678        let err = d.validate().unwrap_err();
12679        assert!(
12680            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
12681            "got {err:?}",
12682        );
12683    }
12684
12685    #[test]
12686    fn fonte_caminho_shell_background_fires_before_shell_quote_grouping() {
12687        // Cascade pin on the upstream shell-background arm: a value
12688        // carrying both `&` and `'` (`"../caixa-teia & 'x'"` — the
12689        // canonical "I pasted a `cmd & 'literal'` background-launch
12690        // + quote chain" footgun) routes through
12691        // `FonteCaminhoShellBackground` not
12692        // `FonteCaminhoShellQuoteGrouping`. The background-launch
12693        // tail is the load-bearing root-cause edit on every
12694        // probe-as-both value.
12695        let d = dep_with_fonte(DepSource::Path {
12696            caminho: "../caixa-teia & 'x'".into(),
12697        });
12698        let err = d.validate().unwrap_err();
12699        assert!(
12700            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
12701            "got {err:?}",
12702        );
12703    }
12704
12705    #[test]
12706    fn fonte_caminho_shell_semicolon_fires_before_shell_quote_grouping() {
12707        // Cascade pin on the upstream shell-semicolon arm: a value
12708        // carrying both `;` and `'` (`"../caixa-teia; 'x'"` — the
12709        // canonical sequential-cleanup + quote paste idiom) routes
12710        // through `FonteCaminhoShellSemicolon` not
12711        // `FonteCaminhoShellQuoteGrouping`. The sequential-command-
12712        // separator paste is the load-bearing root-cause edit on
12713        // every probe-as-both value.
12714        let d = dep_with_fonte(DepSource::Path {
12715            caminho: "../caixa-teia; 'x'".into(),
12716        });
12717        let err = d.validate().unwrap_err();
12718        assert!(
12719            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
12720            "got {err:?}",
12721        );
12722    }
12723
12724    #[test]
12725    fn fonte_caminho_shell_pipe_fires_before_shell_quote_grouping() {
12726        // Cascade pin on the upstream shell-pipe arm: a value
12727        // carrying both `|` and `'` (`"../caixa-teia | 'x'"` — the
12728        // canonical pipeline-to-quoted-literal paste idiom) routes
12729        // through `FonteCaminhoShellPipe` not
12730        // `FonteCaminhoShellQuoteGrouping`. The pipeline-tail paste
12731        // is the load-bearing root-cause edit on every probe-as-
12732        // both value.
12733        let d = dep_with_fonte(DepSource::Path {
12734            caminho: "../caixa-teia | 'x'".into(),
12735        });
12736        let err = d.validate().unwrap_err();
12737        assert!(
12738            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
12739            "got {err:?}",
12740        );
12741    }
12742
12743    #[test]
12744    fn fonte_caminho_shell_redirection_fires_before_shell_quote_grouping() {
12745        // Cascade pin on the upstream shell-redirection arm: a
12746        // value carrying both `>` and `'` (`"../caixa-teia>log 'x'"`
12747        // — the canonical "I pasted a `cmd > log 'literal'`
12748        // redirect-plus-quote chain" footgun) routes through
12749        // `FonteCaminhoShellRedirection` not
12750        // `FonteCaminhoShellQuoteGrouping`. The input/output
12751        // redirection metachar carries the more self-locating
12752        // `byte` payload, so the prior arm wins on every probe-as-
12753        // both value.
12754        let d = dep_with_fonte(DepSource::Path {
12755            caminho: "../caixa-teia>log 'x'".into(),
12756        });
12757        let err = d.validate().unwrap_err();
12758        assert!(
12759            matches!(
12760                err,
12761                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
12762            ),
12763            "got {err:?}",
12764        );
12765    }
12766
12767    #[test]
12768    fn fonte_caminho_backslash_fires_before_shell_quote_grouping() {
12769        // Cascade pin on the upstream backslash arm: a value
12770        // carrying both `\` and `'` (`"..\caixa-teia\'x'"` — the
12771        // canonical "I pasted a Windows-shell `cd ..\path\'literal'`
12772        // chain" footgun) routes through `FonteCaminhoBackslash`
12773        // not `FonteCaminhoShellQuoteGrouping`. The cross-host-OS-
12774        // separator divergence is the load-bearing axis on every
12775        // probe-as-both value.
12776        let d = dep_with_fonte(DepSource::Path {
12777            caminho: "..\\caixa-teia\\'x'".into(),
12778        });
12779        let err = d.validate().unwrap_err();
12780        assert!(
12781            matches!(err, DepError::FonteCaminhoBackslash { .. }),
12782            "got {err:?}",
12783        );
12784    }
12785
12786    #[test]
12787    fn fonte_caminho_control_char_fires_before_shell_quote_grouping() {
12788        // Cascade pin on the embedded-control-byte arm: a value
12789        // carrying both a control byte and `'` (`"../foo\n'x'"` —
12790        // the canonical paste-from-multiline-doc footgun where a
12791        // newline landed mid-caminho between two paste fragments)
12792        // routes through `FonteCaminhoControlChar` not
12793        // `FonteCaminhoShellQuoteGrouping`. The POSIX-syscall-
12794        // rejected-byte / NUL-`CString::new`-fail diagnostic is
12795        // the load-bearing axis on every value that probes
12796        // positive for both — mirrors the cascade discipline on
12797        // every prior arm.
12798        let d = dep_with_fonte(DepSource::Path {
12799            caminho: "../foo\n'x'".into(),
12800        });
12801        let err = d.validate().unwrap_err();
12802        assert!(
12803            matches!(err, DepError::FonteCaminhoControlChar { .. }),
12804            "got {err:?}",
12805        );
12806    }
12807
12808    #[test]
12809    fn fonte_caminho_absolute_fires_before_shell_quote_grouping() {
12810        // Cascade pin on the load-bearing leading-byte arm: a
12811        // leading `/` value with embedded `'` (`"/etc/'x'"`) routes
12812        // through `FonteCaminhoAbsolute` not
12813        // `FonteCaminhoShellQuoteGrouping` — the host-layout-leak
12814        // diagnostic is the load-bearing axis, the quote byte is
12815        // the secondary observation. Same precedence logic as every
12816        // prior leading-byte arm.
12817        let d = dep_with_fonte(DepSource::Path {
12818            caminho: "/etc/'x'".into(),
12819        });
12820        let err = d.validate().unwrap_err();
12821        assert!(
12822            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
12823            "got {err:?}",
12824        );
12825    }
12826
12827    #[test]
12828    fn fonte_caminho_var_expansion_fires_before_shell_quote_grouping() {
12829        // Cascade pin on the upstream leading-`$` var-expansion
12830        // arm: a value carrying both a leading `$` and a `'`
12831        // (`"$DIR/'x'"` — the canonical "I pasted a `$DIR` shell-
12832        // variable + quoted literal at the head of a sibling-
12833        // workspace path" footgun) routes through
12834        // `FonteCaminhoVarExpansion` not
12835        // `FonteCaminhoShellQuoteGrouping`. The leading-byte
12836        // shell-variable-expansion is the more self-locating
12837        // diagnostic on values that probe as both — same
12838        // load-bearing-leading-byte cascade discipline every
12839        // prior `:caminho` arm establishes.
12840        let d = dep_with_fonte(DepSource::Path {
12841            caminho: "$DIR/'x'".into(),
12842        });
12843        let err = d.validate().unwrap_err();
12844        assert!(
12845            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
12846            "got {err:?}",
12847        );
12848    }
12849
12850    #[test]
12851    fn fonte_caminho_shell_quote_grouping_fires_before_trailing_slash() {
12852        // Cascade pin on the immediate-successor arm: a value
12853        // carrying both `'` and a trailing `/` (`"../'caixa-teia'/"`
12854        // — the canonical "I tab-completed a path whose strong-
12855        // quoted body already carried the quoting from a shell-
12856        // history paste" footgun) routes through
12857        // `FonteCaminhoShellQuoteGrouping` not
12858        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
12859        // is the more semantic-locating axis (an author who removes
12860        // the `'` typically also drops the trailing separator since
12861        // both are paste-from-shell artifacts).
12862        let d = dep_with_fonte(DepSource::Path {
12863            caminho: "../'caixa-teia'/".into(),
12864        });
12865        let err = d.validate().unwrap_err();
12866        assert!(
12867            matches!(
12868                err,
12869                DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
12870            ),
12871            "got {err:?}",
12872        );
12873    }
12874
12875    #[test]
12876    fn fonte_caminho_shell_quote_grouping_diagnostic_carries_offending_dep_caminho_and_byte() {
12877        // Diagnostic-shape pin (peer with
12878        // `fonte_caminho_shell_bracket_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
12879        // on the closest two-byte peer arm): the error's Display
12880        // surfaces the offending `:nome`, the offending `:caminho`
12881        // verbatim, the offending byte's hex / character form, and
12882        // names the shell-quote-grouping / cross-config-DSL-string-
12883        // literal-delimiter footgun explicitly so a `feira lint`
12884        // run can render the diagnostic without re-parsing.
12885        let d = dep_with_fonte(DepSource::Path {
12886            caminho: "'../caixa-teia'".into(),
12887        });
12888        let rendered = d.validate().unwrap_err().to_string();
12889        assert!(
12890            rendered.contains("caixa-teia"),
12891            "diagnostic must name the offending dep: {rendered}",
12892        );
12893        assert!(
12894            rendered.contains("'../caixa-teia'"),
12895            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
12896        );
12897        assert!(
12898            rendered.contains("0x27"),
12899            "diagnostic must surface the offending byte hex: {rendered:?}",
12900        );
12901        assert!(
12902            rendered.contains("quote-grouping"),
12903            "diagnostic must name the shell-quote-grouping footgun: {rendered:?}",
12904        );
12905        assert!(
12906            rendered.contains("string-literal"),
12907            "diagnostic must reference the cross-config-DSL string-literal-delimiter \
12908             vocabulary: {rendered:?}",
12909        );
12910    }
12911
12912    #[test]
12913    fn validate_rejects_path_fonte_with_caminho_carrying_shell_comment_lead() {
12914        // The canonical paste-from-shell-history-with-trailing-
12915        // annotation footgun: an author pastes a `cd ../caixa-teia
12916        // # legacy sibling` shell-history one-liner whose unquoted `#`
12917        // comment-lead separates the path from an inline annotation.
12918        // The POSIX shell trims the annotation to `../caixa-teia`
12919        // (POSIX.1-2017 §2.3 Token Recognition step 6), but
12920        // `Path::is_absolute` returns false on `..`, `#` is neither
12921        // a leading-byte sentinel nor a control byte nor `\` nor
12922        // `<` / `>` nor `|` nor `;` nor `&` nor backtick nor `*` /
12923        // `?` nor `(` / `)` nor `{` / `}` nor `[` / `]` nor `'` /
12924        // `"`, and the value's last byte isn't `/` — so the value
12925        // silently passed every prior arm. The resolver folded the
12926        // value through `Path::join` looking for a literal
12927        // `./../caixa-teia # legacy sibling` subdirectory and the
12928        // failure surfaced at resolve time with a non-self-locating
12929        // `No such file or directory` error. The new arm moves the
12930        // rejection to validate time and names the offending dep +
12931        // caminho + byte verbatim.
12932        let d = dep_with_fonte(DepSource::Path {
12933            caminho: "../caixa-teia # legacy sibling".into(),
12934        });
12935        let err = d.validate().unwrap_err();
12936        let DepError::FonteCaminhoShellComment {
12937            nome,
12938            caminho,
12939            byte,
12940        } = err
12941        else {
12942            panic!("expected FonteCaminhoShellComment, got {err:?}");
12943        };
12944        assert_eq!(nome, "caixa-teia");
12945        assert_eq!(caminho, "../caixa-teia # legacy sibling");
12946        assert_eq!(byte, b'#');
12947    }
12948
12949    #[test]
12950    fn validate_rejects_path_fonte_with_caminho_carrying_yaml_comment_paste() {
12951        // The symmetric YAML flow-scalar / values.yaml / K8s-manifest
12952        // cross-idiom-leak shape (`"../caixa-teia  # pin"` — the
12953        // canonical "I copied a `path: ../caixa-teia  # pin` YAML
12954        // scalar-plus-comment entry out of an aligned values.yaml and
12955        // dropped it verbatim into the `:caminho` slot" paste-idiom).
12956        // Pinned separately from the shell-history shape so the
12957        // gate's coverage extends from the single-space `#` shape to
12958        // the YAML-canonical double-space `  #` shape. YAML 1.2 §6.6
12959        // requires the `#` to be preceded by whitespace to lex as a
12960        // comment (bare `foo#bar` is a single scalar); the double-
12961        // space paste from an aligned manifest is the canonical
12962        // shape.
12963        let d = dep_with_fonte(DepSource::Path {
12964            caminho: "../caixa-teia  # pin".into(),
12965        });
12966        let err = d.validate().unwrap_err();
12967        assert!(
12968            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
12969            "got {err:?}",
12970        );
12971    }
12972
12973    #[test]
12974    fn validate_rejects_path_fonte_with_caminho_carrying_url_fragment_anchor() {
12975        // The URL-fragment-identifier paste shape
12976        // (`"../caixa-teia#readme"` — the canonical
12977        // paste-from-browser-address-bar permalink shape where the
12978        // browser preserved the `#anchor` tail on the copy). Pinned
12979        // separately from the whitespace-separated shell / YAML
12980        // comment shapes so the gate covers the unpadded RFC 3986
12981        // §3.5 fragment-delimiter position too, not only positions
12982        // preceded by unquoted whitespace. Peer with the immediate-
12983        // sibling `is_git_repo_url` arm on the `:fonte :repo` axis
12984        // (a68f818) which closes the same byte under the same URL-
12985        // fragment-identifier banner.
12986        let d = dep_with_fonte(DepSource::Path {
12987            caminho: "../caixa-teia#readme".into(),
12988        });
12989        let err = d.validate().unwrap_err();
12990        assert!(
12991            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
12992            "got {err:?}",
12993        );
12994    }
12995
12996    #[test]
12997    fn validate_rejects_path_fonte_with_caminho_carrying_leading_shell_comment() {
12998        // Leading-position `#` shape (`"#../caixa-teia"` — the
12999        // "I copied a shell-comment-out entry from a commented-out
13000        // dep row" footgun). Pinned separately from the embedded
13001        // shapes so the gate covers every position, not only
13002        // whitespace-preceded / mid-value.
13003        let d = dep_with_fonte(DepSource::Path {
13004            caminho: "#../caixa-teia".into(),
13005        });
13006        let err = d.validate().unwrap_err();
13007        assert!(
13008            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
13009            "got {err:?}",
13010        );
13011    }
13012
13013    #[test]
13014    fn validate_accepts_path_fonte_with_caminho_carrying_no_shell_comment() {
13015        // The positive-control pin: the gate targets only `#`,
13016        // never adjacent printable ASCII or POSIX-valid bytes. The
13017        // canonical relative POSIX path (`"../caixa-teia"`) and a
13018        // nested deeply-pathed variant with adjacent printable
13019        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
13020        // to validate cleanly so the gate doesn't widen to a "no
13021        // printable punctuation anywhere" sweep that would defeat
13022        // the entire path-fonte author surface. Peer with
13023        // `validate_accepts_path_fonte_with_caminho_carrying_no_quote_grouping`
13024        // on the immediate-predecessor arm.
13025        let d = dep_with_fonte(DepSource::Path {
13026            caminho: "../caixa-teia/sub-dir.v2".into(),
13027        });
13028        d.validate().unwrap();
13029    }
13030
13031    #[test]
13032    fn fonte_caminho_shell_quote_grouping_fires_before_shell_comment() {
13033        // Cascade pin on the immediate-predecessor arm: a value
13034        // carrying both `'` and `#` (`"../'x'#pin"` — the canonical
13035        // "I pasted a strong-quoted literal followed by a URL-
13036        // fragment permalink tail" footgun) routes through
13037        // `FonteCaminhoShellQuoteGrouping` not
13038        // `FonteCaminhoShellComment`. The shell-string-literal-
13039        // delimiter is the load-bearing root-cause edit on every
13040        // probe-as-both value; same cascade discipline every prior
13041        // `:caminho` arm establishes.
13042        let d = dep_with_fonte(DepSource::Path {
13043            caminho: "../'x'#pin".into(),
13044        });
13045        let err = d.validate().unwrap_err();
13046        assert!(
13047            matches!(
13048                err,
13049                DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
13050            ),
13051            "got {err:?}",
13052        );
13053    }
13054
13055    #[test]
13056    fn fonte_caminho_shell_bracket_expansion_fires_before_shell_comment() {
13057        // Cascade pin on the upstream shell-bracket-expansion arm:
13058        // a value carrying both `[` and `#` (`"../[a-z]#pin"` — the
13059        // canonical "I pasted a glob-character-class followed by a
13060        // URL-fragment tail" footgun) routes through
13061        // `FonteCaminhoShellBracketExpansion` not
13062        // `FonteCaminhoShellComment`. The glob-character-class
13063        // expansion is the load-bearing root-cause edit on every
13064        // probe-as-both value.
13065        let d = dep_with_fonte(DepSource::Path {
13066            caminho: "../[a-z]#pin".into(),
13067        });
13068        let err = d.validate().unwrap_err();
13069        assert!(
13070            matches!(
13071                err,
13072                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
13073            ),
13074            "got {err:?}",
13075        );
13076    }
13077
13078    #[test]
13079    fn fonte_caminho_shell_brace_expansion_fires_before_shell_comment() {
13080        // Cascade pin on the upstream shell-brace-expansion arm: a
13081        // value carrying both `{` and `#` (`"../{a,b}#pin"` — the
13082        // canonical "I pasted a brace-expansion fan followed by a
13083        // URL-fragment tail" footgun) routes through
13084        // `FonteCaminhoShellBraceExpansion` not
13085        // `FonteCaminhoShellComment`. The brace-expansion fan is the
13086        // load-bearing root-cause edit on every probe-as-both value.
13087        let d = dep_with_fonte(DepSource::Path {
13088            caminho: "../{a,b}#pin".into(),
13089        });
13090        let err = d.validate().unwrap_err();
13091        assert!(
13092            matches!(
13093                err,
13094                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
13095            ),
13096            "got {err:?}",
13097        );
13098    }
13099
13100    #[test]
13101    fn fonte_caminho_shell_subshell_grouping_fires_before_shell_comment() {
13102        // Cascade pin on the upstream shell-subshell-grouping arm:
13103        // a value carrying both `(` and `#` (`"../(cd foo)#pin"` —
13104        // the canonical "I pasted a subshell-grouping followed by a
13105        // URL-fragment tail" footgun) routes through
13106        // `FonteCaminhoShellSubshellGrouping` not
13107        // `FonteCaminhoShellComment`. The modern Bourne `$(<cmd>)`
13108        // command-substitution boundary is the load-bearing axis on
13109        // every probe-as-both value.
13110        let d = dep_with_fonte(DepSource::Path {
13111            caminho: "../(cd foo)#pin".into(),
13112        });
13113        let err = d.validate().unwrap_err();
13114        assert!(
13115            matches!(
13116                err,
13117                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
13118            ),
13119            "got {err:?}",
13120        );
13121    }
13122
13123    #[test]
13124    fn fonte_caminho_shell_glob_fires_before_shell_comment() {
13125        // Cascade pin on the upstream shell-glob arm: a value
13126        // carrying both `*` and `#` (`"../caixa-teia/*#pin"` — the
13127        // canonical "I pasted a `*` unbounded pathname-expansion
13128        // followed by a URL-fragment tail" footgun) routes through
13129        // `FonteCaminhoShellGlob` not `FonteCaminhoShellComment`.
13130        // The unbounded pathname-expansion sentinel is the load-
13131        // bearing root-cause edit on every probe-as-both value.
13132        let d = dep_with_fonte(DepSource::Path {
13133            caminho: "../caixa-teia/*#pin".into(),
13134        });
13135        let err = d.validate().unwrap_err();
13136        assert!(
13137            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
13138            "got {err:?}",
13139        );
13140    }
13141
13142    #[test]
13143    fn fonte_caminho_shell_command_substitution_fires_before_shell_comment() {
13144        // Cascade pin on the upstream shell-command-substitution
13145        // arm: a value carrying both a backtick and `#`
13146        // (``"../`whoami`#pin"`` — the canonical "I pasted a
13147        // legacy-backtick command-substitution followed by a URL-
13148        // fragment tail" footgun) routes through
13149        // `FonteCaminhoShellCommandSubstitution` not
13150        // `FonteCaminhoShellComment`. The CWE-78 shell-command-
13151        // injection vector is the load-bearing root-cause edit on
13152        // every probe-as-both value.
13153        let d = dep_with_fonte(DepSource::Path {
13154            caminho: "../`whoami`#pin".into(),
13155        });
13156        let err = d.validate().unwrap_err();
13157        assert!(
13158            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
13159            "got {err:?}",
13160        );
13161    }
13162
13163    #[test]
13164    fn fonte_caminho_shell_background_fires_before_shell_comment() {
13165        // Cascade pin on the upstream shell-background arm: a value
13166        // carrying both `&` and `#` (`"../caixa-teia&pin#tail"` —
13167        // the canonical "I pasted a `cmd &` background-launch
13168        // followed by a URL-fragment tail" footgun) routes through
13169        // `FonteCaminhoShellBackground` not
13170        // `FonteCaminhoShellComment`. The background-launch tail is
13171        // the load-bearing root-cause edit on every probe-as-both
13172        // value.
13173        let d = dep_with_fonte(DepSource::Path {
13174            caminho: "../caixa-teia&pin#tail".into(),
13175        });
13176        let err = d.validate().unwrap_err();
13177        assert!(
13178            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
13179            "got {err:?}",
13180        );
13181    }
13182
13183    #[test]
13184    fn fonte_caminho_shell_semicolon_fires_before_shell_comment() {
13185        // Cascade pin on the upstream shell-semicolon arm: a value
13186        // carrying both `;` and `#` (`"../caixa-teia;pin#tail"` —
13187        // the canonical sequential-cleanup + URL-fragment paste
13188        // idiom) routes through `FonteCaminhoShellSemicolon` not
13189        // `FonteCaminhoShellComment`. The sequential-command-
13190        // separator paste is the load-bearing root-cause edit on
13191        // every probe-as-both value.
13192        let d = dep_with_fonte(DepSource::Path {
13193            caminho: "../caixa-teia;pin#tail".into(),
13194        });
13195        let err = d.validate().unwrap_err();
13196        assert!(
13197            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
13198            "got {err:?}",
13199        );
13200    }
13201
13202    #[test]
13203    fn fonte_caminho_shell_pipe_fires_before_shell_comment() {
13204        // Cascade pin on the upstream shell-pipe arm: a value
13205        // carrying both `|` and `#` (`"../caixa-teia|pin#tail"` —
13206        // the canonical pipeline-to-URL-fragment paste idiom) routes
13207        // through `FonteCaminhoShellPipe` not
13208        // `FonteCaminhoShellComment`. The pipeline-tail paste is
13209        // the load-bearing root-cause edit on every probe-as-both
13210        // value.
13211        let d = dep_with_fonte(DepSource::Path {
13212            caminho: "../caixa-teia|pin#tail".into(),
13213        });
13214        let err = d.validate().unwrap_err();
13215        assert!(
13216            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
13217            "got {err:?}",
13218        );
13219    }
13220
13221    #[test]
13222    fn fonte_caminho_shell_redirection_fires_before_shell_comment() {
13223        // Cascade pin on the upstream shell-redirection arm: a
13224        // value carrying both `>` and `#` (`"../caixa-teia>log#pin"`
13225        // — the canonical "I pasted a `cmd > log` redirect followed
13226        // by a URL-fragment tail" footgun) routes through
13227        // `FonteCaminhoShellRedirection` not
13228        // `FonteCaminhoShellComment`. The input/output redirection
13229        // metachar carries the more self-locating `byte` payload,
13230        // so the prior arm wins on every probe-as-both value.
13231        let d = dep_with_fonte(DepSource::Path {
13232            caminho: "../caixa-teia>log#pin".into(),
13233        });
13234        let err = d.validate().unwrap_err();
13235        assert!(
13236            matches!(
13237                err,
13238                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
13239            ),
13240            "got {err:?}",
13241        );
13242    }
13243
13244    #[test]
13245    fn fonte_caminho_backslash_fires_before_shell_comment() {
13246        // Cascade pin on the upstream backslash arm: a value
13247        // carrying both `\` and `#` (`"..\caixa-teia#pin"` — the
13248        // canonical "I pasted a Windows-shell path followed by a
13249        // URL-fragment tail" footgun) routes through
13250        // `FonteCaminhoBackslash` not `FonteCaminhoShellComment`.
13251        // The cross-host-OS-separator divergence is the load-
13252        // bearing axis on every probe-as-both value.
13253        let d = dep_with_fonte(DepSource::Path {
13254            caminho: "..\\caixa-teia#pin".into(),
13255        });
13256        let err = d.validate().unwrap_err();
13257        assert!(
13258            matches!(err, DepError::FonteCaminhoBackslash { .. }),
13259            "got {err:?}",
13260        );
13261    }
13262
13263    #[test]
13264    fn fonte_caminho_control_char_fires_before_shell_comment() {
13265        // Cascade pin on the embedded-control-byte arm: a value
13266        // carrying both a control byte and `#` (`"../foo\n#pin"` —
13267        // the canonical paste-from-multiline-doc footgun where a
13268        // newline landed mid-caminho between the path and an
13269        // annotation) routes through `FonteCaminhoControlChar` not
13270        // `FonteCaminhoShellComment`. The POSIX-syscall-rejected-
13271        // byte diagnostic is the load-bearing axis on every value
13272        // that probes positive for both — mirrors the cascade
13273        // discipline on every prior arm.
13274        let d = dep_with_fonte(DepSource::Path {
13275            caminho: "../foo\n#pin".into(),
13276        });
13277        let err = d.validate().unwrap_err();
13278        assert!(
13279            matches!(err, DepError::FonteCaminhoControlChar { .. }),
13280            "got {err:?}",
13281        );
13282    }
13283
13284    #[test]
13285    fn fonte_caminho_absolute_fires_before_shell_comment() {
13286        // Cascade pin on the load-bearing leading-byte arm: a
13287        // leading `/` value with embedded `#` (`"/etc/foo#pin"`)
13288        // routes through `FonteCaminhoAbsolute` not
13289        // `FonteCaminhoShellComment` — the host-layout-leak
13290        // diagnostic is the load-bearing axis, the fragment byte is
13291        // the secondary observation. Same precedence logic as every
13292        // prior leading-byte arm.
13293        let d = dep_with_fonte(DepSource::Path {
13294            caminho: "/etc/foo#pin".into(),
13295        });
13296        let err = d.validate().unwrap_err();
13297        assert!(
13298            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
13299            "got {err:?}",
13300        );
13301    }
13302
13303    #[test]
13304    fn fonte_caminho_var_expansion_fires_before_shell_comment() {
13305        // Cascade pin on the upstream leading-`$` var-expansion
13306        // arm: a value carrying both a leading `$` and a `#`
13307        // (`"$DIR/foo#pin"` — the canonical "I pasted a `$DIR`
13308        // shell-variable at the head of a sibling-workspace path
13309        // followed by a URL-fragment tail" footgun) routes through
13310        // `FonteCaminhoVarExpansion` not `FonteCaminhoShellComment`.
13311        // The leading-byte shell-variable-expansion is the more
13312        // self-locating diagnostic on values that probe as both.
13313        let d = dep_with_fonte(DepSource::Path {
13314            caminho: "$DIR/foo#pin".into(),
13315        });
13316        let err = d.validate().unwrap_err();
13317        assert!(
13318            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
13319            "got {err:?}",
13320        );
13321    }
13322
13323    #[test]
13324    fn fonte_caminho_shell_comment_fires_before_trailing_slash() {
13325        // Cascade pin on the immediate-successor arm: a value
13326        // carrying both `#` and a trailing `/`
13327        // (`"../caixa-teia#pin/"` — the canonical "I tab-completed
13328        // a URL-fragment-carrying path" footgun) routes through
13329        // `FonteCaminhoShellComment` not
13330        // `FonteCaminhoTrailingSlash`. The embedded fragment /
13331        // comment-lead byte is the more semantic-locating axis (an
13332        // author who removes the `#pin` fragment typically also
13333        // drops the trailing separator since both are paste-from-
13334        // URL / paste-from-shell-tab-completion artifacts).
13335        let d = dep_with_fonte(DepSource::Path {
13336            caminho: "../caixa-teia#pin/".into(),
13337        });
13338        let err = d.validate().unwrap_err();
13339        assert!(
13340            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. },),
13341            "got {err:?}",
13342        );
13343    }
13344
13345    #[test]
13346    fn fonte_caminho_shell_comment_diagnostic_carries_offending_dep_caminho_and_byte() {
13347        // Diagnostic-shape pin (peer with
13348        // `fonte_caminho_shell_quote_grouping_diagnostic_carries_offending_dep_caminho_and_byte`
13349        // on the immediate-predecessor arm): the error's Display
13350        // surfaces the offending `:nome`, the offending `:caminho`
13351        // verbatim, the offending byte's hex / character form, and
13352        // names the shell-comment / URL-fragment-identifier /
13353        // YAML-comment cross-config-DSL footgun explicitly so a
13354        // `feira lint` run can render the diagnostic without
13355        // re-parsing.
13356        let d = dep_with_fonte(DepSource::Path {
13357            caminho: "../caixa-teia#readme".into(),
13358        });
13359        let rendered = d.validate().unwrap_err().to_string();
13360        assert!(
13361            rendered.contains("caixa-teia"),
13362            "diagnostic must name the offending dep: {rendered}",
13363        );
13364        assert!(
13365            rendered.contains("../caixa-teia#readme"),
13366            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
13367        );
13368        assert!(
13369            rendered.contains("0x23"),
13370            "diagnostic must surface the offending byte hex: {rendered:?}",
13371        );
13372        assert!(
13373            rendered.contains("shell-comment") || rendered.contains("comment-lead"),
13374            "diagnostic must name the shell-comment footgun: {rendered:?}",
13375        );
13376        assert!(
13377            rendered.contains("fragment") || rendered.contains("URL-fragment"),
13378            "diagnostic must reference the URL-fragment-identifier vocabulary: \
13379             {rendered:?}",
13380        );
13381    }
13382
13383    #[test]
13384    fn validate_rejects_path_fonte_with_caminho_carrying_url_percent_encoded_space() {
13385        // The canonical paste-from-browser-address-bar percent-
13386        // encoded-space footgun: an author copies `../caixa%20teia`
13387        // out of a URL-encoded README hyperlink / browser address
13388        // bar / percent-encoded permalink expecting `%20` to decode
13389        // to a literal space at the filesystem layer. POSIX
13390        // `std::path::Path` treats `%` as a literal path-component
13391        // byte, so `Path::join` looks for a literal
13392        // `./../caixa%20teia` subdirectory. `Path::is_absolute`
13393        // returns false on `..`, `%` is neither a leading-byte
13394        // sentinel nor a control byte nor `\` nor `<` / `>` nor
13395        // `|` nor `;` nor `&` nor backtick nor `*` / `?` nor `(` /
13396        // `)` nor `{` / `}` nor `[` / `]` nor `'` / `"` nor `#`,
13397        // and the value's last byte isn't `/` — so the value
13398        // silently passed every prior arm. The new arm moves the
13399        // rejection to validate time and names the offending dep +
13400        // caminho + byte verbatim.
13401        let d = dep_with_fonte(DepSource::Path {
13402            caminho: "../caixa%20teia".into(),
13403        });
13404        let err = d.validate().unwrap_err();
13405        let DepError::FonteCaminhoUrlPercentEncoding {
13406            nome,
13407            caminho,
13408            byte,
13409        } = err
13410        else {
13411            panic!("expected FonteCaminhoUrlPercentEncoding, got {err:?}");
13412        };
13413        assert_eq!(nome, "caixa-teia");
13414        assert_eq!(caminho, "../caixa%20teia");
13415        assert_eq!(byte, b'%');
13416    }
13417
13418    #[test]
13419    fn validate_rejects_path_fonte_with_caminho_carrying_url_percent_encoded_slash() {
13420        // The over-encoded path-separator shape (`"../caixa%2Fteia"`
13421        // intending the `%2F` as the URL encoding of `/`) locks a
13422        // `path:../caixa%2Fteia` BLAKE3 closure that diverges from
13423        // the byte-identical `path:../caixa/teia` form. Pinned
13424        // separately from the space-encoded shape so the gate's
13425        // coverage extends past the single canonical `%20` example
13426        // to any two-hex-digit percent-encoded sequence.
13427        let d = dep_with_fonte(DepSource::Path {
13428            caminho: "../caixa%2Fteia".into(),
13429        });
13430        let err = d.validate().unwrap_err();
13431        assert!(
13432            matches!(
13433                err,
13434                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
13435            ),
13436            "got {err:?}",
13437        );
13438    }
13439
13440    #[test]
13441    fn validate_rejects_path_fonte_with_caminho_carrying_lone_percent() {
13442        // The lone-`%` malformed-escape shape (`"../caixa-teia%foo"`
13443        // where `%` isn't followed by two hex digits) — every
13444        // WHATWG-conformant URL parser rejects the value at parse
13445        // time per RFC 3986 §2.1, but the byte would silently ride
13446        // into the lacre before the resolver subprocess crosses the
13447        // URL-parser boundary. Pinned separately from the well-
13448        // formed `%HH` shapes so the gate covers every percent-
13449        // occurrence, not only strictly-conformant escapes.
13450        let d = dep_with_fonte(DepSource::Path {
13451            caminho: "../caixa-teia%foo".into(),
13452        });
13453        let err = d.validate().unwrap_err();
13454        assert!(
13455            matches!(
13456                err,
13457                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
13458            ),
13459            "got {err:?}",
13460        );
13461    }
13462
13463    #[test]
13464    fn validate_rejects_path_fonte_with_caminho_carrying_leading_yaml_directive() {
13465        // The YAML-directive-lead paste shape (`"%YAML/../caixa-teia"`
13466        // — the canonical paste-from-top-of-doc YAML directive
13467        // block cross-idiom leak per YAML 1.2 §6.8.1). Pinned
13468        // separately from embedded shapes so the gate covers the
13469        // leading-position `%` too, not only mid-value occurrences.
13470        let d = dep_with_fonte(DepSource::Path {
13471            caminho: "%YAML/../caixa-teia".into(),
13472        });
13473        let err = d.validate().unwrap_err();
13474        assert!(
13475            matches!(
13476                err,
13477                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
13478            ),
13479            "got {err:?}",
13480        );
13481    }
13482
13483    #[test]
13484    fn validate_rejects_path_fonte_with_caminho_carrying_printf_format_specifier() {
13485        // The printf-format-specifier paste shape
13486        // (`"../caixa-%s-teia"` — the canonical paste-from-shell-
13487        // diagnostic-one-liner `printf "path=%s\n" ...` idiom, CWE-
13488        // 134 format-string-injection vector). Pinned separately
13489        // from the URL-encoding shapes so the gate's rationale
13490        // extends past the RFC 3986 axis to the C / POSIX printf
13491        // format-directive-lead axis.
13492        let d = dep_with_fonte(DepSource::Path {
13493            caminho: "../caixa-%s-teia".into(),
13494        });
13495        let err = d.validate().unwrap_err();
13496        assert!(
13497            matches!(
13498                err,
13499                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
13500            ),
13501            "got {err:?}",
13502        );
13503    }
13504
13505    #[test]
13506    fn validate_accepts_path_fonte_with_caminho_carrying_no_percent() {
13507        // The positive-control pin: the gate targets only `%`,
13508        // never adjacent printable ASCII or POSIX-valid bytes. The
13509        // canonical relative POSIX path (`"../caixa-teia"`) and a
13510        // nested deeply-pathed variant with adjacent printable
13511        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
13512        // to validate cleanly so the gate doesn't widen to a "no
13513        // printable punctuation anywhere" sweep that would defeat
13514        // the entire path-fonte author surface. Peer with
13515        // `validate_accepts_path_fonte_with_caminho_carrying_no_shell_comment`
13516        // on the immediate-predecessor arm.
13517        let d = dep_with_fonte(DepSource::Path {
13518            caminho: "../caixa-teia/sub-dir.v2".into(),
13519        });
13520        d.validate().unwrap();
13521    }
13522
13523    #[test]
13524    fn fonte_caminho_shell_comment_fires_before_url_percent_encoding() {
13525        // Cascade pin on the immediate-predecessor arm: a value
13526        // carrying both `#` and `%` (`"../caixa-teia#pin%20"` — the
13527        // canonical "I pasted a URL-fragment permalink followed by a
13528        // percent-encoded space tail" footgun) routes through
13529        // `FonteCaminhoShellComment` not
13530        // `FonteCaminhoUrlPercentEncoding`. The URL-fragment-
13531        // identifier is the load-bearing downstream-truncation edit
13532        // on every probe-as-both value; same cascade discipline
13533        // every prior `:caminho` arm establishes.
13534        let d = dep_with_fonte(DepSource::Path {
13535            caminho: "../caixa-teia#pin%20".into(),
13536        });
13537        let err = d.validate().unwrap_err();
13538        assert!(
13539            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
13540            "got {err:?}",
13541        );
13542    }
13543
13544    #[test]
13545    fn fonte_caminho_shell_quote_grouping_fires_before_url_percent_encoding() {
13546        // Cascade pin on the upstream shell-quote-grouping arm: a
13547        // value carrying both `'` and `%` (`"../'x'%20teia"` — the
13548        // canonical "I pasted a strong-quoted literal followed by
13549        // a percent-encoded space" footgun) routes through
13550        // `FonteCaminhoShellQuoteGrouping` not
13551        // `FonteCaminhoUrlPercentEncoding`. The shell-string-
13552        // literal-delimiter is the load-bearing root-cause edit on
13553        // every probe-as-both value.
13554        let d = dep_with_fonte(DepSource::Path {
13555            caminho: "../'x'%20teia".into(),
13556        });
13557        let err = d.validate().unwrap_err();
13558        assert!(
13559            matches!(
13560                err,
13561                DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
13562            ),
13563            "got {err:?}",
13564        );
13565    }
13566
13567    #[test]
13568    fn fonte_caminho_backslash_fires_before_url_percent_encoding() {
13569        // Cascade pin on the upstream backslash arm: a value
13570        // carrying both `\` and `%` (`"..\\caixa%20teia"` — the
13571        // canonical "I pasted a Windows-shell path followed by a
13572        // percent-encoded space" footgun) routes through
13573        // `FonteCaminhoBackslash` not
13574        // `FonteCaminhoUrlPercentEncoding`. The cross-host-OS-
13575        // separator divergence is the load-bearing root-cause edit
13576        // on every probe-as-both value.
13577        let d = dep_with_fonte(DepSource::Path {
13578            caminho: "..\\caixa%20teia".into(),
13579        });
13580        let err = d.validate().unwrap_err();
13581        assert!(
13582            matches!(err, DepError::FonteCaminhoBackslash { .. }),
13583            "got {err:?}",
13584        );
13585    }
13586
13587    #[test]
13588    fn fonte_caminho_control_char_fires_before_url_percent_encoding() {
13589        // Cascade pin on the upstream control-char arm: a value
13590        // carrying both a NUL byte and `%` (`"../caixa\0%20teia"` —
13591        // the canonical "I pasted a paste-from-binary-blob path
13592        // followed by a percent-encoded space" footgun) routes
13593        // through `FonteCaminhoControlChar` not
13594        // `FonteCaminhoUrlPercentEncoding`. The POSIX-syscall-
13595        // rejected byte is the load-bearing root-cause edit on
13596        // every probe-as-both value.
13597        let d = dep_with_fonte(DepSource::Path {
13598            caminho: "../caixa\0%20teia".into(),
13599        });
13600        let err = d.validate().unwrap_err();
13601        assert!(
13602            matches!(err, DepError::FonteCaminhoControlChar { byte: 0x00, .. },),
13603            "got {err:?}",
13604        );
13605    }
13606
13607    #[test]
13608    fn fonte_caminho_absolute_fires_before_url_percent_encoding() {
13609        // Cascade pin on the upstream absolute-path arm: a value
13610        // that's both absolute and carries `%` (`"/etc/passwd%20"`
13611        // — the canonical "I pasted an absolute path with a
13612        // percent-encoded space tail" footgun) routes through
13613        // `FonteCaminhoAbsolute` not
13614        // `FonteCaminhoUrlPercentEncoding`. The host-layout-leak is
13615        // the load-bearing root-cause edit on every probe-as-both
13616        // value.
13617        let d = dep_with_fonte(DepSource::Path {
13618            caminho: "/etc/passwd%20".into(),
13619        });
13620        let err = d.validate().unwrap_err();
13621        assert!(
13622            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
13623            "got {err:?}",
13624        );
13625    }
13626
13627    #[test]
13628    fn fonte_caminho_var_expansion_fires_before_url_percent_encoding() {
13629        // Cascade pin on the upstream var-expansion arm: a value
13630        // starting with `$` and carrying `%` (`"$HOME/caixa%20teia"`
13631        // — the canonical "I pasted a `$HOME`-rooted path with a
13632        // percent-encoded space" footgun) routes through
13633        // `FonteCaminhoVarExpansion` not
13634        // `FonteCaminhoUrlPercentEncoding`. The shell-variable-
13635        // expansion is the load-bearing root-cause edit on every
13636        // probe-as-both value.
13637        let d = dep_with_fonte(DepSource::Path {
13638            caminho: "$HOME/caixa%20teia".into(),
13639        });
13640        let err = d.validate().unwrap_err();
13641        assert!(
13642            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
13643            "got {err:?}",
13644        );
13645    }
13646
13647    #[test]
13648    fn fonte_caminho_url_percent_encoding_fires_before_trailing_slash() {
13649        // Cascade pin on the immediate-successor arm: a value
13650        // carrying both `%` and a trailing `/`
13651        // (`"../caixa%20teia/"` — the canonical "I tab-completed a
13652        // percent-encoded-space-carrying path" footgun) routes
13653        // through `FonteCaminhoUrlPercentEncoding` not
13654        // `FonteCaminhoTrailingSlash`. The embedded percent-
13655        // encoding-escape byte is the more semantic-locating axis
13656        // (an author who decodes the `%20` to a literal space is
13657        // likely to also tab-strip the trailing separator since
13658        // both are paste-from-URL / paste-from-shell-tab-completion
13659        // artifacts).
13660        let d = dep_with_fonte(DepSource::Path {
13661            caminho: "../caixa%20teia/".into(),
13662        });
13663        let err = d.validate().unwrap_err();
13664        assert!(
13665            matches!(
13666                err,
13667                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
13668            ),
13669            "got {err:?}",
13670        );
13671    }
13672
13673    #[test]
13674    fn fonte_caminho_url_percent_encoding_diagnostic_carries_offending_dep_caminho_and_byte() {
13675        // Diagnostic-shape pin (peer with
13676        // `fonte_caminho_shell_comment_diagnostic_carries_offending_dep_caminho_and_byte`
13677        // on the immediate-predecessor arm): the error's Display
13678        // surfaces the offending `:nome`, the offending `:caminho`
13679        // verbatim, the offending byte's hex / character form, and
13680        // names the URL-percent-encoding-escape / printf-format-
13681        // specifier footgun explicitly so a `feira lint` run can
13682        // render the diagnostic without re-parsing.
13683        let d = dep_with_fonte(DepSource::Path {
13684            caminho: "../caixa%20teia".into(),
13685        });
13686        let rendered = d.validate().unwrap_err().to_string();
13687        assert!(
13688            rendered.contains("caixa-teia"),
13689            "diagnostic must name the offending dep: {rendered}",
13690        );
13691        assert!(
13692            rendered.contains("../caixa%20teia"),
13693            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
13694        );
13695        assert!(
13696            rendered.contains("0x25"),
13697            "diagnostic must surface the offending byte hex: {rendered:?}",
13698        );
13699        assert!(
13700            rendered.contains("percent-encoding") || rendered.contains("percent-encoded"),
13701            "diagnostic must name the URL-percent-encoding-escape footgun: {rendered:?}",
13702        );
13703        assert!(
13704            rendered.contains("printf") || rendered.contains("format-specifier"),
13705            "diagnostic must reference the printf-format-specifier vocabulary: \
13706             {rendered:?}",
13707        );
13708    }
13709
13710    #[test]
13711    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_var_expansion() {
13712        // The canonical embedded-`$` shell-variable-expansion paste
13713        // shape (`"../foo$HOME/bar"` — an author copies a partially-
13714        // substituted shell one-liner where the leading segment is a
13715        // literal `../foo` while the mid segment carries the un-
13716        // substituted `$HOME` template). The leading-`$` position is
13717        // already gated by the f4efe9c leading-byte arm which routes
13718        // through `FonteCaminhoVarExpansion`; this arm closes the
13719        // last positional gap on `$` — every position on the axis is
13720        // structurally rejected.
13721        let d = dep_with_fonte(DepSource::Path {
13722            caminho: "../foo$HOME/bar".into(),
13723        });
13724        let err = d.validate().unwrap_err();
13725        let DepError::FonteCaminhoShellVariableExpansion {
13726            nome,
13727            caminho,
13728            byte,
13729        } = err
13730        else {
13731            panic!("expected FonteCaminhoShellVariableExpansion, got {err:?}");
13732        };
13733        assert_eq!(nome, "caixa-teia");
13734        assert_eq!(caminho, "../foo$HOME/bar");
13735        assert_eq!(byte, b'$');
13736    }
13737
13738    #[test]
13739    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_braced_var_expansion() {
13740        // The symmetric braced-CI-manifest paste shape
13741        // (`"../foo${WORKSPACE}/bar"` — the canonical paste-from-
13742        // GitHub-Actions-workflow / paste-from-`.gitlab-ci.yml`
13743        // footgun). Pinned separately from the bare-`$VAR` shape so
13744        // the gate covers both POSIX shell §2.6 Parameter Expansion
13745        // syntactic forms, not only the unbraced variant. The
13746        // embedded `{` byte in `${...}` is also caught by the 598b770
13747        // shell-brace-expansion arm but that arm fires earlier in
13748        // the cascade — the `$` arm's coverage extends to `${...}`
13749        // structurally, so the diagnostic asserted here is the
13750        // brace-expansion one (which is a valid outcome; the point
13751        // of the pin is that the value never survives validation).
13752        let d = dep_with_fonte(DepSource::Path {
13753            caminho: "../foo${WORKSPACE}/bar".into(),
13754        });
13755        let err = d.validate().unwrap_err();
13756        assert!(
13757            matches!(
13758                err,
13759                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. }
13760                    | DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
13761            ),
13762            "got {err:?}",
13763        );
13764    }
13765
13766    #[test]
13767    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_command_substitution() {
13768        // The paste-from-shell-prompt command-substitution idiom
13769        // (`"../foo$(whoami)/bar"`). Pinned separately from the bare-
13770        // `$VAR` shape so the gate's rationale extends to POSIX shell
13771        // §2.6.3 Command Substitution (the modern `$(<cmd>)` form; the
13772        // legacy `` `<cmd>` `` form is already closed by the c370458
13773        // backtick arm). The embedded `(` byte in `$(...)` is also
13774        // caught structurally by the 0633c91 shell-subshell-grouping
13775        // arm which fires earlier in the cascade — the diagnostic
13776        // asserted here is either outcome, since both structurally
13777        // reject the value; the point of the pin is that the value
13778        // never survives validation.
13779        let d = dep_with_fonte(DepSource::Path {
13780            caminho: "../foo$(whoami)/bar".into(),
13781        });
13782        let err = d.validate().unwrap_err();
13783        assert!(
13784            matches!(
13785                err,
13786                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. }
13787                    | DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
13788            ),
13789            "got {err:?}",
13790        );
13791    }
13792
13793    #[test]
13794    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_positional_parameter() {
13795        // The paste-from-`Makefile` / paste-from-SQL-migration bare-
13796        // `$1` positional-parameter shape (`"../foo$1/bar"` — a Make
13797        // automatic-variable `$1` or a PostgreSQL bind-parameter `$1`
13798        // idiom copied into a caminho template). None of the prior
13799        // shell-metachar arms cover this shape (`1` is a bare digit;
13800        // no `(` / `{` / letter follows the `$`), so the arm is the
13801        // sole gate on the shape.
13802        let d = dep_with_fonte(DepSource::Path {
13803            caminho: "../foo$1/bar".into(),
13804        });
13805        let err = d.validate().unwrap_err();
13806        assert!(
13807            matches!(
13808                err,
13809                DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
13810            ),
13811            "got {err:?}",
13812        );
13813    }
13814
13815    #[test]
13816    fn validate_accepts_path_fonte_with_caminho_carrying_no_dollar() {
13817        // The positive-control pin (peer with
13818        // `validate_accepts_path_fonte_with_caminho_carrying_no_percent`
13819        // on the immediate-predecessor arm): the gate targets only
13820        // `$`, never adjacent printable ASCII or POSIX-valid bytes.
13821        // A relative POSIX path carrying dashes / dots / slashes /
13822        // digits (`"../caixa-teia/sub-dir.v2"`) must continue to
13823        // validate cleanly so the gate doesn't widen to a "no
13824        // printable punctuation anywhere" sweep that would defeat
13825        // the entire path-fonte author surface.
13826        let d = dep_with_fonte(DepSource::Path {
13827            caminho: "../caixa-teia/sub-dir.v2".into(),
13828        });
13829        d.validate().unwrap();
13830    }
13831
13832    #[test]
13833    fn fonte_caminho_var_expansion_fires_before_shell_variable_expansion() {
13834        // Cascade pin on the leading-`$` sibling arm at line 540: a
13835        // value starting with `$` and carrying an embedded `$` too
13836        // (`"$HOME/foo$WORKSPACE/bar"` — the canonical "I pasted a
13837        // fully-templated CI path with two un-substituted variables")
13838        // routes through `FonteCaminhoVarExpansion` not
13839        // `FonteCaminhoShellVariableExpansion`. The leading-byte
13840        // host-layout-leak is the load-bearing self-locating axis
13841        // (the leading position dominates the semantic-locating
13842        // rationale on every probe-as-both value); the embedded
13843        // arm's positional-agnostic sweep catches only values whose
13844        // leading byte doesn't route through the earlier leading-
13845        // byte arms.
13846        let d = dep_with_fonte(DepSource::Path {
13847            caminho: "$HOME/foo$WORKSPACE/bar".into(),
13848        });
13849        let err = d.validate().unwrap_err();
13850        assert!(
13851            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
13852            "got {err:?}",
13853        );
13854    }
13855
13856    #[test]
13857    fn fonte_caminho_url_percent_encoding_fires_before_shell_variable_expansion() {
13858        // Cascade pin on the immediate-predecessor arm: a value
13859        // carrying both `%` and embedded `$` (`"../foo%20$HOME/bar"`
13860        // — the canonical "I pasted a percent-encoded space adjacent
13861        // to a `$HOME` template") routes through
13862        // `FonteCaminhoUrlPercentEncoding` not
13863        // `FonteCaminhoShellVariableExpansion`. The URL-percent-
13864        // encoding-escape byte is the more semantic-locating axis
13865        // (the paste-from-browser-address-bar shape is the load-
13866        // bearing self-locating edit); same cascade discipline every
13867        // prior `:caminho` arm establishes.
13868        let d = dep_with_fonte(DepSource::Path {
13869            caminho: "../foo%20$HOME/bar".into(),
13870        });
13871        let err = d.validate().unwrap_err();
13872        assert!(
13873            matches!(
13874                err,
13875                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
13876            ),
13877            "got {err:?}",
13878        );
13879    }
13880
13881    #[test]
13882    fn fonte_caminho_shell_variable_expansion_fires_before_trailing_slash() {
13883        // Cascade pin on the immediate-successor arm: a value
13884        // carrying both embedded `$` and a trailing `/`
13885        // (`"../foo$HOME/bar/"` — the canonical "I tab-completed a
13886        // `$HOME`-template-carrying path") routes through
13887        // `FonteCaminhoShellVariableExpansion` not
13888        // `FonteCaminhoTrailingSlash`. The embedded shell-variable-
13889        // expansion byte is the more semantic-locating axis on
13890        // probe-as-both values (an author who substitutes the
13891        // `$HOME` template with a literal value is likely to also
13892        // tab-strip the trailing separator).
13893        let d = dep_with_fonte(DepSource::Path {
13894            caminho: "../foo$HOME/bar/".into(),
13895        });
13896        let err = d.validate().unwrap_err();
13897        assert!(
13898            matches!(
13899                err,
13900                DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
13901            ),
13902            "got {err:?}",
13903        );
13904    }
13905
13906    #[test]
13907    fn fonte_caminho_shell_variable_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
13908        // Diagnostic-shape pin (peer with
13909        // `fonte_caminho_url_percent_encoding_diagnostic_carries_offending_dep_caminho_and_byte`
13910        // on the immediate-predecessor arm): the error's Display
13911        // surfaces the offending `:nome`, the offending `:caminho`
13912        // verbatim, the offending byte's hex / character form, and
13913        // names the shell-variable-expansion / command-substitution
13914        // footgun explicitly so a `feira lint` run can render the
13915        // diagnostic without re-parsing.
13916        let d = dep_with_fonte(DepSource::Path {
13917            caminho: "../foo$HOME/bar".into(),
13918        });
13919        let rendered = d.validate().unwrap_err().to_string();
13920        assert!(
13921            rendered.contains("caixa-teia"),
13922            "diagnostic must name the offending dep: {rendered}",
13923        );
13924        assert!(
13925            rendered.contains("../foo$HOME/bar"),
13926            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
13927        );
13928        assert!(
13929            rendered.contains("0x24"),
13930            "diagnostic must surface the offending byte hex: {rendered:?}",
13931        );
13932        assert!(
13933            rendered.contains("variable-expansion") || rendered.contains("variable expansion"),
13934            "diagnostic must name the shell-variable-expansion footgun: {rendered:?}",
13935        );
13936        assert!(
13937            rendered.contains("command-substitution") || rendered.contains("command substitution"),
13938            "diagnostic must reference the command-substitution vocabulary: {rendered:?}",
13939        );
13940    }
13941
13942    #[test]
13943    fn validate_rejects_path_fonte_with_caminho_carrying_shell_history_expansion() {
13944        // The fail-before-pass-after pin for the canonical paste-from-
13945        // shell-history footgun on `:caminho`. An author copies a `cd
13946        // ../caixa-teia && !sudo make install` one-liner from a quick-
13947        // start README, intending the trailing `!sudo` as a shell-
13948        // history-expansion reference but the typed slot is itself a
13949        // byte-level string parser, not a shell context, so the byte
13950        // rides into the value verbatim. Until this arm landed the `!`
13951        // byte silently passed every prior `:caminho` cascade arm
13952        // (`!` isn't `\` / `<` / `>` / `|` / `;` / `&` / backtick /
13953        // `*` / `?` / `(` / `)` / `{` / `}` / `[` / `]` / `'` / `"` /
13954        // `#` / `%` / `$`); bash with the default `histexpand` mode
13955        // rewrites `!command` to the most recent history entry
13956        // beginning with `command`, the canonical RCE-class injection
13957        // vector when the byte rides into a shell argument executed
13958        // under `bash -i` (the operator-notebook interactive shell).
13959        let d = dep_with_fonte(DepSource::Path {
13960            caminho: "../caixa-teia!sudo".into(),
13961        });
13962        let err = d.validate().unwrap_err();
13963        let DepError::FonteCaminhoShellHistoryExpansion {
13964            nome,
13965            caminho,
13966            byte,
13967        } = err
13968        else {
13969            panic!("expected FonteCaminhoShellHistoryExpansion, got {err:?}");
13970        };
13971        assert_eq!(nome, "caixa-teia");
13972        assert_eq!(caminho, "../caixa-teia!sudo");
13973        assert_eq!(byte, b'!');
13974    }
13975
13976    #[test]
13977    fn validate_rejects_path_fonte_with_caminho_carrying_double_bang_history_reference() {
13978        // The symmetric `!!` repeat-prior-command paste idiom (peer with
13979        // `validate_rejects_git_fonte_with_repo_carrying_double_bang_history_reference`
13980        // on `is_git_repo_url`). Pinned separately from the wrapped
13981        // `!command` shape so a future diagnostic-surface change that
13982        // only checked the leading or paired-bang position surfaces
13983        // here — the per-byte arm fires anywhere `!` appears in the
13984        // value, including at consecutive positions in the middle.
13985        let d = dep_with_fonte(DepSource::Path {
13986            caminho: "../foo!!/bar".into(),
13987        });
13988        let err = d.validate().unwrap_err();
13989        assert!(
13990            matches!(
13991                err,
13992                DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
13993            ),
13994            "got {err:?}",
13995        );
13996    }
13997
13998    #[test]
13999    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_enthusiasm_bang() {
14000        // The English-typography enthusiasm-form paste-from-prose
14001        // idiom: an author writes `:caminho "../caixa-teia!"`
14002        // expecting the substrate to coerce it to a kebab-case slug.
14003        // Pinned separately from the `!<word>` shell-history shape so
14004        // the gate's rationale extends to the paste-from-prose surface
14005        // (the same rationale the peer `is_git_repo_url` bang arm at
14006        // 7d53c68 covers). None of the prior shell-metachar arms cover
14007        // this shape (no `!<word>` reference and no `!!` repeat), so
14008        // the arm is the sole gate on the shape.
14009        let d = dep_with_fonte(DepSource::Path {
14010            caminho: "../caixa-teia!".into(),
14011        });
14012        let err = d.validate().unwrap_err();
14013        assert!(
14014            matches!(
14015                err,
14016                DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
14017            ),
14018            "got {err:?}",
14019        );
14020    }
14021
14022    #[test]
14023    fn validate_accepts_path_fonte_with_caminho_carrying_no_bang() {
14024        // The positive-control pin (peer with
14025        // `validate_accepts_path_fonte_with_caminho_carrying_no_dollar`
14026        // on the immediate-predecessor arm): the gate targets only
14027        // `!`, never adjacent printable ASCII or POSIX-valid bytes.
14028        // A relative POSIX path carrying dashes / dots / slashes /
14029        // digits (`"../caixa-teia/sub-dir.v2"`) must continue to
14030        // validate cleanly so the gate doesn't widen to a "no
14031        // printable punctuation anywhere" sweep that would defeat
14032        // the entire path-fonte author surface.
14033        let d = dep_with_fonte(DepSource::Path {
14034            caminho: "../caixa-teia/sub-dir.v2".into(),
14035        });
14036        d.validate().unwrap();
14037    }
14038
14039    #[test]
14040    fn fonte_caminho_shell_variable_expansion_fires_before_shell_history_expansion() {
14041        // Cascade pin on the immediate-predecessor arm: a value
14042        // carrying both embedded `$` and `!` (`"../foo$HOME/bar!sudo"`
14043        // — the canonical "I pasted a `$HOME`-templated path adjacent
14044        // to a trailing `!sudo` history-expansion") routes through
14045        // `FonteCaminhoShellVariableExpansion` not
14046        // `FonteCaminhoShellHistoryExpansion`. The shell-variable-
14047        // expansion byte is the more semantic-locating axis on
14048        // probe-as-both values (the paste-from-CI-manifest-with-`$VAR`-
14049        // template shape is the load-bearing self-locating edit);
14050        // same cascade discipline every prior `:caminho` arm
14051        // establishes.
14052        let d = dep_with_fonte(DepSource::Path {
14053            caminho: "../foo$HOME/bar!sudo".into(),
14054        });
14055        let err = d.validate().unwrap_err();
14056        assert!(
14057            matches!(
14058                err,
14059                DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
14060            ),
14061            "got {err:?}",
14062        );
14063    }
14064
14065    #[test]
14066    fn fonte_caminho_shell_history_expansion_fires_before_trailing_slash() {
14067        // Cascade pin on the immediate-successor arm: a value carrying
14068        // both embedded `!` and a trailing `/` (`"../caixa-teia!sudo/"`
14069        // — the canonical "I tab-completed a `!sudo`-carrying path")
14070        // routes through `FonteCaminhoShellHistoryExpansion` not
14071        // `FonteCaminhoTrailingSlash`. The embedded shell-history-
14072        // expansion byte is the more semantic-locating axis on probe-
14073        // as-both values (an author who removes the `!sudo` history
14074        // reference is likely to also tab-strip the trailing separator).
14075        let d = dep_with_fonte(DepSource::Path {
14076            caminho: "../caixa-teia!sudo/".into(),
14077        });
14078        let err = d.validate().unwrap_err();
14079        assert!(
14080            matches!(
14081                err,
14082                DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
14083            ),
14084            "got {err:?}",
14085        );
14086    }
14087
14088    #[test]
14089    fn fonte_caminho_shell_history_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
14090        // Diagnostic-shape pin (peer with
14091        // `fonte_caminho_shell_variable_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
14092        // on the immediate-predecessor arm): the error's Display
14093        // surfaces the offending `:nome`, the offending `:caminho`
14094        // verbatim, the offending byte's hex / character form, and
14095        // names the shell-history-expansion / bang-operator footgun
14096        // explicitly so a `feira lint` run can render the diagnostic
14097        // without re-parsing.
14098        let d = dep_with_fonte(DepSource::Path {
14099            caminho: "../caixa-teia!sudo".into(),
14100        });
14101        let rendered = d.validate().unwrap_err().to_string();
14102        assert!(
14103            rendered.contains("caixa-teia"),
14104            "diagnostic must name the offending dep: {rendered}",
14105        );
14106        assert!(
14107            rendered.contains("../caixa-teia!sudo"),
14108            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
14109        );
14110        assert!(
14111            rendered.contains("0x21"),
14112            "diagnostic must surface the offending byte hex: {rendered:?}",
14113        );
14114        assert!(
14115            rendered.contains("history-expansion") || rendered.contains("history expansion"),
14116            "diagnostic must name the shell-history-expansion footgun: {rendered:?}",
14117        );
14118        assert!(
14119            rendered.contains("bang"),
14120            "diagnostic must reference the bang-operator vocabulary: {rendered:?}",
14121        );
14122    }
14123
14124    #[test]
14125    fn validate_rejects_path_fonte_with_caminho_carrying_shell_history_substitution() {
14126        // The fail-before-pass-after pin for the canonical paste-from-
14127        // shell-history-quick-substitution footgun on `:caminho`. An
14128        // author copies a `git clone <bad-url>` line from their terminal,
14129        // corrects it via bash's `^bad^good` quick-substitution history
14130        // operator (bash reference §9.3, `set -o histexpand` mode's
14131        // default for interactive sessions), and pastes the trailing
14132        // `^bad^good` substitution fragment into a `:caminho` value
14133        // without trimming the leading `git clone` prefix — the byte
14134        // rides into the manifest verbatim. Until this arm landed the
14135        // `^` byte silently passed every prior `:caminho` cascade arm
14136        // (`^` isn't `\` / `<` / `>` / `|` / `;` / `&` / backtick / `*`
14137        // / `?` / `(` / `)` / `{` / `}` / `[` / `]` / `'` / `"` / `#` /
14138        // `%` / `$` / `!`); bash with the default `histexpand` mode
14139        // rewrites the prior command's `bad` string to `good` and re-
14140        // executes it, the paired-operator half of the `set -o
14141        // histexpand` feature the peer `!` arm already closes the prefix
14142        // half of. The peer `is_git_repo_url` axis rejects the byte at
14143        // 49e142f under the same shell-history-substitution / RFC-3986-
14144        // unwise banner.
14145        let d = dep_with_fonte(DepSource::Path {
14146            caminho: "../foo^bad^good".into(),
14147        });
14148        let err = d.validate().unwrap_err();
14149        let DepError::FonteCaminhoShellHistorySubstitution {
14150            nome,
14151            caminho,
14152            byte,
14153        } = err
14154        else {
14155            panic!("expected FonteCaminhoShellHistorySubstitution, got {err:?}");
14156        };
14157        assert_eq!(nome, "caixa-teia");
14158        assert_eq!(caminho, "../foo^bad^good");
14159        assert_eq!(byte, b'^');
14160    }
14161
14162    #[test]
14163    fn validate_rejects_path_fonte_with_caminho_carrying_regex_negation_anchor() {
14164        // The symmetric paste-from-doc-grep-pipeline footgun (peer with
14165        // `validate_rejects_git_fonte_with_repo_carrying_caret_regex_anchor`
14166        // on `is_git_repo_url`). An author copies a `grep '^archived'`
14167        // regex-anchor / negation idiom from a doc snippet and the byte
14168        // rides in verbatim. Pinned separately from the `^old^new^`
14169        // quick-substitution shape so a future diagnostic-surface change
14170        // that only checked the paired-caret history-substitution
14171        // position surfaces here — the per-byte arm fires anywhere `^`
14172        // appears in the value, including at a solitary leading-of-
14173        // segment position.
14174        let d = dep_with_fonte(DepSource::Path {
14175            caminho: "../foo/^archived".into(),
14176        });
14177        let err = d.validate().unwrap_err();
14178        assert!(
14179            matches!(
14180                err,
14181                DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
14182            ),
14183            "got {err:?}",
14184        );
14185    }
14186
14187    #[test]
14188    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_history_substitution_open() {
14189        // The trailing-`^` history-substitution-open shape — an author
14190        // starts typing a `^bad^good` quick-substitution but pastes only
14191        // the leading `^` sentinel before context-switching (a bash-
14192        // reference §9.3 valid histexpand prefix on its own — even a
14193        // solitary `^` on the prior command's whole re-execution shape).
14194        // Pinned separately from the `^old^new^` full-form and the leading-
14195        // of-segment `^archived` regex-anchor shape so the gate's
14196        // rationale extends to the paste-from-shell-history-with-only-
14197        // the-first-byte-selected surface. None of the prior shell-
14198        // metachar arms cover this shape.
14199        let d = dep_with_fonte(DepSource::Path {
14200            caminho: "../caixa-teia^".into(),
14201        });
14202        let err = d.validate().unwrap_err();
14203        assert!(
14204            matches!(
14205                err,
14206                DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
14207            ),
14208            "got {err:?}",
14209        );
14210    }
14211
14212    #[test]
14213    fn validate_accepts_path_fonte_with_caminho_carrying_no_caret() {
14214        // The positive-control pin (peer with
14215        // `validate_accepts_path_fonte_with_caminho_carrying_no_bang`
14216        // on the immediate-predecessor arm): the gate targets only
14217        // `^`, never adjacent printable ASCII or POSIX-valid bytes.
14218        // A relative POSIX path carrying dashes / dots / slashes /
14219        // digits / underscore (`"../caixa-teia/sub_v2.rc"`) must
14220        // continue to validate cleanly so the gate doesn't widen to
14221        // a "no printable punctuation anywhere" sweep that would
14222        // defeat the entire path-fonte author surface.
14223        let d = dep_with_fonte(DepSource::Path {
14224            caminho: "../caixa-teia/sub_v2.rc".into(),
14225        });
14226        d.validate().unwrap();
14227    }
14228
14229    #[test]
14230    fn fonte_caminho_shell_history_expansion_fires_before_shell_history_substitution() {
14231        // Cascade pin on the immediate-predecessor arm: a value carrying
14232        // both embedded `!` and `^` (`"../foo!sudo^bad^good"` — the
14233        // canonical "I pasted a `!sudo` history-reference next to a
14234        // `^bad^good` quick-substitution") routes through
14235        // `FonteCaminhoShellHistoryExpansion` not
14236        // `FonteCaminhoShellHistorySubstitution`. The `!` prefix form is
14237        // the more semantic-locating axis on probe-as-both values (an
14238        // author who removes the `!sudo` reference is likely to also
14239        // strip the paired `^` substitution fragment); same cascade
14240        // discipline every prior `:caminho` arm establishes.
14241        let d = dep_with_fonte(DepSource::Path {
14242            caminho: "../foo!sudo^bad^good".into(),
14243        });
14244        let err = d.validate().unwrap_err();
14245        assert!(
14246            matches!(
14247                err,
14248                DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
14249            ),
14250            "got {err:?}",
14251        );
14252    }
14253
14254    #[test]
14255    fn fonte_caminho_shell_history_substitution_fires_before_trailing_slash() {
14256        // Cascade pin on the immediate-successor arm: a value carrying
14257        // both embedded `^` and a trailing `/` (`"../foo^bad^good/"` —
14258        // the canonical "I tab-completed a `^bad^good`-carrying path")
14259        // routes through `FonteCaminhoShellHistorySubstitution` not
14260        // `FonteCaminhoTrailingSlash`. The embedded shell-history-
14261        // substitution byte is the more semantic-locating axis on probe-
14262        // as-both values (an author who removes the `^bad^good`
14263        // substitution fragment is likely to also tab-strip the trailing
14264        // separator).
14265        let d = dep_with_fonte(DepSource::Path {
14266            caminho: "../foo^bad^good/".into(),
14267        });
14268        let err = d.validate().unwrap_err();
14269        assert!(
14270            matches!(
14271                err,
14272                DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
14273            ),
14274            "got {err:?}",
14275        );
14276    }
14277
14278    #[test]
14279    fn fonte_caminho_shell_history_substitution_diagnostic_carries_offending_dep_caminho_and_byte()
14280    {
14281        // Diagnostic-shape pin (peer with
14282        // `fonte_caminho_shell_history_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
14283        // on the immediate-predecessor arm): the error's Display
14284        // surfaces the offending `:nome`, the offending `:caminho`
14285        // verbatim, the offending byte's hex form, and names the
14286        // shell-history-substitution / RFC-3986-'unwise' / regex-
14287        // negation footgun explicitly so a `feira lint` run can render
14288        // the diagnostic without re-parsing.
14289        let d = dep_with_fonte(DepSource::Path {
14290            caminho: "../foo^bad^good".into(),
14291        });
14292        let rendered = d.validate().unwrap_err().to_string();
14293        assert!(
14294            rendered.contains("caixa-teia"),
14295            "diagnostic must name the offending dep: {rendered}",
14296        );
14297        assert!(
14298            rendered.contains("../foo^bad^good"),
14299            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
14300        );
14301        assert!(
14302            rendered.contains("0x5e") || rendered.contains("0x5E"),
14303            "diagnostic must surface the offending byte hex: {rendered:?}",
14304        );
14305        assert!(
14306            rendered.contains("history-substitution") || rendered.contains("history substitution"),
14307            "diagnostic must name the shell-history-substitution footgun: {rendered:?}",
14308        );
14309        assert!(
14310            rendered.contains("unwise"),
14311            "diagnostic must reference the RFC-3986 'unwise' set vocabulary: {rendered:?}",
14312        );
14313    }
14314
14315    #[test]
14316    fn fonte_repo_empty_fires_before_pin_missing() {
14317        // Order pin: empty `:repo` is the more self-locating diagnostic
14318        // (every git source needs a repo; the pin discussion is
14319        // secondary), so it fires before the pin-missing arm even when
14320        // both are violated. Mirrors the
14321        // `nome_empty_takes_precedence_over_versao_invalid` ordering
14322        // discipline on the per-entry layer.
14323        let d = dep_with_fonte(DepSource::Git {
14324            repo: String::new(),
14325            tag: None,
14326            rev: None,
14327            branch: None,
14328        });
14329        let err = d.validate().unwrap_err();
14330        assert!(
14331            matches!(err, DepError::FonteRepoEmpty { .. }),
14332            "got {err:?}"
14333        );
14334    }
14335
14336    #[test]
14337    fn fonte_pin_missing_fires_before_pin_empty() {
14338        // Order pin: a fully-None pin set is structurally distinct from
14339        // a Some(empty) pin — the first surfaces as FontePinMissing
14340        // (no axis chosen), the second as FontePinEmpty (axis chosen
14341        // but value blank). Pin the disjoint relationship so a future
14342        // unification collapses to one variant only as a structural
14343        // decision.
14344        let d = dep_with_fonte(DepSource::Git {
14345            repo: "github:pleme-io/caixa-teia".into(),
14346            tag: None,
14347            rev: None,
14348            branch: None,
14349        });
14350        assert!(matches!(
14351            d.validate().unwrap_err(),
14352            DepError::FontePinMissing { .. }
14353        ));
14354    }
14355
14356    #[test]
14357    fn nome_empty_takes_precedence_over_fonte_invalid() {
14358        // Order pin: a per-entry diagnostic without a non-empty :nome
14359        // can't be self-locating, so :nome "" fires first even when
14360        // :fonte is also malformed. Mirrors
14361        // `nome_empty_takes_precedence_over_versao_invalid` on the
14362        // adjacent axis.
14363        let mut d = dep_with_fonte(DepSource::Git {
14364            repo: String::new(),
14365            tag: None,
14366            rev: None,
14367            branch: None,
14368        });
14369        d.nome = String::new();
14370        assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
14371    }
14372
14373    #[test]
14374    fn versao_invalid_takes_precedence_over_fonte_invalid() {
14375        // Order pin: the :versao parse-side diagnostic is narrower than
14376        // the :fonte shape diagnostic — a malformed :versao always names
14377        // the parser's reason, which is more actionable than the
14378        // :fonte gate's "the pins are wrong" wording. Pin the ordering
14379        // so a re-ordering surfaces here.
14380        let mut d = dep_with_fonte(DepSource::Git {
14381            repo: String::new(),
14382            tag: None,
14383            rev: None,
14384            branch: None,
14385        });
14386        d.versao = "v0.1".into();
14387        let err = d.validate().unwrap_err();
14388        assert!(
14389            matches!(err, DepError::VersaoInvalid { ref nome, .. } if nome == "caixa-teia"),
14390            "got {err:?}"
14391        );
14392    }
14393
14394    #[test]
14395    fn fonte_invalid_diagnostic_carries_offending_nome() {
14396        // The diagnostic-shape pin: every :fonte error variant names
14397        // the offending dep's :nome verbatim, so the author can grep
14398        // caixa.lisp for the `:nome "<n>"` block and fix it in one
14399        // edit. Cover all seven variants so a future variant addition
14400        // forces a parallel diagnostic-shape decision.
14401        for (case, fonte) in [
14402            (
14403                "repo-empty",
14404                DepSource::Git {
14405                    repo: String::new(),
14406                    tag: Some("v1".into()),
14407                    rev: None,
14408                    branch: None,
14409                },
14410            ),
14411            (
14412                "repo-shape",
14413                DepSource::Git {
14414                    repo: "github:p/x ".into(),
14415                    tag: Some("v1".into()),
14416                    rev: None,
14417                    branch: None,
14418                },
14419            ),
14420            (
14421                "pin-missing",
14422                DepSource::Git {
14423                    repo: "github:p/x".into(),
14424                    tag: None,
14425                    rev: None,
14426                    branch: None,
14427                },
14428            ),
14429            (
14430                "pin-ambiguous",
14431                DepSource::Git {
14432                    repo: "github:p/x".into(),
14433                    tag: Some("v1".into()),
14434                    rev: None,
14435                    branch: Some("main".into()),
14436                },
14437            ),
14438            (
14439                "pin-empty",
14440                DepSource::Git {
14441                    repo: "github:p/x".into(),
14442                    tag: Some(String::new()),
14443                    rev: None,
14444                    branch: None,
14445                },
14446            ),
14447            (
14448                "caminho-empty",
14449                DepSource::Path {
14450                    caminho: String::new(),
14451                },
14452            ),
14453            (
14454                "caminho-absolute",
14455                DepSource::Path {
14456                    caminho: "/home/me/work/caixa-teia".into(),
14457                },
14458            ),
14459        ] {
14460            let d = dep_with_fonte(fonte);
14461            let msg = d
14462                .validate()
14463                .expect_err(&format!("{case}: expected fonte error"))
14464                .to_string();
14465            assert!(
14466                msg.contains("\"caixa-teia\""),
14467                "{case}: diagnostic must quote the offending :nome verbatim, got {msg:?}"
14468            );
14469        }
14470    }
14471
14472    // -- :tag / :branch value-shape gate ----------------------------------
14473
14474    #[test]
14475    fn validate_rejects_git_fonte_with_tag_carrying_trailing_space() {
14476        // The canonical paste-from-doc footgun on `:tag` — author
14477        // copies `"v0.1.0 "` (trailing space) out of a release-notes
14478        // paragraph. Until this gate landed the empty-pin arm passed
14479        // (the string isn't empty), the resolver issued
14480        // `git fetch <remote> tag 'v0.1.0 '`, and the failure
14481        // surfaced at clone time with a quoting-confused git error
14482        // far from the source caixa.lisp. The new gate moves the
14483        // check to caixa-build time and names the offending dep +
14484        // pin + value verbatim.
14485        let d = dep_with_fonte(DepSource::Git {
14486            repo: "github:pleme-io/caixa-teia".into(),
14487            tag: Some("v0.1.0 ".into()),
14488            rev: None,
14489            branch: None,
14490        });
14491        let err = d.validate().unwrap_err();
14492        let DepError::FontePinShape {
14493            nome,
14494            pin,
14495            value,
14496            reason,
14497        } = err
14498        else {
14499            panic!("expected FontePinShape, got other variant");
14500        };
14501        assert_eq!(nome, "caixa-teia");
14502        assert_eq!(pin, ":tag");
14503        assert_eq!(value, "v0.1.0 ");
14504        assert!(
14505            reason.contains("whitespace"),
14506            "reason must surface the whitespace arm, got {reason:?}"
14507        );
14508    }
14509
14510    #[test]
14511    fn validate_rejects_git_fonte_with_tag_carrying_lock_suffix() {
14512        // The `.lock` suffix is git's atomic-rename guard for
14513        // in-flight ref updates — a refname ending in `.lock` is
14514        // unwritable on disk. Pinned separately from the whitespace
14515        // arm so a future relaxation that admits one but not the
14516        // other surfaces here.
14517        let d = dep_with_fonte(DepSource::Git {
14518            repo: "github:pleme-io/caixa-teia".into(),
14519            tag: Some("v0.1.0.lock".into()),
14520            rev: None,
14521            branch: None,
14522        });
14523        let err = d.validate().unwrap_err();
14524        let DepError::FontePinShape {
14525            pin, value, reason, ..
14526        } = err
14527        else {
14528            panic!("expected FontePinShape, got other variant");
14529        };
14530        assert_eq!(pin, ":tag");
14531        assert_eq!(value, "v0.1.0.lock");
14532        assert!(
14533            reason.contains(".lock"),
14534            "reason must surface the .lock arm, got {reason:?}"
14535        );
14536    }
14537
14538    #[test]
14539    fn validate_rejects_git_fonte_with_branch_carrying_embedded_space() {
14540        // The canonical "branch name with spaces" footgun (`feature
14541        // foo`, `release branch`) — git's refname parser rejects raw
14542        // whitespace, and the failure surfaces at `git checkout
14543        // 'feature foo'` time with a quoting-confused error far from
14544        // the source caixa.lisp. Pinned on the `:branch` axis so the
14545        // gate-applies-to-both-:tag-and-:branch contract is a build-
14546        // error to relax.
14547        let d = dep_with_fonte(DepSource::Git {
14548            repo: "github:pleme-io/caixa-teia".into(),
14549            tag: None,
14550            rev: None,
14551            branch: Some("feature/foo bar".into()),
14552        });
14553        let err = d.validate().unwrap_err();
14554        let DepError::FontePinShape {
14555            pin, value, reason, ..
14556        } = err
14557        else {
14558            panic!("expected FontePinShape, got other variant");
14559        };
14560        assert_eq!(pin, ":branch");
14561        assert_eq!(value, "feature/foo bar");
14562        assert!(
14563            reason.contains("whitespace"),
14564            "reason must surface the whitespace arm, got {reason:?}"
14565        );
14566    }
14567
14568    #[test]
14569    fn validate_rejects_git_fonte_with_branch_carrying_qualified_prefix() {
14570        // The `refs/heads/main` shape — the canonical "I copied the
14571        // fully-qualified ref out of `git show-ref` instead of the
14572        // leaf" footgun. The caixa-resolver prepends `refs/heads/`
14573        // at clone time, so this resolves to a literal ref named
14574        // `refs/heads/refs/heads/main` on disk; the silent double-
14575        // prefix is the load-bearing reason to gate at validate.
14576        // The diagnostic must enumerate the leaf the author probably
14577        // meant (`"main"`) so the fix is one edit.
14578        let d = dep_with_fonte(DepSource::Git {
14579            repo: "github:pleme-io/caixa-teia".into(),
14580            tag: None,
14581            rev: None,
14582            branch: Some("refs/heads/main".into()),
14583        });
14584        let err = d.validate().unwrap_err();
14585        let DepError::FontePinShape {
14586            pin, value, reason, ..
14587        } = err
14588        else {
14589            panic!("expected FontePinShape, got other variant");
14590        };
14591        assert_eq!(pin, ":branch");
14592        assert_eq!(value, "refs/heads/main");
14593        assert!(
14594            reason.contains("fully-qualified"),
14595            "reason must surface the qualified-prefix arm, got {reason:?}"
14596        );
14597        assert!(
14598            reason.contains("\"main\""),
14599            "reason must quote the leaf the author probably meant, got {reason:?}"
14600        );
14601    }
14602
14603    #[test]
14604    fn validate_rejects_git_fonte_with_tag_carrying_qualified_prefix() {
14605        // Sibling arm of the qualified-prefix gate on the `:tag`
14606        // axis (`refs/tags/v0.1.0` — same `git show-ref` output-leak
14607        // footgun). Pinned separately so a future relaxation that
14608        // only catches the `:branch` arm surfaces here.
14609        let d = dep_with_fonte(DepSource::Git {
14610            repo: "github:pleme-io/caixa-teia".into(),
14611            tag: Some("refs/tags/v0.1.0".into()),
14612            rev: None,
14613            branch: None,
14614        });
14615        let err = d.validate().unwrap_err();
14616        let DepError::FontePinShape {
14617            pin, value, reason, ..
14618        } = err
14619        else {
14620            panic!("expected FontePinShape, got other variant");
14621        };
14622        assert_eq!(pin, ":tag");
14623        assert_eq!(value, "refs/tags/v0.1.0");
14624        assert!(
14625            reason.contains("fully-qualified"),
14626            "reason must surface the qualified-prefix arm, got {reason:?}"
14627        );
14628        assert!(
14629            reason.contains("\"v0.1.0\""),
14630            "reason must quote the leaf the author probably meant, got {reason:?}"
14631        );
14632    }
14633
14634    #[test]
14635    fn validate_rejects_git_fonte_with_branch_named_at() {
14636        // The bare `@` is git's alias for `HEAD`; a `:branch "@"` is
14637        // unsourceable. Pinned so a future relaxation that admits
14638        // any single-character refname surfaces here.
14639        let d = dep_with_fonte(DepSource::Git {
14640            repo: "github:pleme-io/caixa-teia".into(),
14641            tag: None,
14642            rev: None,
14643            branch: Some("@".into()),
14644        });
14645        let err = d.validate().unwrap_err();
14646        let DepError::FontePinShape { pin, value, .. } = err else {
14647            panic!("expected FontePinShape, got other variant");
14648        };
14649        assert_eq!(pin, ":branch");
14650        assert_eq!(value, "@");
14651    }
14652
14653    #[test]
14654    fn validate_rejects_git_fonte_with_tag_carrying_double_dot() {
14655        // Git's `<rev1>..<rev2>` range grammar reserves `..` —
14656        // a `:tag "../escape"` (path-traversal-shaped slug) silently
14657        // passes parse and surfaces as a refname-parse error or, on
14658        // older git, a literal `../escape` checkout that escapes the
14659        // refs/ directory tree. Pinned separately from the
14660        // qualified-prefix arm so a future relaxation that catches
14661        // one but not the other surfaces here.
14662        let d = dep_with_fonte(DepSource::Git {
14663            repo: "github:pleme-io/caixa-teia".into(),
14664            tag: Some("../escape".into()),
14665            rev: None,
14666            branch: None,
14667        });
14668        let err = d.validate().unwrap_err();
14669        let DepError::FontePinShape { pin, value, .. } = err else {
14670            panic!("expected FontePinShape, got other variant");
14671        };
14672        assert_eq!(pin, ":tag");
14673        assert_eq!(value, "../escape");
14674    }
14675
14676    #[test]
14677    fn validate_accepts_git_fonte_with_hierarchical_branch() {
14678        // The positive-control pin: hierarchical refnames with one or
14679        // more `/` separators (the `feature/foo` / `user/jdoe/feat`
14680        // canonical idiom) round-trip through the gate. Pinned
14681        // separately from the leaf-`"main"` positive control so a
14682        // future tightening that rejects all multi-component refnames
14683        // surfaces here.
14684        let d = dep_with_fonte(DepSource::Git {
14685            repo: "github:pleme-io/caixa-teia".into(),
14686            tag: None,
14687            rev: None,
14688            branch: Some("feature/checkout-rewrite".into()),
14689        });
14690        d.validate().unwrap();
14691    }
14692
14693    #[test]
14694    fn validate_accepts_git_fonte_with_prerelease_tag() {
14695        // The positive-control pin: semver pre-release shape
14696        // (`v0.1.0-alpha.1`) — the in-component dot is allowed
14697        // (only consecutive `..` and trailing `.` are rejected), the
14698        // mid-component hyphen is allowed. Pinned separately from
14699        // the bare-`"v0.1.0"` positive control so a future tightening
14700        // that rejects pre-release tags surfaces here.
14701        let d = dep_with_fonte(DepSource::Git {
14702            repo: "github:pleme-io/caixa-teia".into(),
14703            tag: Some("v0.1.0-alpha.1".into()),
14704            rev: None,
14705            branch: None,
14706        });
14707        d.validate().unwrap();
14708    }
14709
14710    #[test]
14711    fn validate_rejects_git_fonte_with_rev_carrying_refname_unfriendly_value() {
14712        // The `:rev` axis is routed through `crate::render::is_git_oid`
14713        // (a SHA's character set is `[0-9a-f]`, not a refname's), so a
14714        // value with refname-shape punctuation (here, a `:` mid-string
14715        // — would be a refname violation under `is_git_ref_name` too)
14716        // is rejected at the OID-shape gate. The two predicates
14717        // partition the `:fonte` pin axes structurally: an `:rev` value
14718        // that's a valid refname (`:rev "main"`, `:rev "v0.1.0"`) is
14719        // *still* rejected here because every refname character outside
14720        // `[0-9a-f]` fails the OID gate. Same shape as
14721        // `fonte_pin_shape_diagnostic_carries_offending_nome_pin_value`
14722        // on the refname-shaped axes — the diagnostic names the
14723        // offending dep + pin + value verbatim. The flip-from-accept
14724        // case the prior `:tag`/`:branch` gate left as a "future axis"
14725        // (e70d213) — now landed.
14726        let d = dep_with_fonte(DepSource::Git {
14727            repo: "github:pleme-io/caixa-teia".into(),
14728            tag: None,
14729            rev: Some("c0ffee:notarefname".into()),
14730            branch: None,
14731        });
14732        let err = d.validate().unwrap_err();
14733        let DepError::FontePinShape {
14734            nome,
14735            pin,
14736            value,
14737            reason,
14738        } = err
14739        else {
14740            panic!("expected FontePinShape, got other variant");
14741        };
14742        assert_eq!(nome, "caixa-teia");
14743        assert_eq!(pin, ":rev");
14744        assert_eq!(value, "c0ffee:notarefname");
14745        assert!(
14746            !reason.is_empty(),
14747            "FontePinShape `reason` must carry the predicate's wording verbatim"
14748        );
14749    }
14750
14751    #[test]
14752    fn validate_accepts_git_fonte_with_rev_full_sha1() {
14753        // The positive-control pin on the SHA-1 OID width: exactly 40
14754        // lowercase hex characters — the canonical `git rev-parse HEAD`
14755        // emission on a SHA-1-hashed repository (the default on every
14756        // pre-2.42 git and the canonical pleme-io substrate hash).
14757        // Pinned separately from the SHA-256 positive control so a
14758        // future tightening that only admits one width surfaces here.
14759        let d = dep_with_fonte(DepSource::Git {
14760            repo: "github:pleme-io/caixa-teia".into(),
14761            tag: None,
14762            rev: Some("0123456789abcdef0123456789abcdef01234567".into()),
14763            branch: None,
14764        });
14765        d.validate().unwrap();
14766    }
14767
14768    #[test]
14769    fn validate_accepts_git_fonte_with_rev_full_sha256() {
14770        // The positive-control pin on the SHA-256 OID width: exactly
14771        // 64 lowercase hex characters — `git`'s
14772        // `extensions.objectFormat = sha256` emission (GA since Git
14773        // 2.42 / Oct 2023). The substrate admits either canonical
14774        // width so an `:rev` authored against a SHA-256-hashed
14775        // upstream round-trips through the gate without per-repo
14776        // configuration. Pinned separately from the SHA-1 positive
14777        // control so a future tightening that drops one width surfaces
14778        // here as a structural decision.
14779        let d = dep_with_fonte(DepSource::Git {
14780            repo: "github:pleme-io/caixa-teia".into(),
14781            tag: None,
14782            rev: Some("0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef".into()),
14783            branch: None,
14784        });
14785        d.validate().unwrap();
14786    }
14787
14788    #[test]
14789    fn validate_rejects_git_fonte_with_rev_abbreviated_prefix() {
14790        // The canonical `git log --short` / `git rev-parse --short HEAD`
14791        // paste-from-release-notes footgun: a 7-char prefix (git's
14792        // default `core.abbrev`) silently passes string emptiness
14793        // checks and resolves to one commit today, but becomes ambiguous
14794        // tomorrow as the repo grows. Until this gate landed the empty-
14795        // pin arm passed (the string isn't empty) and the resolver
14796        // accepted the prefix through git's separate prefix-lookup pass
14797        // — defeating the reproducibility contract `:rev` carries vs.
14798        // `:tag` / `:branch`. The new gate moves the check to caixa-
14799        // build time and names the offending dep + pin + value verbatim.
14800        let d = dep_with_fonte(DepSource::Git {
14801            repo: "github:pleme-io/caixa-teia".into(),
14802            tag: None,
14803            rev: Some("c0ffee0".into()),
14804            branch: None,
14805        });
14806        let err = d.validate().unwrap_err();
14807        let DepError::FontePinShape {
14808            pin, value, reason, ..
14809        } = err
14810        else {
14811            panic!("expected FontePinShape, got other variant");
14812        };
14813        assert_eq!(pin, ":rev");
14814        assert_eq!(value, "c0ffee0");
14815        assert!(
14816            reason.contains("abbreviated") || reason.contains("ambiguous"),
14817            "reason must surface the abbreviation arm, got {reason:?}"
14818        );
14819    }
14820
14821    #[test]
14822    fn validate_rejects_git_fonte_with_rev_uppercase_hex() {
14823        // The canonical "I pasted the SHA in uppercase" footgun: `git
14824        // porcelain` emits OIDs lowercase exclusively, so an uppercase-
14825        // bearing `:rev` round-trips inconsistently across the
14826        // resolver's `git fetch <remote> <:rev>` ↔ `git rev-parse HEAD`
14827        // equality-check pipeline and fails the lacre's content-
14828        // addressing probe with a confusing case-only diff. Pinned
14829        // separately from the non-hex arm so a future relaxation that
14830        // admits one but not the other surfaces here.
14831        let d = dep_with_fonte(DepSource::Git {
14832            repo: "github:pleme-io/caixa-teia".into(),
14833            tag: None,
14834            rev: Some("DEADBEEFCAFEBABE0123456789ABCDEF01234567".into()),
14835            branch: None,
14836        });
14837        let err = d.validate().unwrap_err();
14838        let DepError::FontePinShape {
14839            pin, value, reason, ..
14840        } = err
14841        else {
14842            panic!("expected FontePinShape, got other variant");
14843        };
14844        assert_eq!(pin, ":rev");
14845        assert_eq!(value, "DEADBEEFCAFEBABE0123456789ABCDEF01234567");
14846        assert!(
14847            reason.contains("uppercase"),
14848            "reason must surface the uppercase arm, got {reason:?}"
14849        );
14850    }
14851
14852    #[test]
14853    fn validate_rejects_git_fonte_with_rev_refname_value() {
14854        // The cross-axis mis-slot footgun: `:rev "main"` — the author
14855        // conflated `:rev` (hex commit ID, immutable) and `:branch`
14856        // (mutable ref pointing at whatever HEAD is today). Until this
14857        // gate landed the resolver silently dispatched on the value
14858        // shape ("`main` doesn't look like a SHA, fall back to
14859        // refname"), defeating the `:rev` reproducibility contract.
14860        // The new gate rejects every non-hex value on the `:rev` axis,
14861        // so the `:rev`/`:branch` boundary is structurally enforced —
14862        // a refname in the `:rev` slot is a build error, not a
14863        // resolver-time silent reinterpretation.
14864        let d = dep_with_fonte(DepSource::Git {
14865            repo: "github:pleme-io/caixa-teia".into(),
14866            tag: None,
14867            rev: Some("main".into()),
14868            branch: None,
14869        });
14870        let err = d.validate().unwrap_err();
14871        let DepError::FontePinShape {
14872            pin, value, reason, ..
14873        } = err
14874        else {
14875            panic!("expected FontePinShape, got other variant");
14876        };
14877        assert_eq!(pin, ":rev");
14878        assert_eq!(value, "main");
14879        // 4 chars `main` fails the length arm before the character arm,
14880        // so the diagnostic surfaces the abbreviation wording (same
14881        // path the `c0ffee0` 7-char fixture lands on); the structural
14882        // assertion is just that the `:rev "main"` value is rejected.
14883        assert!(
14884            !reason.is_empty(),
14885            "FontePinShape reason must be non-empty for refname-shaped :rev"
14886        );
14887    }
14888
14889    #[test]
14890    fn validate_rejects_git_fonte_with_rev_tag_shaped_value() {
14891        // Sibling cross-axis mis-slot: `:rev "v0.1.0"` — the author
14892        // conflated `:rev` and `:tag`. Pinned separately from the
14893        // `:rev "main"` (`:branch` mis-slot) arm so a future relaxation
14894        // that catches one but not the other surfaces here. The
14895        // length arm fires first (6 chars ≠ 40 ≠ 64); the structural
14896        // assertion is just that the cross-axis mis-slot is a build
14897        // error, regardless of which sub-arm surfaces the diagnostic
14898        // (`is_git_oid` rejects at the first violation; longer
14899        // tag-shape values would hit the non-hex arm instead).
14900        let d = dep_with_fonte(DepSource::Git {
14901            repo: "github:pleme-io/caixa-teia".into(),
14902            tag: None,
14903            rev: Some("v0.1.0".into()),
14904            branch: None,
14905        });
14906        let err = d.validate().unwrap_err();
14907        let DepError::FontePinShape {
14908            pin, value, reason, ..
14909        } = err
14910        else {
14911            panic!("expected FontePinShape, got other variant");
14912        };
14913        assert_eq!(pin, ":rev");
14914        assert_eq!(value, "v0.1.0");
14915        assert!(
14916            !reason.is_empty(),
14917            "FontePinShape reason must be non-empty for tag-shaped :rev"
14918        );
14919    }
14920
14921    #[test]
14922    fn validate_rejects_git_fonte_with_rev_too_long() {
14923        // Boundary case on the upper end: 41 hex chars — one past the
14924        // SHA-1 width, well below the SHA-256 width. Pin so a future
14925        // relaxation that admits "long enough to be a SHA" without
14926        // matching either canonical width surfaces here. The diagnostic
14927        // names the offending length verbatim so the author's grep
14928        // target is unambiguous (either trim one char or paste the
14929        // full SHA-256).
14930        let too_long: String = "0".repeat(41);
14931        let d = dep_with_fonte(DepSource::Git {
14932            repo: "github:pleme-io/caixa-teia".into(),
14933            tag: None,
14934            rev: Some(too_long.clone()),
14935            branch: None,
14936        });
14937        let err = d.validate().unwrap_err();
14938        let DepError::FontePinShape {
14939            pin, value, reason, ..
14940        } = err
14941        else {
14942            panic!("expected FontePinShape, got other variant");
14943        };
14944        assert_eq!(pin, ":rev");
14945        assert_eq!(value, too_long);
14946        assert!(
14947            reason.contains("41"),
14948            "reason must surface the offending length verbatim, got {reason:?}"
14949        );
14950    }
14951
14952    #[test]
14953    fn validate_rejects_git_fonte_with_rev_carrying_whitespace() {
14954        // The canonical paste-from-doc footgun on `:rev` — author
14955        // copies `"deadbeefcafe…0123 "` (trailing space) out of a
14956        // commit-message paragraph. Until this gate landed the empty-
14957        // pin arm passed (the string isn't empty), the resolver issued
14958        // `git fetch <remote> 'deadbeef… '` and the failure surfaced at
14959        // clone time with a quoting-confused git error far from the
14960        // source caixa.lisp. The new gate moves the check to caixa-
14961        // build time. Length is 41 (40 hex + space) so the length arm
14962        // fires first — pinned separately from the pure-length arm to
14963        // ensure the diagnostic surfaces *some* parser wording, not
14964        // silently pass through.
14965        let with_space = "0123456789abcdef0123456789abcdef01234567 ".to_string();
14966        let d = dep_with_fonte(DepSource::Git {
14967            repo: "github:pleme-io/caixa-teia".into(),
14968            tag: None,
14969            rev: Some(with_space.clone()),
14970            branch: None,
14971        });
14972        let err = d.validate().unwrap_err();
14973        let DepError::FontePinShape {
14974            pin, value, reason, ..
14975        } = err
14976        else {
14977            panic!("expected FontePinShape, got other variant");
14978        };
14979        assert_eq!(pin, ":rev");
14980        assert_eq!(value, with_space);
14981        assert!(
14982            !reason.is_empty(),
14983            "FontePinShape reason must be non-empty for whitespace-bearing :rev"
14984        );
14985    }
14986
14987    #[test]
14988    fn fonte_pin_shape_diagnostic_carries_offending_nome_pin_value_for_rev() {
14989        // Diagnostic-shape pin on the `:rev` axis: every FontePinShape
14990        // variant on this axis names the offending dep's `:nome` + the
14991        // `:rev` axis + the offending value verbatim, so the author's
14992        // grep target is the literal `:rev "<value>"` block in
14993        // caixa.lisp. Sibling of the `fonte_pin_shape_diagnostic_
14994        // carries_offending_nome_pin_value` test on the refname-shaped
14995        // (`:tag` / `:branch`) axes.
14996        let d = dep_with_fonte(DepSource::Git {
14997            repo: "github:p/x".into(),
14998            tag: None,
14999            rev: Some("not-a-sha".into()),
15000            branch: None,
15001        });
15002        let msg = d
15003            .validate()
15004            .expect_err(":rev: expected FontePinShape")
15005            .to_string();
15006        assert!(
15007            msg.contains("\"caixa-teia\""),
15008            ":rev: diagnostic must quote the offending :nome verbatim, got {msg:?}"
15009        );
15010        assert!(
15011            msg.contains(":rev"),
15012            ":rev: diagnostic must name the offending pin axis, got {msg:?}"
15013        );
15014        assert!(
15015            msg.contains("not-a-sha"),
15016            ":rev: diagnostic must quote the offending value verbatim, got {msg:?}"
15017        );
15018    }
15019
15020    #[test]
15021    fn fonte_pin_empty_fires_before_pin_shape() {
15022        // Order pin: a `Some("")` `:tag` is the more self-locating
15023        // diagnostic (the author chose an axis but left it blank;
15024        // grep is unambiguous), so it fires before the shape gate
15025        // even when both arms would match. Pinned so a future
15026        // reordering surfaces here. Mirrors the
15027        // `fonte_repo_empty_fires_before_pin_missing` ordering
15028        // discipline on the peer per-axis arms.
15029        let d = dep_with_fonte(DepSource::Git {
15030            repo: "github:pleme-io/caixa-teia".into(),
15031            tag: Some(String::new()),
15032            rev: None,
15033            branch: None,
15034        });
15035        assert!(matches!(
15036            d.validate().unwrap_err(),
15037            DepError::FontePinEmpty { ref pin, .. } if pin == ":tag"
15038        ));
15039    }
15040
15041    #[test]
15042    fn fonte_pin_shape_fires_after_repo_empty() {
15043        // Order pin: `:repo ""` is the more self-locating axis
15044        // (every git source needs a repo; the per-pin shape gate is
15045        // secondary), so the repo-empty arm fires before the
15046        // per-pin shape arm even when both are violated. Pinned so
15047        // a future reordering surfaces here. Mirrors
15048        // `fonte_repo_empty_fires_before_pin_missing` on the
15049        // adjacent axis pair.
15050        let d = dep_with_fonte(DepSource::Git {
15051            repo: String::new(),
15052            tag: Some("v0.1.0 ".into()),
15053            rev: None,
15054            branch: None,
15055        });
15056        assert!(matches!(
15057            d.validate().unwrap_err(),
15058            DepError::FonteRepoEmpty { .. }
15059        ));
15060    }
15061
15062    #[test]
15063    fn fonte_pin_shape_diagnostic_carries_offending_nome_pin_value() {
15064        // Diagnostic-shape pin across both refname-shaped axes
15065        // (`:tag` + `:branch`): every `FontePinShape` variant names
15066        // the offending dep's `:nome` + the offending pin axis + the
15067        // offending value verbatim, so the author's grep target is
15068        // unambiguous (the literal `:tag "<value>"` / `:branch
15069        // "<value>"` lands in caixa.lisp with quotes). Cover both
15070        // pin axes so a future variant addition forces a parallel
15071        // diagnostic-shape decision.
15072        for (pin_label, fonte) in [
15073            (
15074                ":tag",
15075                DepSource::Git {
15076                    repo: "github:p/x".into(),
15077                    tag: Some("v0.1.0~1".into()),
15078                    rev: None,
15079                    branch: None,
15080                },
15081            ),
15082            (
15083                ":branch",
15084                DepSource::Git {
15085                    repo: "github:p/x".into(),
15086                    tag: None,
15087                    rev: None,
15088                    branch: Some("feature/foo*".into()),
15089                },
15090            ),
15091        ] {
15092            let d = dep_with_fonte(fonte);
15093            let msg = d
15094                .validate()
15095                .expect_err(&format!("{pin_label}: expected FontePinShape"))
15096                .to_string();
15097            assert!(
15098                msg.contains("\"caixa-teia\""),
15099                "{pin_label}: diagnostic must quote the offending :nome verbatim, got {msg:?}"
15100            );
15101            assert!(
15102                msg.contains(pin_label),
15103                "{pin_label}: diagnostic must name the offending pin axis, got {msg:?}"
15104            );
15105        }
15106    }
15107
15108    #[test]
15109    fn git_source_json_round_trip() {
15110        let src = DepSource::Git {
15111            repo: "github:pleme-io/caixa-teia".into(),
15112            tag: Some("v0.1.0".into()),
15113            rev: None,
15114            branch: None,
15115        };
15116        let s = serde_json::to_string(&src).unwrap();
15117        assert!(s.contains(&format!(
15118            r#""{tipo}":"{git}""#,
15119            tipo = crate::render::DEP_SOURCE_KEY_TIPO,
15120            git = crate::render::DEP_SOURCE_TIPO_GIT,
15121        )));
15122        assert!(s.contains(r#""repo":"github:pleme-io/caixa-teia""#));
15123        assert!(s.contains(r#""tag":"v0.1.0""#));
15124        assert!(!s.contains("rev"));
15125        assert!(!s.contains("branch"));
15126        let round: DepSource = serde_json::from_str(&s).unwrap();
15127        assert_eq!(round, src);
15128    }
15129
15130    // ── DEP_SOURCE_{KEY_TIPO,TIPO_GIT,TIPO_PATH} drift-detection ────────
15131    //
15132    // The `#[serde(tag = "tipo", rename_all = "lowercase")]` derive
15133    // attribute on [`DepSource`] pins three load-bearing byte-sequences
15134    // that flow into every serialized `Dep.fonte` block: the outer
15135    // discriminator-key `"tipo"` the `tag = "tipo"` attribute names, and
15136    // the two admitted variant-tag values `"git"` / `"path"` the
15137    // `rename_all = "lowercase"` attribute pins as the discriminator's
15138    // closed-set arms. The three pin tests below round-trip a
15139    // fully-populated variant of each arm through
15140    // [`serde_json::to_value`] and assert each canonical byte-sequence
15141    // appears at its axis — pins a hypothetical future
15142    // `tag = "type"` / `tag = "source_type"` typo, a `rename_all`
15143    // rebrand (`"UPPERCASE"` / `"snake_case"` / `"kebab-case"`), or a
15144    // Rust-side variant rename (`Git` → `Repository`, `Path` → `Local`)
15145    // at build time rather than at fetch time when the resolver's
15146    // `Dep.fonte` dispatch silently fails to match on the drifted
15147    // discriminator. Same "serialize-and-check" discipline the peer
15148    // `M2_LIMITS_KEY_*`, `M2_BEHAVIOR_KEY_ON_*`, `SUPERVISOR_KEY_*`,
15149    // and `MEMBRO_KEY_*` drift-detection pins carry — extended here
15150    // to the last `#[serde(tag = ..., rename_all = ...)]` discriminator
15151    // family in caixa-core lacking a lifted peer.
15152
15153    #[test]
15154    fn dep_source_git_serde_keys_match_lifted_dep_source_key_consts() {
15155        // Fail-before-pass-after: a future `tag = "type"` at the derive
15156        // attribute would serialize under `"type":"git"`, and this test
15157        // would trip because `"tipo"` no longer appears at the emitted
15158        // discriminator key. A future `rename_all = "kebab-case"` /
15159        // `"snake_case"` (both no-ops on `Git` since it lacks internal
15160        // word boundaries) is caught by the sibling
15161        // `dep_source_path_serde_keys_match_lifted_dep_source_key_consts`
15162        // pin below (Path has no internal boundary either but the pair
15163        // catches any per-arm inconsistency). A future variant rename
15164        // `Git` → `Repository` would emit `"tipo":"repository"` and
15165        // trip this pin.
15166        let src = DepSource::Git {
15167            repo: "github:pleme-io/caixa-teia".into(),
15168            tag: Some("v0.1.0".into()),
15169            rev: None,
15170            branch: None,
15171        };
15172        let json = serde_json::to_value(&src).unwrap();
15173        let obj = json.as_object().expect("Git serializes as a JSON object");
15174        assert_eq!(
15175            obj.get(crate::render::DEP_SOURCE_KEY_TIPO)
15176                .and_then(serde_json::Value::as_str),
15177            Some(crate::render::DEP_SOURCE_TIPO_GIT),
15178            "DepSource::Git must serialize the tipo discriminator at DEP_SOURCE_KEY_TIPO \
15179             with value DEP_SOURCE_TIPO_GIT — attribute drift or variant rename \
15180             detected in {json}"
15181        );
15182    }
15183
15184    #[test]
15185    fn dep_source_path_serde_keys_match_lifted_dep_source_key_consts() {
15186        // Fail-before-pass-after: a future variant rename `Path` →
15187        // `Local` / `Filesystem` would emit `"tipo":"local"` and trip
15188        // this pin. A per-consumer disambiguation as the `defcaixa`
15189        // macro stabilizes ("caminho" → "path" for English-uniformity)
15190        // is scoped to the inner field key, not the discriminator; this
15191        // pin is orthogonal to that and catches only the outer
15192        // discriminator drift.
15193        let src = DepSource::Path {
15194            caminho: "../caixa-teia".into(),
15195        };
15196        let json = serde_json::to_value(&src).unwrap();
15197        let obj = json.as_object().expect("Path serializes as a JSON object");
15198        assert_eq!(
15199            obj.get(crate::render::DEP_SOURCE_KEY_TIPO)
15200                .and_then(serde_json::Value::as_str),
15201            Some(crate::render::DEP_SOURCE_TIPO_PATH),
15202            "DepSource::Path must serialize the tipo discriminator at DEP_SOURCE_KEY_TIPO \
15203             with value DEP_SOURCE_TIPO_PATH — attribute drift or variant rename \
15204             detected in {json}"
15205        );
15206    }
15207
15208    #[test]
15209    fn dep_source_key_consts_are_pairwise_distinct() {
15210        // Cross-axis collapse detector: a hypothetical future edit that
15211        // accidentally set two of the three consts to the same byte
15212        // (`DEP_SOURCE_TIPO_GIT = "path"` typo matching a peer arm) would
15213        // pass every per-arm serialize pin above but silently collapse
15214        // the discriminator's closed-set arms onto one another; this pin
15215        // catches the collapse at build time.
15216        assert_ne!(
15217            crate::render::DEP_SOURCE_KEY_TIPO,
15218            crate::render::DEP_SOURCE_TIPO_GIT,
15219        );
15220        assert_ne!(
15221            crate::render::DEP_SOURCE_KEY_TIPO,
15222            crate::render::DEP_SOURCE_TIPO_PATH,
15223        );
15224        assert_ne!(
15225            crate::render::DEP_SOURCE_TIPO_GIT,
15226            crate::render::DEP_SOURCE_TIPO_PATH,
15227        );
15228    }
15229
15230    #[test]
15231    fn dep_source_tipo_variant_consts_are_ascii_lowercase_shape() {
15232        // Shape pin against `rename_all` drift: the two variant-tag
15233        // consts must be ASCII-lowercase-only to match the
15234        // `rename_all = "lowercase"` attribute the derive uses; a future
15235        // rebrand to `"UPPERCASE"` / `"PascalCase"` at the attribute
15236        // would emit `"GIT"` / `"Git"` instead and trip this pin.
15237        for (label, s) in [
15238            ("DEP_SOURCE_TIPO_GIT", crate::render::DEP_SOURCE_TIPO_GIT),
15239            ("DEP_SOURCE_TIPO_PATH", crate::render::DEP_SOURCE_TIPO_PATH),
15240        ] {
15241            assert!(!s.is_empty(), "{label} must not be empty");
15242            assert!(
15243                s.bytes().all(|b| b.is_ascii_lowercase()),
15244                "{label} must be ASCII-lowercase-only (matching \
15245                 rename_all = \"lowercase\"), got {s:?}",
15246            );
15247        }
15248    }
15249
15250    // ── per-entry :caracteristicas set-not-multiset gate ────────────
15251    //
15252    // Every Vec-keyed-by-name authoring surface on the typed Caixa
15253    // surface that identifies its entries by a name field now uniformly
15254    // closes the set-not-multiset discipline at build time (cite
15255    // `validate_caracteristicas`'s peer-axis enumeration). The
15256    // `:caracteristicas` axis is per-`Dep`: the feature-toggle slot is
15257    // set-shaped (a feature is either enabled or not — there is no
15258    // `feature × 2` semantic), so two entries naming the same feature
15259    // are a redundant declaration the caixa-resolver's lacre pipeline
15260    // would silently dedup at resolve time. The empty-feature arm
15261    // closes the parallel "operationally-meaningless value" axis on
15262    // the same slot. Same linear-walk + `HashSet` + first-collision
15263    // shape every peer set gate uses; same empty-first cascade every
15264    // peer per-entry shape + duplicate gate uses (the empty-feature
15265    // axis is the more-actionable defect since two `""` entries would
15266    // both report `caracteristica: ""` under a duplicate-first
15267    // ordering, with no way to distinguish the offending site).
15268
15269    fn dep_with_features(features: &[&str]) -> Dep {
15270        Dep {
15271            nome: "caixa-teia".into(),
15272            versao: "^0.1".into(),
15273            fonte: None,
15274            opcional: false,
15275            caracteristicas: features.iter().map(|s| (*s).into()).collect(),
15276        }
15277    }
15278
15279    #[test]
15280    fn validate_rejects_empty_caracteristica() {
15281        // Fail-before-pass-after pin: every pre-gate codebase accepted
15282        // `(:caracteristicas (""))` cleanly (the `Vec<String>` field
15283        // imposed no per-entry shape contract), the dep validated, and
15284        // the empty feature would have reached the future caixa-resolver
15285        // lacre pipeline as a no-op feature enable — silently dropping
15286        // the author's intent far from the source `caixa.lisp`. The new
15287        // gate surfaces the structural defect at the typed-validate
15288        // surface with a self-locating diagnostic naming the offending
15289        // dep's `:nome`.
15290        let d = dep_with_features(&[""]);
15291        assert!(
15292            matches!(d.validate().unwrap_err(), DepError::CaracteristicaEmpty { ref nome } if nome == "caixa-teia"),
15293            "expected CaracteristicaEmpty, got {:?}",
15294            d.validate(),
15295        );
15296    }
15297
15298    #[test]
15299    fn validate_rejects_duplicate_caracteristica() {
15300        // Fail-before-pass-after pin on the set-not-multiset arm: the
15301        // feature-toggle slot is set-shaped, so `(:caracteristicas
15302        // ("http" "http"))` is a redundant declaration the lacre
15303        // pipeline dedupes silently at resolve time. The diagnostic
15304        // names the offending dep + the colliding feature verbatim so
15305        // the author can grep their caixa.lisp for `:caracteristicas`
15306        // and fix it in one edit. First-collision determinism is
15307        // pinned separately below.
15308        let d = dep_with_features(&["http", "http"]);
15309        assert!(
15310            matches!(
15311                d.validate().unwrap_err(),
15312                DepError::CaracteristicaDuplicate { ref nome, ref caracteristica }
15313                    if nome == "caixa-teia" && caracteristica == "http"
15314            ),
15315            "expected CaracteristicaDuplicate, got {:?}",
15316            d.validate(),
15317        );
15318    }
15319
15320    #[test]
15321    fn validate_accepts_distinct_caracteristicas() {
15322        // The canonical authoring shape — every feature distinct — must
15323        // remain a clean pass (positive control sweep). Covers the
15324        // canonical kebab-case feature names a target caixa typically
15325        // declares.
15326        dep_with_features(&["http", "json", "tls"])
15327            .validate()
15328            .unwrap();
15329    }
15330
15331    #[test]
15332    fn validate_accepts_single_caracteristica() {
15333        // Single-element list is the minimum non-empty shape; passes
15334        // the gate as the identity of the duplicate check (no second
15335        // entry to collide with).
15336        dep_with_features(&["http"]).validate().unwrap();
15337    }
15338
15339    #[test]
15340    fn validate_accepts_empty_caracteristicas_list() {
15341        // The bare-dep authoring shape (`Dep::simple` / `Dep::git`)
15342        // produces `caracteristicas: Vec::new()`; the empty list is
15343        // the gate's empty-set identity and passes vacuously. Pin
15344        // this so a future tightening that requires ≥1 feature
15345        // surfaces here as a test failure rather than a silent
15346        // contract narrowing.
15347        Dep::simple("caixa-teia", "^0.1").validate().unwrap();
15348        assert!(dep_with_features(&[]).validate().is_ok());
15349    }
15350
15351    #[test]
15352    fn validate_caracteristica_empty_fires_before_duplicate() {
15353        // Empty-first cascade: an entry with an empty feature *and*
15354        // duplicate entries surfaces the empty diagnostic first. The
15355        // empty-feature axis is the more-actionable defect since
15356        // `caracteristica: ""` is unambiguous; under duplicate-first
15357        // ordering the diagnostic could report the empty string from
15358        // either of two empty entries with no way to distinguish.
15359        // Mirrors the peer empty-before-duplicate ordering
15360        // discipline every per-entry shape + duplicate gate establishes
15361        // (`SupervisorSpec::validate`'s `EmptyChildName` arm before
15362        // `DuplicateChildCaixa`, `validate_membros`'s
15363        // `MembroCaixaEmpty` arm before `MembroDuplicate`).
15364        let d = dep_with_features(&["", "http", "http"]);
15365        assert!(matches!(
15366            d.validate().unwrap_err(),
15367            DepError::CaracteristicaEmpty { .. }
15368        ));
15369    }
15370
15371    #[test]
15372    fn validate_caracteristica_duplicate_first_collision_determinism() {
15373        // Three matching entries: the second occurrence surfaces the
15374        // diagnostic (the second is the first *collision* — the first
15375        // entry is the establishing one, not a duplicate). Mirrors
15376        // every peer first-collision posture
15377        // (`SupervisorError::DuplicateChildCaixa` reports the second
15378        // collision, `AplicacaoError::MembroDuplicate` reports the
15379        // second, `DepError::DuplicateNome` reports the second).
15380        // Pinning this so a future shortcut that flips to last-
15381        // collision (or non-deterministic) surfaces here.
15382        let d = dep_with_features(&["http", "http", "http"]);
15383        assert!(matches!(
15384            d.validate().unwrap_err(),
15385            DepError::CaracteristicaDuplicate { ref caracteristica, .. } if caracteristica == "http"
15386        ));
15387    }
15388
15389    #[test]
15390    fn validate_per_entry_shape_fires_before_caracteristicas() {
15391        // Per-entry shape precedence: a dep with a malformed `:nome`
15392        // (uppercase) AND duplicate `:caracteristicas` surfaces the
15393        // narrower `NomeInvalid` diagnostic first, not the set-gate
15394        // diagnostic. The `:nome` is the self-locating axis (every
15395        // diagnostic from the caracteristicas gate quotes the
15396        // offending dep's `:nome` to anchor the grep target —
15397        // surfacing the malformed name first keeps that anchor
15398        // valid). Same precedence shape every peer per-entry-shape
15399        // arm establishes against its peer set-gate
15400        // (`validate_deps_per_entry_validate_fires_before_duplicate_in_deps`
15401        // on the cross-entry `:nome` axis).
15402        let d = Dep {
15403            nome: "Caixa-Teia".into(), // uppercase — DNS-1123 violation
15404            versao: "^0.1".into(),
15405            fonte: None,
15406            opcional: false,
15407            caracteristicas: vec!["http".into(), "http".into()],
15408        };
15409        assert!(matches!(
15410            d.validate().unwrap_err(),
15411            DepError::NomeInvalid { .. }
15412        ));
15413    }
15414
15415    // ── per-entry :caracteristicas value-shape gate ──────────────────
15416    //
15417    // Until this gate landed `:caracteristicas` only refused the empty
15418    // string and cross-entry duplicates: a non-empty distinct but
15419    // structurally invalid feature name silently passed validate and the
15420    // failure surfaced at `cargo metadata` time as Cargo's
15421    // `restricted_names::validate_feature_name` parser rejection, far from
15422    // the source `caixa.lisp` with no field naming which `:deps` entry's
15423    // `:caracteristicas` carried the typo. The lifted predicate makes the
15424    // Cargo-feature-name-grammar intersection-floor a substrate-level
15425    // invariant at validate time. Same trajectory as the eight peer
15426    // value-shape predicates each typed surface downstream of a structured
15427    // grammar already follows.
15428
15429    #[test]
15430    fn validate_rejects_caracteristica_with_leading_plus() {
15431        // Fail-before-pass-after pin on the canonical Cargo
15432        // `+<feature>` activation-form-in-feature-name-slot footgun.
15433        // Cargo's `[dependencies.<dep>.features]` list grammar accepts
15434        // `+optional-feature` as an enablement of a previously-disabled
15435        // feature; pasting that activation form into `:caracteristicas`
15436        // (which names the feature itself) silently passed pre-gate and
15437        // failed at `cargo metadata` parse time.
15438        let d = dep_with_features(&["+http"]);
15439        let err = d.validate().unwrap_err();
15440        assert!(
15441            matches!(
15442                err,
15443                DepError::CaracteristicaInvalid { ref nome, ref caracteristica, .. }
15444                    if nome == "caixa-teia" && caracteristica == "+http"
15445            ),
15446            "expected CaracteristicaInvalid, got {err:?}"
15447        );
15448    }
15449
15450    #[test]
15451    fn validate_rejects_caracteristica_with_leading_hyphen() {
15452        // Fail-before-pass-after pin on the leading-hyphen footgun. `-`
15453        // is a legitimate continuation character (kebab-case feature
15454        // names like `runtime-tokio` pass) but Cargo rejects it at the
15455        // start; the structural defect — and its CLI-argument-injection
15456        // adjacency at any downstream Cargo subprocess invocation — is
15457        // closed at validate time, not at `cargo metadata` time.
15458        let d = dep_with_features(&["-json"]);
15459        let err = d.validate().unwrap_err();
15460        assert!(
15461            matches!(
15462                err,
15463                DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "-json"
15464            ),
15465            "expected CaracteristicaInvalid, got {err:?}"
15466        );
15467    }
15468
15469    #[test]
15470    fn validate_rejects_caracteristica_with_leading_dot() {
15471        // Fail-before-pass-after pin on the leading-dot footgun. `.` is
15472        // a legitimate continuation character (version-suffix shapes
15473        // like `feat.v2` pass) but the leading-dot form is the
15474        // canonical dotted-version-suffix-as-feature-name confusion.
15475        let d = dep_with_features(&[".feat"]);
15476        let err = d.validate().unwrap_err();
15477        assert!(matches!(
15478            err,
15479            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == ".feat"
15480        ));
15481    }
15482
15483    #[test]
15484    fn validate_rejects_caracteristica_with_whitespace() {
15485        // Fail-before-pass-after pin on the embedded-whitespace footgun:
15486        // a feature name with a space inside is structurally a multi-
15487        // token blob (the canonical paste-from-doc footgun, or an
15488        // accidental `"http server"` where the author meant
15489        // `"http-server"`).
15490        let d = dep_with_features(&["http feature"]);
15491        let err = d.validate().unwrap_err();
15492        assert!(matches!(
15493            err,
15494            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http feature"
15495        ));
15496    }
15497
15498    #[test]
15499    fn validate_rejects_caracteristica_with_comma() {
15500        // Fail-before-pass-after pin on the embedded-comma footgun:
15501        // the list-separator-belongs-to-the-list-grammar
15502        // miscomprehension where the author writes
15503        // `:caracteristicas ("http,json")` intending two features but
15504        // the `Vec<String>` field consumes the bare token as one entry.
15505        let d = dep_with_features(&["http,json"]);
15506        let err = d.validate().unwrap_err();
15507        assert!(matches!(
15508            err,
15509            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http,json"
15510        ));
15511    }
15512
15513    #[test]
15514    fn validate_rejects_caracteristica_with_slash() {
15515        // Fail-before-pass-after pin on the embedded-slash footgun:
15516        // Cargo's `dep/feat` namespaced-dep syntax applies inside
15517        // `[dependencies.<dep>.features]` list entries that already
15518        // name the parent dep (so the syntax says "enable feature
15519        // `feat` on a transitive dep `dep`"); `:caracteristicas` is
15520        // per-dep already (a sibling slot on the `Dep` itself), so the
15521        // segment separator within an entry must be `-`, `_`, `+`,
15522        // or `.`. The diagnostic remediation points at the canonical
15523        // Cargo namespaced-dep discipline.
15524        let d = dep_with_features(&["http/json"]);
15525        let err = d.validate().unwrap_err();
15526        assert!(matches!(
15527            err,
15528            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http/json"
15529        ));
15530    }
15531
15532    #[test]
15533    fn validate_rejects_caracteristica_with_non_ascii() {
15534        // Fail-before-pass-after pin on the un-percent-encoded non-ASCII
15535        // byte footgun: NFC-vs-NFD normalization across filesystems
15536        // silently rewrites the feature-key, breaking the lacre's
15537        // content-addressing invariant. Pinned at a canonical
15538        // smart-quote-paste shape (`café`) where the raw `é` byte is the
15539        // documented APFS round-trip break.
15540        let d = dep_with_features(&["caf\u{e9}"]);
15541        let err = d.validate().unwrap_err();
15542        assert!(matches!(
15543            err,
15544            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "caf\u{e9}"
15545        ));
15546    }
15547
15548    #[test]
15549    fn validate_rejects_caracteristica_with_control_character() {
15550        // Fail-before-pass-after pin on the embedded-control-character
15551        // footgun: a CR/LF or any 0x00..0x1F / 0x7F byte landing in a
15552        // feature name is the canonical paste-from-multiline-doc
15553        // footgun the predicate's reason wording specifically calls out.
15554        let d = dep_with_features(&["http\njson"]);
15555        let err = d.validate().unwrap_err();
15556        assert!(matches!(err, DepError::CaracteristicaInvalid { .. }));
15557    }
15558
15559    #[test]
15560    fn validate_accepts_canonical_caracteristicas_shapes() {
15561        // Positive control sweep: every canonical Cargo feature name
15562        // shape the pleme-io ecosystem uses must still pass. Mirrors
15563        // the substrate-side `cargo_feature_name_accepts_canonical_forms`
15564        // sweep — drift between either landing site and the predicate's
15565        // accepted set is a build error visible at this pair of tests,
15566        // not a per-renderer "this passed validate but failed at
15567        // cargo metadata time" surprise on the next acceptance.
15568        for s in [
15569            "http",
15570            "json",
15571            "derive",
15572            "serde_json",
15573            "runtime-tokio",
15574            "tokio.full",
15575            "v0.1",
15576            "http+json",
15577            "_internal",
15578            "__private",
15579            "default",
15580            "rt-multi-thread",
15581            "feat.v2",
15582        ] {
15583            let d = dep_with_features(&[s]);
15584            d.validate().unwrap_or_else(|e| {
15585                panic!("canonical Cargo feature name {s:?} must pass validate: {e:?}")
15586            });
15587        }
15588    }
15589
15590    #[test]
15591    fn validate_caracteristica_empty_fires_before_invalid() {
15592        // Cascade precedence pin: an entry list with both an empty
15593        // feature AND an invalid-shape feature surfaces the
15594        // `CaracteristicaEmpty` arm first (the empty value carries no
15595        // self-locating data — `caracteristica: ""` is the diagnostic
15596        // with no way to anchor a grep target — so closing the empty
15597        // axis first preserves the per-entry-shape diagnostic's
15598        // self-locating discipline). Same empty-first cascade every
15599        // peer per-entry shape gate establishes
15600        // (`SupervisorSpec::validate`'s `EmptyChildName` before
15601        // `ChildCaixaInvalid`, `validate_membros`'s `MembroCaixaEmpty`
15602        // before `MembroCaixaInvalid`).
15603        let d = dep_with_features(&["", "+http"]);
15604        assert!(matches!(
15605            d.validate().unwrap_err(),
15606            DepError::CaracteristicaEmpty { .. }
15607        ));
15608    }
15609
15610    #[test]
15611    fn validate_caracteristica_invalid_fires_before_duplicate() {
15612        // Per-entry-shape precedence pin: an entry list with the same
15613        // invalid feature shape declared twice surfaces the
15614        // `CaracteristicaInvalid` diagnostic on the first entry, not
15615        // the `CaracteristicaDuplicate` on the second collision. The
15616        // per-entry shape gate fires before the cross-entry set gate
15617        // — same precedence shape every peer two-arm-plus-set gate
15618        // establishes (`SupervisorSpec::validate`'s
15619        // `ChildCaixaInvalid` before `DuplicateChildCaixa`,
15620        // `validate_membros`'s `MembroCaixaInvalid` before
15621        // `MembroDuplicate`, `Dep::validate`'s `NomeInvalid` before
15622        // cross-list `DuplicateNome`).
15623        let d = dep_with_features(&["+http", "+http"]);
15624        assert!(matches!(
15625            d.validate().unwrap_err(),
15626            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "+http"
15627        ));
15628    }
15629
15630    #[test]
15631    fn validate_rejects_caracteristica_at_65_byte_boundary() {
15632        // Boundary pin on the 64-byte cap — both the boundary-accepting
15633        // case and the boundary-exceeding case in one place, so a
15634        // future cap shift surfaces both arms simultaneously, mirroring
15635        // the peer `cargo_feature_name_rejects_at_65_byte_boundary`
15636        // predicate-level pin at the dep-axis landing site.
15637        let max_ok = "a".repeat(64);
15638        dep_with_features(&[&max_ok])
15639            .validate()
15640            .unwrap_or_else(|e| panic!("64-byte feature name must pass: {e:?}"));
15641        let too_long = "a".repeat(65);
15642        let d = dep_with_features(&[&too_long]);
15643        assert!(matches!(
15644            d.validate().unwrap_err(),
15645            DepError::CaracteristicaInvalid { .. }
15646        ));
15647    }
15648
15649    // ── self-dep cross-slot gate ─────────────────────────────────────
15650
15651    #[test]
15652    fn validate_no_self_dep_rejects_self_in_deps() {
15653        // A caixa whose `:deps` lists its own `:nome` is a one-node
15654        // cycle in the lacre closure's dep-graph traversal — rejected,
15655        // naming the parent and the offending list tag.
15656        let deps = vec![
15657            Dep::simple("caixa-teia", "^0.1"),
15658            Dep::simple("orquestra", "^0.1"),
15659        ];
15660        let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
15661        assert!(
15662            matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS),
15663            "got {err:?}"
15664        );
15665    }
15666
15667    #[test]
15668    fn validate_no_self_dep_rejects_self_in_deps_dev() {
15669        // Same gate on the `:deps-dev` axis — neither dep list is a
15670        // second-class citizen on the self-edge invariant.
15671        let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
15672        let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
15673        assert!(
15674            matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
15675            "got {err:?}"
15676        );
15677    }
15678
15679    #[test]
15680    fn validate_no_self_dep_deps_fires_before_deps_dev() {
15681        // Walk order pin: a caixa that self-references on both lists
15682        // surfaces the `:deps` arm first — the load-bearing axis the
15683        // lacre closure resolves at every build. Mirrors the canonical
15684        // [`Caixa::validate_deps`] cascade (`:deps` → `:deps-dev`).
15685        let deps = vec![Dep::simple("orquestra", "^0.1")];
15686        let deps_dev = vec![Dep::simple("orquestra", "^0.2")];
15687        let err = validate_no_self_dep(&deps, &deps_dev, "orquestra").unwrap_err();
15688        assert!(
15689            matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS),
15690            "got {err:?}"
15691        );
15692    }
15693
15694    #[test]
15695    fn validate_no_self_dep_accepts_distinct_names() {
15696        // Positive control: every dep names a distinct caixa. The
15697        // canonical author surface — peer of
15698        // [`validate_no_self_supervision_accepts_distinct_children`].
15699        let deps = vec![
15700            Dep::simple("caixa-teia", "^0.1"),
15701            Dep::simple("caixa-arch", "^0.1"),
15702        ];
15703        let deps_dev = vec![Dep::simple("caixa-test", "^0.1")];
15704        validate_no_self_dep(&deps, &deps_dev, "orquestra").unwrap();
15705    }
15706
15707    #[test]
15708    fn validate_no_self_dep_empty_lists_pass() {
15709        // A caixa with no declared deps has nothing to self-reference —
15710        // the gate is vacuously satisfied. Peer of
15711        // [`validate_no_self_supervision_empty_children_is_ok`].
15712        validate_no_self_dep(&[], &[], "orquestra").unwrap();
15713    }
15714
15715    #[test]
15716    fn validate_no_self_dep_diagnostic_carries_offending_list_and_nome() {
15717        // Diagnostic-shape pin (peer with
15718        // [`validate_no_self_supervision`]'s diagnostic): the error's
15719        // Display surfaces both the offending list tag and the
15720        // parent's `:nome` verbatim, so the author can grep their
15721        // caixa.lisp for the offending block in one edit. Names
15722        // `:bibliotecas` / `:exe` / `:servicos` as the corrective
15723        // surface — every legitimate "I want to use code from this
15724        // caixa" intent routes through one of those three slots.
15725        let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
15726        let rendered = validate_no_self_dep(&[], &deps_dev, "orquestra")
15727            .unwrap_err()
15728            .to_string();
15729        assert!(
15730            rendered.contains(crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
15731            "diagnostic must name the offending list tag: {rendered}",
15732        );
15733        assert!(
15734            rendered.contains("orquestra"),
15735            "diagnostic must quote the parent caixa name: {rendered}",
15736        );
15737        assert!(
15738            rendered.contains(":bibliotecas"),
15739            "diagnostic must point at the corrective code-surface slot: {rendered}",
15740        );
15741    }
15742
15743    #[test]
15744    fn validate_no_self_dep_accepts_coincidental_substring_match() {
15745        // Identity is exact-string equality, not substring — a dep
15746        // named `"orquestra-helper"` is a distinct caixa even when the
15747        // parent is `"orquestra"`. Pin the exact-match discipline so a
15748        // future relaxation that uses `contains` surfaces here, peer
15749        // with the supervision-tree and Aplicacao-membership gates
15750        // which all use exact-string equality on the typed identity.
15751        let deps = vec![Dep::simple("orquestra-helper", "^0.1")];
15752        validate_no_self_dep(&deps, &[], "orquestra").unwrap();
15753    }
15754
15755    // ── drift-detection: DEP_AUTHOR_KEY_{DEPS,DEPS_DEV} pin ─────────────
15756
15757    #[test]
15758    fn dep_author_key_consts_pin_canonical_kebab_case_labels() {
15759        // Scalar-value pin: the two author-facing kebab-case labels the
15760        // `(defcaixa … :deps ((…)) :deps-dev ((…)))` surface admits on
15761        // the two-list dep-graph slot axis, one arm per typed slot.
15762        // Mirrors the peer scalar-value pin the sibling
15763        // [`crate::M2_AUTHOR_KEY_LIMITS`] /
15764        // [`crate::M2_AUTHOR_KEY_BEHAVIOR`] /
15765        // [`crate::M2_AUTHOR_KEY_UPGRADE_FROM`] (f49c8b0) M2 top-level
15766        // author-labels, [`crate::M3_AUTHOR_KEY_MEMBROS`] etc.
15767        // (882f498) M3 top-level author-labels, and
15768        // [`crate::SUPERVISOR_AUTHOR_KEY_ESTRATEGIA`] etc. (be40492)
15769        // Supervisor top-level author-labels carry, so every kind-scoped
15770        // typed-slot-family axis routes through one canonical per-arm
15771        // declaration.
15772        //
15773        // A future rebrand (`:deps` → `:dependencies` matching Cargo's
15774        // verbatim key, `:deps-dev` → `:dev-dependencies` matching the
15775        // same, `:deps` / `:deps-dev` → `:runtime-deps` / `:dev-deps`
15776        // for symmetry) lands as an edit to exactly one const, and
15777        // every consumer that reaches for the label picks it up at
15778        // build time rather than at runtime as a downstream mismatch on
15779        // a `DepError::DuplicateNome { list: … }` diagnostic far from
15780        // the rename's commit.
15781        assert_eq!(crate::render::DEP_AUTHOR_KEY_DEPS, ":deps");
15782        assert_eq!(crate::render::DEP_AUTHOR_KEY_DEPS_DEV, ":deps-dev");
15783    }
15784
15785    #[test]
15786    fn dep_author_key_consts_are_pairwise_distinct() {
15787        // Distinct-labels pin: the two `:deps` / `:deps-dev` labels
15788        // must not collapse onto one byte-string. A future copy-paste
15789        // slip that renamed both consts to the same value (or a rebrand
15790        // that dropped the `-dev` suffix from one but not the other)
15791        // would leave every `DepError::DuplicateNome { list: … }`
15792        // diagnostic naming an unattributable list — the linter would
15793        // route the author to the wrong caixa.lisp block, or the
15794        // cross-list precedence gate
15795        // (`validate_deps_duplicate_in_deps_fires_before_duplicate_in_deps_dev`)
15796        // would surface a `:deps`-tagged diagnostic on a `:deps-dev`
15797        // duplicate. Peer of the sibling
15798        // `m2_author_key_consts_are_pairwise_distinct`-shape gates the
15799        // other top-level kind-scoped slot-family axes carry
15800        // (implicitly held by their different byte-values today).
15801        assert_ne!(
15802            crate::render::DEP_AUTHOR_KEY_DEPS,
15803            crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
15804            "DEP_AUTHOR_KEY_{{DEPS,DEPS_DEV}} consts must be pairwise-distinct \
15805             so a `DepError::DuplicateNome {{ list: … }}` diagnostic \
15806             self-locates the offending block in the author's caixa.lisp",
15807        );
15808    }
15809
15810    #[test]
15811    fn validate_no_self_dep_routes_through_lifted_dep_author_key_consts() {
15812        // Production-through-const pin: the two per-arm list tags
15813        // [`validate_no_self_dep`] threads onto the `list:` field of a
15814        // returned [`DepError::DepIsSelf`] route through the lifted
15815        // [`crate::DEP_AUTHOR_KEY_DEPS`] /
15816        // [`crate::DEP_AUTHOR_KEY_DEPS_DEV`] consts. A future drift at
15817        // the walker (a rename that reaches one arm but not the const,
15818        // or vice versa) surfaces here at build time rather than at
15819        // runtime as a `feira lint` diagnostic naming the wrong list
15820        // tag. Mirror of the peer
15821        // [`crate::Caixa::declared_servico_slots`] production tagger
15822        // pin (f49c8b0) on the sibling M2 top-level slot axis, extended
15823        // onto the two-list dep-graph gate.
15824        let deps = vec![Dep::simple("orquestra", "^0.1")];
15825        let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
15826        let DepError::DepIsSelf { list, .. } = err else {
15827            panic!("expected DepIsSelf from :deps walk");
15828        };
15829        assert_eq!(list, crate::render::DEP_AUTHOR_KEY_DEPS);
15830
15831        let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
15832        let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
15833        let DepError::DepIsSelf { list, .. } = err else {
15834            panic!("expected DepIsSelf from :deps-dev walk");
15835        };
15836        assert_eq!(list, crate::render::DEP_AUTHOR_KEY_DEPS_DEV);
15837    }
15838
15839    // ── Dep::nome accessor pins ───────────────────────────────────────
15840    //
15841    // Three coherence pins on the lifted `Dep::nome` accessor: byte-equal
15842    // projection over the plain-shorthand / explicit-git / explicit-path
15843    // fixture triad the [`Dep`] docstring lists (so the accessor's
15844    // accept-set is exercised across every author-surface `:fonte`
15845    // shape); by-borrow pointer identity so the projection stays
15846    // zero-copy at every consumer site; and validate-composition through
15847    // the [`validate_no_self_dep`] cross-slot gate reading its
15848    // parent-name equality check through the lifted accessor rather than
15849    // the raw field.
15850
15851    #[test]
15852    fn dep_nome_returns_declared_nome_across_fonte_shapes() {
15853        // Plain-shorthand form (`:fonte None`).
15854        assert_eq!(Dep::simple("caixa-teia", "^0.1").nome(), "caixa-teia");
15855        // Explicit git-source form with a tag pin — same accessor path.
15856        assert_eq!(
15857            Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0").nome(),
15858            "caixa-teia",
15859        );
15860        // Explicit path-source form.
15861        assert_eq!(
15862            Dep {
15863                nome: "caixa-teia".to_string(),
15864                versao: "0.1.0".to_string(),
15865                fonte: Some(DepSource::Path {
15866                    caminho: "../caixa-teia".to_string(),
15867                }),
15868                opcional: false,
15869                caracteristicas: Vec::new(),
15870            }
15871            .nome(),
15872            "caixa-teia",
15873        );
15874        // The empty-string `:nome` sentinel (which [`Dep::validate`]
15875        // refuses through the [`DepError::NomeEmpty`] arm) still round-
15876        // trips as an empty `&str` through the accessor — the accessor is
15877        // a projection, not a gate; the gate is [`Dep::validate`].
15878        assert_eq!(Dep::simple("", "^0.1").nome(), "");
15879    }
15880
15881    #[test]
15882    fn dep_nome_is_by_borrow_pointer_identity() {
15883        // Zero-copy pin: the accessor must borrow into the field's own
15884        // storage, not clone. If a future rewrite regresses to
15885        // `self.nome.clone().leak()` or an owned-buffer shape, the two
15886        // pointers diverge and this pin fails at build time.
15887        let d = Dep::simple("caixa-teia", "^0.1");
15888        assert!(std::ptr::eq(d.nome().as_ptr(), d.nome.as_ptr()));
15889    }
15890
15891    // ── Dep::versao_requirement accessor pins ─────────────────────────
15892    //
15893    // Three coherence pins on the lifted `Dep::versao_requirement`
15894    // accessor: byte-equal projection over the plain-shorthand /
15895    // explicit-git / explicit-path fixture triad the [`Dep`] docstring
15896    // lists plus the empty-sentinel that round-trips as `""` (the accessor
15897    // is a projection, not a gate; the gate is [`Dep::validate`]); by-
15898    // borrow pointer identity so the projection stays zero-copy at every
15899    // consumer site; and validate-composition through the
15900    // [`crate::render::require_valid_versao_requirement`] cascade reading
15901    // its requirement-shape check through the lifted accessor rather than
15902    // the raw field.
15903    #[test]
15904    fn dep_versao_requirement_returns_declared_versao_across_fonte_shapes() {
15905        // Plain-shorthand form (`:fonte None`).
15906        assert_eq!(
15907            Dep::simple("caixa-teia", "^0.1").versao_requirement(),
15908            "^0.1",
15909        );
15910        // Explicit git-source form with a tag pin — same accessor path.
15911        assert_eq!(
15912            Dep::git(
15913                "caixa-teia",
15914                "~0.1.2",
15915                "github:pleme-io/caixa-teia",
15916                "v0.1.0"
15917            )
15918            .versao_requirement(),
15919            "~0.1.2",
15920        );
15921        // Explicit path-source form.
15922        assert_eq!(
15923            Dep {
15924                nome: "caixa-teia".to_string(),
15925                versao: "0.1.0".to_string(),
15926                fonte: Some(DepSource::Path {
15927                    caminho: "../caixa-teia".to_string(),
15928                }),
15929                opcional: false,
15930                caracteristicas: Vec::new(),
15931            }
15932            .versao_requirement(),
15933            "0.1.0",
15934        );
15935        // The wildcard requirement (`"*"`) — the shorthand
15936        // `parse_requirement` accepts as `VersionReq::STAR` — round-trips
15937        // verbatim through the accessor as `"*"`, same byte-shape the
15938        // author wrote.
15939        assert_eq!(Dep::simple("caixa-teia", "*").versao_requirement(), "*");
15940        // The empty-string `:versao` sentinel (which [`Dep::validate`]
15941        // refuses through the [`DepError::VersaoEmpty`] arm) still round-
15942        // trips as an empty `&str` through the accessor — the accessor is
15943        // a projection, not a gate; the gate is [`Dep::validate`]. Peer
15944        // of the sibling [`Dep::nome`] empty-sentinel round-trip pin.
15945        assert_eq!(Dep::simple("caixa-teia", "").versao_requirement(), "");
15946    }
15947
15948    #[test]
15949    fn dep_versao_requirement_is_by_borrow_pointer_identity() {
15950        // Zero-copy pin: the accessor must borrow into the field's own
15951        // storage, not clone. If a future rewrite regresses to
15952        // `self.versao.clone().leak()` or an owned-buffer shape, the two
15953        // pointers diverge and this pin fails at build time. Peer of the
15954        // sibling [`Dep::nome`] pointer-identity pin — same by-borrow
15955        // discipline extended onto the requirement-carrying axis.
15956        let d = Dep::simple("caixa-teia", "^0.1");
15957        assert!(std::ptr::eq(
15958            d.versao_requirement().as_ptr(),
15959            d.versao.as_ptr(),
15960        ));
15961    }
15962
15963    #[test]
15964    fn dep_validate_reads_requirement_through_accessor() {
15965        // Composition pin: the [`Dep::validate`]
15966        // [`crate::render::require_valid_versao_requirement`] cascade
15967        // consumes the requirement string through the lifted accessor —
15968        // both the requirement-gate input and the
15969        // [`DepError::VersaoInvalid`] error-body carrier route through
15970        // `self.versao_requirement()`. A valid requirement passes
15971        // (positive control); a malformed-but-non-empty requirement fails
15972        // and the diagnostic quotes the offending byte-string verbatim
15973        // (same shape the accessor projects), so a future regression that
15974        // detoured the requirement carrier through a different byte-
15975        // string (say the parsed `VersionReq`'s `Display`, or a
15976        // normalized rewrite) would surface here at build time. The
15977        // empty-`:versao` arm fires the [`DepError::VersaoEmpty`] variant
15978        // ahead of the parse arm, pinning the empty-first cascade the
15979        // accessor's `""` sentinel round-trip acknowledges.
15980        Dep::simple("caixa-teia", "^0.1").validate().unwrap();
15981        let err = Dep::simple("caixa-teia", "v0.1").validate().unwrap_err();
15982        assert!(
15983            matches!(
15984                &err,
15985                DepError::VersaoInvalid {
15986                    nome,
15987                    versao,
15988                    ..
15989                } if nome == "caixa-teia" && versao == "v0.1",
15990            ),
15991            "expected VersaoInvalid quoting the accessor-projected requirement, got {err:?}",
15992        );
15993        let err = Dep::simple("caixa-teia", "").validate().unwrap_err();
15994        assert!(
15995            matches!(
15996                &err,
15997                DepError::VersaoEmpty { nome } if nome == "caixa-teia",
15998            ),
15999            "expected VersaoEmpty from the empty-first arm, got {err:?}",
16000        );
16001    }
16002
16003    // ── Dep::fonte accessor pins ──────────────────────────────────────
16004    //
16005    // Three coherence pins on the lifted `Dep::fonte` accessor: byte-
16006    // equal projection over the plain-shorthand (`:fonte None`) /
16007    // explicit-git-tag / explicit-path fixture triad the [`Dep`]
16008    // docstring lists (so the accessor's accept-set is exercised across
16009    // every author-surface `:fonte` shape and both `DepSource` variants);
16010    // pointer identity so the borrowed reference points into the field's
16011    // own `Option<DepSource>` storage (not a cloned side-buffer); and
16012    // validate-composition through the [`Dep::validate`] gate reading
16013    // its per-`:fonte` [`DepSource::validate`] delegation through the
16014    // lifted accessor rather than the raw `if let Some(ref fonte) =
16015    // self.fonte` bracket.
16016
16017    #[test]
16018    fn dep_fonte_returns_declared_source_across_shapes() {
16019        // Plain-shorthand form — `:fonte` omitted, accessor projects
16020        // the `None` partition the resolver-side default-fill treats
16021        // as "resolve through `github:<default-org>/<nome>`".
16022        assert!(Dep::simple("caixa-teia", "^0.1").fonte().is_none());
16023        // Explicit git-source form with a tag pin — same accessor path.
16024        let git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
16025        match git.fonte() {
16026            Some(DepSource::Git {
16027                repo,
16028                tag,
16029                rev,
16030                branch,
16031            }) => {
16032                assert_eq!(repo, "github:pleme-io/caixa-teia");
16033                assert_eq!(tag.as_deref(), Some("v0.1.0"));
16034                assert!(rev.is_none());
16035                assert!(branch.is_none());
16036            }
16037            other => panic!("expected explicit git :fonte, got {other:?}"),
16038        }
16039        // Explicit path-source form — the dev-only local-filesystem
16040        // arm the [`Dep`] docstring's third fixture carries.
16041        let path = Dep {
16042            nome: "caixa-teia".to_string(),
16043            versao: "0.1.0".to_string(),
16044            fonte: Some(DepSource::Path {
16045                caminho: "../caixa-teia".to_string(),
16046            }),
16047            opcional: false,
16048            caracteristicas: Vec::new(),
16049        };
16050        match path.fonte() {
16051            Some(DepSource::Path { caminho }) => {
16052                assert_eq!(caminho, "../caixa-teia");
16053            }
16054            other => panic!("expected explicit path :fonte, got {other:?}"),
16055        }
16056    }
16057
16058    #[test]
16059    fn dep_fonte_is_by_borrow_pointer_identity() {
16060        // Zero-copy pin: the accessor must borrow into the field's own
16061        // `Option<DepSource>` storage, not clone into a side buffer. If
16062        // a future rewrite regresses to `self.fonte.clone()` or an
16063        // owned-buffer shape, the two pointers diverge and this pin
16064        // fails at build time. Peer of the sibling per-`Dep` [`Dep::nome`]
16065        // (eba2cde) / [`Dep::versao_requirement`] (05529b1) pointer-
16066        // identity pins — same by-borrow discipline extended onto the
16067        // outer-`Dep` `Option<&Composite>` composite-reference axis.
16068        let d = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
16069        let accessed = d.fonte().expect("git :fonte present") as *const DepSource;
16070        let raw = d.fonte.as_ref().expect("git :fonte present") as *const DepSource;
16071        assert!(std::ptr::eq(accessed, raw));
16072    }
16073
16074    #[test]
16075    fn dep_validate_reads_fonte_through_accessor() {
16076        // Composition pin: [`Dep::validate`]'s per-`:fonte`
16077        // [`DepSource::validate`] delegation consumes the typed slot
16078        // through the lifted accessor — an author-omitted `:fonte`
16079        // still passes the outer gate (positive control), an explicit
16080        // well-formed git source with exactly one pin passes, and a
16081        // malformed git source (empty `:repo`) surfaces the
16082        // [`DepError::FonteRepoEmpty`] variant quoting the offending
16083        // dep's `:nome` verbatim so a future regression that detoured
16084        // the `:fonte` delegation through a different path (say a
16085        // per-scope override projector) would surface here at build
16086        // time. Peer of the sibling
16087        // `dep_validate_reads_requirement_through_accessor` composition
16088        // pin on the `:versao` axis.
16089        // Positive control 1: no `:fonte` at all.
16090        Dep::simple("caixa-teia", "^0.1").validate().unwrap();
16091        // Positive control 2: well-formed git source.
16092        Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0")
16093            .validate()
16094            .unwrap();
16095        // Negative control: empty `:repo` — the accessor still returns
16096        // `Some(&DepSource::Git { repo: "", … })` and the delegated
16097        // `DepSource::validate` gate raises the typed carrier.
16098        let bad = Dep {
16099            nome: "caixa-teia".to_string(),
16100            versao: "^0.1".to_string(),
16101            fonte: Some(DepSource::Git {
16102                repo: String::new(),
16103                tag: Some("v0.1.0".to_string()),
16104                rev: None,
16105                branch: None,
16106            }),
16107            opcional: false,
16108            caracteristicas: Vec::new(),
16109        };
16110        let err = bad.validate().unwrap_err();
16111        assert!(
16112            matches!(
16113                &err,
16114                DepError::FonteRepoEmpty { nome } if nome == "caixa-teia",
16115            ),
16116            "expected FonteRepoEmpty from the accessor-routed :fonte gate, got {err:?}",
16117        );
16118    }
16119
16120    #[test]
16121    fn validate_no_self_dep_reads_parent_equality_through_accessor() {
16122        // Composition pin: the cross-slot [`validate_no_self_dep`] gate
16123        // rejects a `:deps` entry whose `:nome` equals the parent caixa's
16124        // own `:nome` through the lifted accessor rather than the raw
16125        // field. Fails-before-passes-after: with the accessor lifted the
16126        // gate reads its equality check through `dep.nome() ==
16127        // parent_nome` on both the `:deps` and `:deps-dev` traversals, so
16128        // the diagnostic still names the offending list tag as expected.
16129        let deps = vec![Dep::simple("orquestra", "^0.1")];
16130        let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
16131        assert!(matches!(
16132            err,
16133            DepError::DepIsSelf {
16134                ref nome,
16135                list,
16136            } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS,
16137        ));
16138        let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
16139        let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
16140        assert!(matches!(
16141            err,
16142            DepError::DepIsSelf {
16143                ref nome,
16144                list,
16145            } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
16146        ));
16147        // A non-matching `:nome` passes through the accessor gate.
16148        let deps = vec![Dep::simple("caixa-teia", "^0.1")];
16149        validate_no_self_dep(&deps, &[], "orquestra").unwrap();
16150    }
16151
16152    // ── Dep::caracteristicas accessor pins ────────────────────────────
16153    //
16154    // Three coherence pins on the lifted `Dep::caracteristicas` accessor:
16155    // byte-equal projection over the default-empty / single-entry /
16156    // multi-entry fixture triad (so the accessor's accept-set is
16157    // exercised across every author-surface `:caracteristicas` shape,
16158    // matching the peer sibling family's fixture-triad discipline); by-
16159    // borrow pointer identity so the projection stays zero-copy at every
16160    // consumer site; and validate-composition through the
16161    // [`Dep::validate_caracteristicas`] gate reading its per-entry
16162    // linear walk through the lifted accessor rather than the raw
16163    // `for c in &self.caracteristicas` bracket.
16164
16165    #[test]
16166    fn dep_caracteristicas_returns_declared_features_across_shapes() {
16167        // Default-empty form — the [`Dep::simple`] constructor's
16168        // `Vec::new()` fill; the accessor projects the empty slice
16169        // verbatim (no `None` collapse).
16170        assert!(
16171            Dep::simple("caixa-teia", "^0.1")
16172                .caracteristicas()
16173                .is_empty(),
16174        );
16175        // Single-entry form — the canonical Cargo-shaped one-feature
16176        // enable ([`crate::render::is_cargo_feature_name`] accepts the
16177        // `"http"` byte-string as a valid feature name).
16178        let one = Dep {
16179            nome: "caixa-teia".to_string(),
16180            versao: "^0.1".to_string(),
16181            fonte: None,
16182            opcional: false,
16183            caracteristicas: vec!["http".to_string()],
16184        };
16185        assert_eq!(one.caracteristicas(), &["http".to_string()]);
16186        // Multi-entry form — the substrate's set-shaped multi-feature
16187        // enable, exercising the accessor over a length-two slice with
16188        // no duplicate collapse.
16189        let two = Dep {
16190            nome: "caixa-teia".to_string(),
16191            versao: "^0.1".to_string(),
16192            fonte: None,
16193            opcional: false,
16194            caracteristicas: vec!["http".to_string(), "json".to_string()],
16195        };
16196        assert_eq!(
16197            two.caracteristicas(),
16198            &["http".to_string(), "json".to_string()],
16199        );
16200    }
16201
16202    #[test]
16203    fn dep_caracteristicas_is_by_borrow_pointer_identity() {
16204        // Zero-copy pin: the accessor must borrow into the field's own
16205        // `Vec<String>` storage, not clone into a side buffer. If a
16206        // future rewrite regresses to `self.caracteristicas.clone()` or
16207        // an owned-buffer shape, the two pointers diverge and this pin
16208        // fails at build time. Peer of the sibling per-`Dep`
16209        // [`Dep::nome`] (eba2cde) / [`Dep::versao_requirement`] (05529b1)
16210        // / [`Dep::fonte`] (d65d1bf) pointer-identity pins — same by-
16211        // borrow discipline extended onto the outer-`Dep` `&[String]`
16212        // slice-projection axis.
16213        let d = Dep {
16214            nome: "caixa-teia".to_string(),
16215            versao: "^0.1".to_string(),
16216            fonte: None,
16217            opcional: false,
16218            caracteristicas: vec!["http".to_string(), "json".to_string()],
16219        };
16220        assert!(std::ptr::eq(
16221            d.caracteristicas().as_ptr(),
16222            d.caracteristicas.as_ptr(),
16223        ));
16224    }
16225
16226    #[test]
16227    fn dep_validate_reads_caracteristicas_through_accessor() {
16228        // Composition pin: [`Dep::validate_caracteristicas`]'s per-entry
16229        // linear walk consumes the feature-toggle list through the
16230        // lifted accessor — a well-formed `:caracteristicas` set passes
16231        // (positive control), an empty-string entry surfaces the
16232        // [`DepError::CaracteristicaEmpty`] variant quoting the offending
16233        // `Dep::nome`, and a within-list duplicate surfaces the
16234        // [`DepError::CaracteristicaDuplicate`] variant so a future
16235        // regression that detoured the walk through a different byte-
16236        // string list (say a per-scope override projector) would surface
16237        // here at build time. Peer of the sibling
16238        // `dep_validate_reads_fonte_through_accessor` /
16239        // `dep_validate_reads_requirement_through_accessor` composition
16240        // pins on the `:fonte` / `:versao` axes.
16241        // Positive control: two distinct well-formed feature names pass.
16242        Dep {
16243            nome: "caixa-teia".to_string(),
16244            versao: "^0.1".to_string(),
16245            fonte: None,
16246            opcional: false,
16247            caracteristicas: vec!["http".to_string(), "json".to_string()],
16248        }
16249        .validate()
16250        .unwrap();
16251        // Negative control 1: empty-string feature-name entry — the
16252        // accessor still returns `&[""]` and the walk raises the typed
16253        // empty-first carrier.
16254        let err = Dep {
16255            nome: "caixa-teia".to_string(),
16256            versao: "^0.1".to_string(),
16257            fonte: None,
16258            opcional: false,
16259            caracteristicas: vec![String::new()],
16260        }
16261        .validate()
16262        .unwrap_err();
16263        assert!(
16264            matches!(
16265                &err,
16266                DepError::CaracteristicaEmpty { nome } if nome == "caixa-teia",
16267            ),
16268            "expected CaracteristicaEmpty from the accessor-routed walk, got {err:?}",
16269        );
16270        // Negative control 2: within-list duplicate — the accessor's
16271        // slice view carries both entries, and the walk's dedup arm
16272        // raises the typed duplicate carrier quoting the offending
16273        // feature name verbatim.
16274        let err = Dep {
16275            nome: "caixa-teia".to_string(),
16276            versao: "^0.1".to_string(),
16277            fonte: None,
16278            opcional: false,
16279            caracteristicas: vec!["http".to_string(), "http".to_string()],
16280        }
16281        .validate()
16282        .unwrap_err();
16283        assert!(
16284            matches!(
16285                &err,
16286                DepError::CaracteristicaDuplicate {
16287                    nome,
16288                    caracteristica,
16289                } if nome == "caixa-teia" && caracteristica == "http",
16290            ),
16291            "expected CaracteristicaDuplicate from the accessor-routed dedup, got {err:?}",
16292        );
16293    }
16294
16295    // ── Dep::opcional accessor pins ───────────────────────────────────
16296    //
16297    // Two coherence pins on the lifted `Dep::opcional` accessor: byte-
16298    // equal projection over the default-`false` / explicit-`true`
16299    // fixture pair across the plain-shorthand (`:fonte None`) / explicit-
16300    // git-tag / explicit-path fixture triad the [`Dep`] docstring lists,
16301    // exercising the accessor's accept-set over every author-surface
16302    // `:fonte` shape × every author-surface `:opcional` shape; and by-
16303    // `Copy` idempotency so the projection stays value-return (no
16304    // silent detour to a fresh `&bool` borrow that would introduce a
16305    // lifetime on the return type the plain-`Copy`-scalar axis's `bool`
16306    // shape elides). No composition pin — `:opcional` does not
16307    // participate in [`Dep::validate`] (an opcional dep with any bool
16308    // value is validate-accepted; the missing-source arm is a resolver-
16309    // side runtime dispatch, not a build-time refusal), so the axis
16310    // reduces to the value-shape + `Copy` pin pair the peer
16311    // [`crate::Caixa::max_restarts`] / [`crate::Caixa::estrategia`]
16312    // outer-`Option<Copy>` accessor pins already carry.
16313
16314    #[test]
16315    fn dep_opcional_returns_declared_opcional_across_fonte_shapes() {
16316        // Default-`false` form via the [`Dep::simple`] constructor —
16317        // the accessor projects the `false` bit the default-fill sets.
16318        assert!(!Dep::simple("caixa-teia", "^0.1").opcional());
16319        // Default-`false` form via the [`Dep::git`] constructor — same
16320        // default fill; the accessor projects `false` regardless of the
16321        // `:fonte` arm.
16322        assert!(!Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0").opcional(),);
16323        // Explicit-`true` form × plain-shorthand `:fonte` — the
16324        // canonical author-surface "this dep may be missing" shape.
16325        let plain_true = Dep {
16326            nome: "caixa-teia".to_string(),
16327            versao: "^0.1".to_string(),
16328            fonte: None,
16329            opcional: true,
16330            caracteristicas: Vec::new(),
16331        };
16332        assert!(plain_true.opcional());
16333        // Explicit-`true` form × explicit git-source — the accessor
16334        // projects the bit verbatim regardless of the `:fonte` arm.
16335        let git_true = Dep {
16336            nome: "caixa-teia".to_string(),
16337            versao: "^0.1".to_string(),
16338            fonte: Some(DepSource::Git {
16339                repo: "github:pleme-io/caixa-teia".to_string(),
16340                tag: Some("v0.1.0".to_string()),
16341                rev: None,
16342                branch: None,
16343            }),
16344            opcional: true,
16345            caracteristicas: Vec::new(),
16346        };
16347        assert!(git_true.opcional());
16348        // Explicit-`true` form × explicit path-source — the dev-only
16349        // local-filesystem arm the [`Dep`] docstring's third fixture
16350        // carries.
16351        let path_true = Dep {
16352            nome: "caixa-teia".to_string(),
16353            versao: "0.1.0".to_string(),
16354            fonte: Some(DepSource::Path {
16355                caminho: "../caixa-teia".to_string(),
16356            }),
16357            opcional: true,
16358            caracteristicas: Vec::new(),
16359        };
16360        assert!(path_true.opcional());
16361    }
16362
16363    #[test]
16364    fn dep_opcional_projects_bool_by_copy() {
16365        // The by-`Copy` pin: [`Dep::opcional`] returns `bool` by value
16366        // (`bool: Copy`) — the accessor does not borrow `&self` past
16367        // the call (no lifetime on the return type), and calling the
16368        // accessor twice on the same [`Dep`] must yield discriminant-
16369        // equal values (idempotent, no side effects on `&self`). Peer
16370        // of the sibling outer-`Caixa` `Option<Copy>` by-`Copy`
16371        // `max_restarts_projects_option_by_copy` (eba5211) /
16372        // `estrategia_projects_option_by_copy` (ed04d3c) pins on the
16373        // outer-`Caixa` altitude — extended here to the outer-`Dep`
16374        // altitude's plain-`Copy` `bool` axis. The `Copy` discipline
16375        // replaces the pointer-equality claim the sibling per-`Dep`
16376        // by-borrow pins (`dep_nome_is_by_borrow_pointer_identity`
16377        // eba2cde, `dep_versao_requirement_is_by_borrow_pointer_identity`
16378        // 05529b1, `dep_fonte_is_by_borrow_pointer_identity` d65d1bf,
16379        // `dep_caracteristicas_is_by_borrow_pointer_identity` 9197944)
16380        // carry (a fresh `Copy` of a `Copy` discriminant is definitionally
16381        // the same discriminant, so the axis reduces to discriminant
16382        // equality).
16383        //
16384        // Pins against a future silent detour that returned a fresh
16385        // `&bool` reference (which would type-check but silently
16386        // introduce a borrow of `&self` past the call, collapsing the
16387        // load-bearing "no lifetime on the return type" `Copy`
16388        // projection the plain-`Copy`-scalar axis's `bool` shape
16389        // carries) or a stale-read side effect that flipped the outer
16390        // discriminant on successive calls.
16391        for opcional in [false, true] {
16392            let d = Dep {
16393                nome: "caixa-teia".to_string(),
16394                versao: "^0.1".to_string(),
16395                fonte: None,
16396                opcional,
16397                caracteristicas: Vec::new(),
16398            };
16399            let first = d.opcional();
16400            let second = d.opcional();
16401            assert_eq!(
16402                first, second,
16403                "Dep::opcional must be idempotent — two successive calls \
16404                 on the same &self must return the same bool",
16405            );
16406            assert_eq!(
16407                first, opcional,
16408                "Dep::opcional must return :opcional verbatim by Copy — \
16409                 got {first}, expected {opcional}",
16410            );
16411            assert_eq!(
16412                d.opcional(),
16413                d.opcional,
16414                "Dep::opcional accessor and self.opcional field access \
16415                 must byte-equal — a bit-flip drift would silently split \
16416                 the paired resolver-side drop-vs-error dispatch from \
16417                 the storage-side default-fill the [`Dep::simple`] / \
16418                 [`Dep::git`] constructor pair carries",
16419            );
16420        }
16421    }
16422
16423    // ── DepSource::sole_pin — sole-set git-pin accessor ─────────────────
16424
16425    #[test]
16426    fn sole_pin_returns_none_for_path_source() {
16427        // A path source carries no git-ref, so `sole_pin()` returns
16428        // `None` structurally — the sibling arm every git-fetching
16429        // consumer partitions off before reaching for a git-ref. Pins
16430        // the Path-arm branch of the accessor against a future silent
16431        // detour that treats a `Self::Path` as an unpinned-git source
16432        // and returns the wrong "no pin" signal (e.g. the empty string,
16433        // or a hard-coded `Some("HEAD")` matching the caixa-crd
16434        // path-arm `git_ref` fill).
16435        let s = DepSource::Path {
16436            caminho: "../local-caixa".to_string(),
16437        };
16438        assert_eq!(s.sole_pin(), None);
16439    }
16440
16441    #[test]
16442    fn sole_pin_returns_none_for_unpinned_git_source() {
16443        // The [`DepSource::default_github`] shorthand shape carries no
16444        // pin — every `tag`/`rev`/`branch` is `None`, and `sole_pin()`
16445        // returns `None`. This is the shape caixa-resolver's `fetch_dep`
16446        // materializes when the author omits `:fonte` entirely, then
16447        // hands to `fetch_git` which raises `ResolveError::MissingPin`
16448        // on the `None` arm — the accessor's return matches the arm
16449        // the resolver's diagnostic keys off.
16450        let s = DepSource::default_github("pleme-io", "caixa-teia");
16451        assert_eq!(s.sole_pin(), None);
16452    }
16453
16454    #[test]
16455    fn sole_pin_returns_rev_when_only_rev_is_set() {
16456        let s = DepSource::Git {
16457            repo: "github:o/x".into(),
16458            tag: None,
16459            rev: Some("deadbeefcafebabe1234567890abcdef12345678".into()),
16460            branch: None,
16461        };
16462        assert_eq!(
16463            s.sole_pin(),
16464            Some("deadbeefcafebabe1234567890abcdef12345678")
16465        );
16466    }
16467
16468    #[test]
16469    fn sole_pin_returns_tag_when_only_tag_is_set() {
16470        let s = DepSource::Git {
16471            repo: "github:o/x".into(),
16472            tag: Some("v0.1.0".into()),
16473            rev: None,
16474            branch: None,
16475        };
16476        assert_eq!(s.sole_pin(), Some("v0.1.0"));
16477    }
16478
16479    #[test]
16480    fn sole_pin_returns_branch_when_only_branch_is_set() {
16481        let s = DepSource::Git {
16482            repo: "github:o/x".into(),
16483            tag: None,
16484            rev: None,
16485            branch: Some("main".into()),
16486        };
16487        assert_eq!(s.sole_pin(), Some("main"));
16488    }
16489
16490    #[test]
16491    fn sole_pin_precedence_rev_beats_tag_and_branch() {
16492        // Precedence: rev > tag > branch. Validate() rejects
16493        // multiple-pin shapes, but the accessor's precedence is defined
16494        // for pre-validate consumers (the resolver's `MissingPin`
16495        // diagnostic path, the caixa-crd round-trip's default `"main"`
16496        // fallback) and as defense-in-depth if the gate is ever
16497        // bypassed. Pins the same precedence caixa-resolver's
16498        // `fetch_git` and caixa-crd's `dep_into_ref` already apply
16499        // inline.
16500        let s = DepSource::Git {
16501            repo: "github:o/x".into(),
16502            tag: Some("v1".into()),
16503            rev: Some("deadbeefcafebabe1234567890abcdef12345678".into()),
16504            branch: Some("main".into()),
16505        };
16506        assert_eq!(
16507            s.sole_pin(),
16508            Some("deadbeefcafebabe1234567890abcdef12345678")
16509        );
16510    }
16511
16512    #[test]
16513    fn sole_pin_precedence_tag_beats_branch_when_no_rev() {
16514        let s = DepSource::Git {
16515            repo: "github:o/x".into(),
16516            tag: Some("v1".into()),
16517            rev: None,
16518            branch: Some("main".into()),
16519        };
16520        assert_eq!(s.sole_pin(), Some("v1"));
16521    }
16522
16523    #[test]
16524    fn sole_pin_byte_equals_inline_rev_or_tag_or_branch_cascade() {
16525        // Fail-before-pass-after byte-parity pin: the substrate accessor
16526        // must return byte-identical to the inline
16527        // `rev.as_deref().or(tag.as_deref()).or(branch.as_deref())`
16528        // cascade both caixa-resolver's `fetch_git` and caixa-crd's
16529        // `dep_into_ref` open-coded pre-lift. Trips at caixa-core build
16530        // time if the accessor's precedence silently drifts from the
16531        // consumer-side cascade — the exact drift this lift converges
16532        // to one substrate primitive to close structurally.
16533        //
16534        // Iterates through the 2^3 = 8 combinations of (tag, rev,
16535        // branch) each-either-`None`-or-`Some`, so every arm of the
16536        // precedence cascade lands under the pin. `validate()` refuses
16537        // the 4 multi-pin combinations, but the accessor's return is
16538        // defined on all 8.
16539        let vals = [Some("R".to_string()), None];
16540        for tag in &vals {
16541            for rev in &vals {
16542                for branch in &vals {
16543                    let s = DepSource::Git {
16544                        repo: "github:o/x".into(),
16545                        tag: tag.clone(),
16546                        rev: rev.clone(),
16547                        branch: branch.clone(),
16548                    };
16549                    // The exact inline cascade the two pre-lift
16550                    // consumer sites hand-rolled, byte-for-byte.
16551                    let expected = rev.as_deref().or(tag.as_deref()).or(branch.as_deref());
16552                    assert_eq!(
16553                        s.sole_pin(),
16554                        expected,
16555                        "sole_pin() must byte-equal \
16556                         rev.or(tag).or(branch) for \
16557                         (tag={tag:?}, rev={rev:?}, branch={branch:?}) — \
16558                         a drift would silently split caixa-resolver's \
16559                         fetch_git checkout target from caixa-crd's \
16560                         dep_into_ref git_ref fill",
16561                    );
16562                }
16563            }
16564        }
16565    }
16566
16567    // Fail-before-pass-after pins on the eleven
16568    // [`fonte_caminho_ctors!`]-generated `DepError::fonte_caminho_*`
16569    // constructors folded from the [`DepSource::validate_caminho`]
16570    // wire-up sites. Each pins the generated ctor's output to the
16571    // pre-lift struct-literal on the same `(&str, &str)` fixture, so
16572    // any wrapper-side lowercase / trim / re-order / silent-field-swap
16573    // regression on the two-field `{ nome: nome.to_string(), caminho:
16574    // caminho.to_string() }` construction surfaces here rather than at
16575    // a downstream diagnostic-shape mismatch. Peer of the sibling
16576    // `empty_child_version_ctor_matches_struct_literal_wrap` /
16577    // `contrato_endpoint_empty_ctor_matches_struct_literal_wrap` /
16578    // `entrada_host_invalid_ctor_matches_struct_literal_wrap` /
16579    // `nome_only_ctor_routes_caixa_through_nome_accessor` equivalence
16580    // pins on the peer `SupervisorError` / `AplicacaoError` /
16581    // `LayoutError` / `LimitsError` / `UpgradeError` envelopes.
16582
16583    #[test]
16584    fn fonte_caminho_absolute_ctor_matches_struct_literal_wrap() {
16585        assert_eq!(
16586            DepError::fonte_caminho_absolute("caixa-teia", "/home/me/work/caixa-teia"),
16587            DepError::FonteCaminhoAbsolute {
16588                nome: "caixa-teia".to_string(),
16589                caminho: "/home/me/work/caixa-teia".to_string(),
16590            },
16591            "generated fonte_caminho_absolute ctor must produce byte-equal \
16592             DepError to the open-coded struct-literal wrap on the same \
16593             (&str, &str) fixture",
16594        );
16595    }
16596
16597    #[test]
16598    fn fonte_caminho_tilde_expansion_ctor_matches_struct_literal_wrap() {
16599        assert_eq!(
16600            DepError::fonte_caminho_tilde_expansion("caixa-teia", "~/work/caixa-teia"),
16601            DepError::FonteCaminhoTildeExpansion {
16602                nome: "caixa-teia".to_string(),
16603                caminho: "~/work/caixa-teia".to_string(),
16604            },
16605        );
16606    }
16607
16608    #[test]
16609    fn fonte_caminho_var_expansion_ctor_matches_struct_literal_wrap() {
16610        assert_eq!(
16611            DepError::fonte_caminho_var_expansion("caixa-teia", "$HOME/work/caixa-teia"),
16612            DepError::FonteCaminhoVarExpansion {
16613                nome: "caixa-teia".to_string(),
16614                caminho: "$HOME/work/caixa-teia".to_string(),
16615            },
16616        );
16617    }
16618
16619    #[test]
16620    fn fonte_caminho_leading_whitespace_ctor_matches_struct_literal_wrap() {
16621        assert_eq!(
16622            DepError::fonte_caminho_leading_whitespace("caixa-teia", " ../caixa-teia"),
16623            DepError::FonteCaminhoLeadingWhitespace {
16624                nome: "caixa-teia".to_string(),
16625                caminho: " ../caixa-teia".to_string(),
16626            },
16627        );
16628    }
16629
16630    #[test]
16631    fn fonte_caminho_leading_hyphen_ctor_matches_struct_literal_wrap() {
16632        assert_eq!(
16633            DepError::fonte_caminho_leading_hyphen("caixa-teia", "-rf"),
16634            DepError::FonteCaminhoLeadingHyphen {
16635                nome: "caixa-teia".to_string(),
16636                caminho: "-rf".to_string(),
16637            },
16638        );
16639    }
16640
16641    #[test]
16642    fn fonte_caminho_backslash_ctor_matches_struct_literal_wrap() {
16643        assert_eq!(
16644            DepError::fonte_caminho_backslash("caixa-teia", "..\\caixa-teia"),
16645            DepError::FonteCaminhoBackslash {
16646                nome: "caixa-teia".to_string(),
16647                caminho: "..\\caixa-teia".to_string(),
16648            },
16649        );
16650    }
16651
16652    #[test]
16653    fn fonte_caminho_shell_pipe_ctor_matches_struct_literal_wrap() {
16654        assert_eq!(
16655            DepError::fonte_caminho_shell_pipe("caixa-teia", "../caixa-teia|evil"),
16656            DepError::FonteCaminhoShellPipe {
16657                nome: "caixa-teia".to_string(),
16658                caminho: "../caixa-teia|evil".to_string(),
16659            },
16660        );
16661    }
16662
16663    #[test]
16664    fn fonte_caminho_shell_semicolon_ctor_matches_struct_literal_wrap() {
16665        assert_eq!(
16666            DepError::fonte_caminho_shell_semicolon("caixa-teia", "../caixa-teia;evil"),
16667            DepError::FonteCaminhoShellSemicolon {
16668                nome: "caixa-teia".to_string(),
16669                caminho: "../caixa-teia;evil".to_string(),
16670            },
16671        );
16672    }
16673
16674    #[test]
16675    fn fonte_caminho_shell_background_ctor_matches_struct_literal_wrap() {
16676        assert_eq!(
16677            DepError::fonte_caminho_shell_background("caixa-teia", "../caixa-teia&"),
16678            DepError::FonteCaminhoShellBackground {
16679                nome: "caixa-teia".to_string(),
16680                caminho: "../caixa-teia&".to_string(),
16681            },
16682        );
16683    }
16684
16685    #[test]
16686    fn fonte_caminho_shell_command_substitution_ctor_matches_struct_literal_wrap() {
16687        assert_eq!(
16688            DepError::fonte_caminho_shell_command_substitution(
16689                "caixa-teia",
16690                "../caixa-teia`whoami`",
16691            ),
16692            DepError::FonteCaminhoShellCommandSubstitution {
16693                nome: "caixa-teia".to_string(),
16694                caminho: "../caixa-teia`whoami`".to_string(),
16695            },
16696        );
16697    }
16698
16699    #[test]
16700    fn fonte_caminho_trailing_slash_ctor_matches_struct_literal_wrap() {
16701        assert_eq!(
16702            DepError::fonte_caminho_trailing_slash("caixa-teia", "../caixa-teia/"),
16703            DepError::FonteCaminhoTrailingSlash {
16704                nome: "caixa-teia".to_string(),
16705                caminho: "../caixa-teia/".to_string(),
16706            },
16707        );
16708    }
16709
16710    #[test]
16711    fn fonte_caminho_ctors_route_nome_and_caminho_through_to_string() {
16712        // Cross-axis pin: sweep the two constructor input axes
16713        // (`nome: &str`, `caminho: &str`) through a non-default fixture
16714        // pair against every generated arm in the
16715        // [`fonte_caminho_ctors!`] macro, so any wrapper-side lowercase
16716        // / trim / truncate / re-order on the two-field
16717        // `{ nome, caminho }` construction — or a silent field swap
16718        // between the two axes at codegen time — surfaces here rather
16719        // than at a downstream diagnostic-shape mismatch. Peer of the
16720        // sibling `supervisor_caixa_only_ctors_route_caixa_through_
16721        // to_string` cross-axis routing pin on the peer
16722        // `SupervisorError` envelope, extended here onto the
16723        // `DepError` `{ nome: String, caminho: String }` envelope so
16724        // every substrate-primitive ctor family in caixa-core
16725        // guarantees each `&str`-field construction routes the
16726        // caller's `&str` verbatim through `.to_string()`.
16727        let nome = "sibling-teia";
16728        let caminho = "../workspace/sibling";
16729        let cases: [(DepError, DepError); 11] = [
16730            (
16731                DepError::fonte_caminho_absolute(nome, caminho),
16732                DepError::FonteCaminhoAbsolute {
16733                    nome: nome.to_string(),
16734                    caminho: caminho.to_string(),
16735                },
16736            ),
16737            (
16738                DepError::fonte_caminho_tilde_expansion(nome, caminho),
16739                DepError::FonteCaminhoTildeExpansion {
16740                    nome: nome.to_string(),
16741                    caminho: caminho.to_string(),
16742                },
16743            ),
16744            (
16745                DepError::fonte_caminho_var_expansion(nome, caminho),
16746                DepError::FonteCaminhoVarExpansion {
16747                    nome: nome.to_string(),
16748                    caminho: caminho.to_string(),
16749                },
16750            ),
16751            (
16752                DepError::fonte_caminho_leading_whitespace(nome, caminho),
16753                DepError::FonteCaminhoLeadingWhitespace {
16754                    nome: nome.to_string(),
16755                    caminho: caminho.to_string(),
16756                },
16757            ),
16758            (
16759                DepError::fonte_caminho_leading_hyphen(nome, caminho),
16760                DepError::FonteCaminhoLeadingHyphen {
16761                    nome: nome.to_string(),
16762                    caminho: caminho.to_string(),
16763                },
16764            ),
16765            (
16766                DepError::fonte_caminho_backslash(nome, caminho),
16767                DepError::FonteCaminhoBackslash {
16768                    nome: nome.to_string(),
16769                    caminho: caminho.to_string(),
16770                },
16771            ),
16772            (
16773                DepError::fonte_caminho_shell_pipe(nome, caminho),
16774                DepError::FonteCaminhoShellPipe {
16775                    nome: nome.to_string(),
16776                    caminho: caminho.to_string(),
16777                },
16778            ),
16779            (
16780                DepError::fonte_caminho_shell_semicolon(nome, caminho),
16781                DepError::FonteCaminhoShellSemicolon {
16782                    nome: nome.to_string(),
16783                    caminho: caminho.to_string(),
16784                },
16785            ),
16786            (
16787                DepError::fonte_caminho_shell_background(nome, caminho),
16788                DepError::FonteCaminhoShellBackground {
16789                    nome: nome.to_string(),
16790                    caminho: caminho.to_string(),
16791                },
16792            ),
16793            (
16794                DepError::fonte_caminho_shell_command_substitution(nome, caminho),
16795                DepError::FonteCaminhoShellCommandSubstitution {
16796                    nome: nome.to_string(),
16797                    caminho: caminho.to_string(),
16798                },
16799            ),
16800            (
16801                DepError::fonte_caminho_trailing_slash(nome, caminho),
16802                DepError::FonteCaminhoTrailingSlash {
16803                    nome: nome.to_string(),
16804                    caminho: caminho.to_string(),
16805                },
16806            ),
16807        ];
16808        for (via_ctor, via_struct_literal) in cases {
16809            assert_eq!(
16810                via_ctor, via_struct_literal,
16811                "fonte_caminho_ctors!-generated ctor must route (nome, caminho) \
16812                 through `.to_string()` in declared field order — a field-swap or \
16813                 silent-conversion regression surfaces here rather than at a \
16814                 downstream diagnostic-shape mismatch",
16815            );
16816        }
16817    }
16818
16819    // ── `dep_nome_only_ctors!` — the paired `{ nome: String }` single-slot
16820    //    envelope on `DepError`, sibling of the peer `fonte_caminho_ctors!`
16821    //    (f85f145) on the `{ nome, caminho }` two-slot envelope of the same
16822    //    enum, and of `supervisor_caixa_only_ctors!` (db09650) on the peer
16823    //    `SupervisorError` envelope's `{ caixa: String }` single-slot axis.
16824
16825    #[test]
16826    fn versao_empty_ctor_matches_struct_literal_wrap() {
16827        assert_eq!(
16828            DepError::versao_empty("caixa-teia"),
16829            DepError::VersaoEmpty {
16830                nome: "caixa-teia".to_string(),
16831            },
16832        );
16833    }
16834
16835    #[test]
16836    fn fonte_repo_empty_ctor_matches_struct_literal_wrap() {
16837        assert_eq!(
16838            DepError::fonte_repo_empty("caixa-teia"),
16839            DepError::FonteRepoEmpty {
16840                nome: "caixa-teia".to_string(),
16841            },
16842        );
16843    }
16844
16845    #[test]
16846    fn fonte_pin_missing_ctor_matches_struct_literal_wrap() {
16847        assert_eq!(
16848            DepError::fonte_pin_missing("caixa-teia"),
16849            DepError::FontePinMissing {
16850                nome: "caixa-teia".to_string(),
16851            },
16852        );
16853    }
16854
16855    #[test]
16856    fn fonte_caminho_empty_ctor_matches_struct_literal_wrap() {
16857        assert_eq!(
16858            DepError::fonte_caminho_empty("caixa-teia"),
16859            DepError::FonteCaminhoEmpty {
16860                nome: "caixa-teia".to_string(),
16861            },
16862        );
16863    }
16864
16865    #[test]
16866    fn caracteristica_empty_ctor_matches_struct_literal_wrap() {
16867        assert_eq!(
16868            DepError::caracteristica_empty("caixa-teia"),
16869            DepError::CaracteristicaEmpty {
16870                nome: "caixa-teia".to_string(),
16871            },
16872        );
16873    }
16874
16875    #[test]
16876    fn dep_nome_only_ctors_route_nome_through_to_string() {
16877        // Cross-axis routing pin: sweep the single constructor input
16878        // axis (`nome: &str`) through a non-default fixture against
16879        // every generated arm in the [`dep_nome_only_ctors!`] macro, so
16880        // any wrapper-side lowercase / trim / truncate at codegen time
16881        // — or a silent field re-name away from the canonical `nome`
16882        // axis on any one variant — surfaces here rather than at a
16883        // downstream diagnostic-shape mismatch. Peer of the sibling
16884        // `fonte_caminho_ctors_route_nome_and_caminho_through_
16885        // to_string` cross-axis routing pin on the same envelope's
16886        // two-slot family (f85f145) and of the peer
16887        // `supervisor_caixa_only_ctors_route_caixa_through_to_string`
16888        // pin on the `SupervisorError` single-slot family (db09650).
16889        let nome = "sibling-teia";
16890        let cases: [(DepError, DepError); 5] = [
16891            (
16892                DepError::versao_empty(nome),
16893                DepError::VersaoEmpty {
16894                    nome: nome.to_string(),
16895                },
16896            ),
16897            (
16898                DepError::fonte_repo_empty(nome),
16899                DepError::FonteRepoEmpty {
16900                    nome: nome.to_string(),
16901                },
16902            ),
16903            (
16904                DepError::fonte_pin_missing(nome),
16905                DepError::FontePinMissing {
16906                    nome: nome.to_string(),
16907                },
16908            ),
16909            (
16910                DepError::fonte_caminho_empty(nome),
16911                DepError::FonteCaminhoEmpty {
16912                    nome: nome.to_string(),
16913                },
16914            ),
16915            (
16916                DepError::caracteristica_empty(nome),
16917                DepError::CaracteristicaEmpty {
16918                    nome: nome.to_string(),
16919                },
16920            ),
16921        ];
16922        for (via_ctor, via_struct_literal) in cases {
16923            assert_eq!(
16924                via_ctor, via_struct_literal,
16925                "dep_nome_only_ctors!-generated ctor must route `nome` \
16926                 through `.to_string()` onto the canonical `nome` field \
16927                 — a field-rename or silent-conversion regression surfaces \
16928                 here rather than at a downstream diagnostic-shape mismatch",
16929            );
16930        }
16931    }
16932
16933    // ── `dep_nome_list_ctors!` — the paired `{ nome: String, list:
16934    //    &'static str }` two-slot envelope on `DepError`, strict
16935    //    sibling of the peer `dep_nome_only_ctors!` (792aa92) on the
16936    //    same envelope's `{ nome: String }` one-slot shape and of the
16937    //    peer `supervisor_caixa_only_ctors!` (db09650) on the
16938    //    `SupervisorError` envelope's `{ caixa: String }` one-slot axis.
16939
16940    #[test]
16941    fn duplicate_nome_ctor_matches_struct_literal_wrap() {
16942        assert_eq!(
16943            DepError::duplicate_nome("caixa-teia", crate::render::DEP_AUTHOR_KEY_DEPS),
16944            DepError::DuplicateNome {
16945                nome: "caixa-teia".to_string(),
16946                list: crate::render::DEP_AUTHOR_KEY_DEPS,
16947            },
16948            "generated duplicate_nome ctor must produce byte-equal \
16949             `DepError::DuplicateNome` to the pre-lift struct-literal \
16950             wrap on the same scalar fixtures",
16951        );
16952    }
16953
16954    #[test]
16955    fn dep_is_self_ctor_matches_struct_literal_wrap() {
16956        assert_eq!(
16957            DepError::dep_is_self("orquestra", crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
16958            DepError::DepIsSelf {
16959                nome: "orquestra".to_string(),
16960                list: crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
16961            },
16962            "generated dep_is_self ctor must produce byte-equal \
16963             `DepError::DepIsSelf` to the pre-lift struct-literal \
16964             wrap on the same scalar fixtures",
16965        );
16966    }
16967
16968    #[test]
16969    fn dep_nome_list_ctors_route_nome_and_list_through_uniformly() {
16970        // Cross-axis routing pin: sweep the two constructor input axes
16971        // (`nome: &str`, `list: &'static str`) through non-default
16972        // fixtures against every generated arm in the
16973        // [`dep_nome_list_ctors!`] macro, so any wrapper-side
16974        // lowercase / trim / truncate at codegen time — or a silent
16975        // field re-name away from the canonical `nome` / `list` axes
16976        // on any one variant, or a `list` axis silently rerouted
16977        // through `.to_string()` instead of passed as `&'static str`
16978        // verbatim — surfaces here rather than at a downstream
16979        // diagnostic-shape mismatch. Peer of the sibling
16980        // `dep_nome_only_ctors_route_nome_through_to_string` pin
16981        // (792aa92) on the same envelope's one-slot family, and of the
16982        // peer
16983        // `supervisor_child_reason_ctors_route_reason_through_into_uniformly`
16984        // pin (d2ef2ec) on the sibling `SupervisorError` envelope's
16985        // two-slot `{ caixa: String, reason: String }` shape.
16986        let nome = "sibling-teia";
16987        let cases: [(DepError, DepError); 4] = [
16988            (
16989                DepError::duplicate_nome(nome, crate::render::DEP_AUTHOR_KEY_DEPS),
16990                DepError::DuplicateNome {
16991                    nome: nome.to_string(),
16992                    list: crate::render::DEP_AUTHOR_KEY_DEPS,
16993                },
16994            ),
16995            (
16996                DepError::duplicate_nome(nome, crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
16997                DepError::DuplicateNome {
16998                    nome: nome.to_string(),
16999                    list: crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
17000                },
17001            ),
17002            (
17003                DepError::dep_is_self(nome, crate::render::DEP_AUTHOR_KEY_DEPS),
17004                DepError::DepIsSelf {
17005                    nome: nome.to_string(),
17006                    list: crate::render::DEP_AUTHOR_KEY_DEPS,
17007                },
17008            ),
17009            (
17010                DepError::dep_is_self(nome, crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
17011                DepError::DepIsSelf {
17012                    nome: nome.to_string(),
17013                    list: crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
17014                },
17015            ),
17016        ];
17017        for (via_ctor, via_struct_literal) in cases {
17018            assert_eq!(
17019                via_ctor, via_struct_literal,
17020                "dep_nome_list_ctors!-generated ctor must route `nome` \
17021                 through `.to_string()` onto the canonical `nome` field \
17022                 and pass `list` verbatim onto the canonical `&'static str` \
17023                 `list` field — a field-rename, silent-conversion, or \
17024                 axis-swap regression surfaces here rather than at a \
17025                 downstream diagnostic-shape mismatch",
17026            );
17027        }
17028    }
17029
17030    // ── `fonte_pin_shape` — the paired `{ nome: String, pin: String,
17031    //    value: String, reason: String }` four-slot envelope on
17032    //    `DepError`, sibling of the peer `dep_nome_only_ctors!` (792aa92),
17033    //    `dep_nome_list_ctors!` (6f5e0cd), `fonte_caminho_ctors!` (f85f145),
17034    //    and `fonte_caminho_byte_ctors!` (0e35793) folds on the same
17035    //    envelope, and of the peer `contrato_pair_value_reason_ctors!`
17036    //    (14e13f1) four-slot fold on the sibling `AplicacaoError`
17037    //    envelope. Single-variant lift closing the last open-coded ctor
17038    //    site on the `:fonte (:tipo git …)` value-shape trajectory.
17039
17040    #[test]
17041    fn fonte_pin_shape_ctor_matches_struct_literal_wrap() {
17042        // Pre-lift equivalence pin on the [`DepError::fonte_pin_shape`]
17043        // ctor: sweep both wire-up-shape arms (the refname-pin arm
17044        // routing `":tag"` / `":branch"` value through
17045        // [`crate::render::is_git_ref_name`], and the hex-OID-pin arm
17046        // routing `":rev"` through [`crate::render::is_git_oid`]) and
17047        // assert byte-equal `PartialEq` against the pre-lift
17048        // struct-literal, so any wrapper-side field-rename /
17049        // silent-conversion regression surfaces here rather than at a
17050        // downstream diagnostic-shape mismatch. Peer of the sibling
17051        // per-envelope byte-equal ctor pins
17052        // ([`fonte_pin_missing_ctor_matches_struct_literal_wrap`],
17053        // [`duplicate_nome_ctor_matches_struct_literal_wrap`],
17054        // [`dep_is_self_ctor_matches_struct_literal_wrap`]).
17055        assert_eq!(
17056            DepError::fonte_pin_shape(
17057                "caixa-teia",
17058                ":tag",
17059                "v0.1.0 ",
17060                "trailing whitespace".to_string(),
17061            ),
17062            DepError::FontePinShape {
17063                nome: "caixa-teia".to_string(),
17064                pin: ":tag".to_string(),
17065                value: "v0.1.0 ".to_string(),
17066                reason: "trailing whitespace".to_string(),
17067            },
17068            "fonte_pin_shape ctor must produce byte-equal \
17069             `DepError::FontePinShape` to the pre-lift struct-literal \
17070             wrap on a refname-pin (`:tag` / `:branch`) fixture",
17071        );
17072        assert_eq!(
17073            DepError::fonte_pin_shape(
17074                "caixa-teia",
17075                ":rev",
17076                "DEADBEEF",
17077                "abbreviated OID rejected".to_string(),
17078            ),
17079            DepError::FontePinShape {
17080                nome: "caixa-teia".to_string(),
17081                pin: ":rev".to_string(),
17082                value: "DEADBEEF".to_string(),
17083                reason: "abbreviated OID rejected".to_string(),
17084            },
17085            "fonte_pin_shape ctor must produce byte-equal \
17086             `DepError::FontePinShape` to the pre-lift struct-literal \
17087             wrap on a hex-OID-pin (`:rev`) fixture",
17088        );
17089    }
17090
17091    #[test]
17092    fn fonte_pin_shape_ctor_routes_all_four_axes_through_to_string() {
17093        // Cross-axis routing pin: sweep every one of the four
17094        // constructor input axes (`nome: &str`, `pin: &str`,
17095        // `value: &str`, `reason: String`) through non-default
17096        // fixtures against the [`DepError::fonte_pin_shape`] ctor, so
17097        // any wrapper-side lowercase / trim / truncate at codegen time
17098        // — or a silent field re-name / axis-swap on any one of the
17099        // four fields, or a `reason` axis silently routed through
17100        // `.to_string()` instead of forwarded owned — surfaces here
17101        // rather than at a downstream diagnostic-shape mismatch. Peer
17102        // of the sibling
17103        // `dep_nome_only_ctors_route_nome_through_to_string` pin
17104        // (792aa92) and
17105        // `dep_nome_list_ctors_route_nome_and_list_through_uniformly`
17106        // pin (6f5e0cd) on the same envelope's one- and two-slot
17107        // families. Distinct-per-axis fixtures rule out any two-axis
17108        // swap (`nome` ↔ `pin`, `pin` ↔ `value`, `value` ↔ `reason`,
17109        // etc.) that would still pass a same-fixture-per-axis pin.
17110        let nome = "sibling-teia";
17111        let pin = ":branch";
17112        let value = "feature/bar";
17113        let reason = "embedded space".to_string();
17114        let via_ctor = DepError::fonte_pin_shape(nome, pin, value, reason.clone());
17115        let via_struct_literal = DepError::FontePinShape {
17116            nome: nome.to_string(),
17117            pin: pin.to_string(),
17118            value: value.to_string(),
17119            reason: reason.clone(),
17120        };
17121        assert_eq!(
17122            via_ctor, via_struct_literal,
17123            "fonte_pin_shape ctor must route `nome` / `pin` / `value` \
17124             through `.to_string()` onto their canonical fields and \
17125             forward `reason` owned onto the canonical `reason` field \
17126             — a field-rename, silent-conversion, or axis-swap \
17127             regression surfaces here rather than at a downstream \
17128             diagnostic-shape mismatch",
17129        );
17130        let DepError::FontePinShape {
17131            nome: n,
17132            pin: p,
17133            value: v,
17134            reason: r,
17135        } = via_ctor
17136        else {
17137            panic!("fonte_pin_shape ctor produced non-FontePinShape variant")
17138        };
17139        assert_eq!(n, nome);
17140        assert_eq!(p, pin);
17141        assert_eq!(v, value);
17142        assert_eq!(r, reason);
17143    }
17144
17145    // ── `fonte_caminho_byte_ctors!` — the paired `{ nome: String,
17146    //    caminho: String, byte: u8 }` three-slot envelope on `DepError`,
17147    //    strict sibling of the peer `fonte_caminho_ctors!` (f85f145) on
17148    //    the same envelope's `{ nome: String, caminho: String }` two-slot
17149    //    shape, and of the peer `dep_nome_only_ctors!` (792aa92) on the
17150    //    same envelope's `{ nome: String }` one-slot shape.
17151
17152    #[test]
17153    fn fonte_caminho_control_char_ctor_matches_struct_literal_wrap() {
17154        assert_eq!(
17155            DepError::fonte_caminho_control_char("caixa-teia", "../caixa-teia\x00foo", 0x00),
17156            DepError::FonteCaminhoControlChar {
17157                nome: "caixa-teia".to_string(),
17158                caminho: "../caixa-teia\x00foo".to_string(),
17159                byte: 0x00,
17160            },
17161        );
17162    }
17163
17164    #[test]
17165    fn fonte_caminho_shell_redirection_ctor_matches_struct_literal_wrap() {
17166        assert_eq!(
17167            DepError::fonte_caminho_shell_redirection("caixa-teia", "../caixa-teia>log", b'>'),
17168            DepError::FonteCaminhoShellRedirection {
17169                nome: "caixa-teia".to_string(),
17170                caminho: "../caixa-teia>log".to_string(),
17171                byte: b'>',
17172            },
17173        );
17174    }
17175
17176    #[test]
17177    #[allow(
17178        clippy::too_many_lines,
17179        reason = "cross-axis routing pin sweeps twelve typed variants, one per \
17180                  byte-classification arm on the {nome,caminho,byte} envelope; \
17181                  the linear per-variant repetition is exactly what the sweep \
17182                  is pinning — a helper macro would hide the shape the fold is \
17183                  keying on"
17184    )]
17185    fn fonte_caminho_byte_ctors_route_nome_caminho_and_byte_through_to_string() {
17186        // Cross-axis routing pin: sweep the three constructor input axes
17187        // (`nome: &str`, `caminho: &str`, `byte: u8`) through a
17188        // non-default fixture triple against every generated arm in the
17189        // [`fonte_caminho_byte_ctors!`] macro, so any wrapper-side
17190        // lowercase / trim / truncate on the two `&str` axes — a silent
17191        // field swap between `nome` and `caminho`, or a silent
17192        // re-classification of the offending byte — surfaces here rather
17193        // than at a downstream diagnostic-shape mismatch. Peer of the
17194        // sibling `fonte_caminho_ctors_route_nome_and_caminho_through_
17195        // to_string` cross-axis routing pin on the same envelope's
17196        // two-slot family (f85f145) and of the sibling
17197        // `dep_nome_only_ctors_route_nome_through_to_string` pin on the
17198        // same envelope's one-slot family (792aa92), extended here onto
17199        // the `{ nome: String, caminho: String, byte: u8 }` three-slot
17200        // envelope so every substrate-primitive ctor family in
17201        // caixa-core's `DepError` envelope guarantees each field routes
17202        // the caller's value verbatim through `.to_string()` (or byte-
17203        // identity for `byte: u8`) in declared field order.
17204        let nome = "sibling-teia";
17205        let caminho = "../workspace/sibling";
17206        let byte = 0x2A_u8;
17207        let cases: [(DepError, DepError); 12] = [
17208            (
17209                DepError::fonte_caminho_control_char(nome, caminho, byte),
17210                DepError::FonteCaminhoControlChar {
17211                    nome: nome.to_string(),
17212                    caminho: caminho.to_string(),
17213                    byte,
17214                },
17215            ),
17216            (
17217                DepError::fonte_caminho_shell_redirection(nome, caminho, byte),
17218                DepError::FonteCaminhoShellRedirection {
17219                    nome: nome.to_string(),
17220                    caminho: caminho.to_string(),
17221                    byte,
17222                },
17223            ),
17224            (
17225                DepError::fonte_caminho_shell_glob(nome, caminho, byte),
17226                DepError::FonteCaminhoShellGlob {
17227                    nome: nome.to_string(),
17228                    caminho: caminho.to_string(),
17229                    byte,
17230                },
17231            ),
17232            (
17233                DepError::fonte_caminho_shell_subshell_grouping(nome, caminho, byte),
17234                DepError::FonteCaminhoShellSubshellGrouping {
17235                    nome: nome.to_string(),
17236                    caminho: caminho.to_string(),
17237                    byte,
17238                },
17239            ),
17240            (
17241                DepError::fonte_caminho_shell_brace_expansion(nome, caminho, byte),
17242                DepError::FonteCaminhoShellBraceExpansion {
17243                    nome: nome.to_string(),
17244                    caminho: caminho.to_string(),
17245                    byte,
17246                },
17247            ),
17248            (
17249                DepError::fonte_caminho_shell_bracket_expansion(nome, caminho, byte),
17250                DepError::FonteCaminhoShellBracketExpansion {
17251                    nome: nome.to_string(),
17252                    caminho: caminho.to_string(),
17253                    byte,
17254                },
17255            ),
17256            (
17257                DepError::fonte_caminho_shell_quote_grouping(nome, caminho, byte),
17258                DepError::FonteCaminhoShellQuoteGrouping {
17259                    nome: nome.to_string(),
17260                    caminho: caminho.to_string(),
17261                    byte,
17262                },
17263            ),
17264            (
17265                DepError::fonte_caminho_shell_comment(nome, caminho, byte),
17266                DepError::FonteCaminhoShellComment {
17267                    nome: nome.to_string(),
17268                    caminho: caminho.to_string(),
17269                    byte,
17270                },
17271            ),
17272            (
17273                DepError::fonte_caminho_url_percent_encoding(nome, caminho, byte),
17274                DepError::FonteCaminhoUrlPercentEncoding {
17275                    nome: nome.to_string(),
17276                    caminho: caminho.to_string(),
17277                    byte,
17278                },
17279            ),
17280            (
17281                DepError::fonte_caminho_shell_variable_expansion(nome, caminho, byte),
17282                DepError::FonteCaminhoShellVariableExpansion {
17283                    nome: nome.to_string(),
17284                    caminho: caminho.to_string(),
17285                    byte,
17286                },
17287            ),
17288            (
17289                DepError::fonte_caminho_shell_history_expansion(nome, caminho, byte),
17290                DepError::FonteCaminhoShellHistoryExpansion {
17291                    nome: nome.to_string(),
17292                    caminho: caminho.to_string(),
17293                    byte,
17294                },
17295            ),
17296            (
17297                DepError::fonte_caminho_shell_history_substitution(nome, caminho, byte),
17298                DepError::FonteCaminhoShellHistorySubstitution {
17299                    nome: nome.to_string(),
17300                    caminho: caminho.to_string(),
17301                    byte,
17302                },
17303            ),
17304        ];
17305        for (via_ctor, via_struct_literal) in cases {
17306            assert_eq!(
17307                via_ctor, via_struct_literal,
17308                "fonte_caminho_byte_ctors!-generated ctor must route \
17309                 (nome, caminho, byte) through `.to_string()` / byte-\
17310                 identity in declared field order — a field-swap or \
17311                 silent-conversion regression surfaces here rather than \
17312                 at a downstream diagnostic-shape mismatch",
17313            );
17314        }
17315    }
17316}
17317
17318#[cfg(test)]
17319mod dep_source_is_variant_tests {
17320    use super::*;
17321
17322    fn all_variants() -> Vec<(DepSource, &'static str)> {
17323        vec![
17324            (
17325                DepSource::Git {
17326                    repo: "github:pleme-io/caixa-teia".into(),
17327                    tag: Some("v0.1.0".into()),
17328                    rev: None,
17329                    branch: None,
17330                },
17331                "Git",
17332            ),
17333            (
17334                DepSource::Path {
17335                    caminho: "../caixa-teia".into(),
17336                },
17337                "Path",
17338            ),
17339        ]
17340    }
17341
17342    fn predicate_row(s: &DepSource) -> [bool; 2] {
17343        [s.is_git(), s.is_path()]
17344    }
17345
17346    // Fail-before-pass-after pin on the [`gen_platform::IsVariant`]
17347    // derive-generated per-arm predicate partition — for every variant
17348    // in `all_variants()`, the observed 2-slot predicate row must equal
17349    // a one-hot row with the `true` at exactly the same index as the
17350    // variant's declaration order. Expected rows are generated live
17351    // from the enumeration rather than transcribed by hand, so a
17352    // copy-paste flip that reroutes one arm through the wrong predicate
17353    // lane trips at the identity-diagonal assertion the way every peer
17354    // sibling [`DepList`] / [`crate::CaixaKind`] / [`crate::CaixaDialeto`]
17355    // / [`crate::supervisor::RestartStrategy`] / [`crate::supervisor::RestartPolicy`]
17356    // / [`crate::upgrade::UpgradeInstruction`] /
17357    // [`crate::aplicacao::PlacementStrategy`] /
17358    // [`crate::aplicacao::RateLimitUnit`] /
17359    // [`crate::aplicacao::WitTarget`] /
17360    // [`crate::render::PathShapeViolation`] partition pin already does.
17361    #[test]
17362    fn dep_source_is_variant_predicates_partition_the_arm_set() {
17363        let variants = all_variants();
17364        for (idx, (variant, name)) in variants.iter().enumerate() {
17365            let observed = predicate_row(variant);
17366            let mut expected = [false; 2];
17367            expected[idx] = true;
17368            assert_eq!(
17369                observed, expected,
17370                "DepSource::{name} at declaration-order slot {idx} must \
17371                 satisfy exactly one is_* predicate (its own); observed \
17372                 row must equal the one-hot expected row — a drift \
17373                 would silently reroute one `:fonte`-arm consumer \
17374                 through the wrong predicate lane"
17375            );
17376        }
17377    }
17378
17379    // Byte-parity pin on the two field-agnostic `matches!` shapes the
17380    // per-arm arm-discriminator predicates replace at any future
17381    // consumer site (a `:fonte`-shape-only lint rule that flags path
17382    // deps outside dev-caixas via `dep.fonte().is_some_and(DepSource::is_path)`,
17383    // a future admission-webhook that rejects `:fonte` shapes outside
17384    // the `is_git()` accept-set, a caixa-lacre indexing pass that
17385    // dispatches on `s.is_git()` without extracting `repo` / `caminho`).
17386    // Refuses a future accidental split between the derived predicate
17387    // and its `matches!` shape — a hand-rolled shadow impl that
17388    // overrides one path, an accidental rebrand that leaves one
17389    // consumer on the raw `matches!` form — on the two load-bearing
17390    // `:fonte`-arm-discriminator axes every downstream substrate
17391    // consumer of the dep-source axis keys off.
17392    #[test]
17393    fn dep_source_is_git_and_is_path_byte_equal_matches_shape() {
17394        for (variant, name) in all_variants() {
17395            let via_matches_git = matches!(variant, DepSource::Git { .. });
17396            let via_predicate_git = variant.is_git();
17397            assert_eq!(
17398                via_predicate_git, via_matches_git,
17399                "DepSource::{name}.is_git() must byte-equal \
17400                 matches!(_, DepSource::Git {{ .. }}) — otherwise a \
17401                 future converged consumer site would silently \
17402                 disagree with its pre-lift shape"
17403            );
17404            let via_matches_path = matches!(variant, DepSource::Path { .. });
17405            let via_predicate_path = variant.is_path();
17406            assert_eq!(
17407                via_predicate_path, via_matches_path,
17408                "DepSource::{name}.is_path() must byte-equal \
17409                 matches!(_, DepSource::Path {{ .. }}) — otherwise a \
17410                 future converged consumer site would silently \
17411                 disagree with its pre-lift shape"
17412            );
17413        }
17414    }
17415
17416    // Cross-pin against every constructor path that materializes a
17417    // [`DepSource`] shape today (the [`DepSource::default_github`]
17418    // resolver-side fallback that materializes an unpinned
17419    // `github:<org>/<nome>` git shorthand, the [`Dep::git`] author-
17420    // surface constructor that materializes a pinned `:tag`-carrying
17421    // `DepSource::Git`, a hand-rolled `DepSource::Path` the dev-mode
17422    // fixture family builds inline). Every constructor's return must
17423    // satisfy the arm-discriminator predicate the constructor's
17424    // variant name matches — a future constructor addition (an
17425    // in-tree registry-fetch pin, a `DepSource::Feira` variant the
17426    // enclosing docstring already names as a trajectory item) surfaces
17427    // as a build-time failure that names the offending drift when its
17428    // return arm doesn't route through the paired predicate.
17429    #[test]
17430    fn dep_source_constructors_route_through_paired_is_variant_predicate() {
17431        let via_default_github = DepSource::default_github("pleme-io", "caixa-teia");
17432        assert!(
17433            via_default_github.is_git(),
17434            "DepSource::default_github must materialize a Git-arm shape — \
17435             a future constructor that routed through a non-Git arm \
17436             (a registry-fetch pin, a `DepSource::Feira` promotion) \
17437             would silently split the resolver's unpinned-shorthand \
17438             materializer from the sole_pin() precedence cascade"
17439        );
17440        assert!(
17441            !via_default_github.is_path(),
17442            "DepSource::default_github must NOT materialize a Path-arm \
17443             shape — the paired negation pin"
17444        );
17445
17446        let via_dep_git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0")
17447            .fonte
17448            .expect("Dep::git materializes a Some(fonte)");
17449        assert!(
17450            via_dep_git.is_git(),
17451            "Dep::git's `:fonte` materialization must land on the Git \
17452             arm — the author-surface pinned-git constructor's return \
17453             must route through the paired predicate"
17454        );
17455        assert!(!via_dep_git.is_path(), "paired negation pin");
17456
17457        let via_path = DepSource::Path {
17458            caminho: "../caixa-teia".into(),
17459        };
17460        assert!(
17461            via_path.is_path(),
17462            "the dev-mode Path-arm materialization must satisfy is_path()"
17463        );
17464        assert!(!via_path.is_git(), "paired negation pin");
17465    }
17466
17467    // ── `dep_nome_axis_reason_ctors!` — the `{ nome: String, <axis>:
17468    //    String, reason: String }` three-slot envelope on `DepError`,
17469    //    strict sibling of the peer `dep_nome_only_ctors!` (792aa92) on
17470    //    the one-slot `{ nome }` envelope, `dep_nome_list_ctors!`
17471    //    (6f5e0cd) on the two-slot `{ nome, list: &'static str }`
17472    //    envelope, `fonte_caminho_ctors!` (f85f145) on the two-slot
17473    //    `{ nome, caminho }` envelope, and `fonte_caminho_byte_ctors!`
17474    //    (0e35793) on the three-slot `{ nome, caminho, byte }` envelope.
17475
17476    #[test]
17477    fn versao_invalid_ctor_matches_struct_literal_wrap() {
17478        assert_eq!(
17479            DepError::versao_invalid("caixa-teia", "^0..1", "invalid comparator".to_string()),
17480            DepError::VersaoInvalid {
17481                nome: "caixa-teia".to_string(),
17482                versao: "^0..1".to_string(),
17483                reason: "invalid comparator".to_string(),
17484            },
17485            "versao_invalid ctor must produce byte-equal \
17486             `DepError::VersaoInvalid` to the pre-lift struct-literal wrap",
17487        );
17488    }
17489
17490    #[test]
17491    fn fonte_repo_shape_ctor_matches_struct_literal_wrap() {
17492        assert_eq!(
17493            DepError::fonte_repo_shape(
17494                "caixa-teia",
17495                "-upload-pack=evil",
17496                "leading dash rejected".to_string(),
17497            ),
17498            DepError::FonteRepoShape {
17499                nome: "caixa-teia".to_string(),
17500                repo: "-upload-pack=evil".to_string(),
17501                reason: "leading dash rejected".to_string(),
17502            },
17503            "fonte_repo_shape ctor must produce byte-equal \
17504             `DepError::FonteRepoShape` to the pre-lift struct-literal wrap",
17505        );
17506    }
17507
17508    #[test]
17509    fn caracteristica_invalid_ctor_matches_struct_literal_wrap() {
17510        assert_eq!(
17511            DepError::caracteristica_invalid(
17512                "caixa-teia",
17513                "bad feature!",
17514                "embedded space rejected".to_string(),
17515            ),
17516            DepError::CaracteristicaInvalid {
17517                nome: "caixa-teia".to_string(),
17518                caracteristica: "bad feature!".to_string(),
17519                reason: "embedded space rejected".to_string(),
17520            },
17521            "caracteristica_invalid ctor must produce byte-equal \
17522             `DepError::CaracteristicaInvalid` to the pre-lift struct-literal wrap",
17523        );
17524    }
17525
17526    #[test]
17527    fn dep_nome_axis_reason_ctors_route_nome_axis_and_reason_through_uniformly() {
17528        // Cross-axis routing pin: sweep the three constructor input axes
17529        // (`nome: &str`, `<axis>: &str`, `reason: String`) through
17530        // distinct-per-axis fixtures against every generated arm in the
17531        // [`dep_nome_axis_reason_ctors!`] macro, so any wrapper-side
17532        // lowercase / trim / truncate on the two `&str` axes — a silent
17533        // field swap between `nome`, the middle `<axis>` field, and
17534        // `reason`, or a `reason` axis silently rerouted through
17535        // `.to_string()` instead of forwarded owned — surfaces here rather
17536        // than at a downstream diagnostic-shape mismatch. Peer of the
17537        // sibling `fonte_caminho_byte_ctors_route_nome_caminho_and_byte_
17538        // through_to_string` (0e35793) cross-axis routing pin on the same
17539        // envelope's `{ nome, caminho, byte }` three-slot family and of
17540        // the peer `dep_nome_list_ctors_route_nome_and_list_through_
17541        // uniformly` (6f5e0cd) pin on the same envelope's two-slot family
17542        // — extended here onto the `{ nome, <axis>: String, reason:
17543        // String }` three-slot envelope so every substrate-primitive ctor
17544        // family in caixa-core's `DepError` envelope guarantees each field
17545        // routes the caller's value verbatim through `.to_string()` (or
17546        // owned-forward for `reason: String`) in declared field order.
17547        // Distinct-per-axis fixtures rule out any two-axis swap
17548        // (`nome` ↔ `<axis>`, `<axis>` ↔ `reason`) that would still pass a
17549        // same-fixture-per-axis pin.
17550        let nome = "sibling-teia";
17551        let axis = "distinct-axis-value";
17552        let reason = "distinct rejection sentence".to_string();
17553        assert_eq!(
17554            DepError::versao_invalid(nome, axis, reason.clone()),
17555            DepError::VersaoInvalid {
17556                nome: nome.to_string(),
17557                versao: axis.to_string(),
17558                reason: reason.clone(),
17559            },
17560            "versao_invalid must route `nome` → `nome`, `axis` → `versao`, \
17561             `reason` → `reason` in declared field order",
17562        );
17563        assert_eq!(
17564            DepError::fonte_repo_shape(nome, axis, reason.clone()),
17565            DepError::FonteRepoShape {
17566                nome: nome.to_string(),
17567                repo: axis.to_string(),
17568                reason: reason.clone(),
17569            },
17570            "fonte_repo_shape must route `nome` → `nome`, `axis` → `repo`, \
17571             `reason` → `reason` in declared field order",
17572        );
17573        assert_eq!(
17574            DepError::caracteristica_invalid(nome, axis, reason.clone()),
17575            DepError::CaracteristicaInvalid {
17576                nome: nome.to_string(),
17577                caracteristica: axis.to_string(),
17578                reason: reason.clone(),
17579            },
17580            "caracteristica_invalid must route `nome` → `nome`, \
17581             `axis` → `caracteristica`, `reason` → `reason` in declared \
17582             field order",
17583        );
17584    }
17585
17586    // ── `dep_nome_axis_ctors!` — the `{ nome: String, <axis>: String }`
17587    //    two-slot envelope on `DepError`, missing rung between
17588    //    `dep_nome_only_ctors!` (792aa92) on the one-slot `{ nome }`
17589    //    envelope and `dep_nome_axis_reason_ctors!` (5621f8a) on the
17590    //    three-slot `{ nome, <axis>: String, reason: String }` envelope.
17591    //    Sibling of `dep_nome_list_ctors!` (6f5e0cd) on the peer
17592    //    two-slot `{ nome, list: &'static str }` envelope (same slot
17593    //    count, `&'static str` axis instead of owned `String` axis).
17594
17595    #[test]
17596    fn fonte_pin_empty_ctor_matches_struct_literal_wrap() {
17597        assert_eq!(
17598            DepError::fonte_pin_empty("caixa-teia", ":tag"),
17599            DepError::FontePinEmpty {
17600                nome: "caixa-teia".to_string(),
17601                pin: ":tag".to_string(),
17602            },
17603            "fonte_pin_empty ctor must produce byte-equal \
17604             `DepError::FontePinEmpty` to the pre-lift struct-literal wrap \
17605             on the same `(&str, &str)` fixture",
17606        );
17607    }
17608
17609    #[test]
17610    fn fonte_pin_ambiguous_ctor_matches_struct_literal_wrap() {
17611        assert_eq!(
17612            DepError::fonte_pin_ambiguous("caixa-teia", ":tag, :rev"),
17613            DepError::FontePinAmbiguous {
17614                nome: "caixa-teia".to_string(),
17615                pins: ":tag, :rev".to_string(),
17616            },
17617            "fonte_pin_ambiguous ctor must produce byte-equal \
17618             `DepError::FontePinAmbiguous` to the pre-lift struct-literal \
17619             wrap on the same `(&str, &str)` fixture",
17620        );
17621    }
17622
17623    #[test]
17624    fn caracteristica_duplicate_ctor_matches_struct_literal_wrap() {
17625        assert_eq!(
17626            DepError::caracteristica_duplicate("caixa-teia", "http"),
17627            DepError::CaracteristicaDuplicate {
17628                nome: "caixa-teia".to_string(),
17629                caracteristica: "http".to_string(),
17630            },
17631            "caracteristica_duplicate ctor must produce byte-equal \
17632             `DepError::CaracteristicaDuplicate` to the pre-lift \
17633             struct-literal wrap on the same `(&str, &str)` fixture",
17634        );
17635    }
17636
17637    #[test]
17638    fn fonte_pin_ambiguous_ctor_matches_owned_string_join_shape() {
17639        // Owned-`String` routing pin: thread the real
17640        // `set.join(", ")` `String` carrier through the ctor's
17641        // `&str`-parameter Deref coercion, so the ambiguity-arm
17642        // wire-up site's actual `&set.join(", ")` shape stays
17643        // byte-equal to a direct `":tag, :rev"` literal. A future
17644        // parameter-shape change silently dropping the Deref
17645        // coercion route (e.g., a switch to `impl Into<String>`)
17646        // surfaces here rather than at the wire-up's compile
17647        // error far from the ctor definition.
17648        let set: Vec<&'static str> = vec![":tag", ":rev"];
17649        let joined: String = set.join(", ");
17650        assert_eq!(
17651            DepError::fonte_pin_ambiguous("caixa-teia", &joined),
17652            DepError::FontePinAmbiguous {
17653                nome: "caixa-teia".to_string(),
17654                pins: ":tag, :rev".to_string(),
17655            },
17656            "fonte_pin_ambiguous ctor must accept an owned-`String` \
17657             `&set.join(\", \")` carrier via Deref coercion — the exact \
17658             shape the ambiguity-arm wire-up site passes into it",
17659        );
17660    }
17661
17662    #[test]
17663    fn dep_nome_axis_ctors_route_nome_and_axis_through_to_string_uniformly() {
17664        // Cross-axis routing pin: sweep the two constructor input axes
17665        // (`nome: &str`, `<axis>: &str`) through distinct-per-axis
17666        // fixtures against every generated arm in the
17667        // [`dep_nome_axis_ctors!`] macro, so any wrapper-side lowercase /
17668        // trim / truncate at codegen time — a silent field swap between
17669        // `nome` and the middle `<axis>` field, or a `<axis>` axis
17670        // silently rerouted through the wrong field on any one variant
17671        // — surfaces here rather than at a downstream diagnostic-shape
17672        // mismatch. Peer of the sibling
17673        // `dep_nome_list_ctors_route_nome_and_list_through_uniformly`
17674        // (6f5e0cd) pin on the same envelope's peer two-slot family
17675        // (`{ nome, list: &'static str }`) and of the sibling
17676        // `dep_nome_axis_reason_ctors_route_nome_axis_and_reason_through_uniformly`
17677        // (5621f8a) pin on the same envelope's three-slot `{ nome,
17678        // <axis>: String, reason: String }` family — extended here onto
17679        // the `{ nome, <axis>: String }` two-slot envelope so the last
17680        // per-`DepError`-two-slot-owned-axis rung on the ctor-family
17681        // ladder guarantees each field routes the caller's value
17682        // verbatim through `.to_string()` in declared field order.
17683        // Distinct-per-axis fixtures rule out any two-axis swap
17684        // (`nome` ↔ `<axis>`) that would still pass a same-fixture-
17685        // per-axis pin.
17686        let nome = "sibling-teia";
17687        let axis = "distinct-axis-value";
17688        assert_eq!(
17689            DepError::fonte_pin_empty(nome, axis),
17690            DepError::FontePinEmpty {
17691                nome: nome.to_string(),
17692                pin: axis.to_string(),
17693            },
17694            "fonte_pin_empty must route `nome` → `nome`, `axis` → `pin` \
17695             in declared field order",
17696        );
17697        assert_eq!(
17698            DepError::fonte_pin_ambiguous(nome, axis),
17699            DepError::FontePinAmbiguous {
17700                nome: nome.to_string(),
17701                pins: axis.to_string(),
17702            },
17703            "fonte_pin_ambiguous must route `nome` → `nome`, `axis` → `pins` \
17704             in declared field order",
17705        );
17706        assert_eq!(
17707            DepError::caracteristica_duplicate(nome, axis),
17708            DepError::CaracteristicaDuplicate {
17709                nome: nome.to_string(),
17710                caracteristica: axis.to_string(),
17711            },
17712            "caracteristica_duplicate must route `nome` → `nome`, \
17713             `axis` → `caracteristica` in declared field order",
17714        );
17715    }
17716
17717    #[test]
17718    fn nome_invalid_ctor_matches_struct_literal_wrap() {
17719        // Equivalence pin: the ctor produces byte-equal
17720        // `DepError::NomeInvalid` to the pre-lift open-coded struct-
17721        // literal that cloned the offending `:deps :nome` verbatim and
17722        // forwarded the [`crate::render::is_dns_1123_label`]-shaped
17723        // owned `reason` payload at the caller site inside
17724        // [`Dep::validate`]. Guards any future field-addition /
17725        // reordering / accessor-return tweak on the variant. Sibling of
17726        // the peer four-slot `fonte_pin_shape` ctor equivalence pins
17727        // (below) and the sibling three-slot
17728        // `dep_nome_axis_reason_ctors_route_nome_axis_and_reason_through_uniformly`
17729        // pin on the same envelope's three-slot `{ nome, <axis>: String,
17730        // reason: String }` family.
17731        let nome = "Caixa-Teia";
17732        let reason = crate::render::is_dns_1123_label(nome).unwrap_err();
17733        let via_ctor = DepError::nome_invalid(nome, reason.clone());
17734        let via_literal = DepError::NomeInvalid {
17735            nome: nome.to_string(),
17736            reason,
17737        };
17738        assert_eq!(
17739            via_ctor, via_literal,
17740            "nome_invalid(nome, reason) must byte-equal the open-coded \
17741             NomeInvalid struct-literal on the same `(nome, reason)` fixture"
17742        );
17743        assert_eq!(
17744            via_ctor.to_string(),
17745            via_literal.to_string(),
17746            "Display byte-string must byte-equal the open-coded struct-literal"
17747        );
17748    }
17749
17750    #[test]
17751    fn nome_invalid_ctor_routes_nome_and_reason_through_to_string_uniformly() {
17752        // Boundary-sweep pin on the ctor's two-slot projection: sweep
17753        // the two ctor input axes (`nome: &str`, `reason: String`)
17754        // through distinct-per-axis fixtures against a representative
17755        // set of DNS-1123-refused `:deps :nome` byte-strings, so any
17756        // wrapper-side silent lowercase / trim / truncate at codegen
17757        // time — a silent field swap between `nome` and `reason`, an
17758        // accidental `nome`-side `.to_lowercase()` shim, or a `.into()`
17759        // divergence on the `reason` axis — surfaces at caixa-core
17760        // build time rather than at a downstream diagnostic consumer
17761        // that reads `err.nome` / `err.reason` back and gets a different
17762        // value than the one it stored. Peer of the sibling
17763        // `dep_nome_axis_ctors_route_nome_and_axis_through_to_string_uniformly`
17764        // (7f7c950) pin on the same envelope's peer two-slot family
17765        // (`{ nome, <axis>: String }`) — extended here onto the
17766        // `{ nome, reason: String }` two-slot rung the sole `NomeInvalid`
17767        // variant carries. Distinct-per-axis fixtures rule out any
17768        // two-axis swap (`nome` ↔ `reason`) that would still pass a
17769        // same-fixture-per-axis pin. The sweep list carries a mixed
17770        // DNS-1123-refused set (uppercase-carrying, underscore-carrying,
17771        // dot-carrying, leading-hyphen, trailing-hyphen, slash-carrying,
17772        // over-63-byte) so a future silent per-input normalization
17773        // surfaces on the arm that diverges.
17774        for nome in [
17775            "Caixa-Teia",
17776            "caixa_teia",
17777            "caixa.teia",
17778            "-caixa-teia",
17779            "caixa-teia-",
17780            "caixa/teia",
17781            &"a".repeat(64),
17782        ] {
17783            let reason = crate::render::is_dns_1123_label(nome)
17784                .expect_err("fixture must be a DNS-1123-refused label");
17785            let via_ctor = DepError::nome_invalid(nome, reason.clone());
17786            let DepError::NomeInvalid {
17787                nome: stored_nome,
17788                reason: stored_reason,
17789            } = via_ctor
17790            else {
17791                panic!("nome_invalid must construct NomeInvalid for {nome:?}");
17792            };
17793            assert_eq!(
17794                stored_nome, nome,
17795                "nome slot must round-trip verbatim through `.to_string()` for {nome:?}"
17796            );
17797            assert_eq!(
17798                stored_reason, reason,
17799                "reason slot must forward the owned `String` verbatim for {nome:?}"
17800            );
17801        }
17802    }
17803
17804    #[test]
17805    fn validate_nome_invalid_arm_routes_through_nome_invalid_ctor() {
17806        // End-to-end pin: the sole in-crate wire-up site
17807        // ([`Dep::validate`]'s DNS-1123 refusal arm) routes through
17808        // [`DepError::nome_invalid`] and the observed `Err` byte-equals
17809        // the ctor's output on the same DNS-1123-refused `:deps :nome`
17810        // fixture, with identical `Display` rendering. A future silent
17811        // de-lift of the wire-up back to the open-coded struct-literal
17812        // trips this test at caixa-core build time rather than at a
17813        // downstream diagnostic consumer far from the wire-up commit.
17814        // Sibling of the peer
17815        // `nome_invalid_diagnostic_carries_offending_name` pattern-match
17816        // pin on the same wire-up — extended here from a `matches!`
17817        // shape check to a byte-identity + Display parity route through
17818        // the ctor.
17819        let d = Dep::simple("Caixa_Teia", "^0.1");
17820        let observed = d.validate().unwrap_err();
17821        let reason = crate::render::is_dns_1123_label("Caixa_Teia")
17822            .expect_err("fixture must be DNS-1123-refused");
17823        let expected = DepError::nome_invalid("Caixa_Teia", reason);
17824        assert_eq!(
17825            observed, expected,
17826            "Dep::validate's DNS-1123 refusal arm must byte-equal \
17827             nome_invalid(nome, reason)"
17828        );
17829        assert_eq!(
17830            observed.to_string(),
17831            expected.to_string(),
17832            "Display byte-string parity"
17833        );
17834    }
17835}