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::FontePinEmpty {
298                                    nome: nome.to_string(),
299                                    pin: pin.to_string(),
300                                });
301                            }
302                        }
303                    }
304                    _ => {
305                        return Err(DepError::FontePinAmbiguous {
306                            nome: nome.to_string(),
307                            pins: set.join(", "),
308                        });
309                    }
310                }
311                // Per-pin value-shape gate. The refname-shaped axes
312                // (`:tag` + `:branch`) route through
313                // [`crate::render::is_git_ref_name`]; the hex-OID-shaped
314                // `:rev` axis routes through
315                // [`crate::render::is_git_oid`]. The two predicates
316                // partition the `:fonte` pin axes structurally — refname
317                // vs. hex commit — so a cross-axis mis-slot (the
318                // canonical "I conflated `:rev` and `:branch`" footgun:
319                // `:rev "main"` defeating the reproducibility contract,
320                // `:tag "deadbeef…"` mis-slotting a SHA into the
321                // refname-shaped axis) lands at the offending axis's
322                // predicate, not at lacre-resolve `git fetch` /
323                // `git checkout` time. Their valid sets intersect at
324                // the empty set: every refname is rejected by
325                // `is_git_oid`, every OID is rejected by
326                // `is_git_ref_name`, structurally.
327                //
328                // Until this gate landed `:tag` / `:branch` were the
329                // refname-shaped axes still untyped past the empty-pin
330                // arm: a malformed-but-non-empty refname
331                // (`:tag "v0.1.0 "` trailing space — the canonical
332                // paste-from-doc footgun; `:tag "v0.1.0.lock"` colliding
333                // with git's atomic-rename guard suffix; `:tag "../escape"`
334                // path-traversal via consecutive dots; `:branch "main "`
335                // trailing space; `:branch "feature/foo bar"` embedded
336                // space; `:branch "@"` the literal HEAD alias;
337                // `:branch "refs/heads/main"` the fully-qualified ref
338                // copied from `git show-ref` output that resolves to
339                // a literal ref named `refs/heads/refs/heads/main` on
340                // disk) silently passed validate; the `:rev` axis was
341                // the last `:fonte`-related axis still untyped past the
342                // empty-pin arm: a malformed-but-non-empty hex-OID
343                // (`:rev "main"` conflating with `:branch` — the
344                // reproducibility-contract leak; `:rev "v0.1.0"`
345                // conflating with `:tag` — the same mis-slot on the
346                // refname/OID boundary; `:rev "c0ffee"` an abbreviated
347                // 6-char prefix that's ambiguous across repo history;
348                // `:rev "DEADBEEF…"` an uppercase OID that round-trips
349                // inconsistently against `git rev-parse HEAD`'s
350                // lowercase emission) silently passed validate and the
351                // failure surfaced at lacre-resolve `git fetch` /
352                // `git checkout` time with a quoting-confused error
353                // far from the source caixa.lisp, with no field naming
354                // which `:deps` entry carried the typo. Lifting both
355                // gates to caixa-build time matches the value-shape
356                // trajectory the peer typed axes already follow
357                // (c4213a4 typed WitContract endpoint/subject/slot;
358                // eb3456d :entrada :paths; c7d05ec :entrada :host;
359                // 4f0390b :contratos :endpoint; 6226bf4 :contratos :wit;
360                // 63e18a0 :contratos :subject; 2f4316e :contratos
361                // :slot; e70d213 :fonte :tag + :branch) — the typed
362                // slot's valid set matches its downstream consumer's
363                // accepted set (here, the git porcelain's refname /
364                // commit-OID grammars at `git fetch` / `git checkout`
365                // time), structurally. Same diagnostic shape every
366                // per-axis value-shape lift already exposes
367                // (`*Invalid { axis, reason }`); the `value:` field
368                // carries the offending refname / OID verbatim so the
369                // author can grep their caixa.lisp for the
370                // `:tag "<value>"` / `:branch "<value>"` /
371                // `:rev "<value>"` literal and fix it in one edit.
372                for (pin, value) in [(":tag", tag.as_ref()), (":branch", branch.as_ref())] {
373                    if let Some(v) = value
374                        && let Err(reason) = crate::render::is_git_ref_name(v)
375                    {
376                        return Err(DepError::fonte_pin_shape(nome, pin, v, reason));
377                    }
378                }
379                if let Some(v) = rev.as_ref()
380                    && let Err(reason) = crate::render::is_git_oid(v)
381                {
382                    return Err(DepError::fonte_pin_shape(nome, ":rev", v, reason));
383                }
384                Ok(())
385            }
386            Self::Path { caminho } => Self::validate_caminho(nome, caminho),
387        }
388    }
389
390    /// Reproducibility + path-API gate on the `:fonte (:tipo path …)`
391    /// `:caminho` axis. Walks the leading-byte cascade closed by the
392    /// b94fd83 (`/`), a5c248e (`~`), and f4efe9c (`$`) arms; the
393    /// orthogonal embedded-control-byte arm (d624c8d) covering
394    /// `0x00..=0x1F` plus `0x7F` anywhere in the value; and the
395    /// embedded-`\` Windows-path-separator arm closing the
396    /// cross-host-OS-separator divergence vector on the same
397    /// THEORY.md §V.2 render-determinism axis.
398    ///
399    /// Extracted from [`Self::validate`]'s `Self::Path` arm because the
400    /// per-arm cascade now spans nine diagnostic shapes — every new
401    /// `:caminho` arm (a future `&` / `;` / `|` shell-metachar arm,
402    /// a future glob-metachar `*` / `?` arm) lands here rather than
403    /// re-inflating `Self::validate`. The
404    /// function stays a thin per-arm linear walk for one reason: each
405    /// arm's diagnostic carries a distinct typed [`DepError`] variant
406    /// rather than a parser-shaped `reason` string, so collapsing the
407    /// cascade onto a generic [`crate::render`] predicate would regress
408    /// the per-arm self-locating diagnostic that `feira lint` consumers
409    /// depend on. The wrapped predicate trajectory ([`crate::render::is_dns_1123_label`],
410    /// [`crate::render::is_git_repo_url`], etc.) lives on the
411    /// reason-string-shaped axes; the `:caminho` axis keeps its
412    /// per-arm variant shape.
413    #[allow(
414        clippy::too_many_lines,
415        reason = "the per-arm cascade is structurally flat by design — every \
416                  `:caminho` arm carries its own typed [`DepError`] variant + \
417                  per-arm Why comment, so collapsing the cascade onto a generic \
418                  [`crate::render`] predicate would regress the per-arm self-locating \
419                  diagnostic the `feira lint` consumer surface depends on"
420    )]
421    fn validate_caminho(nome: &str, caminho: &str) -> Result<(), DepError> {
422        if caminho.is_empty() {
423            return Err(DepError::fonte_caminho_empty(nome));
424        }
425        // Reproducibility gate on the `:fonte (:tipo path …)`
426        // `:caminho` axis. The lacre pipeline embeds the value
427        // verbatim in its per-dep content-address
428        // (`conteudo: format!("path:{caminho}")`,
429        // caixa-resolver/src/resolve.rs:189) and that string
430        // folds into the BLAKE3 closure the lacre keys every
431        // downstream consumer (the substrate's reproducibility
432        // contract, CAIXA-SDLC §III.2 — the lacre is the
433        // build's content-addressed identity, peer of the Nix
434        // store path) against. Until this gate landed an
435        // absolute `:caminho` (`/home/me/work/caixa-teia` — the
436        // canonical "I dragged the folder out of Finder into
437        // my editor" footgun; `/Users/alice/dev/caixa-teia` on
438        // the macOS path-layout peer; the
439        // `${WORKSPACE}/caixa-teia` shell-expanded literal
440        // pasted from a CI manifest) silently passed validate
441        // and the failure surfaced *as a successful build with
442        // a divergent lacre*: the BLAKE3 closure on Alice's
443        // workstation differed from the closure on Bob's
444        // workstation, two CI runners with different
445        // `${HOME}` layouts emitted two distinct
446        // content-addresses for the byte-identical caixa, and
447        // the substrate's "the lacre is the build's identity"
448        // contract silently broke far from the source
449        // caixa.lisp — the most insidious failure mode the
450        // typed slot can carry (no error surfaces; the
451        // divergence is invisible until two machines compare
452        // lacres). The same THEORY.md §V.2 render-determinism
453        // discipline `is_sandboxed_relative_path` already
454        // applies on the M2 typed path-slots
455        // (`:behavior :on-*`, `:upgrade-from :state-change
456        // :script`, `:bibliotecas`, `:exe`, `:servicos`), here
457        // narrowed to the absolute-vs-relative axis only:
458        // `:fonte :caminho`'s canonical author-surface form is
459        // the `..`-traversing sibling-workspace path
460        // (`"../caixa-teia"`, the in-tree dev-dep frame), so a
461        // full `is_sandboxed_relative_path` lift would
462        // structurally reject every legitimate path-fonte
463        // dep. The narrower
464        // `std::path::Path::is_absolute` cut admits the
465        // sibling-workspace form while still rejecting the
466        // host-layout-leaking absolute shape — the
467        // reproducibility contract bites at exactly the
468        // absolute boundary, and that's the axis the
469        // substrate-level invariant is meant to hold. Same
470        // diagnostic shape every per-axis value-shape lift on
471        // the surrounding [`DepError::Fonte*`] cluster carries
472        // (the offending `:nome` + offending `:caminho`
473        // quoted verbatim so the author can grep their
474        // caixa.lisp for the `:caminho "<value>"` literal and
475        // fix it in one edit). The empty arm strictly
476        // precedes this arm so the blank-string footgun
477        // surfaces the more self-locating
478        // `FonteCaminhoEmpty` diagnostic (the empty string
479        // is not absolute under `Path::new("").is_absolute()`
480        // so the precedence is a no-op at value level — the
481        // pin matters only at the diagnostic-shape level if
482        // a future codec round-trip ever produces an empty
483        // string that probes as absolute).
484        if std::path::Path::new(caminho).is_absolute() {
485            return Err(DepError::fonte_caminho_absolute(nome, caminho));
486        }
487        // Reproducibility gate's tilde-expansion arm. The b94fd83
488        // `FonteCaminhoAbsolute` closes the leading-`/`
489        // host-layout-leak; a `:caminho "~/work/caixa-teia"` (the
490        // canonical paste-from-shell-prompt / paste-from-`cd ~`-
491        // doc footgun) silently passed both the empty arm and
492        // the absolute arm because `Path::new("~").is_absolute()`
493        // returns `false` — `~` is a shell-expansion convention,
494        // not a POSIX path component, so `std::path::Path` treats
495        // it as a literal directory-name segment. The lacre
496        // pipeline then embedded the value verbatim
497        // (`conteudo: format!("path:~/work/caixa-teia")`) and the
498        // failure mode forked per consumer:
499        //
500        //   - The caixa-resolver's `Path` arm folds `:caminho`
501        //     through `Path::new(caminho).join(<file>)` without
502        //     `~`-expansion, so the build looked for a literal
503        //     `./~/work/caixa-teia` subdirectory and failed at
504        //     resolve time with a `No such file or directory`
505        //     error far from the source caixa.lisp (the lacre
506        //     itself, though, was already byte-identical across
507        //     machines — every machine emitted the same
508        //     `path:~/work/caixa-teia` content-address).
509        //   - A future caixa-resolver pass that *does* expand `~`
510        //     (the canonical shell-convention idiom every
511        //     resolver eventually reaches for once an author
512        //     reports the literal-`~`-directory bug) would re-
513        //     introduce the host-layout-leak the b94fd83 absolute
514        //     gate closes: Alice's `~` expands to `/home/alice`,
515        //     Bob's to `/home/bob`, two CI runners with different
516        //     `$HOME` layouts resolve to two distinct paths for
517        //     the byte-identical caixa, and the substrate's
518        //     "the lacre is the build's identity" contract
519        //     silently breaks far from the source caixa.lisp.
520        //
521        // Closing the gate at `DepSource::validate` (here at the
522        // canonical caixa-build-time boundary, peer with the
523        // absolute arm above) refuses both failure modes
524        // structurally: the typed accepted set excludes every
525        // `~`-prefixed authoring shape, so the resolver is
526        // free to grow `~`-expansion (or any other convention-
527        // expansion the substrate adopts) without re-opening
528        // the host-layout-leak at the typed boundary. Same
529        // diagnostic shape every per-axis value-shape gate on
530        // the surrounding [`DepError::Fonte*`] cluster carries
531        // (the offending `:nome` + offending `:caminho` quoted
532        // verbatim so the author can grep their caixa.lisp for
533        // the `:caminho "<value>"` literal and fix it in one
534        // edit).
535        //
536        // The cascade preserves narrower-diagnostic-first
537        // ordering: `FonteCaminhoEmpty` → `FonteCaminhoAbsolute`
538        // → `FonteCaminhoTildeExpansion`. The empty arm
539        // structurally precedes both (the bytes "" / "~" don't
540        // overlap), and the absolute arm structurally precedes
541        // the tilde arm (an absolute path can't start with `~`
542        // since absolute paths start with `/`; the bytes "/" /
543        // "~" don't overlap either). Both arms are
544        // value-disjoint, so the precedence is a no-op at value
545        // level — the pin matters only at the diagnostic-shape
546        // level if a future codec round-trip ever produces a
547        // value that probes as both absolute and tilde-prefixed.
548        if caminho.starts_with('~') {
549            return Err(DepError::fonte_caminho_tilde_expansion(nome, caminho));
550        }
551        // Reproducibility gate's shell-variable-expansion arm.
552        // The b94fd83 `FonteCaminhoAbsolute` closes the leading-`/`
553        // host-layout-leak; the a5c248e `FonteCaminhoTildeExpansion`
554        // closes the leading-`~` shell-home-expansion shape; the
555        // leading-`$` is the sibling shell-variable-expansion shape
556        // — same host-layout-leaking semantic, different syntactic
557        // surface. A `:caminho "$HOME/work/caixa-teia"` (the
558        // canonical paste-from-`echo $HOME`-doc footgun) and the
559        // `${VAR}`-braced variant (`"${WORKSPACE}/caixa-teia"` —
560        // the canonical paste-from-CI-manifest footgun every
561        // GitHub Actions / GitLab CI / Drone manifest carries)
562        // silently passed every prior arm because
563        // `Path::is_absolute` returns false on `$` (the `$` is a
564        // shell convention, not a POSIX path component, so
565        // `std::path::Path` treats it as a literal directory-name
566        // segment) and the tilde arm's `starts_with('~')` doesn't
567        // fire.
568        //
569        // Same per-consumer failure-fork the tilde arm closes:
570        //
571        //   - The caixa-resolver's `Path` arm folds `:caminho`
572        //     through `Path::new(caminho).join(<file>)` without
573        //     `$`-expansion, so the build looks for a literal
574        //     `./$HOME/work/caixa-teia` subdirectory and fails at
575        //     resolve time with a `No such file or directory`
576        //     error far from the source caixa.lisp.
577        //   - A future caixa-resolver pass that *does* expand
578        //     `$VAR` (the shell-convention idiom every resolver
579        //     eventually reaches for once an author reports the
580        //     literal-`$HOME`-directory bug, especially for CI's
581        //     `${WORKSPACE}` idiom) would re-introduce the host-
582        //     layout-leak the b94fd83 absolute gate closes:
583        //     Alice's `$HOME` expands to `/home/alice`, Bob's to
584        //     `/home/bob`, two CI runners with different
585        //     `${WORKSPACE}` layouts resolve to two distinct
586        //     paths for the byte-identical caixa, and the
587        //     substrate's "the lacre is the build's identity"
588        //     contract silently breaks far from the source
589        //     caixa.lisp.
590        //
591        // Closing the gate at `DepSource::validate` (here at the
592        // canonical caixa-build-time boundary, peer with the
593        // absolute + tilde arms above) refuses both failure modes
594        // structurally. Same diagnostic shape every per-axis
595        // value-shape gate on the surrounding [`DepError::Fonte*`]
596        // cluster carries (the offending `:nome` + offending
597        // `:caminho` quoted verbatim).
598        //
599        // The cascade preserves narrower-diagnostic-first ordering:
600        // `FonteCaminhoEmpty` → `FonteCaminhoAbsolute` →
601        // `FonteCaminhoTildeExpansion` → `FonteCaminhoVarExpansion`.
602        // The empty arm structurally precedes all three subsequent
603        // arms; the absolute arm structurally precedes both the
604        // tilde and the var arms (absolute paths start with `/`,
605        // the bytes `/` / `~` / `$` don't overlap at the leading
606        // position); the tilde arm structurally precedes the var
607        // arm (`~` and `$` don't overlap at the leading position).
608        // Every pair is value-disjoint, so the precedence is a
609        // no-op at value level — the pin matters only at the
610        // diagnostic-shape level if a future codec round-trip ever
611        // produces a probe-as-both value.
612        //
613        // The gate covers every leading-`$` shape: the canonical
614        // `"$HOME/work/caixa-teia"` (POSIX shell), the braced
615        // `"${HOME}/work/caixa-teia"` (POSIX shell braces), the
616        // CI-manifest idiom `"${WORKSPACE}/caixa-teia"` (the
617        // GitHub Actions / GitLab CI / Drone paste footgun), the
618        // XDG idiom `"$XDG_CONFIG_HOME/caixa"`, and the bare `$`
619        // (degenerate "I meant `$HOME` and forgot the rest"). All
620        // shapes route through the same `caminho.starts_with('$')`
621        // byte check.
622        if caminho.starts_with('$') {
623            return Err(DepError::fonte_caminho_var_expansion(nome, caminho));
624        }
625        // Reproducibility gate's leading-space arm. The b94fd83 / a5c248e /
626        // f4efe9c arms closed the leading-byte host-layout-leak shapes
627        // (`/` / `~` / `$`); the embedded-control-byte arm below closes
628        // every byte in `0x00..=0x1F` plus `0x7F` (which already includes
629        // tab `0x09`, LF `0x0A`, CR `0x0D` — every ASCII whitespace
630        // *except* the ASCII space byte `0x20`). The bare ASCII space at
631        // the leading position is the orthogonal paste-from-aligned-doc
632        // shape that silently passed every prior arm: `Path::is_absolute`
633        // returns false on `" ../caixa-teia"` (the leading byte is `0x20`
634        // not `0x2F`), `0x20` is not `~` / `$` / `\` / a control byte, and
635        // the value's last byte is not `/`, so the canonical
636        // paste-from-aligned-`caixa.lisp`-doc footgun (every `:fonte`
637        // form in a multi-entry `:deps` block sits at the same column —
638        // an author selecting `"<sp><sp><sp>../caixa-teia"` and pasting
639        // it from the rendered alignment into a fresh entry preserves the
640        // leading whitespace verbatim) silently rendered as a path with
641        // a leading-space directory component the resolver folds through
642        // `Path::join` looking for a literal `./ ../caixa-teia`
643        // subdirectory that fails at resolve time with a non-self-
644        // locating `No such file or directory` error.
645        //
646        // The lacre pipeline's reproducibility contract bites
647        // strictly at this byte: `path:" ../caixa-teia"` and
648        // `path:"../caixa-teia"` yield distinct BLAKE3 closures
649        // (`conteudo: format!("path:{caminho}")`,
650        // caixa-resolver/src/resolve.rs:189) for the byte-divergent /
651        // semantic-identical caixa, and the substrate's "the lacre is
652        // the build's identity" contract (CAIXA-SDLC §III.2) silently
653        // breaks across two workstations whose authors differ only in
654        // paste-from-aligned-doc whitespace habits — the most insidious
655        // failure mode the typed slot can carry (no error surfaces; the
656        // divergence is invisible until two machines compare lacres).
657        //
658        // The arm fires AFTER the absolute / tilde / var leading-byte
659        // arms (each names the more self-locating shell-convention
660        // diagnostic on values that probe as that arm's leading-byte
661        // sentinel followed by a leading space — e.g.
662        // `:caminho "/  /foo"` surfaces `FonteCaminhoAbsolute` because
663        // the leading byte is `/`, not space) and BEFORE the
664        // embedded-control-byte arm (a leading-space value with an
665        // embedded control byte surfaces the broader leading-space
666        // diagnostic because the cascade walks leading-byte arms first
667        // — peer with how `FonteCaminhoAbsolute` precedes
668        // `FonteCaminhoControlChar` on `"/etc/passwd\n"`).
669        //
670        // The peer single-token-shaped axes already reject leading
671        // whitespace on the same paste-from-aligned-doc contract:
672        // [`crate::render::is_git_repo_url`] rejects leading whitespace
673        // on `:fonte :repo`, [`crate::render::is_git_ref_name`] rejects
674        // leading whitespace on `:fonte :tag`/`:branch`,
675        // [`crate::render::is_chart_description_shape`] rejects leading
676        // whitespace on `:descricao`,
677        // [`crate::render::is_spdx_expression_shape`] rejects leading
678        // whitespace on `:licenca`. Closing the same byte on
679        // `:fonte :caminho` makes the substrate-wide "no leading ASCII
680        // space anywhere in a typed string slot" invariant structurally
681        // consistent across every value-shape-gated typed surface (the
682        // `:caminho` axis was the last typed string surface still
683        // admitting a leading space byte).
684        if caminho.starts_with(' ') {
685            return Err(DepError::fonte_caminho_leading_whitespace(nome, caminho));
686        }
687        // Reproducibility gate's leading-`-` CLI-argument-injection arm.
688        // The b94fd83 + a5c248e + f4efe9c + LeadingWhitespace arms closed
689        // the four prior leading-byte shapes (`/` / `~` / `$` / space);
690        // this arm closes the orthogonal leading-`-` axis on the same
691        // subprocess-argument-boundary the peer `is_git_repo_url` arm
692        // (render.rs:2037, `-upload-pack=…` on `:fonte :repo`) and
693        // `is_git_ref_name` arm (render.rs:1381, 5a28454, `-stable` on
694        // `:fonte :tag` / `:branch`) already reject.
695        //
696        // The lacre pipeline embeds `:caminho` verbatim in its per-dep
697        // content-address (`conteudo: format!("path:{caminho}")`,
698        // caixa-resolver/src/resolve.rs:189) and the resolver folds the
699        // value through `Path::join` looking for a literal `./{caminho}`
700        // subdirectory. Every downstream subprocess that consumes the
701        // resolved path — a `git -C {caminho} <verb>` invocation, a
702        // future `feira tofu` `terraform -chdir={caminho}` shell-out, a
703        // future operator-side `nix build --path {caminho}` spawn, an
704        // `xargs` / `find {caminho}` / `stat {caminho}` /
705        // `rm -rf {caminho}` cleanup — reinterprets a leading-`-` value
706        // as a CLI flag rather than a positional path when the
707        // subprocess invocation does not carry a `--` argument-list
708        // terminator between the flag block and the path argument. The
709        // canonical footguns:
710        //
711        //   - `:caminho "-rf"` — bare short-flag paste (`rm -rf` /
712        //     `find -rf` reinterpretation; the byte the peer
713        //     `FonteCaminhoShellSemicolon` arm's `; rm -rf build`
714        //     example paste-idiom carries as its first token).
715        //   - `:caminho "-C"` — `git -C` config-injection paste
716        //     (`git -C -C` reinterprets the second `-C` as another
717        //     `--change-directory` flag rather than the path
718        //     argument; the canonical `git -C <path>` porcelain
719        //     idiom every multi-repo workspace tool carries).
720        //   - `:caminho "--upload-pack=cat /etc/passwd"` — the
721        //     canonical long-flag CLI-arg-injection vector at every
722        //     git porcelain entry point (`git clone`, `git fetch`,
723        //     `git ls-remote`) that consumes a path or URL
724        //     argument; peer with `is_git_repo_url`'s leading-`-`
725        //     arm (render.rs:2037) on the sibling `:fonte :repo`
726        //     axis, which the arm's diagnostic explicitly cites.
727        //   - `:caminho "--config=…"` / `:caminho "-c"` — git-config
728        //     override paste-idiom (paste-from-`git -c foo=bar`
729        //     shell-history footgun that reinterprets the value as
730        //     a `[foo] bar` config injection on every git porcelain
731        //     entry point).
732        //
733        // POSIX `std::path::Path` treats a leading `-` as a literal
734        // filename byte, so the resolver folds `-rf` through `Path::join`
735        // and looks for a literal `./-rf` subdirectory — the failure
736        // surfaces at resolve time with a non-self-locating `No such
737        // file or directory` error far from the source caixa.lisp, and
738        // the value rides through the lacre content-address into every
739        // downstream shell-spawned subprocess. On any consumer that
740        // shells out without the `--` terminator (the common case at
741        // every porcelain entry-point) the reinterpretation is silent
742        // and the failure mode is arbitrary-argument-injection.
743        //
744        // The arm fires AFTER the absolute / tilde / var / leading-space
745        // leading-byte arms (each names the more self-locating shell-
746        // convention diagnostic on values that probe as that arm's
747        // leading-byte sentinel — the byte sets are pairwise disjoint at
748        // the leading position, so the precedence pin is a no-op at
749        // value level, but the ordering keeps every leading-byte arm's
750        // diagnostic-shape stable) and BEFORE the embedded-control-byte
751        // arm (a leading-`-` value with an embedded control byte
752        // surfaces the narrower leading-`-` diagnostic because the
753        // cascade walks leading-byte arms first — peer with how
754        // `FonteCaminhoAbsolute` precedes `FonteCaminhoControlChar` on
755        // `"/etc/passwd\n"`, and how `FonteCaminhoLeadingWhitespace`
756        // precedes `FonteCaminhoControlChar` on `" ../foo\n"`).
757        //
758        // The peer single-token-shaped axes already reject leading `-`
759        // on the same CLI-arg-injection contract:
760        // [`crate::render::is_git_repo_url`] rejects it on `:fonte :repo`
761        // (render.rs:2037), [`crate::render::is_git_ref_name`] rejects
762        // it on `:fonte :tag` / `:fonte :branch` (render.rs:1381,
763        // 5a28454), [`crate::render::is_dns_1123_label`] rejects it on
764        // every DNS-1123-shaped axis (top-level Caixa `:nome`, `:membros
765        // :caixa`, `:children :caixa`, `:deps :nome`, cluster names),
766        // [`crate::render::is_cargo_feature_name`] rejects it on
767        // `:caracteristicas`, and the feira `init` / `add <nome>`
768        // positional gate (868c191) rejects it on the CLI positional
769        // itself. Closing the same byte on `:fonte :caminho` makes the
770        // substrate-wide "no leading `-` anywhere in a typed single-
771        // token string slot routed through a subprocess argument"
772        // invariant structurally consistent across every value-shape-
773        // gated typed surface (the `:caminho` axis was the last typed
774        // string surface still admitting a leading `-` byte).
775        if caminho.starts_with('-') {
776            return Err(DepError::fonte_caminho_leading_hyphen(nome, caminho));
777        }
778        // Reproducibility gate's embedded-control-byte arm. The
779        // b94fd83 + a5c248e + f4efe9c arms closed the three
780        // leading-byte host-layout-leak shapes (`/` / `~` / `$`);
781        // this arm closes the orthogonal embedded-control-byte
782        // axis — any ASCII control byte (`0x00..=0x1F` plus
783        // `0x7F` DEL) appearing anywhere in `:caminho`. Same
784        // shape every peer single-token-typed-slot value-shape
785        // predicate the surrounding [`crate::render`] cluster
786        // gates against (the lifted `is_git_repo_url` arm on
787        // `:fonte :repo`, the `is_git_ref_name` arm on
788        // `:tag`/`:branch`, the `is_chart_description_shape` /
789        // `is_chart_maintainer_name_shape` /
790        // `is_chart_keyword_shape` arms on the
791        // Helm-chart-shaped axes); now consistent on the
792        // `:caminho` axis too.
793        //
794        // Until this gate landed any embedded control byte
795        // silently passed validate, the lacre pipeline embedded
796        // the value verbatim in its per-dep content-address
797        // (`conteudo: format!("path:{caminho}")`,
798        // caixa-resolver/src/resolve.rs:189), and the failure
799        // forked per byte and per consumer:
800        //
801        //   - NUL (`0x00`) the canonical "POSIX paths cannot
802        //     contain a NUL byte" shape: every `std::fs` syscall
803        //     routes the path through `CString::new`, which
804        //     fails with `NulError` on the first NUL byte; the
805        //     build would surface a `NulError` at resolve time
806        //     far from the source caixa.lisp.
807        //   - LF (`0x0A`) / CR (`0x0D`) the canonical paste-from-
808        //     multiline-doc footgun: a `:caminho
809        //     "../caixa-teia\nrm -rf /"` value (paste landed mid-
810        //     `:caminho` block from a multi-line code-fence)
811        //     silently round-trips through `Path::join` but the
812        //     embedded newline class is a sibling of the CRLF-at-
813        //     subprocess-argument injection vector
814        //     `is_git_repo_url` already closes on `:repo`.
815        //   - Tab (`0x09`) the canonical paste-from-aligned-table
816        //     footgun: the tab is invisible in most editors, and
817        //     the lacre embeds the value verbatim so two
818        //     paste-from-distinct-tables yield divergent lacres
819        //     across host editors that strip vs preserve tabs.
820        //   - DEL (`0x7F`) + every other `0x00..=0x1F` byte: the
821        //     paste-from-binary-blob shape every peer single-
822        //     token-shaped slot rejects under the same
823        //     `b < 0x20 || b == 0x7F` predicate.
824        //
825        // Mirrors the cascade discipline every prior `:caminho`
826        // arm establishes: `FonteCaminhoEmpty` →
827        // `FonteCaminhoAbsolute` → `FonteCaminhoTildeExpansion`
828        // → `FonteCaminhoVarExpansion` →
829        // `FonteCaminhoLeadingWhitespace` →
830        // `FonteCaminhoLeadingHyphen` → `FonteCaminhoControlChar`.
831        // The six leading-byte arms structurally precede the
832        // embedded-byte arm because the leading-byte shapes are
833        // the more self-locating diagnostic on values that probe
834        // as both (e.g. `:caminho "/etc/passwd\n"` surfaces the
835        // narrower `FonteCaminhoAbsolute` rather than the broader
836        // embedded-control-byte arm); the precedence pin matters
837        // at the diagnostic-shape level even though the empty /
838        // absolute / tilde / var arms are value-disjoint from a
839        // bare control byte (which would itself be a leading
840        // byte under the empty / absolute / tilde / var arms'
841        // leading-position semantics, but those arms guard the
842        // specific shell-convention characters `/` / `~` / `$`
843        // — a leading `0x01` byte falls through to this arm).
844        for &b in caminho.as_bytes() {
845            if b < 0x20 || b == 0x7F {
846                return Err(DepError::fonte_caminho_control_char(nome, caminho, b));
847            }
848        }
849        // Reproducibility gate's Windows-path-separator arm. The four
850        // leading-byte arms (`/` / `~` / `$`) and the embedded-
851        // control-byte arm close the host-layout-leaking + paste-from-
852        // multiline-doc shapes; the leading-`\` / embedded-`\` byte is
853        // the orthogonal cross-host-OS-separator shape — same render-
854        // determinism axis, different semantic mechanism. POSIX
855        // [`std::path::Path`] treats `\` (0x5C) as a literal byte
856        // inside a single path component (so `..\caixa-teia` is one
857        // directory named literally `..\caixa-teia`, sibling of `.`
858        // and `..`); Windows [`std::path::Path`] treats `\` as a
859        // primary path separator equal to `/` (so `..\caixa-teia` is
860        // the parent's sibling directory `caixa-teia`). The lacre
861        // pipeline embeds the value verbatim in its per-dep content-
862        // address (`conteudo: format!("path:{caminho}")`, caixa-
863        // resolver/src/resolve.rs:189), so byte-identical caixa.lisp
864        // values resolve to two distinct directories across runner
865        // OSes — the same THEORY.md §V.2 render-determinism contract
866        // the absolute / tilde / var arms protect, here against the
867        // cross-host-OS-separator divergence vector. Even on POSIX-
868        // only resolvers (the canonical pleme-io substrate posture),
869        // a `..\caixa-teia` (the Windows-Explorer "copy as path" /
870        // PowerShell `Get-Location` paste-idiom footgun) silently
871        // passes every prior arm because `Path::is_absolute` returns
872        // false on `..` and `\` is neither a leading-byte sentinel
873        // nor a control byte, then the resolver folds the value
874        // through `Path::new(caminho).join(<file>)` looking for a
875        // literal `./..\caixa-teia` subdirectory and fails at
876        // resolve time with a non-self-locating `No such file or
877        // directory` error far from the source caixa.lisp.
878        //
879        // The peer single-token-shaped axes on the same git-CLI /
880        // path-CLI consumer cluster already reject `\` under the same
881        // Windows-path-leak banner: [`crate::render::is_git_ref_name`]
882        // line 1441 (`"must not contain \\ … the canonical Windows-
883        // path-leak footgun; use / for hierarchical refs"`) gates
884        // `:fonte :tag` / `:fonte :branch` against the same byte,
885        // and [`crate::render::is_gateway_api_http_path`] line 506
886        // includes `\` in the eleven-byte RFC-3986-reserved rejection
887        // set on `:entrada :paths`. Closing the same byte on `:fonte
888        // :caminho` makes the substrate-wide "no Windows path
889        // separator anywhere in a typed string slot" invariant
890        // structurally consistent across every path-shaped typed
891        // surface (the `:caminho` axis was the last typed string
892        // surface still admitting `\`).
893        //
894        // The arm fires AFTER the control-char arm because the
895        // control-char diagnostic is the more self-locating axis on
896        // values that probe as both (`"..\caixa\0teia"` carries both
897        // a `\` and a NUL — NUL is the load-bearing POSIX-syscall-
898        // rejected byte, so `FonteCaminhoControlChar` wins). Same
899        // narrower-diagnostic-first cascade discipline every prior
900        // arm establishes. A pure-`\` value
901        // (`"..\caixa-teia"` with no control bytes) falls through
902        // every prior arm and lands here.
903        for &b in caminho.as_bytes() {
904            if b == b'\\' {
905                return Err(DepError::fonte_caminho_backslash(nome, caminho));
906            }
907        }
908        // Reproducibility gate's shell-redirection arm. The 3a4e1d7 backslash
909        // arm closes the cross-host-OS-separator vector; `<` (`0x3C`) and `>`
910        // (`0x3E`) are the orthogonal shell-redirection sentinels — same
911        // paste-from-shell-prompt footgun class, different syntactic surface.
912        // POSIX `std::path::Path` treats `<` / `>` as literal bytes inside a
913        // single path component (so `../caixa-teia>output` is one directory
914        // named literally `../caixa-teia>output`, sibling of `.` and `..`),
915        // but every interactive shell (bash / zsh / fish / nushell) lexes
916        // `<` / `>` as input / output redirection operators — a `:caminho
917        // "../caixa-teia>build.log"` (the canonical "I pasted a shell
918        // pipeline that wrote build output and forgot to trim the redirect"
919        // footgun) or `:caminho "../<input.lisp"` (the symmetric input-
920        // redirection paste idiom) silently passes every prior arm because
921        // `Path::is_absolute` returns false, `<` / `>` are neither leading-
922        // byte sentinels nor control bytes nor `\`, and the value's last byte
923        // isn't `/`. The resolver folds the value through
924        // `Path::new(caminho).join(<file>)` looking for a literal
925        // `./..\caixa-teia>build.log` subdirectory and fails at resolve time
926        // with a non-self-locating `No such file or directory` error far
927        // from the source caixa.lisp.
928        //
929        // The lacre pipeline embeds the value verbatim in its per-dep
930        // content-address (`conteudo: format!("path:{caminho}")`,
931        // caixa-resolver/src/resolve.rs:189), so a `<` / `>` byte lands in
932        // the BLAKE3 closure and rides downstream as part of the build's
933        // identity. The bytes carry a second class of hazard the prior
934        // separator-shaped arms don't: every typed-string slot whose value
935        // ever flows verbatim into a shell-spawned subprocess (the caixa-
936        // resolver's `git clone` invocation, a future `feira tofu` shell-
937        // out, a future operator-side `nix flake check` spawn) is the
938        // canonical CRLF-at-subprocess-argument / shell-metachar injection
939        // surface that every peer single-token-shaped typed slot already
940        // closes. The peer path-shaped axis `[crate::render::is_gateway_api_http_path]`
941        // (caixa-core/src/render.rs:506) rejects `<` / `>` as part of its
942        // eleven-byte RFC-3986-reserved set on `:entrada :paths`, and the
943        // peer git-ref-shaped axis `[crate::render::is_git_ref_name]` rejects
944        // `<` / `>` on `:fonte :tag` / `:fonte :branch` under the same
945        // shell-metachar-injection banner. The `:caminho` axis was the last
946        // typed string surface still admitting these two bytes; this arm
947        // closes the gap so the substrate-wide "no shell-redirection
948        // metacharacter anywhere in a typed string slot" invariant is now
949        // structurally consistent across every path-shaped typed surface.
950        //
951        // The arm fires AFTER the control-char arm + backslash arm because
952        // both prior arms carry more self-locating diagnostics on values
953        // that probe as both (`"..\foo<bar"` carries both `\` and `<` — the
954        // cross-OS-separator divergence is the load-bearing axis, so the
955        // backslash arm wins; `"../foo\n<bar"` carries both LF and `<` —
956        // the POSIX-syscall-rejected byte is the load-bearing axis, so the
957        // control-char arm wins). The arm fires BEFORE the trailing-`/` arm
958        // because the embedded redirection byte is the more semantic-
959        // locating axis on probe-as-both values (`"../foo</"` ends in `/`
960        // but the load-bearing diagnostic is the embedded `<` shell-
961        // redirection — the trailing `/` is the secondary observation, and
962        // an author who removes the `<` is likely to also tab-strip the
963        // trailing separator).
964        for &b in caminho.as_bytes() {
965            if b == b'<' || b == b'>' {
966                return Err(DepError::fonte_caminho_shell_redirection(nome, caminho, b));
967            }
968        }
969        // Reproducibility gate's shell-pipe arm. The e457141 shell-redirection
970        // arm closes the `<` / `>` input/output redirection sentinels; `|`
971        // (`0x7C`) is the orthogonal shell-pipe sentinel — same paste-from-
972        // shell-prompt footgun class, different syntactic surface. POSIX
973        // `std::path::Path` treats `|` as a literal path-component byte (so
974        // `../caixa-teia|tee` is one directory named literally
975        // `../caixa-teia|tee`, sibling of `.` and `..`), but every interactive
976        // shell (bash / zsh / fish / nushell) lexes `|` as the pipe operator
977        // — a `:caminho "../caixa-teia | grep foo"` (the canonical "I copied a
978        // `ls ../caixa-teia | grep` line out of a shell-history block and
979        // forgot to trim the pipeline tail" footgun) or `:caminho
980        // "../foo||bar"` (the symmetric "I copied a `cmd-a || cmd-b` short-
981        // circuit OR line" idiom) silently passes every prior arm because
982        // `Path::is_absolute` returns false on `..`, `|` is neither a leading-
983        // byte sentinel nor a control byte nor `\` nor `<` / `>`, and the
984        // value's last byte isn't `/`. The resolver folds the value through
985        // `Path::new(caminho).join(<file>)` looking for a literal
986        // `./../caixa-teia | grep foo` subdirectory and fails at resolve time
987        // with a non-self-locating `No such file or directory` error far
988        // from the source caixa.lisp.
989        //
990        // The lacre pipeline embeds the value verbatim in its per-dep
991        // content-address (`conteudo: format!("path:{caminho}")`,
992        // caixa-resolver/src/resolve.rs:189), so a `|` byte lands in the
993        // BLAKE3 closure and rides downstream as part of the build's identity
994        // into every shell-spawned subprocess (the caixa-resolver's `git
995        // clone` invocation, a future `feira tofu` shell-out, a future
996        // operator-side `nix flake check` spawn) as the canonical CRLF-at-
997        // subprocess-argument / shell-metachar injection surface every peer
998        // single-token-shaped typed slot already closes. The peer path-shaped
999        // axis [`crate::render::is_gateway_api_http_path`]
1000        // (caixa-core/src/render.rs:506) rejects `|` as part of its eleven-
1001        // byte RFC-3986-reserved set on `:entrada :paths`. The `:caminho`
1002        // axis was the last typed path-string surface still admitting this
1003        // byte; this arm closes the gap so the substrate-wide "no shell-
1004        // composition metacharacter anywhere in a typed string slot that
1005        // flows verbatim into a shell-spawned subprocess" invariant extends
1006        // from shell-redirection (`<` / `>`) to shell-pipe (`|`) on the
1007        // `:caminho` axis.
1008        //
1009        // The arm fires AFTER the shell-redirection arm because the prior
1010        // arm's two-byte `byte: u8` payload is the more self-locating axis on
1011        // values that probe as both (`"../caixa-teia<input|tee"` carries both
1012        // `<` and `|` — the input-redirection-paste idiom is the load-bearing
1013        // root-cause edit, so `FonteCaminhoShellRedirection` wins; same
1014        // cascade discipline every prior `:caminho` arm establishes). The arm
1015        // fires BEFORE the trailing-`/` arm because the embedded pipe byte is
1016        // the more semantic-locating axis on probe-as-both values
1017        // (`"../foo|tee/"` ends in `/` but the load-bearing diagnostic is the
1018        // embedded `|` shell-pipe — the trailing `/` is the secondary
1019        // observation, and an author who removes the `|` is likely to also
1020        // tab-strip the trailing separator).
1021        for &b in caminho.as_bytes() {
1022            if b == b'|' {
1023                return Err(DepError::fonte_caminho_shell_pipe(nome, caminho));
1024            }
1025        }
1026        // Reproducibility gate's shell-command-separator arm. The 124106f
1027        // shell-pipe arm closes the `|` byte; `;` (`0x3B`) is the orthogonal
1028        // shell-command-separator sentinel — same paste-from-shell-prompt
1029        // footgun class, different syntactic surface. POSIX `std::path::Path`
1030        // treats `;` as a literal path-component byte (so
1031        // `../caixa-teia;rm -rf /` is one directory named literally
1032        // `../caixa-teia;rm -rf /`, sibling of `.` and `..`), but every
1033        // interactive shell (bash / zsh / fish / nushell) lexes `;` as the
1034        // sequential-command terminator that fires the next command
1035        // regardless of the prior command's exit status — a `:caminho
1036        // "../caixa-teia; rm -rf build"` (the canonical "I pasted a shell
1037        // one-liner that chained a cleanup tail after the directory name"
1038        // footgun) or `:caminho "../foo;;bar"` (the symmetric "I copied a
1039        // POSIX `case` arm's `;;` terminator into the middle of a path"
1040        // idiom) silently passes every prior arm because `Path::is_absolute`
1041        // returns false on `..`, `;` is neither a leading-byte sentinel nor a
1042        // control byte nor `\` nor `<` / `>` nor `|`, and the value's last
1043        // byte isn't `/`. The resolver folds the value through
1044        // `Path::new(caminho).join(<file>)` looking for a literal
1045        // `./../caixa-teia; rm -rf build` subdirectory and fails at resolve
1046        // time with a non-self-locating `No such file or directory` error far
1047        // from the source caixa.lisp.
1048        //
1049        // The lacre pipeline embeds the value verbatim in its per-dep
1050        // content-address (`conteudo: format!("path:{caminho}")`,
1051        // caixa-resolver/src/resolve.rs:189), so a `;` byte lands in the
1052        // BLAKE3 closure and rides downstream as part of the build's identity
1053        // into every shell-spawned subprocess (the caixa-resolver's `git
1054        // clone` invocation, a future `feira tofu` shell-out, a future
1055        // operator-side `nix flake check` spawn) as the canonical
1056        // shell-metachar injection surface every peer single-token-shaped
1057        // typed slot already closes. The peer path-shaped axis
1058        // [`crate::render::is_gateway_api_http_path`]
1059        // (caixa-core/src/render.rs:506) rejects `;` as part of its eleven-
1060        // byte RFC-3986-reserved set on `:entrada :paths`. The `:caminho`
1061        // axis was the last typed path-string surface still admitting this
1062        // byte; this arm closes the gap so the substrate-wide "no shell-
1063        // composition metacharacter anywhere in a typed string slot that
1064        // flows verbatim into a shell-spawned subprocess" invariant extends
1065        // from shell-pipe (`|`) to shell-command-separator (`;`) on the
1066        // `:caminho` axis.
1067        //
1068        // The arm fires AFTER the shell-pipe arm because the prior arm's
1069        // canonical-cmd-a-|-cmd-b shape is the more common shell-history
1070        // paste idiom on values that probe as both (`"../caixa-teia | tee;
1071        // rm"` carries both `|` and `;` — the pipeline-tail paste is the
1072        // load-bearing root-cause edit, so `FonteCaminhoShellPipe` wins; same
1073        // cascade discipline every prior `:caminho` arm establishes). The arm
1074        // fires BEFORE the trailing-`/` arm because the embedded
1075        // command-separator byte is the more semantic-locating axis on
1076        // probe-as-both values (`"../foo;rm/"` ends in `/` but the
1077        // load-bearing diagnostic is the embedded `;` shell-command-
1078        // separator — the trailing `/` is the secondary observation, and an
1079        // author who removes the `;` is likely to also tab-strip the trailing
1080        // separator).
1081        for &b in caminho.as_bytes() {
1082            if b == b';' {
1083                return Err(DepError::fonte_caminho_shell_semicolon(nome, caminho));
1084            }
1085        }
1086        // Reproducibility gate's shell-background / logical-AND arm. The
1087        // 05c358e shell-command-separator arm closes the `;` byte; `&`
1088        // (`0x26`) is the orthogonal shell-background / list-AND sentinel
1089        // — same paste-from-shell-prompt footgun class, different
1090        // syntactic surface. POSIX `std::path::Path` treats `&` as a
1091        // literal path-component byte (so `../caixa-teia & sleep 1` is
1092        // one directory named literally `../caixa-teia & sleep 1`,
1093        // sibling of `.` and `..`), but every interactive shell
1094        // (bash / zsh / fish / nushell) lexes `&` two ways:
1095        //
1096        //   - Single `&` as the background-task terminator that detaches
1097        //     the prior command into the background and returns control
1098        //     to the prompt immediately (the canonical `cmd &` idiom
1099        //     every long-running pipeline uses);
1100        //   - Double `&&` as the logical-AND list operator that fires
1101        //     the next command only if the prior command succeeded (the
1102        //     canonical `make && make install` idiom every build script
1103        //     carries).
1104        //
1105        // A `:caminho "../caixa-teia & sleep 1"` (the canonical "I
1106        // pasted a `cd path & sleep 1` background-launch into the
1107        // `:caminho` slot" footgun) or `:caminho "../caixa-teia && make"`
1108        // (the symmetric "I copied a `cd path && make` build chain"
1109        // idiom) silently passes every prior arm because
1110        // `Path::is_absolute` returns false on `..`, `&` is neither a
1111        // leading-byte sentinel nor a control byte nor `\` nor
1112        // `<` / `>` nor `|` nor `;`, and the value's last byte isn't `/`.
1113        // The resolver folds the value through
1114        // `Path::new(caminho).join(<file>)` looking for a literal
1115        // `./../caixa-teia & sleep 1` subdirectory and fails at resolve
1116        // time with a non-self-locating `No such file or directory`
1117        // error far from the source caixa.lisp.
1118        //
1119        // The lacre pipeline embeds the value verbatim in its per-dep
1120        // content-address (`conteudo: format!("path:{caminho}")`,
1121        // caixa-resolver/src/resolve.rs:189), so an `&` byte lands in
1122        // the BLAKE3 closure and rides downstream as part of the build's
1123        // identity into every shell-spawned subprocess (the
1124        // caixa-resolver's `git clone` invocation, a future `feira tofu`
1125        // shell-out, a future operator-side `nix flake check` spawn) as
1126        // the canonical shell-metachar injection surface every peer
1127        // single-token-shaped typed slot already closes. The peer
1128        // path-shaped axis [`crate::render::is_gateway_api_http_path`]
1129        // (caixa-core/src/render.rs:506) rejects `&` as part of its
1130        // eleven-byte RFC-3986-reserved set on `:entrada :paths`. The
1131        // `:caminho` axis was the last typed path-string surface still
1132        // admitting this byte; this arm closes the gap so the
1133        // substrate-wide "no shell-composition metacharacter anywhere
1134        // in a typed string slot that flows verbatim into a
1135        // shell-spawned subprocess" invariant extends from
1136        // shell-command-separator (`;`) to shell-background /
1137        // logical-AND (`&`) on the `:caminho` axis.
1138        //
1139        // The arm fires AFTER the shell-command-separator arm because
1140        // the prior arm's `cmd-a; cmd-b` shape is the more common
1141        // shell-history paste idiom on values that probe as both
1142        // (`"../caixa-teia; rm & sleep"` carries both `;` and `&` — the
1143        // command-separator-tail paste is the load-bearing root-cause
1144        // edit, so `FonteCaminhoShellSemicolon` wins; same cascade
1145        // discipline every prior `:caminho` arm establishes). The arm
1146        // fires BEFORE the trailing-`/` arm because the embedded
1147        // background / list-AND byte is the more semantic-locating axis
1148        // on probe-as-both values (`"../foo&bar/"` ends in `/` but the
1149        // load-bearing diagnostic is the embedded `&` shell-background
1150        // / logical-AND metachar — the trailing `/` is the secondary
1151        // observation, and an author who removes the `&` is likely to
1152        // also tab-strip the trailing separator).
1153        for &b in caminho.as_bytes() {
1154            if b == b'&' {
1155                return Err(DepError::fonte_caminho_shell_background(nome, caminho));
1156            }
1157        }
1158        // Reproducibility gate's shell-command-substitution arm. The
1159        // e12e4f3 shell-background / logical-AND arm closes the `&`
1160        // byte; the backtick (`0x60`) is the orthogonal POSIX legacy
1161        // command-substitution sentinel — every POSIX shell (sh /
1162        // bash / zsh / dash / ksh / fish / nushell) lexes the byte as
1163        // the canonical legacy wrapper that runs the enclosed command
1164        // and substitutes its standard-output verbatim into the
1165        // surrounding word (a `whoami` wrapped in backticks expands
1166        // to the current user's name; a `cat /etc/passwd` wrapped in
1167        // backticks expands to the file's contents — the canonical
1168        // CWE-78 shell-command-injection vector every shell-side
1169        // hardening guide enumerates first). POSIX
1170        // `std::path::Path` treats backtick as a literal path-
1171        // component byte (so `../caixa-teia/<backtick>whoami<backtick>`
1172        // is one directory named literally that, sibling of `.` and
1173        // `..`).
1174        //
1175        // A `:caminho "../caixa-teia/<backtick>whoami<backtick>"` (the
1176        // canonical "I pasted a shell one-liner carrying a backticked
1177        // `whoami` command-substitution expansion into the `:caminho`
1178        // slot" footgun) or `:caminho "<backtick>pwd<backtick>/caixa-
1179        // teia"` (the symmetric "I copied a `<backtick>pwd<backtick>/
1180        // path` working-directory expansion") silently passes every
1181        // prior arm because `Path::is_absolute` returns false on
1182        // `..`, the backtick byte is neither a leading-byte sentinel
1183        // (the f4efe9c `FonteCaminhoVarExpansion` arm catches the
1184        // modern `$()` form at leading position only; backtick is
1185        // the orthogonal legacy form) nor a control byte nor `\` nor
1186        // `<` / `>` nor `|` nor `;` nor `&`, and the value's last
1187        // byte isn't `/`. The resolver folds the value through
1188        // `Path::new(caminho).join(<file>)` looking for a literal
1189        // subdirectory whose name embeds the backticked token and
1190        // fails at resolve time with a non-self-locating `No such
1191        // file or directory` error far from the source caixa.lisp.
1192        //
1193        // The lacre pipeline embeds the value verbatim in its per-
1194        // dep content-address (`conteudo: format!("path:{caminho}")`,
1195        // caixa-resolver/src/resolve.rs:189), so a backtick byte
1196        // lands in the BLAKE3 closure and rides downstream as part
1197        // of the build's identity into every shell-spawned
1198        // subprocess (the caixa-resolver's `git clone` invocation, a
1199        // future `feira tofu` shell-out, a future operator-side
1200        // `nix flake check` spawn) as the canonical shell-metachar
1201        // injection surface every peer single-token-shaped typed
1202        // slot already closes. The peer path-shaped axis
1203        // [`crate::render::is_gateway_api_http_path`]
1204        // (caixa-core/src/render.rs:506) rejects backtick as part of
1205        // its eleven-byte RFC-3986-reserved set on `:entrada
1206        // :paths`. The `:caminho` axis was the last typed path-
1207        // string surface still admitting this byte; this arm closes
1208        // the gap so the substrate-wide "no shell-composition
1209        // metacharacter anywhere in a typed string slot that flows
1210        // verbatim into a shell-spawned subprocess" invariant
1211        // extends from shell-background / logical-AND (`&`) to
1212        // shell-command-substitution (backtick) on the `:caminho`
1213        // axis.
1214        //
1215        // The arm fires AFTER the shell-background arm because the
1216        // prior arm's `cmd & sleep` shape is the more common shell-
1217        // history paste idiom on values that probe as both (a
1218        // `"../caixa-teia & <backtick>whoami<backtick>"` carries
1219        // both `&` and a backtick — the background-launch tail is
1220        // the load-bearing root-cause edit, so
1221        // `FonteCaminhoShellBackground` wins; same cascade
1222        // discipline every prior `:caminho` arm establishes). The
1223        // arm fires BEFORE the trailing-`/` arm because the
1224        // embedded command-substitution byte is the more semantic-
1225        // locating axis on probe-as-both values (a
1226        // `"../<backtick>whoami<backtick>/"` ends in `/` but the
1227        // load-bearing diagnostic is the embedded backtick shell-
1228        // command-substitution metachar — the trailing `/` is the
1229        // secondary observation, and an author who removes the
1230        // backtick is likely to also tab-strip the trailing
1231        // separator).
1232        for &b in caminho.as_bytes() {
1233            if b == b'`' {
1234                return Err(DepError::fonte_caminho_shell_command_substitution(
1235                    nome, caminho,
1236                ));
1237            }
1238        }
1239        // Reproducibility gate's shell-glob arm. The c4d62b3 shell-command-
1240        // substitution arm closes the backtick byte; `*` (`0x2A`) and `?`
1241        // (`0x3F`) are the orthogonal POSIX glob-expansion sentinels — same
1242        // paste-from-shell-prompt footgun class, different syntactic surface.
1243        // Every POSIX shell (sh / bash / zsh / dash / ksh / fish / nushell)
1244        // lexes `*` and `?` as pathname-expansion wildcards: `*` matches any
1245        // sequence of characters in a path component (including the empty
1246        // sequence), `?` matches exactly one character. POSIX
1247        // `std::path::Path` treats both bytes as literal path-component bytes
1248        // (so `../caixa-teia/*.lisp` is one directory named literally
1249        // `../caixa-teia/*.lisp`, sibling of `.` and `..`).
1250        //
1251        // A `:caminho "../caixa-teia/*"` (the canonical "I pasted a
1252        // `ls ../caixa-teia/*` shell-listing one-liner into the `:caminho`
1253        // slot" footgun) or `:caminho "../foo?"` (the symmetric "I copied a
1254        // `rm foo?` single-char-wildcard removal idiom") silently passes
1255        // every prior arm because `Path::is_absolute` returns false on `..`,
1256        // `*` / `?` are neither leading-byte sentinels nor control bytes nor
1257        // `\` nor `<` / `>` nor `|` nor `;` nor `&` nor backtick, and the
1258        // value's last byte isn't `/`. The resolver folds the value through
1259        // `Path::new(caminho).join(<file>)` looking for a literal
1260        // `./../caixa-teia/*` subdirectory and fails at resolve time with a
1261        // non-self-locating `No such file or directory` error far from the
1262        // source caixa.lisp.
1263        //
1264        // The lacre pipeline embeds the value verbatim in its per-dep
1265        // content-address (`conteudo: format!("path:{caminho}")`,
1266        // caixa-resolver/src/resolve.rs:189), so a `*` or `?` byte lands in
1267        // the BLAKE3 closure and rides downstream as part of the build's
1268        // identity into every shell-spawned subprocess (the caixa-resolver's
1269        // `git clone` invocation, a future `feira tofu` shell-out, a future
1270        // operator-side `nix flake check` spawn) as the canonical
1271        // shell-metachar / pathname-expansion surface every peer
1272        // single-token-shaped typed slot already closes. The peer path-shaped
1273        // axis [`crate::render::is_gateway_api_http_path`]
1274        // (caixa-core/src/render.rs:506) rejects `*` and `?` as part of its
1275        // eleven-byte RFC-3986-reserved set on `:entrada :paths`. The
1276        // `:caminho` axis was the last typed path-string surface still
1277        // admitting these two bytes; this arm closes the gap so the
1278        // substrate-wide "no shell-composition / glob-expansion
1279        // metacharacter anywhere in a typed string slot that flows verbatim
1280        // into a shell-spawned subprocess" invariant extends from
1281        // shell-command-substitution (backtick) to glob-expansion
1282        // (`*` / `?`) on the `:caminho` axis.
1283        //
1284        // The arm fires AFTER the backtick arm because the prior arm's
1285        // CWE-78 shell-command-injection vector is the load-bearing
1286        // diagnostic on values that probe as both (a `"../`whoami`/*"`
1287        // carries both backtick and `*` — the command-substitution paste
1288        // is the load-bearing root-cause edit, so
1289        // `FonteCaminhoShellCommandSubstitution` wins; same cascade
1290        // discipline every prior `:caminho` arm establishes). The arm
1291        // fires BEFORE the trailing-`/` arm because the embedded glob
1292        // byte is the more semantic-locating axis on probe-as-both values
1293        // (`"../foo*/"` ends in `/` but the load-bearing diagnostic is the
1294        // embedded `*` glob metachar — the trailing `/` is the secondary
1295        // observation, and an author who removes the `*` is likely to
1296        // also tab-strip the trailing separator).
1297        for &b in caminho.as_bytes() {
1298            if b == b'*' || b == b'?' {
1299                return Err(DepError::fonte_caminho_shell_glob(nome, caminho, b));
1300            }
1301        }
1302        // Reproducibility gate's shell-subshell-grouping arm. The cf9034b
1303        // shell-glob arm closes the `*` / `?` pathname-expansion sentinels;
1304        // `(` (`0x28`) and `)` (`0x29`) are the orthogonal POSIX subshell-
1305        // grouping sentinels — same paste-from-shell-prompt footgun class,
1306        // different syntactic surface. Every POSIX shell (sh / bash / zsh /
1307        // dash / ksh / fish / nushell) lexes the parenthesis pair as the
1308        // subshell-grouping operator: `(<cmd>)` runs `<cmd>` in a child
1309        // shell with a fresh environment scope (the canonical sandboxing
1310        // idiom every shell-history `(cd <path> && <cmd>)` one-liner uses
1311        // to scope a `cd` to one subshell without disturbing the parent's
1312        // working directory), and `$(<cmd>)` is the modern Bourne
1313        // command-substitution shape the upstream f4efe9c
1314        // `FonteCaminhoVarExpansion` arm closes the leading `$` byte of —
1315        // the closing `)` byte completes that substitution shape and must
1316        // be refused on the same axis (peer with the
1317        // [`crate::render::is_git_repo_url`] 3b99147 arm that closes the
1318        // same byte-pair on the sibling `:fonte :repo` axis under the
1319        // same shell-subshell-grouping + RFC-3986-sub-delims banner).
1320        // POSIX `std::path::Path` treats both bytes as literal path-
1321        // component bytes (so `../caixa-teia/(date)` is one directory
1322        // named literally `../caixa-teia/(date)`, sibling of `.` and
1323        // `..`).
1324        //
1325        // A `:caminho "../caixa-teia/$(date)/build"` (the canonical "I
1326        // pasted a `cd ../caixa-teia/$(date)/build` shell-history one-
1327        // liner whose modern command-substitution expansion lands the
1328        // current date as a subdirectory name" footgun) or `:caminho
1329        // "../(cd foo && pwd)/caixa-teia"` (the symmetric "I copied a
1330        // `(cd foo && pwd)` subshell-grouping working-directory probe
1331        // idiom") silently passes every prior arm because
1332        // `Path::is_absolute` returns false on `..`, `(` / `)` are
1333        // neither leading-byte sentinels nor control bytes nor `\` nor
1334        // `<` / `>` nor `|` nor `;` nor `&` nor backtick nor `*` / `?`,
1335        // and the value's last byte isn't `/`. The resolver folds the
1336        // value through `Path::new(caminho).join(<file>)` looking for a
1337        // literal `./../caixa-teia/$(date)/build` subdirectory and fails
1338        // at resolve time with a non-self-locating `No such file or
1339        // directory` error far from the source caixa.lisp.
1340        //
1341        // The lacre pipeline embeds the value verbatim in its per-dep
1342        // content-address (`conteudo: format!("path:{caminho}")`,
1343        // caixa-resolver/src/resolve.rs:189), so a `(` or `)` byte lands
1344        // in the BLAKE3 closure and rides downstream as part of the
1345        // build's identity into every shell-spawned subprocess (the
1346        // caixa-resolver's `git clone` invocation, a future `feira tofu`
1347        // shell-out, a future operator-side `nix flake check` spawn) as
1348        // the canonical shell-metachar / subshell-grouping surface every
1349        // peer single-token-shaped typed slot already closes. The peer
1350        // git-source axis [`crate::render::is_git_repo_url`] (3b99147)
1351        // rejects the same byte pair on `:fonte :repo` under the same
1352        // shell-subshell-grouping / RFC-3986-sub-delims banner. The
1353        // `:caminho` axis was the last typed path-string surface still
1354        // admitting these two bytes;
1355        // this arm closes the gap so the substrate-wide "no shell-
1356        // composition metacharacter anywhere in a typed string slot that
1357        // flows verbatim into a shell-spawned subprocess" invariant
1358        // extends from shell-glob (`*` / `?`) to shell-subshell-grouping
1359        // (`(` / `)`) on the `:caminho` axis. Together with the f4efe9c
1360        // leading-`$` arm, the typed `:caminho` accepted set now
1361        // structurally excludes the entire modern Bourne
1362        // command-substitution surface — leading `$` closes the
1363        // leading byte of every `$(<cmd>)` shape, this arm closes the
1364        // trailing `)` boundary.
1365        //
1366        // The arm fires AFTER the shell-glob arm because the prior arm's
1367        // `*` / `?` pathname-expansion shape is the more common shell-
1368        // history paste idiom on values that probe as both
1369        // (`"../caixa-teia/*(date)"` carries both `*` and `(` — the
1370        // glob-paste-tail is the load-bearing root-cause edit, so
1371        // `FonteCaminhoShellGlob` wins; same cascade discipline every
1372        // prior `:caminho` arm establishes). The arm fires BEFORE the
1373        // trailing-`/` arm because the embedded subshell-grouping byte
1374        // is the more semantic-locating axis on probe-as-both values
1375        // (`"../foo(date)/"` ends in `/` but the load-bearing diagnostic
1376        // is the embedded `(` shell-subshell-grouping metachar — the
1377        // trailing `/` is the secondary observation, and an author who
1378        // removes the `(` is likely to also tab-strip the trailing
1379        // separator).
1380        for &b in caminho.as_bytes() {
1381            if b == b'(' || b == b')' {
1382                return Err(DepError::fonte_caminho_shell_subshell_grouping(
1383                    nome, caminho, b,
1384                ));
1385            }
1386        }
1387        // Reproducibility gate's shell-brace-expansion arm. The 0633c91
1388        // shell-subshell-grouping arm closes `(` / `)`; `{` (`0x7b`) and
1389        // `}` (`0x7d`) are the orthogonal shell-brace-expansion /
1390        // URI-Template-placeholder byte pair — same paste-from-shell-
1391        // prompt + paste-from-templated-doc footgun class, different
1392        // syntactic surface. Every POSIX-derived shell that implements
1393        // brace expansion (bash / zsh / ksh / fish; the canonical
1394        // `mkdir -p ../{caixa-teia,caixa-helm,caixa-flux}` /
1395        // `cp file{,.bak}` idiom every shell-history block carries)
1396        // expands `{a,b,c}` to the cross-product of its comma-separated
1397        // members and `{1..10}` to the integer range; RFC 6570 reserves
1398        // the matched pair for URI Template placeholders (the canonical
1399        // `https://{host}/{org}/{repo}` substitution shape every
1400        // OpenAPI / Swagger / Postman / GitHub Octokit client /
1401        // Helm chart-URL fragment / Mustache `{{org}}` doubled-brace
1402        // form carries), and Tera / Jinja2 / Handlebars / Go html/template
1403        // every IaC tool (Helm, Kustomize, Terraform's `${var}` cousin
1404        // shape) emit. POSIX `std::path::Path` treats both bytes as
1405        // literal path-component bytes (so `../{caixa-teia,caixa-helm}`
1406        // is one directory named literally `../{caixa-teia,caixa-helm}`,
1407        // sibling of `.` and `..`).
1408        //
1409        // A `:caminho "../{caixa-teia,caixa-helm}/build"` (the canonical
1410        // "I pasted a `cd ../{caixa-teia,caixa-helm}` shell brace-
1411        // expansion one-liner that fans across two siblings" footgun)
1412        // or `:caminho "../{{org}}/caixa-teia"` (the symmetric "I copied
1413        // a `{{org}}` Mustache / Helm template placeholder out of a
1414        // README quick-start and forgot to substitute") silently passes
1415        // every prior arm because `Path::is_absolute` returns false on
1416        // `..`, `{` / `}` are neither leading-byte sentinels nor control
1417        // bytes nor `\` nor `<` / `>` nor `|` nor `;` nor `&` nor
1418        // backtick nor `*` / `?` nor `(` / `)`, and the value's last
1419        // byte isn't `/`. The resolver folds the value through
1420        // `Path::new(caminho).join(<file>)` looking for a literal
1421        // `./../{caixa-teia,caixa-helm}/build` subdirectory and fails
1422        // at resolve time with a non-self-locating `No such file or
1423        // directory` error far from the source caixa.lisp.
1424        //
1425        // The lacre pipeline embeds the value verbatim in its per-dep
1426        // content-address (`conteudo: format!("path:{caminho}")`,
1427        // caixa-resolver/src/resolve.rs:189), so a `{` or `}` byte
1428        // lands in the BLAKE3 closure and rides downstream as part of
1429        // the build's identity into every shell-spawned subprocess
1430        // (the caixa-resolver's `git clone` invocation, a future
1431        // `feira tofu` shell-out, a future operator-side `nix flake
1432        // check` spawn) as the canonical shell-metachar / brace-
1433        // expansion surface every peer single-token-shaped typed
1434        // slot already closes. The peer git-source axis
1435        // [`crate::render::is_git_repo_url`] (42d8f9d — the URI Template
1436        // placeholder arm) rejects the same byte pair on `:fonte :repo`
1437        // under the same RFC-3986-'delims' / RFC-6570-URI-Template /
1438        // shell-brace-expansion banner. The `:caminho` axis was the last
1439        // typed path-string surface still admitting these two bytes;
1440        // this arm closes the gap so the substrate-wide "no shell-
1441        // composition metacharacter anywhere in a typed string slot
1442        // that flows verbatim into a shell-spawned subprocess"
1443        // invariant extends from shell-subshell-grouping (`(` / `)`)
1444        // to shell-brace-expansion (`{` / `}`) on the `:caminho` axis,
1445        // and the typed `:caminho` accepted set now also structurally
1446        // excludes the URI Template / templating-engine placeholder
1447        // surface that would silently round-trip through any
1448        // downstream IaC templating-engine layer.
1449        //
1450        // The arm fires AFTER the shell-subshell-grouping arm because
1451        // the prior arm's `(` / `)` shape is the more semantic-locating
1452        // axis on values that probe as both (`"../{cd foo}(date)"`
1453        // carries both `{` and `(` — the parenthesis-pair is the
1454        // load-bearing modern-Bourne-command-substitution surface the
1455        // prior arm closes; same cascade discipline every prior
1456        // `:caminho` arm establishes). The arm fires BEFORE the
1457        // trailing-`/` arm because the embedded brace-expansion byte
1458        // is the more semantic-locating axis on probe-as-both values
1459        // (`"../{caixa-teia,caixa-helm}/"` ends in `/` but the
1460        // load-bearing diagnostic is the embedded `{` brace-expansion
1461        // metachar — the trailing `/` is the secondary observation,
1462        // and an author who removes the `{` is likely to also tab-
1463        // strip the trailing separator).
1464        for &b in caminho.as_bytes() {
1465            if b == b'{' || b == b'}' {
1466                return Err(DepError::fonte_caminho_shell_brace_expansion(
1467                    nome, caminho, b,
1468                ));
1469            }
1470        }
1471        // Reproducibility gate's shell-bracket-expansion arm. The 598b770
1472        // shell-brace-expansion arm closes `{` / `}`; `[` (`0x5b`) and
1473        // `]` (`0x5d`) are the orthogonal POSIX glob-character-class /
1474        // shell-`test`-builtin byte pair — same paste-from-shell-prompt
1475        // footgun class, different syntactic surface. Every POSIX shell
1476        // (sh / bash / zsh / dash / ksh / fish / nushell) lexes the
1477        // bracket pair as the glob character-class operator: `[abc]`
1478        // matches one of `a`, `b`, `c`; `[a-z]` matches any lowercase
1479        // ASCII letter; `[^x]` negates (the canonical
1480        // `ls *.[ch]` C-source-file glob and the `cd ../[a-z]*`
1481        // lowercase-sibling glob every shell-history block carries —
1482        // the orthogonal axis to the cf9034b `*` / `?` shell-glob arm
1483        // closing the unbounded pathname-expansion sentinels). The
1484        // bracket pair additionally carries the POSIX `test` /
1485        // `[` builtin command (`[ -d ../caixa-teia ] && cd ...` —
1486        // the canonical idiom every shell-script conditional uses) and
1487        // bash's `[[ ... ]]` extended-test grammar. Beyond shell, the
1488        // bracket pair is the TOML inline-array delimiter
1489        // (`features = ["a", "b"]` — the canonical paste-from-Cargo-
1490        // manifest cross-idiom-leak vector), the YAML flow-sequence
1491        // delimiter (`paths: [/a, /b]` — the canonical paste-from-
1492        // values.yaml cross-idiom leak), the JSON array delimiter,
1493        // and the POSIX-ERE / PCRE bracket-expression / character-
1494        // class anchor (the canonical paste-from-regex-doc shape).
1495        // POSIX `std::path::Path` treats both bytes as literal path-
1496        // component bytes (so `../[caixa-teia]` is one directory
1497        // named literally `../[caixa-teia]`, sibling of `.` and
1498        // `..`).
1499        //
1500        // A `:caminho "../caixa-[a-z]/build"` (the canonical "I
1501        // pasted a `cd ../caixa-[a-z]/build` glob-character-class
1502        // one-liner that matches every lowercase-sibling-suffix
1503        // sibling directory" footgun), `:caminho "../[caixa-teia]/
1504        // build"` (the symmetric "I pasted a TOML inline-array /
1505        // YAML flow-sequence shape out of an aligned manifest"
1506        // idiom), or `:caminho "../caixa-[ch]"` (the canonical
1507        // `*.[ch]` C-source character-class paste-from-shell-history
1508        // shape) silently passes every prior arm because
1509        // `Path::is_absolute` returns false on `..`, `[` / `]` are
1510        // neither leading-byte sentinels nor control bytes nor `\`
1511        // nor `<` / `>` nor `|` nor `;` nor `&` nor backtick nor
1512        // `*` / `?` nor `(` / `)` nor `{` / `}`, and the value's
1513        // last byte isn't `/`. The resolver folds the value through
1514        // `Path::new(caminho).join(<file>)` looking for a literal
1515        // `./../caixa-[a-z]/build` subdirectory and fails at resolve
1516        // time with a non-self-locating `No such file or directory`
1517        // error far from the source caixa.lisp.
1518        //
1519        // The lacre pipeline embeds the value verbatim in its per-dep
1520        // content-address (`conteudo: format!("path:{caminho}")`,
1521        // caixa-resolver/src/resolve.rs:189), so a `[` or `]` byte
1522        // lands in the BLAKE3 closure and rides downstream as part of
1523        // the build's identity into every shell-spawned subprocess
1524        // (the caixa-resolver's `git clone` invocation, a future
1525        // `feira tofu` shell-out, a future operator-side `nix flake
1526        // check` spawn) as the canonical shell-metachar / glob-
1527        // character-class / TOML-array surface every peer single-
1528        // token-shaped typed slot already closes. The `:caminho` axis
1529        // was the last typed path-string surface still admitting
1530        // these two bytes; this arm closes the gap so the substrate-
1531        // wide "no shell-composition metacharacter anywhere in a
1532        // typed string slot that flows verbatim into a shell-spawned
1533        // subprocess" invariant extends from shell-brace-expansion
1534        // (`{` / `}`) to shell-bracket-expansion (`[` / `]`) on the
1535        // `:caminho` axis. Together with the cf9034b `*` / `?` arm,
1536        // the typed `:caminho` accepted set now structurally excludes
1537        // the entire POSIX pathname-expansion / glob surface —
1538        // unbounded glob (`*` / `?`) AND bounded character-class
1539        // (`[abc]` / `[a-z]`).
1540        //
1541        // The arm fires AFTER the shell-brace-expansion arm because
1542        // the prior arm's `{` / `}` shape is the more semantic-
1543        // locating axis on values that probe as both
1544        // (`"../{a,b}[ch]"` carries both `{` and `[` — the brace-
1545        // expansion fan is the load-bearing root-cause edit, so
1546        // `FonteCaminhoShellBraceExpansion` wins; same cascade
1547        // discipline every prior `:caminho` arm establishes). The arm
1548        // fires BEFORE the trailing-`/` arm because the embedded
1549        // bracket-expansion byte is the more semantic-locating axis
1550        // on probe-as-both values (`"../[a-z]/"` ends in `/` but the
1551        // load-bearing diagnostic is the embedded `[` glob-character-
1552        // class metachar — the trailing `/` is the secondary
1553        // observation, and an author who removes the `[` is likely
1554        // to also tab-strip the trailing separator).
1555        for &b in caminho.as_bytes() {
1556            if b == b'[' || b == b']' {
1557                return Err(DepError::fonte_caminho_shell_bracket_expansion(
1558                    nome, caminho, b,
1559                ));
1560            }
1561        }
1562        // Reproducibility gate's shell-quote-grouping arm. The 986963b
1563        // shell-bracket-expansion arm closes `[` / `]`; `'` (`0x27`) and
1564        // `"` (`0x22`) are the orthogonal POSIX shell-string-literal
1565        // delimiter pair — same paste-from-shell-prompt footgun class,
1566        // different syntactic surface. Every POSIX shell (sh / bash /
1567        // zsh / dash / ksh / fish / nushell) lexes the pair as the
1568        // string-literal quoting operator: `'…'` is the strong
1569        // (no-expansion) single-quoted string and `"…"` is the weak
1570        // (variable-/command-substitution-preserving) double-quoted
1571        // string — the canonical `cd '../caixa-teia'` shell-history
1572        // idiom every path-with-embedded-whitespace paste block carries,
1573        // and the symmetric `git clone "$REPO"` weak-quoted CI-manifest
1574        // shape. Beyond shell, the two bytes carry the JSON string-literal
1575        // delimiter (`"key": "value"` — the canonical paste-from-JSON-
1576        // config cross-idiom-leak vector), the YAML double-quoted +
1577        // single-quoted flow-scalar delimiters (`path: "../caixa-teia"`
1578        // — the canonical paste-from-values.yaml / paste-from-K8s-YAML-
1579        // manifest cross-idiom leak), the TOML basic + literal string
1580        // delimiters (`path = "../caixa-teia"` — the canonical paste-
1581        // from-Cargo-manifest cross-idiom-leak vector), the tatara-lisp
1582        // string-literal delimiter itself (`(:caminho "../caixa-teia")`
1583        // — the canonical "I copied the entire `:caminho "..."` slot
1584        // rather than just the string body" author-surface footgun),
1585        // and RFC 3986 §2.2's `gen-delims` / `sub-delims` grammar which
1586        // excludes both bytes from the `unreserved / pct-encoded /
1587        // sub-delims / ":" / "@"` `pchar` production. POSIX
1588        // `std::path::Path` treats both bytes as literal path-component
1589        // bytes (so `../"caixa-teia"` is one directory named literally
1590        // `../"caixa-teia"`, sibling of `.` and `..`).
1591        //
1592        // A `:caminho "'../caixa-teia'"` (the canonical "I pasted a
1593        // `cd '../caixa-teia'` shell-history one-liner whose strong-
1594        // quoting preserved the sibling-workspace path verbatim across
1595        // the whitespace paste boundary" footgun), `:caminho
1596        // "\"../caixa-teia\""` (the symmetric weak-quoted paste-from-
1597        // JSON / paste-from-YAML flow-scalar / paste-from-TOML basic-
1598        // string / paste-from-tatara-lisp string-literal cross-idiom-
1599        // leak shape), or `:caminho "../\"caixa-teia\""` (the embedded-
1600        // quote "I pasted a JSON key-value pair fragment into the
1601        // middle of the path" idiom) silently passes every prior arm
1602        // because `Path::is_absolute` returns false on `..` / `'` /
1603        // `"`, `'` / `"` are neither leading-byte sentinels nor
1604        // control bytes nor `\` nor `<` / `>` nor `|` nor `;` nor `&`
1605        // nor backtick nor `*` / `?` nor `(` / `)` nor `{` / `}` nor
1606        // `[` / `]`, and the value's last byte isn't `/`. The resolver
1607        // folds the value through `Path::new(caminho).join(<file>)`
1608        // looking for a literal `./'../caixa-teia'` subdirectory and
1609        // fails at resolve time with a non-self-locating `No such file
1610        // or directory` error far from the source caixa.lisp.
1611        //
1612        // The lacre pipeline embeds the value verbatim in its per-dep
1613        // content-address (`conteudo: format!("path:{caminho}")`,
1614        // caixa-resolver/src/resolve.rs:189), so a `'` or `"` byte
1615        // lands in the BLAKE3 closure and rides downstream as part of
1616        // the build's identity into every shell-spawned subprocess
1617        // (the caixa-resolver's `git clone` invocation, a future
1618        // `feira tofu` shell-out, a future operator-side `nix flake
1619        // check` spawn) as the canonical shell-metachar / string-
1620        // literal-delimiter surface every peer single-token-shaped
1621        // typed slot already closes. The peer `:fonte :repo` axis
1622        // closes both bytes under the same shell-quote-grouping /
1623        // RFC-3986-sub-delims banner (e7a109f `'` shell-single-quote
1624        // + 4267d8b `"` shell-double-quote on `is_git_repo_url`). The
1625        // `:caminho` axis was the last typed path-string surface
1626        // still admitting these two bytes; this arm closes the gap
1627        // so the substrate-wide "no shell-composition metacharacter
1628        // anywhere in a typed string slot that flows verbatim into a
1629        // shell-spawned subprocess" invariant extends from shell-
1630        // bracket-expansion (`[` / `]`) to shell-quote-grouping (`'`
1631        // / `"`) on the `:caminho` axis. Together with the peer
1632        // JSON / YAML / TOML string-literal delimiters closing at
1633        // this arm and the 598b770 `{` / `}` brace-expansion arm
1634        // closing the templating-engine-placeholder boundary, the
1635        // typed `:caminho` accepted set now structurally excludes
1636        // the entire cross-config-DSL string-literal / templating
1637        // paste-from-aligned-manifest cross-idiom-leak surface that
1638        // would silently round-trip through any downstream JSON /
1639        // YAML / TOML / HCL / tatara-lisp parsing layer.
1640        //
1641        // The arm fires AFTER the shell-bracket-expansion arm because
1642        // the prior arm's `[` / `]` shape is the more semantic-
1643        // locating axis on values that probe as both (`"../[a-z]'x'"`
1644        // carries both `[` and `'` — the glob-character-class
1645        // expansion is the load-bearing root-cause edit, so
1646        // `FonteCaminhoShellBracketExpansion` wins; same cascade
1647        // discipline every prior `:caminho` arm establishes). The arm
1648        // fires BEFORE the trailing-`/` arm because the embedded
1649        // quote-grouping byte is the more semantic-locating axis on
1650        // probe-as-both values (`"../'caixa-teia'/"` ends in `/` but
1651        // the load-bearing diagnostic is the embedded `'` shell-
1652        // string-literal metachar — the trailing `/` is the secondary
1653        // observation, and an author who removes the `'` is likely to
1654        // also tab-strip the trailing separator).
1655        for &b in caminho.as_bytes() {
1656            if b == b'\'' || b == b'"' {
1657                return Err(DepError::fonte_caminho_shell_quote_grouping(
1658                    nome, caminho, b,
1659                ));
1660            }
1661        }
1662        // Reproducibility gate's shell-comment / URL-fragment / YAML-comment arm.
1663        // The d14cbc5 shell-quote-grouping arm closes `'` / `"`; `#` (`0x23`) is
1664        // the orthogonal "byte at which four distinct downstream parsers all
1665        // truncate the value at the first occurrence" surface, and no prior arm
1666        // has covered it on the `:caminho` axis. Every POSIX shell (sh / bash /
1667        // zsh / dash / ksh / fish / nushell) lexes an unquoted `#` at the head
1668        // of a word (or after unquoted whitespace) as the comment-lead: from
1669        // that byte to the end of the physical line is a comment discarded
1670        // before command parsing (`cd ../caixa-teia  # legacy sibling` — the
1671        // canonical paste-from-shell-history-with-trailing-annotation shape
1672        // every operator-notebook and CI-manifest carries; POSIX.1-2017 §2.3
1673        // Token Recognition step 6). YAML 1.2 §6.6 makes `#` the comment lead
1674        // at any position preceded by whitespace or at line-start (`path:
1675        // ../caixa-teia  # pin` — the canonical paste-from-values.yaml /
1676        // paste-from-K8s-manifest cross-idiom-leak shape). tatara-lisp itself
1677        // treats `;` as the comment-lead but a growing number of consumer
1678        // config-DSL layers (HCL, Terraform, Nix flake attributes, .env
1679        // dotenv-style files, gitconfig / .gitignore, ini / TOML) use `#` as
1680        // the comment-lead too — the pair extends the cross-config-DSL
1681        // paste-idiom surface the d14cbc5 quote-grouping arm and the 598b770
1682        // brace-expansion arm already cover on adjacent axes. RFC 3986 §3.5
1683        // reserves `#` as the URL fragment-identifier delimiter (the canonical
1684        // paste-from-browser-address-bar `github.com/foo/bar#readme` /
1685        // `github.com/foo/bar#L42` permalink shape, and the symmetric
1686        // Nix-flake-ref cross-idiom leak `github:foo/bar#packageName` where
1687        // `#` selects a flake output — the same axis the peer
1688        // [`crate::render::is_git_repo_url`] closes on the `:fonte :repo`
1689        // surface at a68f818 with the same downstream-drops-the-tail
1690        // rationale).
1691        //
1692        // POSIX `std::path::Path` treats `#` as a literal path-component byte,
1693        // so a `:caminho "../caixa-teia # legacy sibling"` (the canonical
1694        // paste-from-shell-history-with-trailing-annotation footgun),
1695        // `:caminho "../caixa-teia  # pin"` (the symmetric YAML flow-scalar
1696        // paste-with-trailing-comment shape), or `:caminho "../caixa-teia
1697        // #readme"` (the URL fragment paste-from-browser-address-bar shape)
1698        // silently passes every prior arm because `Path::is_absolute` returns
1699        // false on `..`, `#` is neither a leading-byte sentinel nor a control
1700        // byte nor `\` nor `<` / `>` nor `|` nor `;` nor `&` nor backtick nor
1701        // `*` / `?` nor `(` / `)` nor `{` / `}` nor `[` / `]` nor `'` / `"`,
1702        // and the value's last byte isn't `/`. The resolver folds the value
1703        // through `Path::new(caminho).join(<file>)` looking for a literal
1704        // subdirectory named `../caixa-teia # legacy sibling` and fails at
1705        // resolve time with a non-self-locating `No such file or directory`
1706        // error far from the source caixa.lisp — while every downstream
1707        // shell / YAML / URL parser silently truncates the value at the `#`
1708        // byte to `../caixa-teia`, so a `feira tofu` shell-out to a
1709        // `cd '{caminho}'` command line and a `nix flake check` invocation on
1710        // an emitted YAML `path:` scalar disagree with the resolver on which
1711        // directory the value names. Two workstations whose downstream
1712        // shell / YAML / URL parsing layers differ in unquoted-`#`
1713        // recognition emit divergent build artifacts for the byte-identical
1714        // caixa.lisp value.
1715        //
1716        // The lacre pipeline embeds the value verbatim in its per-dep
1717        // content-address (`conteudo: format!("path:{caminho}")`,
1718        // caixa-resolver/src/resolve.rs:189), so the byte lands in the BLAKE3
1719        // closure and rides downstream as part of the build's identity into
1720        // every shell-spawned subprocess (the caixa-resolver's `git clone`
1721        // invocation, a future `feira tofu` shell-out, a future operator-side
1722        // `nix flake check` spawn) as the canonical shell-metachar /
1723        // comment-lead / URL-fragment-delimiter surface every peer
1724        // single-token-shaped typed slot already closes. The peer `:fonte
1725        // :repo` axis closes the byte under the URL-fragment-identifier
1726        // banner (a68f818 `#` on `is_git_repo_url`); the `:caminho` axis was
1727        // the last typed path-string surface still admitting the byte. This
1728        // arm closes the gap so the substrate-wide "no shell-composition
1729        // metacharacter / comment-lead / URL-fragment-delimiter anywhere in a
1730        // typed string slot that flows verbatim into a shell-spawned
1731        // subprocess or downstream YAML / URL parser" invariant extends from
1732        // shell-quote-grouping (`'` / `"`) to shell-comment / URL-fragment
1733        // (`#`) on the `:caminho` axis. Together with the peer JSON / YAML /
1734        // TOML string-literal delimiters the d14cbc5 quote-grouping arm
1735        // closes and the 598b770 `{` / `}` brace-expansion arm closes on the
1736        // templating-engine-placeholder boundary, the typed `:caminho`
1737        // accepted set now structurally excludes the entire
1738        // paste-with-trailing-annotation / paste-from-URL-permalink /
1739        // paste-from-YAML-comment cross-idiom-leak surface that would
1740        // silently round-trip through any downstream shell / YAML / URL /
1741        // dotenv / gitconfig / HCL parsing layer to a different value than
1742        // the resolver's `Path::join` sees.
1743        //
1744        // The arm fires AFTER the shell-quote-grouping arm because the prior
1745        // arm's `'` / `"` shape is the more semantic-locating axis on values
1746        // that probe as both (`"../'x'#pin"` carries both `'` and `#` — the
1747        // shell-string-literal-delimiter is the load-bearing root-cause edit,
1748        // so `FonteCaminhoShellQuoteGrouping` wins; same cascade discipline
1749        // every prior `:caminho` arm establishes). The arm fires BEFORE the
1750        // trailing-`/` arm because the embedded comment-lead / fragment-
1751        // delimiter byte is the more semantic-locating axis on probe-as-both
1752        // values (`"../caixa-teia#pin/"` ends in `/` but the load-bearing
1753        // diagnostic is the embedded `#` — the trailing `/` is the secondary
1754        // observation, and an author who removes the `#pin` fragment is
1755        // likely to also tab-strip the trailing separator).
1756        for &b in caminho.as_bytes() {
1757            if b == b'#' {
1758                return Err(DepError::fonte_caminho_shell_comment(nome, caminho, b));
1759            }
1760        }
1761        // Reproducibility gate's URL-percent-encoding-escape arm. The 6622063
1762        // shell-comment arm closes the `#` URL-fragment-identifier byte; `%`
1763        // (`0x25`) is the orthogonal RFC 3986 §2.1 URL percent-encoding-escape
1764        // byte — the mandatory encoding mechanism for every byte outside the
1765        // `unreserved` alphanumeric / `-` / `.` / `_` / `~` set, and `%`
1766        // itself must be percent-encoded as `%25` to appear literally inside
1767        // a URL value. The byte carries three distinct render-determinism
1768        // hazards on the `:caminho` axis, no prior arm has covered it, and
1769        // the peer `:fonte :repo` axis (a323db8 `%` on `is_git_repo_url`)
1770        // already closes the same byte under the same URL-percent-encoding
1771        // banner — the `:caminho` axis was the last typed path-string surface
1772        // still admitting the byte.
1773        //
1774        // First, the paste-from-browser-address-bar percent-encoded-space
1775        // footgun: an author copies `../caixa%20teia` out of a URL-encoded
1776        // README hyperlink / a browser address bar / a percent-encoded
1777        // permalink expecting `%20` to decode to a literal space at the
1778        // filesystem layer. POSIX `std::path::Path` treats the byte as a
1779        // literal path-component byte, so `Path::join` looks for a literal
1780        // `./../caixa%20teia` subdirectory and fails at resolve time with a
1781        // non-self-locating `No such file or directory` error far from the
1782        // source caixa.lisp — while the author's mental model was
1783        // `../caixa teia`, the decoded shape. Two authors whose only
1784        // difference is percent-encoding presence resolve to two distinct
1785        // BLAKE3 closures (`path:../caixa%20teia` vs `path:../caixa teia`)
1786        // for what they intended as the byte-identical sibling-workspace
1787        // dep. The lacre pipeline embeds the value verbatim in its per-dep
1788        // content-address (`conteudo: format!("path:{caminho}")`,
1789        // caixa-resolver/src/resolve.rs:189), so the divergence rides
1790        // downstream into the BLAKE3 closure and locks the substrate's
1791        // "the lacre is the build's identity" contract (CAIXA-SDLC §III.2)
1792        // to the wrong encoding — the same THEORY.md §V.2 render-
1793        // determinism vector every prior `:caminho` arm protects.
1794        //
1795        // Second, the printf-format-specifier lead footgun: `%` is the C /
1796        // POSIX printf format-directive lead-in (`%s`, `%d`, `%02x`, the
1797        // canonical `printf "path=%s\n" ../caixa-teia` invocation every
1798        // shell-diagnostic one-liner carries) and the printf builtin is
1799        // wired into every POSIX shell (bash / zsh / dash / ksh / busybox
1800        // ash) as the format-string lead. A `:caminho "../caixa-%s-teia"`
1801        // value flowing into any future `feira` verb that shells out with a
1802        // printf-formatted path template silently gets reinterpreted as a
1803        // format-directive rather than a literal byte — the canonical
1804        // CWE-134 format-string-injection vector.
1805        //
1806        // Third, the bash-job-control-specifier lead footgun: bash / zsh /
1807        // ksh reserve `%N` at word-start as the job-control specifier —
1808        // `%1` names "job 1", `%%` names "the current job", `%foo` names
1809        // "the most recent job whose command started with `foo`". A future
1810        // `feira` verb that invokes `kill %1` on a caminho-scoped
1811        // subprocess would silently redirect the signal to a wrong target.
1812        //
1813        // Beyond the three shell-side hazards, `%` is a first-class parser
1814        // byte in three cross-config-DSL layers the substrate's paste-idiom
1815        // surface routinely crosses: YAML 1.2 §6.8.1 lexes `%` at
1816        // line-start as the directive lead (`%YAML 1.2` / `%TAG` — a
1817        // `:caminho "%YAML/1.2/../caixa-teia"` paste from a top-of-doc
1818        // YAML directive block silently trips the YAML directive parser on
1819        // any downstream emitted YAML manifest); Prometheus / Grafana
1820        // template syntax uses `%(var)s` as the substitution lead; and Nix
1821        // interpolation uses `${var}` (not `%`) but Envsubst /
1822        // Kubernetes / OpenShift template layers use `%VAR%` as the
1823        // Windows-shell env-var-reference lead — the paste-from-`.bat` /
1824        // paste-from-PowerShell-`%env:PATH%` cross-idiom leak.
1825        //
1826        // The three malformed-`%HH` classes documented on the peer
1827        // `is_git_repo_url` `%` arm (a323db8) apply here too:
1828        //
1829        //   - The lone-`%` malformed-escape shape (`"../caixa-teia%foo"`
1830        //     where `%` isn't followed by two hex digits) — every WHATWG-
1831        //     conformant URL parser rejects the value at parse time per
1832        //     RFC 3986 §2.1, but the byte rides into the lacre before
1833        //     the resolver subprocess crosses the URL-parser boundary.
1834        //   - The over-encoded path-separator shape (`"../caixa%2Fteia"`
1835        //     intending the `%2F` as the URL encoding of `/`) locks a
1836        //     `path:../caixa%2Fteia` BLAKE3 closure that diverges from
1837        //     the byte-identical `path:../caixa/teia` form.
1838        //   - The double-encoded shape (`"../caixa%2520teia"` — the `%25`
1839        //     already itself an encoded `%`, so the intent was likely a
1840        //     literal `%20` that survived one round-trip through a
1841        //     URL-encoder that shouldn't have run) locks a triply-
1842        //     divergent closure across the encoded / once-decoded /
1843        //     twice-decoded chain.
1844        //
1845        // POSIX `std::path::Path` treats the byte as a literal path-
1846        // component byte, so a `:caminho "../caixa%20teia"` (the canonical
1847        // paste-from-browser-address-bar percent-encoded-space footgun),
1848        // `:caminho "%YAML/../caixa-teia"` (the symmetric paste-from-YAML-
1849        // directive-block cross-idiom leak), or `:caminho
1850        // "../caixa-%s-teia"` (the printf-format-specifier paste-from-
1851        // shell-diagnostic-one-liner shape) silently passes every prior arm
1852        // because `Path::is_absolute` returns false on `..`, `%` is neither
1853        // a leading-byte sentinel nor a control byte nor `\` nor `<` / `>`
1854        // nor `|` nor `;` nor `&` nor backtick nor `*` / `?` nor `(` / `)`
1855        // nor `{` / `}` nor `[` / `]` nor `'` / `"` nor `#`, and the
1856        // value's last byte isn't `/`. The resolver folds the value through
1857        // `Path::new(caminho).join(<file>)` looking for a literal
1858        // subdirectory named `../caixa%20teia` and fails at resolve time
1859        // with a non-self-locating `No such file or directory` error far
1860        // from the source caixa.lisp — while every downstream URL parser /
1861        // shell printf builtin / YAML directive parser silently
1862        // reinterprets the byte to a different value than the resolver's
1863        // `Path::join` sees. Two workstations whose downstream URL / shell
1864        // / YAML layers differ in `%HH` recognition emit divergent build
1865        // artifacts for the byte-identical caixa.lisp value.
1866        //
1867        // The lacre pipeline embeds the value verbatim in its per-dep
1868        // content-address (`conteudo: format!("path:{caminho}")`, caixa-
1869        // resolver/src/resolve.rs:189), so the byte lands in the BLAKE3
1870        // closure and rides into every shell-spawned subprocess (the
1871        // resolver's `git clone`, a future `feira tofu` shell-out, a
1872        // future operator-side `nix flake check` spawn) as the canonical
1873        // URL-percent-encoding-escape / printf-format-specifier / bash-
1874        // job-control-specifier surface every peer single-token-shaped
1875        // typed slot already closes. This arm closes the gap so the
1876        // substrate-wide "no URL-percent-encoding-escape / printf-format-
1877        // specifier / job-control-specifier / YAML-directive-lead byte
1878        // anywhere in a typed string slot that flows verbatim into a
1879        // shell-spawned subprocess or downstream URL / printf / YAML
1880        // parser" invariant extends from shell-comment / URL-fragment
1881        // (`#` — 6622063) to URL-percent-encoding-escape (`%`) on the
1882        // `:caminho` axis.
1883        //
1884        // The arm fires AFTER the shell-comment arm because the prior
1885        // arm's `#` shape is the more semantic-locating axis on values
1886        // that probe as both (`"../caixa%20teia#pin"` carries both `%`
1887        // and `#` — the URL-fragment-identifier is the load-bearing
1888        // downstream-truncation edit, so `FonteCaminhoShellComment` wins;
1889        // same cascade discipline every prior `:caminho` arm establishes).
1890        // The arm fires BEFORE the trailing-`/` arm because the embedded
1891        // percent-encoding-escape byte is the more semantic-locating axis
1892        // on probe-as-both values (`"../caixa%20teia/"` ends in `/` but
1893        // the load-bearing diagnostic is the embedded `%` percent-
1894        // encoding-escape — the trailing `/` is the secondary observation,
1895        // and an author who decodes the `%20` to a literal space is
1896        // likely to also tab-strip the trailing separator).
1897        for &b in caminho.as_bytes() {
1898            if b == b'%' {
1899                return Err(DepError::fonte_caminho_url_percent_encoding(
1900                    nome, caminho, b,
1901                ));
1902            }
1903        }
1904        // Reproducibility gate's embedded-`$` shell-variable-expansion /
1905        // command-substitution / arithmetic-expansion arm. The f4efe9c
1906        // leading-`$` arm at line 540 routes `caminho.starts_with('$')`
1907        // through `FonteCaminhoVarExpansion` under the leading-byte-
1908        // sentinel host-layout-leak banner (peer with the b94fd83
1909        // absolute / a5c248e tilde leading-byte arms), but the arm
1910        // fires only at position 0 — a `:caminho "../foo$HOME/bar"`
1911        // (embedded `$HOME` in a nested path segment — the canonical
1912        // paste-from-`ls ../foo$HOME/bar`-shell-one-liner footgun where
1913        // an author copies a partially-substituted shell one-liner and
1914        // the leading segment is a literal `../foo` while the mid
1915        // segment carries the un-substituted `$HOME` template), a
1916        // `:caminho "../foo${WORKSPACE}/bar"` (the symmetric braced-CI-
1917        // manifest paste-from-`.gitlab-ci.yml` / paste-from-GitHub-
1918        // Actions-workflow shape), a `:caminho "../foo$(whoami)/bar"`
1919        // (the paste-from-shell-prompt command-substitution idiom), or
1920        // a `:caminho "../foo$((1+2))/bar"` (the arithmetic-expansion
1921        // idiom) silently passes every prior arm because
1922        // `Path::is_absolute` returns false on `..`, `$` is neither a
1923        // leading-byte sentinel (the f4efe9c arm fires only at position
1924        // 0) nor a control byte nor `\` nor `<` / `>` nor `|` nor `;`
1925        // nor `&` nor backtick nor `*` / `?` nor `(` / `)` nor `{` /
1926        // `}` nor `[` / `]` nor `'` / `"` nor `#` nor `%`, and the
1927        // value's last byte isn't `/`. Note that `$(...)` command-
1928        // substitution and `$((...))` arithmetic-expansion each carry
1929        // an embedded `(` byte that the 0633c91 shell-subshell-grouping
1930        // arm catches structurally at the earlier `(` position — but
1931        // an author who reaches for the sh-brace-substitution
1932        // `${VAR}` or the bare `$VAR` shape carries only the `$` byte,
1933        // which no prior arm covers. This arm closes the last
1934        // positional gap on the `$` byte on the `:caminho` axis so
1935        // every position — leading (`FonteCaminhoVarExpansion`) and
1936        // embedded (`FonteCaminhoShellVariableExpansion`) — is
1937        // structurally rejected.
1938        //
1939        // Every POSIX shell (sh / bash / zsh / dash / ksh / busybox
1940        // ash / fish / nushell) lexes `$` as the variable-expansion /
1941        // command-substitution / arithmetic-expansion operator per
1942        // POSIX.1-2017 §2.6 (Word Expansions): `$<name>` (Parameter
1943        // Expansion) expands a named variable, `${<name>}` (Parameter
1944        // Expansion braced form) does the same with an explicit token
1945        // boundary, `$(<cmd>)` (Command Substitution modern form,
1946        // `` `<cmd>` `` legacy form which the c370458 backtick arm
1947        // already closes) runs a subshell and substitutes its stdout,
1948        // and `$((<expr>))` (Arithmetic Expansion) evaluates an
1949        // arithmetic expression. Every form is a host-layout /
1950        // environment-state / shell-subprocess-side-effect leak when
1951        // the byte lands in a value the resolver passes to a shell-
1952        // spawned subprocess. Beyond the POSIX shell layer, `$` is
1953        // the Nix `${var}` string-interpolation lead (the paste-from-
1954        // `flake.nix` / paste-from-`.nix`-attribute cross-idiom leak
1955        // where an author copies `"${pkgs.hello}/bin/hello"` out of a
1956        // nix expression), the Make `$(var)` / `$@` / `$<` automatic-
1957        // variable lead (the paste-from-`Makefile` shape), the
1958        // JavaScript / TypeScript template-literal `${expr}` interp
1959        // lead (the paste-from-JS-template-string idiom in a
1960        // multi-lang-monorepo where a `path` attribute gets copied out
1961        // of a `package.json` script or a Vite config), the envsubst /
1962        // Kubernetes / OpenShift template `${VAR}` interp lead (the
1963        // paste-from-Helm-values / paste-from-K8s-manifest cross-idiom
1964        // leak), the PHP variable lead (`$_GET`, `$_ENV` — the paste-
1965        // from-`.php`-config footgun), the Perl scalar-variable lead
1966        // (`$foo`), the SASS / SCSS variable lead (`$primary-color`),
1967        // and the SQL bind-parameter lead in PostgreSQL / SQLite
1968        // (`$1`, `$2` — the paste-from-`.sql`-migration idiom). The
1969        // cross-idiom paste-footgun surface is broader than any single
1970        // shell layer — `$` is a first-class parser byte in nearly
1971        // every config / templating / build-system DSL the substrate's
1972        // paste-idiom surface routinely crosses. The peer `:fonte
1973        // :repo` axis closes the byte under the shell-variable-
1974        // expansion / URL-sub-delim banner (b9d187c `$` on
1975        // `is_git_repo_url`), the peer `:fonte :tag` / `:fonte :branch`
1976        // axes close `$` as part of `is_git_ref_name`'s printable-
1977        // ASCII-restricted grammar (`git check-ref-format` rejects the
1978        // byte outright), and the peer `:entrada :paths` axis closes
1979        // `$` via `is_gateway_api_http_path`'s eleven-byte RFC-3986-
1980        // reserved set. The `:caminho` axis was the last typed path-
1981        // string surface still admitting `$` at positions other than 0.
1982        //
1983        // POSIX `std::path::Path` treats `$` as a literal path-
1984        // component byte, so `:caminho "../foo$HOME/bar"` silently
1985        // routes through `Path::new(caminho).join(<file>)` looking for
1986        // a literal `./{caminho}` subdirectory that fails at resolve
1987        // time with a non-self-locating `No such file or directory`
1988        // error far from the source caixa.lisp. But every downstream
1989        // shell / envsubst / Nix / Make / K8s-template parser silently
1990        // reinterprets the byte to a different value than the
1991        // resolver's `Path::join` sees — so a `feira tofu` shell-out
1992        // to a `cd '{caminho}'` command line, a `nix flake check`
1993        // invocation on an emitted YAML `path:` scalar folded through
1994        // envsubst, or a `helm template` invocation with a
1995        // `values.yaml` `path: {caminho}` embedded in a `{{`-quoted
1996        // template all disagree with the resolver on which directory
1997        // the value names. Two workstations whose downstream shell /
1998        // envsubst / Nix / Make / K8s-template parsing layers differ
1999        // in `$VAR` recognition (or, worse, expand the byte against
2000        // divergent environments — Alice's `$HOME=/home/alice`, Bob's
2001        // `$HOME=/home/bob`) emit divergent build artifacts for the
2002        // byte-identical caixa.lisp value. Even in the case where the
2003        // resolver strictly does NOT expand `$VAR` (the current
2004        // implementation) the divergence still bites at the lacre-
2005        // identity axis: the lacre pipeline embeds the value verbatim
2006        // in its per-dep content-address (`conteudo:
2007        // format!("path:{caminho}")`, caixa-resolver/src/resolve.rs:189),
2008        // so `path:../foo$HOME/bar` locks a BLAKE3 closure distinct
2009        // from the byte-identical-semantic `path:../foo/home/alice/bar`
2010        // one author would have produced by substituting the literal
2011        // value at author time, defeating the THEORY.md §V.2 render-
2012        // determinism contract on the same axis every prior `:caminho`
2013        // arm protects.
2014        //
2015        // Beyond the render-determinism / host-layout-leak vectors,
2016        // `$` at any position in a value flowing verbatim into a
2017        // shell-spawned subprocess is the canonical CWE-78 shell-
2018        // command-injection surface every peer single-token-shaped
2019        // typed slot already closes. A `:caminho "../foo$(whoami)/bar"`
2020        // that rides into a future `feira tofu` shell-out as `cd
2021        // '../foo$(whoami)/bar'` gets substituted by the shell at
2022        // subprocess-argument-expansion time even inside single quotes
2023        // in fewer positions than one might expect (the substitution
2024        // fires only outside single-quoting per POSIX §2.2.2, but
2025        // eval-style wrappers and `sh -c` layers that route the value
2026        // through re-parsing round-trip the substitution — the same
2027        // vector the c370458 backtick arm closes at the sibling
2028        // command-substitution-legacy-form surface). Every future
2029        // `feira` verb that shells out with a `caminho`-formatted
2030        // subprocess argument silently inherits this substitution
2031        // vector unless the typed slot's accepted set structurally
2032        // excludes the byte.
2033        //
2034        // Frontier inspiration: OTP's `gen_server` return-value grammar
2035        // rejects mid-tuple shell-metachar bytes by construction —
2036        // `{noreply, State}` never carries a raw `$` because the
2037        // Erlang term type system has no notion of "string that gets
2038        // shelled out"; caixa's typed slots inherit the same
2039        // structural discipline (types-are-theorems, the compounding
2040        // mandate's leverage-point-1) by refusing values that would
2041        // silently reinterpret at any downstream layer. Peer with
2042        // Unison's content-addressed code (no ambient environment —
2043        // every reference is a hash, no `$VAR` substitution possible)
2044        // and Pony's capabilities (a path capability that carries a
2045        // `$` would be ill-typed at the reference layer).
2046        //
2047        // The arm fires AFTER the URL-percent-encoding-escape arm (the
2048        // e3558fa `%` arm) because a value carrying both `%` and `$`
2049        // (`"../foo%20$HOME/bar"` — the canonical "I pasted a percent-
2050        // encoded space next to a `$HOME` template") surfaces the
2051        // narrower URL-encoding diagnostic first — the paste-from-
2052        // browser-address-bar shape is the load-bearing self-locating
2053        // edit on every probe-as-both value; same cascade discipline
2054        // every prior `:caminho` arm establishes (a323db8 %  before
2055        // this arm, this arm before trailing-`/`). The arm fires
2056        // BEFORE the trailing-`/` arm because the embedded shell-
2057        // variable-expansion byte is the more semantic-locating axis
2058        // on probe-as-both values (`"../foo$HOME/bar/"` ends in `/`
2059        // but the load-bearing diagnostic is the embedded `$` — the
2060        // trailing `/` is the secondary observation, and an author
2061        // who substitutes the `$HOME` template with a literal value is
2062        // likely to also tab-strip the trailing separator).
2063        for &b in caminho.as_bytes() {
2064            if b == b'$' {
2065                return Err(DepError::fonte_caminho_shell_variable_expansion(
2066                    nome, caminho, b,
2067                ));
2068            }
2069        }
2070        // Reproducibility gate's shell-history-expansion / RFC-3986-sub-delims
2071        // arm. The immediate-predecessor `$` embedded arm closes the shell-
2072        // variable-expansion / command-substitution byte; `!` (`0x21`) is the
2073        // orthogonal POSIX shell-history-expansion sentinel every interactive
2074        // shell with history enabled (bash / ksh / zsh's `bashcompat` /
2075        // csh / tcsh) lexes as the history-expansion prefix: `!command`
2076        // re-runs the most recent history entry beginning with `command`,
2077        // `!!` re-runs the prior command verbatim, `!$` substitutes the
2078        // last word of the prior command, `!:N` substitutes the Nth word,
2079        // `^old^new` rewrites the prior command's `old` to `new` (the
2080        // canonical set of `set -o histexpand` operators bash's default
2081        // interactive session enables). Beyond the shell-history layer,
2082        // RFC 3986 §2.2 lists `!` in the `sub-delims` set (the URL grammar
2083        // admits the byte inside a path segment, but every WHATWG-conformant
2084        // special-scheme URL parser percent-encodes it inside a query
2085        // component via the 'special-query percent-encode set' the peer
2086        // `is_git_repo_url` `*` / `(` / `)` / `'` arms close on); the byte
2087        // is also the C / C++ / Rust / JavaScript / Python bang-operator
2088        // (logical-negation prefix — the paste-from-source-code idiom where
2089        // an author copies `!path.exists()` out of a Rust snippet and the
2090        // trailing punctuation crosses the string-literal boundary); the
2091        // canonical English-typography emphasis / exclamation mark (the
2092        // paste-from-prose enthusiasm-form idiom where an author writes
2093        // `:caminho "../caixa-teia!"` expecting the substrate to coerce it
2094        // to a kebab-case slug); and the Nix flake-ref import-attribute
2095        // `import ./foo.nix { … }` sibling operator surface.
2096        //
2097        // POSIX `std::path::Path` treats `!` as a literal path-component
2098        // byte, so a `:caminho "../caixa-teia!sudo"` (the canonical paste-
2099        // from-shell-history footgun where the author copies a `cd
2100        // ../caixa-teia && !sudo make install` one-liner from a quick-
2101        // start README and the trailing `!sudo` rides in verbatim as a
2102        // history-expansion reference), a `:caminho "../foo!!/bar"` (the
2103        // `!!` repeat-prior-command paste idiom), a `:caminho
2104        // "../caixa-teia!"` (the English-typography enthusiasm-form
2105        // paste-from-prose footgun), or a `:caminho "../foo!$"` (the
2106        // last-word-substitution shape) silently pass every prior arm
2107        // because `Path::is_absolute` returns false on `..`, `!` is neither
2108        // a leading-byte sentinel nor a control byte nor `\` nor `<` / `>`
2109        // nor `|` nor `;` nor `&` nor backtick nor `*` / `?` nor `(` / `)`
2110        // nor `{` / `}` nor `[` / `]` nor `'` / `"` nor `#` nor `%` nor `$`,
2111        // and the value's last byte isn't `/`. The resolver folds the value
2112        // through `Path::new(caminho).join(<file>)` looking for a literal
2113        // `./../caixa-teia!sudo` subdirectory and fails at resolve time
2114        // with a non-self-locating `No such file or directory` error far
2115        // from the source caixa.lisp — while every downstream interactive
2116        // shell with `set -o histexpand` reinterprets the byte as the
2117        // history-expansion prefix, and the failure mode forks per
2118        // consumer: a `feira tofu` shell-out to a `cd '{caminho}'` command
2119        // line executed under `bash -i` (the operator-notebook interactive
2120        // shell) substitutes the `!sudo` reference to the most recent
2121        // history entry starting with `sudo`, silently invoking whatever
2122        // privileged command that entry named.
2123        //
2124        // The lacre pipeline embeds the value verbatim in its per-dep
2125        // content-address (`conteudo: format!("path:{caminho}")`,
2126        // caixa-resolver/src/resolve.rs:189), so the byte lands in the
2127        // BLAKE3 closure and rides into every shell-spawned subprocess
2128        // (the resolver's `git clone`, a future `feira tofu` shell-out,
2129        // a future operator-side `nix flake check` spawn) as the
2130        // canonical shell-history-expansion / RFC-3986-sub-delims surface
2131        // every peer single-token-shaped typed slot already closes. The
2132        // peer `:fonte :repo` axis closes the byte under the same shell-
2133        // history-expansion / RFC-3986-sub-delims banner (7d53c68 `!` on
2134        // `is_git_repo_url`); the `:caminho` axis was the last typed
2135        // path-string surface still admitting the byte. This arm closes
2136        // the gap so the substrate-wide "no shell-composition
2137        // metacharacter / history-expansion sentinel anywhere in a typed
2138        // string slot that flows verbatim into a shell-spawned subprocess"
2139        // invariant extends from shell-variable-expansion (`$`) to shell-
2140        // history-expansion (`!`) on the `:caminho` axis. Together with
2141        // the peer c370458 backtick command-substitution-legacy-form arm
2142        // and the b9d187c-`$`-embedded-variable-expansion arm on the
2143        // sibling `:repo` axis, the typed `:caminho` accepted set now
2144        // structurally excludes every byte the POSIX shell §2.6 Word
2145        // Expansions section, §2.3 Token Recognition step 6, and every
2146        // history-expansion / brace-expansion / pathname-expansion /
2147        // parameter-expansion / command-substitution / arithmetic-
2148        // expansion operator lexes as a first-class parser byte.
2149        //
2150        // Frontier inspiration: Unison's content-addressed code (no
2151        // ambient environment — every reference is a hash, no `!<num>`
2152        // history-index substitution possible; the caixa substrate's
2153        // lacre discipline arrives at the same guarantee by refusing
2154        // bytes at manifest-parse time that would reinterpret against
2155        // ambient shell history state); Pony's capabilities (a path
2156        // capability that carries a `!` would be ill-typed at the
2157        // reference layer).
2158        //
2159        // The arm fires AFTER the shell-variable-expansion arm because a
2160        // value carrying both `$` and `!` (`"../foo$HOME/bar!sudo"` — the
2161        // canonical "I pasted a `$HOME`-templated path adjacent to a
2162        // trailing `!sudo` history-expansion") surfaces the narrower
2163        // shell-variable-expansion diagnostic first — the paste-from-CI-
2164        // manifest-with-`$VAR`-template shape is the load-bearing self-
2165        // locating edit on every probe-as-both value; same cascade
2166        // discipline every prior `:caminho` arm establishes. The arm
2167        // fires BEFORE the trailing-`/` arm because the embedded shell-
2168        // history-expansion byte is the more semantic-locating axis on
2169        // probe-as-both values (`"../foo!sudo/"` ends in `/` but the
2170        // load-bearing diagnostic is the embedded `!` — the trailing `/`
2171        // is the secondary observation, and an author who removes the
2172        // `!sudo` history reference is likely to also tab-strip the
2173        // trailing separator).
2174        for &b in caminho.as_bytes() {
2175            if b == b'!' {
2176                return Err(DepError::fonte_caminho_shell_history_expansion(
2177                    nome, caminho, b,
2178                ));
2179            }
2180        }
2181        // Reproducibility gate's shell-history-substitution / RFC-3986-unwise
2182        // / regex-anchor arm. The immediate-predecessor `!` arm closes the
2183        // POSIX `!command` / `!!` / `!$` history-expansion prefix; `^`
2184        // (`0x5E`) is the paired-operator half of the same bash-reference
2185        // §9.3 histexpand feature — the `^old^new^` "quick substitution"
2186        // form (POSIX bash rewrites the prior command's `old` string to
2187        // `new` and re-executes it, the canonical typo-correction one-
2188        // liner idiom `git clone <bad-url>` → `^bad^good` that pastes the
2189        // trailing substitution fragment verbatim into a `:caminho` value
2190        // when the author trims only the leading `git clone` prefix). The
2191        // peer `:fonte :repo` axis closes the byte under the same
2192        // shell-history-substitution / RFC-3986-unwise banner (49e142f `^`
2193        // on `is_git_repo_url`); the `:caminho` axis was the last typed
2194        // path-string surface still admitting the byte after 6a04767
2195        // landed the `!` arm.
2196        //
2197        // Beyond bash history-substitution, `^` carries five distinct
2198        // downstream-reinterpretation surfaces the typed slot's accepted
2199        // set must structurally exclude:
2200        //
2201        // 1. **RFC 3986 §2 'unwise' set** — the four-byte cross-transport
2202        //    layer set (`{`, `}`, `|`, `\`) plus `^` every URL parser is
2203        //    required to percent-encode-or-refuse at the wire boundary.
2204        //    The WHATWG URL spec's 'fragment percent-encode set' maps
2205        //    `^` → `%5E` at the query / fragment component transition;
2206        //    libcurl silently percent-encodes the byte on the wire, so a
2207        //    `:caminho "../foo^bar"` value the resolver's `Path::join`
2208        //    sees as a literal `./../foo^bar` subdirectory diverges from
2209        //    the byte-transformed `%5E` shape any downstream `feira tofu`
2210        //    curl-invocation or artifact-registry-fetch would emit — the
2211        //    canonical wire-boundary divergence vector the peer
2212        //    `{`, `}`, `|`, `\` `:caminho` arms already close (
2213        //    `FonteCaminhoShellBraceExpansion` at 598b770,
2214        //    `FonteCaminhoShellPipe` at the pipe arm,
2215        //    `FonteCaminhoBackslash` at the backslash arm).
2216        // 2. **Regex character-class negation prefix `[^abc]`** — the
2217        //    canonical paste-from-doc-regex-pipeline footgun where an
2218        //    author copies a `grep '[^abc]'` idiom from a docs quick-
2219        //    listing and the character-class negation byte rides in
2220        //    verbatim.
2221        // 3. **Bitwise XOR operator** in C / C++ / Rust / Python /
2222        //    JavaScript / Nix / Go — the paste-from-source-code idiom
2223        //    where an author copies an `x ^ y`-shaped expression out of
2224        //    a source snippet and the operator crosses the string-
2225        //    literal boundary.
2226        // 4. **Windows `cmd.exe` escape metacharacter** — the byte
2227        //    escapes the next character in a `cmd.exe` batch context (a
2228        //    peer of the backslash arm's Windows-separator-leak vector).
2229        //    A `:caminho "..^&whoami"` cross-platform paste-from-batch-
2230        //    file footgun reinterprets at every `cmd.exe`-spawned
2231        //    subprocess (the resolver's future Windows-runner shell-out,
2232        //    the operator's WinRM path, a future PowerShell-embedded
2233        //    invocation).
2234        // 5. **LaTeX / Markdown / BibTeX superscript operator** — the
2235        //    paste-from-typeset-doc footgun where a mathematical
2236        //    superscript notation (`x^2` / `M^T`) leaks from prose.
2237        //
2238        // POSIX `std::path::Path` treats `^` as a literal path-component
2239        // byte, so `:caminho "../foo^bar/baz"` (embedded quick-
2240        // substitution), `:caminho "../foo^"` (trailing history-
2241        // substitution-open shape), `:caminho "../[^a-z]/foo"` (regex-
2242        // negation-prefix paste from a grep pipeline; note the `[` / `]`
2243        // arm at 986963b fires first on this shape), or `:caminho
2244        // "../x^y"` (XOR-expression paste-from-source) all silently pass
2245        // every prior arm (`^` isn't `\` / `<` / `>` / `|` / `;` / `&` /
2246        // backtick / `*` / `?` / `(` / `)` / `{` / `}` / `[` / `]` / `'`
2247        // / `"` / `#` / `%` / `$` / `!`) and route through
2248        // `Path::new(caminho).join(<file>)` looking for a literal
2249        // `./{caminho}` subdirectory that fails at resolve time with a
2250        // non-self-locating `No such file or directory` error far from
2251        // the source caixa.lisp — while every downstream shell / curl /
2252        // regex / `cmd.exe` layer reinterprets the byte to its own
2253        // semantic.
2254        //
2255        // The lacre pipeline embeds the value verbatim in its per-dep
2256        // content-address (`conteudo: format!("path:{caminho}")`,
2257        // caixa-resolver/src/resolve.rs:189), so the byte lands in the
2258        // BLAKE3 closure and rides into every shell-spawned subprocess
2259        // (the resolver's `git clone`, a future `feira tofu` shell-out,
2260        // a future operator-side `nix flake check` spawn) as the
2261        // canonical shell-history-substitution / RFC-3986-unwise /
2262        // regex-negation surface every peer single-token-shaped typed
2263        // slot already closes. This arm together with the immediate-
2264        // predecessor `!` arm (6a04767) closes the full `set -o
2265        // histexpand` operator surface on the `:caminho` axis — the
2266        // `!command` / `!!` / `!$` prefix form via `!`, the `^old^new^`
2267        // quick-substitution form via `^` — so the substrate-wide "no
2268        // shell-history operator anywhere in a typed string slot that
2269        // flows verbatim into a shell-spawned subprocess" invariant
2270        // extends from the `!` prefix half to the `^` quick-substitution
2271        // half. Every peer bash-history operator now fails at manifest-
2272        // parse time with a self-locating diagnostic naming the offending
2273        // caixa.lisp rather than at resolve-time as a `Path::join`-
2274        // derived `No such file or directory` (harmless but non-self-
2275        // locating) or worse riding into a downstream `bash -i` context
2276        // that reinterprets the byte-pair against ambient history state.
2277        //
2278        // Frontier inspiration: bash reference §9.3 HISTORY EXPANSION
2279        // "Quick substitution. Repeat the previous command, replacing
2280        // string1 with string2." + RFC 3986 §2 'unwise' set
2281        // ("characters that gateways and other transport agents are
2282        // known to sometimes modify") + Pony's capabilities (a path
2283        // capability that carries a `^` would be ill-typed at the
2284        // reference layer, matching the same structural discipline the
2285        // sibling `!` history-expansion arm inherits from Unison's
2286        // content-addressed no-ambient-history discipline).
2287        //
2288        // The arm fires AFTER the shell-history-expansion `!` arm because
2289        // a value carrying both `!` and `^` (`"../foo!sudo^bad^good"` —
2290        // the canonical "I pasted a `!sudo` history-reference next to a
2291        // `^bad^good` quick-substitution") surfaces the narrower prefix-
2292        // form `!` diagnostic first — the `!` form is the load-bearing
2293        // self-locating edit on every probe-as-both value (an author who
2294        // removes the `!sudo` reference is likely to also strip the
2295        // paired `^` substitution fragment); same cascade discipline
2296        // every prior `:caminho` arm establishes. The arm fires BEFORE
2297        // the trailing-`/` arm because the embedded shell-history-
2298        // substitution byte is the more semantic-locating axis on
2299        // probe-as-both values (`"../foo^bar/"` ends in `/` but the
2300        // load-bearing diagnostic is the embedded `^` — the trailing `/`
2301        // is the secondary observation, and an author who removes the
2302        // `^bar` substitution fragment is likely to also tab-strip the
2303        // trailing separator).
2304        for &b in caminho.as_bytes() {
2305            if b == b'^' {
2306                return Err(DepError::fonte_caminho_shell_history_substitution(
2307                    nome, caminho, b,
2308                ));
2309            }
2310        }
2311        // Reproducibility gate's trailing-`/` arm. The b94fd83 absolute arm
2312        // closes the leading-`/` host-layout-leak; the embedded-control-byte
2313        // arm closes any byte-in-the-`0x00..=0x1F` / `0x7F` range; the
2314        // backslash arm closes the cross-host-OS-separator vector. The
2315        // trailing-`/` is the orthogonal shell-tab-completion-on-a-directory
2316        // footgun — `Path::join("../caixa-teia")` and
2317        // `Path::join("../caixa-teia/")` resolve to the same directory
2318        // (POSIX path-component-walk treats trailing `/` as a no-op for
2319        // directory targets, which `:caminho` always names — the sibling-
2320        // workspace dep root is structurally a directory). The lacre
2321        // pipeline embeds the value verbatim in its per-dep content-address
2322        // (`conteudo: format!("path:{caminho}")`,
2323        // caixa-resolver/src/resolve.rs:189), so byte-identical caixa
2324        // semantic-meaning yields two distinct BLAKE3 closures depending on
2325        // whether the author shell-tab-completed the path (every interactive
2326        // shell appends `/` on tab-completing a directory, idiomatic in
2327        // bash / zsh / fish / nushell), pasted from `pwd` (which on most
2328        // shells emits without trailing `/`, but `realpath -e -m` on a
2329        // directory with trailing `/` preserves it), or copied a Cargo
2330        // `path = "../caixa-teia/"` entry from cross-substrate documentation
2331        // (Cargo accepts both shapes and folds them the same way). Two
2332        // workstations whose authors differ only in tab-completion habits
2333        // emit byte-divergent lacres for the byte-identical-semantic caixa,
2334        // and the substrate's "the lacre is the build's identity" contract
2335        // (CAIXA-SDLC §III.2) silently breaks far from the source caixa.lisp.
2336        //
2337        // Same THEORY.md §V.2 render-determinism axis every prior `:caminho`
2338        // arm protects, here against the trailing-separator divergence
2339        // vector: every typed slot's accepted set excludes byte-divergent
2340        // values that round-trip to the same downstream semantic. The peer
2341        // path-shaped axes already reject trailing separators on the same
2342        // contract: [`crate::render::is_gateway_api_http_path`] gates
2343        // `:entrada :paths` against any non-canonical normalization, and
2344        // [`crate::render::is_sandboxed_relative_path`] gates the M2 typed
2345        // path-slots (`:behavior :on-*`, `:upgrade-from :state-change
2346        // :script`, `:bibliotecas`, `:exe`, `:servicos`) against shapes
2347        // whose canonical form would re-introduce determinism divergence.
2348        //
2349        // The arm fires last in the cascade because every prior arm carries
2350        // a more self-locating diagnostic on values that probe as both
2351        // (e.g. `:caminho "../foo/\0/"` ends in `/` but the load-bearing
2352        // diagnostic is the NUL byte's POSIX-syscall-rejection — the
2353        // control-char arm wins; `:caminho "/etc/passwd/"` ends in `/` but
2354        // the load-bearing diagnostic is the absolute host-layout-leak —
2355        // the absolute arm wins; `:caminho "..\caixa-teia/"` ends in `/`
2356        // but the load-bearing diagnostic is the Windows-separator cross-
2357        // OS divergence — the backslash arm wins). The arm covers every
2358        // shape where the last byte is `/` regardless of length, including
2359        // the degenerate single-`/` (which the absolute arm catches first)
2360        // and the consecutive-`//` (where every prior arm passes on the
2361        // bytes other than the trailing `/`).
2362        if caminho.as_bytes().last() == Some(&b'/') {
2363            return Err(DepError::fonte_caminho_trailing_slash(nome, caminho));
2364        }
2365        Ok(())
2366    }
2367}
2368
2369impl Dep {
2370    /// Substrate-canonical per-`:deps` / `:deps-dev` entry `:nome` scalar
2371    /// accessor every consumer of the dep-graph identity axis keys off —
2372    /// returns the author-declared `:nome` byte-string verbatim as a
2373    /// `&str`, borrowed from the typed slot's own [`String`] storage.
2374    ///
2375    /// The `:deps :nome` / `:deps-dev :nome` slot carries the DNS-1123
2376    /// label that names the target caixa (validated by [`Self::validate`]
2377    /// through the shared [`crate::render::is_dns_1123_label`] predicate,
2378    /// same accept-set the peer caixa-identifier axes carry — top-level
2379    /// [`crate::Caixa::nome`], per-`:membros` [`crate::Membro::nome`],
2380    /// per-`:children` [`crate::supervisor::ChildSpec::nome`]). Every
2381    /// downstream consumer that fans on the dep's name-identity keys off
2382    /// this scalar: the [`crate::Caixa::validate_deps`] per-list
2383    /// [`crate::render::insert_first_seen`] dedup key + the paired
2384    /// [`DepError::DuplicateNome`] carrier the walk raises on collision,
2385    /// the cross-list [`validate_no_self_dep`] parent-name equality gate
2386    /// on both `:deps` and `:deps-dev` traversals, the `caixa-resolver`
2387    /// pipeline's `HashSet<String>` seen-set the closure walker gates
2388    /// requeueing off (`caixa-resolver/src/resolve.rs:55`), the resolver's
2389    /// per-transitive-target requeue path (`resolve.rs:63,66`), the
2390    /// [`crate::DepSource::default_github`]-shaped resolver-side shorthand
2391    /// fill-in that folds `:nome` into the fetched-git-URL (`resolve.rs:147`),
2392    /// every `caixa-resolver` `ResolveError::MissingPath` /
2393    /// `ResolveError::MissingPin` carrier that names the offending dep
2394    /// (`resolve.rs:177,206`), each resolved
2395    /// `caixa-lacre::LacreEntry` `nome:` field the closure hash keys off
2396    /// (`resolve.rs:108,113`), and the peer `feira lock` stub-resolver's
2397    /// `LacreEntry` emitter (`caixa-feira/src/cmd/lock.rs:59,61,64`).
2398    ///
2399    /// Prior to this lift the `.nome` byte-string was read inline at every
2400    /// production site — the [`crate::Caixa::validate_deps`] paired
2401    /// `dep.nome.as_str()` / `dep.nome.clone()` accesses on both `:deps`
2402    /// and `:deps-dev` traversals, the [`validate_no_self_dep`] pair of
2403    /// parent-equality checks, and every caixa-resolver / caixa-feira
2404    /// site enumerated above — open-coded field-accesses that expressed
2405    /// no compile-time link back to the typed slot. A future extension of
2406    /// the `:deps :nome` axis to a richer author surface (a per-scope
2407    /// alias table the resolver folds through the `~/.config/caixa/config.yaml`
2408    /// entry the [`crate::dep::Dep`] docstring already acknowledges, a
2409    /// namespace-qualified rewrite the future M4 lacre-federation layer
2410    /// applies per-cluster, a promotion of the plain [`String`] byte-string
2411    /// to a richer scoped-identifier newtype once cross-registry federation
2412    /// lands) would have had to be threaded through every open-coded copy
2413    /// in lockstep or two consumers would silently disagree on which caixa
2414    /// a given dep resolves to — the [`crate::Caixa::validate_deps`] dedup
2415    /// set treating the name as `"caixa-teia"` while the caixa-resolver
2416    /// closure walker treated it as `"tenant-a/caixa-teia"` would silently
2417    /// split the [`DepError::DuplicateNome`] refusal from the resolver's
2418    /// requeue-suppression seen-set, one build-time diagnostic
2419    /// disagreeing with the run-time closure the substrate's lacre
2420    /// pipeline actually materializes. Lifting the resolution rule to a
2421    /// typed method on the substrate primitive means every downstream
2422    /// consumer of the caixa's per-`:deps` identity surface reaches for
2423    /// exactly one typed dispatch — the resolver's accept-set migrates as
2424    /// a unit on any future axis addition.
2425    ///
2426    /// First accessor on the outer `Dep` type — opens the outer-`Dep`
2427    /// `&str`-return required-scalar projection pattern the sibling
2428    /// per-`Dep` `:versao` future lift folds on. Peer of the sibling
2429    /// per-`:membros` [`crate::Membro::nome`] (4a32abf) /
2430    /// per-`:children` [`crate::supervisor::ChildSpec::nome`] (dfb4a81)
2431    /// / top-level [`crate::Caixa::nome`] (e6b7d97) caixa-identity scalar
2432    /// accessors — same "one typed dispatch on the substrate primitive,
2433    /// thin projections at each consumer" discipline extended onto the
2434    /// third named-caixa-referencing axis (`:deps` / `:deps-dev`), the
2435    /// remaining unlifted caixa-name-referencing accessor family in the
2436    /// substrate. Named `nome()` to match the tatara-lisp author-surface
2437    /// term the field's docstring already reaches for ("Caixa name — must
2438    /// match the target caixa's `:nome`") and the peer caixa-identity
2439    /// accessor family the substrate already carries.
2440    #[must_use]
2441    pub const fn nome(&self) -> &str {
2442        self.nome.as_str()
2443    }
2444
2445    /// Substrate-canonical per-`:deps` / `:deps-dev` entry `:versao`
2446    /// Cargo-shaped semver-requirement scalar accessor every consumer of
2447    /// the dep-graph version-pin axis keys off — returns the author-
2448    /// declared `:versao` requirement byte-string verbatim as a `&str`,
2449    /// borrowed from the typed slot's own [`String`] storage.
2450    ///
2451    /// The `:deps :versao` / `:deps-dev :versao` slot carries the
2452    /// Cargo-shaped semver requirement string (`"^0.1"`, `"~0.1.2"`,
2453    /// `"0.1.0"`, `"*"`) the shared [`crate::version::parse_requirement`]
2454    /// entry-point consumes — same accept-set the peer requirement-
2455    /// carrying axes carry (per-`:membros`
2456    /// [`crate::Membro::versao_requirement`], per-`:children`
2457    /// [`crate::supervisor::ChildSpec::versao_requirement`]), validated
2458    /// through the shared
2459    /// [`crate::render::require_valid_versao_requirement`] cascade in
2460    /// [`Self::validate`]. Every downstream consumer that fans on the
2461    /// dep's version-pin keys off this scalar: the [`Self::validate`]
2462    /// `require_valid_versao_requirement` gate + the paired
2463    /// [`DepError::VersaoInvalid`] carrier the cascade raises on
2464    /// requirement-shape rejection, the `feira lock` stub-resolver's
2465    /// `format!("{}@{}", dep.nome(), dep.versao_requirement())`
2466    /// `conteudo` hash-input interpolation and the paired
2467    /// `LacreEntry.versao:` `String`-carry fill (`caixa-feira/src/cmd/lock.rs`),
2468    /// and the peer `feira lock` end-to-end fixture in `caixa-feira/tests/feira_e2e.rs`.
2469    ///
2470    /// Prior to this lift the `.versao` byte-string was read inline at
2471    /// every production site — the [`Self::validate`] paired
2472    /// `&self.versao` requirement-gate reference and `self.versao.clone()`
2473    /// error-body carrier, the `caixa-feira/src/cmd/lock.rs` paired
2474    /// `format!("{}@{}", dep.nome(), dep.versao)` `conteudo` interpolation
2475    /// and `versao: dep.versao.clone()` `LacreEntry` fill, and the
2476    /// `caixa-feira/tests/feira_e2e.rs` end-to-end fixture's pair of the
2477    /// same shapes — open-coded field-accesses that expressed no
2478    /// compile-time link back to the typed slot. A future extension of
2479    /// the `:deps :versao` axis to a richer author surface (a per-scope
2480    /// version-lock overlay the resolver folds through the
2481    /// `~/.config/caixa/config.yaml` entry the [`crate::dep::Dep`]
2482    /// docstring already acknowledges, a per-cluster canary-version
2483    /// overlay per MESH-COMPOSITION §III.2, a promotion of the plain
2484    /// [`String`] requirement to a richer parsed-`VersionReq` newtype
2485    /// once cross-registry federation lands) would have had to be
2486    /// threaded through every open-coded copy in lockstep or two
2487    /// consumers would silently disagree on which release constraint a
2488    /// given dep resolves to — the [`Self::validate`] requirement-gate
2489    /// call reading `"^0.1"` while the `feira lock` stub-resolver's
2490    /// `conteudo` hash-input read `"tenant-a-pin/^0.1"` would silently
2491    /// split the [`DepError::VersaoInvalid`] refusal from the lacre's
2492    /// content-addressed hash the substrate's fetch pipeline actually
2493    /// materializes, one build-time diagnostic disagreeing with the
2494    /// run-time closure. Lifting the resolution rule to a typed method
2495    /// on the substrate primitive means every downstream consumer of
2496    /// the caixa's per-`:deps` version-pin surface reaches for exactly
2497    /// one typed dispatch — the resolver's accept-set migrates as a
2498    /// unit on any future axis addition.
2499    ///
2500    /// Second accessor on the outer `Dep` type — folds on the outer-
2501    /// `Dep` `&str`-return required-scalar projection pattern the
2502    /// sibling per-`Dep` [`Self::nome`] (eba2cde) accessor opened. Peer
2503    /// of the per-`:membros` [`crate::Membro::versao_requirement`]
2504    /// (a40b0e3) / per-`:children`
2505    /// [`crate::supervisor::ChildSpec::versao_requirement`] (7844f4e
2506    /// family) member/child version-pin accessors — the three
2507    /// requirement-carrying axes (`Dep::versao_requirement` on the
2508    /// per-caixa dep-graph edge, `Membro::versao_requirement` on the M3
2509    /// Aplicacao side, `ChildSpec::versao_requirement` on the M2
2510    /// Supervisor side) now share one accessor discipline for the
2511    /// shared substrate concept "another caixa referenced by a
2512    /// Cargo-shaped semver requirement". The pair
2513    /// `(nome(), versao_requirement())` jointly projects the
2514    /// `(nome, versao)` field pair every dep-graph consumer that fans
2515    /// on per-dep identity + version pin keys off. Named
2516    /// `versao_requirement()` rather than `versao()` because the field's
2517    /// storage-side `.versao` label is already the author-surface term
2518    /// (`:versao`); the accessor's name carries the semantic role — the
2519    /// semver *requirement* string the shared
2520    /// [`crate::version::parse_requirement`] entry-point consumes — so a
2521    /// raw field access and a typed dispatch read differently at every
2522    /// consumer site. Matches the peer
2523    /// [`crate::Membro::versao_requirement`] /
2524    /// [`crate::supervisor::ChildSpec::versao_requirement`] naming
2525    /// discipline verbatim.
2526    #[must_use]
2527    pub const fn versao_requirement(&self) -> &str {
2528        self.versao.as_str()
2529    }
2530
2531    /// Substrate-canonical per-`:deps` / `:deps-dev` entry `:fonte`
2532    /// Zig-store-model per-dep source-tuple optional-composite-reference
2533    /// accessor every consumer of the dep-graph fetch-source axis keys
2534    /// off — returns the author-declared `:fonte` typed [`DepSource`]
2535    /// verbatim as an `Option<&DepSource>` borrowed from the typed slot's
2536    /// own `Option<DepSource>` storage, with `None` naming the "author
2537    /// omitted `:fonte`" shorthand every resolver-side default-fill
2538    /// (`caixa-feira/src/cmd/lock.rs`'s stub, `caixa-resolver/src/resolve.rs`'s
2539    /// canonical fetcher, per the [`DepSource::default_github`] fallback
2540    /// the [`Dep::fonte`] field docstring already documents) treats as
2541    /// the "resolve through the configured default host / org
2542    /// (`github:<default-org>/<nome>`)" partition.
2543    ///
2544    /// The `:deps :fonte` / `:deps-dev :fonte` slot carries the two-
2545    /// arm typed [`DepSource`] the `Zig-style git-only store model` the
2546    /// enclosing [`Dep`] docstring names — `DepSource::Git { repo, tag,
2547    /// rev, branch }` for the git-clone arm every published caixa
2548    /// resolves through, `DepSource::Path { caminho }` for the dev-only
2549    /// local-filesystem arm every unpublishable in-tree checkout
2550    /// resolves through. Every downstream consumer that fans on the
2551    /// dep's fetch-source keys off this accessor: [`Self::validate`]'s
2552    /// per-`:fonte` [`DepSource::validate`] delegation (which raises
2553    /// the empty-`:repo` / missing-pin / multiple-pin / empty-`:caminho`
2554    /// diagnostics through the [`DepError::Fonte*`] carrier family
2555    /// naming the offending `Dep::nome`), the caixa-crd conversion
2556    /// crate's `dep_into_ref` two-arm projection into the `CaixaSource`
2557    /// `{repo, git_ref}` pair the K8s-CR side consumes
2558    /// (`caixa-crd/src/conversion.rs`), and — through the paired
2559    /// resolver-side default-fill's `Option::unwrap_or_else` — every
2560    /// `caixa-feira` / `caixa-resolver` fetch site that requires a
2561    /// concrete `DepSource` at run time.
2562    ///
2563    /// Prior to this lift the `.fonte` typed slot was read inline at
2564    /// every production site — the [`Self::validate`]
2565    /// `if let Some(ref fonte) = self.fonte` bracket the per-`:fonte`
2566    /// gate delegates through, the caixa-crd `dep_into_ref`
2567    /// `d.fonte.as_ref().and_then(...)` two-arm `CaixaSource` projector,
2568    /// the resolver-side `caixa-feira/src/cmd/lock.rs` / `caixa-resolver/src/resolve.rs`
2569    /// `dep.fonte.clone().unwrap_or_else(...)` default-fill pair — open-
2570    /// coded field-accesses that expressed no compile-time link back to
2571    /// the typed slot. A future extension of the `:deps :fonte` axis
2572    /// to a richer author surface (a per-scope source-override table
2573    /// the resolver folds through the `~/.config/caixa/config.yaml`
2574    /// entry the [`Dep`] docstring already acknowledges, a per-org
2575    /// mirror-fallback list the future M4 lacre-federation resolver
2576    /// consults ahead of the `default_github` fallback, a promotion of
2577    /// the plain `Option<DepSource>` to a richer
2578    /// `{primary, mirrors, integrity}` triple once cross-registry
2579    /// federation lands, a per-dep `sri:sha256-…` integrity slot the
2580    /// M4 lacre gate binds against ahead of the git-fetch) would have
2581    /// had to be threaded through every open-coded copy in lockstep or
2582    /// two consumers would silently disagree on which fetch source a
2583    /// given dep resolves to — the [`Self::validate`] per-`:fonte`
2584    /// gate reading the author-declared source while the caixa-crd
2585    /// projector read a per-scope-override-resolved source would
2586    /// silently split the build-time refusal from the CR the
2587    /// substrate's admission pipeline actually materializes, one
2588    /// build-time diagnostic disagreeing with the run-time closure.
2589    /// Lifting the resolution rule to a typed method on the substrate
2590    /// primitive means every downstream consumer of the caixa's per-
2591    /// `:deps` fetch-source surface reaches for exactly one typed
2592    /// dispatch — the resolver's accept-set migrates as a unit on any
2593    /// future axis addition.
2594    ///
2595    /// First outer-`Dep` `Option<&Composite>`-return composite-reference
2596    /// accessor — opens the outer-`Dep` `Option<&Composite>` composite-
2597    /// reference projection pattern the sibling per-`Dep` `:opcional`
2598    /// (`Option<Copy>` — the plain-bool axis) / `:caracteristicas`
2599    /// (`&[String]` — the feature-flag list) future outer scalar / slice
2600    /// lifts fold on. Peer of the outer-top-level [`crate::Caixa`]
2601    /// `Option<&Composite>` composite-reference sub-family the
2602    /// [`crate::Caixa::limits`] (b2bd9d7) / [`crate::Caixa::behavior`]
2603    /// (35d8b52) / [`crate::Caixa::politicas`] (5d23d29) /
2604    /// [`crate::Caixa::placement`] (4fb8074) / [`crate::Caixa::entrada`]
2605    /// (e4128e4) accessors already close on the outer [`crate::Caixa`]
2606    /// altitude, and of the outer M3 mesh-slot [`crate::AplicacaoSpec`]
2607    /// altitude the sibling [`crate::AplicacaoSpec::entrada`] (d32111c)
2608    /// accessor already carries — extends that "one typed dispatch on
2609    /// the substrate primitive, thin projections at each consumer"
2610    /// discipline onto the third outer typed-slot altitude that carries
2611    /// an `Option<Composite>` axis (`Dep`, the outer per-dep-list-entry
2612    /// slot). Returns `Option<&DepSource>` (not the owning composite by
2613    /// copy or clone) because every downstream consumer of the fonte
2614    /// composite treats it as a read-only per-arm dispatch source — the
2615    /// reference-view is the narrowest borrow that supports every
2616    /// present + roadmapped consumer (per-arm match projection at the
2617    /// caixa-crd `CaixaSource` two-arm emitter, presence-probe early
2618    /// return on the "author-omitted `:fonte` ⇒ resolver-side
2619    /// `default_github` fill applies" partition every resolver
2620    /// consults, `.cloned()`-on-demand for the two resolver-side
2621    /// default-fill call sites that require an owned `DepSource` for
2622    /// `Option::unwrap_or_else`) without cloning the composite through
2623    /// every consumer's fast path. The `Option` half of the return-type
2624    /// preserves the load-bearing "author-omitted `:fonte` ⇒ resolver-
2625    /// side default applies" partition (not a default composite the
2626    /// downstream must reject on emptiness) — the accessor projects the
2627    /// raw `Option<DepSource>` slot's presence bit through the
2628    /// reference-return unchanged. Named `fonte()` to match the storage
2629    /// field's name verbatim and the tatara-lisp author-surface term
2630    /// (`:fonte`) the field's own docstring already carries.
2631    ///
2632    /// Declared `pub const fn` — the body projects through
2633    /// `Option::<DepSource>::as_ref`, const-stable since Rust 1.83 and
2634    /// well within the workspace MSRV, so every downstream `const`-
2635    /// context consumer of the per-`Dep` `:fonte` composite-reference
2636    /// accessor reaches through the same typed dispatch on the
2637    /// substrate primitive at const-eval time as at runtime. The
2638    /// paired [`dep_outer_accessor_family_is_const_fn`][pin] pin
2639    /// (a `const fn <name>_via_const_fn(d: &Dep) -> …` wrapper family
2640    /// that forwards through each lifted accessor) locks the posture
2641    /// load-bearing at caixa-core build time — any future accidental
2642    /// downgrade to non-`const` fails the wrapper with E0015
2643    /// (`cannot call non-const method`), strictly stronger than a
2644    /// runtime `assert!` and side-stepping the destructor-in-const
2645    /// restriction the `Dep` fixture's `String` / `Option<DepSource>`
2646    /// / `Vec<String>` carriers rule out. Peer of the sibling per-
2647    /// `WitContract` pre-projection accessor family's `const`-eval-
2648    /// surface pass (279823b) and of the outer-`Caixa` slice-return
2649    /// accessor family's parallel pass (231a968) — same "one canonical
2650    /// dispatch per axis, `const`-eval posture pinned at the substrate
2651    /// primitive, thin projections at each consumer" discipline
2652    /// extended onto the outer per-dep-list-entry [`Dep`] altitude.
2653    ///
2654    /// [pin]: tests::dep_outer_accessor_family_is_const_fn
2655    #[must_use]
2656    pub const fn fonte(&self) -> Option<&DepSource> {
2657        self.fonte.as_ref()
2658    }
2659
2660    /// Substrate-canonical per-`:deps` / `:deps-dev` entry
2661    /// `:caracteristicas` Cargo-shaped feature-toggle-set slice accessor
2662    /// every consumer of the dep-graph feature-flag axis keys off —
2663    /// returns the author-declared `:caracteristicas` feature-name list
2664    /// verbatim as a `&[String]` slice-view over the same backing buffer
2665    /// the raw `self.caracteristicas.as_slice()` field access borrows
2666    /// from. Empty-list-carrying (`:caracteristicas` is a default-empty
2667    /// axis every `Dep` supplies with `Vec::new()` when the author omits
2668    /// the slot; the [`crate::Caixa::from_lisp`] derive folds an omitted
2669    /// `:caracteristicas` through `#[serde(default)]` to `Vec::new()`,
2670    /// so a `Dep` past parse definitionally carries a `Vec<String>` slot
2671    /// — possibly empty — and the returned `&[String]` degenerates to
2672    /// an empty slice on that arm without any silent `None` collapse).
2673    ///
2674    /// The `:deps :caracteristicas` / `:deps-dev :caracteristicas` slot
2675    /// carries the set-shaped feature-toggle list the substrate walks
2676    /// through the [`Self::validate_caracteristicas`] per-entry shape +
2677    /// duplicate cascade — same Cargo `[dependencies.<dep>.features]`
2678    /// accept-set (per-entry Cargo-feature-name grammar via the shared
2679    /// [`crate::render::is_cargo_feature_name`] predicate, cross-entry
2680    /// uniqueness via the shared [`crate::render::insert_first_seen`]
2681    /// walk, empty-first / value-shape-second / duplicate-third
2682    /// precedence via the peer per-axis two-arm cascade discipline every
2683    /// substrate-blessed Vec-keyed-by-name slot already follows).
2684    /// Every downstream consumer that fans on the dep's feature-toggle
2685    /// keys off this accessor: [`Self::validate_caracteristicas`]'s
2686    /// per-entry linear walk that gates each feature-name byte-string
2687    /// through the empty / value-shape / duplicate arms (raising the
2688    /// [`DepError::CaracteristicaEmpty`] / [`DepError::CaracteristicaInvalid`]
2689    /// / [`DepError::CaracteristicaDuplicate`] carrier family naming the
2690    /// offending `Dep::nome`), and every future
2691    /// per-`Caixa`-manifest / caixa-resolver / caixa-crd feature-toggle-
2692    /// facing consumer the CAIXA-SDLC §I roadmap acknowledges (the
2693    /// future caixa-resolver per-dep feature-projection walk that folds
2694    /// the toggle set into the resolved [`crate::Caixa`]'s activated
2695    /// [`crate::render::CARGO_FEATURE_NAME_MAX_LEN`]-bounded feature
2696    /// closure ahead of the lacre hash, the future caixa-crd per-`spec.deps`
2697    /// features slice the K8s-CR admission gate consumes, the future
2698    /// per-cluster feature-overlay the M4 lacre-federation resolver
2699    /// composes ahead of the substrate-wide feature-name accept-set).
2700    ///
2701    /// Prior to this lift the `.caracteristicas` byte-string list was
2702    /// read inline at the [`Self::validate_caracteristicas`] `for c in
2703    /// &self.caracteristicas` walk — the only in-crate consumer of the
2704    /// raw field beyond the per-`Dep` constructor pair
2705    /// ([`Self::simple`] / [`Self::git`]) and the paired serde
2706    /// round-trip / per-test fixture-mutation paths — an open-coded
2707    /// field-access that expressed no compile-time link back to the
2708    /// typed slot. A future extension of the `:caracteristicas` axis to
2709    /// a richer author surface (a per-scope feature-overlay the resolver
2710    /// folds through the `~/.config/caixa/config.yaml` entry the
2711    /// [`Dep`] docstring already acknowledges, a per-cluster feature-
2712    /// activation overlay the future M4 lacre-federation layer applies
2713    /// per-CR, a promotion of the plain `Vec<String>` byte-string list
2714    /// to a richer parsed-feature-set newtype once the Cargo-shaped
2715    /// namespaced-dep `dep/feat` syntax the value-shape gate's
2716    /// docstring anticipates lands) would have had to be threaded
2717    /// through every open-coded copy in lockstep or two consumers
2718    /// would silently disagree on which feature closure a given dep
2719    /// activates — the [`Self::validate_caracteristicas`] gate walking
2720    /// the author-declared list while a downstream caixa-resolver
2721    /// consumer walked a per-scope-override-resolved list would
2722    /// silently split the build-time refusal from the lacre closure
2723    /// the substrate's fetch pipeline actually materializes, one
2724    /// build-time diagnostic disagreeing with the run-time closure.
2725    /// Lifting the resolution rule to a typed method on the substrate
2726    /// primitive means every downstream consumer of the caixa's per-
2727    /// `:deps` feature-toggle surface reaches for exactly one typed
2728    /// dispatch — the resolver's accept-set migrates as a unit on any
2729    /// future axis addition.
2730    ///
2731    /// First outer-`Dep` `&[T]`-return slice accessor — opens the
2732    /// outer-`Dep` `&[String]` slice projection pattern the sibling
2733    /// per-`Dep` `:opcional` (`bool` — the plain-`Copy`-scalar axis)
2734    /// future outer scalar lift folds on and closes the outer-`Dep`
2735    /// slot-family the sibling [`Self::nome`] (eba2cde) /
2736    /// [`Self::versao_requirement`] (05529b1) / [`Self::fonte`] (d65d1bf)
2737    /// accessors already open, leaving the `:opcional` `Copy`-scalar arm
2738    /// as the sole remaining unlifted outer-`Dep` slot. Peer of the
2739    /// outer top-level [`crate::Caixa`] `&[String]`-return foreign-code-
2740    /// slot sub-family ([`crate::Caixa::bibliotecas`] 8a36c23,
2741    /// [`crate::Caixa::exe`] 65d9527, [`crate::Caixa::servicos`]
2742    /// 611f78b) and the outer top-level [`crate::Caixa`] universal-axis
2743    /// text-tag family ([`crate::Caixa::autores`] b5d813f,
2744    /// [`crate::Caixa::etiquetas`] 78c7d3c) that already carry the
2745    /// `&[String]` slice-projection discipline on the outer-`Caixa`
2746    /// altitude — extends the "one typed dispatch on the substrate
2747    /// primitive, thin projections at each consumer" discipline onto the
2748    /// outer per-dep-list-entry [`Dep`] altitude's set-shaped byte-
2749    /// string list slot. Returns `&[String]` (not `&Vec<String>`)
2750    /// because every downstream consumer of the feature-toggle list
2751    /// treats it as a read-only sequence — the slice-view is the
2752    /// narrowest borrow that supports every present + roadmapped
2753    /// consumer (`.iter()`, `.len()`, `.is_empty()`) without leaking
2754    /// the backing `Vec`'s grow/push/reserve surface no consumer of
2755    /// the typed view reaches for (the storage-side `Vec` remains
2756    /// reachable through the `pub caracteristicas` field for the
2757    /// mutation-carrying serde round-trip and per-test fixture-mutation
2758    /// paths). Named `caracteristicas()` to match the storage field's
2759    /// name verbatim and the tatara-lisp author-surface term
2760    /// (`:caracteristicas`) the field's own docstring already carries.
2761    ///
2762    /// Declared `pub const fn` — the body projects through
2763    /// `Vec::<String>::as_slice`, const-stable since Rust 1.83 and
2764    /// well within the workspace MSRV, so every downstream `const`-
2765    /// context consumer of the per-`Dep` `:caracteristicas` slice-
2766    /// accessor reaches through the same typed dispatch on the
2767    /// substrate primitive at const-eval time as at runtime. Pinned
2768    /// load-bearing by the paired
2769    /// [`dep_outer_accessor_family_is_const_fn`][pin] wrapper family
2770    /// alongside its sibling [`Self::fonte`] — see [`Self::fonte`] for
2771    /// the full pin-shape rationale.
2772    ///
2773    /// [pin]: tests::dep_outer_accessor_family_is_const_fn
2774    #[must_use]
2775    pub const fn caracteristicas(&self) -> &[String] {
2776        self.caracteristicas.as_slice()
2777    }
2778
2779    /// Substrate-canonical per-`:deps` / `:deps-dev` entry `:opcional`
2780    /// missing-source-tolerance flag scalar accessor every consumer of
2781    /// the dep-graph opt-in-fetch axis keys off — returns the author-
2782    /// declared `:opcional` `bool` verbatim, `Copy`-projected from the
2783    /// typed slot's own `bool` storage (no borrow of `&self` past the
2784    /// call; the `Copy`-return arm matches the peer
2785    /// [`crate::Caixa::max_restarts`] (eba5211) `Option<u32>` `Copy`-
2786    /// projected sibling discipline the outer flat-spread family
2787    /// already carries). Default-`false` (`#[serde(default,
2788    /// skip_serializing_if = "is_false")]` on the storage slot, so a
2789    /// `Dep` past parse definitionally carries a `bool` — `false` when
2790    /// the author omits `:opcional` — and the returned value degenerates
2791    /// to `false` on that arm without any silent `None` collapse).
2792    ///
2793    /// The `:deps :opcional` / `:deps-dev :opcional` slot carries the
2794    /// per-entry "if this dep's `:fonte` cannot be resolved, treat the
2795    /// missing-source arm as a soft-fail rather than a build refusal"
2796    /// bit — the same Cargo-shaped `[dependencies.<dep>.optional = true]`
2797    /// accept-set (an opcional dep whose `:fonte` fails to resolve is
2798    /// dropped from the resolved dep-graph rather than tripping the
2799    /// build-refusal edge that a mandatory `:opcional false` entry
2800    /// would). Every downstream consumer that fans on the dep's
2801    /// missing-source-tolerance keys off this accessor: the future
2802    /// caixa-resolver's per-`:fonte` resolve-fail arm (drop-vs-error
2803    /// dispatch on the opcional bit ahead of the lacre closure
2804    /// materialization), the future caixa-crd per-`spec.deps`
2805    /// `optional` boolean the K8s-CR admission gate consumes on the
2806    /// per-dep partition, and the future feira / caixa-resolver /
2807    /// caixa-crd feature-projection walk that folds the opcional bit
2808    /// into the resolved feature-closure the future M4 lacre-federation
2809    /// layer emits.
2810    ///
2811    /// Prior to this lift the `.opcional` `bool` slot was read inline
2812    /// at the sole in-crate consumer site — the tests-module
2813    /// `registry_dep_is_minimal` fixture's `assert!(!d.opcional)` gate
2814    /// pinning the [`Self::simple`] constructor's default-`false` fill
2815    /// (the only in-crate read of the raw field beyond the per-`Dep`
2816    /// constructor pair [`Self::simple`] / [`Self::git`] and the paired
2817    /// serde round-trip / per-test fixture-mutation paths) — an open-
2818    /// coded field-access that expressed no compile-time link back to
2819    /// the typed slot. A future extension of the `:opcional` axis to a
2820    /// richer author surface (a per-scope opcional-override the resolver
2821    /// folds through the `~/.config/caixa/config.yaml` entry the [`Dep`]
2822    /// docstring already acknowledges, a per-cluster opcional-override
2823    /// the future M4 lacre-federation layer applies per-CR, a promotion
2824    /// of the plain `bool` to a richer `OpcionalPolicy { drop, warn,
2825    /// error }` tri-state once the CAIXA-SDLC §II opcional-policy
2826    /// roadmap lands) would have had to be threaded through every open-
2827    /// coded copy in lockstep or two consumers would silently disagree
2828    /// on which missing-source arm a given dep resolves to — the
2829    /// [`Self::simple`] constructor's default-`false` fill reading
2830    /// verbatim while a downstream caixa-resolver consumer read a per-
2831    /// scope-override-resolved bit would silently split the build-time
2832    /// arm from the lacre closure the substrate's fetch pipeline
2833    /// actually materializes, one build-time diagnostic disagreeing
2834    /// with the run-time closure. Lifting the resolution rule to a
2835    /// typed method on the substrate primitive means every downstream
2836    /// consumer of the caixa's per-`:deps` opcional-tolerance surface
2837    /// reaches for exactly one typed dispatch — the resolver's accept-
2838    /// set migrates as a unit on any future axis addition.
2839    ///
2840    /// Fifth and final outer-`Dep` accessor — closes the outer-`Dep`
2841    /// slot-family the sibling per-`Dep` [`Self::nome`] (eba2cde) /
2842    /// [`Self::versao_requirement`] (05529b1) / [`Self::fonte`] (d65d1bf)
2843    /// / [`Self::caracteristicas`] (9197944) accessors opened, so every
2844    /// outer-`Dep` slot (`:nome`, `:versao`, `:fonte`, `:opcional`,
2845    /// `:caracteristicas`) now routes through exactly one typed
2846    /// dispatch on the substrate primitive. First outer-`Dep`
2847    /// `bool`-return / plain-`Copy`-scalar accessor — opens the
2848    /// outer-`Dep` `Copy`-scalar projection pattern that folds on the
2849    /// peer outer-top-level [`crate::Caixa`] `Option<Copy>`
2850    /// flat-spread sub-family ([`crate::Caixa::max_restarts`] eba5211,
2851    /// [`crate::Caixa::estrategia`] ed04d3c) the outer-`Caixa` altitude
2852    /// already carries — extends the "one typed dispatch on the
2853    /// substrate primitive, thin projections at each consumer"
2854    /// discipline onto the outer per-dep-list-entry [`Dep`] altitude's
2855    /// bool-shaped missing-source-tolerance slot. Returns `bool` by
2856    /// `Copy` (not by `&bool` reference) because `bool` is `Copy` and
2857    /// every downstream consumer treats it as a plain discriminant
2858    /// value — the by-value return is the narrowest return-shape that
2859    /// supports every present + roadmapped consumer (`.then(…)` early
2860    /// return on the resolver-side drop-vs-error partition, direct
2861    /// bool composition with a per-scope-override projector, plain
2862    /// `if dep.opcional() { … }` early return at every future admission
2863    /// gate) without leaking the storage field's `bool`-in-`&self`
2864    /// lifetime the by-value return elides. Marked `pub const fn` so
2865    /// the accessor is `const`-callable — same discipline the peer
2866    /// [`crate::Caixa::max_restarts`] `Option<u32>` `Copy`-return
2867    /// accessor carries. Named `opcional()` to match the storage
2868    /// field's name verbatim and the tatara-lisp author-surface term
2869    /// (`:opcional`) the field's own docstring already carries.
2870    #[must_use]
2871    pub const fn opcional(&self) -> bool {
2872        self.opcional
2873    }
2874
2875    /// Build a minimal registry-sourced dep.
2876    #[must_use]
2877    pub fn simple(nome: impl Into<String>, versao: impl Into<String>) -> Self {
2878        Self {
2879            nome: nome.into(),
2880            versao: versao.into(),
2881            fonte: None,
2882            opcional: false,
2883            caracteristicas: Vec::new(),
2884        }
2885    }
2886
2887    /// Build a Git-sourced dep (tag-based).
2888    #[must_use]
2889    pub fn git(
2890        nome: impl Into<String>,
2891        versao: impl Into<String>,
2892        repo: impl Into<String>,
2893        tag: impl Into<String>,
2894    ) -> Self {
2895        Self {
2896            nome: nome.into(),
2897            versao: versao.into(),
2898            fonte: Some(DepSource::Git {
2899                repo: repo.into(),
2900                tag: Some(tag.into()),
2901                rev: None,
2902                branch: None,
2903            }),
2904            opcional: false,
2905            caracteristicas: Vec::new(),
2906        }
2907    }
2908
2909    /// Reject dependency entries whose `:nome` or `:versao` are empty,
2910    /// whose `:nome` is non-empty but not a valid DNS-1123 label,
2911    /// or whose `:versao` is non-empty but not a valid Cargo-shaped
2912    /// semver requirement.
2913    ///
2914    /// The author surface for `:deps :versao` (and `:deps-dev :versao`)
2915    /// is the same Cargo-shaped requirement string `:membros :versao`
2916    /// (validated at [`crate::AplicacaoSpec::validate`] since 9888b13)
2917    /// and `:children :versao` (validated at
2918    /// [`crate::SupervisorSpec::validate`] since b38ff3a) carry — and
2919    /// the lacre pipeline resolves all three axes through the same
2920    /// [`crate::parse_requirement`] entry-point. Until 2420c44 landed
2921    /// `:deps :versao` was the last `:versao` axis untyped past
2922    /// `Caixa::from_lisp`: a malformed-but-non-empty requirement
2923    /// (`"^bad-version"`, `"^^0.1"`, the canonical git-tag-shape-
2924    /// leaking-into-:versao `"v0.1"` typo, the accidental
2925    /// `"not-a-req"`) silently passed parse and the `semver::Error`
2926    /// surfaced at lacre-resolve time, far from the source
2927    /// caixa.lisp, with no field naming which `:deps` entry carried
2928    /// the typo. The diagnostic [`DepError::VersaoInvalid`] carries
2929    /// the offending entry's `:nome` + the offending `:versao`
2930    /// verbatim + the parser's own wording in `reason`, so the
2931    /// author's grep target is unambiguous.
2932    ///
2933    /// The author surface for `:deps :nome` is the same DNS-1123 label
2934    /// the peer caixa-identifier axes carry — top-level Caixa `:nome`
2935    /// (validated at [`crate::Caixa::validate_nome`] since 6c992f8),
2936    /// `:membros :caixa` (validated at
2937    /// [`crate::AplicacaoSpec::validate_membros`] since 3f9d7a0),
2938    /// `:children :caixa` (validated at
2939    /// [`crate::SupervisorSpec::validate`] since 31bfa43). A `:deps
2940    /// :nome` value flows verbatim through the lacre pipeline as the
2941    /// target caixa's `:nome` (which the gate at the *target* side now
2942    /// rejects if non-DNS-1123) and lands as the rendered caixa's
2943    /// `lareira-<nome>` Helm chart name segment, the per-dep
2944    /// `LABEL_PROGRAM` label value, and the `caixa-resolver`'s
2945    /// `~/.cache/caixa/<org>/<nome>` checkout-directory leaf. Until
2946    /// this gate landed `:deps :nome` was the fourth and last
2947    /// DNS-1123-shaped caixa-identifier axis still untyped past
2948    /// `Caixa::from_lisp`: a syntactically wrong dep name (`"Caixa-
2949    /// Teia"` uppercase — the canonical "I copied the README header"
2950    /// typo; `"caixa_teia"` underscore — the Go module / Python
2951    /// identifier leak; `"caixa-teia."` trailing dot — the FQDN
2952    /// confusion; `"-caixa-teia"` leading hyphen; a 64-byte slug)
2953    /// silently passed parse and surfaced at lacre-resolve time when
2954    /// the resolved target caixa's `:nome` failed *its* DNS-1123 gate
2955    /// — far from the source `:deps` entry, with a diagnostic naming
2956    /// the *target's* `:nome` rather than the dep entry that referenced
2957    /// it. Mirroring the 3f9d7a0 / 31bfa43 / 6c992f8 trajectory through
2958    /// the lifted [`crate::render::is_dns_1123_label`] predicate (the
2959    /// "before its third occurrence" PRIME DIRECTIVE boundary, THEORY.md
2960    /// §I.3.5): every `Dep::nome` past validate is DNS-1123-label-shaped,
2961    /// so every downstream consumer (caixa-resolver's lacre fetch,
2962    /// caixa-helm's `lareira-<nome>` chart name, the future M4 per-dep
2963    /// fan-out emitter) reaches for the name knowing the value is
2964    /// apiserver-valid without re-validating.
2965    ///
2966    /// Empty checks fire first (narrower diagnostic), parse last —
2967    /// same ordering discipline as
2968    /// [`crate::AplicacaoSpec::validate_membros`] and
2969    /// [`crate::SupervisorSpec::validate`]. `parse_requirement("")`
2970    /// returns `Ok(VersionReq::STAR)`, so the empty-`:versao` arm is
2971    /// structurally necessary even with the parse arm in place. The
2972    /// `:nome` shape gate runs after the `:nome` empty gate and before
2973    /// the `:versao` checks so a one-entry caixa.lisp with both wrong
2974    /// sees the name-side diagnostic first (the name is the
2975    /// self-locating axis — without it, the parse diagnostic can't
2976    /// quote `:nome "<bad>"`).
2977    pub fn validate(&self) -> Result<(), DepError> {
2978        if self.nome.is_empty() {
2979            return Err(DepError::NomeEmpty);
2980        }
2981        if let Err(reason) = crate::render::is_dns_1123_label(&self.nome) {
2982            return Err(DepError::NomeInvalid {
2983                nome: self.nome.clone(),
2984                reason,
2985            });
2986        }
2987        // Delegate the empty-first + `parse_requirement` cascade to the
2988        // shared [`crate::render::require_valid_versao_requirement`]
2989        // helper — same two-arm shape the peer
2990        // [`crate::AplicacaoSpec::validate_membros`] on `:membros
2991        // :versao` and [`crate::SupervisorSpec::validate`] on `:children
2992        // :versao` route through, so drift between the three axes'
2993        // accepted requirement sets is structurally impossible and the
2994        // parse-side no-op the empty-first arm closes (semver's empty
2995        // parse yields an implicit `*`) lives in exactly one predicate.
2996        crate::render::require_valid_versao_requirement(
2997            self.versao_requirement(),
2998            || DepError::versao_empty(&self.nome),
2999            |reason| DepError::versao_invalid(&self.nome, self.versao_requirement(), reason),
3000        )?;
3001        if let Some(fonte) = self.fonte() {
3002            fonte.validate(&self.nome)?;
3003        }
3004        self.validate_caracteristicas()?;
3005        Ok(())
3006    }
3007
3008    /// Reject per-entry `:caracteristicas` (feature-flag) values that
3009    /// are operationally meaningless. The `:caracteristicas` slot is
3010    /// a set of feature toggles to enable on the target caixa — same
3011    /// shape as Cargo's `[dependencies.<dep>.features]` list — and
3012    /// two structural footguns close here:
3013    ///
3014    ///   - empty-string entry (`(:caracteristicas (""))`): the future
3015    ///     caixa-resolver lacre pipeline would consume the empty
3016    ///     identifier as a no-op feature enable, silently dropping the
3017    ///     author's intent far from the source `caixa.lisp`;
3018    ///   - duplicate entry within one dep (`(:caracteristicas ("http"
3019    ///     "http"))`): the feature-toggle slot is set-shaped (enabling
3020    ///     a feature twice has no additional semantic — there is no
3021    ///     `feature × 2`), so two entries naming the same feature are
3022    ///     a silent miscount, the same set-not-multiset distinction
3023    ///     every peer Vec-keyed-by-name axis already closes
3024    ///     ([`crate::SupervisorError::DuplicateChildCaixa`] on
3025    ///     `:children :caixa`, [`crate::AplicacaoError::MembroDuplicate`]
3026    ///     on `:membros :caixa`, [`crate::AplicacaoError::ContratoDuplicate`]
3027    ///     on `:contratos`, [`crate::AplicacaoError::PlacementClusterDuplicate`]
3028    ///     on `:placement :clusters`, [`crate::AplicacaoError::EntradaPathDuplicate`]
3029    ///     on `:entrada :paths`, [`crate::UpgradeError::DuplicateFrom`]
3030    ///     on `:upgrade-from :from`, [`crate::UpgradeError::DuplicateLoadModule`]
3031    ///     / [`crate::UpgradeError::DuplicateStateChange`] /
3032    ///     [`crate::UpgradeError::DuplicateCleanup`] on the within-
3033    ///     entry `:upgrade-from` axes, and [`DepError::DuplicateNome`]
3034    ///     on the cross-entry `:deps`/`:deps-dev` `:nome` axis the
3035    ///     immediate-predecessor 359fba5 closed).
3036    ///
3037    /// Same linear-walk + `HashSet` + first-collision diagnostic shape
3038    /// every peer set-not-multiset gate uses; the empty arm fires
3039    /// before the duplicate arm so an entry with both an empty feature
3040    /// *and* a duplicate of some later feature surfaces the empty-
3041    /// shape diagnostic first (the empty-feature axis is the
3042    /// more-actionable defect since the missing-name renders the
3043    /// duplicate-key arm ambiguous: two `""` entries would both report
3044    /// `caracteristica: ""` with no way to distinguish the offending
3045    /// site). Empty-first cascade discipline mirrors every peer per-
3046    /// entry shape + duplicate gate
3047    /// (`SupervisorSpec::validate`'s `EmptyChildName` before
3048    /// `DuplicateChildCaixa`; `validate_membros`'s `MembroCaixaEmpty`
3049    /// before `MembroDuplicate`).
3050    ///
3051    /// The per-entry value-shape gate (Cargo-feature-name grammar via
3052    /// the lifted [`crate::render::is_cargo_feature_name`] predicate)
3053    /// fires between the empty arm and the duplicate arm — the
3054    /// canonical per-entry-shape-before-cross-entry-uniqueness
3055    /// precedence every peer two-arm + value-shape gate establishes
3056    /// ([`crate::SupervisorSpec::validate`]'s `EmptyChildName` →
3057    /// `ChildCaixaInvalid` → `DuplicateChildCaixa`,
3058    /// [`crate::AplicacaoSpec::validate_membros`]'s `MembroCaixaEmpty`
3059    /// → `MembroCaixaInvalid` → `MembroDuplicate`, [`Dep::validate`]'s
3060    /// `NomeEmpty` → `NomeInvalid` → cross-list `DuplicateNome`).
3061    /// Until the value-shape arm landed `:caracteristicas` accepted
3062    /// every non-empty distinct string — a structurally invalid
3063    /// feature name (`"http feature"` whitespace, `"+http"` the
3064    /// canonical paste-from-`+optional-feature` doc activation-form
3065    /// footgun, `"-flag"` leading hyphen, `".feat"` leading dot,
3066    /// `"http/json"` Cargo's `dep/feat` namespaced-dep syntax that
3067    /// only applies inside list-grammar contexts, `"http,json"`
3068    /// list-separator-belongs-to-the-list-grammar miscomprehension,
3069    /// `"café"` un-percent-encoded non-ASCII silently round-tripping
3070    /// inconsistently across NFC/NFD normalization, the 65-byte
3071    /// paste-from-binary slug) silently passed validate and the
3072    /// failure surfaced at `cargo metadata` time as the
3073    /// `restricted_names::validate_feature_name` parser's rejection,
3074    /// far from the source `caixa.lisp`, with no field naming which
3075    /// `:deps` entry's `:caracteristicas` carried the typo. The
3076    /// lifted predicate makes the Cargo-feature-name-grammar
3077    /// intersection-floor a substrate-level invariant at validate
3078    /// time — same trajectory as the eight peer
3079    /// [`crate::render`] value-shape predicates each typed surface
3080    /// downstream of a structured grammar already follows
3081    /// ([`is_dns_1123_label`](crate::render::is_dns_1123_label),
3082    /// [`is_gateway_api_http_path`](crate::render::is_gateway_api_http_path),
3083    /// [`is_wit_world_ref`](crate::render::is_wit_world_ref),
3084    /// [`is_nats_subject`](crate::render::is_nats_subject),
3085    /// [`is_wasi_keyvalue_slot`](crate::render::is_wasi_keyvalue_slot),
3086    /// [`is_git_ref_name`](crate::render::is_git_ref_name),
3087    /// [`is_git_oid`](crate::render::is_git_oid),
3088    /// [`is_git_repo_url`](crate::render::is_git_repo_url)).
3089    fn validate_caracteristicas(&self) -> Result<(), DepError> {
3090        let mut seen = std::collections::HashSet::new();
3091        for c in self.caracteristicas() {
3092            if c.is_empty() {
3093                return Err(DepError::caracteristica_empty(&self.nome));
3094            }
3095            if let Err(reason) = crate::render::is_cargo_feature_name(c) {
3096                return Err(DepError::caracteristica_invalid(&self.nome, c, reason));
3097            }
3098            crate::render::insert_first_seen(&mut seen, c.as_str(), || {
3099                DepError::CaracteristicaDuplicate {
3100                    nome: self.nome.clone(),
3101                    caracteristica: c.clone(),
3102                }
3103            })?;
3104        }
3105        Ok(())
3106    }
3107}
3108
3109/// Cross-slot coherence gate on the dep-graph axis: no `:deps` or
3110/// `:deps-dev` entry may name the caixa's own `:nome`.
3111///
3112/// A caixa that lists itself as a dep is a degenerate self-edge in the
3113/// lacre closure's dep-graph — the closure is a DAG rooted at the
3114/// caixa's `:nome`, and the caixa-resolver's lacre pipeline traverses
3115/// every `:deps` / `:deps-dev` entry's target by name. A self-dep
3116/// hands the resolver a node that is its own parent: a one-node cycle
3117/// it either rejects mid-traversal far from the source `caixa.lisp`
3118/// (the resolver detecting infinite recursion on the closure walk) or,
3119/// worse, recurses on until it exhausts its stack. Because every
3120/// `:nome` is a globally-unique substrate identity (DNS-1123 label +
3121/// lacre closure root), a dep entry whose `:nome` equals the caixa's
3122/// own `:nome` *is* the caixa itself, not a coincidentally-named peer.
3123///
3124/// Lives outside [`Caixa::validate_deps`] because the dep-list view
3125/// carries the entries but not the parent `:nome`; mirrors the
3126/// cross-slot self-edge gates [`crate::supervisor::validate_no_self_supervision`]
3127/// (ad4abf1) on the `:children :caixa` axis and
3128/// [`crate::aplicacao::validate_no_self_membership`] on the
3129/// `:membros :caixa` axis — the same "an edge from a graph node to
3130/// itself is structurally not a tree/graph edge" discipline, here on
3131/// the third typed-name-graph axis (the dep closure; the supervision
3132/// tree and the Aplicacao membership set were the prior two).
3133///
3134/// Walks `:deps` first then `:deps-dev` so the diagnostic for a caixa
3135/// that self-references on both axes surfaces the `:deps` arm first —
3136/// the load-bearing axis the lacre closure resolves at every build,
3137/// peer with the canonical [`Caixa::validate_deps`] walk order
3138/// (`:deps` → `:deps-dev`).
3139///
3140/// Carries the offending list tag (`":deps"` or `":deps-dev"`)
3141/// verbatim into the diagnostic so the author can grep their
3142/// `caixa.lisp` for the offending block in one edit — same
3143/// `list: &'static str` shape [`DepError::DuplicateNome`] (359fba5)
3144/// uses on the cross-list duplicate-name axis.
3145///
3146/// `Code paths` (`:bibliotecas` / `:exe` / `:servicos`) are the
3147/// substrate-blessed shape for referencing the caixa's *own* code, so
3148/// the diagnostic names them as the corrective surface — every
3149/// legitimate "I want to use code from this caixa" authoring intent
3150/// routes through one of those three slots, not a self-dep.
3151pub fn validate_no_self_dep(
3152    deps: &[Dep],
3153    deps_dev: &[Dep],
3154    parent_nome: &str,
3155) -> Result<(), DepError> {
3156    for dep in deps {
3157        if dep.nome() == parent_nome {
3158            return Err(DepError::dep_is_self(
3159                parent_nome,
3160                crate::render::DEP_AUTHOR_KEY_DEPS,
3161            ));
3162        }
3163    }
3164    for dep in deps_dev {
3165        if dep.nome() == parent_nome {
3166            return Err(DepError::dep_is_self(
3167                parent_nome,
3168                crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
3169            ));
3170        }
3171    }
3172    Ok(())
3173}
3174
3175/// Closed-set typed enum for the two dep-list author-surface axes every
3176/// top-level [`crate::Caixa`] carries — the runtime-closure `:deps` slot
3177/// (`Prod`) and the dev-only-closure `:deps-dev` slot (`Dev`). Every
3178/// substrate consumer that dispatches on "which of the two dep-lists"
3179/// (the `feira add` mutation head, the future per-cluster dev-closure-
3180/// audit overlay the M4 CR materializer resolves per-CR, the future
3181/// `caixa app graph` per-list dep summary, every future
3182/// `Caixa::push_dep` / `Caixa::deps_by_list` typed-method dispatch a
3183/// caller reaches for) reads through this enum rather than through a
3184/// bare `&'static str` — the closed-set is expressed at the type layer,
3185/// so a future third dep-list axis (a `:deps-build` build-only closure
3186/// once the substrate grows cross-artifact heterogeneous dep-graphs,
3187/// per CAIXA-SDLC §I) is one variant plus one arm per method and the
3188/// compiler enforces exhaustiveness on every consumer's `match` arms.
3189///
3190/// The wire byte-string [`Self::as_str`] returns is the same author-
3191/// surface tag the sibling [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3192/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] constants carry — the
3193/// [`DepError::DuplicateNome`] / [`DepError::DepIsSelf`] `list:
3194/// &'static str` payload family the substrate already emits routes
3195/// through the same source of truth (an author reading a
3196/// [`DepError::DuplicateNome`] refusal can grep their `caixa.lisp`
3197/// for the offending `:deps` / `:deps-dev` block in one edit whether
3198/// the diagnostic came from a `Caixa::validate_deps` walk or a
3199/// `Caixa::push_dep` mutation).
3200///
3201/// Same "closed-set typed-enum discriminator with canonical
3202/// projections per axis" discipline the sibling closed-set typed enums
3203/// on the caixa typed surface carry
3204/// ([`crate::aplicacao::PlacementStrategy`] cc8f749,
3205/// [`crate::aplicacao::RateLimitUnit`] 6bce03d,
3206/// [`crate::supervisor::RestartStrategy`],
3207/// [`crate::supervisor::RestartPolicy`],
3208/// [`crate::upgrade::UpgradeInstruction`], [`crate::CaixaKind`])
3209/// — extended onto the outer-`Caixa` two-list dep-graph axis, the
3210/// substrate's last unlifted closed-set-shaped `&'static str`-carrying
3211/// axis on the top-level manifest surface.
3212#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, gen_platform::IsVariant)]
3213pub enum DepList {
3214    /// Runtime-closure `:deps` axis — the load-bearing dep-list the
3215    /// lacre closure resolves at every build. Wire-format
3216    /// [`crate::render::DEP_AUTHOR_KEY_DEPS`].
3217    Prod,
3218    /// Dev-only-closure `:deps-dev` axis — Cargo's `[dev-dependencies]`
3219    /// table's dev-time-only visibility contract per CAIXA-SDLC §I.
3220    /// Wire-format [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`].
3221    Dev,
3222}
3223
3224impl DepList {
3225    /// Exhaustive iteration surface for every consumer that reads the
3226    /// full closed-set (the future M4 admission webhook's per-list
3227    /// summary rejection body, any future round-trip pin harness). A
3228    /// future variant addition extends this slice as a single edit and
3229    /// every consumer picks up the new entry by construction — the
3230    /// compiler-checked exhaustiveness on the sibling method `match`
3231    /// arms is the build-time guarantee that no arm forgets to grow.
3232    pub const ALL: &'static [Self] = &[Self::Prod, Self::Dev];
3233
3234    /// Canonical author-surface tag every substrate consumer that
3235    /// names the offending dep-list in a diagnostic reaches for —
3236    /// [`crate::render::DEP_AUTHOR_KEY_DEPS`] for [`Self::Prod`] and
3237    /// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] for [`Self::Dev`],
3238    /// the same `&'static str` payload the sibling
3239    /// [`DepError::DuplicateNome`] and [`DepError::DepIsSelf`] variants
3240    /// already carry. Routing every dep-list diagnostic through the
3241    /// closed-set enum's `as_str` closes the last `&'static str`-shape
3242    /// literal-carry axis on the two-list dep-graph surface — a
3243    /// future kebab-case rebrand (`":deps"` → `":packages"`) or a
3244    /// wire-format promotion (a distinct diagnostic form for the
3245    /// `Dev` arm) reaches every consumer through one edit on the
3246    /// canonical constant, not a coordinated rewrite across the
3247    /// substrate's dep-graph consumers.
3248    #[must_use]
3249    pub const fn as_str(self) -> &'static str {
3250        match self {
3251            Self::Prod => crate::render::DEP_AUTHOR_KEY_DEPS,
3252            Self::Dev => crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
3253        }
3254    }
3255
3256    /// Substrate-canonical reverse projection on the two-list dep-graph
3257    /// axis — parses the author-surface wire tag back to the typed
3258    /// variant, or `None` when `s` is outside the closed-set arm-string
3259    /// set [`Self::as_str`] emits. Dispatches on the same lifted
3260    /// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3261    /// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] constants the
3262    /// [`Self::as_str`] emitter walks, so the parse and emit halves of
3263    /// the round-trip migrate through one caixa-core edit on any future
3264    /// list-axis addition.
3265    ///
3266    /// Prior to this lift the substrate carried only the forward
3267    /// `Self → &str` projection on the two-list dep-graph axis (the
3268    /// [`Self::as_str`] emitter, the [`std::fmt::Display`] impl routed
3269    /// through it, the two [`DepError::DuplicateNome`] /
3270    /// [`DepError::DepIsSelf`] variants that carry the wire tag verbatim
3271    /// as a `&'static str` `list:` field). Every future consumer that
3272    /// wanted to promote the wire tag back to the typed enum (a future
3273    /// `feira dep --list <deps|deps-dev>` CLI arg-parse that binds the
3274    /// wire form into the typed enum before dispatching to
3275    /// [`crate::Caixa::deps_of`] / [`crate::Caixa::push_dep`], the M4
3276    /// `mesh.pleme.io/v1alpha1/Caixa` CR materializer's admission-time
3277    /// wire re-parse of the per-list diagnostic body, a future
3278    /// [`DepError`] widening that promotes the two `list: &'static str`
3279    /// fields to a typed `list: DepList` carry so downstream consumers
3280    /// dispatch on the enum rather than string-comparing the wire
3281    /// scalar) would have had to re-inline a two-arm `match s { ":deps"
3282    /// => …, ":deps-dev" => …, _ => … }` cascade that expressed no
3283    /// compile-time link back to the typed [`DepList`] enum. A future
3284    /// variant addition (a `:build-dep` or `:test-dep` third list once
3285    /// the substrate grows Cargo-style split-graphs, a `:tool-dep` for
3286    /// build-time-only tooling per the peer Cargo `[build-dependencies]`
3287    /// / `[target.<cfg>.dev-dependencies]` future admission surface)
3288    /// would silently split the wire byte-string the emitter walks from
3289    /// the parser's arm-set — the round-trip would carry the new list
3290    /// through the forward projection but land on the fallback silently
3291    /// at every non-updated reverse parser, far from the arm-addition
3292    /// commit that caused the drift. Lifting the resolver to a typed
3293    /// method on the substrate primitive closes the drift footgun by
3294    /// construction: the parser's accept-set is the same set the
3295    /// [`Self::as_str`] emitter walks (routed through the same lifted
3296    /// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3297    /// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] consts), so both halves
3298    /// of the round-trip migrate through one caixa-core edit on any
3299    /// future list-axis addition.
3300    ///
3301    /// Same closed-set-reverse-projection discipline the sibling
3302    /// [`crate::CaixaKind::from_wire`] (2aa6d23) /
3303    /// [`crate::supervisor::RestartStrategy::from_wire`] (4eec29c) /
3304    /// [`crate::supervisor::RestartPolicy::from_wire`] (dd32ccf) /
3305    /// [`crate::aplicacao::PlacementStrategy::from_wire`] (18c7342) /
3306    /// [`crate::aplicacao::RateLimitUnit::from_suffix`] typed enums
3307    /// carry on the peer wire-side `str → Self` axes — extended onto
3308    /// the two-list dep-graph closed-set axis, the sixth substrate-side
3309    /// closed-set typed enum on the caixa surface to converge on the
3310    /// two-way `str ↔ Self` round-trip. Method-named `from_wire` (not
3311    /// `from_str`) to match the peer shapes verbatim and side-step the
3312    /// derived [`std::str::FromStr`] impls the sibling
3313    /// [`gen_platform::FromStrKind`]-carrying axes install on their
3314    /// kebab-case dispatcher-catalog identity. Returns `Option<Self>`
3315    /// (rather than `Result<Self, _>`) to match the peer shapes: the
3316    /// caller picks the diagnostic form appropriate for its use site —
3317    /// a future `feira dep --list …` arg-parse that surfaces
3318    /// `unknown list: <arg>` at the CLI builds one on top by iterating
3319    /// [`Self::ALL`], while the future M4 admission-webhook's rejection
3320    /// path folds `None` onto its per-CR structured refusal body.
3321    #[must_use]
3322    pub fn from_wire(s: &str) -> Option<Self> {
3323        match s {
3324            crate::render::DEP_AUTHOR_KEY_DEPS => Some(Self::Prod),
3325            crate::render::DEP_AUTHOR_KEY_DEPS_DEV => Some(Self::Dev),
3326            _ => None,
3327        }
3328    }
3329}
3330
3331/// Route [`std::fmt::Display`] through [`DepList::as_str`], so every
3332/// consumer that formats the axis as user-facing text (a future
3333/// `feira app graph` per-list summary, a future M4 admission-webhook
3334/// rejection body naming the offending list, this crate's own
3335/// [`DepError`] `#[error(...)]` templates when they widen to carry a
3336/// typed [`DepList`]) lands on the same author-surface tag the
3337/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3338/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] constants carry. Same
3339/// as-str-through-Display convergence discipline the sibling
3340/// [`crate::aplicacao::PlacementStrategy`],
3341/// [`crate::aplicacao::RateLimitUnit`],
3342/// [`crate::supervisor::RestartStrategy`],
3343/// [`crate::supervisor::RestartPolicy`], and [`crate::CaixaKind`]
3344/// closed-set typed enums carry.
3345impl std::fmt::Display for DepList {
3346    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3347        f.write_str(self.as_str())
3348    }
3349}
3350
3351/// Errors raised by [`Dep::validate`].
3352///
3353/// Mirrors the per-axis error families the other `:versao`-carrying
3354/// typed surfaces expose
3355/// ([`crate::AplicacaoError::MembroVersaoEmpty`] /
3356/// [`crate::AplicacaoError::MembroVersaoInvalid`],
3357/// [`crate::SupervisorError::EmptyChildVersion`] /
3358/// [`crate::SupervisorError::ChildVersaoInvalid`]) so a future top-
3359/// level `CaixaError` (M4) sums these without reshaping the diagnostic.
3360#[derive(Debug, Error, PartialEq, Eq)]
3361pub enum DepError {
3362    #[error(
3363        ":deps entry has empty :nome (every dep must name a target caixa; \
3364         omit the entry instead of carrying an empty name)"
3365    )]
3366    NomeEmpty,
3367    #[error(
3368        ":deps entry :nome {nome:?} is not a valid DNS-1123 label: {reason} \
3369         (the value flows verbatim as the target caixa's `:nome`, the rendered \
3370         `lareira-<nome>` Helm chart name segment, the `LABEL_PROGRAM` label \
3371         value, and the resolver's checkout-directory leaf — each apiserver-side \
3372         schema rejects non-DNS-1123 names at admission time; use a lowercase \
3373         RFC 1123 label like `\"caixa-teia\"` or `\"pleme-mesh\"`, 1..=63 bytes, \
3374         pattern `^[a-z0-9]([-a-z0-9]*[a-z0-9])?$`)"
3375    )]
3376    NomeInvalid { nome: String, reason: String },
3377    #[error(
3378        ":deps entry {nome:?} has empty :versao (every dep must pin a semver \
3379         constraint that resolves through the lacre pipeline)"
3380    )]
3381    VersaoEmpty { nome: String },
3382    #[error(
3383        ":deps entry {nome:?} :versao {versao:?} is not a valid semver \
3384         requirement: {reason} (use Cargo-shaped forms like `\"^0.1\"`, \
3385         `\"~0.1.2\"`, `\"0.1.0\"`, or `\"*\"` — the same shape `:membros :versao` \
3386         and `:children :versao` carry; the lacre pipeline resolves all three \
3387         through the same parser)"
3388    )]
3389    VersaoInvalid {
3390        nome: String,
3391        versao: String,
3392        reason: String,
3393    },
3394    #[error(
3395        ":deps entry {nome:?} :fonte (:tipo git …) has empty :repo \
3396         (every git source must name a repo — use a `github:org/repo` \
3397         shorthand, an `https://…` URL, or an ssh-git URL; omit the \
3398         entire :fonte block to fall back to the default-host resolver \
3399         convention)"
3400    )]
3401    FonteRepoEmpty { nome: String },
3402    #[error(
3403        ":deps entry {nome:?} :fonte (:tipo git …) :repo {repo:?} has \
3404         invalid value-shape: {reason} (the value flows verbatim into the \
3405         caixa-resolver's `git clone <repo>` subprocess invocation; every \
3406         documented form carries a `:` separator and no whitespace / \
3407         control / non-ASCII bytes — use a `github:org/repo` shorthand, \
3408         an `https://host/path` / `ssh://[user@]host/path` / \
3409         `git://host/path` / `file:///path` URL, or the `git@host:path` \
3410         scp-style SSH form)"
3411    )]
3412    FonteRepoShape {
3413        nome: String,
3414        repo: String,
3415        reason: String,
3416    },
3417    #[error(
3418        ":deps entry {nome:?} :fonte (:tipo git …) has no pin set \
3419         (set exactly one of :tag, :rev, or :branch so the resolver \
3420         can pick a reproducible commit; omit the entire :fonte block \
3421         to fall back to the default-host resolver convention, which \
3422         resolves the latest tag matching :versao)"
3423    )]
3424    FontePinMissing { nome: String },
3425    #[error(
3426        ":deps entry {nome:?} :fonte (:tipo git …) has multiple pins \
3427         set ({pins}); exactly one of :tag, :rev, or :branch must be \
3428         set so the resolver's checkout target is unambiguous (the \
3429         resolver's silent precedence is :rev > :tag > :branch — if \
3430         you intended one specifically, drop the others)"
3431    )]
3432    FontePinAmbiguous { nome: String, pins: String },
3433    #[error(
3434        ":deps entry {nome:?} :fonte (:tipo git …) has empty {pin} \
3435         (a set pin must name a non-empty git ref; drop the {pin} key \
3436         entirely to fall through to another pin axis)"
3437    )]
3438    FontePinEmpty { nome: String, pin: String },
3439    #[error(
3440        ":deps entry {nome:?} :fonte (:tipo git …) {pin} {value:?} has invalid \
3441         value-shape: {reason} (the git porcelain enforces the same shape at \
3442         `git fetch` / `git checkout` time on every pin; use a leaf refname \
3443         like `\"v0.1.0\"` for `:tag` or `\"main\"` / `\"feature/foo\"` for \
3444         `:branch`, or a full 40/64 lowercase-hex commit OID for `:rev` — \
3445         drop any `refs/heads/` or `refs/tags/` prefix the caixa-resolver \
3446         prepends at clone time, and avoid abbreviated SHAs which are \
3447         ambiguous across repository history)"
3448    )]
3449    FontePinShape {
3450        nome: String,
3451        pin: String,
3452        value: String,
3453        reason: String,
3454    },
3455    #[error(
3456        ":deps entry {nome:?} :fonte (:tipo path …) has empty :caminho \
3457         (every path source must name a non-empty filesystem path; \
3458         omit the entire :fonte block to fall back to the default-host \
3459         resolver convention)"
3460    )]
3461    FonteCaminhoEmpty { nome: String },
3462    #[error(
3463        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} is \
3464         absolute (the lacre pipeline embeds the value verbatim in its \
3465         per-dep content-address `path:{caminho}` at \
3466         caixa-resolver/src/resolve.rs:189, so an absolute path makes the \
3467         BLAKE3 closure differ across machines — defeating the \
3468         reproducibility contract that's load-bearing for CSE; express \
3469         the path relative to the caixa.lisp location, e.g. \
3470         \"../caixa-teia\" for a sibling workspace dep)"
3471    )]
3472    FonteCaminhoAbsolute { nome: String, caminho: String },
3473    #[error(
3474        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
3475         with `~` (the leading-tilde is a shell-expansion convention, not a \
3476         POSIX path component — `Path::is_absolute` returns false on it, so \
3477         the b94fd83 absolute-path gate doesn't catch it, but the lacre \
3478         pipeline embeds the value verbatim in its per-dep content-address \
3479         `path:{caminho}` at caixa-resolver/src/resolve.rs:189 and the \
3480         caixa-resolver folds it through `Path::join` without `~`-expansion, \
3481         so the build looks for a literal `./{caminho}` subdirectory and \
3482         fails at resolve time far from the source caixa.lisp; even worse, a \
3483         future caixa-resolver pass that *does* expand `~` would silently \
3484         re-open the host-layout-leak the b94fd83 absolute gate closes — \
3485         Alice's `~` resolves to `/home/alice`, Bob's to `/home/bob`, two CI \
3486         runners with different `$HOME` layouts resolve to two distinct paths \
3487         for the byte-identical caixa, defeating the THEORY.md §V.2 render-\
3488         determinism contract; express the path relative to the caixa.lisp \
3489         location, e.g. \"../caixa-teia\" for a sibling workspace dep, or \
3490         spell out the full relative path explicitly if a workstation-rooted \
3491         dep is genuinely intended)"
3492    )]
3493    FonteCaminhoTildeExpansion { nome: String, caminho: String },
3494    #[error(
3495        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
3496         with `$` (the leading-`$` is a shell-variable-expansion convention, \
3497         not a POSIX path component — `Path::is_absolute` returns false on it \
3498         and the a5c248e tilde gate doesn't catch it, but the lacre pipeline \
3499         embeds the value verbatim in its per-dep content-address \
3500         `path:{caminho}` at caixa-resolver/src/resolve.rs:189 and the \
3501         caixa-resolver folds it through `Path::join` without `$`-expansion, \
3502         so the build looks for a literal `./{caminho}` subdirectory and \
3503         fails at resolve time far from the source caixa.lisp; even worse, a \
3504         future caixa-resolver pass that *does* expand `$VAR` (the canonical \
3505         shell-convention idiom that CI's `${{WORKSPACE}}` paste-idiom \
3506         invites) would silently re-open the host-layout-leak the b94fd83 \
3507         absolute gate closes — Alice's `$HOME` resolves to `/home/alice`, \
3508         Bob's to `/home/bob`, two CI runners with different `${{WORKSPACE}}` \
3509         layouts resolve to two distinct paths for the byte-identical caixa, \
3510         defeating the THEORY.md §V.2 render-determinism contract; express \
3511         the path relative to the caixa.lisp location, e.g. \"../caixa-teia\" \
3512         for a sibling workspace dep, or spell out the full relative path \
3513         explicitly if a workstation-rooted dep is genuinely intended)"
3514    )]
3515    FonteCaminhoVarExpansion { nome: String, caminho: String },
3516    #[error(
3517        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
3518         with a space (the leading ASCII space `0x20` is the orthogonal \
3519         paste-from-aligned-doc footgun that silently passes \
3520         `Path::is_absolute` and every prior leading-byte arm — \
3521         `\" ../caixa-teia\"` resolves via `Path::join` to a literal \
3522         `./ ../caixa-teia` subdirectory the resolver fails to find at \
3523         resolve time with a non-self-locating `No such file or directory` \
3524         error far from the source caixa.lisp; the lacre pipeline embeds \
3525         the value verbatim in its per-dep content-address `path:{caminho}` \
3526         at caixa-resolver/src/resolve.rs:189, so byte-divergent / \
3527         semantic-identical caixa values (` ../caixa-teia` vs \
3528         `../caixa-teia`) yield two distinct BLAKE3 closures across two \
3529         workstations whose authors differ only in paste-from-aligned- \
3530         caixa.lisp-doc whitespace habits — the most insidious failure \
3531         mode the typed slot can carry (no error surfaces; the divergence \
3532         is invisible until two machines compare lacres), defeating the \
3533         THEORY.md §V.2 render-determinism contract. The canonical \
3534         paste-from-aligned-`:deps`-block footgun (every `:fonte` form in \
3535         a multi-entry `:deps` block sits at the same column — an author \
3536         selecting `\"<sp><sp><sp>../caixa-teia\"` and pasting it from \
3537         the rendered alignment into a fresh entry preserves the leading \
3538         whitespace verbatim); peer `:fonte :repo` axis already rejects \
3539         leading whitespace via `is_git_repo_url`, `:fonte :tag` / \
3540         `:fonte :branch` via `is_git_ref_name`, `:descricao` via \
3541         `is_chart_description_shape`, `:licenca` via \
3542         `is_spdx_expression_shape`. Drop the leading space; express the \
3543         path as a bare relative single-token like \"../caixa-teia\")"
3544    )]
3545    FonteCaminhoLeadingWhitespace { nome: String, caminho: String },
3546    #[error(
3547        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
3548         with `-` (the canonical CLI-argument-injection footgun on the \
3549         `:caminho` axis — the lacre pipeline embeds the value verbatim in \
3550         its per-dep content-address `path:{caminho}` at \
3551         caixa-resolver/src/resolve.rs:189 and the caixa-resolver folds it \
3552         through `Path::join` looking for a literal `./{caminho}` \
3553         subdirectory. Every downstream subprocess that consumes the resolved \
3554         path — `git -C {caminho} <verb>`, `terraform -chdir={caminho}`, \
3555         `nix build --path {caminho}`, `find {caminho}`, `stat {caminho}`, \
3556         `cp -r {caminho} …`, `rm -rf {caminho}` — reinterprets a leading-`-` \
3557         value as a CLI flag rather than a positional path when the invocation \
3558         does not carry a `--` argument-list terminator between the flag block \
3559         and the path (the common case at every porcelain entry point). The \
3560         canonical footguns: `:caminho \"-rf\"` (bare short-flag paste), \
3561         `:caminho \"-C\"` (`git -C -C` config-injection paste), \
3562         `:caminho \"--upload-pack=cat /etc/passwd\"` (the canonical long-flag \
3563         CLI-arg-injection vector at every git porcelain entry point that \
3564         consumes a path or URL argument, peer with is_git_repo_url's \
3565         leading-`-` arm on the sibling `:fonte :repo` axis), \
3566         `:caminho \"--config=…\"` (`git -c foo=bar` config-override paste). \
3567         POSIX `std::path::Path` treats a leading `-` as a literal filename \
3568         byte so the resolver folds `\"-rf\"` through `Path::join` and looks \
3569         for a literal `./-rf` subdirectory that fails at resolve time with a \
3570         non-self-locating `No such file or directory` error far from the \
3571         source caixa.lisp — but on any downstream shell-out without `--` the \
3572         reinterpretation is silent and the failure mode is arbitrary-\
3573         argument-injection. Peer arms: `is_git_repo_url` (render.rs:2037) \
3574         rejects leading `-` on `:fonte :repo` for `git clone <repo>` CLI-\
3575         arg-injection; `is_git_ref_name` (render.rs:1381, 5a28454) rejects \
3576         leading `-` on `:fonte :tag` / `:branch` for `git checkout <ref>` \
3577         CLI-arg-injection; `is_dns_1123_label` rejects leading `-` on every \
3578         DNS-1123-shaped axis (top-level Caixa `:nome`, `:membros :caixa`, \
3579         `:children :caixa`, `:deps :nome`, cluster names); \
3580         `is_cargo_feature_name` rejects leading `-` on `:caracteristicas`; \
3581         the feira `init` / `add <nome>` positional gate (868c191) rejects \
3582         leading `-` on the CLI positional itself. Express the path as a bare \
3583         relative single-token like \"../caixa-teia\" — the sibling-workspace \
3584         directory name carries no leading-hyphen semantic, and `./` / `../` \
3585         prefixes structurally partition the leading-byte set to safe values.)"
3586    )]
3587    FonteCaminhoLeadingHyphen { nome: String, caminho: String },
3588    #[error(
3589        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains \
3590         ASCII control byte 0x{byte:02x} (POSIX paths reject NUL `0x00` outright — \
3591         every `std::fs` syscall routes the path through `CString::new` which \
3592         fails with `NulError` at resolve time; the lacre pipeline embeds the \
3593         value verbatim in its per-dep content-address `path:{caminho}` at \
3594         caixa-resolver/src/resolve.rs:189 so a control byte anywhere in the \
3595         value lands in the BLAKE3 closure and breaks the THEORY.md §V.2 render-\
3596         determinism contract — the canonical paste-from-multiline-doc \
3597         (`\\n`/`\\r`), paste-from-aligned-table (`\\t`), or paste-from-binary-\
3598         blob (`0x00`-DEL) footgun every peer single-token-shaped axis \
3599         (`:fonte :repo`, `:fonte :tag`/`:branch`, the Helm chart-string axes) \
3600         already gates against. Express the path as a relative single-line ASCII \
3601         string, e.g. \"../caixa-teia\" for a sibling workspace dep)"
3602    )]
3603    FonteCaminhoControlChar {
3604        nome: String,
3605        caminho: String,
3606        byte: u8,
3607    },
3608    #[error(
3609        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains `\\` \
3610         (POSIX `std::path::Path` treats `\\` as a literal byte inside a single path \
3611         component, so `..\\caixa-teia` is one directory named literally `..\\caixa-teia` — \
3612         not the parent's sibling — and the caixa-resolver folds the value through \
3613         `Path::join` looking for a literal `./{caminho}` subdirectory that fails at \
3614         resolve time with a non-self-locating `No such file or directory` error far \
3615         from the source caixa.lisp; Windows `std::path::Path` treats `\\` as a \
3616         primary path separator equal to `/`, so byte-identical caixa.lisp values \
3617         resolve to two distinct directories across runner OSes — the lacre pipeline \
3618         embeds the value verbatim in its per-dep content-address `path:{caminho}` at \
3619         caixa-resolver/src/resolve.rs:189, defeating the THEORY.md §V.2 render-\
3620         determinism contract via the cross-host-OS-separator divergence vector. The \
3621         canonical Windows-Explorer `Copy as path` / PowerShell `Get-Location` \
3622         paste-idiom footgun; peer `:fonte :tag` / `:fonte :branch` axis already \
3623         rejects `\\` via `is_git_ref_name` for the same Windows-path-leak reason, \
3624         and `:entrada :paths` rejects `\\` via `is_gateway_api_http_path`'s eleven-\
3625         byte RFC-3986-reserved set. Express the path with `/` as the separator, e.g. \
3626         \"../caixa-teia\" for a sibling workspace dep)"
3627    )]
3628    FonteCaminhoBackslash { nome: String, caminho: String },
3629    #[error(
3630        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3631         redirection metacharacter 0x{byte:02x} `{ch}` (every interactive shell — bash / \
3632         zsh / fish / nushell — lexes `<` and `>` as input / output redirection \
3633         operators, so `:caminho \"../caixa-teia>build.log\"` is the canonical \
3634         paste-from-shell-pipeline footgun where an author copies a `command > log` \
3635         tail without trimming the redirect; POSIX `std::path::Path` treats both bytes \
3636         as literal path-component bytes, so the resolver folds the value through \
3637         `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
3638         subdirectory and fails at resolve time with a non-self-locating `No such \
3639         file or directory` error far from the source caixa.lisp. The lacre pipeline \
3640         embeds the value verbatim in its per-dep content-address `path:{caminho}` at \
3641         caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure \
3642         and rides into every shell-spawned subprocess (the resolver's `git clone`, a \
3643         future `feira tofu` shell-out, a future operator-side `nix` spawn) as the \
3644         canonical CRLF-at-subprocess-argument / shell-metachar injection surface every \
3645         peer single-token-shaped typed slot already closes. The peer `:fonte :tag` / \
3646         `:fonte :branch` axis already rejects `<` / `>` via `is_git_ref_name`, and \
3647         `:entrada :paths` rejects them via `is_gateway_api_http_path`'s eleven-byte \
3648         RFC-3986-reserved set. Express the path as a bare relative single-token like \
3649         \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
3650         redirection semantic.",
3651        ch = *byte as char
3652    )]
3653    FonteCaminhoShellRedirection {
3654        nome: String,
3655        caminho: String,
3656        byte: u8,
3657    },
3658    #[error(
3659        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-pipe \
3660         metacharacter `|` (every interactive shell — bash / zsh / fish / nushell — lexes \
3661         `|` as the pipe operator that wires one command's stdout to the next command's \
3662         stdin, so `:caminho \"../caixa-teia | grep foo\"` is the canonical paste-from-\
3663         shell-history footgun where an author copies a `ls ../caixa-teia | grep` line \
3664         without trimming the pipeline tail, and `:caminho \"../foo||bar\"` is the \
3665         symmetric `cmd-a || cmd-b` short-circuit-OR paste shape; POSIX `std::path::Path` \
3666         treats `|` as a literal path-component byte, so the resolver folds the value \
3667         through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
3668         subdirectory and fails at resolve time with a non-self-locating `No such file or \
3669         directory` error far from the source caixa.lisp. The lacre pipeline embeds the \
3670         value verbatim in its per-dep content-address `path:{caminho}` at caixa-resolver/\
3671         src/resolve.rs:189, so the byte lands in the BLAKE3 closure and rides into every \
3672         shell-spawned subprocess (the resolver's `git clone`, a future `feira tofu` \
3673         shell-out, a future operator-side `nix` spawn) as the canonical CRLF-at-\
3674         subprocess-argument / shell-metachar injection surface every peer single-token-\
3675         shaped typed slot already closes. The peer `:entrada :paths` axis rejects `|` \
3676         via `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the \
3677         path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
3678         workspace directory name carries no shell-pipe semantic."
3679    )]
3680    FonteCaminhoShellPipe { nome: String, caminho: String },
3681    #[error(
3682        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3683         command-separator metacharacter `;` (every interactive shell — bash / zsh / fish \
3684         / nushell — lexes `;` as the sequential-command terminator that fires the next \
3685         command regardless of the prior command's exit status, so `:caminho \
3686         \"../caixa-teia; rm -rf build\"` is the canonical paste-from-shell-one-liner \
3687         footgun where an author copies a `cd path; do-thing` chain without trimming \
3688         the cleanup tail, and `:caminho \"../foo;;bar\"` is the symmetric POSIX `case` \
3689         arm `;;` terminator paste shape; POSIX `std::path::Path` treats `;` as a \
3690         literal path-component byte, so the resolver folds the value through \
3691         `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
3692         subdirectory and fails at resolve time with a non-self-locating `No such file \
3693         or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
3694         the value verbatim in its per-dep content-address `path:{caminho}` at \
3695         caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
3696         rides into every shell-spawned subprocess (the resolver's `git clone`, a \
3697         future `feira tofu` shell-out, a future operator-side `nix` spawn) as the \
3698         canonical shell-metachar injection surface every peer single-token-shaped \
3699         typed slot already closes. The peer `:entrada :paths` axis rejects `;` via \
3700         `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the \
3701         path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
3702         workspace directory name carries no shell-command-separator semantic."
3703    )]
3704    FonteCaminhoShellSemicolon { nome: String, caminho: String },
3705    #[error(
3706        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3707         background / list-AND metacharacter `&` (every interactive shell — bash / zsh \
3708         / fish / nushell — lexes `&` two ways: single `&` as the background-task \
3709         terminator detaching the prior command and returning control immediately to \
3710         the prompt, double `&&` as the logical-AND list operator firing the next \
3711         command only if the prior succeeded; POSIX `std::path::Path` treats it as a \
3712         literal byte. The canonical paste-from-shell-prompt footgun is a `cd path & \
3713         sleep 1` background-launch one-liner or a `cd path && make install` build-\
3714         chain idiom selected whole into the `:caminho` slot — the prior `;` arm at \
3715         05c358e closed the sequential-command-separator vector, this arm closes the \
3716         orthogonal background-task / logical-AND vector on the same paste-from-shell-\
3717         prompt class. The lacre pipeline embeds the value verbatim in its per-dep \
3718         content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the \
3719         byte lands in the BLAKE3 closure and rides into every shell-spawned \
3720         subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a \
3721         future operator-side `nix` spawn) as the canonical shell-metachar injection \
3722         surface every peer single-token-shaped typed slot already closes. The peer \
3723         `:entrada :paths` axis rejects `&` via `is_gateway_api_http_path`'s eleven-\
3724         byte RFC-3986-reserved set. Express the path as a bare relative single-token \
3725         like \"../caixa-teia\" — the sibling-workspace directory name carries no \
3726         shell-background / logical-AND semantic."
3727    )]
3728    FonteCaminhoShellBackground { nome: String, caminho: String },
3729    #[error(
3730        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3731         command-substitution metacharacter `` ` `` (every POSIX shell — sh / bash / zsh / \
3732         dash / ksh / fish / nushell — lexes the byte as the legacy command-substitution \
3733         wrapper that runs the enclosed command and substitutes its standard-output \
3734         verbatim into the surrounding word, so a backticked `whoami` expands to the \
3735         current user's name and a backticked `cat /etc/passwd` expands to the file's \
3736         contents — the canonical CWE-78 shell-command-injection vector; POSIX \
3737         `std::path::Path` treats the byte as a literal path-component byte. The canonical \
3738         paste-from-shell-prompt footgun is a `cd ../path/<backtick>whoami<backtick>` legacy substitution \
3739         one-liner or a `cd <backtick>pwd<backtick>/path` working-directory expansion idiom selected whole \
3740         into the `:caminho` slot — the prior `&` arm at e12e4f3 closed the shell-\
3741         background / logical-AND vector, this arm closes the orthogonal command-\
3742         substitution vector on the same paste-from-shell-prompt class (the modern `$()` \
3743         form is gated at leading position by the f4efe9c `FonteCaminhoVarExpansion` arm; \
3744         the legacy backtick form is the orthogonal axis). The lacre pipeline embeds the \
3745         value verbatim in its per-dep content-address `path:{caminho}` at \
3746         caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
3747         rides into every shell-spawned subprocess (the resolver's `git clone`, a future \
3748         `feira tofu` shell-out, a future operator-side `nix` spawn) as the canonical \
3749         shell-metachar injection surface every peer single-token-shaped typed slot \
3750         already closes. The peer `:entrada :paths` axis rejects the byte via \
3751         `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the path \
3752         as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
3753         directory name carries no shell-command-substitution semantic."
3754    )]
3755    FonteCaminhoShellCommandSubstitution { nome: String, caminho: String },
3756    #[error(
3757        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3758         glob / pathname-expansion metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — \
3759         sh / bash / zsh / dash / ksh / fish / nushell — lexes `*` and `?` as pathname-\
3760         expansion wildcards: `*` matches any sequence of characters in a path component \
3761         and `?` matches exactly one character, so a `:caminho \"../caixa-teia/*\"` is the \
3762         canonical paste-from-shell-listing footgun where an author copies a \
3763         `ls ../caixa-teia/*` listing without trimming the wildcard, and `:caminho \
3764         \"../foo?\"` is the symmetric single-char-wildcard paste shape; POSIX \
3765         `std::path::Path` treats both bytes as literal path-component bytes, so the \
3766         resolver folds the value through `Path::new(caminho).join(<file>)` looking for \
3767         a literal `./{caminho}` subdirectory and fails at resolve time with a non-self-\
3768         locating `No such file or directory` error far from the source caixa.lisp. The \
3769         lacre pipeline embeds the value verbatim in its per-dep content-address \
3770         `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in the \
3771         BLAKE3 closure and rides into every shell-spawned subprocess (the resolver's \
3772         `git clone`, a future `feira tofu` shell-out, a future operator-side `nix` \
3773         spawn) as the canonical shell-metachar / glob-expansion surface every peer \
3774         single-token-shaped typed slot already closes. The peer `:entrada :paths` axis \
3775         rejects `*` and `?` via `is_gateway_api_http_path`'s eleven-byte RFC-3986-\
3776         reserved set. Express the path as a bare relative single-token like \
3777         \"../caixa-teia\" — the sibling-workspace directory name carries no shell-glob \
3778         / pathname-expansion semantic.",
3779        ch = *byte as char
3780    )]
3781    FonteCaminhoShellGlob {
3782        nome: String,
3783        caminho: String,
3784        byte: u8,
3785    },
3786    #[error(
3787        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3788         subshell-grouping metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / \
3789         zsh / dash / ksh / fish / nushell — lexes `(` and `)` as the subshell-grouping \
3790         operator: `(<cmd>)` runs `<cmd>` in a child shell with a fresh environment scope \
3791         (the canonical `(cd <path> && <cmd>)` shell-history one-liner scopes a `cd` to one \
3792         subshell without disturbing the parent's working directory), and `$(<cmd>)` is the \
3793         modern Bourne command-substitution shape the leading-`$` `FonteCaminhoVarExpansion` \
3794         arm closes the leading byte of — together the two arms now structurally exclude the \
3795         entire `$(<cmd>)` substitution surface from the typed `:caminho` accepted set. \
3796         POSIX `std::path::Path` treats the byte as a literal path-component byte, so a \
3797         `:caminho \"../caixa-teia/$(date)/build\"` (the canonical paste-from-shell-history \
3798         modern-command-substitution footgun) or `:caminho \"../(cd foo && pwd)/caixa-teia\"` \
3799         (the symmetric subshell-grouping working-directory-probe paste idiom) silently passes \
3800         every prior arm and the resolver folds the value through `Path::new(caminho).join(\
3801         <file>)` looking for a literal subdirectory and fails at resolve time with a non-\
3802         self-locating `No such file or directory` error far from the source caixa.lisp. The \
3803         lacre pipeline embeds the value verbatim in its per-dep content-address `path:\
3804         {caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 \
3805         closure and rides into every shell-spawned subprocess (the resolver's `git clone`, a \
3806         future `feira tofu` shell-out, a future operator-side `nix` spawn) as the canonical \
3807         shell-metachar / subshell-grouping surface every peer single-token-shaped typed slot \
3808         already closes. The peer `:fonte :repo` axis (3b99147) closes the same byte under the \
3809         same shell-subshell-grouping / RFC-3986-sub-delims banner on `is_git_repo_url`, \
3810         together with the leading-`$` `FonteCaminhoVarExpansion` arm closing the leading byte \
3811         of every `$(<cmd>)` shape. Express the path as a bare relative single-token \
3812         like \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
3813         subshell-grouping semantic.",
3814        ch = *byte as char
3815    )]
3816    FonteCaminhoShellSubshellGrouping {
3817        nome: String,
3818        caminho: String,
3819        byte: u8,
3820    },
3821    #[error(
3822        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3823         brace-expansion / URI-Template placeholder metacharacter 0x{byte:02x} `{ch}` \
3824         (every POSIX-derived brace-expanding shell — bash / zsh / ksh / fish — lexes `{{` / \
3825         `}}` as the brace-expansion operator: `{{a,b,c}}` expands to the cross-product of \
3826         comma-separated members and `{{1..10}}` expands to the integer range — the \
3827         canonical `mkdir -p ../{{caixa-teia,caixa-helm,caixa-flux}}` / `cp file{{,.bak}}` \
3828         idiom every shell-history block carries; RFC 6570 reserves the matched pair for \
3829         URI Template placeholders (the canonical `https://{{host}}/{{org}}/{{repo}}` \
3830         substitution shape every OpenAPI / Swagger / Postman / GitHub Octokit client \
3831         library / Helm chart-URL fragment carries) and the Mustache / Handlebars / \
3832         Tera / Jinja2 / Go html/template doubled-brace substitution form every IaC \
3833         templating engine (Helm, Kustomize, Terraform's `${{var}}` cousin) emits. POSIX \
3834         `std::path::Path` treats the byte as a literal path-component byte, so a \
3835         `:caminho \"../{{caixa-teia,caixa-helm}}/build\"` (the canonical paste-from-\
3836         shell-history brace-expansion fan-across-siblings footgun) or `:caminho \"../{{{{org}}}}/\
3837         caixa-teia\"` (the symmetric paste-from-templated-doc URI-Template placeholder \
3838         idiom every README quick-start / OpenAPI spec / Helm chart `home:` field carries) \
3839         silently passes every prior arm and the resolver folds the value through \
3840         `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
3841         resolve time with a non-self-locating `No such file or directory` error far from \
3842         the source caixa.lisp. The lacre pipeline embeds the value verbatim in its \
3843         per-dep content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, \
3844         so the byte lands in the BLAKE3 closure and rides into every shell-spawned \
3845         subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a \
3846         future operator-side `nix` spawn) as the canonical shell-metachar / brace-\
3847         expansion / URI-Template-placeholder surface every peer single-token-shaped \
3848         typed slot already closes. The peer `:fonte :repo` axis (42d8f9d) closes the \
3849         same byte pair on `is_git_repo_url` under the same RFC-3986-'delims' / \
3850         RFC-6570-URI-Template / shell-brace-expansion banner. Express the path as a \
3851         bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
3852         directory name carries no shell-brace-expansion / URI-Template-placeholder \
3853         semantic; if two siblings actually need pinning, author two separate `:deps` \
3854         entries rather than one brace-expanded `:caminho` value.",
3855        ch = *byte as char
3856    )]
3857    FonteCaminhoShellBraceExpansion {
3858        nome: String,
3859        caminho: String,
3860        byte: u8,
3861    },
3862    #[error(
3863        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3864         bracket-expansion / POSIX glob-character-class / shell-`test`-builtin metacharacter \
3865         0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / nushell \
3866         — lexes the bracket pair as the glob character-class operator: `[abc]` matches one of \
3867         `a` / `b` / `c`, `[a-z]` matches any lowercase ASCII letter, `[^x]` negates — the \
3868         canonical `ls *.[ch]` C-source-file glob and `cd ../caixa-[a-z]*` lowercase-sibling \
3869         glob every shell-history block carries; the bracket pair additionally carries the \
3870         POSIX `test` / `[` builtin command (`[ -d ../caixa-teia ] && cd ...` every shell-\
3871         script conditional uses) and bash's `[[ ... ]]` extended-test grammar; beyond shell \
3872         the pair is the TOML inline-array delimiter (`features = [\"a\", \"b\"]` — the \
3873         canonical paste-from-Cargo-manifest cross-idiom-leak vector), the YAML flow-sequence \
3874         delimiter (`paths: [/a, /b]` — the canonical paste-from-values.yaml cross-idiom \
3875         leak), the JSON array delimiter, and the POSIX-ERE / PCRE bracket-expression anchor. \
3876         POSIX `std::path::Path` treats the byte as a literal path-component byte, so a \
3877         `:caminho \"../caixa-[a-z]/build\"` (the canonical paste-from-shell-history glob-\
3878         character-class fan-across-siblings footgun) or `:caminho \"../[caixa-teia]/build\"` \
3879         (the symmetric paste-from-TOML-array / paste-from-YAML-flow-sequence cross-idiom \
3880         leak) silently passes every prior arm and the resolver folds the value through \
3881         `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
3882         resolve time with a non-self-locating `No such file or directory` error far from \
3883         the source caixa.lisp. The lacre pipeline embeds the value verbatim in its per-dep \
3884         content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte \
3885         lands in the BLAKE3 closure and rides into every shell-spawned subprocess (the \
3886         resolver's `git clone`, a future `feira tofu` shell-out, a future operator-side \
3887         `nix` spawn) as the canonical shell-metachar / glob-character-class / TOML-array \
3888         surface every peer single-token-shaped typed slot already closes. Express the path \
3889         as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
3890         directory name carries no shell-bracket-expansion / glob-character-class / array-\
3891         literal semantic; if a family of sibling caixas actually needs pinning, author \
3892         separate `:deps` entries rather than one character-class-expanded `:caminho` value.",
3893        ch = *byte as char
3894    )]
3895    FonteCaminhoShellBracketExpansion {
3896        nome: String,
3897        caminho: String,
3898        byte: u8,
3899    },
3900    #[error(
3901        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3902         quote-grouping / cross-config-DSL string-literal-delimiter metacharacter \
3903         0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / \
3904         nushell — lexes `'` as the strong string-literal delimiter (`'…'` — no expansion) \
3905         and `\"` as the weak string-literal delimiter (`\"…\"` — variable- / command-\
3906         substitution-preserving); the canonical `cd '../caixa-teia'` shell-history idiom \
3907         every path-with-embedded-whitespace paste block carries and the symmetric \
3908         `git clone \"$REPO\"` weak-quoted CI-manifest shape both leak the pair verbatim. \
3909         Beyond shell the pair is the JSON string-literal delimiter (`\"key\": \"value\"` — \
3910         the canonical paste-from-JSON-config cross-idiom-leak vector), the YAML double- \
3911         and single-quoted flow-scalar delimiter (`path: \"../caixa-teia\"` — the canonical \
3912         paste-from-values.yaml / paste-from-K8s-YAML-manifest cross-idiom leak), the TOML \
3913         basic and literal string delimiter (`path = \"../caixa-teia\"` — the canonical \
3914         paste-from-Cargo-manifest cross-idiom leak), the tatara-lisp string-literal \
3915         delimiter itself (`(:caminho \"../caixa-teia\")` — the canonical \"I copied the \
3916         entire `:caminho \"...\"` slot rather than just the string body\" author-surface \
3917         footgun), and RFC 3986 §2.2's `gen-delims` / `sub-delims` grammar which excludes \
3918         both bytes from the `pchar = unreserved / pct-encoded / sub-delims / \":\" / \"@\"` \
3919         production. POSIX `std::path::Path` treats the byte as a literal path-component \
3920         byte, so a `:caminho \"'../caixa-teia'\"` (the canonical paste-from-shell-history \
3921         strong-quoted sibling-workspace path footgun) or `:caminho \"\\\"../caixa-teia\\\"\"` \
3922         (the symmetric weak-quoted paste-from-JSON / paste-from-YAML flow-scalar / paste-\
3923         from-TOML basic-string / paste-from-tatara-lisp string-literal cross-idiom-leak \
3924         shape) silently passes every prior arm and the resolver folds the value through \
3925         `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
3926         resolve time with a non-self-locating `No such file or directory` error far from \
3927         the source caixa.lisp. The lacre pipeline embeds the value verbatim in its per-dep \
3928         content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte \
3929         lands in the BLAKE3 closure and rides into every shell-spawned subprocess (the \
3930         resolver's `git clone`, a future `feira tofu` shell-out, a future operator-side \
3931         `nix` spawn) as the canonical shell-metachar / string-literal-delimiter surface \
3932         every peer single-token-shaped typed slot already closes. The peer `:fonte :repo` \
3933         axis closes both bytes under the same shell-quote-grouping / RFC-3986-sub-delims \
3934         banner (e7a109f `'` shell-single-quote + 4267d8b `\"` shell-double-quote on \
3935         `is_git_repo_url`). Express the path as a bare relative single-token like \
3936         \"../caixa-teia\" — the sibling-workspace directory name carries no shell-quote-\
3937         grouping / string-literal-delimiter semantic; strip the outer quote pair from the \
3938         paste (the tatara-lisp `:caminho \"...\"` slot already carries the string-literal \
3939         quoting on the outer syntactic layer, so an inner quote pair would nest and \
3940         desugar to a broken layer).",
3941        ch = *byte as char
3942    )]
3943    FonteCaminhoShellQuoteGrouping {
3944        nome: String,
3945        caminho: String,
3946        byte: u8,
3947    },
3948    #[error(
3949        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3950         comment / URL-fragment-identifier / YAML-comment cross-config-DSL metacharacter \
3951         0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / \
3952         nushell — lexes an unquoted `#` at the head of a word or after unquoted \
3953         whitespace as the comment-lead per POSIX.1-2017 §2.3 Token Recognition step 6, \
3954         discarding the byte and everything after it to the end of the physical line \
3955         before command parsing (`cd ../caixa-teia  # legacy sibling` — the canonical \
3956         paste-from-shell-history-with-trailing-annotation shape every operator-notebook \
3957         and CI-manifest carries); YAML 1.2 §6.6 makes `#` the comment-lead at any \
3958         position preceded by whitespace or at line-start (`path: ../caixa-teia  # pin` \
3959         — the canonical paste-from-values.yaml / paste-from-K8s-manifest cross-idiom-\
3960         leak); RFC 3986 §3.5 reserves `#` as the URL fragment-identifier delimiter (the \
3961         canonical paste-from-browser-address-bar `github.com/foo/bar#readme` / \
3962         `github.com/foo/bar#L42` permalink shape, and the symmetric Nix-flake-ref \
3963         cross-idiom leak `github:foo/bar#packageName` where `#` selects a flake \
3964         output); the same cross-config-DSL surface extends to HCL / Terraform / Nix \
3965         flake attributes / dotenv `.env` / gitconfig / .gitignore / ini / TOML where \
3966         `#` is likewise the comment-lead. POSIX `std::path::Path` treats the byte as a \
3967         literal path-component byte, so a `:caminho \"../caixa-teia # legacy sibling\"` \
3968         (the canonical paste-from-shell-history-with-trailing-annotation footgun), \
3969         `:caminho \"../caixa-teia  # pin\"` (the symmetric YAML flow-scalar paste-with-\
3970         trailing-comment shape), or `:caminho \"../caixa-teia#readme\"` (the URL \
3971         fragment paste-from-browser-address-bar shape) silently passes every prior arm \
3972         and the resolver folds the value through `Path::new(caminho).join(<file>)` \
3973         looking for a literal subdirectory named `../caixa-teia # legacy sibling` and \
3974         fails at resolve time with a non-self-locating `No such file or directory` \
3975         error far from the source caixa.lisp — while every downstream shell / YAML / \
3976         URL parser silently truncates the value at the `#` byte to `../caixa-teia`, so \
3977         a `feira tofu` shell-out and a `nix flake check` on an emitted YAML `path:` \
3978         scalar disagree with the resolver on which directory the value names. The \
3979         lacre pipeline embeds the value verbatim in its per-dep content-address \
3980         `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in \
3981         the BLAKE3 closure and rides into every shell-spawned subprocess (the \
3982         resolver's `git clone`, a future `feira tofu` shell-out, a future operator-\
3983         side `nix` spawn) as the canonical shell-metachar / comment-lead / URL-\
3984         fragment-delimiter surface every peer single-token-shaped typed slot already \
3985         closes. The peer `:fonte :repo` axis closes the byte under the same URL-\
3986         fragment-identifier banner (a68f818 `#` on `is_git_repo_url`). Express the \
3987         path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
3988         workspace directory name carries no shell-comment / URL-fragment / YAML-\
3989         comment semantic; move any trailing annotation to a tatara-lisp `;`-comment \
3990         on the surrounding form (`;; legacy sibling` above the `(:caminho ...)` slot) \
3991         and drop any `#fragment` tail entirely (fragment identifiers select \
3992         renderings, not directories, and `:caminho` names a directory).",
3993        ch = *byte as char
3994    )]
3995    FonteCaminhoShellComment {
3996        nome: String,
3997        caminho: String,
3998        byte: u8,
3999    },
4000    #[error(
4001        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains URL-\
4002         percent-encoding-escape / printf-format-specifier / bash-job-control-specifier \
4003         / YAML-directive-lead metacharacter 0x{byte:02x} `{ch}` (RFC 3986 §2.1 reserves \
4004         `%` as the URL percent-encoding-escape — `%HH` is the mandatory encoding \
4005         mechanism for every byte outside the `unreserved` alphanumeric / `-` / `.` / \
4006         `_` / `~` set, and `%` itself must be percent-encoded as `%25` to appear \
4007         literally inside a URL value. The canonical paste-from-browser-address-bar \
4008         percent-encoded-space footgun (an author copies `../caixa%20teia` out of a URL-\
4009         encoded README hyperlink / browser address bar / percent-encoded permalink \
4010         expecting `%20` to decode to a literal space at the filesystem layer) locks two \
4011         distinct BLAKE3 closures (`path:../caixa%20teia` vs `path:../caixa teia`) for \
4012         what the author intended as the byte-identical sibling-workspace dep. POSIX \
4013         `std::path::Path` treats the byte as a literal path-component byte, so \
4014         `Path::join` looks for a literal `./{caminho}` subdirectory and fails at \
4015         resolve time with a non-self-locating `No such file or directory` error far \
4016         from the source caixa.lisp — while every downstream URL parser / shell printf \
4017         builtin / YAML directive parser silently reinterprets the byte to a different \
4018         value than the resolver's `Path::join` sees. Beyond the URL-encoding hazard, \
4019         `%` is the C / POSIX printf format-directive lead-in (`%s`, `%d`, `%02x` — \
4020         wired into every POSIX shell's `printf` builtin, the canonical CWE-134 format-\
4021         string-injection vector); the bash / zsh / ksh job-control-specifier lead-in \
4022         (`%1` names \"job 1\", `%%` names \"the current job\", `%foo` names \"the most \
4023         recent job whose command started with `foo`\" — a future `kill %1` invocation \
4024         silently redirects the signal to a wrong target); the YAML 1.2 §6.8.1 \
4025         directive lead-in (`%YAML 1.2` / `%TAG` — the paste-from-top-of-doc YAML \
4026         directive block cross-idiom leak); and the Windows-shell env-var-reference \
4027         lead-in (`%PATH%` — the paste-from-`.bat` / paste-from-PowerShell-`%env:PATH%` \
4028         cross-idiom leak). The lacre pipeline embeds the value verbatim in its per-dep \
4029         content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the \
4030         byte lands in the BLAKE3 closure and rides into every shell-spawned subprocess \
4031         (the resolver's `git clone`, a future `feira tofu` shell-out, a future \
4032         operator-side `nix` spawn) as the canonical URL-percent-encoding-escape / \
4033         printf-format-specifier / job-control-specifier surface every peer single-\
4034         token-shaped typed slot already closes. The peer `:fonte :repo` axis closes \
4035         the byte under the same URL-percent-encoding-escape banner (a323db8 `%` on \
4036         `is_git_repo_url`). Express the path as a bare relative single-token like \
4037         \"../caixa-teia\" — the sibling-workspace directory name carries no URL-\
4038         percent-encoding-escape / format-specifier / job-control semantic; substitute \
4039         any `%20` percent-encoded-space with a literal space then reject the whole \
4040         value at the leading-whitespace / embedded-`?` arm on the same axis (a caixa \
4041         directory name never carries an embedded space in practice); drop any \
4042         `%2F`-encoded path separator in favor of a literal `/`; and drop any leading \
4043         `%YAML` / `%PATH%` cross-idiom-leak prefix entirely.",
4044        ch = *byte as char
4045    )]
4046    FonteCaminhoUrlPercentEncoding {
4047        nome: String,
4048        caminho: String,
4049        byte: u8,
4050    },
4051    #[error(
4052        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4053         variable-expansion / command-substitution / arithmetic-expansion / cross-config-\
4054         DSL-interpolation metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — sh / \
4055         bash / zsh / dash / ksh / busybox ash / fish / nushell — lexes `$` per \
4056         POSIX.1-2017 §2.6 as the variable-expansion `$<name>` / braced-form `${{<name>}}` \
4057         / command-substitution `$(<cmd>)` / arithmetic-expansion `$((<expr>))` operator; \
4058         Nix uses `${{var}}` as the string-interpolation lead, Make uses `$(var)` / `$@` \
4059         / `$<` for variables and automatic-variables, JavaScript / TypeScript template \
4060         literals use `${{expr}}` for interpolation, envsubst / Kubernetes / OpenShift \
4061         templates use `${{VAR}}` for env-var-reference, PHP uses `$_GET` / `$_ENV` for \
4062         superglobals, Perl uses `$foo` for scalars, SASS / SCSS uses `$primary-color` \
4063         for variables, and PostgreSQL / SQLite use `$1` / `$2` for bind parameters — \
4064         the byte is a first-class parser byte in nearly every config / templating / \
4065         build-system DSL the substrate's paste-idiom surface routinely crosses. POSIX \
4066         `std::path::Path` treats the byte as a literal path-component byte, so the \
4067         canonical paste-from-shell-one-liner `:caminho \"../foo$HOME/bar\"` / paste-\
4068         from-CI-manifest `:caminho \"../foo${{WORKSPACE}}/bar\"` / paste-from-shell-\
4069         prompt `:caminho \"../foo$(whoami)/bar\"` footguns silently pass every prior \
4070         cascade arm (`$` isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / \
4071         `?` / `(` / `)` / `{{` / `}}` / `[` / `]` / `'` / `\"` / `#` / `%`) and route \
4072         through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
4073         subdirectory that fails at resolve time with a non-self-locating `No such file \
4074         or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
4075         the value verbatim in its per-dep content-address `path:{caminho}` at \
4076         caixa-resolver/src/resolve.rs:189, so byte-identical caixa.lisp values differing \
4077         only in whether the author substituted `$HOME` / `${{WORKSPACE}}` at author \
4078         time lock to two distinct BLAKE3 closures across two workstations whose \
4079         downstream envsubst / Nix / Make / K8s-template layers differ in `$VAR` \
4080         recognition — defeating the THEORY.md §V.2 render-determinism contract on the \
4081         same axis every prior `:caminho` arm protects. Beyond the determinism vector, \
4082         `$` at any position in a value flowing verbatim into a shell-spawned subprocess \
4083         is the canonical CWE-78 shell-command-injection surface every peer single-\
4084         token-shaped typed slot already closes: peer `:fonte :repo` axis rejects `$` \
4085         under the shell-variable-expansion / URL-sub-delim banner via `is_git_repo_url` \
4086         (b9d187c), peer `:fonte :tag` / `:fonte :branch` axes reject `$` as part of \
4087         `is_git_ref_name`'s printable-ASCII-restricted grammar (`git check-ref-format` \
4088         rejects the byte outright), and peer `:entrada :paths` axis rejects `$` via \
4089         `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. The leading-`$` \
4090         position on the same axis routes through `FonteCaminhoVarExpansion` at the \
4091         f4efe9c leading-byte arm; this arm closes the last positional gap on the byte \
4092         so every position — leading and embedded — is structurally rejected. Substitute \
4093         the `$VAR` / `${{VAR}}` / `$(cmd)` template with the literal value at author \
4094         time, or express the path as a bare relative single-token like \
4095         \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
4096         variable-expansion / command-substitution / arithmetic-expansion semantic.",
4097        ch = *byte as char
4098    )]
4099    FonteCaminhoShellVariableExpansion {
4100        nome: String,
4101        caminho: String,
4102        byte: u8,
4103    },
4104    #[error(
4105        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4106         history-expansion / RFC-3986-sub-delims / bang-operator metacharacter 0x{byte:02x} \
4107         `{ch}` (every interactive POSIX shell with history enabled — bash / ksh / zsh's \
4108         `bashcompat` / csh / tcsh — lexes `!` as the history-expansion prefix per bash \
4109         reference §9.3: `!command` re-runs the most recent history entry beginning with \
4110         `command`, `!!` re-runs the prior command verbatim, `!$` substitutes the last \
4111         word of the prior command, `!:N` substitutes the Nth word of the prior command, \
4112         and the substitution fires at every history-expansion-enabled shell context — \
4113         `set -o histexpand` is bash's default for interactive sessions and the layer \
4114         every `feira tofu` / `git clone` / `nix flake check` subprocess-argument \
4115         invocation crosses when spawned under `bash -i`. Beyond shell history, RFC 3986 \
4116         §2.2 lists `!` in the `sub-delims` set (the URL grammar admits the byte inside \
4117         a path segment, but every WHATWG-conformant special-scheme URL parser percent-\
4118         encodes it inside a query component via the 'special-query percent-encode set' \
4119         the peer `is_git_repo_url` `*` / `(` / `)` / `'` arms close on); the byte is \
4120         also the C / C++ / Rust / JavaScript / Python bang-operator (logical-negation \
4121         prefix — the paste-from-source-code idiom where an author copies \
4122         `!path.exists()` out of a Rust snippet and the trailing punctuation crosses \
4123         the string-literal boundary); the canonical English-typography emphasis / \
4124         exclamation mark (the paste-from-prose enthusiasm-form idiom where an author \
4125         writes `:caminho \"../caixa-teia!\"` expecting the substrate to coerce it to a \
4126         kebab-case slug); and the Nix flake-ref attribute-selection operator surface. \
4127         POSIX `std::path::Path` treats `!` as a literal path-component byte, so the \
4128         canonical paste-from-shell-history footgun `:caminho \"../caixa-teia!sudo\"` \
4129         (an author copies a `cd ../caixa-teia && !sudo make install` one-liner from a \
4130         quick-start README and the trailing `!sudo` rides in verbatim as a history-\
4131         expansion reference), the symmetric `:caminho \"../foo!!/bar\"` (the `!!` \
4132         repeat-prior-command paste idiom), the English-typography `:caminho \
4133         \"../caixa-teia!\"` (paste-from-prose enthusiasm-form), and the last-word-\
4134         substitution `:caminho \"../foo!$\"` shape silently pass every prior cascade \
4135         arm (`!` isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / `?` / `(` \
4136         / `)` / `{{` / `}}` / `[` / `]` / `'` / `\"` / `#` / `%` / `$`) and route \
4137         through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
4138         subdirectory that fails at resolve time with a non-self-locating `No such file \
4139         or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
4140         the value verbatim in its per-dep content-address `path:{caminho}` at \
4141         caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
4142         rides into every shell-spawned subprocess (the resolver's `git clone`, a \
4143         future `feira tofu` shell-out, a future operator-side `nix flake check` spawn) \
4144         as the canonical shell-history-expansion / RFC-3986-sub-delims surface every \
4145         peer single-token-shaped typed slot already closes. The peer `:fonte :repo` \
4146         axis closes the byte under the same shell-history-expansion / RFC-3986-sub-\
4147         delims banner (7d53c68 `!` on `is_git_repo_url`). Express the path as a bare \
4148         relative single-token like \"../caixa-teia\" — the sibling-workspace directory \
4149         name carries no shell-history-expansion / bang-operator semantic; drop any \
4150         `!sudo` / `!!` / `!$` history-expansion trailing paste-from-shell-history \
4151         idiom; and drop any trailing English-typography exclamation mark that pasted \
4152         from prose.",
4153        ch = *byte as char
4154    )]
4155    FonteCaminhoShellHistoryExpansion {
4156        nome: String,
4157        caminho: String,
4158        byte: u8,
4159    },
4160    #[error(
4161        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4162         history-substitution / RFC-3986-'unwise' / regex-negation metacharacter 0x{byte:02x} \
4163         `{ch}` (POSIX bash's `set -o histexpand` mode — the default for every interactive \
4164         session and every `bash -i` subprocess-argument context `feira tofu` / `git clone` / \
4165         `nix flake check` cross — lexes `^old^new^` per bash reference §9.3 as the 'quick \
4166         substitution' history operator that rewrites the prior command's `old` string to \
4167         `new` and re-executes it verbatim, the canonical typo-correction one-liner idiom \
4168         (`git clone <bad-url>` → `^bad^good` typo-fix-and-rerun the paste-from-shell-\
4169         history author trims only the leading `git clone` prefix from). RFC 3986 §2 lists \
4170         `^` in the 'unwise' set every URL parser is required to percent-encode-or-refuse at \
4171         the wire boundary, and the WHATWG URL spec's 'fragment percent-encode set' maps \
4172         `^` → `%5E` at the query / fragment component transition, so `Path::join` on the \
4173         literal value diverges from every downstream `feira tofu` curl-invocation / \
4174         artifact-registry-fetch that percent-encodes the byte before the wire. `^` is also \
4175         the regex character-class negation prefix (`[^abc]`), the bitwise XOR operator in \
4176         C / C++ / Rust / Python / JavaScript / Nix / Go, the Windows `cmd.exe` escape \
4177         metacharacter, and the LaTeX / Markdown / BibTeX superscript operator. POSIX \
4178         `std::path::Path` treats `^` as a literal path-component byte, so \
4179         `:caminho \"../foo^bar/baz\"` (embedded quick-substitution), `:caminho \
4180         \"../foo^\"` (trailing history-substitution-open shape), or `:caminho \"../x^y\"` \
4181         (XOR-expression paste-from-source) silently pass every prior cascade arm (`^` \
4182         isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / `?` / `(` / `)` / `{{` \
4183         / `}}` / `[` / `]` / `'` / `\"` / `#` / `%` / `$` / `!`) and route through \
4184         `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` subdirectory \
4185         that fails at resolve time with a non-self-locating `No such file or directory` \
4186         error far from the source caixa.lisp. The lacre pipeline embeds the value verbatim \
4187         in its per-dep content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, \
4188         so the byte lands in the BLAKE3 closure and rides into every shell-spawned \
4189         subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a future \
4190         operator-side `nix flake check` spawn) as the canonical shell-history-substitution \
4191         / RFC-3986-unwise surface every peer single-token-shaped typed slot already closes. \
4192         The peer `:fonte :repo` axis closes the byte under the same shell-history-\
4193         substitution / RFC-3986-unwise banner (49e142f `^` on `is_git_repo_url`). Together \
4194         with the immediate-predecessor `!` arm (6a04767) this arm closes the full `set -o \
4195         histexpand` operator surface on the `:caminho` axis — the `!command` / `!!` / `!$` \
4196         prefix form via `!`, the `^old^new^` quick-substitution form via `^`. Express the \
4197         path as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
4198         directory name carries no shell-history-substitution / regex-negation / XOR-operator \
4199         semantic; drop any `^old^new` history-substitution paste-from-shell-history idiom; \
4200         drop any trailing `^` history-substitution-open fragment.",
4201        ch = *byte as char
4202    )]
4203    FonteCaminhoShellHistorySubstitution {
4204        nome: String,
4205        caminho: String,
4206        byte: u8,
4207    },
4208    #[error(
4209        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} has a trailing \
4210         `/` (the resolver's `Path::join` resolves `\"../caixa-teia\"` and \
4211         `\"../caixa-teia/\"` to the same directory, but the lacre pipeline embeds the \
4212         value verbatim in its per-dep content-address `path:{caminho}` at \
4213         caixa-resolver/src/resolve.rs:189, so two authors whose only difference is \
4214         shell tab-completion emit byte-divergent BLAKE3 closures for the same caixa — \
4215         defeating the THEORY.md §V.2 render-determinism contract via the trailing-\
4216         separator vector (the canonical paste-from-shell-tab-completion + paste-from-\
4217         `pwd`-with-`/`-suffix footgun, and the canonical Cargo-style `path = \
4218         \"../caixa-teia/\"` paste-from-Cargo-manifest cross-idiom leak). Drop the \
4219         trailing `/`; every `:caminho` value names a sibling-workspace directory \
4220         already, so the trailing separator carries no information. Use \
4221         `\"../caixa-teia\"` rather than `\"../caixa-teia/\"`)"
4222    )]
4223    FonteCaminhoTrailingSlash { nome: String, caminho: String },
4224    #[error(
4225        "{list} carries duplicate entry :nome {nome:?} — every dep list keys its \
4226         entries by caixa name (Cargo's [dependencies] / [dev-dependencies] tables \
4227         apply the same set-not-multiset discipline; one package per table), and \
4228         two entries naming the same caixa carry two version constraints / source \
4229         pins / feature sets for one identity. The caixa-resolver's lacre pipeline \
4230         consumes the list as a `HashMap`-keyed-by-`:nome` lookup: the second entry \
4231         silently overwrites the first at the resolver-side `concrete_versao` step, \
4232         and the dropped entry's pin / features never reach the closure — far from \
4233         the source caixa.lisp, with no field naming which `:deps` entry was the \
4234         silent loser. If two version constraints are genuinely needed (the rare \
4235         multi-version closure case the lacre pipeline doesn't yet support), the \
4236         author surface is two distinct caixa names (e.g. a `caixa-teia-v01` / \
4237         `caixa-teia-v02` aliased pair); within one list, one entry per caixa name."
4238    )]
4239    DuplicateNome { nome: String, list: &'static str },
4240    #[error(
4241        ":deps entry {nome:?} has empty :caracteristicas entry — every feature flag must \
4242         name a non-empty identifier on the target caixa (Cargo's [dependencies.<dep>.features] \
4243         applies the same per-entry non-empty discipline). An empty feature flag reaches the \
4244         caixa-resolver's lacre pipeline as a no-op feature enable, silently dropping the \
4245         author's intent far from the source caixa.lisp; drop the empty entry, or replace it \
4246         with the canonical kebab-case feature name the target caixa declares."
4247    )]
4248    CaracteristicaEmpty { nome: String },
4249    #[error(
4250        ":deps entry {nome:?} :caracteristicas entry {caracteristica:?} is not a valid Cargo \
4251         feature name: {reason} (the value flows verbatim into Cargo's \
4252         [dependencies.<dep>.features] list and Cargo's `restricted_names::validate_feature_name` \
4253         parser enforces the same shape at `cargo metadata` time; use a single-token \
4254         identifier like `\"http\"`, `\"derive\"`, or `\"runtime-tokio\"` — kebab-case ASCII \
4255         alphanumeric with `-`, `_`, `+`, or `.` as continuation characters, starting with \
4256         an ASCII alphanumeric or `_`)"
4257    )]
4258    CaracteristicaInvalid {
4259        nome: String,
4260        caracteristica: String,
4261        reason: String,
4262    },
4263    #[error(
4264        ":deps entry {nome:?} :caracteristicas carries duplicate feature {caracteristica:?} — \
4265         every feature-flag list keys its entries by name (Cargo's \
4266         [dependencies.<dep>.features] applies the same set-not-multiset discipline; one entry \
4267         per feature per dep), and two entries naming the same feature are a redundant \
4268         set-membership declaration for one identity (the feature-toggle slot is set-shaped; \
4269         enabling a feature twice has no additional semantic). The caixa-resolver's lacre \
4270         pipeline consumes the list as a set-shaped feature toggle — the resolver enables the \
4271         feature once regardless of declaration count, so the duplicate's pin / position never \
4272         reaches the closure with no field naming the silent loser. One entry per feature per \
4273         dep; if two distinct features are intended, name each verbatim."
4274    )]
4275    CaracteristicaDuplicate {
4276        nome: String,
4277        caracteristica: String,
4278    },
4279    #[error(
4280        "{list} entry :nome {nome:?} names the caixa itself — a caixa cannot depend \
4281         on itself (the lacre closure's dep-graph traversal is rooted at the caixa's \
4282         :nome, and a self-dep would be a one-node cycle the caixa-resolver either \
4283         rejects mid-traversal far from the source caixa.lisp or recurses on until \
4284         it exhausts its stack). Every :nome is globally-unique substrate identity, \
4285         so a :deps / :deps-dev entry whose :nome equals the parent caixa's :nome \
4286         *is* the parent itself, not a coincidentally-named peer. Drop the \
4287         self-referential dep entry — to reference code from this caixa, use \
4288         :bibliotecas / :exe / :servicos (the substrate-blessed shape for \
4289         referencing the caixa's own code surface) instead."
4290    )]
4291    DepIsSelf { nome: String, list: &'static str },
4292}
4293
4294// Fold the eleven `DepError::FonteCaminho<Variant> { nome: nome.to_string(),
4295// caminho: caminho.to_string() }` two-slot struct-variant wire-up sites at
4296// [`DepSource::validate_caminho`] onto one substrate primitive per typed
4297// variant — the paired `{ nome: String, caminho: String }` two-slot family
4298// on [`DepError`], sibling of the peer
4299// [`crate::supervisor::supervisor_caixa_only_ctors!`] (db09650, 3 variants
4300// on `{ caixa: String }`) on the `SupervisorError` envelope, the peer
4301// [`crate::aplicacao::contrato_empty_pair_ctors!`] (8580068, 4 variants on
4302// `{ de, para }`), [`crate::aplicacao::aplicacao_field_reason_ctors!`]
4303// (981060b, 7 variants on `{ <field>: String, reason: String }`),
4304// [`crate::aplicacao::contrato_target_ctors!`] (14b81d5, 2 variants on
4305// `{ de, para, wit, expected }`), and
4306// [`crate::aplicacao::contrato_pair_value_reason_ctors!`] (14e13f1, 3
4307// variants on `{ de, para, <field>: String, reason: String }`) on the
4308// `AplicacaoError` envelopes, the peer
4309// [`crate::layout::layout_violation_ctors!`] (131ca0d, 16 variants on
4310// `{ caixa, issue }`), [`crate::layout::layout_slot_kind_ctors!`]
4311// (0419438, 4 variants on `{ caixa, kind, slots }`),
4312// [`crate::LayoutError::missing_entry`] (1b09f9d, one variant on
4313// `{ kind, path }`), and [`crate::layout::layout_nome_only_ctors!`]
4314// (3fe3dd7, 6 variants on `<Variant>(String)`) on the `LayoutError`
4315// envelopes, the peer three [`crate::limits::limits_codec_value_*_ctors!`]
4316// codec-family macros (81c856c, 12 wire-ups) on the `LimitsError`
4317// envelope, and the peer [`crate::upgrade::upgrade_from_script_ctors!`]
4318// (8e67041, 3 variants on `{ from: String, script: PathBuf }`) on the
4319// `UpgradeError` envelope. First fold family on this `DepError` envelope.
4320//
4321// Each of the eleven wire-up sites on this shape (the leading-byte cascade
4322// closing the seven `FonteCaminho{Absolute, TildeExpansion, VarExpansion,
4323// LeadingWhitespace, LeadingHyphen}` arms; the orthogonal single-metachar
4324// cascade closing `FonteCaminhoBackslash` on `\`; the shell-lexer-metachar
4325// cascade closing `FonteCaminhoShell{Pipe, Semicolon, Background,
4326// CommandSubstitution}` on the four single-byte shell operators; and the
4327// trailing-`/` reproducibility arm closing `FonteCaminhoTrailingSlash`)
4328// opened the identical `DepError::FonteCaminho<Variant> { nome:
4329// nome.to_string(), caminho: caminho.to_string() }` four-line
4330// struct-literal against the same `(nome: &str, caminho: &str)` local pair
4331// — the exact "same block re-inlined at every consumer" shape the PRIME
4332// DIRECTIVE names as a bug, on the same altitude the peer `LayoutError` /
4333// `AplicacaoError` / `SupervisorError` / `LimitsError` / `UpgradeError`
4334// families each closed on their sibling envelopes. The eleven variants
4335// share one `{ nome: String, caminho: String }` shape, so the fold routes
4336// each wire-up site through one dispatch per typed variant.
4337//
4338// The macro below generates one `#[must_use]` inherent constructor per
4339// variant of shape `fn <ctor>(nome: &str, caminho: &str) -> Self`, so every
4340// wire-up site collapses onto one dispatch:
4341// `DepError::<ctor>(nome, caminho)`, byte-equal to the pre-lift
4342// struct-literal on the same `(&str, &str)` fixture. The uniform two-field
4343// construction (`nome.to_string()` / `caminho.to_string()`) is spelled
4344// once — inside the macro — rather than at every wire-up site.
4345//
4346// The twelve `FonteCaminho<Variant> { nome, caminho, byte }` three-field
4347// shapes at the per-byte-classification arms — the
4348// `FonteCaminho{ControlChar,ShellRedirection,ShellGlob,
4349// ShellSubshellGrouping,ShellBraceExpansion,ShellBracketExpansion,
4350// ShellQuoteGrouping,ShellComment,UrlPercentEncoding,
4351// ShellVariableExpansion,ShellHistoryExpansion,ShellHistorySubstitution}`
4352// cluster — carry an additional `byte: u8` naming the offending byte and
4353// so would break the uniform-two-field routing this macro promises. They
4354// instead fold onto the sibling three-field envelope through
4355// [`fonte_caminho_byte_ctors!`] (this-commit-lift, 12 variants on the
4356// `{ nome, caminho, byte }` shape), whose sole additional axis over this
4357// two-slot family is the `byte: u8` classification the arms carry. The
4358// remaining `FonteCaminhoEmpty` one-field `{ nome }` shape at the empty-
4359// first arm folds instead onto the peer [`dep_nome_only_ctors!`]
4360// (792aa92, 5 variants on `{ nome: String }`) sibling family of this
4361// envelope.
4362//
4363// Every future consumer that wants to construct one of these eleven
4364// variants outside the current in-crate [`DepSource::validate_caminho`]
4365// wire-up sites (a deferred `caixa-resolver` per-`:caminho` re-validator
4366// at lacre-resolve time re-checking the same value-shape axes the resolver
4367// consumes, a future `feira validate --deps` per-caixa admission verb
4368// re-checking the `:fonte :caminho` axis, a per-lacre overlay resolver
4369// rejecting a `:caminho` value against a cluster-local snapshot) now
4370// reaches each variant through one call rather than re-inlining the
4371// four-line struct-literal in lockstep with the eleven in-crate wire-up
4372// sites.
4373macro_rules! fonte_caminho_ctors {
4374    ($($ctor:ident => $variant:ident),* $(,)?) => {
4375        impl DepError {
4376            $(
4377                #[doc = concat!(
4378                    "Construct a [`DepError::",
4379                    stringify!($variant),
4380                    "`] naming the offending `:deps :nome` + `:fonte ",
4381                    "(:tipo path …) :caminho` pair. Folds the uniform ",
4382                    "`Self::",
4383                    stringify!($variant),
4384                    " { nome: nome.to_string(), caminho: caminho.to_string() }` ",
4385                    "two-slot struct-literal onto one substrate primitive so ",
4386                    "every [`DepSource::validate_caminho`] wire-up on this ",
4387                    "variant reads through one dispatch rather than the ",
4388                    "pre-lift four-line open-coded block."
4389                )]
4390                #[must_use]
4391                pub fn $ctor(nome: &str, caminho: &str) -> Self {
4392                    Self::$variant {
4393                        nome: nome.to_string(),
4394                        caminho: caminho.to_string(),
4395                    }
4396                }
4397            )*
4398        }
4399    };
4400}
4401
4402fonte_caminho_ctors! {
4403    fonte_caminho_absolute => FonteCaminhoAbsolute,
4404    fonte_caminho_tilde_expansion => FonteCaminhoTildeExpansion,
4405    fonte_caminho_var_expansion => FonteCaminhoVarExpansion,
4406    fonte_caminho_leading_whitespace => FonteCaminhoLeadingWhitespace,
4407    fonte_caminho_leading_hyphen => FonteCaminhoLeadingHyphen,
4408    fonte_caminho_backslash => FonteCaminhoBackslash,
4409    fonte_caminho_shell_pipe => FonteCaminhoShellPipe,
4410    fonte_caminho_shell_semicolon => FonteCaminhoShellSemicolon,
4411    fonte_caminho_shell_background => FonteCaminhoShellBackground,
4412    fonte_caminho_shell_command_substitution => FonteCaminhoShellCommandSubstitution,
4413    fonte_caminho_trailing_slash => FonteCaminhoTrailingSlash,
4414}
4415
4416// Fold the twelve `DepError::FonteCaminho<Variant> { nome: nome.to_string(),
4417// caminho: caminho.to_string(), byte: b }` three-slot struct-variant wire-up
4418// sites at [`DepSource::validate_caminho`] onto one substrate primitive per
4419// typed variant — the paired `{ nome: String, caminho: String, byte: u8 }`
4420// three-slot family on [`DepError`], strict sibling of the peer
4421// [`fonte_caminho_ctors!`] (f85f145, 11 variants on the two-slot
4422// `{ nome: String, caminho: String }` envelope) of this envelope. Extends
4423// that fold onto the `byte`-classifying arms whose additional `byte: u8`
4424// axis broke its uniform-two-field routing — the exact "future compounding
4425// work" the pre-lift `fonte_caminho_ctors!` prose named as deferred, closed
4426// here. Third fold family on this `DepError` envelope, sibling of the peer
4427// two-slot [`fonte_caminho_ctors!`] and one-slot [`dep_nome_only_ctors!`]
4428// (792aa92, 5 variants on the `{ nome: String }` envelope) families on the
4429// same enum.
4430//
4431// Each of the twelve wire-up sites on this shape (the control-byte arm
4432// closing `FonteCaminhoControlChar` on the sub-`0x20` / `0x7F` cluster; the
4433// shell-lexer-metachar cascade closing `FonteCaminhoShellRedirection` on
4434// `< >`, `FonteCaminhoShellGlob` on `* ?`, `FonteCaminhoShellSubshellGrouping`
4435// on `( )`, `FonteCaminhoShellBraceExpansion` on `{ }`,
4436// `FonteCaminhoShellBracketExpansion` on `[ ]`, and
4437// `FonteCaminhoShellQuoteGrouping` on `' "`; the single-metachar arms
4438// closing `FonteCaminhoShellComment` on `#`, `FonteCaminhoUrlPercentEncoding`
4439// on `%`, `FonteCaminhoShellVariableExpansion` on `$`,
4440// `FonteCaminhoShellHistoryExpansion` on `!`, and
4441// `FonteCaminhoShellHistorySubstitution` on `^`) opened the identical
4442// `DepError::FonteCaminho<Variant> { nome: nome.to_string(),
4443// caminho: caminho.to_string(), byte: b }` five-line struct-literal against
4444// the same `(nome: &str, caminho: &str, b: u8)` local triple — the exact
4445// "same block re-inlined at every consumer" shape the PRIME DIRECTIVE names
4446// as a bug, on the same altitude the peer two-slot `fonte_caminho_ctors!`
4447// closed on the sibling two-field envelope of this same enum. The twelve
4448// variants share one `{ nome: String, caminho: String, byte: u8 }` shape, so
4449// the fold routes each wire-up site through one dispatch per typed variant.
4450//
4451// The macro below generates one `#[must_use]` inherent constructor per
4452// variant of shape `fn <ctor>(nome: &str, caminho: &str, byte: u8) -> Self`,
4453// so every wire-up site collapses onto one dispatch:
4454// `DepError::<ctor>(nome, caminho, b)`, byte-equal to the pre-lift
4455// struct-literal on the same `(&str, &str, u8)` fixture. The uniform
4456// three-field construction (`nome.to_string()` / `caminho.to_string()` /
4457// `byte`) is spelled once — inside the macro — rather than at every wire-up
4458// site.
4459//
4460// Every future consumer that wants to construct one of these twelve
4461// variants outside the current in-crate [`DepSource::validate_caminho`]
4462// wire-up sites (a deferred `caixa-resolver` per-`:caminho` re-validator
4463// at lacre-resolve time re-checking the same value-shape axes the resolver
4464// consumes, a future `feira validate --deps` per-caixa admission verb
4465// re-checking the `:fonte :caminho` axis against the shell-metachar
4466// classification bytes this cluster catches, a per-lacre overlay resolver
4467// rejecting a `:caminho` value against a cluster-local snapshot) now
4468// reaches each variant through one call rather than re-inlining the
4469// five-line struct-literal in lockstep with the twelve in-crate wire-up
4470// sites.
4471macro_rules! fonte_caminho_byte_ctors {
4472    ($($ctor:ident => $variant:ident),* $(,)?) => {
4473        impl DepError {
4474            $(
4475                #[doc = concat!(
4476                    "Construct a [`DepError::",
4477                    stringify!($variant),
4478                    "`] naming the offending `:deps :nome` + `:fonte ",
4479                    "(:tipo path …) :caminho` pair + the offending `byte: u8` ",
4480                    "classification. Folds the uniform `Self::",
4481                    stringify!($variant),
4482                    " { nome: nome.to_string(), caminho: caminho.to_string(), ",
4483                    "byte }` three-slot struct-literal onto one substrate ",
4484                    "primitive so every [`DepSource::validate_caminho`] wire-up ",
4485                    "on this variant reads through one dispatch rather than ",
4486                    "the pre-lift five-line open-coded block."
4487                )]
4488                #[must_use]
4489                pub fn $ctor(nome: &str, caminho: &str, byte: u8) -> Self {
4490                    Self::$variant {
4491                        nome: nome.to_string(),
4492                        caminho: caminho.to_string(),
4493                        byte,
4494                    }
4495                }
4496            )*
4497        }
4498    };
4499}
4500
4501fonte_caminho_byte_ctors! {
4502    fonte_caminho_control_char => FonteCaminhoControlChar,
4503    fonte_caminho_shell_redirection => FonteCaminhoShellRedirection,
4504    fonte_caminho_shell_glob => FonteCaminhoShellGlob,
4505    fonte_caminho_shell_subshell_grouping => FonteCaminhoShellSubshellGrouping,
4506    fonte_caminho_shell_brace_expansion => FonteCaminhoShellBraceExpansion,
4507    fonte_caminho_shell_bracket_expansion => FonteCaminhoShellBracketExpansion,
4508    fonte_caminho_shell_quote_grouping => FonteCaminhoShellQuoteGrouping,
4509    fonte_caminho_shell_comment => FonteCaminhoShellComment,
4510    fonte_caminho_url_percent_encoding => FonteCaminhoUrlPercentEncoding,
4511    fonte_caminho_shell_variable_expansion => FonteCaminhoShellVariableExpansion,
4512    fonte_caminho_shell_history_expansion => FonteCaminhoShellHistoryExpansion,
4513    fonte_caminho_shell_history_substitution => FonteCaminhoShellHistorySubstitution,
4514}
4515
4516// Fold the five `DepError::<Variant> { nome: <owner>.clone_or_to_string() }`
4517// single-slot struct-variant wire-up sites scattered across
4518// [`Dep::validate`] / [`Dep::validate_caracteristicas`] /
4519// [`DepSource::validate`] / [`DepSource::validate_caminho`] onto one
4520// substrate primitive per typed variant — the paired `{ nome: String }`
4521// single-slot family on [`DepError`], sibling of the peer
4522// [`fonte_caminho_ctors!`] (f85f145, 11 variants on
4523// `{ nome: String, caminho: String }`) on the sibling two-slot envelope of
4524// the same enum, and of the peer
4525// [`crate::supervisor::supervisor_caixa_only_ctors!`] (db09650, 3 variants
4526// on `{ caixa: String }`) on the `SupervisorError` envelope's single-slot
4527// axis. Second fold family on this `DepError` envelope, and the first on
4528// the single-`{ nome }` shape.
4529//
4530// The five wire-up sites this fold closes each opened the identical
4531// `DepError::<Variant> { nome: <owner>.to_string_or_clone() }` three-line
4532// struct-literal against the same `nome: &str` (or `self.nome: &String`)
4533// local — the exact "same block re-inlined at every consumer" shape the
4534// PRIME DIRECTIVE names as a bug. The five variants share one
4535// `{ nome: String }` shape, so the fold routes each wire-up site through
4536// one dispatch per typed variant.
4537//
4538// The macro below generates one `#[must_use]` inherent constructor per
4539// variant of shape `fn <ctor>(nome: &str) -> Self`, so every wire-up site
4540// collapses onto one dispatch: `DepError::<ctor>(nome)`, byte-equal to the
4541// pre-lift struct-literal on the same `&str` fixture. The uniform
4542// one-field construction (`nome.to_string()`) is spelled once — inside
4543// the macro — rather than at every wire-up site. Callers that hold a
4544// `String` (`self.nome`) pass `&self.nome`, which auto-derefs to `&str`
4545// and lets the macro-owned `.to_string()` produce the fresh owning copy
4546// the enum variant needs; the semantics collapse onto the same
4547// `.clone()`-equivalent one this fold replaces at every site.
4548//
4549// The sibling `NomeEmpty` unit-variant (`enum DepError { NomeEmpty, … }`)
4550// on the same envelope stays on its pre-lift open-coded wire-up shape —
4551// it carries no `nome` field (the offending `:nome` value *is* the empty
4552// string this variant catches) so the uniform `fn(nome: &str) -> Self`
4553// signature this macro promises does not apply. Every future consumer
4554// that wants to construct one of these five variants outside the current
4555// in-crate wire-up sites (a deferred `caixa-resolver` per-`:versao` /
4556// `:caracteristicas` / `:fonte :repo` / `:fonte :pin` / `:fonte :caminho`
4557// re-validator at lacre-resolve time, a future `feira validate --deps`
4558// per-caixa admission verb, a per-lacre overlay resolver rejecting one of
4559// these empty-value shapes against a cluster-local snapshot) now reaches
4560// each variant through one call rather than re-inlining the three-line
4561// struct-literal in lockstep with the five in-crate wire-up sites.
4562macro_rules! dep_nome_only_ctors {
4563    ($($ctor:ident => $variant:ident),* $(,)?) => {
4564        impl DepError {
4565            $(
4566                #[doc = concat!(
4567                    "Construct a [`DepError::",
4568                    stringify!($variant),
4569                    "`] naming the offending `:deps :nome`. Folds the ",
4570                    "uniform `Self::",
4571                    stringify!($variant),
4572                    " { nome: nome.to_string() }` one-field ",
4573                    "struct-literal onto one substrate primitive so every ",
4574                    "in-crate wire-up on this variant reads through one ",
4575                    "dispatch rather than the pre-lift three-line ",
4576                    "open-coded block."
4577                )]
4578                #[must_use]
4579                pub fn $ctor(nome: &str) -> Self {
4580                    Self::$variant { nome: nome.to_string() }
4581                }
4582            )*
4583        }
4584    };
4585}
4586
4587dep_nome_only_ctors! {
4588    versao_empty => VersaoEmpty,
4589    fonte_repo_empty => FonteRepoEmpty,
4590    fonte_pin_missing => FontePinMissing,
4591    fonte_caminho_empty => FonteCaminhoEmpty,
4592    caracteristica_empty => CaracteristicaEmpty,
4593}
4594
4595// Fold the four `DepError::{DuplicateNome, DepIsSelf}` struct-variant
4596// wire-up sites at [`crate::manifest::Caixa::push_dep`] +
4597// [`crate::manifest::Caixa::validate_deps`] +
4598// [`validate_no_self_dep`] onto one substrate-primitive family per
4599// typed variant — the `DepError`-side siblings of the peer
4600// [`crate::supervisor::supervisor_caixa_only_ctors!`] macro (db09650)
4601// on the `SupervisorError { caixa: String }` one-slot envelope and of
4602// the peer [`dep_nome_only_ctors!`] macro (792aa92) on the
4603// `DepError { nome: String }` one-slot envelope. The two variants
4604// carry the same `{ nome: String, list: &'static str }` two-slot
4605// shape: the `nome` field names the offending dep the diagnostic
4606// points the author back at, and the `list` field carries the
4607// `":deps"` / `":deps-dev"` author-surface tag verbatim (via
4608// [`crate::dep::DepList::as_str`] on the [`push_dep`] /
4609// [`validate_deps`] arms, and via the paired
4610// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
4611// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `&'static str`
4612// canonicals on the [`validate_no_self_dep`] arm) so the author can
4613// grep their caixa.lisp for the offending list block in one edit.
4614//
4615// Each of the four wire-up sites opened the same struct-literal
4616// `DepError::<Variant> { nome: <name>.to_string(), list: <tag> }`
4617// two-line block — the exact "same block re-inlined at every
4618// consumer" shape the PRIME DIRECTIVE names as a bug, on the same
4619// altitude the peer `DepError` / `SupervisorError` /
4620// `AplicacaoError` / `LayoutError` / `LimitsError` ctor families
4621// already closed on their sibling envelopes. The two `#[must_use]`
4622// inherent constructors below fold each wire-up onto one dispatch:
4623// `DepError::duplicate_nome(<nome>, <list>)` and
4624// `DepError::dep_is_self(<nome>, <list>)`, byte-equal to the
4625// pre-lift struct-literal on the same scalar fixtures. The `list:
4626// &'static str` parameter (not `impl Into<String>`) preserves the
4627// exact wire tag every consumer already passes verbatim — no
4628// downstream diagnostic reshaping at the lift, matching the peer
4629// `DepList::as_str` / `DEP_AUTHOR_KEY_DEPS*` `&'static str`
4630// contract each wire-up site already keys off.
4631macro_rules! dep_nome_list_ctors {
4632    ($($ctor:ident => $variant:ident),* $(,)?) => {
4633        impl DepError {
4634            $(
4635                #[doc = concat!(
4636                    "Construct a [`DepError::",
4637                    stringify!($variant),
4638                    "`] naming the offending `:deps :nome` and the ",
4639                    "author-surface list tag (`:deps` vs. `:deps-dev`) ",
4640                    "the diagnostic points the author back at. Folds ",
4641                    "the uniform `Self::",
4642                    stringify!($variant),
4643                    " { nome: nome.to_string(), list }` two-field ",
4644                    "struct-literal onto one substrate primitive so ",
4645                    "every in-crate wire-up on this variant reads ",
4646                    "through one dispatch rather than the pre-lift ",
4647                    "open-coded struct-literal block."
4648                )]
4649                #[must_use]
4650                pub fn $ctor(nome: &str, list: &'static str) -> Self {
4651                    Self::$variant { nome: nome.to_string(), list }
4652                }
4653            )*
4654        }
4655    };
4656}
4657
4658dep_nome_list_ctors! {
4659    duplicate_nome => DuplicateNome,
4660    dep_is_self => DepIsSelf,
4661}
4662
4663// Fold the three `DepError::{VersaoInvalid, FonteRepoShape,
4664// CaracteristicaInvalid} { nome: <nome>.to_string(), <axis>:
4665// <value>.to_string(), reason }` struct-variant wire-up sites at
4666// [`Dep::validate`]'s `:versao` requirement-shape gate + [`DepSource::validate`]'s
4667// `:fonte (:tipo git …) :repo` value-shape gate + [`Dep::validate_caracteristicas`]'s
4668// per-entry `:caracteristicas` feature-name-shape gate onto one substrate-
4669// primitive family per typed variant — the `DepError`-side siblings of the
4670// peer [`dep_nome_only_ctors!`] (792aa92) on the one-slot `{ nome }`
4671// envelope, [`dep_nome_list_ctors!`] (6f5e0cd) on the two-slot `{ nome,
4672// list: &'static str }` envelope, [`fonte_caminho_ctors!`] (f85f145) on
4673// the two-slot `{ nome, caminho }` envelope, and
4674// [`fonte_caminho_byte_ctors!`] (0e35793) on the three-slot `{ nome,
4675// caminho, byte }` envelope. The three variants share the same
4676// `{ nome: String, <axis>: String, reason: String }` three-slot shape —
4677// the `nome` field names the offending dep the diagnostic points the
4678// author back at, the middle `<axis>: String` field carries the offending
4679// axis value verbatim (`:versao` requirement scalar on `VersaoInvalid`,
4680// `:repo` URL scalar on `FonteRepoShape`, `:caracteristicas` per-entry
4681// feature-name scalar on `CaracteristicaInvalid`), and the `reason: String`
4682// field carries the parser-shaped rejection sentence the paired
4683// [`crate::render::require_valid_versao_requirement`] /
4684// [`crate::render::is_git_repo_url`] /
4685// [`crate::render::is_cargo_feature_name`] predicate returned. The middle
4686// axis-field name differs across variants (`versao` / `repo` /
4687// `caracteristica`) so the ctor family below takes the axis field name as
4688// a macro parameter (`$axis:ident`) alongside the ctor + variant names,
4689// generating one `pub fn $ctor(nome: &str, $axis: &str, reason: String)
4690// -> Self` inherent constructor per typed variant that spells the uniform
4691// three-field construction (`nome.to_string()` / `<axis>.to_string()` /
4692// `reason` forwarded owned) exactly once. Peer of the sibling
4693// [`crate::aplicacao::aplicacao_field_reason_ctors!`] (981060b) macro
4694// family on the `AplicacaoError` envelope's mirror-symmetric
4695// `{ <field>: String, reason: String }` two-slot shape — same
4696// `<axis>: <value>.to_string()` + `reason` owned-forward payload shape,
4697// one `nome`-axis added at the per-dep-owned altitude the `DepError`
4698// envelope keys off (every `DepError` variant carries the offending
4699// `:deps :nome` verbatim so the author can grep their caixa.lisp for the
4700// offending block in one edit).
4701//
4702// The three wire-up sites this fold closes are:
4703// - [`DepSource::validate`]'s `:repo` value-shape arm
4704//   (`Err(DepError::FonteRepoShape { nome: nome.to_string(), repo:
4705//   repo.clone(), reason })` after [`crate::render::is_git_repo_url`]
4706//   rejects the offending URL);
4707// - [`Dep::validate`]'s `:versao` requirement-shape arm
4708//   (`|reason| DepError::VersaoInvalid { nome: self.nome.clone(), versao:
4709//   self.versao_requirement().to_string(), reason }` inside the
4710//   [`crate::render::require_valid_versao_requirement`] callback pair);
4711// - [`Dep::validate_caracteristicas`]'s per-entry feature-name-shape arm
4712//   (`Err(DepError::CaracteristicaInvalid { nome: self.nome.clone(),
4713//   caracteristica: c.clone(), reason })` after
4714//   [`crate::render::is_cargo_feature_name`] rejects the offending
4715//   feature-name).
4716//
4717// Each opened the identical five-line struct-literal against the same
4718// `(nome, <axis>, reason)` local triple — the exact "same block re-inlined
4719// at every consumer" shape the PRIME DIRECTIVE names as a bug, on the
4720// same altitude the peer four already-lifted `DepError` ctor families
4721// closed on their sibling shape-envelopes. The three variant / axis-field
4722// discriminators are the only things that vary between them; the rest of
4723// the struct-literal is a byte-for-byte re-inline.
4724//
4725// Every future consumer wanting to raise one of these three diagnostics
4726// (a deferred `caixa-resolver` per-`:deps` re-validator at lacre-resolve
4727// time re-checking each declared dep against the same requirement +
4728// git-URL + feature-name value-shape cascade, a future `feira validate
4729// --deps` per-caixa admission verb re-running the shape gates on demand,
4730// a per-lacre overlay resolver rejecting an author-supplied dep against a
4731// cluster-local snapshot) now reaches one dispatch rather than re-inlining
4732// the five-line struct-literal in lockstep with the three in-crate
4733// wire-up sites.
4734macro_rules! dep_nome_axis_reason_ctors {
4735    ($($ctor:ident => $variant:ident { $axis:ident }),* $(,)?) => {
4736        impl DepError {
4737            $(
4738                #[doc = concat!(
4739                    "Construct a [`DepError::",
4740                    stringify!($variant),
4741                    "`] naming the offending `:deps :nome`, the offending ",
4742                    "`:", stringify!($axis), "` axis value, and the ",
4743                    "parser-shaped rejection `reason`. Folds the uniform ",
4744                    "`Self::",
4745                    stringify!($variant),
4746                    " { nome: nome.to_string(), ",
4747                    stringify!($axis),
4748                    ": ",
4749                    stringify!($axis),
4750                    ".to_string(), reason }` three-field struct-literal ",
4751                    "onto one substrate primitive so every in-crate ",
4752                    "wire-up on this variant reads through one dispatch ",
4753                    "rather than the pre-lift five-line open-coded block. ",
4754                    "The `nome: &str` and `",
4755                    stringify!($axis),
4756                    ": &str` parameters accept `&str` literals and ",
4757                    "`&String` (via Deref coercion) so every existing ",
4758                    "wire-up threads through the ctor without a ",
4759                    "pre-conversion; the `reason: String` parameter takes ",
4760                    "an owned `String` (not `impl Into<String>`) matching ",
4761                    "the paired `crate::render::*` predicate's ",
4762                    "`Result<(), String>` return shape every wire-up ",
4763                    "already holds owned at the call site."
4764                )]
4765                #[must_use]
4766                pub fn $ctor(nome: &str, $axis: &str, reason: String) -> Self {
4767                    Self::$variant {
4768                        nome: nome.to_string(),
4769                        $axis: $axis.to_string(),
4770                        reason,
4771                    }
4772                }
4773            )*
4774        }
4775    };
4776}
4777
4778dep_nome_axis_reason_ctors! {
4779    versao_invalid => VersaoInvalid { versao },
4780    fonte_repo_shape => FonteRepoShape { repo },
4781    caracteristica_invalid => CaracteristicaInvalid { caracteristica },
4782}
4783
4784// Fold the two `DepError::FontePinShape { nome: nome.to_string(),
4785// pin: <pin>.to_string(), value: v.clone(), reason }` four-slot
4786// struct-variant wire-up sites at [`DepSource::validate`]'s
4787// per-`:fonte` git-pin value-shape gate onto one substrate primitive on
4788// the `DepError` envelope — the last open-coded ctor site remaining on
4789// the `:fonte (:tipo git …)` value-shape trajectory this envelope
4790// carries, and the single-variant sibling of the peer four already-
4791// lifted [`DepError`] ctor families ([`fonte_caminho_ctors!`] f85f145
4792// on the two-slot `{ nome, caminho }` envelope,
4793// [`fonte_caminho_byte_ctors!`] 0e35793 on the three-slot
4794// `{ nome, caminho, byte }` envelope, [`dep_nome_only_ctors!`] 792aa92
4795// on the one-slot `{ nome }` envelope, and [`dep_nome_list_ctors!`]
4796// 6f5e0cd on the two-slot `{ nome, list }` envelope). Peer of the
4797// sibling [`crate::aplicacao::contrato_pair_value_reason_ctors!`]
4798// (14e13f1) four-slot fold on the `AplicacaoError` envelope — same
4799// `{ …, value: String, reason: String }` payload shape, one axis
4800// removed at the `nome`-only-owner altitude the `DepError` envelope
4801// keys off (no `edge_pair()` de/para pair).
4802//
4803// The two wire-up sites this fold closes are the paired refname-pin
4804// arm (`|| DepError::FontePinShape { nome: nome.to_string(),
4805// pin: pin.to_string(), value: v.clone(), reason }` inside the
4806// `[(":tag", tag), (":branch", branch)]` iterator against
4807// [`crate::render::is_git_ref_name`]) and the hex-OID-pin arm
4808// (`|| DepError::FontePinShape { nome: nome.to_string(),
4809// pin: ":rev".to_string(), value: v.clone(), reason }` against
4810// [`crate::render::is_git_oid`]) — each opened the identical
4811// `DepError::FontePinShape { … }` six-line struct-literal against the
4812// same `(nome: &str, pin: &str, v: &String, reason: String)` local
4813// tuple, the exact "same block re-inlined at every consumer" shape
4814// the PRIME DIRECTIVE names as a bug. The `pin` axis discriminator is
4815// the only thing that varies between them (`":tag"`/`":branch"` on
4816// the refname arm, `":rev"` on the hex-OID arm); the rest of the
4817// struct-literal is a byte-for-byte re-inline. Refname/hex-OID both
4818// route through the same ctor because their `pin` field carries the
4819// author-surface tag verbatim (matching the `FontePinEmpty` /
4820// `FontePinAmbiguous` sibling variants' `pin: String` axis
4821// convention), so the offending author can grep their caixa.lisp for
4822// the offending `:tag "<value>"` / `:branch "<value>"` /
4823// `:rev "<value>"` literal in one edit.
4824//
4825// The single ctor below folds each wire-up onto one dispatch:
4826// `DepError::fonte_pin_shape(nome, pin, v, reason)`, byte-equal to
4827// the pre-lift struct-literal on the same `(&str, &str, &str,
4828// String)` fixture. The uniform four-field construction
4829// (`nome.to_string()` / `pin.to_string()` / `value.to_string()` /
4830// `reason` forwarded owned) is spelled once here rather than at every
4831// wire-up site. The `reason: String` field takes an owned `String`
4832// (not `impl Into<String>`) matching the two call sites' pre-existing
4833// `let Err(reason) = crate::render::is_git_ref_name(v)` /
4834// `let Err(reason) = crate::render::is_git_oid(v)` shape — both
4835// predicates return `Result<(), String>`, so the caller always holds
4836// an owned `String` at the wire-up site and threading it through the
4837// ctor without a `.into()` shim keeps the routing shape byte-equal to
4838// the pre-lift block. The `value: &str` parameter accepts both `&str`
4839// literals (unused today) and `&String` (from the caller-held
4840// `v: &String` on each arm, via Deref coercion), so every existing
4841// wire-up threads through the ctor without a pre-conversion.
4842//
4843// Every future consumer that wants to construct this variant outside
4844// the two in-crate [`DepSource::validate`] wire-up sites (a deferred
4845// `caixa-resolver` per-`:fonte` re-validator at lacre-resolve time
4846// re-checking the same value-shape axes the resolver consumes, a
4847// future `feira validate --deps` per-caixa admission verb re-checking
4848// the `:fonte :tag`/`:branch`/`:rev` axes, a per-lacre overlay
4849// resolver rejecting a git-pin value against a cluster-local
4850// snapshot) now reaches this variant through one call rather than
4851// re-inlining the six-line struct-literal in lockstep with the two
4852// in-crate wire-up sites.
4853impl DepError {
4854    /// Construct a [`DepError::FontePinShape`] naming the offending
4855    /// `:deps :nome`, the offending `:fonte (:tipo git …) :<pin>`
4856    /// axis tag, the offending value, and the parser-shaped `reason`.
4857    /// Folds the uniform
4858    /// `Self::FontePinShape { nome: nome.to_string(),
4859    /// pin: pin.to_string(), value: value.to_string(), reason }`
4860    /// four-field struct-literal onto one substrate primitive so
4861    /// every [`DepSource::validate`] wire-up on this variant reads
4862    /// through one dispatch rather than the pre-lift six-line
4863    /// open-coded block. The `nome` string threads verbatim from
4864    /// [`Dep::nome`] at the call site; the `pin` string carries the
4865    /// author-surface `:tag` / `:branch` / `:rev` tag verbatim; the
4866    /// `value` string carries the offending refname / hex-OID
4867    /// verbatim; and `reason` forwards the owned `String` returned
4868    /// by [`crate::render::is_git_ref_name`] /
4869    /// [`crate::render::is_git_oid`] without a `.into()` shim.
4870    #[must_use]
4871    pub fn fonte_pin_shape(nome: &str, pin: &str, value: &str, reason: String) -> Self {
4872        Self::FontePinShape {
4873            nome: nome.to_string(),
4874            pin: pin.to_string(),
4875            value: value.to_string(),
4876            reason,
4877        }
4878    }
4879}
4880
4881#[allow(clippy::trivially_copy_pass_by_ref)]
4882fn is_false(b: &bool) -> bool {
4883    !*b
4884}
4885
4886#[cfg(test)]
4887mod tests {
4888    use super::*;
4889
4890    #[test]
4891    fn registry_dep_is_minimal() {
4892        let d = Dep::simple("caixa-teia", "^0.1");
4893        assert_eq!(d.nome, "caixa-teia");
4894        assert_eq!(d.versao, "^0.1");
4895        assert!(d.fonte.is_none());
4896        assert!(!d.opcional());
4897        assert!(d.caracteristicas().is_empty());
4898    }
4899
4900    #[test]
4901    fn dep_string_scalar_accessor_pair_is_const_fn() {
4902        // Fail-before-pass-after pin on [`Dep::nome`] +
4903        // [`Dep::versao_requirement`]'s `const`-eval-surface posture.
4904        // Each accessor projects the per-`:deps` / per-`:deps-dev`
4905        // entry's [`String`] storage through the `pub const fn`
4906        // [`String::as_str`] (const-stable since Rust 1.87, well
4907        // within the workspace MSRV) — any future accidental
4908        // downgrade to non-`const` fails the corresponding
4909        // `<name>_via_const_fn` wrapper at caixa-core build time with
4910        // E0015 (`cannot call non-const method`), strictly stronger
4911        // than a runtime `assert!`. Sibling of the peer
4912        // per-M2/M3/universal-axis `String → &str` scalar-accessor
4913        // family pins on the sibling `const`-eval-surface passes
4914        // ([`crate::Caixa::nome`] / [`crate::Caixa::versao`] at the
4915        // top-level manifest, [`crate::CaixaVersion::as_str`] at the
4916        // typed-newtype wrapper, [`crate::aplicacao::Membro::nome`] /
4917        // [`crate::aplicacao::Membro::versao_requirement`] at the M3
4918        // membership axis, [`crate::aplicacao::Entrada::hostname`] /
4919        // [`crate::aplicacao::Entrada::destination`] at the M3
4920        // ingress axis, [`crate::supervisor::ChildSpec::nome`] /
4921        // [`crate::supervisor::ChildSpec::versao_requirement`] at the
4922        // M2 supervisor-tree axis,
4923        // [`crate::upgrade::UpgradeFromEntry::prior_versao`] at the
4924        // M2 upgrade axis, and the per-`:contratos`
4925        // [`crate::aplicacao::WitContract::source`] /
4926        // [`crate::aplicacao::WitContract::destination`] /
4927        // [`crate::aplicacao::WitContract::world_ref`] trio the
4928        // sibling pin at 279823b already anchors).
4929        const fn nome_via_const_fn(d: &Dep) -> &str {
4930            d.nome()
4931        }
4932        const fn versao_via_const_fn(d: &Dep) -> &str {
4933            d.versao_requirement()
4934        }
4935        for (nome, versao) in [
4936            ("caixa-teia", "^0.1"),
4937            ("caixa-mesh", "~0.2.3"),
4938            ("caixa-helm", "*"),
4939        ] {
4940            let d = Dep::simple(nome, versao);
4941            assert_eq!(nome_via_const_fn(&d), d.nome());
4942            assert_eq!(versao_via_const_fn(&d), d.versao_requirement());
4943            assert_eq!(d.nome(), nome);
4944            assert_eq!(d.versao_requirement(), versao);
4945        }
4946    }
4947
4948    #[test]
4949    fn dep_outer_accessor_family_is_const_fn() {
4950        // Fail-before-pass-after pin on [`Dep::fonte`] +
4951        // [`Dep::caracteristicas`]'s `const`-eval-surface posture.
4952        // Each accessor projects the per-`:deps` / per-`:deps-dev`
4953        // entry's composite / list storage through a `pub const fn`
4954        // stdlib method (`Option::<DepSource>::as_ref` /
4955        // `Vec::<String>::as_slice`, both const-stable since Rust
4956        // 1.83, well within the workspace MSRV). Any future
4957        // accidental downgrade to non-`const` fails the corresponding
4958        // `<name>_via_const_fn` wrapper at caixa-core build time with
4959        // E0015 (`cannot call non-const method`), strictly stronger
4960        // than a runtime `assert!` and side-stepping the destructor-
4961        // in-const restriction the `Dep` fixture's `String` /
4962        // `Option<DepSource>` / `Vec<String>` carriers rule out on the
4963        // direct-`const _: () = assert!(...)` residence.
4964        //
4965        // Peer of the sibling per-`Dep` scalar-accessor pair pin
4966        // [`dep_string_scalar_accessor_pair_is_const_fn`] on the same
4967        // outer per-dep-list-entry [`Dep`] altitude — this pin extends
4968        // the `const`-eval-surface discipline onto the composite-
4969        // reference and slice-return arms of the outer-`Dep` accessor
4970        // family, closing the four-slot outer surface (`:nome` +
4971        // `:versao` + `:fonte` + `:caracteristicas`) on the `const`-fn
4972        // posture. The `:opcional` `bool` arm already carries the
4973        // posture through [`Dep::opcional`]'s prior `pub const fn`
4974        // declaration, so this pin lands the last two unlifted
4975        // outer-`Dep` accessors and closes the family.
4976        const fn fonte_via_const_fn(d: &Dep) -> Option<&DepSource> {
4977            d.fonte()
4978        }
4979        const fn caracteristicas_via_const_fn(d: &Dep) -> &[String] {
4980            d.caracteristicas()
4981        }
4982        // `Dep::simple` — no `:fonte`, empty `:caracteristicas`.
4983        let empty = Dep::simple("caixa-teia", "^0.1");
4984        assert!(fonte_via_const_fn(&empty).is_none());
4985        assert_eq!(fonte_via_const_fn(&empty), empty.fonte());
4986        assert!(caracteristicas_via_const_fn(&empty).is_empty());
4987        assert_eq!(
4988            caracteristicas_via_const_fn(&empty),
4989            empty.caracteristicas()
4990        );
4991        // `Dep::git` — `:fonte` is `Some(Git{…})`, `:caracteristicas`
4992        // still empty.
4993        let git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
4994        assert!(fonte_via_const_fn(&git).is_some());
4995        assert_eq!(fonte_via_const_fn(&git), git.fonte());
4996        assert_eq!(caracteristicas_via_const_fn(&git), git.caracteristicas());
4997        // Populated `:caracteristicas` — exercise the non-empty
4998        // slice-view arm to pin the accessor's borrow shape against
4999        // both a `Vec::new()` empty backing buffer and a populated one.
5000        let mut with_features = Dep::simple("caixa-teia", "^0.1");
5001        with_features.caracteristicas = vec!["feat-a".into(), "feat-b".into()];
5002        assert_eq!(caracteristicas_via_const_fn(&with_features).len(), 2);
5003        assert_eq!(
5004            caracteristicas_via_const_fn(&with_features),
5005            with_features.caracteristicas()
5006        );
5007    }
5008
5009    #[test]
5010    fn git_dep_carries_tag() {
5011        let d = Dep::git("t", "*", "github:o/r", "v1");
5012        match d.fonte {
5013            Some(DepSource::Git {
5014                ref repo, ref tag, ..
5015            }) => {
5016                assert_eq!(repo, "github:o/r");
5017                assert_eq!(tag.as_deref(), Some("v1"));
5018            }
5019            _ => panic!("expected Git source"),
5020        }
5021    }
5022
5023    #[test]
5024    fn validate_accepts_simple_dep() {
5025        Dep::simple("caixa-teia", "^0.1").validate().unwrap();
5026    }
5027
5028    #[test]
5029    fn validate_rejects_empty_nome() {
5030        // The fail-before-pass-after pin for `:nome ""`: the empty-name
5031        // arm fires first so the per-entry parse-side diagnostic doesn't
5032        // emit a useless `nome: ""` reference.
5033        let mut d = Dep::simple("placeholder", "^0.1");
5034        d.nome = String::new();
5035        assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
5036    }
5037
5038    #[test]
5039    fn validate_rejects_empty_versao() {
5040        // `parse_requirement("")` returns `Ok(VersionReq::STAR)` (the
5041        // semver crate accepts the empty string as a wildcard match),
5042        // so the empty-`:versao` arm is structurally necessary even
5043        // with the parse arm in place — mirrors `MembroVersaoEmpty` /
5044        // `EmptyChildVersion` ordering on the other two `:versao` axes.
5045        let mut d = Dep::simple("caixa-teia", "ignored");
5046        d.versao = String::new();
5047        let err = d.validate().unwrap_err();
5048        assert!(
5049            matches!(err, DepError::VersaoEmpty { ref nome } if nome == "caixa-teia"),
5050            "got {err:?}"
5051        );
5052    }
5053
5054    // ── value-shape: DNS-1123 label on :deps :nome ────────────────────────
5055
5056    #[test]
5057    fn validate_rejects_nome_with_uppercase() {
5058        // The fail-before-pass-after pin: a non-empty but uppercase
5059        // `:nome` silently passed `validate()` on every pre-gate
5060        // codebase because the prior shape only refused the empty
5061        // string. The DNS-1123 violation surfaced far downstream at
5062        // lacre-resolve time when the *target* caixa's `:nome` failed
5063        // its own gate — far from the `:deps` entry, with a diagnostic
5064        // naming the target rather than the dep entry that referenced
5065        // it. Same fail-before-pass-after fixture pinned for
5066        // `:membros :caixa` (3f9d7a0), `:children :caixa` (31bfa43),
5067        // and Caixa `:nome` (6c992f8).
5068        let d = Dep::simple("Caixa-Teia", "^0.1");
5069        let err = d.validate().unwrap_err();
5070        assert!(
5071            matches!(
5072                err,
5073                DepError::NomeInvalid { ref nome, ref reason }
5074                    if nome == "Caixa-Teia" && reason.contains("uppercase")
5075            ),
5076            "got {err:?}"
5077        );
5078    }
5079
5080    #[test]
5081    fn validate_rejects_nome_with_underscore() {
5082        // RFC 1123 allows `[a-z0-9-]` only; underscore is the canonical
5083        // "I'm thinking of Go module names / Python identifiers" leak.
5084        // Same fixture pinned for the peer caixa-identifier axes.
5085        let d = Dep::simple("caixa_teia", "^0.1");
5086        let err = d.validate().unwrap_err();
5087        assert!(
5088            matches!(
5089                err,
5090                DepError::NomeInvalid { ref nome, ref reason }
5091                    if nome == "caixa_teia" && reason.contains('_')
5092            ),
5093            "got {err:?}"
5094        );
5095    }
5096
5097    #[test]
5098    fn validate_rejects_nome_with_dot() {
5099        // A `:deps :nome` is a single DNS-1123 *label*, not a
5100        // subdomain — dots are rejected. The `"caixa.teia"` shape is
5101        // the canonical "I confused the dep name with the FQDN /
5102        // namespace" footgun, distinct from the legitimate
5103        // `:fonte :repo "github:org/caixa-teia"` axis.
5104        let d = Dep::simple("caixa.teia", "^0.1");
5105        let err = d.validate().unwrap_err();
5106        assert!(
5107            matches!(
5108                err,
5109                DepError::NomeInvalid { ref nome, ref reason }
5110                    if nome == "caixa.teia" && reason.contains('.')
5111            ),
5112            "got {err:?}"
5113        );
5114    }
5115
5116    #[test]
5117    fn validate_rejects_nome_with_leading_hyphen() {
5118        // RFC 1123 requires alphanumeric at both label boundaries.
5119        // Pinned in parity with the peer DNS-1123 fixtures.
5120        let d = Dep::simple("-caixa-teia", "^0.1");
5121        let err = d.validate().unwrap_err();
5122        assert!(
5123            matches!(
5124                err,
5125                DepError::NomeInvalid { ref nome, ref reason }
5126                    if nome == "-caixa-teia" && reason.contains("alphanumeric")
5127            ),
5128            "got {err:?}"
5129        );
5130    }
5131
5132    #[test]
5133    fn validate_rejects_nome_with_trailing_hyphen() {
5134        let d = Dep::simple("caixa-teia-", "^0.1");
5135        let err = d.validate().unwrap_err();
5136        assert!(
5137            matches!(
5138                err,
5139                DepError::NomeInvalid { ref nome, ref reason }
5140                    if nome == "caixa-teia-" && reason.contains("alphanumeric")
5141            ),
5142            "got {err:?}"
5143        );
5144    }
5145
5146    #[test]
5147    fn validate_rejects_nome_with_slash() {
5148        // The canonical "I copied the GitHub repo path into `:nome`
5149        // instead of `:fonte :repo`" typo. A `/` in the name leaks the
5150        // lacre-side `:repositorio` shape (`pleme-io/caixa-teia`) into
5151        // the local-name slot. Same fixture pinned for `:membros
5152        // :caixa` (3f9d7a0).
5153        let d = Dep::simple("pleme-io/caixa-teia", "^0.1");
5154        let err = d.validate().unwrap_err();
5155        assert!(
5156            matches!(
5157                err,
5158                DepError::NomeInvalid { ref nome, ref reason }
5159                    if nome == "pleme-io/caixa-teia" && reason.contains('/')
5160            ),
5161            "got {err:?}"
5162        );
5163    }
5164
5165    #[test]
5166    fn validate_rejects_nome_too_long() {
5167        // 64-byte label — one over the RFC 1035 / RFC 1123 label cap.
5168        // Built from a valid character set so the length-bound
5169        // diagnostic surfaces before any per-character check (the
5170        // order pin parallel to the per-character predicates inside
5171        // [`crate::render::is_dns_1123_label`]).
5172        let long = "a".repeat(64);
5173        let d = Dep::simple(&long, "^0.1");
5174        let err = d.validate().unwrap_err();
5175        assert!(
5176            matches!(
5177                err,
5178                DepError::NomeInvalid { ref nome, ref reason }
5179                    if nome.len() == 64 && reason.contains("max length of 63")
5180            ),
5181            "got {err:?}"
5182        );
5183    }
5184
5185    #[test]
5186    fn validate_accepts_canonical_nome_labels() {
5187        // Positive-control sweep — every form the K8s apiserver
5188        // accepts as a DNS-1123 label must round-trip through
5189        // validate. Covers a hyphen-bearing label, a numeric-suffix
5190        // label, a leading-digit label, a single-character label, and
5191        // a 63-byte (exactly the cap) label — the same fixture set
5192        // the peer `:membros :caixa` / `:children :caixa` positive
5193        // controls pin.
5194        for nome in [
5195            "caixa-teia",
5196            "caixa-resolver2",
5197            "2nd-tier-cache",
5198            "x",
5199            "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0",
5200        ] {
5201            Dep::simple(nome, "^0.1")
5202                .validate()
5203                .unwrap_or_else(|e| panic!("canonical label {nome:?} must validate, got {e:?}"));
5204        }
5205    }
5206
5207    #[test]
5208    fn nome_empty_takes_precedence_over_nome_invalid() {
5209        // Ordering pin: `NomeEmpty` is the more self-locating
5210        // diagnostic on `""` and must lead — `is_dns_1123_label` is
5211        // only reached after the empty-check fires at the call site.
5212        // Mirrors `membro_caixa_empty_takes_precedence_over_invalid`
5213        // (3f9d7a0) on the peer caixa-identifier axis.
5214        let mut d = Dep::simple("placeholder", "^0.1");
5215        d.nome = String::new();
5216        assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
5217    }
5218
5219    #[test]
5220    fn nome_invalid_fires_before_versao_empty() {
5221        // Ordering pin: a malformed `:nome` fires before any `:versao`
5222        // axis check on the *same* entry — the per-entry shape gates
5223        // run top-to-bottom (nome empty → nome shape → versao empty →
5224        // versao parse → fonte shape), so a one-entry caixa.lisp with
5225        // both wrong sees the name-side diagnostic first (the name is
5226        // the self-locating axis — without a valid name, the parse
5227        // diagnostic can't quote `:nome "<bad>"`). Same ordering
5228        // discipline as `membro_caixa_invalid_fires_before_versao_check`
5229        // (3f9d7a0).
5230        let mut d = Dep::simple("Caixa-Teia", "^0.1");
5231        d.versao = String::new();
5232        let err = d.validate().unwrap_err();
5233        assert!(
5234            matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
5235            "got {err:?}"
5236        );
5237    }
5238
5239    #[test]
5240    fn nome_invalid_fires_before_versao_invalid() {
5241        // Ordering pin: a malformed `:nome` fires before the `:versao`
5242        // parse-side check on the *same* entry. Pin separately from
5243        // the empty-versao ordering so a future re-ordering surfaces
5244        // here, parallel to the b0c8389 / c4213a4 trajectory.
5245        let d = Dep::simple("Caixa-Teia", "^^0.1");
5246        let err = d.validate().unwrap_err();
5247        assert!(
5248            matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
5249            "got {err:?}"
5250        );
5251    }
5252
5253    #[test]
5254    fn nome_invalid_fires_before_fonte_invalid() {
5255        // Ordering pin: a malformed `:nome` fires before the `:fonte`
5256        // shape check on the *same* entry. The `:fonte` diagnostic
5257        // names the offending dep's `:nome` verbatim (via
5258        // `DepSource::validate(&self.nome)`), so a non-self-locating
5259        // name would taint the downstream diagnostic too — the gate
5260        // ordering keeps both diagnostics individually self-locating.
5261        let mut d = Dep::simple("Caixa-Teia", "^0.1");
5262        d.fonte = Some(DepSource::Git {
5263            repo: String::new(),
5264            tag: None,
5265            rev: None,
5266            branch: None,
5267        });
5268        let err = d.validate().unwrap_err();
5269        assert!(
5270            matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
5271            "got {err:?}"
5272        );
5273    }
5274
5275    #[test]
5276    fn nome_invalid_diagnostic_carries_offending_name() {
5277        // The diagnostic-shape pin: the error names the offending
5278        // `:nome` value verbatim so the author can grep their
5279        // caixa.lisp without re-running the build, and carries a
5280        // non-empty `reason` from `is_dns_1123_label` so the
5281        // predicate's own wording flows through to the diagnostic.
5282        // Same shape as `MembroCaixaInvalid` (3f9d7a0),
5283        // `ChildCaixaInvalid` (31bfa43), `ManifestError::NomeInvalid`
5284        // (6c992f8) — the four DNS-1123 caixa-identifier axes now
5285        // share a structurally-equivalent diagnostic family.
5286        let d = Dep::simple("Caixa_Teia", "^0.1");
5287        let err = d.validate().unwrap_err();
5288        let DepError::NomeInvalid { nome, reason } = err else {
5289            panic!("expected NomeInvalid, got other variant");
5290        };
5291        assert_eq!(nome, "Caixa_Teia");
5292        assert!(
5293            !reason.is_empty(),
5294            "NomeInvalid `reason` must carry the predicate's wording verbatim"
5295        );
5296    }
5297
5298    #[test]
5299    fn validate_rejects_invalid_versao_requirement() {
5300        // The fail-before-pass-after pin: a non-empty but malformed
5301        // requirement (`"^bad-version"`) silently passed every pre-gate
5302        // codebase because `:deps :versao` wasn't validated. The parse
5303        // failure surfaced far downstream at lacre-resolve time with a
5304        // `semver::Error` that didn't name which `:deps` entry carried
5305        // the typo. The new gate moves the check to caixa-build time
5306        // at the source caixa.lisp.
5307        let d = Dep::simple("caixa-teia", "^bad-version");
5308        let err = d.validate().unwrap_err();
5309        assert!(
5310            matches!(
5311                err,
5312                DepError::VersaoInvalid { ref nome, ref versao, .. }
5313                    if nome == "caixa-teia" && versao == "^bad-version"
5314            ),
5315            "got {err:?}"
5316        );
5317    }
5318
5319    #[test]
5320    fn validate_rejects_versao_with_double_caret_typo() {
5321        // `"^^0.1"` is the canonical doubled-caret typo — looks like a
5322        // Cargo-shaped requirement on first glance but fails the parser
5323        // because semver doesn't accept stacked operators. Pin this
5324        // adjacent-shape footgun explicitly so a future relaxation that
5325        // accepts "looks-canonical-but-isn't" forms surfaces here, in
5326        // parity with the `:membros` / `:children` fixtures.
5327        let d = Dep::simple("caixa-teia", "^^0.1");
5328        let err = d.validate().unwrap_err();
5329        assert!(
5330            matches!(
5331                err,
5332                DepError::VersaoInvalid { ref nome, ref versao, .. }
5333                    if nome == "caixa-teia" && versao == "^^0.1"
5334            ),
5335            "got {err:?}"
5336        );
5337    }
5338
5339    #[test]
5340    fn validate_rejects_versao_with_v_prefixed_tag() {
5341        // `"v0.1"` is the canonical "git-tag-shape leaking into the
5342        // semver requirement slot" typo — an author copies the
5343        // publish-side git-tag string verbatim into `:versao`, but
5344        // Cargo's semver parser rejects the leading `v`. Same fixture
5345        // pinned for `:membros :versao` (9888b13) and `:children
5346        // :versao` (b38ff3a). (Bare `x`-glob shorthands like `^0.1.x`
5347        // are *accepted* by the semver crate as an `*` wildcard on the
5348        // patch axis — they're a Cargo-side valid shape, not a typo.)
5349        let d = Dep::simple("caixa-teia", "v0.1");
5350        let err = d.validate().unwrap_err();
5351        assert!(
5352            matches!(
5353                err,
5354                DepError::VersaoInvalid { ref nome, ref versao, .. }
5355                    if nome == "caixa-teia" && versao == "v0.1"
5356            ),
5357            "got {err:?}"
5358        );
5359    }
5360
5361    #[test]
5362    fn validate_accepts_canonical_versao_forms() {
5363        // The five Cargo-shaped requirement forms `:membros :versao`
5364        // and `:children :versao` already accept via
5365        // `crate::parse_requirement` must pass the deps gate without
5366        // re-validating at the resolver layer. Pin every leg so a
5367        // future tightening of the canonical set surfaces here as a
5368        // test failure.
5369        for form in [
5370            "^0.1",      // caret — minor-range pin (the most common shape)
5371            "~0.1.2",    // tilde — patch-range pin
5372            "0.1.0",     // exact — single-version pin
5373            "*",         // wildcard — explicitly any-version
5374            ">=0.1, <2", // multi-range — comma-separated comparators
5375        ] {
5376            Dep::simple("caixa-teia", form)
5377                .validate()
5378                .unwrap_or_else(|e| panic!("canonical form {form:?} must validate, got {e:?}"));
5379        }
5380    }
5381
5382    #[test]
5383    fn versao_empty_takes_precedence_over_invalid() {
5384        // Order pin: the existing `VersaoEmpty` diagnostic (which
5385        // doesn't try to parse) fires before the new `VersaoInvalid`
5386        // parse-side diagnostic, so an empty `:versao` keeps its
5387        // narrower error message — `parse_requirement("")` would
5388        // otherwise return `Ok(STAR)` and silently pass, but the empty
5389        // arm catches it first.
5390        let mut d = Dep::simple("caixa-teia", "ignored");
5391        d.versao = String::new();
5392        let err = d.validate().unwrap_err();
5393        assert!(
5394            matches!(err, DepError::VersaoEmpty { ref nome } if nome == "caixa-teia"),
5395            "got {err:?}"
5396        );
5397    }
5398
5399    #[test]
5400    fn nome_empty_takes_precedence_over_versao_invalid() {
5401        // Order pin: even when `:versao` is malformed and would raise
5402        // its own diagnostic, `:nome ""` fires first because the
5403        // per-entry parse diagnostic needs a non-empty name to be
5404        // self-locating. Mirrors the
5405        // `membros_validation_runs_before_contratos_membership_check`
5406        // ordering on the typed-graph layer.
5407        let mut d = Dep::simple("placeholder", "^bad");
5408        d.nome = String::new();
5409        let err = d.validate().unwrap_err();
5410        assert_eq!(err, DepError::NomeEmpty);
5411    }
5412
5413    #[test]
5414    fn versao_invalid_diagnostic_carries_offending_versao() {
5415        // The diagnostic-shape pin: the error names the offending
5416        // `:versao` value verbatim so the author can grep their
5417        // caixa.lisp without re-running the build, and carries a
5418        // non-empty `reason` from `semver::VersionReq::parse` so the
5419        // parser's own wording flows through to the diagnostic.
5420        let d = Dep::simple("caixa-teia", "not-a-req");
5421        let err = d.validate().unwrap_err();
5422        let DepError::VersaoInvalid {
5423            nome,
5424            versao,
5425            reason,
5426        } = err
5427        else {
5428            panic!("expected VersaoInvalid, got other variant");
5429        };
5430        assert_eq!(nome, "caixa-teia");
5431        assert_eq!(versao, "not-a-req");
5432        assert!(
5433            !reason.is_empty(),
5434            "VersaoInvalid `reason` must carry the parser's wording verbatim"
5435        );
5436    }
5437
5438    // -- :fonte value-shape gate ------------------------------------------
5439
5440    fn dep_with_fonte(fonte: DepSource) -> Dep {
5441        let mut d = Dep::simple("caixa-teia", "^0.1");
5442        d.fonte = Some(fonte);
5443        d
5444    }
5445
5446    #[test]
5447    fn validate_accepts_git_fonte_with_tag() {
5448        // The positive-control pin on the canonical git source — exactly
5449        // one of :tag/:rev/:branch set, non-empty :repo. Mirrors the
5450        // shape every existing caixa-resolver integration test uses.
5451        let d = dep_with_fonte(DepSource::Git {
5452            repo: "github:pleme-io/caixa-teia".into(),
5453            tag: Some("v0.1.0".into()),
5454            rev: None,
5455            branch: None,
5456        });
5457        d.validate().unwrap();
5458    }
5459
5460    #[test]
5461    fn validate_accepts_git_fonte_with_rev() {
5462        // Each of the three pin axes is independently a valid single-pin
5463        // shape; pin the :rev arm so a future relaxation that only
5464        // accepts :tag surfaces here. The value is a full 40-hex SHA-1
5465        // OID — the canonical `git rev-parse HEAD` emission shape the
5466        // `crate::render::is_git_oid` value-shape gate now requires;
5467        // abbreviated OIDs are ambiguous across repo history and
5468        // rejected at this gate (pinned separately by
5469        // `validate_rejects_git_fonte_with_rev_abbreviated_prefix`).
5470        let d = dep_with_fonte(DepSource::Git {
5471            repo: "github:pleme-io/caixa-teia".into(),
5472            tag: None,
5473            rev: Some("c0ffee0123abcdef0123456789abcdef01234567".into()),
5474            branch: None,
5475        });
5476        d.validate().unwrap();
5477    }
5478
5479    #[test]
5480    fn validate_accepts_git_fonte_with_branch() {
5481        // The :branch arm is the third valid single-pin shape — pinned
5482        // separately so the gate-accepts-all-three-pin-axes contract is
5483        // a build-error to relax.
5484        let d = dep_with_fonte(DepSource::Git {
5485            repo: "github:pleme-io/caixa-teia".into(),
5486            tag: None,
5487            rev: None,
5488            branch: Some("main".into()),
5489        });
5490        d.validate().unwrap();
5491    }
5492
5493    #[test]
5494    fn validate_accepts_path_fonte() {
5495        // The positive-control pin on the path source — non-empty
5496        // :caminho, no pin axes (paths have no commit identity). Pinned
5497        // so a future "paths must also pin a rev" tightening surfaces
5498        // here as a structural decision, not a silent break.
5499        let d = dep_with_fonte(DepSource::Path {
5500            caminho: "../caixa-teia".into(),
5501        });
5502        d.validate().unwrap();
5503    }
5504
5505    #[test]
5506    fn validate_rejects_git_fonte_with_empty_repo() {
5507        // The fail-before-pass-after pin for `(:tipo git :repo "" :tag
5508        // "v1")`: the empty-repo shape silently passed every pre-gate
5509        // codebase because `:fonte` wasn't validated. The git-clone
5510        // failure surfaced far downstream at lacre-resolve time with no
5511        // field naming which `:deps` entry carried the typo. The new
5512        // gate moves the check to caixa-build time at the source
5513        // caixa.lisp.
5514        let d = dep_with_fonte(DepSource::Git {
5515            repo: String::new(),
5516            tag: Some("v0.1.0".into()),
5517            rev: None,
5518            branch: None,
5519        });
5520        let err = d.validate().unwrap_err();
5521        assert!(
5522            matches!(err, DepError::FonteRepoEmpty { ref nome } if nome == "caixa-teia"),
5523            "got {err:?}"
5524        );
5525    }
5526
5527    // -- :repo value-shape gate -------------------------------------------
5528    //
5529    // The `:fonte (:tipo git :repo …)` value flows verbatim into the
5530    // caixa-resolver's `git clone <repo>` subprocess. The pre-gate
5531    // codebase admitted any non-empty string; the new
5532    // [`crate::render::is_git_repo_url`] predicate gates the git-porcelain
5533    // URL intersection-floor at validate time, peer with the three pin
5534    // axes (`:tag` + `:branch` via `is_git_ref_name`, `:rev` via
5535    // `is_git_oid`). Every test in this section is a fail-before /
5536    // pass-after pin on a specific authoring footgun.
5537
5538    #[test]
5539    fn validate_rejects_git_fonte_with_repo_carrying_trailing_space() {
5540        // The canonical paste-from-doc footgun on `:repo` — an author
5541        // copies `"github:pleme-io/caixa-teia "` (trailing space) out of
5542        // a doc paragraph. Until this gate landed the empty-repo arm
5543        // passed (the string isn't empty), the resolver issued
5544        // `git clone 'github:pleme-io/caixa-teia '`, and the failure
5545        // surfaced at clone time with a quoting-confused error far from
5546        // the source caixa.lisp. Same paste-from-doc footgun the
5547        // `:tag "v0.1.0 "` gate (e70d213) closes on the peer refname
5548        // axis — now closed on the `:repo` URL axis too.
5549        let d = dep_with_fonte(DepSource::Git {
5550            repo: "github:pleme-io/caixa-teia ".into(),
5551            tag: Some("v0.1.0".into()),
5552            rev: None,
5553            branch: None,
5554        });
5555        let err = d.validate().unwrap_err();
5556        let DepError::FonteRepoShape { nome, repo, reason } = err else {
5557            panic!("expected FonteRepoShape, got other variant");
5558        };
5559        assert_eq!(nome, "caixa-teia");
5560        assert_eq!(repo, "github:pleme-io/caixa-teia ");
5561        assert!(
5562            reason.contains("whitespace"),
5563            "reason must surface the whitespace arm, got {reason:?}"
5564        );
5565    }
5566
5567    #[test]
5568    fn validate_rejects_git_fonte_with_repo_starting_with_dash() {
5569        // The canonical CLI-argument-injection footgun at the `git clone`
5570        // subprocess boundary — `:repo "-upload-pack=evil"` makes git's
5571        // argv parser read the value as a CLI flag, escaping the
5572        // subprocess argument boundary. The `--` separator workaround
5573        // does not fix the typed slot's accepted set; the gate rejects
5574        // the shape upstream at validate time so the resolver never
5575        // invokes a `git clone -…` subprocess.
5576        let d = dep_with_fonte(DepSource::Git {
5577            repo: "-upload-pack=evil".into(),
5578            tag: Some("v0.1.0".into()),
5579            rev: None,
5580            branch: None,
5581        });
5582        let err = d.validate().unwrap_err();
5583        let DepError::FonteRepoShape { repo, reason, .. } = err else {
5584            panic!("expected FonteRepoShape, got other variant");
5585        };
5586        assert_eq!(repo, "-upload-pack=evil");
5587        assert!(
5588            reason.contains("must not start with `-`"),
5589            "reason must surface the leading-`-` arm, got {reason:?}"
5590        );
5591    }
5592
5593    #[test]
5594    fn validate_rejects_git_fonte_with_repo_carrying_embedded_newline() {
5595        // The canonical paste-from-multiline-doc footgun — a `:repo`
5596        // string with an embedded `\n` silently breaks git's URL parser
5597        // and is a class of CRLF-injection at the subprocess-argument
5598        // boundary. Caught by the control-char arm (0x0A < 0x20).
5599        let d = dep_with_fonte(DepSource::Git {
5600            repo: "github:pleme-io/caixa-teia\nrm -rf /".into(),
5601            tag: Some("v0.1.0".into()),
5602            rev: None,
5603            branch: None,
5604        });
5605        let err = d.validate().unwrap_err();
5606        let DepError::FonteRepoShape { reason, .. } = err else {
5607            panic!("expected FonteRepoShape, got other variant");
5608        };
5609        assert!(
5610            reason.contains("control character"),
5611            "reason must surface the control-char arm, got {reason:?}"
5612        );
5613    }
5614
5615    #[test]
5616    fn validate_rejects_git_fonte_with_repo_carrying_tab() {
5617        // Tab is the sibling whitespace footgun (the canonical
5618        // copy-from-aligned-table paste); pinned separately from the
5619        // space arm so a future relaxation that only catches one
5620        // surfaces here.
5621        let d = dep_with_fonte(DepSource::Git {
5622            repo: "github:pleme-io/caixa-teia\t".into(),
5623            tag: Some("v0.1.0".into()),
5624            rev: None,
5625            branch: None,
5626        });
5627        let err = d.validate().unwrap_err();
5628        assert!(
5629            matches!(
5630                err,
5631                DepError::FonteRepoShape { ref reason, .. }
5632                    if reason.contains("whitespace")
5633            ),
5634            "got {err:?}"
5635        );
5636    }
5637
5638    #[test]
5639    fn validate_rejects_git_fonte_with_repo_carrying_non_ascii() {
5640        // IDN hosts must be pre-encoded as Punycode (`xn--…`) — raw
5641        // non-ASCII silently breaks at git's URL parser and round-trips
5642        // inconsistently across NFC/NFD normalization on APFS /
5643        // case-folding filesystems. Same intersection-floor
5644        // [`is_git_ref_name`] enforces on the refname axes.
5645        let d = dep_with_fonte(DepSource::Git {
5646            repo: "https://github.com/pleme-io/café".into(),
5647            tag: Some("v0.1.0".into()),
5648            rev: None,
5649            branch: None,
5650        });
5651        let err = d.validate().unwrap_err();
5652        assert!(
5653            matches!(
5654                err,
5655                DepError::FonteRepoShape { ref reason, .. }
5656                    if reason.contains("non-ASCII")
5657            ),
5658            "got {err:?}"
5659        );
5660    }
5661
5662    #[test]
5663    fn validate_rejects_git_fonte_with_repo_carrying_fragment_anchor() {
5664        // The fail-before-pass-after pin for the canonical paste-from-
5665        // browser-address-bar footgun on `:repo`: an author copies a
5666        // GitHub permalink to a README anchor / line-permalink and
5667        // forgets to trim the `#fragment` tail. Until this arm landed
5668        // `:repo "https://github.com/pleme-io/caixa-teia#readme"`
5669        // silently passed every prior arm (no whitespace, no control
5670        // chars, no non-ASCII, contains a `:`, doesn't start with `-`
5671        // or `:`), libcurl's URL parser stripped the `#readme` tail
5672        // before opening the HTTPS transport, and the lacre embedded
5673        // the value verbatim in its per-dep BLAKE3 closure — two
5674        // authors whose values differ only in their fragment anchor
5675        // (`#readme` vs `#L42`) resolve to the byte-identical upstream
5676        // `git clone` but lock to two distinct lacres, defeating the
5677        // THEORY.md §V.2 render-determinism contract. Same value-shape
5678        // axis-floor every peer typed surface enforces; peer `:fonte
5679        // :tag` / `:fonte :branch` already reject the byte-class through
5680        // `is_git_ref_name`'s alphabet (refs are leaf identifiers, no
5681        // URL grammar admitted) and `:entrada :paths` rejects `#` as
5682        // part of `is_gateway_api_http_path`'s RFC-3986-reserved set.
5683        let d = dep_with_fonte(DepSource::Git {
5684            repo: "https://github.com/pleme-io/caixa-teia#readme".into(),
5685            tag: Some("v0.1.0".into()),
5686            rev: None,
5687            branch: None,
5688        });
5689        let err = d.validate().unwrap_err();
5690        let DepError::FonteRepoShape { nome, repo, reason } = err else {
5691            panic!("expected FonteRepoShape, got other variant");
5692        };
5693        assert_eq!(nome, "caixa-teia");
5694        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia#readme");
5695        assert!(
5696            reason.contains("must not contain `#`"),
5697            "reason must surface the fragment-`#` arm, got {reason:?}"
5698        );
5699        assert!(
5700            reason.contains("fragment"),
5701            "reason must name the URL fragment grammar, got {reason:?}"
5702        );
5703    }
5704
5705    #[test]
5706    fn validate_rejects_git_fonte_with_repo_carrying_flake_ref_fragment() {
5707        // The symmetric paste-from-Nix-flake-ref footgun — an author
5708        // confuses the Nix flake-reference idiom (`github:foo/
5709        // bar#packageName`, where `#packageName` selects a flake
5710        // output) with the bare git `:repo` shape. The pleme-io
5711        // substrate authors compose flakes downstream of caixa
5712        // (caixa-flake renders a flake.nix), so the cross-idiom leak
5713        // is the canonical near-miss: the author writes the
5714        // flake-ref shape into a git `:repo` slot. Pinned separately
5715        // from the HTTPS-anchor arm so a future relaxation that
5716        // narrows to one URL scheme surfaces here.
5717        let d = dep_with_fonte(DepSource::Git {
5718            repo: "github:pleme-io/caixa-teia#caixa-teia".into(),
5719            tag: Some("v0.1.0".into()),
5720            rev: None,
5721            branch: None,
5722        });
5723        let err = d.validate().unwrap_err();
5724        let DepError::FonteRepoShape { reason, .. } = err else {
5725            panic!("expected FonteRepoShape, got other variant");
5726        };
5727        assert!(
5728            reason.contains("must not contain `#`"),
5729            "reason must surface the fragment-`#` arm, got {reason:?}"
5730        );
5731        assert!(
5732            reason.contains("Nix flake"),
5733            "reason must name the Nix-flake-ref cross-idiom footgun, got {reason:?}"
5734        );
5735    }
5736
5737    #[test]
5738    fn validate_rejects_git_fonte_with_repo_carrying_query_string() {
5739        // The fail-before-pass-after pin for the canonical paste-from-
5740        // browser-address-bar footgun on `:repo` (peer with the
5741        // a68f818 fragment-`#` arm on the same axis). An author
5742        // copies a GitHub tab deep-link out of the address bar and
5743        // forgets to trim the `?tab=…` query tail. Until this arm
5744        // landed `:repo "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file"`
5745        // silently passed every prior arm (no whitespace, no control
5746        // chars, no non-ASCII, no `#` fragment, contains a `:`,
5747        // doesn't start with `-` or `:`); GitHub silently ignored
5748        // the `?query` tail and served the same repo regardless;
5749        // the lacre embedded the value verbatim in its per-dep
5750        // BLAKE3 closure — two authors whose values differ only in
5751        // their query tail (`?tab=readme-ov-file` vs `?ref=main` vs
5752        // `?utm_source=twitter`) resolve to the byte-identical
5753        // upstream `git clone` but lock to two distinct lacres,
5754        // defeating the THEORY.md §V.2 render-determinism contract
5755        // on the same axis the `#` fragment arm closes. Same value-
5756        // shape axis-floor every peer typed surface enforces; peer
5757        // `:fonte :tag` / `:fonte :branch` already reject the byte-
5758        // class through `is_git_ref_name`'s alphabet (refspec glob
5759        // wildcards, caixa-core/src/render.rs:1426) and `:entrada
5760        // :paths` rejects `?` as the query separator in
5761        // `is_gateway_api_http_path` (caixa-core/src/render.rs:473).
5762        let d = dep_with_fonte(DepSource::Git {
5763            repo: "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file".into(),
5764            tag: Some("v0.1.0".into()),
5765            rev: None,
5766            branch: None,
5767        });
5768        let err = d.validate().unwrap_err();
5769        let DepError::FonteRepoShape { nome, repo, reason } = err else {
5770            panic!("expected FonteRepoShape, got other variant");
5771        };
5772        assert_eq!(nome, "caixa-teia");
5773        assert_eq!(
5774            repo,
5775            "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file"
5776        );
5777        assert!(
5778            reason.contains("must not contain `?`"),
5779            "reason must surface the query-`?` arm, got {reason:?}"
5780        );
5781        assert!(
5782            reason.contains("query"),
5783            "reason must name the URL query grammar, got {reason:?}"
5784        );
5785    }
5786
5787    #[test]
5788    fn validate_rejects_git_fonte_with_repo_carrying_utm_tracker() {
5789        // The symmetric paste-from-social-share footgun — an author
5790        // copies a repo URL out of a Slack unfurl / Twitter share /
5791        // newsletter link / Discord embed and forgets to trim the
5792        // `?utm_source=…` / `?utm_medium=…` / `?utm_campaign=…`
5793        // campaign-tracker tail. Every major social-share / unfurl /
5794        // newsletter platform appends these UTM parameters; the
5795        // canonical near-miss on the `:repo` axis. Pinned separately
5796        // from the GitHub-tab-deep-link arm so a future relaxation
5797        // that narrows to one query-parameter class surfaces here.
5798        let d = dep_with_fonte(DepSource::Git {
5799            repo: "https://github.com/pleme-io/caixa-teia?utm_source=twitter&utm_campaign=launch"
5800                .into(),
5801            tag: Some("v0.1.0".into()),
5802            rev: None,
5803            branch: None,
5804        });
5805        let err = d.validate().unwrap_err();
5806        let DepError::FonteRepoShape { reason, .. } = err else {
5807            panic!("expected FonteRepoShape, got other variant");
5808        };
5809        assert!(
5810            reason.contains("must not contain `?`"),
5811            "reason must surface the query-`?` arm, got {reason:?}"
5812        );
5813        assert!(
5814            reason.contains("campaign-tracker"),
5815            "reason must name the campaign-tracker paste footgun, got {reason:?}"
5816        );
5817    }
5818
5819    #[test]
5820    fn fonte_repo_fragment_fires_before_query_when_fragment_first() {
5821        // Cascade pin: the fragment-`#` arm and the query-`?` arm are
5822        // both per-byte arms inside the same `for &b in s.as_bytes()`
5823        // loop, so the byte that appears first in the value's byte
5824        // order wins. A `:repo "https://github.com/p/x#readme?ref=main"`
5825        // (fragment before query — unusual URL-grammar but value-
5826        // disjoint at byte level) carries both `#` and `?`; the `#`
5827        // byte appears first, so the fragment-`#` arm fires, surfacing
5828        // the more self-locating diagnostic on the byte the author
5829        // pasted earliest in the URL. Mirrors the peer cascade
5830        // discipline `fonte_repo_control_char_fires_before_fragment`
5831        // pins on the prior `:repo` byte-class arm.
5832        let d = dep_with_fonte(DepSource::Git {
5833            repo: "https://github.com/pleme-io/caixa-teia#readme?ref=main".into(),
5834            tag: Some("v0.1.0".into()),
5835            rev: None,
5836            branch: None,
5837        });
5838        let err = d.validate().unwrap_err();
5839        let DepError::FonteRepoShape { reason, .. } = err else {
5840            panic!("expected FonteRepoShape, got other variant");
5841        };
5842        assert!(
5843            reason.contains("must not contain `#`"),
5844            "reason must surface the fragment-`#` arm (fires before query-`?` when \
5845             `#` byte appears first in value), got {reason:?}"
5846        );
5847    }
5848
5849    #[test]
5850    fn fonte_repo_control_char_fires_before_fragment() {
5851        // Cascade pin: the control-char arm structurally precedes the
5852        // fragment-`#` arm. A value like `"github:p/x\n#readme"` probes
5853        // positive on both arms (contains LF and `#`), but the narrower
5854        // POSIX-syscall-rejected / CRLF-injection-class diagnostic
5855        // (`control character`) wins so the author sees the more
5856        // self-locating arm first. Mirrors the peer cascade discipline
5857        // every prior `:repo` byte-class arm establishes.
5858        let d = dep_with_fonte(DepSource::Git {
5859            repo: "github:pleme-io/caixa-teia\n#readme".into(),
5860            tag: Some("v0.1.0".into()),
5861            rev: None,
5862            branch: None,
5863        });
5864        let err = d.validate().unwrap_err();
5865        let DepError::FonteRepoShape { reason, .. } = err else {
5866            panic!("expected FonteRepoShape, got other variant");
5867        };
5868        assert!(
5869            reason.contains("control character"),
5870            "reason must surface the control-char arm, got {reason:?}"
5871        );
5872    }
5873
5874    #[test]
5875    fn validate_rejects_git_fonte_with_repo_carrying_embedded_backslash() {
5876        // The fail-before-pass-after pin for the canonical Windows-
5877        // file-path-confusion footgun on `:repo` (peer with the 3a4e1d7
5878        // backslash arm on the sibling `:caminho` path-fonte axis).
5879        // An author pastes a Windows Explorer address-bar / PowerShell
5880        // `Get-Location` output into a `file://` URL slot, producing
5881        // `file:///C:\Users\me\caixa-teia`. Until this arm landed the
5882        // value silently passed every prior arm (no whitespace, no
5883        // control chars, no non-ASCII, no `#`, no `?`, doesn't start
5884        // with `-` or `:`); libcurl's URL parser silently translates
5885        // `\` → `/` on some platforms and refuses it on others, so
5886        // the byte rides verbatim into the lacre's per-dep content-
5887        // address but is silently rewritten / rejected at the wire —
5888        // two authors whose `:repo` values differ only in backslash-
5889        // vs-forward-slash (`file:///C:\path` vs `file:///C:/path`)
5890        // resolve to the byte-identical local clone but lock to two
5891        // distinct BLAKE3 closures, defeating the THEORY.md §V.2
5892        // render-determinism contract on the same axis the `#`
5893        // fragment and `?` query arms close. Same value-shape axis-
5894        // floor every peer typed surface enforces; the `:caminho`
5895        // 3a4e1d7 arm closes the same byte on the path-fonte axis.
5896        let d = dep_with_fonte(DepSource::Git {
5897            repo: "file:///C:\\Users\\me\\caixa-teia".into(),
5898            tag: Some("v0.1.0".into()),
5899            rev: None,
5900            branch: None,
5901        });
5902        let err = d.validate().unwrap_err();
5903        let DepError::FonteRepoShape { nome, repo, reason } = err else {
5904            panic!("expected FonteRepoShape, got other variant");
5905        };
5906        assert_eq!(nome, "caixa-teia");
5907        assert_eq!(repo, "file:///C:\\Users\\me\\caixa-teia");
5908        assert!(
5909            reason.contains("must not contain `\\`"),
5910            "reason must surface the backslash-`\\` arm, got {reason:?}"
5911        );
5912        assert!(
5913            reason.contains("Windows"),
5914            "reason must name the Windows-path-confusion footgun, got {reason:?}"
5915        );
5916    }
5917
5918    #[test]
5919    fn validate_rejects_git_fonte_with_repo_carrying_mangled_https_backslashes() {
5920        // The symmetric Win32-shell-mangled-slashes footgun — an author
5921        // copies `https://github.com/foo/bar` into a Win32 shell that
5922        // rewrites every `/` to `\` (the canonical `cmd.exe` path-
5923        // separator-coercion bug), pastes the result into a `:repo`
5924        // slot, and produces `https:\\github.com\foo\bar`. Pinned
5925        // separately from the `file://` Explorer-paste arm so a future
5926        // relaxation that narrows to one URL scheme surfaces here.
5927        let d = dep_with_fonte(DepSource::Git {
5928            repo: "https:\\\\github.com\\pleme-io\\caixa-teia".into(),
5929            tag: Some("v0.1.0".into()),
5930            rev: None,
5931            branch: None,
5932        });
5933        let err = d.validate().unwrap_err();
5934        let DepError::FonteRepoShape { reason, .. } = err else {
5935            panic!("expected FonteRepoShape, got other variant");
5936        };
5937        assert!(
5938            reason.contains("must not contain `\\`"),
5939            "reason must surface the backslash-`\\` arm, got {reason:?}"
5940        );
5941        assert!(
5942            reason.contains("path separator") || reason.contains("path-segment separator"),
5943            "reason must name the URL path-segment separator grammar, got {reason:?}"
5944        );
5945    }
5946
5947    #[test]
5948    fn fonte_repo_fragment_fires_before_backslash_when_fragment_first() {
5949        // Cascade pin: the fragment-`#` arm and the backslash-`\` arm
5950        // are both per-byte arms inside the same `for &b in s.as_bytes()`
5951        // loop, so the byte that appears first in the value's byte order
5952        // wins. A `:repo "https://github.com/p/x#readme\\foo"` carries
5953        // both `#` and `\`; the `#` byte appears first, so the fragment-
5954        // `#` arm fires, surfacing the more self-locating diagnostic on
5955        // the byte the author pasted earliest in the URL. Mirrors the
5956        // peer cascade discipline `fonte_repo_fragment_fires_before_query_when_fragment_first`
5957        // pins on the prior `:repo` byte-class arm.
5958        let d = dep_with_fonte(DepSource::Git {
5959            repo: "https://github.com/pleme-io/caixa-teia#readme\\foo".into(),
5960            tag: Some("v0.1.0".into()),
5961            rev: None,
5962            branch: None,
5963        });
5964        let err = d.validate().unwrap_err();
5965        let DepError::FonteRepoShape { reason, .. } = err else {
5966            panic!("expected FonteRepoShape, got other variant");
5967        };
5968        assert!(
5969            reason.contains("must not contain `#`"),
5970            "reason must surface the fragment-`#` arm (fires before backslash-`\\` when \
5971             `#` byte appears first in value), got {reason:?}"
5972        );
5973    }
5974
5975    #[test]
5976    fn validate_rejects_git_fonte_with_repo_carrying_uri_template_placeholder() {
5977        // The fail-before-pass-after pin for the canonical URI Template
5978        // (RFC 6570) placeholder footgun on `:repo`. An author copies a
5979        // README quick-start snippet / OpenAPI `servers:` URL / Helm
5980        // chart `home:` template that carries unresolved
5981        // `{org}` / `{repo}` placeholders and pastes the raw template
5982        // into the `:repo` slot, expecting the substrate to resolve the
5983        // placeholder downstream. Until this arm landed the value
5984        // silently passed every prior arm (no whitespace, no control
5985        // chars, no non-ASCII, no `#`, no `?`, no `\`, doesn't start
5986        // with `-` or `:`); libcurl percent-encodes `{` / `}` to `%7B`
5987        // / `%7D` on the wire, so the byte rides verbatim into the
5988        // lacre's per-dep content-address but round-trips inconsistently
5989        // between the lacre's per-dep content-address and the
5990        // resolver's `git clone <repo>` invocation, defeating the
5991        // THEORY.md §V.2 render-determinism contract on the same axis
5992        // the `#` fragment, `?` query, and `\` backslash arms close;
5993        // every git porcelain entry-point additionally fetches a
5994        // nonexistent literal-`{placeholder}`-named path far from the
5995        // source caixa.lisp.
5996        let d = dep_with_fonte(DepSource::Git {
5997            repo: "https://github.com/{org}/caixa-teia".into(),
5998            tag: Some("v0.1.0".into()),
5999            rev: None,
6000            branch: None,
6001        });
6002        let err = d.validate().unwrap_err();
6003        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6004            panic!("expected FonteRepoShape, got other variant");
6005        };
6006        assert_eq!(nome, "caixa-teia");
6007        assert_eq!(repo, "https://github.com/{org}/caixa-teia");
6008        assert!(
6009            reason.contains("must not contain `{`"),
6010            "reason must surface the open-brace `{{` arm, got {reason:?}"
6011        );
6012        assert!(
6013            reason.contains("URI Template") || reason.contains("RFC 6570"),
6014            "reason must name the RFC 6570 URI Template grammar, got {reason:?}"
6015        );
6016    }
6017
6018    #[test]
6019    fn validate_rejects_git_fonte_with_repo_carrying_handlebars_doubled_brace() {
6020        // The symmetric Mustache / Handlebars doubled-brace
6021        // substitution-form footgun every CI / IaC templating engine
6022        // (Argo Workflows, Jinja2, Liquid, Vue / Angular interpolation,
6023        // GitHub Actions `${{ … }}` even though Actions uses `${{`) /
6024        // chart README quick-start snippet emits. Pinned separately
6025        // from the single-`{` `{org}` arm so a future relaxation that
6026        // narrows to one substitution-form surfaces here.
6027        let d = dep_with_fonte(DepSource::Git {
6028            repo: "https://github.com/{{org}}/caixa-teia".into(),
6029            tag: Some("v0.1.0".into()),
6030            rev: None,
6031            branch: None,
6032        });
6033        let err = d.validate().unwrap_err();
6034        let DepError::FonteRepoShape { reason, .. } = err else {
6035            panic!("expected FonteRepoShape, got other variant");
6036        };
6037        assert!(
6038            reason.contains("must not contain `{`"),
6039            "reason must surface the open-brace `{{` arm, got {reason:?}"
6040        );
6041    }
6042
6043    #[test]
6044    fn validate_rejects_git_fonte_with_repo_carrying_closing_brace_only() {
6045        // Asymmetric `}`-only shape — covers the closing-brace-by-
6046        // itself footgun (an author truncated `{org}/{repo}` mid-edit
6047        // and left a trailing `}` from the prior template fragment,
6048        // or pasted a value that included a closing brace from a
6049        // surrounding shell context). Pinned to ensure the predicate
6050        // refuses each brace independently rather than only when both
6051        // appear — a future regression that ANDs the two byte tests
6052        // surfaces here.
6053        let d = dep_with_fonte(DepSource::Git {
6054            repo: "https://github.com/pleme-io/caixa-teia}".into(),
6055            tag: Some("v0.1.0".into()),
6056            rev: None,
6057            branch: None,
6058        });
6059        let err = d.validate().unwrap_err();
6060        let DepError::FonteRepoShape { reason, .. } = err else {
6061            panic!("expected FonteRepoShape, got other variant");
6062        };
6063        assert!(
6064            reason.contains("must not contain `}`"),
6065            "reason must surface the close-brace `}}` arm, got {reason:?}"
6066        );
6067    }
6068
6069    #[test]
6070    fn fonte_repo_fragment_fires_before_template_placeholder_when_fragment_first() {
6071        // Cascade pin: the fragment-`#` arm and the template-`{` /
6072        // `}` arm are both per-byte arms inside the same
6073        // `for &b in s.as_bytes()` loop, so the byte that appears
6074        // first in the value's byte order wins. A `:repo
6075        // "https://github.com/p/x#readme{org}"` carries both `#` and
6076        // `{`; the `#` byte appears first, so the fragment-`#` arm
6077        // fires, surfacing the more self-locating diagnostic on the
6078        // byte the author pasted earliest in the URL. Mirrors the
6079        // peer cascade discipline `fonte_repo_fragment_fires_before_backslash_when_fragment_first`
6080        // pins on the prior `:repo` byte-class arm.
6081        let d = dep_with_fonte(DepSource::Git {
6082            repo: "https://github.com/pleme-io/caixa-teia#readme{org}".into(),
6083            tag: Some("v0.1.0".into()),
6084            rev: None,
6085            branch: None,
6086        });
6087        let err = d.validate().unwrap_err();
6088        let DepError::FonteRepoShape { reason, .. } = err else {
6089            panic!("expected FonteRepoShape, got other variant");
6090        };
6091        assert!(
6092            reason.contains("must not contain `#`"),
6093            "reason must surface the fragment-`#` arm (fires before template-`{{` when \
6094             `#` byte appears first in value), got {reason:?}"
6095        );
6096    }
6097
6098    #[test]
6099    fn validate_rejects_git_fonte_with_repo_carrying_output_redirection() {
6100        // The fail-before-pass-after pin for the canonical
6101        // shell-output-redirection footgun on `:repo`: an author
6102        // pastes a shell-pipeline tail (`git clone <repo> > build.log`
6103        // / `… >output.txt`) into the `:repo` slot without trimming
6104        // the redirect. Until this arm landed the value silently
6105        // passed every prior arm (no whitespace, no control chars,
6106        // no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, doesn't
6107        // start with `-` or `:`); RFC 3986 §2 lists `<` / `>` in the
6108        // 'delims' / 'unwise' set and the WHATWG URL spec's fragment
6109        // percent-encode set maps `>` → `%3E` on the wire, so the
6110        // byte rides verbatim into the lacre's per-dep BLAKE3 closure
6111        // but is silently rewritten or rejected at libcurl's URL-
6112        // parser layer — two authors whose values differ only in
6113        // their redirect tail (`>build.log` vs nothing) resolve to
6114        // the byte-identical upstream `git clone` but lock to two
6115        // distinct lacres, defeating the THEORY.md §V.2 render-
6116        // determinism contract. Peer with the `:caminho` axis's
6117        // `FonteCaminhoShellRedirection` arm (e457141) on the sibling
6118        // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
6119        // byte RFC-3986-reserved set on `:entrada :paths`.
6120        let d = dep_with_fonte(DepSource::Git {
6121            repo: "https://github.com/pleme-io/caixa-teia>build.log".into(),
6122            tag: Some("v0.1.0".into()),
6123            rev: None,
6124            branch: None,
6125        });
6126        let err = d.validate().unwrap_err();
6127        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6128            panic!("expected FonteRepoShape, got other variant");
6129        };
6130        assert_eq!(nome, "caixa-teia");
6131        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia>build.log");
6132        assert!(
6133            reason.contains("must not contain `>`"),
6134            "reason must surface the output-redirection `>` arm, got {reason:?}"
6135        );
6136        assert!(
6137            reason.contains("redirection") || reason.contains("'delims'"),
6138            "reason must name the shell-redirection / RFC-3986-unwise rationale, got {reason:?}"
6139        );
6140    }
6141
6142    #[test]
6143    fn validate_rejects_git_fonte_with_repo_carrying_input_redirection() {
6144        // The symmetric shell-input-redirection footgun — an author
6145        // pastes a shell-pipeline head (`git clone <input.url` /
6146        // `cat <README.md`) into the `:repo` slot. Pinned separately
6147        // from the `>`-output arm so a future relaxation that only
6148        // catches one of the two redirect bytes surfaces here. Peer
6149        // with the `:caminho` axis's `FonteCaminhoShellRedirection`
6150        // arm which closes both `<` and `>` under the same banner.
6151        let d = dep_with_fonte(DepSource::Git {
6152            repo: "https://github.com/pleme-io/caixa-teia<input.url".into(),
6153            tag: Some("v0.1.0".into()),
6154            rev: None,
6155            branch: None,
6156        });
6157        let err = d.validate().unwrap_err();
6158        let DepError::FonteRepoShape { reason, .. } = err else {
6159            panic!("expected FonteRepoShape, got other variant");
6160        };
6161        assert!(
6162            reason.contains("must not contain `<`"),
6163            "reason must surface the input-redirection `<` arm, got {reason:?}"
6164        );
6165        assert!(
6166            reason.contains("RFC 3986") || reason.contains("'unwise'"),
6167            "reason must name the RFC 3986 'unwise' grammar, got {reason:?}"
6168        );
6169    }
6170
6171    #[test]
6172    fn validate_rejects_git_fonte_with_repo_carrying_backtick_command_substitution() {
6173        // The fail-before-pass-after pin for the canonical
6174        // paste-from-shell-prompt-with-backticked-substitution footgun
6175        // on `:repo` (peer with the c4d62b3 backtick arm on the sibling
6176        // `:caminho` path-fonte axis). An author pastes a URL whose
6177        // segment carries a backticked command-substitution wrapper
6178        // (`` `whoami` ``, `` `git config user.name` ``, `` `pwd` ``)
6179        // from a doc / README quick-start snippet that expected the
6180        // substrate to substitute the value downstream. Until this arm
6181        // landed the value silently passed every prior arm (no
6182        // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
6183        // no `\`, no `{`/`}`, no `<`/`>`, doesn't start with `-` or
6184        // `:`); RFC 3986 §2 lists the backtick byte in the 'delims' /
6185        // 'unwise' set and the WHATWG URL spec's fragment percent-
6186        // encode set maps `` ` `` → `%60` on the wire, so the byte
6187        // rides verbatim into the lacre's per-dep BLAKE3 closure but
6188        // is silently rewritten or rejected at libcurl's URL-parser
6189        // layer — two authors whose values differ only in their
6190        // backtick wrapper (`` `whoami` `` vs nothing) resolve to the
6191        // byte-identical upstream `git clone` but lock to two distinct
6192        // lacres, defeating the THEORY.md §V.2 render-determinism
6193        // contract. Peer with the `:caminho` axis's
6194        // `FonteCaminhoShellCommandSubstitution` arm (c4d62b3) on the
6195        // sibling path-fonte axis, and `is_gateway_api_http_path`'s
6196        // eleven-byte RFC-3986-reserved set on `:entrada :paths`.
6197        let d = dep_with_fonte(DepSource::Git {
6198            repo: "https://github.com/pleme-io/`whoami`/caixa-teia".into(),
6199            tag: Some("v0.1.0".into()),
6200            rev: None,
6201            branch: None,
6202        });
6203        let err = d.validate().unwrap_err();
6204        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6205            panic!("expected FonteRepoShape, got other variant");
6206        };
6207        assert_eq!(nome, "caixa-teia");
6208        assert_eq!(repo, "https://github.com/pleme-io/`whoami`/caixa-teia");
6209        assert!(
6210            reason.contains("must not contain `` ` ``"),
6211            "reason must surface the backtick command-substitution arm, got {reason:?}"
6212        );
6213        assert!(
6214            reason.contains("command-substitution") || reason.contains("'unwise'"),
6215            "reason must name the shell-command-substitution / RFC-3986-unwise rationale, \
6216             got {reason:?}"
6217        );
6218    }
6219
6220    #[test]
6221    fn fonte_repo_fragment_fires_before_backtick_when_fragment_first() {
6222        // Cascade pin: the fragment-`#` arm and the backtick command-
6223        // substitution arm are both per-byte arms inside the same
6224        // `for &b in s.as_bytes()` loop, so the byte that appears first
6225        // in the value's byte order wins. A `:repo
6226        // "https://github.com/p/x#readme/`whoami`"` carries both `#`
6227        // and backtick; the `#` byte appears first, so the fragment-
6228        // `#` arm fires, surfacing the more self-locating diagnostic
6229        // on the byte the author pasted earliest in the URL. Mirrors
6230        // the peer cascade discipline
6231        // `fonte_repo_fragment_fires_before_shell_redirection_when_fragment_first`
6232        // pins on the prior `:repo` byte-class arm.
6233        let d = dep_with_fonte(DepSource::Git {
6234            repo: "https://github.com/pleme-io/caixa-teia#readme/`whoami`".into(),
6235            tag: Some("v0.1.0".into()),
6236            rev: None,
6237            branch: None,
6238        });
6239        let err = d.validate().unwrap_err();
6240        let DepError::FonteRepoShape { reason, .. } = err else {
6241            panic!("expected FonteRepoShape, got other variant");
6242        };
6243        assert!(
6244            reason.contains("must not contain `#`"),
6245            "reason must surface the fragment-`#` arm (fires before backtick when `#` byte \
6246             appears first in value), got {reason:?}"
6247        );
6248    }
6249
6250    #[test]
6251    fn fonte_repo_shell_redirection_fires_before_backtick_when_redirection_first() {
6252        // Cascade pin: the shell-redirection `<` / `>` arm and the
6253        // backtick command-substitution arm are both per-byte arms
6254        // inside the same `for &b in s.as_bytes()` loop, so the byte
6255        // that appears first in the value's byte order wins. A `:repo
6256        // "https://github.com/p/x>build.log/`whoami`"` carries both
6257        // `>` and backtick; the `>` byte appears first, so the
6258        // shell-redirection arm fires, surfacing the more self-
6259        // locating diagnostic on the byte the author pasted earliest
6260        // in the URL. Pins the natural-order cascade so a future
6261        // reorder of the per-byte arms surfaces here.
6262        let d = dep_with_fonte(DepSource::Git {
6263            repo: "https://github.com/pleme-io/caixa-teia>build.log/`whoami`".into(),
6264            tag: Some("v0.1.0".into()),
6265            rev: None,
6266            branch: None,
6267        });
6268        let err = d.validate().unwrap_err();
6269        let DepError::FonteRepoShape { reason, .. } = err else {
6270            panic!("expected FonteRepoShape, got other variant");
6271        };
6272        assert!(
6273            reason.contains("must not contain `>`"),
6274            "reason must surface the shell-redirection `>` arm (fires before backtick when \
6275             `>` byte appears first in value), got {reason:?}"
6276        );
6277    }
6278
6279    #[test]
6280    fn fonte_repo_fragment_fires_before_shell_redirection_when_fragment_first() {
6281        // Cascade pin: the fragment-`#` arm and the shell-redirection
6282        // `<` / `>` arm are both per-byte arms inside the same
6283        // `for &b in s.as_bytes()` loop, so the byte that appears
6284        // first in the value's byte order wins. A `:repo
6285        // "https://github.com/p/x#readme>build.log"` carries both
6286        // `#` and `>`; the `#` byte appears first, so the fragment-
6287        // `#` arm fires, surfacing the more self-locating diagnostic
6288        // on the byte the author pasted earliest in the URL. Mirrors
6289        // the peer cascade discipline
6290        // `fonte_repo_fragment_fires_before_template_placeholder_when_fragment_first`
6291        // pins on the prior `:repo` byte-class arm.
6292        let d = dep_with_fonte(DepSource::Git {
6293            repo: "https://github.com/pleme-io/caixa-teia#readme>build.log".into(),
6294            tag: Some("v0.1.0".into()),
6295            rev: None,
6296            branch: None,
6297        });
6298        let err = d.validate().unwrap_err();
6299        let DepError::FonteRepoShape { reason, .. } = err else {
6300            panic!("expected FonteRepoShape, got other variant");
6301        };
6302        assert!(
6303            reason.contains("must not contain `#`"),
6304            "reason must surface the fragment-`#` arm (fires before shell-redirection `>` when \
6305             `#` byte appears first in value), got {reason:?}"
6306        );
6307    }
6308
6309    #[test]
6310    fn validate_rejects_git_fonte_with_repo_carrying_shell_pipe() {
6311        // The fail-before-pass-after pin for the canonical
6312        // paste-from-shell-prompt-with-piped-pipeline footgun on
6313        // `:repo` (peer with the 124106f pipe arm on the sibling
6314        // `:caminho` path-fonte axis). An author pastes a shell
6315        // pipeline (`git clone <url> | tee build.log`,
6316        // `git ls-remote <url> | head`) into the `:repo` slot,
6317        // forgetting to trim the `| <consumer>` tail. Until this arm
6318        // landed the value silently passed every prior arm (no
6319        // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
6320        // no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, doesn't start
6321        // with `-` or `:`); RFC 3986 §2 lists the pipe byte in the
6322        // 'unwise' set and the WHATWG URL spec's fragment percent-
6323        // encode set maps `|` → `%7C` on the wire, so the byte rides
6324        // verbatim into the lacre's per-dep BLAKE3 closure but is
6325        // silently rewritten or rejected at libcurl's URL-parser
6326        // layer — two authors whose values differ only in their pipe
6327        // tail (`|tee build.log` vs nothing) resolve to the byte-
6328        // identical upstream `git clone` but lock to two distinct
6329        // lacres, defeating the THEORY.md §V.2 render-determinism
6330        // contract. Peer with the `:caminho` axis's
6331        // `FonteCaminhoShellPipe` arm (124106f) on the sibling path-
6332        // fonte axis, and `is_gateway_api_http_path`'s eleven-byte
6333        // RFC-3986-reserved set on `:entrada :paths`.
6334        let d = dep_with_fonte(DepSource::Git {
6335            repo: "https://github.com/pleme-io/caixa-teia|tee build.log".into(),
6336            tag: Some("v0.1.0".into()),
6337            rev: None,
6338            branch: None,
6339        });
6340        let err = d.validate().unwrap_err();
6341        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6342            panic!("expected FonteRepoShape, got other variant");
6343        };
6344        assert_eq!(nome, "caixa-teia");
6345        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia|tee build.log");
6346        assert!(
6347            reason.contains("must not contain `|`"),
6348            "reason must surface the shell-pipe arm, got {reason:?}"
6349        );
6350        assert!(
6351            reason.contains("pipe") || reason.contains("'unwise'"),
6352            "reason must name the shell-pipe / RFC-3986-unwise rationale, got {reason:?}"
6353        );
6354    }
6355
6356    #[test]
6357    fn fonte_repo_fragment_fires_before_pipe_when_fragment_first() {
6358        // Cascade pin: the fragment-`#` arm and the pipe arm are both
6359        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
6360        // so the byte that appears first in the value's byte order
6361        // wins. A `:repo "https://github.com/p/x#readme|tee"` carries
6362        // both `#` and `|`; the `#` byte appears first, so the
6363        // fragment-`#` arm fires, surfacing the more self-locating
6364        // diagnostic on the byte the author pasted earliest in the
6365        // URL. Mirrors the peer cascade discipline
6366        // `fonte_repo_fragment_fires_before_backtick_when_fragment_first`
6367        // pins on the prior `:repo` byte-class arm.
6368        let d = dep_with_fonte(DepSource::Git {
6369            repo: "https://github.com/pleme-io/caixa-teia#readme|tee".into(),
6370            tag: Some("v0.1.0".into()),
6371            rev: None,
6372            branch: None,
6373        });
6374        let err = d.validate().unwrap_err();
6375        let DepError::FonteRepoShape { reason, .. } = err else {
6376            panic!("expected FonteRepoShape, got other variant");
6377        };
6378        assert!(
6379            reason.contains("must not contain `#`"),
6380            "reason must surface the fragment-`#` arm (fires before pipe when `#` byte \
6381             appears first in value), got {reason:?}"
6382        );
6383    }
6384
6385    #[test]
6386    fn fonte_repo_backtick_fires_before_pipe_when_backtick_first() {
6387        // Cascade pin: the backtick arm and the pipe arm are both per-
6388        // byte arms inside the same `for &b in s.as_bytes()` loop, so
6389        // the byte that appears first in the value's byte order wins.
6390        // A `:repo "https://github.com/p/x/`whoami`|tee"` carries both
6391        // `` ` `` and `|`; the backtick byte appears first, so the
6392        // backtick arm fires, surfacing the more self-locating
6393        // diagnostic on the byte the author pasted earliest in the
6394        // URL. Pins the natural-order cascade so a future reorder of
6395        // the per-byte arms surfaces here.
6396        let d = dep_with_fonte(DepSource::Git {
6397            repo: "https://github.com/pleme-io/caixa-teia/`whoami`|tee".into(),
6398            tag: Some("v0.1.0".into()),
6399            rev: None,
6400            branch: None,
6401        });
6402        let err = d.validate().unwrap_err();
6403        let DepError::FonteRepoShape { reason, .. } = err else {
6404            panic!("expected FonteRepoShape, got other variant");
6405        };
6406        assert!(
6407            reason.contains("must not contain `` ` ``"),
6408            "reason must surface the backtick arm (fires before pipe when `` ` `` byte \
6409             appears first in value), got {reason:?}"
6410        );
6411    }
6412
6413    #[test]
6414    fn validate_rejects_git_fonte_with_repo_carrying_shell_command_separator() {
6415        // The fail-before-pass-after pin for the canonical
6416        // paste-from-shell-prompt-with-sequential-command-tail footgun
6417        // on `:repo` (peer with the 05c358e `;` arm on the sibling
6418        // `:caminho` path-fonte axis). An author pastes a shell
6419        // one-liner that chained a cleanup tail after the URL
6420        // (`git clone <url>; rm -rf build`, `git ls-remote <url>;
6421        // echo done`) into the `:repo` slot, forgetting to trim the
6422        // `; <cmd>` tail. Until this arm landed the value silently
6423        // passed every prior `is_git_repo_url` arm (no whitespace, no
6424        // control chars, no non-ASCII, no `#`, no `?`, no `\`, no
6425        // `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, doesn't start with
6426        // `-` or `:`); RFC 3986 §2 lists `;` in the 'sub-delims' /
6427        // reserved set and the WHATWG URL spec's fragment percent-
6428        // encode set maps `;` → `%3B` on the wire, so the byte rides
6429        // verbatim into the lacre's per-dep BLAKE3 closure but is
6430        // silently rewritten at libcurl's URL-parser layer — two
6431        // authors whose values differ only in their sequential-command
6432        // tail (`; rm -rf build` vs nothing) resolve to the byte-
6433        // identical upstream `git clone` but lock to two distinct
6434        // lacres, defeating the THEORY.md §V.2 render-determinism
6435        // contract. Peer with the `:caminho` axis's
6436        // `FonteCaminhoShellSemicolon` arm (05c358e) on the sibling
6437        // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
6438        // byte RFC-3986-reserved set on `:entrada :paths`.
6439        let d = dep_with_fonte(DepSource::Git {
6440            repo: "https://github.com/pleme-io/caixa-teia; rm -rf build".into(),
6441            tag: Some("v0.1.0".into()),
6442            rev: None,
6443            branch: None,
6444        });
6445        let err = d.validate().unwrap_err();
6446        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6447            panic!("expected FonteRepoShape, got other variant");
6448        };
6449        assert_eq!(nome, "caixa-teia");
6450        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia; rm -rf build");
6451        assert!(
6452            reason.contains("must not contain `;`"),
6453            "reason must surface the shell-command-separator arm, got {reason:?}"
6454        );
6455        assert!(
6456            reason.contains("sequential-command") || reason.contains("'sub-delims'"),
6457            "reason must name the shell-command-separator / RFC-3986-sub-delims \
6458             rationale, got {reason:?}"
6459        );
6460    }
6461
6462    #[test]
6463    fn fonte_repo_fragment_fires_before_semicolon_when_fragment_first() {
6464        // Cascade pin: the fragment-`#` arm and the semicolon arm are
6465        // both per-byte arms inside the same `for &b in s.as_bytes()`
6466        // loop, so the byte that appears first in the value's byte
6467        // order wins. A `:repo "https://github.com/p/x#readme; rm"`
6468        // carries both `#` and `;`; the `#` byte appears first, so the
6469        // fragment-`#` arm fires, surfacing the more self-locating
6470        // diagnostic on the byte the author pasted earliest in the URL.
6471        // Mirrors the peer cascade discipline
6472        // `fonte_repo_fragment_fires_before_pipe_when_fragment_first`
6473        // pins on the prior `:repo` byte-class arm.
6474        let d = dep_with_fonte(DepSource::Git {
6475            repo: "https://github.com/pleme-io/caixa-teia#readme; rm".into(),
6476            tag: Some("v0.1.0".into()),
6477            rev: None,
6478            branch: None,
6479        });
6480        let err = d.validate().unwrap_err();
6481        let DepError::FonteRepoShape { reason, .. } = err else {
6482            panic!("expected FonteRepoShape, got other variant");
6483        };
6484        assert!(
6485            reason.contains("must not contain `#`"),
6486            "reason must surface the fragment-`#` arm (fires before semicolon when `#` \
6487             byte appears first in value), got {reason:?}"
6488        );
6489    }
6490
6491    #[test]
6492    fn fonte_repo_pipe_fires_before_semicolon_when_pipe_first() {
6493        // Cascade pin: the pipe arm and the semicolon arm are both
6494        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
6495        // so the byte that appears first in the value's byte order
6496        // wins. A `:repo "https://github.com/p/x|tee; rm"` carries
6497        // both `|` and `;`; the `|` byte appears first, so the
6498        // pipe arm fires, surfacing the more self-locating diagnostic
6499        // on the byte the author pasted earliest in the URL. Pins the
6500        // natural-order cascade so a future reorder of the per-byte
6501        // arms surfaces here.
6502        let d = dep_with_fonte(DepSource::Git {
6503            repo: "https://github.com/pleme-io/caixa-teia|tee; rm".into(),
6504            tag: Some("v0.1.0".into()),
6505            rev: None,
6506            branch: None,
6507        });
6508        let err = d.validate().unwrap_err();
6509        let DepError::FonteRepoShape { reason, .. } = err else {
6510            panic!("expected FonteRepoShape, got other variant");
6511        };
6512        assert!(
6513            reason.contains("must not contain `|`"),
6514            "reason must surface the pipe arm (fires before semicolon when `|` byte \
6515             appears first in value), got {reason:?}"
6516        );
6517    }
6518
6519    #[test]
6520    fn validate_rejects_git_fonte_with_repo_carrying_shell_background() {
6521        // The fail-before-pass-after pin for the canonical
6522        // paste-from-shell-prompt-with-background-launch-tail footgun
6523        // on `:repo` (peer with the e12e4f3 `&` arm on the sibling
6524        // `:caminho` path-fonte axis). An author pastes a shell one-
6525        // liner that detached the clone into the background
6526        // (`git clone <url> & sleep 1`, `git clone <url> && cd …`)
6527        // into the `:repo` slot, forgetting to trim the `& <cmd>` /
6528        // `&& <cmd>` tail. Until this arm landed the value silently
6529        // passed every prior `is_git_repo_url` arm (no whitespace,
6530        // no control chars, no non-ASCII, no `#`, no `?`, no `\`,
6531        // no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no `;`,
6532        // doesn't start with `-` or `:`); RFC 3986 §2 lists `&` in
6533        // the 'sub-delims' / reserved set and the WHATWG URL spec's
6534        // fragment percent-encode set maps `&` → `%26` on the wire,
6535        // so the byte rides verbatim into the lacre's per-dep
6536        // BLAKE3 closure but is silently rewritten at libcurl's
6537        // URL-parser layer — two authors whose values differ only
6538        // in their background-launch tail (`& sleep 1` vs nothing)
6539        // resolve to the byte-identical upstream `git clone` but
6540        // lock to two distinct lacres, defeating the THEORY.md
6541        // §V.2 render-determinism contract. Peer with the
6542        // `:caminho` axis's `FonteCaminhoShellBackground` arm
6543        // (e12e4f3) on the sibling path-fonte axis, and
6544        // `is_gateway_api_http_path`'s eleven-byte RFC-3986-
6545        // reserved set on `:entrada :paths`.
6546        let d = dep_with_fonte(DepSource::Git {
6547            repo: "https://github.com/pleme-io/caixa-teia&sleep".into(),
6548            tag: Some("v0.1.0".into()),
6549            rev: None,
6550            branch: None,
6551        });
6552        let err = d.validate().unwrap_err();
6553        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6554            panic!("expected FonteRepoShape, got other variant");
6555        };
6556        assert_eq!(nome, "caixa-teia");
6557        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia&sleep");
6558        assert!(
6559            reason.contains("must not contain `&`"),
6560            "reason must surface the shell-background / logical-AND arm, got {reason:?}"
6561        );
6562        assert!(
6563            reason.contains("background-task") || reason.contains("'sub-delims'"),
6564            "reason must name the shell-background / RFC-3986-sub-delims rationale, \
6565             got {reason:?}"
6566        );
6567    }
6568
6569    #[test]
6570    fn validate_rejects_git_fonte_with_repo_carrying_logical_and() {
6571        // The fail-before-pass-after pin for the symmetric `&&`
6572        // logical-AND build-chain paste footgun: an author pastes
6573        // a `git clone <url> && cd <repo>` build-chain one-liner
6574        // and forgets to trim the `&& <cmd>` tail. The `&&` shape
6575        // is the same `&` byte twice in a row; the per-byte arm
6576        // fires on the first `&` it sees. Pinned separately from
6577        // the single-`&` background-launch shape so a future
6578        // diagnostic-surface change that special-cased the
6579        // doubled-byte form surfaces here.
6580        let d = dep_with_fonte(DepSource::Git {
6581            repo: "github:pleme-io/caixa-teia&&echo".into(),
6582            tag: Some("v0.1.0".into()),
6583            rev: None,
6584            branch: None,
6585        });
6586        let err = d.validate().unwrap_err();
6587        let DepError::FonteRepoShape { reason, .. } = err else {
6588            panic!("expected FonteRepoShape, got other variant");
6589        };
6590        assert!(
6591            reason.contains("must not contain `&`"),
6592            "reason must surface the shell-background / logical-AND arm on the doubled-`&&` \
6593             shape too, got {reason:?}"
6594        );
6595    }
6596
6597    #[test]
6598    fn fonte_repo_fragment_fires_before_background_when_fragment_first() {
6599        // Cascade pin: the fragment-`#` arm and the background-`&`
6600        // arm are both per-byte arms inside the same `for &b in
6601        // s.as_bytes()` loop, so the byte that appears first in the
6602        // value's byte order wins. A `:repo
6603        // "https://github.com/p/x#readme & sleep"` carries both `#`
6604        // and `&`; the `#` byte appears first, so the fragment-`#`
6605        // arm fires, surfacing the more self-locating diagnostic on
6606        // the byte the author pasted earliest in the URL. Mirrors
6607        // the peer cascade discipline
6608        // `fonte_repo_fragment_fires_before_semicolon_when_fragment_first`
6609        // on the prior `:repo` byte-class arm.
6610        let d = dep_with_fonte(DepSource::Git {
6611            repo: "https://github.com/pleme-io/caixa-teia#readme&sleep".into(),
6612            tag: Some("v0.1.0".into()),
6613            rev: None,
6614            branch: None,
6615        });
6616        let err = d.validate().unwrap_err();
6617        let DepError::FonteRepoShape { reason, .. } = err else {
6618            panic!("expected FonteRepoShape, got other variant");
6619        };
6620        assert!(
6621            reason.contains("must not contain `#`"),
6622            "reason must surface the fragment-`#` arm (fires before background-`&` when `#` \
6623             byte appears first in value), got {reason:?}"
6624        );
6625    }
6626
6627    #[test]
6628    fn fonte_repo_semicolon_fires_before_background_when_semicolon_first() {
6629        // Cascade pin: the semicolon arm and the background-`&` arm
6630        // are both per-byte arms inside the same `for &b in
6631        // s.as_bytes()` loop, so the byte that appears first in the
6632        // value's byte order wins. A `:repo
6633        // "https://github.com/p/x; rm & sleep"` carries both `;` and
6634        // `&`; the `;` byte appears first, so the semicolon arm
6635        // fires, surfacing the more self-locating diagnostic on the
6636        // byte the author pasted earliest in the URL. Pins the
6637        // natural-order cascade so a future reorder of the per-byte
6638        // arms surfaces here.
6639        let d = dep_with_fonte(DepSource::Git {
6640            repo: "https://github.com/pleme-io/caixa-teia;rm&sleep".into(),
6641            tag: Some("v0.1.0".into()),
6642            rev: None,
6643            branch: None,
6644        });
6645        let err = d.validate().unwrap_err();
6646        let DepError::FonteRepoShape { reason, .. } = err else {
6647            panic!("expected FonteRepoShape, got other variant");
6648        };
6649        assert!(
6650            reason.contains("must not contain `;`"),
6651            "reason must surface the semicolon arm (fires before background-`&` when `;` \
6652             byte appears first in value), got {reason:?}"
6653        );
6654    }
6655
6656    #[test]
6657    fn validate_rejects_git_fonte_with_repo_carrying_shell_variable_expansion() {
6658        // The fail-before-pass-after pin for the canonical
6659        // paste-from-shell-prompt-with-unsubstituted-variable footgun
6660        // on `:repo` (peer with the f4efe9c `$` arm on the sibling
6661        // `:caminho` path-fonte axis). An author pastes a shell one-
6662        // liner that referenced an environment variable
6663        // (`git clone https://github.com/$ORG/x`, `git clone
6664        // github:$USER/repo`) into the `:repo` slot, forgetting to
6665        // substitute the literal value at author time. Until this arm
6666        // landed the value silently passed every prior
6667        // `is_git_repo_url` arm (no whitespace, no control chars, no
6668        // non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no `<`/`>`,
6669        // no `` ` ``, no `|`, no `;`, no `&`, doesn't start with `-`
6670        // or `:`); RFC 3986 §2 lists `$` in the 'sub-delims' /
6671        // reserved set and the WHATWG URL spec's fragment percent-
6672        // encode set maps `$` → `%24` on the wire, so the byte rides
6673        // verbatim into the lacre's per-dep BLAKE3 closure but is
6674        // silently rewritten at libcurl's URL-parser layer — two
6675        // authors whose values differ only in their `$VAR` /
6676        // `${VAR}` / `$(cmd)` expansion tail resolve to the byte-
6677        // identical upstream `git clone` but lock to two distinct
6678        // lacres, defeating the THEORY.md §V.2 render-determinism
6679        // contract. Beyond determinism, the value is a structural
6680        // host-layout leak: two authors with the same `:repo` slot
6681        // but different `$ORG` / `$HOME` / `$WORKSPACE` resolve
6682        // different upstreams. Peer with the `:caminho` axis's
6683        // `FonteCaminhoVarExpansion` arm (f4efe9c) on the sibling
6684        // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
6685        // byte RFC-3986-reserved set on `:entrada :paths`.
6686        let d = dep_with_fonte(DepSource::Git {
6687            repo: "https://github.com/$ORG/caixa-teia".into(),
6688            tag: Some("v0.1.0".into()),
6689            rev: None,
6690            branch: None,
6691        });
6692        let err = d.validate().unwrap_err();
6693        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6694            panic!("expected FonteRepoShape, got other variant");
6695        };
6696        assert_eq!(nome, "caixa-teia");
6697        assert_eq!(repo, "https://github.com/$ORG/caixa-teia");
6698        assert!(
6699            reason.contains("must not contain `$`"),
6700            "reason must surface the shell-variable-expansion arm, got {reason:?}"
6701        );
6702        assert!(
6703            reason.contains("variable-expansion") || reason.contains("'sub-delims'"),
6704            "reason must name the shell-variable-expansion / RFC-3986-sub-delims \
6705             rationale, got {reason:?}"
6706        );
6707    }
6708
6709    #[test]
6710    fn validate_rejects_git_fonte_with_repo_carrying_braced_variable_expansion() {
6711        // The fail-before-pass-after pin for the symmetric POSIX-
6712        // shell braced `${VAR}` expansion paste footgun: an author
6713        // pastes a CI-manifest line `git clone
6714        // https://github.com/${WORKSPACE}/x` (the canonical GitHub
6715        // Actions / GitLab CI / Drone shape) and forgets to
6716        // substitute the literal value. The `${...}` shape is the
6717        // same `$` byte at the leading position of the expansion;
6718        // the per-byte arm fires on the `$`. Pinned separately from
6719        // the bare-`$VAR` shape so a future diagnostic-surface
6720        // change that special-cased the braced form surfaces here.
6721        let d = dep_with_fonte(DepSource::Git {
6722            repo: "https://github.com/${WORKSPACE}/caixa-teia".into(),
6723            tag: Some("v0.1.0".into()),
6724            rev: None,
6725            branch: None,
6726        });
6727        let err = d.validate().unwrap_err();
6728        let DepError::FonteRepoShape { reason, .. } = err else {
6729            panic!("expected FonteRepoShape, got other variant");
6730        };
6731        assert!(
6732            reason.contains("must not contain `$`"),
6733            "reason must surface the shell-variable-expansion arm on the braced `${{...}}` \
6734             shape too, got {reason:?}"
6735        );
6736    }
6737
6738    #[test]
6739    fn fonte_repo_fragment_fires_before_var_expansion_when_fragment_first() {
6740        // Cascade pin: the fragment-`#` arm and the var-expansion-`$`
6741        // arm are both per-byte arms inside the same `for &b in
6742        // s.as_bytes()` loop, so the byte that appears first in the
6743        // value's byte order wins. A `:repo
6744        // "https://github.com/p/x#readme$HOME"` carries both `#` and
6745        // `$`; the `#` byte appears first, so the fragment-`#` arm
6746        // fires, surfacing the more self-locating diagnostic on the
6747        // byte the author pasted earliest in the URL. Mirrors the
6748        // peer cascade discipline
6749        // `fonte_repo_fragment_fires_before_background_when_fragment_first`
6750        // on the prior `:repo` byte-class arm.
6751        let d = dep_with_fonte(DepSource::Git {
6752            repo: "https://github.com/pleme-io/caixa-teia#readme$HOME".into(),
6753            tag: Some("v0.1.0".into()),
6754            rev: None,
6755            branch: None,
6756        });
6757        let err = d.validate().unwrap_err();
6758        let DepError::FonteRepoShape { reason, .. } = err else {
6759            panic!("expected FonteRepoShape, got other variant");
6760        };
6761        assert!(
6762            reason.contains("must not contain `#`"),
6763            "reason must surface the fragment-`#` arm (fires before var-expansion-`$` when \
6764             `#` byte appears first in value), got {reason:?}"
6765        );
6766    }
6767
6768    #[test]
6769    fn fonte_repo_background_fires_before_var_expansion_when_background_first() {
6770        // Cascade pin: the background-`&` arm and the
6771        // var-expansion-`$` arm are both per-byte arms inside the
6772        // same `for &b in s.as_bytes()` loop, so the byte that
6773        // appears first in the value's byte order wins. A `:repo
6774        // "https://github.com/p/x&sleep$HOME"` carries both `&` and
6775        // `$`; the `&` byte appears first, so the background arm
6776        // fires, surfacing the more self-locating diagnostic on the
6777        // byte the author pasted earliest in the URL. Pins the
6778        // natural-order cascade so a future reorder of the per-byte
6779        // arms surfaces here — `$` is the most recent byte-class arm,
6780        // so the cascade-pin sweep extends to cover every immediately
6781        // prior byte arm (`#`, `&`) firing first when ordered ahead
6782        // of `$` in the value.
6783        let d = dep_with_fonte(DepSource::Git {
6784            repo: "https://github.com/pleme-io/caixa-teia&sleep$HOME".into(),
6785            tag: Some("v0.1.0".into()),
6786            rev: None,
6787            branch: None,
6788        });
6789        let err = d.validate().unwrap_err();
6790        let DepError::FonteRepoShape { reason, .. } = err else {
6791            panic!("expected FonteRepoShape, got other variant");
6792        };
6793        assert!(
6794            reason.contains("must not contain `&`"),
6795            "reason must surface the background-`&` arm (fires before var-expansion-`$` when \
6796             `&` byte appears first in value), got {reason:?}"
6797        );
6798    }
6799
6800    #[test]
6801    fn validate_rejects_git_fonte_with_repo_carrying_shell_glob_wildcard() {
6802        // The fail-before-pass-after pin for the canonical
6803        // paste-from-shell-prompt glob footgun on `:repo` (peer with
6804        // the cf9034b `*` / `?` arm on the sibling `:caminho`
6805        // path-fonte axis). An author pastes a shell one-liner that
6806        // referenced a glob expansion (`ls
6807        // github.com/pleme-io/caixa-*`, `git clone
6808        // github:pleme-io/caixa-*`) into the `:repo` slot, forgetting
6809        // to substitute the literal repo name. Until this arm landed
6810        // the `*` byte silently passed every prior `is_git_repo_url`
6811        // arm (no whitespace, no control chars, no non-ASCII, no `#`,
6812        // no `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`,
6813        // no `;`, no `&`, no `$`, doesn't start with `-` or `:`); RFC
6814        // 3986 §2 lists `*` in the 'sub-delims' / reserved set and
6815        // the WHATWG URL spec's special-query percent-encode set maps
6816        // `*` → `%2A` on the wire, so the byte rides verbatim into
6817        // the lacre's per-dep BLAKE3 closure but is silently
6818        // rewritten at libcurl's URL-parser layer — two authors
6819        // whose values differ only in their asterisk presence
6820        // resolve to the byte-identical upstream `git clone` but
6821        // lock to two distinct lacres, defeating the THEORY.md §V.2
6822        // render-determinism contract. Peer with the `:caminho`
6823        // axis's `FonteCaminhoShellGlob` arm (cf9034b) on the
6824        // sibling path-fonte axis, and the `is_git_ref_name`
6825        // refspec-wildcard cascade on the `:fonte :tag` / `:branch`
6826        // axes.
6827        let d = dep_with_fonte(DepSource::Git {
6828            repo: "https://github.com/pleme-io/caixa-*".into(),
6829            tag: Some("v0.1.0".into()),
6830            rev: None,
6831            branch: None,
6832        });
6833        let err = d.validate().unwrap_err();
6834        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6835            panic!("expected FonteRepoShape, got other variant");
6836        };
6837        assert_eq!(nome, "caixa-teia");
6838        assert_eq!(repo, "https://github.com/pleme-io/caixa-*");
6839        assert!(
6840            reason.contains("must not contain `*`"),
6841            "reason must surface the shell-glob arm, got {reason:?}"
6842        );
6843        assert!(
6844            reason.contains("pathname-expansion") || reason.contains("'sub-delims'"),
6845            "reason must name the shell-glob / pathname-expansion / \
6846             RFC-3986-sub-delims rationale, got {reason:?}"
6847        );
6848    }
6849
6850    #[test]
6851    fn validate_rejects_git_fonte_with_repo_carrying_recursive_shell_glob() {
6852        // The fail-before-pass-after pin for the symmetric bash
6853        // `globstar` recursive-glob paste footgun: an author pastes
6854        // a `ls github.com/pleme-io/**/x` (the canonical
6855        // `globstar`-shopt-enabled recursive-listing tail) into the
6856        // `:repo` slot. The `**` shape is two `*` bytes adjacent;
6857        // the per-byte arm fires on the first `*`. Pinned
6858        // separately from the single-`*` shape so a future
6859        // diagnostic-surface change that special-cased the
6860        // double-`*` form surfaces here.
6861        let d = dep_with_fonte(DepSource::Git {
6862            repo: "https://github.com/pleme-io/**/caixa-teia".into(),
6863            tag: Some("v0.1.0".into()),
6864            rev: None,
6865            branch: None,
6866        });
6867        let err = d.validate().unwrap_err();
6868        let DepError::FonteRepoShape { reason, .. } = err else {
6869            panic!("expected FonteRepoShape, got other variant");
6870        };
6871        assert!(
6872            reason.contains("must not contain `*`"),
6873            "reason must surface the shell-glob arm on the `**` recursive-glob shape too, \
6874             got {reason:?}"
6875        );
6876    }
6877
6878    #[test]
6879    fn fonte_repo_fragment_fires_before_glob_when_fragment_first() {
6880        // Cascade pin: the fragment-`#` arm and the glob-`*` arm are
6881        // both per-byte arms inside the same `for &b in s.as_bytes()`
6882        // loop, so the byte that appears first in the value's byte
6883        // order wins. A `:repo
6884        // "https://github.com/p/x#readme*tail"` carries both `#` and
6885        // `*`; the `#` byte appears first, so the fragment-`#` arm
6886        // fires, surfacing the more self-locating diagnostic on the
6887        // byte the author pasted earliest in the URL. Mirrors the
6888        // peer cascade discipline
6889        // `fonte_repo_fragment_fires_before_var_expansion_when_fragment_first`
6890        // on the prior `:repo` byte-class arm.
6891        let d = dep_with_fonte(DepSource::Git {
6892            repo: "https://github.com/pleme-io/caixa-teia#readme*tail".into(),
6893            tag: Some("v0.1.0".into()),
6894            rev: None,
6895            branch: None,
6896        });
6897        let err = d.validate().unwrap_err();
6898        let DepError::FonteRepoShape { reason, .. } = err else {
6899            panic!("expected FonteRepoShape, got other variant");
6900        };
6901        assert!(
6902            reason.contains("must not contain `#`"),
6903            "reason must surface the fragment-`#` arm (fires before glob-`*` when `#` byte \
6904             appears first in value), got {reason:?}"
6905        );
6906    }
6907
6908    #[test]
6909    fn fonte_repo_var_expansion_fires_before_glob_when_var_expansion_first() {
6910        // Cascade pin: the var-expansion-`$` arm and the glob-`*`
6911        // arm are both per-byte arms inside the same `for &b in
6912        // s.as_bytes()` loop, so the byte that appears first in the
6913        // value's byte order wins. A `:repo
6914        // "https://github.com/p/$ORG-*"` carries both `$` and `*`;
6915        // the `$` byte appears first, so the var-expansion arm
6916        // fires, surfacing the more self-locating diagnostic on the
6917        // byte the author pasted earliest in the URL. Pins the
6918        // natural-order cascade so a future reorder of the per-byte
6919        // arms surfaces here — `*` is the most recent byte-class
6920        // arm, so the cascade-pin sweep extends to cover the
6921        // immediately prior `$` byte arm firing first when ordered
6922        // ahead of `*` in the value.
6923        let d = dep_with_fonte(DepSource::Git {
6924            repo: "https://github.com/pleme-io/$ORG-caixa-*".into(),
6925            tag: Some("v0.1.0".into()),
6926            rev: None,
6927            branch: None,
6928        });
6929        let err = d.validate().unwrap_err();
6930        let DepError::FonteRepoShape { reason, .. } = err else {
6931            panic!("expected FonteRepoShape, got other variant");
6932        };
6933        assert!(
6934            reason.contains("must not contain `$`"),
6935            "reason must surface the var-expansion-`$` arm (fires before glob-`*` when `$` \
6936             byte appears first in value), got {reason:?}"
6937        );
6938    }
6939
6940    #[test]
6941    fn validate_rejects_git_fonte_with_repo_carrying_subshell_open_paren() {
6942        // The fail-before-pass-after pin for the canonical paste-from-
6943        // shell-prompt subshell-grouping footgun on `:repo`. An author
6944        // pastes a doc / README snippet carrying a regex-alternation
6945        // grouping shape (`https://github.com/(foo|bar)/repo`) or a
6946        // dynamic-config-substitution wrapper (`$(<cmd>)`) into the
6947        // `:repo` slot, forgetting to substitute one literal org name.
6948        // Until this arm landed the `(` byte silently passed every
6949        // prior `is_git_repo_url` arm (no whitespace, no control
6950        // chars, no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no
6951        // `<`/`>`, no `` ` ``, no `|`, no `;`, no `&`, no `$`, no
6952        // `*`, doesn't start with `-` or `:`); RFC 3986 §2 lists `(`
6953        // / `)` in the 'sub-delims' / reserved set, and the WHATWG
6954        // URL spec's special-query percent-encode set maps `(` →
6955        // `%28` and `)` → `%29` on the wire, so the byte rides
6956        // verbatim into the lacre's per-dep BLAKE3 closure but is
6957        // silently rewritten at libcurl's URL-parser layer —
6958        // defeating the THEORY.md §V.2 render-determinism contract on
6959        // the same axis the prior twelve byte-class arms close.
6960        let d = dep_with_fonte(DepSource::Git {
6961            repo: "https://github.com/(foo|bar)/caixa-teia".into(),
6962            tag: Some("v0.1.0".into()),
6963            rev: None,
6964            branch: None,
6965        });
6966        let err = d.validate().unwrap_err();
6967        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6968            panic!("expected FonteRepoShape, got other variant");
6969        };
6970        assert_eq!(nome, "caixa-teia");
6971        assert_eq!(repo, "https://github.com/(foo|bar)/caixa-teia");
6972        assert!(
6973            reason.contains("must not contain `(`"),
6974            "reason must surface the subshell-open-paren arm, got {reason:?}"
6975        );
6976        assert!(
6977            reason.contains("subshell-grouping") || reason.contains("'sub-delims'"),
6978            "reason must name the shell-subshell-grouping / RFC-3986-sub-delims rationale, \
6979             got {reason:?}"
6980        );
6981    }
6982
6983    #[test]
6984    fn validate_rejects_git_fonte_with_repo_carrying_subshell_close_paren() {
6985        // The symmetric arm pin on the closing `)` byte: an author
6986        // pastes a `$(date)` command-substitution wrapper or a
6987        // regex-alternation `(foo|bar)` tail into the `:repo` slot.
6988        // Pinned separately from the opening `(` shape so a future
6989        // diagnostic-surface change that only checked one boundary
6990        // surfaces here. The `(` byte appears earlier in the
6991        // canonical regex / subshell wrapper so the per-byte loop
6992        // fires on `(` first; this test exercises a `:repo` value
6993        // carrying only the closing `)` byte (no opening paren) so
6994        // the `)` arm fires directly — pinning the byte-class arm
6995        // independent of order.
6996        let d = dep_with_fonte(DepSource::Git {
6997            repo: "github:pleme-io/caixa-teia)tail".into(),
6998            tag: Some("v0.1.0".into()),
6999            rev: None,
7000            branch: None,
7001        });
7002        let err = d.validate().unwrap_err();
7003        let DepError::FonteRepoShape { reason, .. } = err else {
7004            panic!("expected FonteRepoShape, got other variant");
7005        };
7006        assert!(
7007            reason.contains("must not contain `)`"),
7008            "reason must surface the subshell-close-paren arm on the bare `)` shape, \
7009             got {reason:?}"
7010        );
7011    }
7012
7013    #[test]
7014    fn fonte_repo_fragment_fires_before_subshell_when_fragment_first() {
7015        // Cascade pin: the fragment-`#` arm and the subshell-`(` arm
7016        // are both per-byte arms inside the same `for &b in
7017        // s.as_bytes()` loop, so the byte that appears first in the
7018        // value's byte order wins. A `:repo
7019        // "https://github.com/p/x#readme(tail)"` carries both `#` and
7020        // `(`; the `#` byte appears first, so the fragment-`#` arm
7021        // fires, surfacing the more self-locating diagnostic on the
7022        // byte the author pasted earliest in the URL. Mirrors the
7023        // peer cascade discipline
7024        // `fonte_repo_fragment_fires_before_glob_when_fragment_first`
7025        // on the prior `:repo` byte-class arm.
7026        let d = dep_with_fonte(DepSource::Git {
7027            repo: "https://github.com/pleme-io/caixa-teia#readme(tail)".into(),
7028            tag: Some("v0.1.0".into()),
7029            rev: None,
7030            branch: None,
7031        });
7032        let err = d.validate().unwrap_err();
7033        let DepError::FonteRepoShape { reason, .. } = err else {
7034            panic!("expected FonteRepoShape, got other variant");
7035        };
7036        assert!(
7037            reason.contains("must not contain `#`"),
7038            "reason must surface the fragment-`#` arm (fires before subshell-`(` when `#` \
7039             byte appears first in value), got {reason:?}"
7040        );
7041    }
7042
7043    #[test]
7044    fn fonte_repo_glob_fires_before_subshell_when_glob_first() {
7045        // Cascade pin: the glob-`*` arm (the immediate-predecessor
7046        // byte-class arm, 3902a9a) and the subshell-`(` arm are both
7047        // per-byte arms inside the same `for &b in s.as_bytes()`
7048        // loop, so the byte that appears first in the value's byte
7049        // order wins. A `:repo
7050        // "https://github.com/p/x-*-(date)"` carries both `*` and
7051        // `(`; the `*` byte appears first, so the glob arm fires,
7052        // surfacing the more self-locating diagnostic on the byte
7053        // the author pasted earliest in the URL. Pins the natural-
7054        // order cascade so a future reorder of the per-byte arms
7055        // surfaces here — `(` is the most recent byte-class arm,
7056        // so the cascade-pin sweep extends to cover the immediately
7057        // prior `*` byte arm firing first when ordered ahead of `(`
7058        // in the value.
7059        let d = dep_with_fonte(DepSource::Git {
7060            repo: "https://github.com/pleme-io/caixa-teia-*-(date)".into(),
7061            tag: Some("v0.1.0".into()),
7062            rev: None,
7063            branch: None,
7064        });
7065        let err = d.validate().unwrap_err();
7066        let DepError::FonteRepoShape { reason, .. } = err else {
7067            panic!("expected FonteRepoShape, got other variant");
7068        };
7069        assert!(
7070            reason.contains("must not contain `*`"),
7071            "reason must surface the glob-`*` arm (fires before subshell-`(` when `*` byte \
7072             appears first in value), got {reason:?}"
7073        );
7074    }
7075
7076    #[test]
7077    fn validate_rejects_git_fonte_with_repo_carrying_shell_double_quote() {
7078        // The fail-before-pass-after pin for the canonical paste-from-
7079        // doc-shell-quoting footgun on `:repo`. An author copies a
7080        // README quick-start snippet (`$ git clone "https://github.com/
7081        // foo/bar"`) and keeps the surrounding double-quote bytes when
7082        // pasting into the `:repo` slot — the doc wraps the URL in
7083        // double quotes so the shell doesn't re-lex metachars inside,
7084        // but the typed slot is itself a byte-level string parser, not
7085        // a shell context, so the quote bytes ride into the value
7086        // verbatim. Until this arm landed the `"` byte silently passed
7087        // every prior `is_git_repo_url` arm (no whitespace, no control
7088        // chars, no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no
7089        // `<`/`>`, no `` ` ``, no `|`, no `;`, no `&`, no `$`, no `*`,
7090        // no `(`/`)`, doesn't start with `-` or `:`); RFC 3986 §2 lists
7091        // `"` in the strict four-byte 'delims' subset (with `<`, `>`,
7092        // `` ` ``) every URL parser is required to refuse or percent-
7093        // encode, and the WHATWG URL spec's 'C0 control percent-encode
7094        // set' maps `"` → `%22` on the wire, so the byte rides verbatim
7095        // into the lacre's per-dep BLAKE3 closure but is silently
7096        // rewritten at libcurl's URL-parser layer, defeating the
7097        // THEORY.md §V.2 render-determinism contract.
7098        let d = dep_with_fonte(DepSource::Git {
7099            repo: "\"https://github.com/pleme-io/caixa-teia\"".into(),
7100            tag: Some("v0.1.0".into()),
7101            rev: None,
7102            branch: None,
7103        });
7104        let err = d.validate().unwrap_err();
7105        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7106            panic!("expected FonteRepoShape, got other variant");
7107        };
7108        assert_eq!(nome, "caixa-teia");
7109        assert_eq!(repo, "\"https://github.com/pleme-io/caixa-teia\"");
7110        assert!(
7111            reason.contains("must not contain `\"`"),
7112            "reason must surface the shell-double-quote arm, got {reason:?}"
7113        );
7114        assert!(
7115            reason.contains("double-quote") || reason.contains("'delims'"),
7116            "reason must name the shell-double-quote / RFC-3986-delims rationale, \
7117             got {reason:?}"
7118        );
7119    }
7120
7121    #[test]
7122    fn validate_rejects_git_fonte_with_repo_carrying_stray_trailing_double_quote() {
7123        // The symmetric stray-quote tail pin: an author pastes only a
7124        // closing `"` from a shell-history line like `git clone
7125        // "https://github.com/foo/bar" && cd …` (the trim went too
7126        // far in one direction but not the other) into the `:repo`
7127        // slot. Pinned separately from the wrapped-quote shape so a
7128        // future diagnostic-surface change that only checked one
7129        // boundary (only leading, only trailing, only paired) surfaces
7130        // here — the per-byte arm fires anywhere `"` appears.
7131        let d = dep_with_fonte(DepSource::Git {
7132            repo: "github:pleme-io/caixa-teia\"".into(),
7133            tag: Some("v0.1.0".into()),
7134            rev: None,
7135            branch: None,
7136        });
7137        let err = d.validate().unwrap_err();
7138        let DepError::FonteRepoShape { reason, .. } = err else {
7139            panic!("expected FonteRepoShape, got other variant");
7140        };
7141        assert!(
7142            reason.contains("must not contain `\"`"),
7143            "reason must surface the shell-double-quote arm on the trailing-`\"` shape, \
7144             got {reason:?}"
7145        );
7146    }
7147
7148    #[test]
7149    fn fonte_repo_fragment_fires_before_double_quote_when_fragment_first() {
7150        // Cascade pin: the fragment-`#` arm and the double-quote arm
7151        // are both per-byte arms inside the same `for &b in
7152        // s.as_bytes()` loop, so the byte that appears first in the
7153        // value's byte order wins. A `:repo
7154        // "https://github.com/p/x#readme\"tail"` carries both `#` and
7155        // `"`; the `#` byte appears first, so the fragment-`#` arm
7156        // fires, surfacing the more self-locating diagnostic on the
7157        // byte the author pasted earliest in the URL.
7158        let d = dep_with_fonte(DepSource::Git {
7159            repo: "https://github.com/pleme-io/caixa-teia#readme\"tail".into(),
7160            tag: Some("v0.1.0".into()),
7161            rev: None,
7162            branch: None,
7163        });
7164        let err = d.validate().unwrap_err();
7165        let DepError::FonteRepoShape { reason, .. } = err else {
7166            panic!("expected FonteRepoShape, got other variant");
7167        };
7168        assert!(
7169            reason.contains("must not contain `#`"),
7170            "reason must surface the fragment-`#` arm (fires before double-quote when `#` \
7171             byte appears first in value), got {reason:?}"
7172        );
7173    }
7174
7175    #[test]
7176    fn fonte_repo_subshell_fires_before_double_quote_when_subshell_first() {
7177        // Cascade pin: the subshell-`(` arm (the immediate-predecessor
7178        // byte-class arm, 3b99147) and the double-quote arm are both
7179        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
7180        // so the byte that appears first in the value's byte order
7181        // wins. A `:repo "github:p/x(date)\"tail"` carries both `(`
7182        // and `"`; the `(` byte appears first, so the subshell arm
7183        // fires, surfacing the more self-locating diagnostic on the
7184        // byte the author pasted earliest in the URL. Pins the natural-
7185        // order cascade so a future reorder of the per-byte arms
7186        // surfaces here — `"` is the most recent byte-class arm, so
7187        // the cascade-pin sweep extends to cover the immediately prior
7188        // `(` byte arm firing first when ordered ahead of `"` in the
7189        // value.
7190        let d = dep_with_fonte(DepSource::Git {
7191            repo: "github:pleme-io/caixa-teia(date)\"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 subshell-`(` arm (fires before double-quote when `(` \
7203             byte appears first in value), got {reason:?}"
7204        );
7205    }
7206
7207    #[test]
7208    fn validate_rejects_git_fonte_with_repo_carrying_shell_single_quote() {
7209        // The fail-before-pass-after pin for the canonical paste-from-
7210        // doc-strong-quoting footgun on `:repo`. An author copies a
7211        // security-conscious README quick-start snippet (`$ git clone
7212        // 'https://github.com/foo/bar'`) and keeps the surrounding
7213        // single-quote bytes when pasting into the `:repo` slot — the
7214        // doc strong-quotes the URL so the shell suppresses every form
7215        // of expansion on the bytes inside (no `$`, no backtick, no
7216        // glob, no word-splitting), but the typed slot is itself a
7217        // byte-level string parser, not a shell context, so the quote
7218        // bytes ride into the value verbatim. Until this arm landed the
7219        // `'` byte silently passed every prior `is_git_repo_url` arm
7220        // (no whitespace, no control chars, no non-ASCII, no `#`, no
7221        // `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no
7222        // `;`, no `&`, no `$`, no `*`, no `(`/`)`, no `"`, doesn't start
7223        // with `-` or `:`); RFC 3986 §2.2 lists `'` in the 'sub-delims'
7224        // set, peer with the `\"` 'delims' double-quote arm and the
7225        // partner ASCII shell-string-delimiter byte every byte-level
7226        // string parser sharing a value-shape with a shell argument
7227        // must refuse on a URL-shaped slot.
7228        let d = dep_with_fonte(DepSource::Git {
7229            repo: "'https://github.com/pleme-io/caixa-teia'".into(),
7230            tag: Some("v0.1.0".into()),
7231            rev: None,
7232            branch: None,
7233        });
7234        let err = d.validate().unwrap_err();
7235        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7236            panic!("expected FonteRepoShape, got other variant");
7237        };
7238        assert_eq!(nome, "caixa-teia");
7239        assert_eq!(repo, "'https://github.com/pleme-io/caixa-teia'");
7240        assert!(
7241            reason.contains("must not contain `'`"),
7242            "reason must surface the shell-single-quote arm, got {reason:?}"
7243        );
7244        assert!(
7245            reason.contains("single-quote") || reason.contains("strong-quote"),
7246            "reason must name the shell-single-quote / strong-quote rationale, \
7247             got {reason:?}"
7248        );
7249    }
7250
7251    #[test]
7252    fn validate_rejects_git_fonte_with_repo_carrying_english_apostrophe() {
7253        // The symmetric English-typography pin: an author writes
7254        // `:repo "github:p/repo's-fork"` (the possessive-form paste-
7255        // from-prose idiom every README / commit-message / chat-thread
7256        // reference to a repo carries) expecting the substrate to
7257        // coerce it to a kebab-case slug — but the byte rides into the
7258        // lacre verbatim. Pinned separately from the wrapped-quote
7259        // shape so a future diagnostic-surface change that only checked
7260        // the boundary positions (only leading, only trailing, only
7261        // paired) surfaces here — the per-byte arm fires anywhere `'`
7262        // appears in the value.
7263        let d = dep_with_fonte(DepSource::Git {
7264            repo: "github:pleme-io/repo's-fork".into(),
7265            tag: Some("v0.1.0".into()),
7266            rev: None,
7267            branch: None,
7268        });
7269        let err = d.validate().unwrap_err();
7270        let DepError::FonteRepoShape { reason, .. } = err else {
7271            panic!("expected FonteRepoShape, got other variant");
7272        };
7273        assert!(
7274            reason.contains("must not contain `'`"),
7275            "reason must surface the shell-single-quote arm on the mid-string \
7276             apostrophe shape, got {reason:?}"
7277        );
7278    }
7279
7280    #[test]
7281    fn fonte_repo_fragment_fires_before_single_quote_when_fragment_first() {
7282        // Cascade pin: the fragment-`#` arm and the single-quote arm
7283        // are both per-byte arms inside the same `for &b in
7284        // s.as_bytes()` loop, so the byte that appears first in the
7285        // value's byte order wins. A `:repo
7286        // "https://github.com/p/x#readme'tail"` carries both `#` and
7287        // `'`; the `#` byte appears first, so the fragment-`#` arm
7288        // fires, surfacing the more self-locating diagnostic on the
7289        // byte the author pasted earliest in the URL.
7290        let d = dep_with_fonte(DepSource::Git {
7291            repo: "https://github.com/pleme-io/caixa-teia#readme'tail".into(),
7292            tag: Some("v0.1.0".into()),
7293            rev: None,
7294            branch: None,
7295        });
7296        let err = d.validate().unwrap_err();
7297        let DepError::FonteRepoShape { reason, .. } = err else {
7298            panic!("expected FonteRepoShape, got other variant");
7299        };
7300        assert!(
7301            reason.contains("must not contain `#`"),
7302            "reason must surface the fragment-`#` arm (fires before single-quote when `#` \
7303             byte appears first in value), got {reason:?}"
7304        );
7305    }
7306
7307    #[test]
7308    fn fonte_repo_double_quote_fires_before_single_quote_when_double_quote_first() {
7309        // Cascade pin: the double-quote-`"` arm (the immediate-predecessor
7310        // byte-class arm, 4267d8b) and the single-quote arm are both
7311        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
7312        // so the byte that appears first in the value's byte order
7313        // wins. A `:repo "github:p/x\"mid'tail"` carries both `"` and
7314        // `'`; the `"` byte appears first, so the double-quote arm
7315        // fires, surfacing the more self-locating diagnostic on the
7316        // byte the author pasted earliest in the URL. Pins the natural-
7317        // order cascade so a future reorder of the per-byte arms
7318        // surfaces here — `'` is the most recent byte-class arm, so
7319        // the cascade-pin sweep extends to cover the immediately prior
7320        // `"` byte arm firing first when ordered ahead of `'` in the
7321        // value.
7322        let d = dep_with_fonte(DepSource::Git {
7323            repo: "github:pleme-io/caixa-teia\"mid'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 double-quote arm (fires before single-quote when `\"` \
7335             byte appears first in value), got {reason:?}"
7336        );
7337    }
7338
7339    #[test]
7340    fn validate_rejects_git_fonte_with_repo_carrying_shell_history_expansion() {
7341        // The fail-before-pass-after pin for the canonical paste-from-
7342        // shell-history footgun on `:repo`. An author copies a `git
7343        // clone <url>!sudo make install` one-liner from a README's
7344        // quick-start snippet, intending the trailing `!sudo` as a
7345        // shell-history-expansion reference but the typed slot is itself
7346        // a byte-level string parser, not a shell context, so the byte
7347        // rides into the value verbatim. Until this arm landed the `!`
7348        // byte silently passed every prior `is_git_repo_url` arm (no
7349        // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
7350        // no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no `;`,
7351        // no `&`, no `$`, no `*`, no `(`/`)`, no `"`, no `'`, doesn't
7352        // start with `-` or `:`); bash with the default `histexpand`
7353        // mode rewrites `!command` to the most recent history entry
7354        // beginning with `command`, the canonical RCE-class injection
7355        // vector when the byte rides into a shell argument.
7356        let d = dep_with_fonte(DepSource::Git {
7357            repo: "https://github.com/pleme-io/caixa-teia!sudo".into(),
7358            tag: Some("v0.1.0".into()),
7359            rev: None,
7360            branch: None,
7361        });
7362        let err = d.validate().unwrap_err();
7363        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7364            panic!("expected FonteRepoShape, got other variant");
7365        };
7366        assert_eq!(nome, "caixa-teia");
7367        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia!sudo");
7368        assert!(
7369            reason.contains("must not contain `!`"),
7370            "reason must surface the shell-history-expansion arm, got {reason:?}"
7371        );
7372        assert!(
7373            reason.contains("history-expansion") || reason.contains("bang"),
7374            "reason must name the shell-history-expansion / bang rationale, got {reason:?}"
7375        );
7376    }
7377
7378    #[test]
7379    fn validate_rejects_git_fonte_with_repo_carrying_double_bang_history_reference() {
7380        // The symmetric `!!` repeat-prior-command pin: an author paste-
7381        // trims a `git clone <url>` retry idiom from shell history that
7382        // expands to the previous command via `!!`. Pinned separately
7383        // from the wrapped `!command` shape so a future diagnostic-
7384        // surface change that only checked the leading or paired-bang
7385        // position surfaces here — the per-byte arm fires anywhere `!`
7386        // appears in the value.
7387        let d = dep_with_fonte(DepSource::Git {
7388            repo: "github:pleme-io/caixa-teia!!".into(),
7389            tag: Some("v0.1.0".into()),
7390            rev: None,
7391            branch: None,
7392        });
7393        let err = d.validate().unwrap_err();
7394        let DepError::FonteRepoShape { reason, .. } = err else {
7395            panic!("expected FonteRepoShape, got other variant");
7396        };
7397        assert!(
7398            reason.contains("must not contain `!`"),
7399            "reason must surface the shell-history-expansion arm on the trailing-`!!` shape, \
7400             got {reason:?}"
7401        );
7402    }
7403
7404    #[test]
7405    fn fonte_repo_fragment_fires_before_bang_when_fragment_first() {
7406        // Cascade pin: the fragment-`#` arm and the bang arm are both
7407        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
7408        // so the byte that appears first in the value's byte order
7409        // wins. A `:repo "https://github.com/p/x#readme!tail"` carries
7410        // both `#` and `!`; the `#` byte appears first, so the
7411        // fragment-`#` arm fires, surfacing the more self-locating
7412        // diagnostic on the byte the author pasted earliest in the URL.
7413        let d = dep_with_fonte(DepSource::Git {
7414            repo: "https://github.com/pleme-io/caixa-teia#readme!tail".into(),
7415            tag: Some("v0.1.0".into()),
7416            rev: None,
7417            branch: None,
7418        });
7419        let err = d.validate().unwrap_err();
7420        let DepError::FonteRepoShape { reason, .. } = err else {
7421            panic!("expected FonteRepoShape, got other variant");
7422        };
7423        assert!(
7424            reason.contains("must not contain `#`"),
7425            "reason must surface the fragment-`#` arm (fires before bang when `#` byte \
7426             appears first in value), got {reason:?}"
7427        );
7428    }
7429
7430    #[test]
7431    fn fonte_repo_single_quote_fires_before_bang_when_single_quote_first() {
7432        // Cascade pin: the single-quote-`'` arm (the immediate-predecessor
7433        // byte-class arm, e7a109f) and the bang arm are both per-byte
7434        // arms inside the same `for &b in s.as_bytes()` loop, so the
7435        // byte that appears first in the value's byte order wins. A
7436        // `:repo "github:p/x'mid!tail"` carries both `'` and `!`; the
7437        // `'` byte appears first, so the single-quote arm fires,
7438        // surfacing the more self-locating diagnostic on the byte the
7439        // author pasted earliest in the URL. Pins the natural-order
7440        // cascade so a future reorder of the per-byte arms surfaces
7441        // here — `!` is the most recent byte-class arm, so the
7442        // cascade-pin sweep extends to cover the immediately prior `'`
7443        // byte arm firing first when ordered ahead of `!` in the value.
7444        let d = dep_with_fonte(DepSource::Git {
7445            repo: "github:pleme-io/caixa-teia'mid!tail".into(),
7446            tag: Some("v0.1.0".into()),
7447            rev: None,
7448            branch: None,
7449        });
7450        let err = d.validate().unwrap_err();
7451        let DepError::FonteRepoShape { reason, .. } = err else {
7452            panic!("expected FonteRepoShape, got other variant");
7453        };
7454        assert!(
7455            reason.contains("must not contain `'`"),
7456            "reason must surface the single-quote arm (fires before bang when `'` byte \
7457             appears first in value), got {reason:?}"
7458        );
7459    }
7460
7461    #[test]
7462    fn validate_rejects_git_fonte_with_repo_carrying_list_separator_comma() {
7463        // The fail-before-pass-after pin for the canonical
7464        // list-separator-belongs-to-list-grammar footgun on `:repo`.
7465        // An author copies a `git clone <a>, <b>, <c>` paste-from-CSV
7466        // one-liner from a multi-repo bootstrap doc, intending the
7467        // comma to separate multiple repo entries but the typed
7468        // `:repo` slot names *one* repo (the list-separator belongs
7469        // to the `:deps` list grammar, not to the value). Until this
7470        // arm landed the `,` byte silently passed every prior
7471        // `is_git_repo_url` arm (no whitespace, no control chars, no
7472        // non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no `<`/`>`,
7473        // no `` ` ``, no `|`, no `;`, no `&`, no `$`, no `*`, no
7474        // `(`/`)`, no `"`, no `'`, no `!`, doesn't start with `-` or
7475        // `:`); the byte rode into the lacre's per-dep content-
7476        // address and the resolver's `git clone <repo>` subprocess
7477        // invocation, where no host's repo registry resolved the
7478        // comma-bearing slug.
7479        let d = dep_with_fonte(DepSource::Git {
7480            repo: "github:pleme-io/caixa-teia,github:pleme-io/caixa-feira".into(),
7481            tag: Some("v0.1.0".into()),
7482            rev: None,
7483            branch: None,
7484        });
7485        let err = d.validate().unwrap_err();
7486        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7487            panic!("expected FonteRepoShape, got other variant");
7488        };
7489        assert_eq!(nome, "caixa-teia");
7490        assert_eq!(
7491            repo,
7492            "github:pleme-io/caixa-teia,github:pleme-io/caixa-feira"
7493        );
7494        assert!(
7495            reason.contains("must not contain `,`"),
7496            "reason must surface the list-separator-comma arm, got {reason:?}"
7497        );
7498        assert!(
7499            reason.contains("list-separator") || reason.contains("sub-delims"),
7500            "reason must name the list-separator / RFC-3986-sub-delims rationale, \
7501             got {reason:?}"
7502        );
7503    }
7504
7505    #[test]
7506    fn validate_rejects_git_fonte_with_repo_carrying_trailing_comma() {
7507        // The symmetric trailing-`,` paste-from-prose pin: an author
7508        // writes `:repo "github:pleme-io/caixa-feira,"` (the trailing
7509        // comma every README-prose list-of-projects sentence carries,
7510        // mistakenly retained when the slug is pasted mid-sentence)
7511        // expecting the substrate to coerce it to a kebab-case slug.
7512        // Pinned separately from the wrapped mid-token shape so a
7513        // future diagnostic-surface change that only checked the
7514        // leading or paired-comma position surfaces here — the
7515        // per-byte arm fires anywhere `,` appears in the value.
7516        let d = dep_with_fonte(DepSource::Git {
7517            repo: "github:pleme-io/caixa-feira,".into(),
7518            tag: Some("v0.1.0".into()),
7519            rev: None,
7520            branch: None,
7521        });
7522        let err = d.validate().unwrap_err();
7523        let DepError::FonteRepoShape { reason, .. } = err else {
7524            panic!("expected FonteRepoShape, got other variant");
7525        };
7526        assert!(
7527            reason.contains("must not contain `,`"),
7528            "reason must surface the list-separator-comma arm on the trailing-`,` shape, \
7529             got {reason:?}"
7530        );
7531    }
7532
7533    #[test]
7534    fn fonte_repo_fragment_fires_before_comma_when_fragment_first() {
7535        // Cascade pin: the fragment-`#` arm and the comma arm are
7536        // both per-byte arms inside the same `for &b in s.as_bytes()`
7537        // loop, so the byte that appears first in the value's byte
7538        // order wins. A `:repo "https://github.com/p/x#readme,tail"`
7539        // carries both `#` and `,`; the `#` byte appears first, so
7540        // the fragment-`#` arm fires, surfacing the more self-
7541        // locating diagnostic on the byte the author pasted earliest
7542        // in the URL.
7543        let d = dep_with_fonte(DepSource::Git {
7544            repo: "https://github.com/pleme-io/caixa-teia#readme,tail".into(),
7545            tag: Some("v0.1.0".into()),
7546            rev: None,
7547            branch: None,
7548        });
7549        let err = d.validate().unwrap_err();
7550        let DepError::FonteRepoShape { reason, .. } = err else {
7551            panic!("expected FonteRepoShape, got other variant");
7552        };
7553        assert!(
7554            reason.contains("must not contain `#`"),
7555            "reason must surface the fragment-`#` arm (fires before comma when `#` byte \
7556             appears first in value), got {reason:?}"
7557        );
7558    }
7559
7560    #[test]
7561    fn fonte_repo_bang_fires_before_comma_when_bang_first() {
7562        // Cascade pin: the bang-`!` arm (the immediate-predecessor
7563        // byte-class arm, 7d53c68) and the comma arm are both
7564        // per-byte arms inside the same `for &b in s.as_bytes()`
7565        // loop, so the byte that appears first in the value's byte
7566        // order wins. A `:repo "github:p/x!mid,tail"` carries both
7567        // `!` and `,`; the `!` byte appears first, so the bang arm
7568        // fires, surfacing the more self-locating diagnostic on the
7569        // byte the author pasted earliest in the URL. Pins the
7570        // natural-order cascade so a future reorder of the per-byte
7571        // arms surfaces here — `,` is the most recent byte-class
7572        // arm, so the cascade-pin sweep extends to cover the
7573        // immediately prior `!` byte arm firing first when ordered
7574        // ahead of `,` in the value.
7575        let d = dep_with_fonte(DepSource::Git {
7576            repo: "github:pleme-io/caixa-teia!mid,tail".into(),
7577            tag: Some("v0.1.0".into()),
7578            rev: None,
7579            branch: None,
7580        });
7581        let err = d.validate().unwrap_err();
7582        let DepError::FonteRepoShape { reason, .. } = err else {
7583            panic!("expected FonteRepoShape, got other variant");
7584        };
7585        assert!(
7586            reason.contains("must not contain `!`"),
7587            "reason must surface the bang arm (fires before comma when `!` byte \
7588             appears first in value), got {reason:?}"
7589        );
7590    }
7591
7592    #[test]
7593    fn validate_rejects_git_fonte_with_repo_carrying_shell_env_var_assignment() {
7594        // The fail-before-pass-after pin for the canonical
7595        // shell-env-var-assignment-belongs-to-shell-grammar footgun
7596        // on `:repo`. An author copies
7597        // `GIT_TERMINAL_PROMPT=0 git clone <url>` (or
7598        // `GIT_SSL_NO_VERIFY=1 git clone <url>`, `HTTPS_PROXY=…
7599        // git clone <url>`, etc. — the canonical
7600        // git-troubleshooting README idiom for a one-shot env-var
7601        // scoped to the `git clone` invocation) from a shell-prompt
7602        // one-liner, intending the `KEY=VALUE` prefix as a shell-
7603        // grammar env-var assignment but the typed `:repo` slot is
7604        // a value parser, not a shell context, so the bytes ride
7605        // into the value verbatim. Until this arm landed the `=`
7606        // byte silently passed every prior `is_git_repo_url` arm
7607        // (no whitespace, no control chars, no non-ASCII, no `#`,
7608        // no `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no
7609        // `|`, no `;`, no `&`, no `$`, no `*`, no `(`/`)`, no `"`,
7610        // no `'`, no `!`, no `,`, doesn't start with `-` or `:`);
7611        // the byte rode into the lacre's per-dep content-address
7612        // and the resolver's `git clone <repo>` subprocess
7613        // invocation, where the upstream host's git porcelain
7614        // fetched a literal `GIT_TERMINAL_PROMPT=0 https://…`-shaped
7615        // path that no host's repo registry resolves.
7616        let d = dep_with_fonte(DepSource::Git {
7617            repo: "GIT_TERMINAL_PROMPT=0 https://github.com/pleme-io/caixa-teia".into(),
7618            tag: Some("v0.1.0".into()),
7619            rev: None,
7620            branch: None,
7621        });
7622        let err = d.validate().unwrap_err();
7623        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7624            panic!("expected FonteRepoShape, got other variant");
7625        };
7626        assert_eq!(nome, "caixa-teia");
7627        assert_eq!(
7628            repo,
7629            "GIT_TERMINAL_PROMPT=0 https://github.com/pleme-io/caixa-teia"
7630        );
7631        // The `=` byte at position 19 of `GIT_TERMINAL_PROMPT=0 …`
7632        // appears before the ` ` byte at position 21, so the `=`
7633        // arm fires (not the whitespace arm) — both arms guard
7634        // the slot, but the per-byte for-loop scans left-to-right
7635        // and the first matching byte wins.
7636        assert!(
7637            reason.contains("must not contain `=`"),
7638            "reason must surface the equals-`=` arm on the env-var-assignment \
7639             paste shape, got {reason:?}"
7640        );
7641        assert!(
7642            reason.contains("env-var-assignment") || reason.contains("KEY=VALUE"),
7643            "reason must name the shell-env-var-assignment rationale, got {reason:?}"
7644        );
7645    }
7646
7647    #[test]
7648    fn validate_rejects_git_fonte_with_repo_carrying_gitconfig_url_key_prefix() {
7649        // The symmetric paste-from-gitconfig pin: an author copies
7650        // `url=https://github.com/p/x` from `git config --get-all
7651        // remote.origin.url` output, a `.gitconfig` `[remote
7652        // "origin"] url = https://…` ini-stanza paste, or a
7653        // `git config remote.origin.url <value>` doc snippet,
7654        // intending the `url=` prefix as the ini-key but the typed
7655        // `:repo` slot is a URL value parser, not a gitconfig
7656        // grammar. With no leading whitespace and no earlier-arm
7657        // bytes in the value, the `=` arm itself fires (rather
7658        // than cascading to the whitespace arm as in the env-var
7659        // paste shape). Pinned separately so a future diagnostic-
7660        // surface change that only checked the whitespace-leading
7661        // shape surfaces here — the per-byte arm fires anywhere
7662        // `=` appears in the value.
7663        let d = dep_with_fonte(DepSource::Git {
7664            repo: "url=https://github.com/pleme-io/caixa-feira".into(),
7665            tag: Some("v0.1.0".into()),
7666            rev: None,
7667            branch: None,
7668        });
7669        let err = d.validate().unwrap_err();
7670        let DepError::FonteRepoShape { reason, .. } = err else {
7671            panic!("expected FonteRepoShape, got other variant");
7672        };
7673        assert!(
7674            reason.contains("must not contain `=`"),
7675            "reason must surface the equals-`=` arm on the `url=…` gitconfig \
7676             paste shape, got {reason:?}"
7677        );
7678        assert!(
7679            reason.contains("key-value-separator") || reason.contains("sub-delims"),
7680            "reason must name the key-value-separator / RFC-3986-sub-delims \
7681             rationale, got {reason:?}"
7682        );
7683    }
7684
7685    #[test]
7686    fn fonte_repo_fragment_fires_before_equals_when_fragment_first() {
7687        // Cascade pin: the fragment-`#` arm and the `=` arm are
7688        // both per-byte arms inside the same `for &b in s.as_bytes()`
7689        // loop, so the byte that appears first in the value's byte
7690        // order wins. A `:repo "https://github.com/p/x#readme=tail"`
7691        // carries both `#` and `=`; the `#` byte appears first, so
7692        // the fragment-`#` arm fires, surfacing the more self-
7693        // locating diagnostic on the byte the author pasted earliest
7694        // in the URL.
7695        let d = dep_with_fonte(DepSource::Git {
7696            repo: "https://github.com/pleme-io/caixa-teia#readme=tail".into(),
7697            tag: Some("v0.1.0".into()),
7698            rev: None,
7699            branch: None,
7700        });
7701        let err = d.validate().unwrap_err();
7702        let DepError::FonteRepoShape { reason, .. } = err else {
7703            panic!("expected FonteRepoShape, got other variant");
7704        };
7705        assert!(
7706            reason.contains("must not contain `#`"),
7707            "reason must surface the fragment-`#` arm (fires before equals when \
7708             `#` byte appears first in value), got {reason:?}"
7709        );
7710    }
7711
7712    #[test]
7713    fn fonte_repo_comma_fires_before_equals_when_comma_first() {
7714        // Cascade pin: the comma-`,` arm (the immediate-predecessor
7715        // byte-class arm, 775b80e) and the `=` arm are both per-byte
7716        // arms inside the same `for &b in s.as_bytes()` loop, so
7717        // the byte that appears first in the value's byte order
7718        // wins. A `:repo "github:p/x,mid=tail"` carries both `,`
7719        // and `=`; the `,` byte appears first, so the comma arm
7720        // fires, surfacing the more self-locating diagnostic on
7721        // the byte the author pasted earliest in the URL. Pins the
7722        // natural-order cascade so a future reorder of the per-byte
7723        // arms surfaces here — `=` is the most recent byte-class
7724        // arm, so the cascade-pin sweep extends to cover the
7725        // immediately prior `,` byte arm firing first when ordered
7726        // ahead of `=` in the value.
7727        let d = dep_with_fonte(DepSource::Git {
7728            repo: "github:pleme-io/caixa-teia,mid=tail".into(),
7729            tag: Some("v0.1.0".into()),
7730            rev: None,
7731            branch: None,
7732        });
7733        let err = d.validate().unwrap_err();
7734        let DepError::FonteRepoShape { reason, .. } = err else {
7735            panic!("expected FonteRepoShape, got other variant");
7736        };
7737        assert!(
7738            reason.contains("must not contain `,`"),
7739            "reason must surface the comma arm (fires before equals when `,` byte \
7740             appears first in value), got {reason:?}"
7741        );
7742    }
7743
7744    #[test]
7745    fn validate_rejects_git_fonte_with_repo_carrying_percent_encoded_space() {
7746        // The fail-before-pass-after pin for the canonical paste-from-
7747        // browser-address-bar percent-encoded-space footgun on `:repo`.
7748        // An author copies `https://github.com/p/x%20test` from a
7749        // browser address bar (or a percent-encoded README hyperlink,
7750        // or a `curl --data-urlencode` shell-pipeline output)
7751        // intending `%20` as the URL encoding of a literal space; the
7752        // typed `:repo` slot already rejects the literal space byte
7753        // (the whitespace arm at the top of `is_git_repo_url`), so an
7754        // author trying to express "I really meant a space" reaches
7755        // for percent-encoding. Until this arm landed the `%` byte
7756        // silently passed every prior `is_git_repo_url` arm and rode
7757        // verbatim into the lacre's per-dep content-address — but
7758        // libcurl re-percent-encodes `%` to `%25` on the wire (since
7759        // `%` is reserved as the escape-sequence lead-in), so the
7760        // wire request becomes `https://github.com/p/x%2520test`, a
7761        // path the lacre's content-address never names. The classic
7762        // render-determinism violation on the encoding-mechanism axis
7763        // itself.
7764        let d = dep_with_fonte(DepSource::Git {
7765            repo: "https://github.com/pleme-io/caixa-teia%20test".into(),
7766            tag: Some("v0.1.0".into()),
7767            rev: None,
7768            branch: None,
7769        });
7770        let err = d.validate().unwrap_err();
7771        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7772            panic!("expected FonteRepoShape, got other variant");
7773        };
7774        assert_eq!(nome, "caixa-teia");
7775        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia%20test");
7776        assert!(
7777            reason.contains("must not contain `%`"),
7778            "reason must surface the percent-`%` arm on the percent-encoded-space \
7779             paste shape, got {reason:?}"
7780        );
7781        assert!(
7782            reason.contains("percent-encoding") || reason.contains("%25"),
7783            "reason must name the percent-encoding / `%25` re-encoding rationale, \
7784             got {reason:?}"
7785        );
7786    }
7787
7788    #[test]
7789    fn validate_rejects_git_fonte_with_repo_carrying_percent_encoded_slash() {
7790        // The symmetric over-encoded-path-separator pin: an author
7791        // writes `:repo "https://github.com/p%2Fx"` intending the
7792        // `%2F` as the URL encoding of `/` (the canonical
7793        // paste-from-OpenAPI-spec / paste-from-percent-encoded-template
7794        // footgun every API client library and OAuth redirect-URI
7795        // documentation surfaces — the `/` is the URL-path-separator
7796        // and some templates percent-encode it to escape interpretation
7797        // as a path separator). The GitHub Smart-HTTP transport
7798        // resolves the URL's path-segment grammar before the
7799        // percent-decoding pass, so the value identifies a different
7800        // resource on the wire than the literal-`/` form the lacre's
7801        // content-address must agree with — two authors whose `:repo`
7802        // values differ only in their `/` vs `%2F` presence lock to
7803        // two distinct BLAKE3 closures for the byte-identical upstream
7804        // `git clone`. Pinned separately so a future diagnostic
7805        // surface that only catches the `%20` shape surfaces here too.
7806        let d = dep_with_fonte(DepSource::Git {
7807            repo: "https://github.com/pleme-io%2Fcaixa-teia".into(),
7808            tag: Some("v0.1.0".into()),
7809            rev: None,
7810            branch: None,
7811        });
7812        let err = d.validate().unwrap_err();
7813        let DepError::FonteRepoShape { reason, .. } = err else {
7814            panic!("expected FonteRepoShape, got other variant");
7815        };
7816        assert!(
7817            reason.contains("must not contain `%`"),
7818            "reason must surface the percent-`%` arm on the over-encoded-path \
7819             shape, got {reason:?}"
7820        );
7821        assert!(
7822            reason.contains("render-determinism") || reason.contains("BLAKE3"),
7823            "reason must name the render-determinism / BLAKE3-closure rationale, \
7824             got {reason:?}"
7825        );
7826    }
7827
7828    #[test]
7829    fn fonte_repo_fragment_fires_before_percent_when_fragment_first() {
7830        // Cascade pin: the fragment-`#` arm and the `%` arm are both
7831        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
7832        // so the byte that appears first in the value's byte order
7833        // wins. A `:repo "https://github.com/p/x#sec%20tail"` carries
7834        // both `#` and `%`; the `#` byte appears first, so the
7835        // fragment-`#` arm fires, surfacing the more self-locating
7836        // diagnostic on the byte the author pasted earliest in the URL.
7837        let d = dep_with_fonte(DepSource::Git {
7838            repo: "https://github.com/pleme-io/caixa-teia#sec%20tail".into(),
7839            tag: Some("v0.1.0".into()),
7840            rev: None,
7841            branch: None,
7842        });
7843        let err = d.validate().unwrap_err();
7844        let DepError::FonteRepoShape { reason, .. } = err else {
7845            panic!("expected FonteRepoShape, got other variant");
7846        };
7847        assert!(
7848            reason.contains("must not contain `#`"),
7849            "reason must surface the fragment-`#` arm (fires before percent when \
7850             `#` byte appears first in value), got {reason:?}"
7851        );
7852    }
7853
7854    #[test]
7855    fn fonte_repo_equals_fires_before_percent_when_equals_first() {
7856        // Cascade pin: the equals-`=` arm (the immediate-predecessor
7857        // byte-class arm, acf99af) and the `%` arm are both per-byte
7858        // arms inside the same `for &b in s.as_bytes()` loop, so the
7859        // byte that appears first in the value's byte order wins.
7860        // A `:repo "github:p/x=mid%20tail"` carries both `=` and `%`;
7861        // the `=` byte appears first, so the equals arm fires,
7862        // surfacing the more self-locating diagnostic on the byte the
7863        // author pasted earliest in the URL. Pins the natural-order
7864        // cascade so a future reorder of the per-byte arms surfaces
7865        // here — `%` is the most recent byte-class arm, so the
7866        // cascade-pin sweep extends to cover the immediately prior
7867        // `=` byte arm firing first when ordered ahead of `%` in the
7868        // value.
7869        let d = dep_with_fonte(DepSource::Git {
7870            repo: "github:pleme-io/caixa-teia=mid%20tail".into(),
7871            tag: Some("v0.1.0".into()),
7872            rev: None,
7873            branch: None,
7874        });
7875        let err = d.validate().unwrap_err();
7876        let DepError::FonteRepoShape { reason, .. } = err else {
7877            panic!("expected FonteRepoShape, got other variant");
7878        };
7879        assert!(
7880            reason.contains("must not contain `=`"),
7881            "reason must surface the equals arm (fires before percent when `=` byte \
7882             appears first in value), got {reason:?}"
7883        );
7884    }
7885
7886    #[test]
7887    fn validate_rejects_git_fonte_with_repo_carrying_caret_history_substitution() {
7888        // The fail-before-pass-after pin for the canonical paste-from-
7889        // shell-history footgun on `:repo`. An author copies a
7890        // `git clone <url>` line from their terminal followed by a
7891        // bash / ksh / zsh `^typo^fix^` quick-edit-and-rerun shell-
7892        // history shorthand (the `^old^new^` form re-runs the prior
7893        // history entry with the first `old` substituted by `new`,
7894        // bash's default behavior on interactive sessions with
7895        // `set -o histexpand`), forgetting to trim the trailing
7896        // `^...^...` shell-history fragment from the URL value. The
7897        // `^` byte sits in the RFC 3986 §2 'unwise' set (peer with
7898        // `{`, `}`, `|`, `\\` — the strictest of the §2 reserved
7899        // classes), the WHATWG URL spec's 'fragment percent-encode
7900        // set' maps `^` → `%5E` on the wire, so the byte rides
7901        // verbatim into the lacre's per-dep content-address but
7902        // libcurl re-encodes it to `%5E` at `git clone` time — the
7903        // classic render-determinism violation on the same axis the
7904        // peer `%`, `=`, `,`, `!`, `'`, `"`, `(`, `)`, `*`, `$`,
7905        // `&`, `;`, `|`, backtick, `<`, `>`, `{`, `}`, `\\`, `?`,
7906        // `#` arms close.
7907        let d = dep_with_fonte(DepSource::Git {
7908            repo: "https://github.com/pleme-io/caixa-teia^typo^fix".into(),
7909            tag: Some("v0.1.0".into()),
7910            rev: None,
7911            branch: None,
7912        });
7913        let err = d.validate().unwrap_err();
7914        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7915            panic!("expected FonteRepoShape, got other variant");
7916        };
7917        assert_eq!(nome, "caixa-teia");
7918        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia^typo^fix");
7919        assert!(
7920            reason.contains("must not contain `^`"),
7921            "reason must surface the caret-`^` arm on the paste-from-shell-history \
7922             shape, got {reason:?}"
7923        );
7924        assert!(
7925            reason.contains("history-substitution") || reason.contains("%5E"),
7926            "reason must name the shell-history-substitution / `%5E` wire-encoding \
7927             rationale, got {reason:?}"
7928        );
7929    }
7930
7931    #[test]
7932    fn validate_rejects_git_fonte_with_repo_carrying_caret_regex_anchor() {
7933        // The symmetric paste-from-doc-grep-pipeline footgun: an
7934        // author writes `:repo "github:p/^archived"` after copying a
7935        // `grep '^archived'` regex-anchor / negation idiom from a
7936        // doc / README quick-listing snippet, expecting the substrate
7937        // to coerce it to a literal repo name. The byte rides
7938        // verbatim into the lacre's per-dep content-address and
7939        // diverges from the byte-identical literal `archived` form
7940        // every other author authored — the canonical render-
7941        // determinism violation pin on the second footgun shape the
7942        // caret-`^` arm closes.
7943        let d = dep_with_fonte(DepSource::Git {
7944            repo: "github:pleme-io/^archived".into(),
7945            tag: Some("v0.1.0".into()),
7946            rev: None,
7947            branch: None,
7948        });
7949        let err = d.validate().unwrap_err();
7950        let DepError::FonteRepoShape { reason, .. } = err else {
7951            panic!("expected FonteRepoShape, got other variant");
7952        };
7953        assert!(
7954            reason.contains("must not contain `^`"),
7955            "reason must surface the caret-`^` arm on the regex-anchor shape, \
7956             got {reason:?}"
7957        );
7958        assert!(
7959            reason.contains("render-determinism") || reason.contains("BLAKE3"),
7960            "reason must name the render-determinism / BLAKE3-closure rationale, \
7961             got {reason:?}"
7962        );
7963    }
7964
7965    #[test]
7966    fn fonte_repo_percent_fires_before_caret_when_percent_first() {
7967        // Cascade pin: the `%` arm (the immediate-predecessor byte-
7968        // class arm, a323db8) and the `^` arm are both per-byte arms
7969        // inside the same `for &b in s.as_bytes()` loop, so the byte
7970        // that appears first in the value's byte order wins. A
7971        // `:repo "https://github.com/p/x%20mid^tail"` carries both
7972        // `%` and `^`; the `%` byte appears first, so the percent
7973        // arm fires, surfacing the more self-locating diagnostic on
7974        // the byte the author pasted earliest in the URL. Pins the
7975        // natural-order cascade so a future reorder of the per-byte
7976        // arms surfaces here — `^` is the most recent byte-class arm,
7977        // so the cascade-pin sweep extends to cover the immediately
7978        // prior `%` byte arm firing first when ordered ahead of `^`
7979        // in the value.
7980        let d = dep_with_fonte(DepSource::Git {
7981            repo: "https://github.com/pleme-io/caixa-teia%20mid^tail".into(),
7982            tag: Some("v0.1.0".into()),
7983            rev: None,
7984            branch: None,
7985        });
7986        let err = d.validate().unwrap_err();
7987        let DepError::FonteRepoShape { reason, .. } = err else {
7988            panic!("expected FonteRepoShape, got other variant");
7989        };
7990        assert!(
7991            reason.contains("must not contain `%`"),
7992            "reason must surface the percent arm (fires before caret when `%` byte \
7993             appears first in value), got {reason:?}"
7994        );
7995    }
7996
7997    #[test]
7998    fn validate_rejects_git_fonte_with_repo_missing_colon_separator() {
7999        // The "I dropped the scheme" footgun — `:repo "pleme-io/caixa-teia"`
8000        // (no `github:` prefix, no scheme). Every documented form
8001        // carries a `:` (`github:`, `https://`, `ssh://`, `git://`,
8002        // `file://`, or `git@host:path`); a bare `org/repo` is
8003        // ambiguous (`git clone` reads as a relative filesystem path
8004        // rather than the GitHub-shorthand expansion the author
8005        // probably intended) and the gate rejects the shape upstream.
8006        let d = dep_with_fonte(DepSource::Git {
8007            repo: "pleme-io/caixa-teia".into(),
8008            tag: Some("v0.1.0".into()),
8009            rev: None,
8010            branch: None,
8011        });
8012        let err = d.validate().unwrap_err();
8013        let DepError::FonteRepoShape { reason, .. } = err else {
8014            panic!("expected FonteRepoShape, got other variant");
8015        };
8016        assert!(
8017            reason.contains("must contain a `:`"),
8018            "reason must surface the missing-`:` arm, got {reason:?}"
8019        );
8020        assert!(
8021            reason.contains("github:"),
8022            "reason must name the canonical `github:` shorthand prefix, got {reason:?}"
8023        );
8024    }
8025
8026    #[test]
8027    fn validate_rejects_git_fonte_with_repo_leading_colon() {
8028        // The "empty scheme" footgun — `:repo ":foo"` has a zero-length
8029        // scheme that no git porcelain entry-point accepts. Pinned
8030        // separately from the missing-`:` arm because a value with a
8031        // leading `:` does technically contain a `:` separator; the
8032        // shape gate rejects on a dedicated arm so the diagnostic
8033        // names the specific footgun.
8034        let d = dep_with_fonte(DepSource::Git {
8035            repo: ":pleme-io/caixa-teia".into(),
8036            tag: Some("v0.1.0".into()),
8037            rev: None,
8038            branch: None,
8039        });
8040        let err = d.validate().unwrap_err();
8041        let DepError::FonteRepoShape { reason, .. } = err else {
8042            panic!("expected FonteRepoShape, got other variant");
8043        };
8044        assert!(
8045            reason.contains("must not start with `:`"),
8046            "reason must surface the leading-`:` arm, got {reason:?}"
8047        );
8048    }
8049
8050    #[test]
8051    fn validate_rejects_git_fonte_with_repo_too_long() {
8052        // The cap arm — a `:repo` value longer than
8053        // [`crate::render::GIT_REPO_URL_MAX_LEN`] (2048) bytes is
8054        // structurally untenable on every realistic landing site (the
8055        // resolver's `git clone` invocation, the future M4 CR
8056        // materializer's per-dep `repo:` axis); a value of that length
8057        // is almost certainly a paste-from-binary slug.
8058        let too_long = format!(
8059            "github:pleme-io/{}",
8060            "x".repeat(crate::render::GIT_REPO_URL_MAX_LEN)
8061        );
8062        let d = dep_with_fonte(DepSource::Git {
8063            repo: too_long.clone(),
8064            tag: Some("v0.1.0".into()),
8065            rev: None,
8066            branch: None,
8067        });
8068        let err = d.validate().unwrap_err();
8069        let DepError::FonteRepoShape { reason, .. } = err else {
8070            panic!("expected FonteRepoShape, got other variant");
8071        };
8072        assert!(
8073            reason.contains("2048"),
8074            "reason must name the cap, got {reason:?}"
8075        );
8076    }
8077
8078    #[test]
8079    fn validate_accepts_canonical_git_fonte_repo_shapes() {
8080        // The positive-control sweep: every documented author shape on
8081        // the `:fonte :repo` axis ([`crate::DepSource::Git`] doc comment)
8082        // must pass the value-shape gate. Pinned so a future tightening
8083        // (e.g. forbidding `http://` in favor of `https://`-only) surfaces
8084        // here as a structural decision. Each form is exercised with the
8085        // same canonical `:tag` pin so only the `:repo` axis varies.
8086        for repo in [
8087            // The pleme-io registry-shorthand convention — `github:org/repo`.
8088            "github:pleme-io/caixa-teia",
8089            // Other host-aliased shorthands (the resolver's pluggable
8090            // host-prefix table).
8091            "gitlab:pleme-io/caixa-teia",
8092            "codeberg:pleme-io/caixa-teia",
8093            "sourcehut:~pleme-io/caixa-teia",
8094            // Full HTTPS URL with and without `.git` suffix.
8095            "https://github.com/pleme-io/caixa-teia",
8096            "https://github.com/pleme-io/caixa-teia.git",
8097            // HTTP (rare; dev / mirror).
8098            "http://example.com/pleme-io/caixa-teia.git",
8099            // SSH URL.
8100            "ssh://git@github.com/pleme-io/caixa-teia.git",
8101            "ssh://git@git.example.com:2222/pleme-io/caixa-teia.git",
8102            // Scp-style SSH — the canonical `git@host:path` short form.
8103            "git@github.com:pleme-io/caixa-teia.git",
8104            "git@git.example.com:team/private.git",
8105            // Anonymous git protocol.
8106            "git://git.example.com/pleme-io/caixa-teia.git",
8107            // Local file URL (dev path).
8108            "file:///tmp/caixa-teia",
8109        ] {
8110            let d = dep_with_fonte(DepSource::Git {
8111                repo: repo.into(),
8112                tag: Some("v0.1.0".into()),
8113                rev: None,
8114                branch: None,
8115            });
8116            d.validate()
8117                .unwrap_or_else(|e| panic!("canonical repo {repo:?} must validate, got {e:?}"));
8118        }
8119    }
8120
8121    #[test]
8122    fn fonte_repo_empty_takes_precedence_over_shape() {
8123        // Order pin: the existing `FonteRepoEmpty` diagnostic (narrower
8124        // diagnostic; doesn't try to parse the URL shape) fires before
8125        // the new `FonteRepoShape` per-axis gate, so an empty `:repo`
8126        // keeps its narrower error message. Mirrors
8127        // `fonte_repo_empty_fires_before_pin_missing` (already pinned)
8128        // on the ordering layer.
8129        let d = dep_with_fonte(DepSource::Git {
8130            repo: String::new(),
8131            tag: Some("v0.1.0".into()),
8132            rev: None,
8133            branch: None,
8134        });
8135        let err = d.validate().unwrap_err();
8136        assert!(
8137            matches!(err, DepError::FonteRepoEmpty { .. }),
8138            "got {err:?}"
8139        );
8140    }
8141
8142    #[test]
8143    fn fonte_repo_shape_fires_before_pin_missing() {
8144        // Order pin: a malformed `:repo` value on a dep with no pin set
8145        // surfaces the `:repo` shape diagnostic (the more self-locating
8146        // axis — the `:repo` is the load-bearing identity of the source;
8147        // a missing pin is downstream from "do we even know the repo")
8148        // rather than collapsing onto the pin-missing diagnostic. The
8149        // shape gate runs inline before the pin enumeration in
8150        // `DepSource::validate`.
8151        let d = dep_with_fonte(DepSource::Git {
8152            repo: "pleme-io/caixa-teia".into(), // missing `:` separator
8153            tag: None,
8154            rev: None,
8155            branch: None,
8156        });
8157        let err = d.validate().unwrap_err();
8158        assert!(
8159            matches!(err, DepError::FonteRepoShape { .. }),
8160            "got {err:?}"
8161        );
8162    }
8163
8164    #[test]
8165    fn fonte_repo_shape_diagnostic_carries_offending_repo_verbatim() {
8166        // The diagnostic-shape pin: the error names the offending
8167        // `:repo` value verbatim plus a non-empty parser-shaped `reason`
8168        // so the author can grep their caixa.lisp without re-running
8169        // the build. Mirrors the diagnostic-shape sweep on every prior
8170        // value-shape gate (3f9d7a0, 6cbb900, c7d05ec, e70d213, be07fd5).
8171        let d = dep_with_fonte(DepSource::Git {
8172            repo: "pleme-io/caixa-teia".into(),
8173            tag: Some("v0.1.0".into()),
8174            rev: None,
8175            branch: None,
8176        });
8177        let err = d.validate().unwrap_err();
8178        let DepError::FonteRepoShape { nome, repo, reason } = err else {
8179            panic!("expected FonteRepoShape, got other variant");
8180        };
8181        assert_eq!(nome, "caixa-teia");
8182        assert_eq!(repo, "pleme-io/caixa-teia");
8183        assert!(
8184            !reason.is_empty(),
8185            "FonteRepoShape `reason` must carry the predicate's wording verbatim"
8186        );
8187    }
8188
8189    #[test]
8190    fn validate_rejects_git_fonte_with_no_pin() {
8191        // The fail-before-pass-after pin for the canonical
8192        // `(:tipo git :repo "github:pleme-io/x")` shape with no
8193        // :tag/:rev/:branch — until this gate landed the resolver's
8194        // ResolveError::MissingPin surfaced at fetch time, far from the
8195        // source caixa.lisp. The new gate moves the check to validate
8196        // time and names the offending dep.
8197        let d = dep_with_fonte(DepSource::Git {
8198            repo: "github:pleme-io/caixa-teia".into(),
8199            tag: None,
8200            rev: None,
8201            branch: None,
8202        });
8203        let err = d.validate().unwrap_err();
8204        assert!(
8205            matches!(err, DepError::FontePinMissing { ref nome } if nome == "caixa-teia"),
8206            "got {err:?}"
8207        );
8208    }
8209
8210    #[test]
8211    fn validate_rejects_git_fonte_with_ambiguous_tag_and_branch() {
8212        // The canonical "pin drift" footgun: an author writes
8213        // `:tag "v1"` and later adds `:branch "main"` without removing
8214        // the :tag, and the resolver silently picks :tag (precedence
8215        // :rev > :tag > :branch). The :branch was dropped with no
8216        // diagnostic. The gate now rejects multi-pin shapes so the
8217        // author makes the precedence explicit at the source.
8218        let d = dep_with_fonte(DepSource::Git {
8219            repo: "github:pleme-io/caixa-teia".into(),
8220            tag: Some("v0.1.0".into()),
8221            rev: None,
8222            branch: Some("main".into()),
8223        });
8224        let err = d.validate().unwrap_err();
8225        let DepError::FontePinAmbiguous { nome, pins } = err else {
8226            panic!("expected FontePinAmbiguous");
8227        };
8228        assert_eq!(nome, "caixa-teia");
8229        assert!(pins.contains(":tag"));
8230        assert!(pins.contains(":branch"));
8231        assert!(!pins.contains(":rev"));
8232    }
8233
8234    #[test]
8235    fn validate_rejects_git_fonte_with_ambiguous_tag_and_rev() {
8236        // Sibling arm of the pin-drift footgun: :tag + :rev set
8237        // simultaneously. Pinned separately so a future relaxation
8238        // that only catches the (:tag, :branch) pair surfaces here.
8239        let d = dep_with_fonte(DepSource::Git {
8240            repo: "github:pleme-io/caixa-teia".into(),
8241            tag: Some("v0.1.0".into()),
8242            rev: Some("c0ffee".into()),
8243            branch: None,
8244        });
8245        let err = d.validate().unwrap_err();
8246        let DepError::FontePinAmbiguous { nome, pins } = err else {
8247            panic!("expected FontePinAmbiguous");
8248        };
8249        assert_eq!(nome, "caixa-teia");
8250        assert!(pins.contains(":tag"));
8251        assert!(pins.contains(":rev"));
8252    }
8253
8254    #[test]
8255    fn validate_rejects_git_fonte_with_all_three_pins() {
8256        // The maximal ambiguity case — every pin axis set. Pinned so a
8257        // future relaxation that only catches pairs surfaces here. The
8258        // diagnostic must enumerate every offending axis so the author
8259        // sees the full set, not just the first match.
8260        let d = dep_with_fonte(DepSource::Git {
8261            repo: "github:pleme-io/caixa-teia".into(),
8262            tag: Some("v0.1.0".into()),
8263            rev: Some("c0ffee".into()),
8264            branch: Some("main".into()),
8265        });
8266        let err = d.validate().unwrap_err();
8267        let DepError::FontePinAmbiguous { nome, pins } = err else {
8268            panic!("expected FontePinAmbiguous");
8269        };
8270        assert_eq!(nome, "caixa-teia");
8271        assert!(pins.contains(":tag"));
8272        assert!(pins.contains(":rev"));
8273        assert!(pins.contains(":branch"));
8274    }
8275
8276    #[test]
8277    fn validate_rejects_git_fonte_with_empty_tag_pin() {
8278        // The empty-pin arm: exactly one pin axis is `Some(_)`, but its
8279        // inner string is empty. Distinct from FontePinMissing (where
8280        // every axis is None) — pinned separately so a future
8281        // tightening collapsing them surfaces here as a structural
8282        // decision.
8283        let d = dep_with_fonte(DepSource::Git {
8284            repo: "github:pleme-io/caixa-teia".into(),
8285            tag: Some(String::new()),
8286            rev: None,
8287            branch: None,
8288        });
8289        let err = d.validate().unwrap_err();
8290        let DepError::FontePinEmpty { nome, pin } = err else {
8291            panic!("expected FontePinEmpty");
8292        };
8293        assert_eq!(nome, "caixa-teia");
8294        assert_eq!(pin, ":tag");
8295    }
8296
8297    #[test]
8298    fn validate_rejects_git_fonte_with_empty_rev_pin() {
8299        // Sibling arm — the empty-pin diagnostic names which axis
8300        // carries the empty value, so the author's grep target is
8301        // unambiguous.
8302        let d = dep_with_fonte(DepSource::Git {
8303            repo: "github:pleme-io/caixa-teia".into(),
8304            tag: None,
8305            rev: Some(String::new()),
8306            branch: None,
8307        });
8308        let err = d.validate().unwrap_err();
8309        let DepError::FontePinEmpty { nome, pin } = err else {
8310            panic!("expected FontePinEmpty");
8311        };
8312        assert_eq!(nome, "caixa-teia");
8313        assert_eq!(pin, ":rev");
8314    }
8315
8316    #[test]
8317    fn validate_rejects_path_fonte_with_empty_caminho() {
8318        // The fail-before-pass-after pin for `(:tipo path :caminho "")`:
8319        // until this gate landed the resolver's
8320        // ResolveError::MissingPath surfaced with `path: PathBuf("")` at
8321        // fetch time — not actionable. The new gate moves the check to
8322        // validate time and names the offending dep.
8323        let d = dep_with_fonte(DepSource::Path {
8324            caminho: String::new(),
8325        });
8326        let err = d.validate().unwrap_err();
8327        assert!(
8328            matches!(err, DepError::FonteCaminhoEmpty { ref nome } if nome == "caixa-teia"),
8329            "got {err:?}"
8330        );
8331    }
8332
8333    #[test]
8334    fn validate_rejects_path_fonte_with_absolute_caminho() {
8335        // The fail-before-pass-after pin for the absolute-`:caminho`
8336        // shape: `(:tipo path :caminho "/home/me/work/caixa-teia")`.
8337        // Until this gate landed an absolute `:caminho` silently
8338        // passed validate; the lacre pipeline embedded the
8339        // host-specific filesystem path verbatim in its
8340        // content-address (`conteudo: format!("path:{caminho}")`,
8341        // caixa-resolver/src/resolve.rs:189), so the BLAKE3 closure
8342        // differed per machine — the build succeeded but two CI
8343        // runners with different `${HOME}` layouts emitted two
8344        // distinct lacres for the byte-identical caixa, silently
8345        // breaking the THEORY.md §V.2 render-determinism contract
8346        // far from the source caixa.lisp. The new gate moves the
8347        // check to validate time and names the offending dep +
8348        // caminho verbatim.
8349        let d = dep_with_fonte(DepSource::Path {
8350            caminho: "/home/me/work/caixa-teia".into(),
8351        });
8352        let err = d.validate().unwrap_err();
8353        let DepError::FonteCaminhoAbsolute { nome, caminho } = err else {
8354            panic!("expected FonteCaminhoAbsolute, got other variant");
8355        };
8356        assert_eq!(nome, "caixa-teia");
8357        assert_eq!(caminho, "/home/me/work/caixa-teia");
8358    }
8359
8360    #[test]
8361    fn validate_accepts_path_fonte_with_parent_escape_caminho() {
8362        // The canonical sibling-workspace dep form
8363        // (`:caminho "../caixa-teia"`) remains accepted. The
8364        // absolute-path gate above is specifically narrower than the
8365        // shared [`crate::render::is_sandboxed_relative_path`]
8366        // predicate (which additionally forbids `..` traversal): a
8367        // local-path dep's canonical author surface is the in-tree
8368        // sibling-workspace path, so a full sandboxed-relative-path
8369        // lift would structurally reject every legitimate path-fonte
8370        // dep. Pinned so a future tightening to the full predicate
8371        // surfaces here as a structural decision, not a silent break.
8372        let d = dep_with_fonte(DepSource::Path {
8373            caminho: "../caixa-teia".into(),
8374        });
8375        d.validate().unwrap();
8376    }
8377
8378    #[test]
8379    fn validate_accepts_path_fonte_with_deeply_nested_relative_caminho() {
8380        // A multi-segment relative `:caminho`
8381        // (`"vendor/forks/caixa-teia"`) remains accepted — the
8382        // absolute-path gate brackets the host-layout-leaking shape
8383        // at the leading-`/` boundary only; every relative shape past
8384        // the empty arm continues to pass. Pinned alongside the
8385        // `..`-traversal positive control so a future tightening
8386        // surfaces the full set of legitimate relative forms here
8387        // rather than at a downstream consumer.
8388        let d = dep_with_fonte(DepSource::Path {
8389            caminho: "vendor/forks/caixa-teia".into(),
8390        });
8391        d.validate().unwrap();
8392    }
8393
8394    #[test]
8395    fn validate_rejects_path_fonte_with_tilde_prefix_caminho() {
8396        // The fail-before-pass-after pin for the tilde-expansion
8397        // `:caminho` shape: `(:tipo path :caminho "~/work/caixa-teia")`.
8398        // Until this gate landed the b94fd83 absolute arm let `~/foo`
8399        // through (`Path::is_absolute` returns false on a leading `~`
8400        // — the tilde is a shell-expansion convention, not a POSIX
8401        // path component), so the lacre embedded the value verbatim
8402        // and the resolver folded it through `Path::join` without
8403        // expansion, looking for a literal `./~/work/caixa-teia`
8404        // subdirectory and failing at resolve time with a
8405        // `No such file or directory` error far from the source
8406        // caixa.lisp. The new gate moves the check to validate time
8407        // and names the offending dep + caminho verbatim.
8408        let d = dep_with_fonte(DepSource::Path {
8409            caminho: "~/work/caixa-teia".into(),
8410        });
8411        let err = d.validate().unwrap_err();
8412        let DepError::FonteCaminhoTildeExpansion { nome, caminho } = err else {
8413            panic!("expected FonteCaminhoTildeExpansion, got {err:?}");
8414        };
8415        assert_eq!(nome, "caixa-teia");
8416        assert_eq!(caminho, "~/work/caixa-teia");
8417    }
8418
8419    #[test]
8420    fn validate_rejects_path_fonte_with_bare_tilde_caminho() {
8421        // The bare `~` form (canonical "I meant `$HOME` and forgot
8422        // the rest"): both the leading-tilde arm catches it and the
8423        // canonical-user-tilde shell idiom (`~alice/dev/caixa-teia`)
8424        // sweeps through the same arm. Pinned both to ensure the
8425        // gate doesn't narrow to `~/` only.
8426        for s in ["~", "~alice/dev/caixa-teia", "~/", "~root/work"] {
8427            let d = dep_with_fonte(DepSource::Path { caminho: s.into() });
8428            let err = d.validate().unwrap_err();
8429            assert!(
8430                matches!(err, DepError::FonteCaminhoTildeExpansion { .. }),
8431                "{s:?} → {err:?}",
8432            );
8433        }
8434    }
8435
8436    #[test]
8437    fn validate_accepts_path_fonte_with_mid_path_tilde_caminho() {
8438        // The leading-`~` is the canonical shell-expansion footgun —
8439        // a tilde mid-path (`"../foo~bar/caixa-teia"` — the canonical
8440        // backup-file-suffix idiom) is a legitimate POSIX path byte
8441        // with no shell-expansion semantic at the leading position.
8442        // Pinned so the gate doesn't widen to a full no-tilde-anywhere
8443        // sweep that would break every legitimate-shape backup-file
8444        // path.
8445        let d = dep_with_fonte(DepSource::Path {
8446            caminho: "../foo~bar/caixa-teia".into(),
8447        });
8448        d.validate().unwrap();
8449    }
8450
8451    #[test]
8452    fn fonte_caminho_empty_fires_before_tilde_expansion() {
8453        // Cascade pin: the empty arm structurally precedes the
8454        // tilde arm (the bytes `""` and `"~"` don't overlap), but the
8455        // pin establishes the precedence at the diagnostic-shape
8456        // level should a future codec round-trip ever produce a
8457        // probe-as-both value. Mirrors the peer
8458        // `fonte_repo_empty_fires_before_pin_missing` cascade
8459        // discipline.
8460        let d = dep_with_fonte(DepSource::Path {
8461            caminho: String::new(),
8462        });
8463        let err = d.validate().unwrap_err();
8464        assert!(
8465            matches!(err, DepError::FonteCaminhoEmpty { .. }),
8466            "got {err:?}",
8467        );
8468    }
8469
8470    #[test]
8471    fn fonte_caminho_tilde_diagnostic_carries_offending_dep_and_caminho() {
8472        // Diagnostic-shape pin (peer with
8473        // `validate_rejects_path_fonte_with_absolute_caminho`'s
8474        // payload assertion): the error's Display surfaces both the
8475        // offending `:nome` and the offending `:caminho` verbatim
8476        // so a `feira lint` run can render the diagnostic without
8477        // re-parsing.
8478        let d = dep_with_fonte(DepSource::Path {
8479            caminho: "~alice/dev/caixa-teia".into(),
8480        });
8481        let rendered = d.validate().unwrap_err().to_string();
8482        assert!(
8483            rendered.contains("caixa-teia"),
8484            "diagnostic must name the offending dep: {rendered}",
8485        );
8486        assert!(
8487            rendered.contains("~alice/dev/caixa-teia"),
8488            "diagnostic must quote the offending caminho: {rendered}",
8489        );
8490        assert!(
8491            rendered.contains('~'),
8492            "diagnostic must reference the tilde footgun: {rendered}",
8493        );
8494    }
8495
8496    #[test]
8497    fn validate_rejects_path_fonte_with_dollar_prefix_caminho() {
8498        // The fail-before-pass-after pin for the shell-variable-
8499        // expansion `:caminho` shape: `(:tipo path :caminho
8500        // "$HOME/work/caixa-teia")`. Until this gate landed the
8501        // b94fd83 absolute arm + the a5c248e tilde arm both let
8502        // `$HOME/foo` through (`Path::is_absolute` returns false on
8503        // a leading `$` — the `$` is a shell convention, not a POSIX
8504        // path component; `starts_with('~')` returns false too), so
8505        // the lacre embedded the value verbatim and the resolver
8506        // folded it through `Path::join` without `$`-expansion,
8507        // looking for a literal `./$HOME/work/caixa-teia`
8508        // subdirectory and failing at resolve time with a
8509        // `No such file or directory` error far from the source
8510        // caixa.lisp. The new gate moves the check to validate time
8511        // and names the offending dep + caminho verbatim.
8512        let d = dep_with_fonte(DepSource::Path {
8513            caminho: "$HOME/work/caixa-teia".into(),
8514        });
8515        let err = d.validate().unwrap_err();
8516        let DepError::FonteCaminhoVarExpansion { nome, caminho } = err else {
8517            panic!("expected FonteCaminhoVarExpansion, got {err:?}");
8518        };
8519        assert_eq!(nome, "caixa-teia");
8520        assert_eq!(caminho, "$HOME/work/caixa-teia");
8521    }
8522
8523    #[test]
8524    fn validate_rejects_path_fonte_with_dollar_brace_prefix_caminho() {
8525        // Sweep over every leading-`$` shape: the `${VAR}`-braced
8526        // form (canonical "paste-from-CI-manifest" footgun every
8527        // GitHub Actions / GitLab CI / Drone manifest carries on
8528        // `${WORKSPACE}`), the XDG idiom (`$XDG_CONFIG_HOME/caixa`,
8529        // canonical "I'm referencing a per-user config dir"),
8530        // and the bare `$` (canonical "I meant `$HOME` and forgot
8531        // the rest"). All shapes route through the same gate's
8532        // byte check. Pinned so the gate doesn't narrow to a
8533        // single shape (e.g. `$HOME/` only).
8534        for s in [
8535            "${HOME}/work/caixa-teia",
8536            "${WORKSPACE}/caixa-teia",
8537            "$XDG_CONFIG_HOME/caixa",
8538            "$",
8539        ] {
8540            let d = dep_with_fonte(DepSource::Path { caminho: s.into() });
8541            let err = d.validate().unwrap_err();
8542            assert!(
8543                matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
8544                "{s:?} → {err:?}",
8545            );
8546        }
8547    }
8548
8549    #[test]
8550    fn validate_rejects_path_fonte_with_mid_path_dollar_caminho() {
8551        // The `$` byte is the canonical shell-variable-expansion /
8552        // command-substitution / arithmetic-expansion sentinel and
8553        // is rejected at *every* position on the `:caminho` axis: the
8554        // leading arm surfaces `FonteCaminhoVarExpansion`, the
8555        // embedded arm surfaces `FonteCaminhoShellVariableExpansion`
8556        // (6620f39). Pinned so a future arm doesn't narrow the gate
8557        // back to the leading position and re-open the paste-from-
8558        // shell-one-liner `"../foo$HOME/bar"` / paste-from-CI-
8559        // manifest `"../foo${WORKSPACE}/bar"` / paste-from-shell-
8560        // prompt `"../foo$(whoami)/bar"` cross-idiom-leak surface on
8561        // the lacre content-address (`path:{caminho}`,
8562        // caixa-resolver/src/resolve.rs:189).
8563        let d = dep_with_fonte(DepSource::Path {
8564            caminho: "../foo$bar/caixa-teia".into(),
8565        });
8566        let err = d.validate().unwrap_err();
8567        assert!(
8568            matches!(
8569                err,
8570                DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
8571            ),
8572            "got {err:?}",
8573        );
8574    }
8575
8576    #[test]
8577    fn fonte_caminho_tilde_fires_before_var_expansion() {
8578        // Cascade pin: the tilde arm structurally precedes the var
8579        // arm (the bytes `~` and `$` don't overlap at the leading
8580        // position), but the pin establishes the precedence at the
8581        // diagnostic-shape level should a future codec round-trip
8582        // ever produce a probe-as-both value. Mirrors the peer
8583        // `fonte_caminho_empty_fires_before_tilde_expansion` cascade
8584        // discipline on the immediate-predecessor arm.
8585        let d = dep_with_fonte(DepSource::Path {
8586            caminho: "~/work/caixa-teia".into(),
8587        });
8588        let err = d.validate().unwrap_err();
8589        assert!(
8590            matches!(err, DepError::FonteCaminhoTildeExpansion { .. }),
8591            "got {err:?}",
8592        );
8593    }
8594
8595    #[test]
8596    fn fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho() {
8597        // Diagnostic-shape pin (peer with
8598        // `fonte_caminho_tilde_diagnostic_carries_offending_dep_and_caminho`'s
8599        // payload assertion on the immediate-predecessor arm): the
8600        // error's Display surfaces both the offending `:nome` and
8601        // the offending `:caminho` verbatim plus the `$` footgun
8602        // character itself so a `feira lint` run can render the
8603        // diagnostic without re-parsing.
8604        let d = dep_with_fonte(DepSource::Path {
8605            caminho: "${WORKSPACE}/caixa-teia".into(),
8606        });
8607        let rendered = d.validate().unwrap_err().to_string();
8608        assert!(
8609            rendered.contains("caixa-teia"),
8610            "diagnostic must name the offending dep: {rendered}",
8611        );
8612        assert!(
8613            rendered.contains("${WORKSPACE}/caixa-teia"),
8614            "diagnostic must quote the offending caminho: {rendered}",
8615        );
8616        assert!(
8617            rendered.contains('$'),
8618            "diagnostic must reference the dollar footgun: {rendered}",
8619        );
8620    }
8621
8622    #[test]
8623    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_nul() {
8624        // The fail-before-pass-after pin for the load-bearing NUL byte:
8625        // POSIX paths cannot contain `0x00` (every `std::fs` syscall
8626        // routes the path through `CString::new` which fails with
8627        // `NulError`); until this gate landed a `:caminho
8628        // "../caixa\0teia"` silently passed validate, the lacre
8629        // pipeline embedded the value verbatim, and the failure
8630        // surfaced at the resolver's `Path::join` → `CString::new`
8631        // boundary with a non-self-locating `NulError` far from the
8632        // source caixa.lisp. The new gate moves the check to validate
8633        // time and names the offending dep + caminho + offending byte
8634        // verbatim.
8635        let d = dep_with_fonte(DepSource::Path {
8636            caminho: "../caixa\0teia".into(),
8637        });
8638        let err = d.validate().unwrap_err();
8639        let DepError::FonteCaminhoControlChar {
8640            nome,
8641            caminho,
8642            byte,
8643        } = err
8644        else {
8645            panic!("expected FonteCaminhoControlChar, got {err:?}");
8646        };
8647        assert_eq!(nome, "caixa-teia");
8648        assert_eq!(caminho, "../caixa\0teia");
8649        assert_eq!(byte, 0x00);
8650    }
8651
8652    #[test]
8653    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_newline() {
8654        // The canonical paste-from-multiline-doc footgun on `:caminho`
8655        // — author copies `"../caixa-teia\n"` (trailing newline) out
8656        // of a multi-line code-fence or, worse, a `:caminho
8657        // "../caixa-teia\nrm -rf /"` value (CRLF-at-subprocess-argument
8658        // injection sibling on the path axis the `is_git_repo_url`
8659        // control-char arm already closes on `:repo`). Pinned
8660        // separately from the NUL arm so a future relaxation that
8661        // catches one but not the other surfaces here.
8662        let d = dep_with_fonte(DepSource::Path {
8663            caminho: "../caixa-teia\n".into(),
8664        });
8665        let err = d.validate().unwrap_err();
8666        let DepError::FonteCaminhoControlChar { byte, .. } = err else {
8667            panic!("expected FonteCaminhoControlChar, got {err:?}");
8668        };
8669        assert_eq!(byte, 0x0A);
8670    }
8671
8672    #[test]
8673    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_carriage_return() {
8674        // The CRLF sibling of the LF arm — Windows-line-ending
8675        // paste-from-multiline-doc on a `\r\n`-terminated buffer
8676        // leaves a stray `\r` mid-string after the LF strip. Pinned
8677        // separately from the LF arm so a future relaxation that
8678        // only catches LF surfaces here.
8679        let d = dep_with_fonte(DepSource::Path {
8680            caminho: "../caixa-teia\r".into(),
8681        });
8682        let err = d.validate().unwrap_err();
8683        let DepError::FonteCaminhoControlChar { byte, .. } = err else {
8684            panic!("expected FonteCaminhoControlChar, got {err:?}");
8685        };
8686        assert_eq!(byte, 0x0D);
8687    }
8688
8689    #[test]
8690    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_tab() {
8691        // The canonical paste-from-aligned-table footgun — a `\t`
8692        // mid-`:caminho` is invisible in most editors but rides
8693        // through the lacre's content-address verbatim, so two
8694        // paste-from-distinct-tables (one editor strips tabs, one
8695        // preserves them) yield divergent lacres for the byte-
8696        // identical-looking caixa. Pinned separately from the
8697        // whitespace-shaped LF/CR arms so a future relaxation that
8698        // narrows to line-terminator-only surfaces here.
8699        let d = dep_with_fonte(DepSource::Path {
8700            caminho: "../caixa\tteia".into(),
8701        });
8702        let err = d.validate().unwrap_err();
8703        let DepError::FonteCaminhoControlChar { byte, .. } = err else {
8704            panic!("expected FonteCaminhoControlChar, got {err:?}");
8705        };
8706        assert_eq!(byte, 0x09);
8707    }
8708
8709    #[test]
8710    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_del() {
8711        // The DEL byte (`0x7F`) closes the upper-end paste-from-
8712        // binary-blob footgun — the gate's contract is `b < 0x20 ||
8713        // b == 0x7F`, matching the `is_git_repo_url` /
8714        // `is_git_ref_name` predicates' control-char arms. Pinned
8715        // separately from the lower-range arms so a future narrowing
8716        // to `< 0x20` only surfaces here.
8717        let d = dep_with_fonte(DepSource::Path {
8718            caminho: "../caixa\x7fteia".into(),
8719        });
8720        let err = d.validate().unwrap_err();
8721        let DepError::FonteCaminhoControlChar { byte, .. } = err else {
8722            panic!("expected FonteCaminhoControlChar, got {err:?}");
8723        };
8724        assert_eq!(byte, 0x7F);
8725    }
8726
8727    #[test]
8728    fn validate_accepts_path_fonte_with_caminho_carrying_high_bit_utf8() {
8729        // The control-byte arm targets `0x00..=0x1F` + `0x7F` only —
8730        // high-bit / non-ASCII UTF-8 bytes are not gated. POSIX paths
8731        // are opaque byte sequences and UTF-8 multi-byte sequences
8732        // are a legitimate filename shape (the `café-teia/foo` idiom).
8733        // Pinned so the gate doesn't widen to a full ASCII-only sweep
8734        // that would break every legitimate-shape UTF-8 path.
8735        let d = dep_with_fonte(DepSource::Path {
8736            caminho: "../café-teia/foo".into(),
8737        });
8738        d.validate().unwrap();
8739    }
8740
8741    #[test]
8742    fn fonte_caminho_var_fires_before_control_char() {
8743        // Cascade pin: the var-expansion arm structurally precedes the
8744        // control-char arm. A value like `"$\n"` probes positive on
8745        // both arms (`starts_with('$')` and contains LF), but the
8746        // narrower leading-byte diagnostic (`FonteCaminhoVarExpansion`)
8747        // wins so the author sees the more self-locating shell-
8748        // expansion arm first. Mirrors the
8749        // `fonte_caminho_tilde_fires_before_var_expansion` cascade
8750        // discipline on the immediate-predecessor arm.
8751        let d = dep_with_fonte(DepSource::Path {
8752            caminho: "$HOME\n".into(),
8753        });
8754        let err = d.validate().unwrap_err();
8755        assert!(
8756            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
8757            "got {err:?}",
8758        );
8759    }
8760
8761    #[test]
8762    fn validate_rejects_path_fonte_with_leading_space_caminho() {
8763        // The fail-before-pass-after pin for the leading ASCII space
8764        // `:caminho` shape: `(:tipo path :caminho " ../caixa-teia")`.
8765        // Until this gate landed the b94fd83 absolute arm + the a5c248e
8766        // tilde arm + the f4efe9c var arm + the d624c8d control-byte arm
8767        // all let `" ../caixa-teia"` through: `Path::is_absolute` returns
8768        // false on a leading space (the leading byte is `0x20`, not `0x2F`),
8769        // `starts_with('~')` / `starts_with('$')` return false, and `0x20`
8770        // is not in the `0x00..=0x1F` plus `0x7F` control-byte set (the
8771        // four ASCII whitespace bytes `0x09` tab, `0x0A` LF, `0x0D` CR
8772        // are caught, but the most common whitespace `0x20` space is
8773        // not). The lacre embedded the value verbatim and the resolver
8774        // folded it through `Path::join` looking for a literal `./ ../
8775        // caixa-teia` subdirectory and failing at resolve time with a
8776        // non-self-locating `No such file or directory` error far from
8777        // the source caixa.lisp. The new gate moves the check to
8778        // validate time and names the offending dep + caminho verbatim.
8779        let d = dep_with_fonte(DepSource::Path {
8780            caminho: " ../caixa-teia".into(),
8781        });
8782        let err = d.validate().unwrap_err();
8783        let DepError::FonteCaminhoLeadingWhitespace { nome, caminho } = err else {
8784            panic!("expected FonteCaminhoLeadingWhitespace, got {err:?}");
8785        };
8786        assert_eq!(nome, "caixa-teia");
8787        assert_eq!(caminho, " ../caixa-teia");
8788    }
8789
8790    #[test]
8791    fn validate_rejects_path_fonte_with_multiple_leading_spaces_caminho() {
8792        // The aligned-doc paste footgun sweep: more than one leading
8793        // space (`"   ../caixa-teia"` — the canonical "I selected the
8794        // aligned column from a four-`:fonte`-entry `:deps` block"
8795        // paste) routes through the same gate's `starts_with(' ')`
8796        // byte check. Pinned so the gate doesn't narrow to a
8797        // single-space prefix.
8798        let d = dep_with_fonte(DepSource::Path {
8799            caminho: "   ../caixa-teia".into(),
8800        });
8801        let err = d.validate().unwrap_err();
8802        assert!(
8803            matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
8804            "got {err:?}",
8805        );
8806    }
8807
8808    #[test]
8809    fn validate_accepts_path_fonte_with_mid_path_space_caminho() {
8810        // The leading-space is the canonical paste-from-aligned-doc
8811        // footgun — a space mid-path (`"../my dir/caixa-teia"` — the
8812        // canonical "I have a directory with a space in its name"
8813        // idiom; ASCII `0x20` is a valid POSIX filename byte) is a
8814        // legitimate path with no whitespace-leak semantic at the
8815        // non-leading position. Pinned so the gate doesn't widen to a
8816        // full no-space-anywhere sweep that would break every
8817        // legitimate-shape space-in-filename path.
8818        let d = dep_with_fonte(DepSource::Path {
8819            caminho: "../my dir/caixa-teia".into(),
8820        });
8821        d.validate().unwrap();
8822    }
8823
8824    #[test]
8825    fn fonte_caminho_var_fires_before_leading_whitespace() {
8826        // Cascade pin: the var-expansion arm structurally precedes the
8827        // leading-whitespace arm. A value like `"$ "` would probe positive
8828        // on var (`starts_with('$')`) but the leading-byte arms walk
8829        // left-to-right so the var arm fires on the leading `$` before
8830        // the leading-whitespace arm probes. Mirrors the
8831        // `fonte_caminho_tilde_fires_before_var_expansion` cascade
8832        // discipline on the immediate-predecessor arms.
8833        let d = dep_with_fonte(DepSource::Path {
8834            caminho: "$VAR".into(),
8835        });
8836        let err = d.validate().unwrap_err();
8837        assert!(
8838            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
8839            "got {err:?}",
8840        );
8841    }
8842
8843    #[test]
8844    fn fonte_caminho_leading_whitespace_fires_before_control_char() {
8845        // Cascade pin: the leading-whitespace arm structurally precedes
8846        // the control-char arm. A value like `" ../foo\n"` probes
8847        // positive on both (starts with space AND contains LF), but
8848        // the narrower leading-byte diagnostic
8849        // (`FonteCaminhoLeadingWhitespace`) wins so the author sees the
8850        // more self-locating paste-from-aligned-doc arm first. Mirrors
8851        // the `fonte_caminho_var_fires_before_control_char` cascade
8852        // discipline on the immediate-predecessor arm.
8853        let d = dep_with_fonte(DepSource::Path {
8854            caminho: " ../foo\n".into(),
8855        });
8856        let err = d.validate().unwrap_err();
8857        assert!(
8858            matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
8859            "got {err:?}",
8860        );
8861    }
8862
8863    #[test]
8864    fn fonte_caminho_leading_whitespace_diagnostic_carries_offending_dep_and_caminho() {
8865        // Diagnostic-shape pin (peer with
8866        // `fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho`'s
8867        // payload assertion on the immediate-predecessor arm): the
8868        // error's Display surfaces both the offending `:nome` and the
8869        // offending `:caminho` verbatim, so a `feira lint` run can
8870        // render the diagnostic without re-parsing and the author can
8871        // grep their caixa.lisp for `:caminho "<value>"` and fix it in
8872        // one edit.
8873        let d = dep_with_fonte(DepSource::Path {
8874            caminho: " ../caixa-teia".into(),
8875        });
8876        let rendered = d.validate().unwrap_err().to_string();
8877        assert!(
8878            rendered.contains("caixa-teia"),
8879            "diagnostic must name the offending dep: {rendered}",
8880        );
8881        assert!(
8882            rendered.contains(" ../caixa-teia"),
8883            "diagnostic must quote the offending caminho: {rendered}",
8884        );
8885        assert!(
8886            rendered.contains("space"),
8887            "diagnostic must name the space footgun: {rendered}",
8888        );
8889    }
8890
8891    #[test]
8892    fn fonte_caminho_absolute_fires_before_control_char() {
8893        // Cascade pin on the sibling leading-byte arm: a leading `/`
8894        // value with embedded control byte (`"/etc/passwd\n"`) routes
8895        // through `FonteCaminhoAbsolute` not `FonteCaminhoControlChar`
8896        // — the host-layout-leak diagnostic is the load-bearing axis,
8897        // the control byte is the secondary observation. Same precedence
8898        // logic on every prior leading-byte arm.
8899        let d = dep_with_fonte(DepSource::Path {
8900            caminho: "/etc/passwd\n".into(),
8901        });
8902        let err = d.validate().unwrap_err();
8903        assert!(
8904            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
8905            "got {err:?}",
8906        );
8907    }
8908
8909    #[test]
8910    fn validate_rejects_path_fonte_with_leading_hyphen_caminho() {
8911        // The fail-before-pass-after pin for the leading-`-` CLI-arg-
8912        // injection `:caminho` shape sweep. Until this gate landed
8913        // every prior leading-byte arm passed a leading-`-` value
8914        // through: `Path::is_absolute` returns false on `-` (the
8915        // leading byte is `0x2D`, not `0x2F`), `starts_with('~')` /
8916        // `starts_with('$')` / `starts_with(' ')` all return false,
8917        // and `0x2D` sits outside the control-byte set. The lacre
8918        // embedded the value verbatim and the resolver folded it
8919        // through `Path::join` looking for a literal `./-rf` /
8920        // `./-C` / `./--upload-pack=…` subdirectory; the failure at
8921        // `Path::join` time is non-self-locating but harmless, while
8922        // the failure at every downstream `git -C {caminho}` /
8923        // `terraform -chdir={caminho}` / `find {caminho}` shell-out
8924        // is arbitrary-CLI-arg-injection because none of those
8925        // porcelains carry a `--` argument-list terminator between
8926        // the flag block and the path argument. The new arm moves the
8927        // rejection to `Caixa::from_lisp` boundary time and names
8928        // the offending dep + caminho verbatim.
8929        //
8930        // Sweep spans the canonical CLI-arg-injection shapes matching
8931        // the peer sweep on the sibling `is_git_ref_name` /
8932        // `is_git_repo_url` axes: short-flag `-rf` (the `rm -rf` /
8933        // `find -rf` reinterpretation vector), `-C` (the `git -C`
8934        // change-directory-config-injection paste), long-flag
8935        // `--upload-pack=cat /etc/passwd` (the canonical
8936        // arbitrary-command-execution vector on every git porcelain
8937        // entry point), git-config-injection `--config=core.merge=ours`,
8938        // and the degenerate single-byte `-` value.
8939        for caminho in [
8940            "-rf",
8941            "-C",
8942            "--upload-pack=cat /etc/passwd",
8943            "--config=core.merge=ours",
8944            "-",
8945        ] {
8946            let d = dep_with_fonte(DepSource::Path {
8947                caminho: caminho.into(),
8948            });
8949            let err = d.validate().unwrap_err();
8950            let DepError::FonteCaminhoLeadingHyphen { nome, caminho: got } = err else {
8951                panic!("expected FonteCaminhoLeadingHyphen for {caminho:?}, got {err:?}");
8952            };
8953            assert_eq!(nome, "caixa-teia");
8954            assert_eq!(got, caminho);
8955        }
8956    }
8957
8958    #[test]
8959    fn validate_accepts_path_fonte_with_mid_path_hyphen_caminho() {
8960        // The leading-`-` is the canonical CLI-arg-injection footgun
8961        // — a `-` anywhere else in the path (`"../caixa-teia"` — the
8962        // canonical kebab-separator-between-alphanumeric-segments
8963        // shape every DNS-1123-shaped caixa name carries; `"../-hidden"`
8964        // — a mid-path segment starting with `-`, still a legitimate
8965        // POSIX filename byte at that non-leading position because the
8966        // subprocess reads the whole `{caminho}` value as one positional
8967        // argument, so only the very first byte of the composite path
8968        // string is at the CLI-arg-injection boundary) is a legitimate
8969        // path with no CLI-flag-reinterpretation semantic at the non-
8970        // leading position of the top-level value. Pinned so the gate
8971        // doesn't widen to a full no-`-`-anywhere sweep that would
8972        // break every legitimate-shape kebab-in-filename path (i.e.
8973        // essentially every sibling-workspace caixa dep).
8974        for caminho in [
8975            "../caixa-teia",
8976            "../caixa-teia/-hidden",
8977            "./my-lib",
8978            "../foo-bar/baz",
8979        ] {
8980            let d = dep_with_fonte(DepSource::Path {
8981                caminho: caminho.into(),
8982            });
8983            d.validate()
8984                .unwrap_or_else(|e| panic!("mid-path `-` caminho {caminho:?} must pass: {e:?}"));
8985        }
8986    }
8987
8988    #[test]
8989    fn fonte_caminho_leading_whitespace_fires_before_leading_hyphen() {
8990        // Cascade pin: the leading-whitespace arm structurally precedes
8991        // the leading-hyphen arm. A value like `" -rf"` probes positive
8992        // on both (leading space AND, one byte in, a `-` — though the
8993        // leading-hyphen arm probes only the very first byte so it
8994        // wouldn't fire on this value; the pin instead documents the
8995        // arm order on the more common "leading space then a hyphen"
8996        // paste-from-aligned-doc paste-flag-shell-one-liner idiom).
8997        // The narrower leading-space diagnostic (the paste-from-aligned-
8998        // doc footgun) wins so the author sees the more self-locating
8999        // whitespace arm first. Mirrors the
9000        // `fonte_caminho_var_fires_before_leading_whitespace` cascade
9001        // discipline on the immediate-predecessor arm.
9002        let d = dep_with_fonte(DepSource::Path {
9003            caminho: " -rf".into(),
9004        });
9005        let err = d.validate().unwrap_err();
9006        assert!(
9007            matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
9008            "got {err:?}",
9009        );
9010    }
9011
9012    #[test]
9013    fn fonte_caminho_leading_hyphen_fires_before_control_char() {
9014        // Cascade pin: the leading-hyphen arm structurally precedes
9015        // the control-char arm. A value like `"-rf\n"` probes positive
9016        // on both (starts with `-` AND contains LF), but the narrower
9017        // leading-byte diagnostic (`FonteCaminhoLeadingHyphen`) wins so
9018        // the author sees the more self-locating CLI-arg-injection arm
9019        // first. Mirrors the
9020        // `fonte_caminho_leading_whitespace_fires_before_control_char`
9021        // cascade discipline on the immediate-predecessor arm.
9022        let d = dep_with_fonte(DepSource::Path {
9023            caminho: "-rf\n".into(),
9024        });
9025        let err = d.validate().unwrap_err();
9026        assert!(
9027            matches!(err, DepError::FonteCaminhoLeadingHyphen { .. }),
9028            "got {err:?}",
9029        );
9030    }
9031
9032    #[test]
9033    fn fonte_caminho_leading_hyphen_diagnostic_carries_offending_dep_and_caminho() {
9034        // Diagnostic-shape pin (peer with
9035        // `fonte_caminho_leading_whitespace_diagnostic_carries_offending_dep_and_caminho`'s
9036        // payload assertion on the immediate-predecessor arm): the
9037        // error's Display surfaces both the offending `:nome` and the
9038        // offending `:caminho` verbatim plus the CLI-argument-injection
9039        // vocabulary, so a `feira lint` run can render the diagnostic
9040        // without re-parsing and the author can grep their caixa.lisp
9041        // for `:caminho "<value>"` and fix it in one edit.
9042        let d = dep_with_fonte(DepSource::Path {
9043            caminho: "--upload-pack=cat /etc/passwd".into(),
9044        });
9045        let rendered = d.validate().unwrap_err().to_string();
9046        assert!(
9047            rendered.contains("caixa-teia"),
9048            "diagnostic must name the offending dep: {rendered}",
9049        );
9050        assert!(
9051            rendered.contains("--upload-pack=cat /etc/passwd"),
9052            "diagnostic must quote the offending caminho: {rendered}",
9053        );
9054        assert!(
9055            rendered.contains("CLI-argument-injection"),
9056            "diagnostic must name the CLI-argument-injection vector: {rendered}",
9057        );
9058        assert!(
9059            rendered.contains("`-`"),
9060            "diagnostic must name the offending byte: {rendered}",
9061        );
9062    }
9063
9064    #[test]
9065    fn fonte_caminho_control_diagnostic_carries_offending_dep_caminho_byte() {
9066        // Diagnostic-shape pin (peer with
9067        // `fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho`'s
9068        // payload assertion on the immediate-predecessor arm): the
9069        // error's Display surfaces the offending `:nome`, the
9070        // offending `:caminho` verbatim, and the offending byte in
9071        // hex form (`0x09` for tab) so a `feira lint` run can render
9072        // the diagnostic without re-parsing.
9073        let d = dep_with_fonte(DepSource::Path {
9074            caminho: "../caixa\tteia".into(),
9075        });
9076        let rendered = d.validate().unwrap_err().to_string();
9077        assert!(
9078            rendered.contains("caixa-teia"),
9079            "diagnostic must name the offending dep: {rendered}",
9080        );
9081        assert!(
9082            rendered.contains("../caixa\tteia"),
9083            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
9084        );
9085        assert!(
9086            rendered.contains("0x09"),
9087            "diagnostic must name the offending byte in hex: {rendered:?}",
9088        );
9089    }
9090
9091    #[test]
9092    fn validate_rejects_path_fonte_with_caminho_carrying_backslash() {
9093        // The fail-before-pass-after pin for the canonical Windows-
9094        // path-separator paste footgun: an author who pastes a path
9095        // from Windows-Explorer's `Copy as path`, PowerShell's
9096        // `Get-Location`, or any CMD/Cygwin/MSYS shell prompt
9097        // produces `..\caixa-teia`-shape values that silently passed
9098        // every prior arm (`Path::is_absolute("..\\caixa-teia")` is
9099        // false; `\` is neither a leading-byte sentinel nor a
9100        // control byte). On POSIX resolvers the value rides through
9101        // `Path::join` as a literal directory name and fails at
9102        // resolve time with `No such file or directory`; on Windows
9103        // resolvers the value resolves to the parent's sibling — two
9104        // distinct directories for the byte-identical caixa.lisp.
9105        // The new arm moves the rejection to validate time and names
9106        // the offending dep + caminho verbatim.
9107        let d = dep_with_fonte(DepSource::Path {
9108            caminho: "..\\caixa-teia".into(),
9109        });
9110        let err = d.validate().unwrap_err();
9111        let DepError::FonteCaminhoBackslash { nome, caminho } = err else {
9112            panic!("expected FonteCaminhoBackslash, got {err:?}");
9113        };
9114        assert_eq!(nome, "caixa-teia");
9115        assert_eq!(caminho, "..\\caixa-teia");
9116    }
9117
9118    #[test]
9119    fn validate_rejects_path_fonte_with_caminho_carrying_windows_drive_letter() {
9120        // The Windows drive-letter paste shape (`C:\work\caixa-teia`
9121        // out of Explorer / `cd`-and-`pwd`-on-Windows). On POSIX
9122        // hosts `Path::is_absolute("C:\\work\\caixa-teia")` returns
9123        // false (POSIX absolute paths start with `/`, drive letters
9124        // are not a POSIX concept), so the b94fd83 absolute arm
9125        // doesn't fire; the value contains `\` bytes that this arm
9126        // now catches with the more self-locating Windows-path-
9127        // separator diagnostic. Pinned separately from the bare
9128        // `..\caixa-teia` shape so a future arm that targets only
9129        // leading-`..\` doesn't regress the drive-letter coverage.
9130        let d = dep_with_fonte(DepSource::Path {
9131            caminho: "C:\\work\\caixa-teia".into(),
9132        });
9133        let err = d.validate().unwrap_err();
9134        assert!(
9135            matches!(err, DepError::FonteCaminhoBackslash { .. }),
9136            "got {err:?}",
9137        );
9138    }
9139
9140    #[test]
9141    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_backslash() {
9142        // The trailing-`\` shape (`..\caixa-teia\` — the canonical
9143        // PowerShell tab-completion-on-a-directory append). Pinned
9144        // separately from the embedded-`\` shape so the gate's
9145        // contract is "any `\` anywhere", not "any `\` not at end".
9146        let d = dep_with_fonte(DepSource::Path {
9147            caminho: "..\\caixa-teia\\".into(),
9148        });
9149        let err = d.validate().unwrap_err();
9150        assert!(
9151            matches!(err, DepError::FonteCaminhoBackslash { .. }),
9152            "got {err:?}",
9153        );
9154    }
9155
9156    #[test]
9157    fn validate_accepts_path_fonte_with_caminho_carrying_legitimate_forward_slash() {
9158        // The positive-control pin: the gate targets `\` only,
9159        // never `/`. The canonical relative POSIX path
9160        // (`../caixa-teia/foo/bar`) must continue to validate cleanly
9161        // so legitimate nested-directory deps aren't broken. Pinned
9162        // so the gate doesn't accidentally widen to a "no path
9163        // separators at all" sweep.
9164        let d = dep_with_fonte(DepSource::Path {
9165            caminho: "../caixa-teia/foo/bar".into(),
9166        });
9167        d.validate().unwrap();
9168    }
9169
9170    #[test]
9171    fn fonte_caminho_control_char_fires_before_backslash() {
9172        // Cascade pin: the control-char arm structurally precedes the
9173        // backslash arm. A value like `"..\caixa\0teia"` probes
9174        // positive on both (`\` byte + NUL byte), but the control-
9175        // char diagnostic wins so the author sees the more self-
9176        // locating POSIX-syscall-rejected-byte diagnostic first
9177        // (NUL outright breaks `CString::new` at every `std::fs`
9178        // syscall boundary; the `\` divergence is the cross-OS-
9179        // separator axis). Mirrors the
9180        // `fonte_caminho_var_fires_before_control_char` cascade
9181        // discipline on the immediate-predecessor arm.
9182        let d = dep_with_fonte(DepSource::Path {
9183            caminho: "..\\caixa\0teia".into(),
9184        });
9185        let err = d.validate().unwrap_err();
9186        assert!(
9187            matches!(err, DepError::FonteCaminhoControlChar { .. }),
9188            "got {err:?}",
9189        );
9190    }
9191
9192    #[test]
9193    fn fonte_caminho_absolute_fires_before_backslash() {
9194        // Cascade pin on the load-bearing leading-byte arm: a leading
9195        // `/` value with embedded `\` (`/etc/passwd\foo`) routes
9196        // through `FonteCaminhoAbsolute` not `FonteCaminhoBackslash`
9197        // — the host-layout-leak diagnostic is the load-bearing
9198        // axis, the `\` byte is the secondary observation. Same
9199        // precedence logic as every prior leading-byte arm.
9200        let d = dep_with_fonte(DepSource::Path {
9201            caminho: "/etc/passwd\\foo".into(),
9202        });
9203        let err = d.validate().unwrap_err();
9204        assert!(
9205            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
9206            "got {err:?}",
9207        );
9208    }
9209
9210    #[test]
9211    fn fonte_caminho_var_fires_before_backslash() {
9212        // Cascade pin on the var-expansion arm: a leading-`$` value
9213        // with embedded `\` (`$WORKSPACE\caixa-teia` — the canonical
9214        // PowerShell-env-var paste-from-CI-manifest footgun) routes
9215        // through `FonteCaminhoVarExpansion` not `FonteCaminhoBackslash`.
9216        // The shell-expansion diagnostic is the more self-locating
9217        // axis since both the leading `$` and the embedded `\`
9218        // are Windows-shell artifacts but the `$` is the root-cause
9219        // surface (an author who removes the `$` is likely to leave
9220        // the `\` too).
9221        let d = dep_with_fonte(DepSource::Path {
9222            caminho: "$WORKSPACE\\caixa-teia".into(),
9223        });
9224        let err = d.validate().unwrap_err();
9225        assert!(
9226            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
9227            "got {err:?}",
9228        );
9229    }
9230
9231    #[test]
9232    fn fonte_caminho_backslash_diagnostic_carries_offending_dep_and_caminho() {
9233        // Diagnostic-shape pin (peer with the prior
9234        // `fonte_caminho_*_diagnostic_carries_*` payload assertions
9235        // on every preceding arm): the error's Display surfaces the
9236        // offending `:nome` and the offending `:caminho` verbatim
9237        // so a `feira lint` run can render the diagnostic without
9238        // re-parsing.
9239        let d = dep_with_fonte(DepSource::Path {
9240            caminho: "..\\caixa-teia".into(),
9241        });
9242        let rendered = d.validate().unwrap_err().to_string();
9243        assert!(
9244            rendered.contains("caixa-teia"),
9245            "diagnostic must name the offending dep: {rendered}",
9246        );
9247        assert!(
9248            rendered.contains("..\\caixa-teia"),
9249            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
9250        );
9251        assert!(
9252            rendered.contains('\\'),
9253            "diagnostic must reference the backslash footgun: {rendered:?}",
9254        );
9255    }
9256
9257    #[test]
9258    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_slash() {
9259        // The fail-before-pass-after pin for the canonical trailing-`/`
9260        // paste footgun: an author who shell-tab-completes a sibling
9261        // directory (every interactive shell — bash/zsh/fish/nushell —
9262        // appends `/` on tab-completing a directory) produces
9263        // `"../caixa-teia/"`-shape values that silently passed every
9264        // prior arm (the leading byte is `.`, no control bytes, no
9265        // backslash). `Path::join` resolves both shapes to the same
9266        // directory at the resolver, but the lacre embeds the value
9267        // verbatim and the BLAKE3 closures diverge across two
9268        // workstations whose authors differ only in tab-completion
9269        // habits.
9270        let d = dep_with_fonte(DepSource::Path {
9271            caminho: "../caixa-teia/".into(),
9272        });
9273        let err = d.validate().unwrap_err();
9274        let DepError::FonteCaminhoTrailingSlash { nome, caminho } = err else {
9275            panic!("expected FonteCaminhoTrailingSlash, got {err:?}");
9276        };
9277        assert_eq!(nome, "caixa-teia");
9278        assert_eq!(caminho, "../caixa-teia/");
9279    }
9280
9281    #[test]
9282    fn validate_rejects_path_fonte_with_caminho_carrying_bare_dot_slash() {
9283        // The `"./"` shape (the canonical "I meant the caixa.lisp's own
9284        // directory and tab-completed it" footgun). Pinned separately
9285        // from the canonical `"../caixa-teia/"` shape so the gate's
9286        // contract is "any trailing `/`", not "trailing `/` after a leaf
9287        // name".
9288        let d = dep_with_fonte(DepSource::Path {
9289            caminho: "./".into(),
9290        });
9291        let err = d.validate().unwrap_err();
9292        assert!(
9293            matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
9294            "got {err:?}",
9295        );
9296    }
9297
9298    #[test]
9299    fn validate_rejects_path_fonte_with_caminho_carrying_consecutive_trailing_slashes() {
9300        // The `"foo//"` shape (the canonical "I pasted from a CI manifest
9301        // that double-templated `${VAR}/` over an already-`/`-suffixed
9302        // path" footgun). The gate fires on the last byte being `/`
9303        // regardless of how many `/` precede it; the arm contract is
9304        // "the value ends with `/`", structurally.
9305        let d = dep_with_fonte(DepSource::Path {
9306            caminho: "../caixa-teia//".into(),
9307        });
9308        let err = d.validate().unwrap_err();
9309        assert!(
9310            matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
9311            "got {err:?}",
9312        );
9313    }
9314
9315    #[test]
9316    fn validate_rejects_path_fonte_with_caminho_carrying_dotdot_trailing_slash() {
9317        // The `"../"` shape (the canonical "I want the parent" tab-
9318        // completion footgun on a bare `..` path). Pinned separately so
9319        // the gate doesn't accidentally narrow to "trailing `/` only on
9320        // multi-segment paths".
9321        let d = dep_with_fonte(DepSource::Path {
9322            caminho: "../".into(),
9323        });
9324        let err = d.validate().unwrap_err();
9325        assert!(
9326            matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
9327            "got {err:?}",
9328        );
9329    }
9330
9331    #[test]
9332    fn validate_accepts_path_fonte_with_caminho_carrying_internal_slashes() {
9333        // The positive-control pin: the gate targets the trailing byte
9334        // only, never internal `/` separators. The canonical nested
9335        // relative POSIX path (`"../caixa-teia/foo/bar"`) must continue
9336        // to validate cleanly so legitimate deeply-nested deps aren't
9337        // broken. Pinned so the gate doesn't accidentally widen to a
9338        // "no `/` separators anywhere" sweep that would defeat the
9339        // entire path-fonte author surface.
9340        let d = dep_with_fonte(DepSource::Path {
9341            caminho: "../caixa-teia/foo/bar".into(),
9342        });
9343        d.validate().unwrap();
9344    }
9345
9346    #[test]
9347    fn validate_accepts_path_fonte_with_caminho_carrying_bare_dot() {
9348        // The positive-control pin on the degenerate single-`.` shape
9349        // (the canonical "the caixa.lisp's own directory" idiom). The
9350        // gate fires on the trailing byte being `/`, not on the path
9351        // being short, so `"."` (one byte, not `/`) must continue to
9352        // validate cleanly.
9353        let d = dep_with_fonte(DepSource::Path {
9354            caminho: ".".into(),
9355        });
9356        d.validate().unwrap();
9357    }
9358
9359    #[test]
9360    fn fonte_caminho_control_char_fires_before_trailing_slash() {
9361        // Cascade pin: the control-char arm structurally precedes the
9362        // trailing-slash arm. A value like `"../foo\n/"` ends in `/`
9363        // but the embedded LF (`0x0A`) is the load-bearing diagnostic
9364        // (control bytes are the paste-from-multiline-doc footgun the
9365        // d624c8d arm already closes). Mirrors the
9366        // `fonte_caminho_control_char_fires_before_backslash` cascade
9367        // discipline on the immediate-predecessor arm.
9368        let d = dep_with_fonte(DepSource::Path {
9369            caminho: "../foo\n/".into(),
9370        });
9371        let err = d.validate().unwrap_err();
9372        assert!(
9373            matches!(err, DepError::FonteCaminhoControlChar { .. }),
9374            "got {err:?}",
9375        );
9376    }
9377
9378    #[test]
9379    fn fonte_caminho_backslash_fires_before_trailing_slash() {
9380        // Cascade pin on the backslash arm: a value like `"..\foo/"`
9381        // ends in `/` but the embedded `\` is the load-bearing
9382        // diagnostic (the cross-host-OS-separator divergence vector
9383        // the 3a4e1d7 arm closes). Same precedence logic as the prior
9384        // narrower-diagnostic-first cascade.
9385        let d = dep_with_fonte(DepSource::Path {
9386            caminho: "..\\caixa-teia/".into(),
9387        });
9388        let err = d.validate().unwrap_err();
9389        assert!(
9390            matches!(err, DepError::FonteCaminhoBackslash { .. }),
9391            "got {err:?}",
9392        );
9393    }
9394
9395    #[test]
9396    fn fonte_caminho_absolute_fires_before_trailing_slash() {
9397        // Cascade pin on the load-bearing leading-byte arm: a leading
9398        // `/` value with a trailing `/` (`"/etc/passwd/"`) routes
9399        // through `FonteCaminhoAbsolute` not `FonteCaminhoTrailingSlash`
9400        // — the host-layout-leak diagnostic is the load-bearing axis,
9401        // the trailing `/` is the secondary observation. Same
9402        // precedence logic as every prior leading-byte arm.
9403        let d = dep_with_fonte(DepSource::Path {
9404            caminho: "/etc/passwd/".into(),
9405        });
9406        let err = d.validate().unwrap_err();
9407        assert!(
9408            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
9409            "got {err:?}",
9410        );
9411    }
9412
9413    #[test]
9414    fn fonte_caminho_trailing_slash_diagnostic_carries_offending_dep_and_caminho() {
9415        // Diagnostic-shape pin (peer with the prior
9416        // `fonte_caminho_*_diagnostic_carries_*` payload assertions on
9417        // every preceding arm): the error's Display surfaces the
9418        // offending `:nome` and the offending `:caminho` verbatim so a
9419        // `feira lint` run can render the diagnostic without re-parsing.
9420        let d = dep_with_fonte(DepSource::Path {
9421            caminho: "../caixa-teia/".into(),
9422        });
9423        let rendered = d.validate().unwrap_err().to_string();
9424        assert!(
9425            rendered.contains("caixa-teia"),
9426            "diagnostic must name the offending dep: {rendered}",
9427        );
9428        assert!(
9429            rendered.contains("../caixa-teia/"),
9430            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
9431        );
9432        assert!(
9433            rendered.contains("trailing"),
9434            "diagnostic must reference the trailing-slash footgun: {rendered:?}",
9435        );
9436    }
9437
9438    // -- :caminho shell-redirection metacharacter arm -----------------------
9439
9440    #[test]
9441    fn validate_rejects_path_fonte_with_caminho_carrying_gt_redirection() {
9442        // The fail-before-pass-after pin for the canonical output-redirection
9443        // paste footgun: an author copies a shell pipeline tail
9444        // (`"../caixa-teia>build.log"` — the canonical "I selected the whole
9445        // line including the `> build.log` redirect" idiom) and silently
9446        // passed every prior arm (`Path::is_absolute` false on `..`, no
9447        // control bytes, no backslash, doesn't end in `/`). The lacre
9448        // embedded the value verbatim, the resolver folded it through
9449        // `Path::join` looking for a literal `./../caixa-teia>build.log`
9450        // subdirectory, and the failure surfaced at resolve time with a
9451        // non-self-locating `No such file or directory` error. The new arm
9452        // moves the rejection to validate time and names the offending dep
9453        // + caminho + byte verbatim.
9454        let d = dep_with_fonte(DepSource::Path {
9455            caminho: "../caixa-teia>build.log".into(),
9456        });
9457        let err = d.validate().unwrap_err();
9458        let DepError::FonteCaminhoShellRedirection {
9459            nome,
9460            caminho,
9461            byte,
9462        } = err
9463        else {
9464            panic!("expected FonteCaminhoShellRedirection, got {err:?}");
9465        };
9466        assert_eq!(nome, "caixa-teia");
9467        assert_eq!(caminho, "../caixa-teia>build.log");
9468        assert_eq!(byte, b'>');
9469    }
9470
9471    #[test]
9472    fn validate_rejects_path_fonte_with_caminho_carrying_lt_redirection() {
9473        // The symmetric input-redirection paste shape
9474        // (`"../caixa-teia<input.lisp"` — the canonical "I copied a
9475        // `command < input.lisp` line from a tatara-lisp REPL log"
9476        // idiom). Pinned separately from the `>` shape so the gate's
9477        // contract is "any `<` or `>` anywhere", not single-byte coverage.
9478        let d = dep_with_fonte(DepSource::Path {
9479            caminho: "../caixa-teia<input.lisp".into(),
9480        });
9481        let err = d.validate().unwrap_err();
9482        let DepError::FonteCaminhoShellRedirection { byte, .. } = err else {
9483            panic!("expected FonteCaminhoShellRedirection, got {err:?}");
9484        };
9485        assert_eq!(byte, b'<');
9486    }
9487
9488    #[test]
9489    fn validate_rejects_path_fonte_with_caminho_carrying_leading_gt_redirection() {
9490        // Leading-position `>` shape (`">../caixa-teia"` — the degenerate
9491        // "I forgot the source side of the redirect" idiom). Pinned
9492        // separately from the embedded-byte shapes so the gate covers
9493        // every position, not only mid-path.
9494        let d = dep_with_fonte(DepSource::Path {
9495            caminho: ">../caixa-teia".into(),
9496        });
9497        let err = d.validate().unwrap_err();
9498        assert!(
9499            matches!(
9500                err,
9501                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
9502            ),
9503            "got {err:?}",
9504        );
9505    }
9506
9507    #[test]
9508    fn validate_rejects_path_fonte_with_caminho_carrying_double_gt_append() {
9509        // The bash append-redirection shape (`"../caixa-teia>>build.log"` —
9510        // the canonical "I copied a `>>` append redirect" idiom). The arm
9511        // fires on the first `>` encountered; pinned so a future arm that
9512        // tries to distinguish `>` from `>>` doesn't break the broader
9513        // contract.
9514        let d = dep_with_fonte(DepSource::Path {
9515            caminho: "../caixa-teia>>build.log".into(),
9516        });
9517        let err = d.validate().unwrap_err();
9518        assert!(
9519            matches!(
9520                err,
9521                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
9522            ),
9523            "got {err:?}",
9524        );
9525    }
9526
9527    #[test]
9528    fn validate_accepts_path_fonte_with_caminho_carrying_no_redirection() {
9529        // The positive-control pin: the gate targets only `<` / `>`,
9530        // never adjacent printable ASCII or POSIX-valid bytes. The
9531        // canonical relative POSIX path (`"../caixa-teia"`) and a
9532        // nested deeply-pathed variant (`"../caixa-teia/foo/bar"`) must
9533        // continue to validate cleanly so the gate doesn't widen to a
9534        // "no printable punctuation anywhere" sweep that would defeat
9535        // the entire path-fonte author surface.
9536        let d = dep_with_fonte(DepSource::Path {
9537            caminho: "../caixa-teia/foo/bar".into(),
9538        });
9539        d.validate().unwrap();
9540    }
9541
9542    #[test]
9543    fn fonte_caminho_backslash_fires_before_shell_redirection() {
9544        // Cascade pin on the immediate-predecessor arm: a value carrying
9545        // both `\` and `<` / `>` (`"..\caixa-teia>build.log"` — the
9546        // canonical "I pasted a Windows-shell command with output
9547        // redirect" footgun) routes through `FonteCaminhoBackslash` not
9548        // `FonteCaminhoShellRedirection`. The cross-host-OS-separator
9549        // divergence is the load-bearing axis (an author who removes
9550        // the `\` is the root-cause edit; the `>` falls away in the
9551        // same edit since it's downstream of the Windows-shell
9552        // convention).
9553        let d = dep_with_fonte(DepSource::Path {
9554            caminho: "..\\caixa-teia>build.log".into(),
9555        });
9556        let err = d.validate().unwrap_err();
9557        assert!(
9558            matches!(err, DepError::FonteCaminhoBackslash { .. }),
9559            "got {err:?}",
9560        );
9561    }
9562
9563    #[test]
9564    fn fonte_caminho_control_char_fires_before_shell_redirection() {
9565        // Cascade pin on the embedded-control-byte arm: a value carrying
9566        // both a control byte and `<` / `>` (`"../foo\n>bar"` — the
9567        // canonical paste-from-multiline-doc footgun where a newline
9568        // landed mid-caminho) routes through `FonteCaminhoControlChar`
9569        // not `FonteCaminhoShellRedirection`. The POSIX-syscall-
9570        // rejected-byte / NUL-`CString::new`-fail diagnostic is the
9571        // load-bearing axis on every value that probes positive for
9572        // both — mirrors the cascade discipline on every prior arm.
9573        let d = dep_with_fonte(DepSource::Path {
9574            caminho: "../foo\n>bar".into(),
9575        });
9576        let err = d.validate().unwrap_err();
9577        assert!(
9578            matches!(err, DepError::FonteCaminhoControlChar { .. }),
9579            "got {err:?}",
9580        );
9581    }
9582
9583    #[test]
9584    fn fonte_caminho_absolute_fires_before_shell_redirection() {
9585        // Cascade pin on the load-bearing leading-byte arm: a leading
9586        // `/` value with embedded `<` / `>` (`"/etc/passwd>out"`)
9587        // routes through `FonteCaminhoAbsolute` not
9588        // `FonteCaminhoShellRedirection` — the host-layout-leak
9589        // diagnostic is the load-bearing axis, the `>` byte is the
9590        // secondary observation. Same precedence logic as every prior
9591        // leading-byte arm.
9592        let d = dep_with_fonte(DepSource::Path {
9593            caminho: "/etc/passwd>out".into(),
9594        });
9595        let err = d.validate().unwrap_err();
9596        assert!(
9597            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
9598            "got {err:?}",
9599        );
9600    }
9601
9602    #[test]
9603    fn fonte_caminho_shell_redirection_fires_before_trailing_slash() {
9604        // Cascade pin on the immediate-successor arm: a value carrying
9605        // both `<` / `>` and a trailing `/` (`"../foo></"` — the
9606        // canonical "I tab-completed a path that already had a
9607        // redirect" footgun) routes through `FonteCaminhoShellRedirection`
9608        // not `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
9609        // the more semantic-locating axis (an author who removes the
9610        // `<` / `>` typically also drops the trailing separator since
9611        // both are paste-from-shell artifacts).
9612        let d = dep_with_fonte(DepSource::Path {
9613            caminho: "../foo></".into(),
9614        });
9615        let err = d.validate().unwrap_err();
9616        assert!(
9617            matches!(
9618                err,
9619                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
9620            ),
9621            "got {err:?}",
9622        );
9623    }
9624
9625    #[test]
9626    fn fonte_caminho_shell_redirection_diagnostic_carries_offending_dep_caminho_byte() {
9627        // Diagnostic-shape pin (peer with
9628        // `fonte_caminho_control_diagnostic_carries_offending_dep_caminho_byte`'s
9629        // payload assertion on the closest peer arm that also carries a
9630        // `byte` field): the error's Display surfaces the offending
9631        // `:nome`, the offending `:caminho` verbatim, and the offending
9632        // byte in hex (`0x3c` for `<`, `0x3e` for `>`) so a `feira lint`
9633        // run can render the diagnostic without re-parsing.
9634        let d = dep_with_fonte(DepSource::Path {
9635            caminho: "../caixa-teia>build.log".into(),
9636        });
9637        let rendered = d.validate().unwrap_err().to_string();
9638        assert!(
9639            rendered.contains("caixa-teia"),
9640            "diagnostic must name the offending dep: {rendered}",
9641        );
9642        assert!(
9643            rendered.contains("../caixa-teia>build.log"),
9644            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
9645        );
9646        assert!(
9647            rendered.contains("0x3e"),
9648            "diagnostic must name the offending byte in hex: {rendered:?}",
9649        );
9650        assert!(
9651            rendered.contains("redirection"),
9652            "diagnostic must name the shell-redirection footgun: {rendered:?}",
9653        );
9654    }
9655
9656    // -- :caminho shell-pipe metacharacter arm ----------------------------
9657
9658    #[test]
9659    fn validate_rejects_path_fonte_with_caminho_carrying_pipe() {
9660        // The fail-before-pass-after pin for the canonical shell-pipe
9661        // paste footgun: an author copies a shell-history line
9662        // (`"../caixa-teia | grep foo"` — the canonical "I selected
9663        // the whole `ls dir | grep` line out of zsh history") and
9664        // silently passed every prior arm (`Path::is_absolute` false
9665        // on `..`, no control bytes, no backslash, no `<` / `>`,
9666        // doesn't end in `/`). The lacre embedded the value verbatim,
9667        // the resolver folded it through `Path::join` looking for a
9668        // literal `./../caixa-teia | grep foo` subdirectory, and the
9669        // failure surfaced at resolve time with a non-self-locating
9670        // `No such file or directory` error. The new arm moves the
9671        // rejection to validate time and names the offending dep +
9672        // caminho verbatim.
9673        let d = dep_with_fonte(DepSource::Path {
9674            caminho: "../caixa-teia | grep foo".into(),
9675        });
9676        let err = d.validate().unwrap_err();
9677        let DepError::FonteCaminhoShellPipe { nome, caminho } = err else {
9678            panic!("expected FonteCaminhoShellPipe, got {err:?}");
9679        };
9680        assert_eq!(nome, "caixa-teia");
9681        assert_eq!(caminho, "../caixa-teia | grep foo");
9682    }
9683
9684    #[test]
9685    fn validate_rejects_path_fonte_with_caminho_carrying_leading_pipe() {
9686        // Leading-position `|` shape (`"|../caixa-teia"` — the
9687        // degenerate "I forgot the source side of the pipe" idiom).
9688        // Pinned separately from the embedded-byte shape so the gate
9689        // covers every position, not only mid-path.
9690        let d = dep_with_fonte(DepSource::Path {
9691            caminho: "|../caixa-teia".into(),
9692        });
9693        let err = d.validate().unwrap_err();
9694        assert!(
9695            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
9696            "got {err:?}",
9697        );
9698    }
9699
9700    #[test]
9701    fn validate_rejects_path_fonte_with_caminho_carrying_double_pipe_or() {
9702        // The bash short-circuit-OR shape (`"../caixa-teia||fallback"`
9703        // — the canonical "I copied a `cmd-a || cmd-b` fallback line"
9704        // idiom). The arm fires on the first `|` encountered; pinned
9705        // so a future arm that tries to distinguish `|` from `||`
9706        // doesn't break the broader contract.
9707        let d = dep_with_fonte(DepSource::Path {
9708            caminho: "../caixa-teia||fallback".into(),
9709        });
9710        let err = d.validate().unwrap_err();
9711        assert!(
9712            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
9713            "got {err:?}",
9714        );
9715    }
9716
9717    #[test]
9718    fn validate_accepts_path_fonte_with_caminho_carrying_no_pipe() {
9719        // The positive-control pin: the gate targets only `|`, never
9720        // adjacent printable ASCII or POSIX-valid bytes. The canonical
9721        // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
9722        // pathed variant with adjacent printable punctuation
9723        // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
9724        // cleanly so the gate doesn't widen to a "no printable
9725        // punctuation anywhere" sweep that would defeat the entire
9726        // path-fonte author surface.
9727        let d = dep_with_fonte(DepSource::Path {
9728            caminho: "../caixa-teia/sub-dir.v2".into(),
9729        });
9730        d.validate().unwrap();
9731    }
9732
9733    #[test]
9734    fn fonte_caminho_shell_redirection_fires_before_shell_pipe() {
9735        // Cascade pin on the immediate-predecessor arm: a value carrying
9736        // both `<` / `>` and `|` (`"../caixa-teia<input|tee"` — the
9737        // canonical "I pasted a `cmd < input | tee` pipeline tail"
9738        // footgun) routes through `FonteCaminhoShellRedirection` not
9739        // `FonteCaminhoShellPipe`. The input/output redirection
9740        // metachar carries the more self-locating `byte: u8` payload
9741        // (it names which of `<` or `>` triggered), so the prior arm
9742        // wins on every probe-as-both value — same cascade discipline
9743        // every prior `:caminho` arm establishes.
9744        let d = dep_with_fonte(DepSource::Path {
9745            caminho: "../caixa-teia<input|tee".into(),
9746        });
9747        let err = d.validate().unwrap_err();
9748        assert!(
9749            matches!(
9750                err,
9751                DepError::FonteCaminhoShellRedirection { byte: b'<', .. }
9752            ),
9753            "got {err:?}",
9754        );
9755    }
9756
9757    #[test]
9758    fn fonte_caminho_backslash_fires_before_shell_pipe() {
9759        // Cascade pin on the upstream backslash arm: a value carrying
9760        // both `\` and `|` (`"..\caixa-teia|tee"` — the canonical
9761        // "I pasted a Windows-shell command with pipe to tee"
9762        // footgun) routes through `FonteCaminhoBackslash` not
9763        // `FonteCaminhoShellPipe`. The cross-host-OS-separator
9764        // divergence is the load-bearing axis on every probe-as-both
9765        // value (an author who removes the `\` is the root-cause edit;
9766        // the `|` falls away in the same edit since it's downstream of
9767        // the Windows-shell convention).
9768        let d = dep_with_fonte(DepSource::Path {
9769            caminho: "..\\caixa-teia|tee".into(),
9770        });
9771        let err = d.validate().unwrap_err();
9772        assert!(
9773            matches!(err, DepError::FonteCaminhoBackslash { .. }),
9774            "got {err:?}",
9775        );
9776    }
9777
9778    #[test]
9779    fn fonte_caminho_control_char_fires_before_shell_pipe() {
9780        // Cascade pin on the embedded-control-byte arm: a value
9781        // carrying both a control byte and `|` (`"../foo\n|bar"` —
9782        // the canonical paste-from-multiline-doc footgun where a
9783        // newline landed mid-caminho) routes through
9784        // `FonteCaminhoControlChar` not `FonteCaminhoShellPipe`. The
9785        // POSIX-syscall-rejected-byte / NUL-`CString::new`-fail
9786        // diagnostic is the load-bearing axis on every value that
9787        // probes positive for both — mirrors the cascade discipline
9788        // on every prior arm.
9789        let d = dep_with_fonte(DepSource::Path {
9790            caminho: "../foo\n|bar".into(),
9791        });
9792        let err = d.validate().unwrap_err();
9793        assert!(
9794            matches!(err, DepError::FonteCaminhoControlChar { .. }),
9795            "got {err:?}",
9796        );
9797    }
9798
9799    #[test]
9800    fn fonte_caminho_absolute_fires_before_shell_pipe() {
9801        // Cascade pin on the load-bearing leading-byte arm: a leading
9802        // `/` value with embedded `|` (`"/etc/passwd|tee"`) routes
9803        // through `FonteCaminhoAbsolute` not `FonteCaminhoShellPipe`
9804        // — the host-layout-leak diagnostic is the load-bearing axis,
9805        // the `|` byte is the secondary observation. Same precedence
9806        // logic as every prior leading-byte arm.
9807        let d = dep_with_fonte(DepSource::Path {
9808            caminho: "/etc/passwd|tee".into(),
9809        });
9810        let err = d.validate().unwrap_err();
9811        assert!(
9812            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
9813            "got {err:?}",
9814        );
9815    }
9816
9817    #[test]
9818    fn fonte_caminho_shell_pipe_fires_before_trailing_slash() {
9819        // Cascade pin on the immediate-successor arm: a value carrying
9820        // both `|` and a trailing `/` (`"../foo|tee/"` — the canonical
9821        // "I tab-completed a path that already had a pipeline tail"
9822        // footgun) routes through `FonteCaminhoShellPipe` not
9823        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
9824        // the more semantic-locating axis (an author who removes the
9825        // `|` typically also drops the trailing separator since both
9826        // are paste-from-shell artifacts).
9827        let d = dep_with_fonte(DepSource::Path {
9828            caminho: "../foo|tee/".into(),
9829        });
9830        let err = d.validate().unwrap_err();
9831        assert!(
9832            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
9833            "got {err:?}",
9834        );
9835    }
9836
9837    #[test]
9838    fn fonte_caminho_shell_pipe_diagnostic_carries_offending_dep_and_caminho() {
9839        // Diagnostic-shape pin (peer with
9840        // `fonte_caminho_backslash_diagnostic_carries_offending_dep_and_caminho`
9841        // on the closest single-byte peer arm): the error's Display
9842        // surfaces the offending `:nome` and the offending `:caminho`
9843        // verbatim, and names the shell-pipe footgun explicitly so a
9844        // `feira lint` run can render the diagnostic without
9845        // re-parsing.
9846        let d = dep_with_fonte(DepSource::Path {
9847            caminho: "../caixa-teia | grep foo".into(),
9848        });
9849        let rendered = d.validate().unwrap_err().to_string();
9850        assert!(
9851            rendered.contains("caixa-teia"),
9852            "diagnostic must name the offending dep: {rendered}",
9853        );
9854        assert!(
9855            rendered.contains("../caixa-teia | grep foo"),
9856            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
9857        );
9858        assert!(
9859            rendered.contains('|'),
9860            "diagnostic must reference the pipe footgun: {rendered:?}",
9861        );
9862        assert!(
9863            rendered.contains("pipe"),
9864            "diagnostic must name the shell-pipe footgun: {rendered:?}",
9865        );
9866    }
9867
9868    // -- :caminho shell-command-separator metacharacter arm ---------------
9869
9870    #[test]
9871    fn validate_rejects_path_fonte_with_caminho_carrying_semicolon() {
9872        // The fail-before-pass-after pin for the canonical shell-command-
9873        // separator paste footgun: an author copies a shell one-liner
9874        // (`"../caixa-teia; rm -rf build"` — the canonical "I selected the
9875        // whole `cd path; do-thing` chain out of a shell-history block")
9876        // and silently passed every prior arm (`Path::is_absolute` false
9877        // on `..`, no control bytes, no backslash, no `<` / `>`, no `|`,
9878        // doesn't end in `/`). The lacre embedded the value verbatim, the
9879        // resolver folded it through `Path::join` looking for a literal
9880        // `./../caixa-teia; rm -rf build` subdirectory, and the failure
9881        // surfaced at resolve time with a non-self-locating `No such file
9882        // or directory` error. The new arm moves the rejection to validate
9883        // time and names the offending dep + caminho verbatim.
9884        let d = dep_with_fonte(DepSource::Path {
9885            caminho: "../caixa-teia; rm -rf build".into(),
9886        });
9887        let err = d.validate().unwrap_err();
9888        let DepError::FonteCaminhoShellSemicolon { nome, caminho } = err else {
9889            panic!("expected FonteCaminhoShellSemicolon, got {err:?}");
9890        };
9891        assert_eq!(nome, "caixa-teia");
9892        assert_eq!(caminho, "../caixa-teia; rm -rf build");
9893    }
9894
9895    #[test]
9896    fn validate_rejects_path_fonte_with_caminho_carrying_leading_semicolon() {
9897        // Leading-position `;` shape (`";../caixa-teia"` — the degenerate
9898        // "I forgot the prior command side of the separator" idiom).
9899        // Pinned separately from the embedded-byte shape so the gate
9900        // covers every position, not only mid-path.
9901        let d = dep_with_fonte(DepSource::Path {
9902            caminho: ";../caixa-teia".into(),
9903        });
9904        let err = d.validate().unwrap_err();
9905        assert!(
9906            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
9907            "got {err:?}",
9908        );
9909    }
9910
9911    #[test]
9912    fn validate_rejects_path_fonte_with_caminho_carrying_double_semicolon() {
9913        // The POSIX `case` arm `;;` terminator shape
9914        // (`"../caixa-teia;;next"` — the canonical "I copied a `case`
9915        // arm tail" idiom). The arm fires on the first `;` encountered;
9916        // pinned so a future arm that tries to distinguish `;` from `;;`
9917        // doesn't break the broader contract.
9918        let d = dep_with_fonte(DepSource::Path {
9919            caminho: "../caixa-teia;;next".into(),
9920        });
9921        let err = d.validate().unwrap_err();
9922        assert!(
9923            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
9924            "got {err:?}",
9925        );
9926    }
9927
9928    #[test]
9929    fn validate_accepts_path_fonte_with_caminho_carrying_no_semicolon() {
9930        // The positive-control pin: the gate targets only `;`, never
9931        // adjacent printable ASCII or POSIX-valid bytes. The canonical
9932        // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
9933        // pathed variant with adjacent printable punctuation
9934        // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
9935        // cleanly so the gate doesn't widen to a "no printable
9936        // punctuation anywhere" sweep that would defeat the entire
9937        // path-fonte author surface.
9938        let d = dep_with_fonte(DepSource::Path {
9939            caminho: "../caixa-teia/sub-dir.v2".into(),
9940        });
9941        d.validate().unwrap();
9942    }
9943
9944    #[test]
9945    fn fonte_caminho_shell_pipe_fires_before_shell_semicolon() {
9946        // Cascade pin on the immediate-predecessor arm: a value carrying
9947        // both `|` and `;` (`"../caixa-teia | tee; rm"` — the canonical
9948        // "I pasted a `cmd | tee; cleanup` chain" footgun) routes through
9949        // `FonteCaminhoShellPipe` not `FonteCaminhoShellSemicolon`. The
9950        // pipeline-tail paste is the load-bearing root-cause edit on
9951        // every probe-as-both value (an author who removes the `|`
9952        // typically also drops the trailing `; cleanup` since both are
9953        // the same paste-from-shell-history artifact) — same cascade
9954        // discipline every prior `:caminho` arm establishes.
9955        let d = dep_with_fonte(DepSource::Path {
9956            caminho: "../caixa-teia | tee; rm".into(),
9957        });
9958        let err = d.validate().unwrap_err();
9959        assert!(
9960            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
9961            "got {err:?}",
9962        );
9963    }
9964
9965    #[test]
9966    fn fonte_caminho_shell_redirection_fires_before_shell_semicolon() {
9967        // Cascade pin on the upstream shell-redirection arm: a value
9968        // carrying both `<` / `>` and `;` (`"../caixa-teia>log; rm"` —
9969        // the canonical "I pasted a `cmd > log; cleanup` chain"
9970        // footgun) routes through `FonteCaminhoShellRedirection` not
9971        // `FonteCaminhoShellSemicolon`. The input/output redirection
9972        // metachar carries the more self-locating `byte: u8` payload
9973        // (it names which of `<` or `>` triggered), so the prior arm
9974        // wins on every probe-as-both value.
9975        let d = dep_with_fonte(DepSource::Path {
9976            caminho: "../caixa-teia>log; rm".into(),
9977        });
9978        let err = d.validate().unwrap_err();
9979        assert!(
9980            matches!(
9981                err,
9982                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
9983            ),
9984            "got {err:?}",
9985        );
9986    }
9987
9988    #[test]
9989    fn fonte_caminho_backslash_fires_before_shell_semicolon() {
9990        // Cascade pin on the upstream backslash arm: a value carrying
9991        // both `\` and `;` (`"..\caixa-teia;rm"` — the canonical "I
9992        // pasted a Windows-shell `cd ..\path; cleanup` chain") routes
9993        // through `FonteCaminhoBackslash` not `FonteCaminhoShellSemicolon`.
9994        // The cross-host-OS-separator divergence is the load-bearing axis
9995        // on every probe-as-both value (an author who removes the `\` is
9996        // the root-cause edit; the `;` falls away in the same edit since
9997        // it's downstream of the Windows-shell convention).
9998        let d = dep_with_fonte(DepSource::Path {
9999            caminho: "..\\caixa-teia;rm".into(),
10000        });
10001        let err = d.validate().unwrap_err();
10002        assert!(
10003            matches!(err, DepError::FonteCaminhoBackslash { .. }),
10004            "got {err:?}",
10005        );
10006    }
10007
10008    #[test]
10009    fn fonte_caminho_control_char_fires_before_shell_semicolon() {
10010        // Cascade pin on the embedded-control-byte arm: a value carrying
10011        // both a control byte and `;` (`"../foo\n;bar"` — the canonical
10012        // paste-from-multiline-doc footgun where a newline landed mid-
10013        // caminho) routes through `FonteCaminhoControlChar` not
10014        // `FonteCaminhoShellSemicolon`. The POSIX-syscall-rejected-byte
10015        // / NUL-`CString::new`-fail diagnostic is the load-bearing axis
10016        // on every value that probes positive for both — mirrors the
10017        // cascade discipline on every prior arm.
10018        let d = dep_with_fonte(DepSource::Path {
10019            caminho: "../foo\n;bar".into(),
10020        });
10021        let err = d.validate().unwrap_err();
10022        assert!(
10023            matches!(err, DepError::FonteCaminhoControlChar { .. }),
10024            "got {err:?}",
10025        );
10026    }
10027
10028    #[test]
10029    fn fonte_caminho_absolute_fires_before_shell_semicolon() {
10030        // Cascade pin on the load-bearing leading-byte arm: a leading
10031        // `/` value with embedded `;` (`"/etc/passwd;rm"`) routes
10032        // through `FonteCaminhoAbsolute` not `FonteCaminhoShellSemicolon`
10033        // — the host-layout-leak diagnostic is the load-bearing axis,
10034        // the `;` byte is the secondary observation. Same precedence
10035        // logic as every prior leading-byte arm.
10036        let d = dep_with_fonte(DepSource::Path {
10037            caminho: "/etc/passwd;rm".into(),
10038        });
10039        let err = d.validate().unwrap_err();
10040        assert!(
10041            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10042            "got {err:?}",
10043        );
10044    }
10045
10046    #[test]
10047    fn fonte_caminho_shell_semicolon_fires_before_trailing_slash() {
10048        // Cascade pin on the immediate-successor arm: a value carrying
10049        // both `;` and a trailing `/` (`"../foo;rm/"` — the canonical
10050        // "I tab-completed a path that already had a `; cleanup` tail"
10051        // footgun) routes through `FonteCaminhoShellSemicolon` not
10052        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
10053        // the more semantic-locating axis (an author who removes the
10054        // `;` typically also drops the trailing separator since both
10055        // are paste-from-shell artifacts).
10056        let d = dep_with_fonte(DepSource::Path {
10057            caminho: "../foo;rm/".into(),
10058        });
10059        let err = d.validate().unwrap_err();
10060        assert!(
10061            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
10062            "got {err:?}",
10063        );
10064    }
10065
10066    #[test]
10067    fn fonte_caminho_shell_semicolon_diagnostic_carries_offending_dep_and_caminho() {
10068        // Diagnostic-shape pin (peer with
10069        // `fonte_caminho_shell_pipe_diagnostic_carries_offending_dep_and_caminho`
10070        // on the closest single-byte peer arm): the error's Display
10071        // surfaces the offending `:nome` and the offending `:caminho`
10072        // verbatim, and names the shell-command-separator footgun
10073        // explicitly so a `feira lint` run can render the diagnostic
10074        // without re-parsing.
10075        let d = dep_with_fonte(DepSource::Path {
10076            caminho: "../caixa-teia; rm -rf build".into(),
10077        });
10078        let rendered = d.validate().unwrap_err().to_string();
10079        assert!(
10080            rendered.contains("caixa-teia"),
10081            "diagnostic must name the offending dep: {rendered}",
10082        );
10083        assert!(
10084            rendered.contains("../caixa-teia; rm -rf build"),
10085            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10086        );
10087        assert!(
10088            rendered.contains(';'),
10089            "diagnostic must reference the semicolon footgun: {rendered:?}",
10090        );
10091        assert!(
10092            rendered.contains("command-separator"),
10093            "diagnostic must name the shell-command-separator footgun: {rendered:?}",
10094        );
10095    }
10096
10097    #[test]
10098    fn validate_rejects_path_fonte_with_caminho_carrying_ampersand() {
10099        // The fail-before-pass-after pin for the canonical shell-
10100        // background-task paste footgun: an author copies a shell one-
10101        // liner (`"../caixa-teia & sleep 1"` — the canonical "I selected
10102        // the whole `cd path & sleep 1` background-launch out of a
10103        // shell-history block") and silently passed every prior arm
10104        // (`Path::is_absolute` false on `..`, no control bytes, no
10105        // backslash, no `<` / `>`, no `|`, no `;`, doesn't end in `/`).
10106        // The lacre embedded the value verbatim, the resolver folded it
10107        // through `Path::join` looking for a literal `./../caixa-teia &
10108        // sleep 1` subdirectory, and the failure surfaced at resolve
10109        // time with a non-self-locating `No such file or directory`
10110        // error. The new arm moves the rejection to validate time and
10111        // names the offending dep + caminho verbatim.
10112        let d = dep_with_fonte(DepSource::Path {
10113            caminho: "../caixa-teia & sleep 1".into(),
10114        });
10115        let err = d.validate().unwrap_err();
10116        let DepError::FonteCaminhoShellBackground { nome, caminho } = err else {
10117            panic!("expected FonteCaminhoShellBackground, got {err:?}");
10118        };
10119        assert_eq!(nome, "caixa-teia");
10120        assert_eq!(caminho, "../caixa-teia & sleep 1");
10121    }
10122
10123    #[test]
10124    fn validate_rejects_path_fonte_with_caminho_carrying_leading_ampersand() {
10125        // Leading-position `&` shape (`"&../caixa-teia"` — the
10126        // degenerate "I forgot the prior command side of the
10127        // background terminator" idiom). Pinned separately from the
10128        // embedded-byte shape so the gate covers every position, not
10129        // only mid-path.
10130        let d = dep_with_fonte(DepSource::Path {
10131            caminho: "&../caixa-teia".into(),
10132        });
10133        let err = d.validate().unwrap_err();
10134        assert!(
10135            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
10136            "got {err:?}",
10137        );
10138    }
10139
10140    #[test]
10141    fn validate_rejects_path_fonte_with_caminho_carrying_double_ampersand() {
10142        // The logical-AND `&&` shape (`"../caixa-teia && make"` — the
10143        // canonical "I copied a `cd path && make` build chain" idiom
10144        // every Makefile / shell-script wraps). The arm fires on the
10145        // first `&` encountered; pinned so a future arm that tries to
10146        // distinguish `&` from `&&` doesn't break the broader contract.
10147        let d = dep_with_fonte(DepSource::Path {
10148            caminho: "../caixa-teia && make".into(),
10149        });
10150        let err = d.validate().unwrap_err();
10151        assert!(
10152            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
10153            "got {err:?}",
10154        );
10155    }
10156
10157    #[test]
10158    fn validate_accepts_path_fonte_with_caminho_carrying_no_ampersand() {
10159        // The positive-control pin: the gate targets only `&`, never
10160        // adjacent printable ASCII or POSIX-valid bytes. The canonical
10161        // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
10162        // pathed variant with adjacent printable punctuation
10163        // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
10164        // cleanly so the gate doesn't widen to a "no printable
10165        // punctuation anywhere" sweep that would defeat the entire
10166        // path-fonte author surface.
10167        let d = dep_with_fonte(DepSource::Path {
10168            caminho: "../caixa-teia/sub-dir.v2".into(),
10169        });
10170        d.validate().unwrap();
10171    }
10172
10173    #[test]
10174    fn fonte_caminho_shell_semicolon_fires_before_shell_background() {
10175        // Cascade pin on the immediate-predecessor arm: a value carrying
10176        // both `;` and `&` (`"../caixa-teia; rm & sleep"` — the
10177        // canonical "I pasted a `cmd; cleanup & sleep` chain" footgun)
10178        // routes through `FonteCaminhoShellSemicolon` not
10179        // `FonteCaminhoShellBackground`. The sequential-command-
10180        // separator paste is the more common shell-history paste idiom
10181        // on every probe-as-both value (an author who removes the `;`
10182        // typically also drops the trailing `& sleep` since both are
10183        // paste-from-shell-history artifacts) — same cascade discipline
10184        // every prior `:caminho` arm establishes.
10185        let d = dep_with_fonte(DepSource::Path {
10186            caminho: "../caixa-teia; rm & sleep".into(),
10187        });
10188        let err = d.validate().unwrap_err();
10189        assert!(
10190            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
10191            "got {err:?}",
10192        );
10193    }
10194
10195    #[test]
10196    fn fonte_caminho_shell_pipe_fires_before_shell_background() {
10197        // Cascade pin on the upstream shell-pipe arm: a value carrying
10198        // both `|` and `&` (`"../caixa-teia | tee & sleep"` — the
10199        // canonical "I pasted a `cmd | tee & sleep` background-pipeline
10200        // chain" footgun) routes through `FonteCaminhoShellPipe` not
10201        // `FonteCaminhoShellBackground`. The pipeline-tail paste is the
10202        // load-bearing root-cause edit on every probe-as-both value.
10203        let d = dep_with_fonte(DepSource::Path {
10204            caminho: "../caixa-teia | tee & sleep".into(),
10205        });
10206        let err = d.validate().unwrap_err();
10207        assert!(
10208            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10209            "got {err:?}",
10210        );
10211    }
10212
10213    #[test]
10214    fn fonte_caminho_shell_redirection_fires_before_shell_background() {
10215        // Cascade pin on the upstream shell-redirection arm: a value
10216        // carrying both `>` and `&` (`"../caixa-teia>log & sleep"` —
10217        // the canonical "I pasted a `cmd > log & sleep` background-
10218        // redirect chain" footgun) routes through
10219        // `FonteCaminhoShellRedirection` not
10220        // `FonteCaminhoShellBackground`. The input/output redirection
10221        // metachar carries the more self-locating `byte: u8` payload
10222        // (it names which of `<` or `>` triggered), so the prior arm
10223        // wins on every probe-as-both value.
10224        let d = dep_with_fonte(DepSource::Path {
10225            caminho: "../caixa-teia>log & sleep".into(),
10226        });
10227        let err = d.validate().unwrap_err();
10228        assert!(
10229            matches!(
10230                err,
10231                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
10232            ),
10233            "got {err:?}",
10234        );
10235    }
10236
10237    #[test]
10238    fn fonte_caminho_backslash_fires_before_shell_background() {
10239        // Cascade pin on the upstream backslash arm: a value carrying
10240        // both `\` and `&` (`"..\caixa-teia & sleep"` — the canonical
10241        // "I pasted a Windows-shell `cd ..\path & sleep` background-
10242        // launch chain") routes through `FonteCaminhoBackslash` not
10243        // `FonteCaminhoShellBackground`. The cross-host-OS-separator
10244        // divergence is the load-bearing axis on every probe-as-both
10245        // value (an author who removes the `\` is the root-cause edit;
10246        // the `&` falls away in the same edit since it's downstream of
10247        // the Windows-shell convention).
10248        let d = dep_with_fonte(DepSource::Path {
10249            caminho: "..\\caixa-teia & sleep".into(),
10250        });
10251        let err = d.validate().unwrap_err();
10252        assert!(
10253            matches!(err, DepError::FonteCaminhoBackslash { .. }),
10254            "got {err:?}",
10255        );
10256    }
10257
10258    #[test]
10259    fn fonte_caminho_control_char_fires_before_shell_background() {
10260        // Cascade pin on the embedded-control-byte arm: a value
10261        // carrying both a control byte and `&` (`"../foo\n&sleep"` —
10262        // the canonical paste-from-multiline-doc footgun where a
10263        // newline landed mid-caminho) routes through
10264        // `FonteCaminhoControlChar` not `FonteCaminhoShellBackground`.
10265        // The POSIX-syscall-rejected-byte / NUL-`CString::new`-fail
10266        // diagnostic is the load-bearing axis on every value that
10267        // probes positive for both — mirrors the cascade discipline on
10268        // every prior arm.
10269        let d = dep_with_fonte(DepSource::Path {
10270            caminho: "../foo\n&sleep".into(),
10271        });
10272        let err = d.validate().unwrap_err();
10273        assert!(
10274            matches!(err, DepError::FonteCaminhoControlChar { .. }),
10275            "got {err:?}",
10276        );
10277    }
10278
10279    #[test]
10280    fn fonte_caminho_absolute_fires_before_shell_background() {
10281        // Cascade pin on the load-bearing leading-byte arm: a leading
10282        // `/` value with embedded `&` (`"/etc/passwd & sleep"`) routes
10283        // through `FonteCaminhoAbsolute` not
10284        // `FonteCaminhoShellBackground` — the host-layout-leak
10285        // diagnostic is the load-bearing axis, the `&` byte is the
10286        // secondary observation. Same precedence logic as every prior
10287        // leading-byte arm.
10288        let d = dep_with_fonte(DepSource::Path {
10289            caminho: "/etc/passwd & sleep".into(),
10290        });
10291        let err = d.validate().unwrap_err();
10292        assert!(
10293            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10294            "got {err:?}",
10295        );
10296    }
10297
10298    #[test]
10299    fn fonte_caminho_shell_background_fires_before_trailing_slash() {
10300        // Cascade pin on the immediate-successor arm: a value carrying
10301        // both `&` and a trailing `/` (`"../foo&sleep/"` — the
10302        // canonical "I tab-completed a path that already had a `&
10303        // sleep` background-launch tail" footgun) routes through
10304        // `FonteCaminhoShellBackground` not `FonteCaminhoTrailingSlash`.
10305        // The embedded shell-metachar is the more semantic-locating
10306        // axis (an author who removes the `&` typically also drops
10307        // the trailing separator since both are paste-from-shell
10308        // artifacts).
10309        let d = dep_with_fonte(DepSource::Path {
10310            caminho: "../foo&sleep/".into(),
10311        });
10312        let err = d.validate().unwrap_err();
10313        assert!(
10314            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
10315            "got {err:?}",
10316        );
10317    }
10318
10319    #[test]
10320    fn fonte_caminho_shell_background_diagnostic_carries_offending_dep_and_caminho() {
10321        // Diagnostic-shape pin (peer with
10322        // `fonte_caminho_shell_semicolon_diagnostic_carries_offending_dep_and_caminho`
10323        // on the closest single-byte peer arm): the error's Display
10324        // surfaces the offending `:nome` and the offending `:caminho`
10325        // verbatim, and names the shell-background / logical-AND
10326        // footgun explicitly so a `feira lint` run can render the
10327        // diagnostic without re-parsing.
10328        let d = dep_with_fonte(DepSource::Path {
10329            caminho: "../caixa-teia & sleep 1".into(),
10330        });
10331        let rendered = d.validate().unwrap_err().to_string();
10332        assert!(
10333            rendered.contains("caixa-teia"),
10334            "diagnostic must name the offending dep: {rendered}",
10335        );
10336        assert!(
10337            rendered.contains("../caixa-teia & sleep 1"),
10338            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10339        );
10340        assert!(
10341            rendered.contains('&'),
10342            "diagnostic must reference the ampersand footgun: {rendered:?}",
10343        );
10344        assert!(
10345            rendered.contains("background") || rendered.contains("list-AND"),
10346            "diagnostic must name the shell-background / logical-AND footgun: {rendered:?}",
10347        );
10348    }
10349
10350    #[test]
10351    fn validate_rejects_path_fonte_with_caminho_carrying_backtick() {
10352        // The fail-before-pass-after pin for the canonical shell-
10353        // command-substitution paste footgun: an author copies a
10354        // POSIX legacy backticked one-liner (`"../caixa-teia/`whoami`"`
10355        // — the canonical "I pasted a path that included a `pwd`
10356        // / `whoami` / `date` legacy command-substitution expansion
10357        // out of a shell-history block") and silently passed every
10358        // prior arm (`Path::is_absolute` false on `..`, no control
10359        // bytes, no `\`, no `<` / `>`, no `|`, no `;`, no `&`, doesn't
10360        // end in `/`). The lacre embedded the value verbatim, the
10361        // resolver folded it through `Path::join` looking for a
10362        // literal `./../caixa-teia/`whoami`` subdirectory, and the
10363        // failure surfaced at resolve time with a non-self-locating
10364        // `No such file or directory` error. The new arm moves the
10365        // rejection to validate time and names the offending dep +
10366        // caminho verbatim.
10367        let d = dep_with_fonte(DepSource::Path {
10368            caminho: "../caixa-teia/`whoami`".into(),
10369        });
10370        let err = d.validate().unwrap_err();
10371        let DepError::FonteCaminhoShellCommandSubstitution { nome, caminho } = err else {
10372            panic!("expected FonteCaminhoShellCommandSubstitution, got {err:?}");
10373        };
10374        assert_eq!(nome, "caixa-teia");
10375        assert_eq!(caminho, "../caixa-teia/`whoami`");
10376    }
10377
10378    #[test]
10379    fn validate_rejects_path_fonte_with_caminho_carrying_leading_backtick() {
10380        // Leading-position backtick shape (``"`pwd`/caixa-teia"`` —
10381        // the canonical `<backtick>pwd<backtick>/path` working-
10382        // directory expansion shape every shell-side path-composition
10383        // idiom carries). Pinned separately from the embedded-byte
10384        // shape so the gate covers every position, not only mid-path.
10385        let d = dep_with_fonte(DepSource::Path {
10386            caminho: "`pwd`/caixa-teia".into(),
10387        });
10388        let err = d.validate().unwrap_err();
10389        assert!(
10390            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
10391            "got {err:?}",
10392        );
10393    }
10394
10395    #[test]
10396    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_backtick() {
10397        // Trailing-position backtick shape (`"../caixa-teia`"` — the
10398        // degenerate "I selected an unbalanced backtick out of a
10399        // shell-history block" idiom that probes for the cascade's
10400        // last-byte handling). The trailing-`/` arm fires only on
10401        // last-byte `/`; an unbalanced trailing backtick must route
10402        // through this arm regardless of position.
10403        let d = dep_with_fonte(DepSource::Path {
10404            caminho: "../caixa-teia`".into(),
10405        });
10406        let err = d.validate().unwrap_err();
10407        assert!(
10408            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
10409            "got {err:?}",
10410        );
10411    }
10412
10413    #[test]
10414    fn validate_rejects_path_fonte_with_caminho_carrying_balanced_backtick_pair() {
10415        // The canonical balanced-pair shape (``"../<backtick>cat
10416        // /etc/passwd<backtick>"`` — the canonical CWE-78 shell-
10417        // command-injection paste idiom every shell-side hardening
10418        // guide enumerates first). The arm fires on the first
10419        // backtick encountered; pinned so a future arm that tries to
10420        // distinguish the opening from the closing byte doesn't break
10421        // the broader contract.
10422        let d = dep_with_fonte(DepSource::Path {
10423            caminho: "../`cat /etc/passwd`".into(),
10424        });
10425        let err = d.validate().unwrap_err();
10426        assert!(
10427            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
10428            "got {err:?}",
10429        );
10430    }
10431
10432    #[test]
10433    fn validate_accepts_path_fonte_with_caminho_carrying_no_backtick() {
10434        // The positive-control pin: the gate targets only the
10435        // backtick byte, never adjacent printable ASCII or POSIX-
10436        // valid bytes. The canonical relative POSIX path
10437        // (`"../caixa-teia"`) and a nested deeply-pathed variant with
10438        // adjacent printable punctuation
10439        // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
10440        // cleanly so the gate doesn't widen to a "no printable
10441        // punctuation anywhere" sweep that would defeat the entire
10442        // path-fonte author surface.
10443        let d = dep_with_fonte(DepSource::Path {
10444            caminho: "../caixa-teia/sub-dir.v2".into(),
10445        });
10446        d.validate().unwrap();
10447    }
10448
10449    #[test]
10450    fn fonte_caminho_shell_background_fires_before_shell_command_substitution() {
10451        // Cascade pin on the immediate-predecessor arm: a value
10452        // carrying both `&` and a backtick (``"../caixa-teia &
10453        // <backtick>sleep 1<backtick>"`` — the canonical "I pasted a
10454        // `cmd & <backtick>sleep N<backtick>` background-launch +
10455        // command-substitution chain" footgun) routes through
10456        // `FonteCaminhoShellBackground` not
10457        // `FonteCaminhoShellCommandSubstitution`. The background-
10458        // launch tail is the more common shell-history paste idiom
10459        // on every probe-as-both value — same cascade discipline
10460        // every prior `:caminho` arm establishes.
10461        let d = dep_with_fonte(DepSource::Path {
10462            caminho: "../caixa-teia & `sleep 1`".into(),
10463        });
10464        let err = d.validate().unwrap_err();
10465        assert!(
10466            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
10467            "got {err:?}",
10468        );
10469    }
10470
10471    #[test]
10472    fn fonte_caminho_shell_semicolon_fires_before_shell_command_substitution() {
10473        // Cascade pin on the upstream shell-semicolon arm: a value
10474        // carrying both `;` and a backtick (``"../caixa-teia;
10475        // <backtick>whoami<backtick>"`` — the canonical "I pasted a
10476        // `cmd; <backtick>follow-up<backtick>` sequential-chain
10477        // footgun) routes through `FonteCaminhoShellSemicolon` not
10478        // `FonteCaminhoShellCommandSubstitution`. The sequential-
10479        // command-separator paste is the load-bearing root-cause
10480        // edit on every probe-as-both value.
10481        let d = dep_with_fonte(DepSource::Path {
10482            caminho: "../caixa-teia; `whoami`".into(),
10483        });
10484        let err = d.validate().unwrap_err();
10485        assert!(
10486            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
10487            "got {err:?}",
10488        );
10489    }
10490
10491    #[test]
10492    fn fonte_caminho_shell_pipe_fires_before_shell_command_substitution() {
10493        // Cascade pin on the upstream shell-pipe arm: a value
10494        // carrying both `|` and a backtick (``"../caixa-teia |
10495        // <backtick>tee log<backtick>"`` — the canonical pipeline-to-
10496        // command-substitution paste idiom) routes through
10497        // `FonteCaminhoShellPipe` not
10498        // `FonteCaminhoShellCommandSubstitution`. The pipeline-tail
10499        // paste is the load-bearing root-cause edit on every
10500        // probe-as-both value.
10501        let d = dep_with_fonte(DepSource::Path {
10502            caminho: "../caixa-teia | `tee log`".into(),
10503        });
10504        let err = d.validate().unwrap_err();
10505        assert!(
10506            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10507            "got {err:?}",
10508        );
10509    }
10510
10511    #[test]
10512    fn fonte_caminho_shell_redirection_fires_before_shell_command_substitution() {
10513        // Cascade pin on the upstream shell-redirection arm: a value
10514        // carrying both `>` and a backtick (``"../caixa-teia>log
10515        // <backtick>date<backtick>"`` — the canonical "I pasted a
10516        // `cmd > log <backtick>date<backtick>` redirect-plus-
10517        // substitution chain" footgun) routes through
10518        // `FonteCaminhoShellRedirection` not
10519        // `FonteCaminhoShellCommandSubstitution`. The input/output
10520        // redirection metachar carries the more self-locating `byte`
10521        // payload (it names which of `<` or `>` triggered), so the
10522        // prior arm wins on every probe-as-both value.
10523        let d = dep_with_fonte(DepSource::Path {
10524            caminho: "../caixa-teia>log `date`".into(),
10525        });
10526        let err = d.validate().unwrap_err();
10527        assert!(
10528            matches!(
10529                err,
10530                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
10531            ),
10532            "got {err:?}",
10533        );
10534    }
10535
10536    #[test]
10537    fn fonte_caminho_backslash_fires_before_shell_command_substitution() {
10538        // Cascade pin on the upstream backslash arm: a value
10539        // carrying both `\` and a backtick (``"..\caixa-teia
10540        // <backtick>whoami<backtick>"`` — the canonical "I pasted a
10541        // Windows-shell `cd ..\path <backtick>whoami<backtick>`
10542        // chain") routes through `FonteCaminhoBackslash` not
10543        // `FonteCaminhoShellCommandSubstitution`. The cross-host-OS-
10544        // separator divergence is the load-bearing axis on every
10545        // probe-as-both value (an author who removes the `\` is the
10546        // root-cause edit; the backtick falls away in the same edit
10547        // since it's downstream of the Windows-shell convention).
10548        let d = dep_with_fonte(DepSource::Path {
10549            caminho: "..\\caixa-teia `whoami`".into(),
10550        });
10551        let err = d.validate().unwrap_err();
10552        assert!(
10553            matches!(err, DepError::FonteCaminhoBackslash { .. }),
10554            "got {err:?}",
10555        );
10556    }
10557
10558    #[test]
10559    fn fonte_caminho_control_char_fires_before_shell_command_substitution() {
10560        // Cascade pin on the embedded-control-byte arm: a value
10561        // carrying both a control byte and a backtick (`"../foo\n
10562        // `whoami`"` — the canonical paste-from-multiline-doc
10563        // footgun where a newline landed mid-caminho between two
10564        // paste fragments) routes through `FonteCaminhoControlChar`
10565        // not `FonteCaminhoShellCommandSubstitution`. The POSIX-
10566        // syscall-rejected-byte / NUL-`CString::new`-fail diagnostic
10567        // is the load-bearing axis on every value that probes
10568        // positive for both — mirrors the cascade discipline on
10569        // every prior arm.
10570        let d = dep_with_fonte(DepSource::Path {
10571            caminho: "../foo\n`whoami`".into(),
10572        });
10573        let err = d.validate().unwrap_err();
10574        assert!(
10575            matches!(err, DepError::FonteCaminhoControlChar { .. }),
10576            "got {err:?}",
10577        );
10578    }
10579
10580    #[test]
10581    fn fonte_caminho_absolute_fires_before_shell_command_substitution() {
10582        // Cascade pin on the load-bearing leading-byte arm: a
10583        // leading `/` value with embedded backtick (``"/etc/passwd
10584        // <backtick>whoami<backtick>"``) routes through
10585        // `FonteCaminhoAbsolute` not
10586        // `FonteCaminhoShellCommandSubstitution` — the host-layout-
10587        // leak diagnostic is the load-bearing axis, the backtick
10588        // byte is the secondary observation. Same precedence logic
10589        // as every prior leading-byte arm.
10590        let d = dep_with_fonte(DepSource::Path {
10591            caminho: "/etc/passwd `whoami`".into(),
10592        });
10593        let err = d.validate().unwrap_err();
10594        assert!(
10595            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10596            "got {err:?}",
10597        );
10598    }
10599
10600    #[test]
10601    fn fonte_caminho_shell_command_substitution_fires_before_trailing_slash() {
10602        // Cascade pin on the immediate-successor arm: a value
10603        // carrying both a backtick and a trailing `/`
10604        // (``"../`whoami`/"`` — the canonical "I tab-completed a
10605        // path that already had a backticked `whoami` substitution
10606        // tail" footgun) routes through
10607        // `FonteCaminhoShellCommandSubstitution` not
10608        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
10609        // is the more semantic-locating axis (an author who removes
10610        // the backtick typically also drops the trailing separator
10611        // since both are paste-from-shell artifacts).
10612        let d = dep_with_fonte(DepSource::Path {
10613            caminho: "../`whoami`/".into(),
10614        });
10615        let err = d.validate().unwrap_err();
10616        assert!(
10617            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
10618            "got {err:?}",
10619        );
10620    }
10621
10622    #[test]
10623    fn fonte_caminho_shell_command_substitution_diagnostic_carries_offending_dep_and_caminho() {
10624        // Diagnostic-shape pin (peer with
10625        // `fonte_caminho_shell_background_diagnostic_carries_offending_dep_and_caminho`
10626        // on the closest single-byte peer arm): the error's Display
10627        // surfaces the offending `:nome` and the offending `:caminho`
10628        // verbatim, and names the shell-command-substitution footgun
10629        // explicitly so a `feira lint` run can render the diagnostic
10630        // without re-parsing.
10631        let d = dep_with_fonte(DepSource::Path {
10632            caminho: "../caixa-teia/`whoami`".into(),
10633        });
10634        let rendered = d.validate().unwrap_err().to_string();
10635        assert!(
10636            rendered.contains("caixa-teia"),
10637            "diagnostic must name the offending dep: {rendered}",
10638        );
10639        assert!(
10640            rendered.contains("../caixa-teia/`whoami`"),
10641            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10642        );
10643        assert!(
10644            rendered.contains('`'),
10645            "diagnostic must reference the backtick footgun: {rendered:?}",
10646        );
10647        assert!(
10648            rendered.contains("command-substitution"),
10649            "diagnostic must name the shell-command-substitution footgun: {rendered:?}",
10650        );
10651    }
10652
10653    #[test]
10654    fn validate_rejects_path_fonte_with_caminho_carrying_star_glob() {
10655        // The fail-before-pass-after pin for the canonical pathname-
10656        // expansion paste footgun: an author copies an `ls
10657        // ../caixa-teia/*` shell-listing tail into the `:caminho`
10658        // slot and silently passes every prior arm
10659        // (`Path::is_absolute` false on `..`, no control bytes, no
10660        // `\`, no `<` / `>`, no `|`, no `;`, no `&`, no backtick,
10661        // doesn't end in `/`). The lacre embedded the value
10662        // verbatim, the resolver folded it through `Path::join`
10663        // looking for a literal `./../caixa-teia/*` subdirectory,
10664        // and the failure surfaced at resolve time with a non-self-
10665        // locating `No such file or directory` error. The new arm
10666        // moves the rejection to validate time and names the
10667        // offending dep + caminho + byte verbatim.
10668        let d = dep_with_fonte(DepSource::Path {
10669            caminho: "../caixa-teia/*".into(),
10670        });
10671        let err = d.validate().unwrap_err();
10672        let DepError::FonteCaminhoShellGlob {
10673            nome,
10674            caminho,
10675            byte,
10676        } = err
10677        else {
10678            panic!("expected FonteCaminhoShellGlob, got {err:?}");
10679        };
10680        assert_eq!(nome, "caixa-teia");
10681        assert_eq!(caminho, "../caixa-teia/*");
10682        assert_eq!(byte, b'*');
10683    }
10684
10685    #[test]
10686    fn validate_rejects_path_fonte_with_caminho_carrying_question_glob() {
10687        // The symmetric single-char-wildcard paste shape
10688        // (`"../foo?"` — the canonical "I copied a `rm foo?` line
10689        // out of shell history" idiom). Pinned separately from the
10690        // `*` shape so the gate's contract is "any `*` or `?`
10691        // anywhere", not single-byte coverage.
10692        let d = dep_with_fonte(DepSource::Path {
10693            caminho: "../foo?".into(),
10694        });
10695        let err = d.validate().unwrap_err();
10696        let DepError::FonteCaminhoShellGlob { byte, .. } = err else {
10697            panic!("expected FonteCaminhoShellGlob, got {err:?}");
10698        };
10699        assert_eq!(byte, b'?');
10700    }
10701
10702    #[test]
10703    fn validate_rejects_path_fonte_with_caminho_carrying_leading_star_glob() {
10704        // Leading-position `*` shape (`"*/caixa-teia"` — the
10705        // degenerate "I selected only the wildcard prefix out of a
10706        // shell-glob expression" idiom). Pinned separately from the
10707        // embedded-byte shapes so the gate covers every position,
10708        // not only mid-path.
10709        let d = dep_with_fonte(DepSource::Path {
10710            caminho: "*/caixa-teia".into(),
10711        });
10712        let err = d.validate().unwrap_err();
10713        assert!(
10714            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
10715            "got {err:?}",
10716        );
10717    }
10718
10719    #[test]
10720    fn validate_rejects_path_fonte_with_caminho_carrying_double_star_recursive_glob() {
10721        // The bash/zsh `globstar` recursive-glob shape
10722        // (`"../caixa-teia/**/foo"` — the canonical "I copied a
10723        // `find ../caixa-teia/**/foo` recursive expansion" idiom).
10724        // The arm fires on the first `*` encountered; pinned so a
10725        // future arm that tries to distinguish single `*` from
10726        // double `**` doesn't break the broader contract.
10727        let d = dep_with_fonte(DepSource::Path {
10728            caminho: "../caixa-teia/**/foo".into(),
10729        });
10730        let err = d.validate().unwrap_err();
10731        assert!(
10732            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
10733            "got {err:?}",
10734        );
10735    }
10736
10737    #[test]
10738    fn validate_rejects_path_fonte_with_caminho_carrying_dotted_extension_glob() {
10739        // The canonical extension-glob shape (`"../caixa-teia/*.lisp"`
10740        // — the "I selected `*.lisp` to mean every Lisp source file
10741        // in the dep root" footgun the prior arms structurally
10742        // cannot catch since `.` is a POSIX-valid path-component
10743        // byte). Pinned so the gate's contract covers the most
10744        // idiomatic glob-paste shape every author meets first.
10745        let d = dep_with_fonte(DepSource::Path {
10746            caminho: "../caixa-teia/*.lisp".into(),
10747        });
10748        let err = d.validate().unwrap_err();
10749        assert!(
10750            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
10751            "got {err:?}",
10752        );
10753    }
10754
10755    #[test]
10756    fn validate_accepts_path_fonte_with_caminho_carrying_no_glob() {
10757        // The positive-control pin: the gate targets only `*` /
10758        // `?`, never adjacent printable ASCII or POSIX-valid bytes.
10759        // The canonical relative POSIX path (`"../caixa-teia"`) and
10760        // a nested deeply-pathed variant with adjacent printable
10761        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
10762        // to validate cleanly so the gate doesn't widen to a "no
10763        // printable punctuation anywhere" sweep that would defeat
10764        // the entire path-fonte author surface.
10765        let d = dep_with_fonte(DepSource::Path {
10766            caminho: "../caixa-teia/sub-dir.v2".into(),
10767        });
10768        d.validate().unwrap();
10769    }
10770
10771    #[test]
10772    fn fonte_caminho_shell_command_substitution_fires_before_shell_glob() {
10773        // Cascade pin on the immediate-predecessor arm: a value
10774        // carrying both a backtick and `*` (``"../`whoami`/*"`` —
10775        // the canonical "I pasted a `cd <backtick>whoami<backtick>/*`
10776        // command-substitution + glob chain") routes through
10777        // `FonteCaminhoShellCommandSubstitution` not
10778        // `FonteCaminhoShellGlob`. The CWE-78 shell-command-
10779        // injection vector is the load-bearing root-cause edit on
10780        // every probe-as-both value — same cascade discipline every
10781        // prior `:caminho` arm establishes.
10782        let d = dep_with_fonte(DepSource::Path {
10783            caminho: "../`whoami`/*".into(),
10784        });
10785        let err = d.validate().unwrap_err();
10786        assert!(
10787            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
10788            "got {err:?}",
10789        );
10790    }
10791
10792    #[test]
10793    fn fonte_caminho_shell_background_fires_before_shell_glob() {
10794        // Cascade pin on the upstream shell-background arm: a value
10795        // carrying both `&` and `*` (`"../caixa-teia & ls /*"` — the
10796        // canonical "I pasted a `cmd & ls /*` background + glob
10797        // chain" footgun) routes through `FonteCaminhoShellBackground`
10798        // not `FonteCaminhoShellGlob`. The background-launch tail is
10799        // the load-bearing root-cause edit on every probe-as-both
10800        // value.
10801        let d = dep_with_fonte(DepSource::Path {
10802            caminho: "../caixa-teia & ls /*".into(),
10803        });
10804        let err = d.validate().unwrap_err();
10805        assert!(
10806            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
10807            "got {err:?}",
10808        );
10809    }
10810
10811    #[test]
10812    fn fonte_caminho_shell_semicolon_fires_before_shell_glob() {
10813        // Cascade pin on the upstream shell-semicolon arm: a value
10814        // carrying both `;` and `*` (`"../caixa-teia; rm *"` — the
10815        // canonical sequential-cleanup + glob paste idiom) routes
10816        // through `FonteCaminhoShellSemicolon` not
10817        // `FonteCaminhoShellGlob`. The sequential-command-separator
10818        // paste is the load-bearing root-cause edit on every
10819        // probe-as-both value.
10820        let d = dep_with_fonte(DepSource::Path {
10821            caminho: "../caixa-teia; rm *".into(),
10822        });
10823        let err = d.validate().unwrap_err();
10824        assert!(
10825            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
10826            "got {err:?}",
10827        );
10828    }
10829
10830    #[test]
10831    fn fonte_caminho_shell_pipe_fires_before_shell_glob() {
10832        // Cascade pin on the upstream shell-pipe arm: a value
10833        // carrying both `|` and `*` (`"../caixa-teia | ls *"` — the
10834        // canonical pipeline-to-glob paste idiom) routes through
10835        // `FonteCaminhoShellPipe` not `FonteCaminhoShellGlob`. The
10836        // pipeline-tail paste is the load-bearing root-cause edit
10837        // on every probe-as-both value.
10838        let d = dep_with_fonte(DepSource::Path {
10839            caminho: "../caixa-teia | ls *".into(),
10840        });
10841        let err = d.validate().unwrap_err();
10842        assert!(
10843            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10844            "got {err:?}",
10845        );
10846    }
10847
10848    #[test]
10849    fn fonte_caminho_shell_redirection_fires_before_shell_glob() {
10850        // Cascade pin on the upstream shell-redirection arm: a value
10851        // carrying both `>` and `*` (`"../caixa-teia>log *"` — the
10852        // canonical "I pasted a `cmd > log *` redirect-plus-glob
10853        // chain" footgun) routes through
10854        // `FonteCaminhoShellRedirection` not `FonteCaminhoShellGlob`.
10855        // The input/output redirection metachar carries the more
10856        // self-locating `byte` payload (it names which of `<` or `>`
10857        // triggered), so the prior arm wins on every probe-as-both
10858        // value.
10859        let d = dep_with_fonte(DepSource::Path {
10860            caminho: "../caixa-teia>log *".into(),
10861        });
10862        let err = d.validate().unwrap_err();
10863        assert!(
10864            matches!(
10865                err,
10866                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
10867            ),
10868            "got {err:?}",
10869        );
10870    }
10871
10872    #[test]
10873    fn fonte_caminho_backslash_fires_before_shell_glob() {
10874        // Cascade pin on the upstream backslash arm: a value
10875        // carrying both `\` and `*` (`"..\caixa-teia\*"` — the
10876        // canonical "I pasted a Windows-shell `cd ..\path\*` glob
10877        // expression" footgun) routes through
10878        // `FonteCaminhoBackslash` not `FonteCaminhoShellGlob`. The
10879        // cross-host-OS-separator divergence is the load-bearing
10880        // axis on every probe-as-both value (an author who removes
10881        // the `\` is the root-cause edit; the `*` falls away in the
10882        // same edit since it's downstream of the Windows-shell
10883        // convention).
10884        let d = dep_with_fonte(DepSource::Path {
10885            caminho: "..\\caixa-teia\\*".into(),
10886        });
10887        let err = d.validate().unwrap_err();
10888        assert!(
10889            matches!(err, DepError::FonteCaminhoBackslash { .. }),
10890            "got {err:?}",
10891        );
10892    }
10893
10894    #[test]
10895    fn fonte_caminho_control_char_fires_before_shell_glob() {
10896        // Cascade pin on the embedded-control-byte arm: a value
10897        // carrying both a control byte and `*` (`"../foo\n*"` — the
10898        // canonical paste-from-multiline-doc footgun where a
10899        // newline landed mid-caminho between two paste fragments)
10900        // routes through `FonteCaminhoControlChar` not
10901        // `FonteCaminhoShellGlob`. The POSIX-syscall-rejected-byte /
10902        // NUL-`CString::new`-fail diagnostic is the load-bearing
10903        // axis on every value that probes positive for both —
10904        // mirrors the cascade discipline on every prior arm.
10905        let d = dep_with_fonte(DepSource::Path {
10906            caminho: "../foo\n*".into(),
10907        });
10908        let err = d.validate().unwrap_err();
10909        assert!(
10910            matches!(err, DepError::FonteCaminhoControlChar { .. }),
10911            "got {err:?}",
10912        );
10913    }
10914
10915    #[test]
10916    fn fonte_caminho_absolute_fires_before_shell_glob() {
10917        // Cascade pin on the load-bearing leading-byte arm: a
10918        // leading `/` value with embedded `*` (`"/etc/*"`) routes
10919        // through `FonteCaminhoAbsolute` not `FonteCaminhoShellGlob`
10920        // — the host-layout-leak diagnostic is the load-bearing
10921        // axis, the glob byte is the secondary observation. Same
10922        // precedence logic as every prior leading-byte arm.
10923        let d = dep_with_fonte(DepSource::Path {
10924            caminho: "/etc/*".into(),
10925        });
10926        let err = d.validate().unwrap_err();
10927        assert!(
10928            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10929            "got {err:?}",
10930        );
10931    }
10932
10933    #[test]
10934    fn fonte_caminho_shell_glob_fires_before_trailing_slash() {
10935        // Cascade pin on the immediate-successor arm: a value
10936        // carrying both `*` and a trailing `/` (`"../foo*/"` — the
10937        // canonical "I tab-completed a path that already had a
10938        // glob-expansion tail" footgun) routes through
10939        // `FonteCaminhoShellGlob` not `FonteCaminhoTrailingSlash`.
10940        // The embedded shell-metachar is the more semantic-locating
10941        // axis (an author who removes the `*` typically also drops
10942        // the trailing separator since both are paste-from-shell
10943        // artifacts).
10944        let d = dep_with_fonte(DepSource::Path {
10945            caminho: "../foo*/".into(),
10946        });
10947        let err = d.validate().unwrap_err();
10948        assert!(
10949            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
10950            "got {err:?}",
10951        );
10952    }
10953
10954    #[test]
10955    fn fonte_caminho_shell_glob_diagnostic_carries_offending_dep_caminho_and_byte() {
10956        // Diagnostic-shape pin (peer with
10957        // `fonte_caminho_shell_redirection_diagnostic_*` on the
10958        // closest two-byte peer arm): the error's Display surfaces
10959        // the offending `:nome`, the offending `:caminho` verbatim,
10960        // the offending byte's hex / character form, and names the
10961        // shell-glob / pathname-expansion footgun explicitly so a
10962        // `feira lint` run can render the diagnostic without
10963        // re-parsing.
10964        let d = dep_with_fonte(DepSource::Path {
10965            caminho: "../caixa-teia/*.lisp".into(),
10966        });
10967        let rendered = d.validate().unwrap_err().to_string();
10968        assert!(
10969            rendered.contains("caixa-teia"),
10970            "diagnostic must name the offending dep: {rendered}",
10971        );
10972        assert!(
10973            rendered.contains("../caixa-teia/*.lisp"),
10974            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10975        );
10976        assert!(
10977            rendered.contains("0x2a"),
10978            "diagnostic must surface the offending byte hex: {rendered:?}",
10979        );
10980        assert!(
10981            rendered.contains("glob"),
10982            "diagnostic must name the shell-glob footgun: {rendered:?}",
10983        );
10984        assert!(
10985            rendered.contains("pathname-expansion"),
10986            "diagnostic must reference the POSIX pathname-expansion vocabulary: {rendered:?}",
10987        );
10988    }
10989
10990    #[test]
10991    fn validate_rejects_path_fonte_with_caminho_carrying_modern_command_substitution() {
10992        // The fail-before-pass-after pin for the canonical modern-Bourne
10993        // command-substitution paste footgun: an author copies a
10994        // `cd ../caixa-teia/$(date)/build` shell-history one-liner whose
10995        // `$(<cmd>)` expansion would land the current date as a
10996        // subdirectory name and silently passed every prior arm
10997        // (`Path::is_absolute` false on `..`, no control bytes, no `\`,
10998        // no `<` / `>`, no `|`, no `;`, no `&`, no backtick, no `*` /
10999        // `?`, doesn't end in `/`; the leading-`$` f4efe9c
11000        // `FonteCaminhoVarExpansion` arm doesn't fire because the `$`
11001        // sits mid-path). The lacre embedded the value verbatim, the
11002        // resolver folded it through `Path::join` looking for a literal
11003        // `./../caixa-teia/$(date)/build` subdirectory, and the failure
11004        // surfaced at resolve time with a non-self-locating `No such
11005        // file or directory` error. The new arm moves the rejection to
11006        // validate time and names the offending dep + caminho + byte
11007        // verbatim. The arm fires on the first `(` encountered (the
11008        // opening byte of `$(date)`).
11009        let d = dep_with_fonte(DepSource::Path {
11010            caminho: "../caixa-teia/$(date)/build".into(),
11011        });
11012        let err = d.validate().unwrap_err();
11013        let DepError::FonteCaminhoShellSubshellGrouping {
11014            nome,
11015            caminho,
11016            byte,
11017        } = err
11018        else {
11019            panic!("expected FonteCaminhoShellSubshellGrouping, got {err:?}");
11020        };
11021        assert_eq!(nome, "caixa-teia");
11022        assert_eq!(caminho, "../caixa-teia/$(date)/build");
11023        assert_eq!(byte, b'(');
11024    }
11025
11026    #[test]
11027    fn validate_rejects_path_fonte_with_caminho_carrying_close_paren() {
11028        // The symmetric close-paren paste shape (`"../caixa-teia)"` —
11029        // the degenerate "I selected an unbalanced closing paren out of
11030        // a shell-history block" idiom that probes for the cascade's
11031        // last-byte handling on a value carrying only the closing byte).
11032        // Pinned separately from the open-paren shape so the gate's
11033        // contract is "any `(` or `)` anywhere", not single-byte
11034        // coverage. Mirrors the peer `validate_rejects_path_fonte_with_\
11035        // caminho_carrying_question_glob` shape on the immediate-
11036        // predecessor `FonteCaminhoShellGlob` arm.
11037        let d = dep_with_fonte(DepSource::Path {
11038            caminho: "../caixa-teia)".into(),
11039        });
11040        let err = d.validate().unwrap_err();
11041        let DepError::FonteCaminhoShellSubshellGrouping { byte, .. } = err else {
11042            panic!("expected FonteCaminhoShellSubshellGrouping, got {err:?}");
11043        };
11044        assert_eq!(byte, b')');
11045    }
11046
11047    #[test]
11048    fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_paren() {
11049        // Leading-position `(` shape (`"(cd foo)/caixa-teia"` — the
11050        // canonical "I selected a `(cd foo)` subshell-grouping prefix
11051        // out of a `(cd foo) && cmd` shell-history one-liner" idiom).
11052        // Pinned separately from the embedded-byte shape so the gate
11053        // covers every position, not only mid-path.
11054        let d = dep_with_fonte(DepSource::Path {
11055            caminho: "(cd foo)/caixa-teia".into(),
11056        });
11057        let err = d.validate().unwrap_err();
11058        assert!(
11059            matches!(
11060                err,
11061                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
11062            ),
11063            "got {err:?}",
11064        );
11065    }
11066
11067    #[test]
11068    fn validate_rejects_path_fonte_with_caminho_carrying_balanced_subshell_grouping_pair() {
11069        // The canonical balanced-pair shape (`"../(pwd)/caixa-teia"`
11070        // — the canonical "I copied a `(pwd)` working-directory-probe
11071        // subshell-grouping idiom every shell-history block carries"
11072        // footgun). The value carries no other cascade-preceding
11073        // shell metachar (`&` / `;` / `|` / `<` / `>` / backtick /
11074        // `*` / `?`) so the arm fires on the first `(` encountered;
11075        // pinned so a future arm that tries to distinguish the
11076        // opening from the closing byte doesn't break the broader
11077        // contract. Mirrors the peer
11078        // `validate_rejects_path_fonte_with_caminho_carrying_balanced_\
11079        // backtick_pair` shape on the upstream `FonteCaminhoShell\
11080        // CommandSubstitution` arm.
11081        let d = dep_with_fonte(DepSource::Path {
11082            caminho: "../(pwd)/caixa-teia".into(),
11083        });
11084        let err = d.validate().unwrap_err();
11085        assert!(
11086            matches!(
11087                err,
11088                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
11089            ),
11090            "got {err:?}",
11091        );
11092    }
11093
11094    #[test]
11095    fn validate_accepts_path_fonte_with_caminho_carrying_no_subshell_grouping() {
11096        // The positive-control pin: the gate targets only `(` / `)`,
11097        // never adjacent printable ASCII or POSIX-valid bytes. The
11098        // canonical relative POSIX path (`"../caixa-teia"`) and a
11099        // nested deeply-pathed variant with adjacent printable
11100        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue to
11101        // validate cleanly so the gate doesn't widen to a "no printable
11102        // punctuation anywhere" sweep that would defeat the entire
11103        // path-fonte author surface.
11104        let d = dep_with_fonte(DepSource::Path {
11105            caminho: "../caixa-teia/sub-dir.v2".into(),
11106        });
11107        d.validate().unwrap();
11108    }
11109
11110    #[test]
11111    fn fonte_caminho_shell_glob_fires_before_shell_subshell_grouping() {
11112        // Cascade pin on the immediate-predecessor arm: a value
11113        // carrying both `*` and `(` (`"../caixa-teia/*(date)"` — the
11114        // canonical "I pasted a glob expansion followed by a
11115        // subshell-grouping tail" footgun) routes through
11116        // `FonteCaminhoShellGlob` not
11117        // `FonteCaminhoShellSubshellGrouping`. The pathname-expansion
11118        // shape is the more common shell-history paste idiom on every
11119        // probe-as-both value — same cascade discipline every prior
11120        // `:caminho` arm establishes.
11121        let d = dep_with_fonte(DepSource::Path {
11122            caminho: "../caixa-teia/*(date)".into(),
11123        });
11124        let err = d.validate().unwrap_err();
11125        assert!(
11126            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
11127            "got {err:?}",
11128        );
11129    }
11130
11131    #[test]
11132    fn fonte_caminho_shell_command_substitution_fires_before_shell_subshell_grouping() {
11133        // Cascade pin on the upstream shell-command-substitution arm: a
11134        // value carrying both a backtick and `(` (``"../`whoami`/$(date)"``
11135        // — the canonical "I pasted a legacy-backtick + modern-paren
11136        // command-substitution chain" footgun) routes through
11137        // `FonteCaminhoShellCommandSubstitution` not
11138        // `FonteCaminhoShellSubshellGrouping`. The CWE-78 shell-
11139        // command-injection vector is the load-bearing root-cause edit
11140        // on every probe-as-both value.
11141        let d = dep_with_fonte(DepSource::Path {
11142            caminho: "../`whoami`/$(date)".into(),
11143        });
11144        let err = d.validate().unwrap_err();
11145        assert!(
11146            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11147            "got {err:?}",
11148        );
11149    }
11150
11151    #[test]
11152    fn fonte_caminho_shell_background_fires_before_shell_subshell_grouping() {
11153        // Cascade pin on the upstream shell-background arm: a value
11154        // carrying both `&` and `(` (`"../caixa-teia & (cd foo)"` —
11155        // the canonical "I pasted a `cmd & (cd foo)` background-launch
11156        // + subshell-grouping chain" footgun) routes through
11157        // `FonteCaminhoShellBackground` not
11158        // `FonteCaminhoShellSubshellGrouping`. The background-launch
11159        // tail is the load-bearing root-cause edit on every probe-as-
11160        // both value.
11161        let d = dep_with_fonte(DepSource::Path {
11162            caminho: "../caixa-teia & (cd foo)".into(),
11163        });
11164        let err = d.validate().unwrap_err();
11165        assert!(
11166            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11167            "got {err:?}",
11168        );
11169    }
11170
11171    #[test]
11172    fn fonte_caminho_shell_semicolon_fires_before_shell_subshell_grouping() {
11173        // Cascade pin on the upstream shell-semicolon arm: a value
11174        // carrying both `;` and `(` (`"../caixa-teia; (cd foo)"` —
11175        // the canonical sequential-cleanup + subshell-grouping paste
11176        // idiom) routes through `FonteCaminhoShellSemicolon` not
11177        // `FonteCaminhoShellSubshellGrouping`. The sequential-command-
11178        // separator paste is the load-bearing root-cause edit on
11179        // every probe-as-both value.
11180        let d = dep_with_fonte(DepSource::Path {
11181            caminho: "../caixa-teia; (cd foo)".into(),
11182        });
11183        let err = d.validate().unwrap_err();
11184        assert!(
11185            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11186            "got {err:?}",
11187        );
11188    }
11189
11190    #[test]
11191    fn fonte_caminho_shell_pipe_fires_before_shell_subshell_grouping() {
11192        // Cascade pin on the upstream shell-pipe arm: a value carrying
11193        // both `|` and `(` (`"../caixa-teia | (tee log)"` — the
11194        // canonical pipeline-to-subshell-grouping paste idiom) routes
11195        // through `FonteCaminhoShellPipe` not
11196        // `FonteCaminhoShellSubshellGrouping`. The pipeline-tail paste
11197        // is the load-bearing root-cause edit on every probe-as-both
11198        // value.
11199        let d = dep_with_fonte(DepSource::Path {
11200            caminho: "../caixa-teia | (tee log)".into(),
11201        });
11202        let err = d.validate().unwrap_err();
11203        assert!(
11204            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11205            "got {err:?}",
11206        );
11207    }
11208
11209    #[test]
11210    fn fonte_caminho_shell_redirection_fires_before_shell_subshell_grouping() {
11211        // Cascade pin on the upstream shell-redirection arm: a value
11212        // carrying both `>` and `(` (`"../caixa-teia>log (cd foo)"` —
11213        // the canonical "I pasted a `cmd > log (cd foo)` redirect-
11214        // plus-subshell-grouping chain" footgun) routes through
11215        // `FonteCaminhoShellRedirection` not
11216        // `FonteCaminhoShellSubshellGrouping`. The input/output
11217        // redirection metachar carries the more self-locating `byte`
11218        // payload (it names which of `<` or `>` triggered), so the
11219        // prior arm wins on every probe-as-both value.
11220        let d = dep_with_fonte(DepSource::Path {
11221            caminho: "../caixa-teia>log (cd foo)".into(),
11222        });
11223        let err = d.validate().unwrap_err();
11224        assert!(
11225            matches!(
11226                err,
11227                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11228            ),
11229            "got {err:?}",
11230        );
11231    }
11232
11233    #[test]
11234    fn fonte_caminho_backslash_fires_before_shell_subshell_grouping() {
11235        // Cascade pin on the upstream backslash arm: a value carrying
11236        // both `\` and `(` (`"..\caixa-teia\(cd foo)"` — the canonical
11237        // "I pasted a Windows-shell `cd ..\path\(cmd)` chain") routes
11238        // through `FonteCaminhoBackslash` not
11239        // `FonteCaminhoShellSubshellGrouping`. The cross-host-OS-
11240        // separator divergence is the load-bearing axis on every
11241        // probe-as-both value (an author who removes the `\` is the
11242        // root-cause edit; the `(` falls away in the same edit since
11243        // it's downstream of the Windows-shell convention).
11244        let d = dep_with_fonte(DepSource::Path {
11245            caminho: "..\\caixa-teia\\(cd foo)".into(),
11246        });
11247        let err = d.validate().unwrap_err();
11248        assert!(
11249            matches!(err, DepError::FonteCaminhoBackslash { .. }),
11250            "got {err:?}",
11251        );
11252    }
11253
11254    #[test]
11255    fn fonte_caminho_control_char_fires_before_shell_subshell_grouping() {
11256        // Cascade pin on the embedded-control-byte arm: a value
11257        // carrying both a control byte and `(` (`"../foo\n(cd bar)"` —
11258        // the canonical paste-from-multiline-doc footgun where a
11259        // newline landed mid-caminho between two paste fragments)
11260        // routes through `FonteCaminhoControlChar` not
11261        // `FonteCaminhoShellSubshellGrouping`. The POSIX-syscall-
11262        // rejected-byte / NUL-`CString::new`-fail diagnostic is the
11263        // load-bearing axis on every value that probes positive for
11264        // both — mirrors the cascade discipline on every prior arm.
11265        let d = dep_with_fonte(DepSource::Path {
11266            caminho: "../foo\n(cd bar)".into(),
11267        });
11268        let err = d.validate().unwrap_err();
11269        assert!(
11270            matches!(err, DepError::FonteCaminhoControlChar { .. }),
11271            "got {err:?}",
11272        );
11273    }
11274
11275    #[test]
11276    fn fonte_caminho_absolute_fires_before_shell_subshell_grouping() {
11277        // Cascade pin on the load-bearing leading-byte arm: a leading
11278        // `/` value with embedded `(` (`"/etc/(cd foo)"`) routes
11279        // through `FonteCaminhoAbsolute` not
11280        // `FonteCaminhoShellSubshellGrouping` — the host-layout-leak
11281        // diagnostic is the load-bearing axis, the subshell-grouping
11282        // byte is the secondary observation. Same precedence logic as
11283        // every prior leading-byte arm.
11284        let d = dep_with_fonte(DepSource::Path {
11285            caminho: "/etc/(cd foo)".into(),
11286        });
11287        let err = d.validate().unwrap_err();
11288        assert!(
11289            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11290            "got {err:?}",
11291        );
11292    }
11293
11294    #[test]
11295    fn fonte_caminho_var_expansion_fires_before_shell_subshell_grouping() {
11296        // Cascade pin on the upstream leading-`$` var-expansion arm: a
11297        // value carrying both a leading `$` and a `(` (`"$(date)/\
11298        // caixa-teia"` — the canonical "I pasted a `$(date)` modern-
11299        // command-substitution at the head of a sibling-workspace
11300        // path" footgun) routes through `FonteCaminhoVarExpansion` not
11301        // `FonteCaminhoShellSubshellGrouping`. The leading-byte
11302        // shell-variable-expansion is the more self-locating diagnostic
11303        // on values that probe as both — same load-bearing-leading-
11304        // byte cascade discipline every prior `:caminho` arm
11305        // establishes. Closing both halves of `$(<cmd>)` structurally
11306        // (leading `$` here, trailing `)` on the new arm) excludes the
11307        // entire modern Bourne command-substitution surface from the
11308        // typed `:caminho` accepted set; the cascade preserves the
11309        // narrower leading-byte diagnostic on values that probe both
11310        // halves at the canonical leading position.
11311        let d = dep_with_fonte(DepSource::Path {
11312            caminho: "$(date)/caixa-teia".into(),
11313        });
11314        let err = d.validate().unwrap_err();
11315        assert!(
11316            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
11317            "got {err:?}",
11318        );
11319    }
11320
11321    #[test]
11322    fn fonte_caminho_shell_subshell_grouping_fires_before_trailing_slash() {
11323        // Cascade pin on the immediate-successor arm: a value carrying
11324        // both `(` and a trailing `/` (`"../(cd foo)/"` — the canonical
11325        // "I tab-completed a path that already had a subshell-grouping
11326        // expansion tail" footgun) routes through
11327        // `FonteCaminhoShellSubshellGrouping` not
11328        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
11329        // the more semantic-locating axis (an author who removes the
11330        // `(` typically also drops the trailing separator since both
11331        // are paste-from-shell artifacts).
11332        let d = dep_with_fonte(DepSource::Path {
11333            caminho: "../(cd foo)/".into(),
11334        });
11335        let err = d.validate().unwrap_err();
11336        assert!(
11337            matches!(
11338                err,
11339                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
11340            ),
11341            "got {err:?}",
11342        );
11343    }
11344
11345    #[test]
11346    fn fonte_caminho_shell_subshell_grouping_diagnostic_carries_offending_dep_caminho_and_byte() {
11347        // Diagnostic-shape pin (peer with
11348        // `fonte_caminho_shell_glob_diagnostic_carries_offending_dep_caminho_and_byte`
11349        // on the closest two-byte peer arm): the error's Display
11350        // surfaces the offending `:nome`, the offending `:caminho`
11351        // verbatim, the offending byte's hex / character form, and
11352        // names the shell-subshell-grouping footgun explicitly so a
11353        // `feira lint` run can render the diagnostic without re-
11354        // parsing.
11355        let d = dep_with_fonte(DepSource::Path {
11356            caminho: "../caixa-teia/$(date)/build".into(),
11357        });
11358        let rendered = d.validate().unwrap_err().to_string();
11359        assert!(
11360            rendered.contains("caixa-teia"),
11361            "diagnostic must name the offending dep: {rendered}",
11362        );
11363        assert!(
11364            rendered.contains("../caixa-teia/$(date)/build"),
11365            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11366        );
11367        assert!(
11368            rendered.contains("0x28"),
11369            "diagnostic must surface the offending byte hex: {rendered:?}",
11370        );
11371        assert!(
11372            rendered.contains("subshell-grouping"),
11373            "diagnostic must name the shell-subshell-grouping footgun: {rendered:?}",
11374        );
11375        assert!(
11376            rendered.contains("command-substitution"),
11377            "diagnostic must reference the `$(<cmd>)` command-substitution vocabulary: \
11378             {rendered:?}",
11379        );
11380    }
11381
11382    // ── shell-brace-expansion / URI-Template-placeholder arm ───────────
11383    //
11384    // Peer with the prior `FonteCaminhoShellSubshellGrouping` (`(` /
11385    // `)`) byte-pair arm: the same per-byte cascade with the same
11386    // self-locating `byte: u8` diagnostic on the orthogonal `{` /
11387    // `}` brace-expansion / URI-Template placeholder axis. The peer
11388    // [`crate::render::is_git_repo_url`] (42d8f9d) closes the same
11389    // byte pair on the sibling `:fonte :repo` axis under the same
11390    // banner.
11391
11392    #[test]
11393    fn validate_rejects_path_fonte_with_caminho_carrying_brace_expansion_fan_across_siblings() {
11394        // The fail-before-pass-after pin for the canonical paste-from-
11395        // shell-history brace-expansion footgun: an author copies a
11396        // `cd ../{caixa-teia,caixa-helm}/build` shell-history one-
11397        // liner whose `{a,b}` brace expansion fans across two siblings
11398        // and silently passed every prior arm (`Path::is_absolute`
11399        // false on `..`, no control bytes, no `\`, no `<` / `>`, no
11400        // `|`, no `;`, no `&`, no backtick, no `*` / `?`, no `(` /
11401        // `)`, doesn't end in `/`; the leading-`$` f4efe9c
11402        // `FonteCaminhoVarExpansion` arm doesn't fire because the
11403        // value starts with `..` not `$`). The lacre embedded the
11404        // value verbatim, the resolver folded it through `Path::join`
11405        // looking for a literal `./../{caixa-teia,caixa-helm}/build`
11406        // subdirectory, and the failure surfaced at resolve time with
11407        // a non-self-locating `No such file or directory` error. The
11408        // new arm moves the rejection to validate time and names the
11409        // offending dep + caminho + byte verbatim. The arm fires on
11410        // the first `{` encountered.
11411        let d = dep_with_fonte(DepSource::Path {
11412            caminho: "../{caixa-teia,caixa-helm}/build".into(),
11413        });
11414        let err = d.validate().unwrap_err();
11415        let DepError::FonteCaminhoShellBraceExpansion {
11416            nome,
11417            caminho,
11418            byte,
11419        } = err
11420        else {
11421            panic!("expected FonteCaminhoShellBraceExpansion, got {err:?}");
11422        };
11423        assert_eq!(nome, "caixa-teia");
11424        assert_eq!(caminho, "../{caixa-teia,caixa-helm}/build");
11425        assert_eq!(byte, b'{');
11426    }
11427
11428    #[test]
11429    fn validate_rejects_path_fonte_with_caminho_carrying_close_brace() {
11430        // The symmetric close-brace paste shape (`"../caixa-teia}"` —
11431        // the degenerate "I selected an unbalanced closing brace out
11432        // of a shell-history block" idiom that probes for the
11433        // cascade's last-byte handling on a value carrying only the
11434        // closing byte). Pinned separately from the open-brace shape
11435        // so the gate's contract is "any `{` or `}` anywhere", not
11436        // single-byte coverage. Mirrors the peer
11437        // `validate_rejects_path_fonte_with_caminho_carrying_close_paren`
11438        // shape on the immediate-predecessor `FonteCaminhoShellSubshellGrouping`
11439        // arm.
11440        let d = dep_with_fonte(DepSource::Path {
11441            caminho: "../caixa-teia}".into(),
11442        });
11443        let err = d.validate().unwrap_err();
11444        let DepError::FonteCaminhoShellBraceExpansion { byte, .. } = err else {
11445            panic!("expected FonteCaminhoShellBraceExpansion, got {err:?}");
11446        };
11447        assert_eq!(byte, b'}');
11448    }
11449
11450    #[test]
11451    fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_brace() {
11452        // Leading-position `{` shape (`"{caixa-teia,caixa-helm}/build"`
11453        // — the canonical "I selected a `{a,b}` brace-expansion prefix
11454        // out of a shell-history one-liner" idiom). Pinned separately
11455        // from the embedded-byte shape so the gate covers every
11456        // position, not only mid-path.
11457        let d = dep_with_fonte(DepSource::Path {
11458            caminho: "{caixa-teia,caixa-helm}/build".into(),
11459        });
11460        let err = d.validate().unwrap_err();
11461        assert!(
11462            matches!(
11463                err,
11464                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
11465            ),
11466            "got {err:?}",
11467        );
11468    }
11469
11470    #[test]
11471    fn validate_rejects_path_fonte_with_caminho_carrying_uri_template_placeholder() {
11472        // The canonical URI-Template / Mustache / Helm doubled-brace
11473        // placeholder shape (`"../{{org}}/caixa-teia"` — the canonical
11474        // "I copied a `https://github.com/{{org}}/caixa-teia` README
11475        // quick-start / OpenAPI spec / Helm chart `home:` template
11476        // and forgot to substitute the placeholder" footgun). The arm
11477        // fires on the first `{` encountered; pinned so the gate's
11478        // coverage extends from the bare-brace shell-history shape to
11479        // the doubled-brace URI-Template / templating-engine shape.
11480        // Mirrors the peer 42d8f9d `is_git_repo_url` arm on the
11481        // sibling `:fonte :repo` axis.
11482        let d = dep_with_fonte(DepSource::Path {
11483            caminho: "../{{org}}/caixa-teia".into(),
11484        });
11485        let err = d.validate().unwrap_err();
11486        assert!(
11487            matches!(
11488                err,
11489                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
11490            ),
11491            "got {err:?}",
11492        );
11493    }
11494
11495    #[test]
11496    fn validate_rejects_path_fonte_with_caminho_carrying_brace_range_expansion() {
11497        // The canonical bash brace-range-expansion shape (`"../caixa-
11498        // v{1..10}"` — the `{1..10}` sequence expansion every bash /
11499        // zsh `for i in {1..10}; do …; done` idiom uses, the symmetric
11500        // sequence-range form to the `{a,b,c}` comma-separated form).
11501        // The arm fires on the first `{` encountered; pinned so the
11502        // gate's coverage extends from the comma-separated form to
11503        // the integer-range form.
11504        let d = dep_with_fonte(DepSource::Path {
11505            caminho: "../caixa-v{1..10}".into(),
11506        });
11507        let err = d.validate().unwrap_err();
11508        assert!(
11509            matches!(
11510                err,
11511                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
11512            ),
11513            "got {err:?}",
11514        );
11515    }
11516
11517    #[test]
11518    fn validate_accepts_path_fonte_with_caminho_carrying_no_brace_expansion() {
11519        // The positive-control pin: the gate targets only `{` / `}`,
11520        // never adjacent printable ASCII or POSIX-valid bytes. The
11521        // canonical relative POSIX path (`"../caixa-teia"`) and a
11522        // nested deeply-pathed variant with adjacent printable
11523        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue to
11524        // validate cleanly so the gate doesn't widen to a "no
11525        // printable punctuation anywhere" sweep that would defeat
11526        // the entire path-fonte author surface. Peer with
11527        // `validate_accepts_path_fonte_with_caminho_carrying_no_subshell_grouping`
11528        // on the immediate-predecessor arm.
11529        let d = dep_with_fonte(DepSource::Path {
11530            caminho: "../caixa-teia/sub-dir.v2".into(),
11531        });
11532        d.validate().unwrap();
11533    }
11534
11535    #[test]
11536    fn fonte_caminho_shell_subshell_grouping_fires_before_shell_brace_expansion() {
11537        // Cascade pin on the immediate-predecessor arm: a value
11538        // carrying both `(` and `{` (`"../(cd foo)/{a,b}"` — the
11539        // canonical "I pasted a subshell-grouping followed by a
11540        // brace-expansion tail" footgun) routes through
11541        // `FonteCaminhoShellSubshellGrouping` not
11542        // `FonteCaminhoShellBraceExpansion`. The subshell-grouping
11543        // shape is the more semantic-locating axis on every probe-
11544        // as-both value because it closes both halves of the modern
11545        // Bourne `$(<cmd>)` command-substitution surface — same
11546        // cascade discipline every prior `:caminho` arm establishes.
11547        let d = dep_with_fonte(DepSource::Path {
11548            caminho: "../(cd foo)/{a,b}".into(),
11549        });
11550        let err = d.validate().unwrap_err();
11551        assert!(
11552            matches!(
11553                err,
11554                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
11555            ),
11556            "got {err:?}",
11557        );
11558    }
11559
11560    #[test]
11561    fn fonte_caminho_shell_glob_fires_before_shell_brace_expansion() {
11562        // Cascade pin on the upstream shell-glob arm: a value carrying
11563        // both `*` and `{` (`"../caixa-teia/*{a,b}"` — the canonical
11564        // "I pasted a glob expansion followed by a brace-expansion
11565        // tail" footgun) routes through `FonteCaminhoShellGlob` not
11566        // `FonteCaminhoShellBraceExpansion`. The pathname-expansion
11567        // shape is the load-bearing root-cause edit on every
11568        // probe-as-both value.
11569        let d = dep_with_fonte(DepSource::Path {
11570            caminho: "../caixa-teia/*{a,b}".into(),
11571        });
11572        let err = d.validate().unwrap_err();
11573        assert!(
11574            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
11575            "got {err:?}",
11576        );
11577    }
11578
11579    #[test]
11580    fn fonte_caminho_shell_command_substitution_fires_before_shell_brace_expansion() {
11581        // Cascade pin on the upstream shell-command-substitution arm:
11582        // a value carrying both a backtick and `{` (``"../`whoami`/{a,b}"``
11583        // — the canonical "I pasted a legacy-backtick command-
11584        // substitution followed by a brace-expansion fan-out" footgun)
11585        // routes through `FonteCaminhoShellCommandSubstitution` not
11586        // `FonteCaminhoShellBraceExpansion`. The CWE-78 shell-
11587        // command-injection vector is the load-bearing root-cause
11588        // edit on every probe-as-both value.
11589        let d = dep_with_fonte(DepSource::Path {
11590            caminho: "../`whoami`/{a,b}".into(),
11591        });
11592        let err = d.validate().unwrap_err();
11593        assert!(
11594            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11595            "got {err:?}",
11596        );
11597    }
11598
11599    #[test]
11600    fn fonte_caminho_shell_background_fires_before_shell_brace_expansion() {
11601        // Cascade pin on the upstream shell-background arm: a value
11602        // carrying both `&` and `{` (`"../caixa-teia & {a,b}"` — the
11603        // canonical "I pasted a `cmd & {fork-fan}` background-launch
11604        // + brace-expansion chain" footgun) routes through
11605        // `FonteCaminhoShellBackground` not
11606        // `FonteCaminhoShellBraceExpansion`. The background-launch
11607        // tail is the load-bearing root-cause edit on every
11608        // probe-as-both value.
11609        let d = dep_with_fonte(DepSource::Path {
11610            caminho: "../caixa-teia & {a,b}".into(),
11611        });
11612        let err = d.validate().unwrap_err();
11613        assert!(
11614            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11615            "got {err:?}",
11616        );
11617    }
11618
11619    #[test]
11620    fn fonte_caminho_shell_semicolon_fires_before_shell_brace_expansion() {
11621        // Cascade pin on the upstream shell-semicolon arm: a value
11622        // carrying both `;` and `{` (`"../caixa-teia; {a,b}"` — the
11623        // canonical sequential-cleanup + brace-expansion paste
11624        // idiom) routes through `FonteCaminhoShellSemicolon` not
11625        // `FonteCaminhoShellBraceExpansion`. The sequential-command-
11626        // separator paste is the load-bearing root-cause edit on
11627        // every probe-as-both value.
11628        let d = dep_with_fonte(DepSource::Path {
11629            caminho: "../caixa-teia; {a,b}".into(),
11630        });
11631        let err = d.validate().unwrap_err();
11632        assert!(
11633            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11634            "got {err:?}",
11635        );
11636    }
11637
11638    #[test]
11639    fn fonte_caminho_shell_pipe_fires_before_shell_brace_expansion() {
11640        // Cascade pin on the upstream shell-pipe arm: a value
11641        // carrying both `|` and `{` (`"../caixa-teia | {tee,cat}"`
11642        // — the canonical pipeline-to-brace-expansion paste idiom)
11643        // routes through `FonteCaminhoShellPipe` not
11644        // `FonteCaminhoShellBraceExpansion`. The pipeline-tail paste
11645        // is the load-bearing root-cause edit on every probe-as-
11646        // both value.
11647        let d = dep_with_fonte(DepSource::Path {
11648            caminho: "../caixa-teia | {tee,cat}".into(),
11649        });
11650        let err = d.validate().unwrap_err();
11651        assert!(
11652            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11653            "got {err:?}",
11654        );
11655    }
11656
11657    #[test]
11658    fn fonte_caminho_shell_redirection_fires_before_shell_brace_expansion() {
11659        // Cascade pin on the upstream shell-redirection arm: a value
11660        // carrying both `>` and `{` (`"../caixa-teia>log {a,b}"` —
11661        // the canonical "I pasted a `cmd > log {a,b}` redirect-
11662        // plus-brace-expansion chain" footgun) routes through
11663        // `FonteCaminhoShellRedirection` not
11664        // `FonteCaminhoShellBraceExpansion`. The input/output
11665        // redirection metachar carries the more self-locating
11666        // `byte` payload, so the prior arm wins on every probe-
11667        // as-both value.
11668        let d = dep_with_fonte(DepSource::Path {
11669            caminho: "../caixa-teia>log {a,b}".into(),
11670        });
11671        let err = d.validate().unwrap_err();
11672        assert!(
11673            matches!(
11674                err,
11675                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11676            ),
11677            "got {err:?}",
11678        );
11679    }
11680
11681    #[test]
11682    fn fonte_caminho_backslash_fires_before_shell_brace_expansion() {
11683        // Cascade pin on the upstream backslash arm: a value
11684        // carrying both `\` and `{` (`"..\caixa-teia\{a,b}"` — the
11685        // canonical "I pasted a Windows-shell `cd ..\path\{a,b}`
11686        // chain") routes through `FonteCaminhoBackslash` not
11687        // `FonteCaminhoShellBraceExpansion`. The cross-host-OS-
11688        // separator divergence is the load-bearing axis on every
11689        // probe-as-both value.
11690        let d = dep_with_fonte(DepSource::Path {
11691            caminho: "..\\caixa-teia\\{a,b}".into(),
11692        });
11693        let err = d.validate().unwrap_err();
11694        assert!(
11695            matches!(err, DepError::FonteCaminhoBackslash { .. }),
11696            "got {err:?}",
11697        );
11698    }
11699
11700    #[test]
11701    fn fonte_caminho_control_char_fires_before_shell_brace_expansion() {
11702        // Cascade pin on the embedded-control-byte arm: a value
11703        // carrying both a control byte and `{` (`"../foo\n{a,b}"` —
11704        // the canonical paste-from-multiline-doc footgun where a
11705        // newline landed mid-caminho between two paste fragments)
11706        // routes through `FonteCaminhoControlChar` not
11707        // `FonteCaminhoShellBraceExpansion`. The POSIX-syscall-
11708        // rejected-byte / NUL-`CString::new`-fail diagnostic is the
11709        // load-bearing axis on every value that probes positive for
11710        // both — mirrors the cascade discipline on every prior arm.
11711        let d = dep_with_fonte(DepSource::Path {
11712            caminho: "../foo\n{a,b}".into(),
11713        });
11714        let err = d.validate().unwrap_err();
11715        assert!(
11716            matches!(err, DepError::FonteCaminhoControlChar { .. }),
11717            "got {err:?}",
11718        );
11719    }
11720
11721    #[test]
11722    fn fonte_caminho_absolute_fires_before_shell_brace_expansion() {
11723        // Cascade pin on the load-bearing leading-byte arm: a
11724        // leading `/` value with embedded `{` (`"/etc/{a,b}"`)
11725        // routes through `FonteCaminhoAbsolute` not
11726        // `FonteCaminhoShellBraceExpansion` — the host-layout-leak
11727        // diagnostic is the load-bearing axis, the brace-expansion
11728        // byte is the secondary observation. Same precedence logic
11729        // as every prior leading-byte arm.
11730        let d = dep_with_fonte(DepSource::Path {
11731            caminho: "/etc/{a,b}".into(),
11732        });
11733        let err = d.validate().unwrap_err();
11734        assert!(
11735            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11736            "got {err:?}",
11737        );
11738    }
11739
11740    #[test]
11741    fn fonte_caminho_var_expansion_fires_before_shell_brace_expansion() {
11742        // Cascade pin on the upstream leading-`$` var-expansion
11743        // arm: a value carrying both a leading `$` and a `{`
11744        // (`"${ORG}/caixa-teia"` — the canonical "I pasted a
11745        // `${ORG}` shell-variable + curly-brace expansion at the
11746        // head of a sibling-workspace path" footgun) routes through
11747        // `FonteCaminhoVarExpansion` not
11748        // `FonteCaminhoShellBraceExpansion`. The leading-byte
11749        // shell-variable-expansion is the more self-locating
11750        // diagnostic on values that probe as both — same
11751        // load-bearing-leading-byte cascade discipline every prior
11752        // `:caminho` arm establishes.
11753        let d = dep_with_fonte(DepSource::Path {
11754            caminho: "${ORG}/caixa-teia".into(),
11755        });
11756        let err = d.validate().unwrap_err();
11757        assert!(
11758            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
11759            "got {err:?}",
11760        );
11761    }
11762
11763    #[test]
11764    fn fonte_caminho_shell_brace_expansion_fires_before_trailing_slash() {
11765        // Cascade pin on the immediate-successor arm: a value
11766        // carrying both `{` and a trailing `/`
11767        // (`"../{caixa-teia,caixa-helm}/"` — the canonical "I
11768        // tab-completed a path that already had a brace-expansion
11769        // expansion tail" footgun) routes through
11770        // `FonteCaminhoShellBraceExpansion` not
11771        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
11772        // is the more semantic-locating axis (an author who removes
11773        // the `{` typically also drops the trailing separator since
11774        // both are paste-from-shell artifacts).
11775        let d = dep_with_fonte(DepSource::Path {
11776            caminho: "../{caixa-teia,caixa-helm}/".into(),
11777        });
11778        let err = d.validate().unwrap_err();
11779        assert!(
11780            matches!(
11781                err,
11782                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
11783            ),
11784            "got {err:?}",
11785        );
11786    }
11787
11788    #[test]
11789    fn fonte_caminho_shell_brace_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
11790        // Diagnostic-shape pin (peer with
11791        // `fonte_caminho_shell_subshell_grouping_diagnostic_carries_offending_dep_caminho_and_byte`
11792        // on the closest two-byte peer arm): the error's Display
11793        // surfaces the offending `:nome`, the offending `:caminho`
11794        // verbatim, the offending byte's hex / character form, and
11795        // names the shell-brace-expansion / URI-Template footgun
11796        // explicitly so a `feira lint` run can render the diagnostic
11797        // without re-parsing.
11798        let d = dep_with_fonte(DepSource::Path {
11799            caminho: "../{caixa-teia,caixa-helm}/build".into(),
11800        });
11801        let rendered = d.validate().unwrap_err().to_string();
11802        assert!(
11803            rendered.contains("caixa-teia"),
11804            "diagnostic must name the offending dep: {rendered}",
11805        );
11806        assert!(
11807            rendered.contains("../{caixa-teia,caixa-helm}/build"),
11808            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11809        );
11810        assert!(
11811            rendered.contains("0x7b"),
11812            "diagnostic must surface the offending byte hex: {rendered:?}",
11813        );
11814        assert!(
11815            rendered.contains("brace-expansion"),
11816            "diagnostic must name the shell-brace-expansion footgun: {rendered:?}",
11817        );
11818        assert!(
11819            rendered.contains("URI Template"),
11820            "diagnostic must reference the RFC-6570 URI-Template-placeholder vocabulary: \
11821             {rendered:?}",
11822        );
11823    }
11824
11825    #[test]
11826    fn validate_rejects_path_fonte_with_caminho_carrying_bracket_glob_character_class() {
11827        // The canonical paste-from-shell-history bracket-glob /
11828        // character-class footgun: an author copies a
11829        // `cd ../caixa-[a-z]/build` shell-history one-liner whose
11830        // `[a-z]` POSIX glob character-class matches every lowercase-
11831        // ASCII-suffix sibling caixa directory and silently passed
11832        // every prior arm (`Path::is_absolute` false on `..`, no
11833        // control bytes, no `\`, no `<` / `>`, no `|`, no `;`, no
11834        // `&`, no backtick, no `*` / `?`, no `(` / `)`, no `{` /
11835        // `}`, doesn't end in `/`; the leading-`$` f4efe9c
11836        // `FonteCaminhoVarExpansion` arm doesn't fire because the
11837        // value starts with `..` not `$`). The lacre embedded the
11838        // value verbatim, the resolver folded it through
11839        // `Path::join` looking for a literal `./../caixa-[a-z]/
11840        // build` subdirectory, and the failure surfaced at resolve
11841        // time with a non-self-locating `No such file or directory`
11842        // error. The new arm moves the rejection to validate time
11843        // and names the offending dep + caminho + byte verbatim.
11844        // The arm fires on the first `[` encountered.
11845        let d = dep_with_fonte(DepSource::Path {
11846            caminho: "../caixa-[a-z]/build".into(),
11847        });
11848        let err = d.validate().unwrap_err();
11849        let DepError::FonteCaminhoShellBracketExpansion {
11850            nome,
11851            caminho,
11852            byte,
11853        } = err
11854        else {
11855            panic!("expected FonteCaminhoShellBracketExpansion, got {err:?}");
11856        };
11857        assert_eq!(nome, "caixa-teia");
11858        assert_eq!(caminho, "../caixa-[a-z]/build");
11859        assert_eq!(byte, b'[');
11860    }
11861
11862    #[test]
11863    fn validate_rejects_path_fonte_with_caminho_carrying_close_bracket() {
11864        // The symmetric close-bracket paste shape (`"../caixa-teia]"`
11865        // — the degenerate "I selected an unbalanced closing bracket
11866        // out of a glob character-class block" idiom that probes for
11867        // the cascade's last-byte handling on a value carrying only
11868        // the closing byte). Pinned separately from the open-bracket
11869        // shape so the gate's contract is "any `[` or `]` anywhere",
11870        // not single-byte coverage. Mirrors the peer
11871        // `validate_rejects_path_fonte_with_caminho_carrying_close_brace`
11872        // shape on the immediate-predecessor
11873        // `FonteCaminhoShellBraceExpansion` arm.
11874        let d = dep_with_fonte(DepSource::Path {
11875            caminho: "../caixa-teia]".into(),
11876        });
11877        let err = d.validate().unwrap_err();
11878        let DepError::FonteCaminhoShellBracketExpansion { byte, .. } = err else {
11879            panic!("expected FonteCaminhoShellBracketExpansion, got {err:?}");
11880        };
11881        assert_eq!(byte, b']');
11882    }
11883
11884    #[test]
11885    fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_bracket() {
11886        // Leading-position `[` shape (`"[caixa-teia]/build"` — the
11887        // canonical "I selected a `[caixa-teia]` TOML-table-header /
11888        // glob-character-class prefix out of an aligned config /
11889        // shell-history one-liner" idiom). Pinned separately from
11890        // the embedded-byte shape so the gate covers every position,
11891        // not only mid-path.
11892        let d = dep_with_fonte(DepSource::Path {
11893            caminho: "[caixa-teia]/build".into(),
11894        });
11895        let err = d.validate().unwrap_err();
11896        assert!(
11897            matches!(
11898                err,
11899                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
11900            ),
11901            "got {err:?}",
11902        );
11903    }
11904
11905    #[test]
11906    fn validate_rejects_path_fonte_with_caminho_carrying_toml_inline_array() {
11907        // The canonical TOML inline-array / YAML flow-sequence
11908        // paste shape (`"../[\"a\", \"b\"]/caixa-teia"` — the
11909        // canonical "I copied a `features = [\"a\", \"b\"]` TOML
11910        // inline-array out of a sibling-Cargo manifest" cross-idiom
11911        // leak; the symmetric YAML flow-sequence form `paths: [/a,
11912        // /b]` paste-from-values.yaml shape carries the same
11913        // bracket pair). The arm fires on the first `[` encountered;
11914        // pinned so the gate's coverage extends from the bare-
11915        // bracket glob-character-class shape to the TOML / YAML /
11916        // JSON array-literal shape.
11917        let d = dep_with_fonte(DepSource::Path {
11918            caminho: "../[\"a\", \"b\"]/caixa-teia".into(),
11919        });
11920        let err = d.validate().unwrap_err();
11921        assert!(
11922            matches!(
11923                err,
11924                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
11925            ),
11926            "got {err:?}",
11927        );
11928    }
11929
11930    #[test]
11931    fn validate_rejects_path_fonte_with_caminho_carrying_shell_test_builtin() {
11932        // The canonical POSIX `test` / `[` builtin command paste
11933        // shape (`"../[ -d caixa-teia ]"` — the `[ <expr> ]` shell-
11934        // script conditional every paste-from-shell-script idiom
11935        // carries; bash's `[[ <expr> ]]` extended-test grammar
11936        // would surface the same byte pair). The arm fires on the
11937        // first `[` encountered; pinned so the gate's coverage
11938        // extends from the embedded-glob-character-class shape to
11939        // the leading-`test`-builtin / extended-test form.
11940        let d = dep_with_fonte(DepSource::Path {
11941            caminho: "../[ -d caixa-teia ]".into(),
11942        });
11943        let err = d.validate().unwrap_err();
11944        assert!(
11945            matches!(
11946                err,
11947                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
11948            ),
11949            "got {err:?}",
11950        );
11951    }
11952
11953    #[test]
11954    fn validate_accepts_path_fonte_with_caminho_carrying_no_bracket_expansion() {
11955        // The positive-control pin: the gate targets only `[` /
11956        // `]`, never adjacent printable ASCII or POSIX-valid bytes.
11957        // The canonical relative POSIX path (`"../caixa-teia"`) and
11958        // a nested deeply-pathed variant with adjacent printable
11959        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
11960        // to validate cleanly so the gate doesn't widen to a "no
11961        // printable punctuation anywhere" sweep that would defeat
11962        // the entire path-fonte author surface. Peer with
11963        // `validate_accepts_path_fonte_with_caminho_carrying_no_brace_expansion`
11964        // on the immediate-predecessor arm.
11965        let d = dep_with_fonte(DepSource::Path {
11966            caminho: "../caixa-teia/sub-dir.v2".into(),
11967        });
11968        d.validate().unwrap();
11969    }
11970
11971    #[test]
11972    fn fonte_caminho_shell_brace_expansion_fires_before_shell_bracket_expansion() {
11973        // Cascade pin on the immediate-predecessor arm: a value
11974        // carrying both `{` and `[` (`"../{a,b}[ch]"` — the
11975        // canonical "I pasted a brace-expansion fan followed by a
11976        // glob-character-class tail" footgun) routes through
11977        // `FonteCaminhoShellBraceExpansion` not
11978        // `FonteCaminhoShellBracketExpansion`. The brace-expansion
11979        // fan is the load-bearing root-cause edit on every
11980        // probe-as-both value because the bracket-class tail
11981        // typically rides on a prior brace-expansion expansion;
11982        // same cascade discipline every prior `:caminho` arm
11983        // establishes.
11984        let d = dep_with_fonte(DepSource::Path {
11985            caminho: "../{a,b}[ch]".into(),
11986        });
11987        let err = d.validate().unwrap_err();
11988        assert!(
11989            matches!(
11990                err,
11991                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
11992            ),
11993            "got {err:?}",
11994        );
11995    }
11996
11997    #[test]
11998    fn fonte_caminho_shell_subshell_grouping_fires_before_shell_bracket_expansion() {
11999        // Cascade pin on the upstream shell-subshell-grouping arm:
12000        // a value carrying both `(` and `[` (`"../(cd foo)/[ch]"` —
12001        // the canonical "I pasted a subshell-grouping followed by
12002        // a glob-character-class tail" footgun) routes through
12003        // `FonteCaminhoShellSubshellGrouping` not
12004        // `FonteCaminhoShellBracketExpansion`. The modern Bourne
12005        // `$(<cmd>)` command-substitution boundary is the load-
12006        // bearing axis on every probe-as-both value.
12007        let d = dep_with_fonte(DepSource::Path {
12008            caminho: "../(cd foo)/[ch]".into(),
12009        });
12010        let err = d.validate().unwrap_err();
12011        assert!(
12012            matches!(
12013                err,
12014                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
12015            ),
12016            "got {err:?}",
12017        );
12018    }
12019
12020    #[test]
12021    fn fonte_caminho_shell_glob_fires_before_shell_bracket_expansion() {
12022        // Cascade pin on the upstream shell-glob arm: a value
12023        // carrying both `*` and `[` (`"../caixa-teia/*[ch]"` — the
12024        // canonical "I pasted a `*.[ch]` C-source-file glob whose
12025        // unbounded `*` precedes the bracket character-class"
12026        // footgun) routes through `FonteCaminhoShellGlob` not
12027        // `FonteCaminhoShellBracketExpansion`. The unbounded
12028        // pathname-expansion sentinel is the load-bearing root-
12029        // cause edit on every probe-as-both value — the unbounded
12030        // `*` carries the more aggressive expansion vector than
12031        // the bounded `[ch]` class, so the prior arm wins.
12032        let d = dep_with_fonte(DepSource::Path {
12033            caminho: "../caixa-teia/*[ch]".into(),
12034        });
12035        let err = d.validate().unwrap_err();
12036        assert!(
12037            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12038            "got {err:?}",
12039        );
12040    }
12041
12042    #[test]
12043    fn fonte_caminho_shell_command_substitution_fires_before_shell_bracket_expansion() {
12044        // Cascade pin on the upstream shell-command-substitution
12045        // arm: a value carrying both a backtick and `[`
12046        // (``"../`whoami`/[ch]"`` — the canonical "I pasted a
12047        // legacy-backtick command-substitution followed by a
12048        // glob-character-class tail" footgun) routes through
12049        // `FonteCaminhoShellCommandSubstitution` not
12050        // `FonteCaminhoShellBracketExpansion`. The CWE-78 shell-
12051        // command-injection vector is the load-bearing root-cause
12052        // edit on every probe-as-both value.
12053        let d = dep_with_fonte(DepSource::Path {
12054            caminho: "../`whoami`/[ch]".into(),
12055        });
12056        let err = d.validate().unwrap_err();
12057        assert!(
12058            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
12059            "got {err:?}",
12060        );
12061    }
12062
12063    #[test]
12064    fn fonte_caminho_shell_background_fires_before_shell_bracket_expansion() {
12065        // Cascade pin on the upstream shell-background arm: a
12066        // value carrying both `&` and `[` (`"../caixa-teia & [ch]"`
12067        // — the canonical "I pasted a `cmd & [glob]` background-
12068        // launch + bracket-class chain" footgun) routes through
12069        // `FonteCaminhoShellBackground` not
12070        // `FonteCaminhoShellBracketExpansion`. The background-
12071        // launch tail is the load-bearing root-cause edit on
12072        // every probe-as-both value.
12073        let d = dep_with_fonte(DepSource::Path {
12074            caminho: "../caixa-teia & [ch]".into(),
12075        });
12076        let err = d.validate().unwrap_err();
12077        assert!(
12078            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
12079            "got {err:?}",
12080        );
12081    }
12082
12083    #[test]
12084    fn fonte_caminho_shell_semicolon_fires_before_shell_bracket_expansion() {
12085        // Cascade pin on the upstream shell-semicolon arm: a value
12086        // carrying both `;` and `[` (`"../caixa-teia; [ch]"` — the
12087        // canonical sequential-cleanup + bracket-class paste
12088        // idiom) routes through `FonteCaminhoShellSemicolon` not
12089        // `FonteCaminhoShellBracketExpansion`. The sequential-
12090        // command-separator paste is the load-bearing root-cause
12091        // edit on every probe-as-both value.
12092        let d = dep_with_fonte(DepSource::Path {
12093            caminho: "../caixa-teia; [ch]".into(),
12094        });
12095        let err = d.validate().unwrap_err();
12096        assert!(
12097            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
12098            "got {err:?}",
12099        );
12100    }
12101
12102    #[test]
12103    fn fonte_caminho_shell_pipe_fires_before_shell_bracket_expansion() {
12104        // Cascade pin on the upstream shell-pipe arm: a value
12105        // carrying both `|` and `[` (`"../caixa-teia | [tee]"` —
12106        // the canonical pipeline-to-bracket-class paste idiom)
12107        // routes through `FonteCaminhoShellPipe` not
12108        // `FonteCaminhoShellBracketExpansion`. The pipeline-tail
12109        // paste is the load-bearing root-cause edit on every
12110        // probe-as-both value.
12111        let d = dep_with_fonte(DepSource::Path {
12112            caminho: "../caixa-teia | [tee]".into(),
12113        });
12114        let err = d.validate().unwrap_err();
12115        assert!(
12116            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
12117            "got {err:?}",
12118        );
12119    }
12120
12121    #[test]
12122    fn fonte_caminho_shell_redirection_fires_before_shell_bracket_expansion() {
12123        // Cascade pin on the upstream shell-redirection arm: a
12124        // value carrying both `>` and `[` (`"../caixa-teia>log
12125        // [ch]"` — the canonical "I pasted a `cmd > log [glob]`
12126        // redirect-plus-bracket chain" footgun) routes through
12127        // `FonteCaminhoShellRedirection` not
12128        // `FonteCaminhoShellBracketExpansion`. The input/output
12129        // redirection metachar carries the more self-locating
12130        // `byte` payload, so the prior arm wins on every
12131        // probe-as-both value.
12132        let d = dep_with_fonte(DepSource::Path {
12133            caminho: "../caixa-teia>log [ch]".into(),
12134        });
12135        let err = d.validate().unwrap_err();
12136        assert!(
12137            matches!(
12138                err,
12139                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
12140            ),
12141            "got {err:?}",
12142        );
12143    }
12144
12145    #[test]
12146    fn fonte_caminho_backslash_fires_before_shell_bracket_expansion() {
12147        // Cascade pin on the upstream backslash arm: a value
12148        // carrying both `\` and `[` (`"..\caixa-teia\[ch]"` — the
12149        // canonical "I pasted a Windows-shell `cd ..\path\[glob]`
12150        // chain") routes through `FonteCaminhoBackslash` not
12151        // `FonteCaminhoShellBracketExpansion`. The cross-host-OS-
12152        // separator divergence is the load-bearing axis on every
12153        // probe-as-both value.
12154        let d = dep_with_fonte(DepSource::Path {
12155            caminho: "..\\caixa-teia\\[ch]".into(),
12156        });
12157        let err = d.validate().unwrap_err();
12158        assert!(
12159            matches!(err, DepError::FonteCaminhoBackslash { .. }),
12160            "got {err:?}",
12161        );
12162    }
12163
12164    #[test]
12165    fn fonte_caminho_control_char_fires_before_shell_bracket_expansion() {
12166        // Cascade pin on the embedded-control-byte arm: a value
12167        // carrying both a control byte and `[` (`"../foo\n[ch]"` —
12168        // the canonical paste-from-multiline-doc footgun where a
12169        // newline landed mid-caminho between two paste fragments)
12170        // routes through `FonteCaminhoControlChar` not
12171        // `FonteCaminhoShellBracketExpansion`. The POSIX-syscall-
12172        // rejected-byte / NUL-`CString::new`-fail diagnostic is
12173        // the load-bearing axis on every value that probes
12174        // positive for both — mirrors the cascade discipline on
12175        // every prior arm.
12176        let d = dep_with_fonte(DepSource::Path {
12177            caminho: "../foo\n[ch]".into(),
12178        });
12179        let err = d.validate().unwrap_err();
12180        assert!(
12181            matches!(err, DepError::FonteCaminhoControlChar { .. }),
12182            "got {err:?}",
12183        );
12184    }
12185
12186    #[test]
12187    fn fonte_caminho_absolute_fires_before_shell_bracket_expansion() {
12188        // Cascade pin on the load-bearing leading-byte arm: a
12189        // leading `/` value with embedded `[` (`"/etc/[ch]"`)
12190        // routes through `FonteCaminhoAbsolute` not
12191        // `FonteCaminhoShellBracketExpansion` — the host-layout-
12192        // leak diagnostic is the load-bearing axis, the bracket-
12193        // expansion byte is the secondary observation. Same
12194        // precedence logic as every prior leading-byte arm.
12195        let d = dep_with_fonte(DepSource::Path {
12196            caminho: "/etc/[ch]".into(),
12197        });
12198        let err = d.validate().unwrap_err();
12199        assert!(
12200            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
12201            "got {err:?}",
12202        );
12203    }
12204
12205    #[test]
12206    fn fonte_caminho_var_expansion_fires_before_shell_bracket_expansion() {
12207        // Cascade pin on the upstream leading-`$` var-expansion
12208        // arm: a value carrying both a leading `$` and a `[`
12209        // (`"$DIR/[ch]"` — the canonical "I pasted a `$DIR` shell-
12210        // variable + bracket-class at the head of a sibling-
12211        // workspace path" footgun) routes through
12212        // `FonteCaminhoVarExpansion` not
12213        // `FonteCaminhoShellBracketExpansion`. The leading-byte
12214        // shell-variable-expansion is the more self-locating
12215        // diagnostic on values that probe as both — same
12216        // load-bearing-leading-byte cascade discipline every
12217        // prior `:caminho` arm establishes.
12218        let d = dep_with_fonte(DepSource::Path {
12219            caminho: "$DIR/[ch]".into(),
12220        });
12221        let err = d.validate().unwrap_err();
12222        assert!(
12223            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
12224            "got {err:?}",
12225        );
12226    }
12227
12228    #[test]
12229    fn fonte_caminho_shell_bracket_expansion_fires_before_trailing_slash() {
12230        // Cascade pin on the immediate-successor arm: a value
12231        // carrying both `[` and a trailing `/` (`"../[a-z]/"` —
12232        // the canonical "I tab-completed a path that already had
12233        // a bracket-glob-character-class expansion tail" footgun)
12234        // routes through `FonteCaminhoShellBracketExpansion` not
12235        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
12236        // is the more semantic-locating axis (an author who
12237        // removes the `[` typically also drops the trailing
12238        // separator since both are paste-from-shell artifacts).
12239        let d = dep_with_fonte(DepSource::Path {
12240            caminho: "../[a-z]/".into(),
12241        });
12242        let err = d.validate().unwrap_err();
12243        assert!(
12244            matches!(
12245                err,
12246                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
12247            ),
12248            "got {err:?}",
12249        );
12250    }
12251
12252    #[test]
12253    fn fonte_caminho_shell_bracket_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
12254        // Diagnostic-shape pin (peer with
12255        // `fonte_caminho_shell_brace_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
12256        // on the closest two-byte peer arm): the error's Display
12257        // surfaces the offending `:nome`, the offending `:caminho`
12258        // verbatim, the offending byte's hex / character form, and
12259        // names the shell-bracket-expansion / glob-character-class
12260        // footgun explicitly so a `feira lint` run can render the
12261        // diagnostic without re-parsing.
12262        let d = dep_with_fonte(DepSource::Path {
12263            caminho: "../caixa-[a-z]/build".into(),
12264        });
12265        let rendered = d.validate().unwrap_err().to_string();
12266        assert!(
12267            rendered.contains("caixa-teia"),
12268            "diagnostic must name the offending dep: {rendered}",
12269        );
12270        assert!(
12271            rendered.contains("../caixa-[a-z]/build"),
12272            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
12273        );
12274        assert!(
12275            rendered.contains("0x5b"),
12276            "diagnostic must surface the offending byte hex: {rendered:?}",
12277        );
12278        assert!(
12279            rendered.contains("bracket-expansion"),
12280            "diagnostic must name the shell-bracket-expansion footgun: {rendered:?}",
12281        );
12282        assert!(
12283            rendered.contains("glob-character-class"),
12284            "diagnostic must reference the POSIX glob-character-class vocabulary: \
12285             {rendered:?}",
12286        );
12287    }
12288
12289    #[test]
12290    fn validate_rejects_path_fonte_with_caminho_carrying_single_quote_grouping() {
12291        // The canonical paste-from-shell-history strong-quoted
12292        // sibling-workspace-path footgun: an author copies a
12293        // `cd '../caixa-teia'` shell-history one-liner whose strong-
12294        // quoting preserved the path across a whitespace paste
12295        // boundary and silently passed every prior arm
12296        // (`Path::is_absolute` false on `'..`, no control bytes, no
12297        // `\`, no `<` / `>`, no `|`, no `;`, no `&`, no backtick, no
12298        // `*` / `?`, no `(` / `)`, no `{` / `}`, no `[` / `]`,
12299        // doesn't end in `/`; the leading-`$` f4efe9c
12300        // `FonteCaminhoVarExpansion` arm doesn't fire because the
12301        // value starts with `'` not `$`). The lacre embedded the
12302        // value verbatim, the resolver folded it through
12303        // `Path::join` looking for a literal `./'../caixa-teia'`
12304        // subdirectory, and the failure surfaced at resolve time
12305        // with a non-self-locating `No such file or directory`
12306        // error. The new arm moves the rejection to validate time
12307        // and names the offending dep + caminho + byte verbatim.
12308        // The arm fires on the first `'` encountered.
12309        let d = dep_with_fonte(DepSource::Path {
12310            caminho: "'../caixa-teia'".into(),
12311        });
12312        let err = d.validate().unwrap_err();
12313        let DepError::FonteCaminhoShellQuoteGrouping {
12314            nome,
12315            caminho,
12316            byte,
12317        } = err
12318        else {
12319            panic!("expected FonteCaminhoShellQuoteGrouping, got {err:?}");
12320        };
12321        assert_eq!(nome, "caixa-teia");
12322        assert_eq!(caminho, "'../caixa-teia'");
12323        assert_eq!(byte, b'\'');
12324    }
12325
12326    #[test]
12327    fn validate_rejects_path_fonte_with_caminho_carrying_double_quote_grouping() {
12328        // The symmetric weak-quoted paste shape (`"\"../caixa-teia\""`
12329        // — the canonical paste-from-JSON-config / paste-from-YAML-
12330        // flow-scalar / paste-from-TOML-basic-string / paste-from-
12331        // tatara-lisp-string-literal cross-idiom leak). Pinned
12332        // separately from the single-quote shape so the gate's
12333        // contract is "any `'` or `\"` anywhere", not single-byte
12334        // coverage. Mirrors the peer
12335        // `validate_rejects_path_fonte_with_caminho_carrying_close_bracket`
12336        // shape on the immediate-predecessor
12337        // `FonteCaminhoShellBracketExpansion` arm.
12338        let d = dep_with_fonte(DepSource::Path {
12339            caminho: "\"../caixa-teia\"".into(),
12340        });
12341        let err = d.validate().unwrap_err();
12342        let DepError::FonteCaminhoShellQuoteGrouping { byte, .. } = err else {
12343            panic!("expected FonteCaminhoShellQuoteGrouping, got {err:?}");
12344        };
12345        assert_eq!(byte, b'"');
12346    }
12347
12348    #[test]
12349    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_double_quote() {
12350        // Embedded-position `"` shape (`"../\"caixa-teia\""` — the
12351        // canonical "I pasted a JSON key-value pair fragment into
12352        // the middle of the path" idiom). Pinned separately from
12353        // the leading-byte shape so the gate covers every position,
12354        // not only leading.
12355        let d = dep_with_fonte(DepSource::Path {
12356            caminho: "../\"caixa-teia\"".into(),
12357        });
12358        let err = d.validate().unwrap_err();
12359        assert!(
12360            matches!(
12361                err,
12362                DepError::FonteCaminhoShellQuoteGrouping { byte: b'"', .. },
12363            ),
12364            "got {err:?}",
12365        );
12366    }
12367
12368    #[test]
12369    fn validate_rejects_path_fonte_with_caminho_carrying_yaml_flow_scalar_paste() {
12370        // The canonical YAML double-quoted flow-scalar cross-idiom
12371        // leak shape (`"path: \"../caixa-teia\""` — the "I copied a
12372        // `path: \"...\"` YAML flow-scalar entry out of an aligned
12373        // values.yaml / K8s manifest and dropped it verbatim into
12374        // the `:caminho` slot including the `path: ` key prefix"
12375        // paste-idiom). The arm fires on the first `"` encountered;
12376        // pinned so the gate's coverage extends from the bare-quote
12377        // paste shape to the aligned-YAML-manifest cross-idiom-leak
12378        // shape.
12379        let d = dep_with_fonte(DepSource::Path {
12380            caminho: "path: \"../caixa-teia\"".into(),
12381        });
12382        let err = d.validate().unwrap_err();
12383        assert!(
12384            matches!(
12385                err,
12386                DepError::FonteCaminhoShellQuoteGrouping { byte: b'"', .. },
12387            ),
12388            "got {err:?}",
12389        );
12390    }
12391
12392    #[test]
12393    fn validate_accepts_path_fonte_with_caminho_carrying_no_quote_grouping() {
12394        // The positive-control pin: the gate targets only `'` /
12395        // `"`, never adjacent printable ASCII or POSIX-valid bytes.
12396        // The canonical relative POSIX path (`"../caixa-teia"`) and
12397        // a nested deeply-pathed variant with adjacent printable
12398        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
12399        // to validate cleanly so the gate doesn't widen to a "no
12400        // printable punctuation anywhere" sweep that would defeat
12401        // the entire path-fonte author surface. Peer with
12402        // `validate_accepts_path_fonte_with_caminho_carrying_no_bracket_expansion`
12403        // on the immediate-predecessor arm.
12404        let d = dep_with_fonte(DepSource::Path {
12405            caminho: "../caixa-teia/sub-dir.v2".into(),
12406        });
12407        d.validate().unwrap();
12408    }
12409
12410    #[test]
12411    fn fonte_caminho_shell_bracket_expansion_fires_before_shell_quote_grouping() {
12412        // Cascade pin on the immediate-predecessor arm: a value
12413        // carrying both `[` and `'` (`"../[a-z]'x'"` — the canonical
12414        // "I pasted a glob-character-class followed by a strong-
12415        // quoted literal tail" footgun) routes through
12416        // `FonteCaminhoShellBracketExpansion` not
12417        // `FonteCaminhoShellQuoteGrouping`. The glob-character-class
12418        // expansion is the load-bearing root-cause edit on every
12419        // probe-as-both value; same cascade discipline every prior
12420        // `:caminho` arm establishes.
12421        let d = dep_with_fonte(DepSource::Path {
12422            caminho: "../[a-z]'x'".into(),
12423        });
12424        let err = d.validate().unwrap_err();
12425        assert!(
12426            matches!(
12427                err,
12428                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
12429            ),
12430            "got {err:?}",
12431        );
12432    }
12433
12434    #[test]
12435    fn fonte_caminho_shell_brace_expansion_fires_before_shell_quote_grouping() {
12436        // Cascade pin on the upstream shell-brace-expansion arm: a
12437        // value carrying both `{` and `'` (`"../{a,b}'x'"` — the
12438        // canonical "I pasted a brace-expansion fan followed by a
12439        // strong-quoted literal tail" footgun) routes through
12440        // `FonteCaminhoShellBraceExpansion` not
12441        // `FonteCaminhoShellQuoteGrouping`. The brace-expansion fan
12442        // is the load-bearing root-cause edit on every probe-as-
12443        // both value.
12444        let d = dep_with_fonte(DepSource::Path {
12445            caminho: "../{a,b}'x'".into(),
12446        });
12447        let err = d.validate().unwrap_err();
12448        assert!(
12449            matches!(
12450                err,
12451                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
12452            ),
12453            "got {err:?}",
12454        );
12455    }
12456
12457    #[test]
12458    fn fonte_caminho_shell_subshell_grouping_fires_before_shell_quote_grouping() {
12459        // Cascade pin on the upstream shell-subshell-grouping arm:
12460        // a value carrying both `(` and `'` (`"../(cd foo)/'x'"` —
12461        // the canonical "I pasted a subshell-grouping followed by
12462        // a strong-quoted literal tail" footgun) routes through
12463        // `FonteCaminhoShellSubshellGrouping` not
12464        // `FonteCaminhoShellQuoteGrouping`. The modern Bourne
12465        // `$(<cmd>)` command-substitution boundary is the load-
12466        // bearing axis on every probe-as-both value.
12467        let d = dep_with_fonte(DepSource::Path {
12468            caminho: "../(cd foo)/'x'".into(),
12469        });
12470        let err = d.validate().unwrap_err();
12471        assert!(
12472            matches!(
12473                err,
12474                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
12475            ),
12476            "got {err:?}",
12477        );
12478    }
12479
12480    #[test]
12481    fn fonte_caminho_shell_glob_fires_before_shell_quote_grouping() {
12482        // Cascade pin on the upstream shell-glob arm: a value
12483        // carrying both `*` and `'` (`"../caixa-teia/*'x'"` — the
12484        // canonical "I pasted a `*` unbounded pathname-expansion
12485        // followed by a strong-quoted literal tail" footgun) routes
12486        // through `FonteCaminhoShellGlob` not
12487        // `FonteCaminhoShellQuoteGrouping`. The unbounded pathname-
12488        // expansion sentinel is the load-bearing root-cause edit
12489        // on every probe-as-both value.
12490        let d = dep_with_fonte(DepSource::Path {
12491            caminho: "../caixa-teia/*'x'".into(),
12492        });
12493        let err = d.validate().unwrap_err();
12494        assert!(
12495            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12496            "got {err:?}",
12497        );
12498    }
12499
12500    #[test]
12501    fn fonte_caminho_shell_command_substitution_fires_before_shell_quote_grouping() {
12502        // Cascade pin on the upstream shell-command-substitution
12503        // arm: a value carrying both a backtick and `'`
12504        // (``"../`whoami`/'x'"`` — the canonical "I pasted a
12505        // legacy-backtick command-substitution followed by a
12506        // strong-quoted literal tail" footgun) routes through
12507        // `FonteCaminhoShellCommandSubstitution` not
12508        // `FonteCaminhoShellQuoteGrouping`. The CWE-78 shell-
12509        // command-injection vector is the load-bearing root-cause
12510        // edit on every probe-as-both value.
12511        let d = dep_with_fonte(DepSource::Path {
12512            caminho: "../`whoami`/'x'".into(),
12513        });
12514        let err = d.validate().unwrap_err();
12515        assert!(
12516            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
12517            "got {err:?}",
12518        );
12519    }
12520
12521    #[test]
12522    fn fonte_caminho_shell_background_fires_before_shell_quote_grouping() {
12523        // Cascade pin on the upstream shell-background arm: a value
12524        // carrying both `&` and `'` (`"../caixa-teia & 'x'"` — the
12525        // canonical "I pasted a `cmd & 'literal'` background-launch
12526        // + quote chain" footgun) routes through
12527        // `FonteCaminhoShellBackground` not
12528        // `FonteCaminhoShellQuoteGrouping`. The background-launch
12529        // tail is the load-bearing root-cause edit on every
12530        // probe-as-both value.
12531        let d = dep_with_fonte(DepSource::Path {
12532            caminho: "../caixa-teia & 'x'".into(),
12533        });
12534        let err = d.validate().unwrap_err();
12535        assert!(
12536            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
12537            "got {err:?}",
12538        );
12539    }
12540
12541    #[test]
12542    fn fonte_caminho_shell_semicolon_fires_before_shell_quote_grouping() {
12543        // Cascade pin on the upstream shell-semicolon arm: a value
12544        // carrying both `;` and `'` (`"../caixa-teia; 'x'"` — the
12545        // canonical sequential-cleanup + quote paste idiom) routes
12546        // through `FonteCaminhoShellSemicolon` not
12547        // `FonteCaminhoShellQuoteGrouping`. The sequential-command-
12548        // separator paste is the load-bearing root-cause edit on
12549        // every probe-as-both value.
12550        let d = dep_with_fonte(DepSource::Path {
12551            caminho: "../caixa-teia; 'x'".into(),
12552        });
12553        let err = d.validate().unwrap_err();
12554        assert!(
12555            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
12556            "got {err:?}",
12557        );
12558    }
12559
12560    #[test]
12561    fn fonte_caminho_shell_pipe_fires_before_shell_quote_grouping() {
12562        // Cascade pin on the upstream shell-pipe arm: a value
12563        // carrying both `|` and `'` (`"../caixa-teia | 'x'"` — the
12564        // canonical pipeline-to-quoted-literal paste idiom) routes
12565        // through `FonteCaminhoShellPipe` not
12566        // `FonteCaminhoShellQuoteGrouping`. The pipeline-tail paste
12567        // is the load-bearing root-cause edit on every probe-as-
12568        // both value.
12569        let d = dep_with_fonte(DepSource::Path {
12570            caminho: "../caixa-teia | 'x'".into(),
12571        });
12572        let err = d.validate().unwrap_err();
12573        assert!(
12574            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
12575            "got {err:?}",
12576        );
12577    }
12578
12579    #[test]
12580    fn fonte_caminho_shell_redirection_fires_before_shell_quote_grouping() {
12581        // Cascade pin on the upstream shell-redirection arm: a
12582        // value carrying both `>` and `'` (`"../caixa-teia>log 'x'"`
12583        // — the canonical "I pasted a `cmd > log 'literal'`
12584        // redirect-plus-quote chain" footgun) routes through
12585        // `FonteCaminhoShellRedirection` not
12586        // `FonteCaminhoShellQuoteGrouping`. The input/output
12587        // redirection metachar carries the more self-locating
12588        // `byte` payload, so the prior arm wins on every probe-as-
12589        // both value.
12590        let d = dep_with_fonte(DepSource::Path {
12591            caminho: "../caixa-teia>log 'x'".into(),
12592        });
12593        let err = d.validate().unwrap_err();
12594        assert!(
12595            matches!(
12596                err,
12597                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
12598            ),
12599            "got {err:?}",
12600        );
12601    }
12602
12603    #[test]
12604    fn fonte_caminho_backslash_fires_before_shell_quote_grouping() {
12605        // Cascade pin on the upstream backslash arm: a value
12606        // carrying both `\` and `'` (`"..\caixa-teia\'x'"` — the
12607        // canonical "I pasted a Windows-shell `cd ..\path\'literal'`
12608        // chain" footgun) routes through `FonteCaminhoBackslash`
12609        // not `FonteCaminhoShellQuoteGrouping`. The cross-host-OS-
12610        // separator divergence is the load-bearing axis on every
12611        // probe-as-both value.
12612        let d = dep_with_fonte(DepSource::Path {
12613            caminho: "..\\caixa-teia\\'x'".into(),
12614        });
12615        let err = d.validate().unwrap_err();
12616        assert!(
12617            matches!(err, DepError::FonteCaminhoBackslash { .. }),
12618            "got {err:?}",
12619        );
12620    }
12621
12622    #[test]
12623    fn fonte_caminho_control_char_fires_before_shell_quote_grouping() {
12624        // Cascade pin on the embedded-control-byte arm: a value
12625        // carrying both a control byte and `'` (`"../foo\n'x'"` —
12626        // the canonical paste-from-multiline-doc footgun where a
12627        // newline landed mid-caminho between two paste fragments)
12628        // routes through `FonteCaminhoControlChar` not
12629        // `FonteCaminhoShellQuoteGrouping`. The POSIX-syscall-
12630        // rejected-byte / NUL-`CString::new`-fail diagnostic is
12631        // the load-bearing axis on every value that probes
12632        // positive for both — mirrors the cascade discipline on
12633        // every prior arm.
12634        let d = dep_with_fonte(DepSource::Path {
12635            caminho: "../foo\n'x'".into(),
12636        });
12637        let err = d.validate().unwrap_err();
12638        assert!(
12639            matches!(err, DepError::FonteCaminhoControlChar { .. }),
12640            "got {err:?}",
12641        );
12642    }
12643
12644    #[test]
12645    fn fonte_caminho_absolute_fires_before_shell_quote_grouping() {
12646        // Cascade pin on the load-bearing leading-byte arm: a
12647        // leading `/` value with embedded `'` (`"/etc/'x'"`) routes
12648        // through `FonteCaminhoAbsolute` not
12649        // `FonteCaminhoShellQuoteGrouping` — the host-layout-leak
12650        // diagnostic is the load-bearing axis, the quote byte is
12651        // the secondary observation. Same precedence logic as every
12652        // prior leading-byte arm.
12653        let d = dep_with_fonte(DepSource::Path {
12654            caminho: "/etc/'x'".into(),
12655        });
12656        let err = d.validate().unwrap_err();
12657        assert!(
12658            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
12659            "got {err:?}",
12660        );
12661    }
12662
12663    #[test]
12664    fn fonte_caminho_var_expansion_fires_before_shell_quote_grouping() {
12665        // Cascade pin on the upstream leading-`$` var-expansion
12666        // arm: a value carrying both a leading `$` and a `'`
12667        // (`"$DIR/'x'"` — the canonical "I pasted a `$DIR` shell-
12668        // variable + quoted literal at the head of a sibling-
12669        // workspace path" footgun) routes through
12670        // `FonteCaminhoVarExpansion` not
12671        // `FonteCaminhoShellQuoteGrouping`. The leading-byte
12672        // shell-variable-expansion is the more self-locating
12673        // diagnostic on values that probe as both — same
12674        // load-bearing-leading-byte cascade discipline every
12675        // prior `:caminho` arm establishes.
12676        let d = dep_with_fonte(DepSource::Path {
12677            caminho: "$DIR/'x'".into(),
12678        });
12679        let err = d.validate().unwrap_err();
12680        assert!(
12681            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
12682            "got {err:?}",
12683        );
12684    }
12685
12686    #[test]
12687    fn fonte_caminho_shell_quote_grouping_fires_before_trailing_slash() {
12688        // Cascade pin on the immediate-successor arm: a value
12689        // carrying both `'` and a trailing `/` (`"../'caixa-teia'/"`
12690        // — the canonical "I tab-completed a path whose strong-
12691        // quoted body already carried the quoting from a shell-
12692        // history paste" footgun) routes through
12693        // `FonteCaminhoShellQuoteGrouping` not
12694        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
12695        // is the more semantic-locating axis (an author who removes
12696        // the `'` typically also drops the trailing separator since
12697        // both are paste-from-shell artifacts).
12698        let d = dep_with_fonte(DepSource::Path {
12699            caminho: "../'caixa-teia'/".into(),
12700        });
12701        let err = d.validate().unwrap_err();
12702        assert!(
12703            matches!(
12704                err,
12705                DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
12706            ),
12707            "got {err:?}",
12708        );
12709    }
12710
12711    #[test]
12712    fn fonte_caminho_shell_quote_grouping_diagnostic_carries_offending_dep_caminho_and_byte() {
12713        // Diagnostic-shape pin (peer with
12714        // `fonte_caminho_shell_bracket_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
12715        // on the closest two-byte peer arm): the error's Display
12716        // surfaces the offending `:nome`, the offending `:caminho`
12717        // verbatim, the offending byte's hex / character form, and
12718        // names the shell-quote-grouping / cross-config-DSL-string-
12719        // literal-delimiter footgun explicitly so a `feira lint`
12720        // run can render the diagnostic without re-parsing.
12721        let d = dep_with_fonte(DepSource::Path {
12722            caminho: "'../caixa-teia'".into(),
12723        });
12724        let rendered = d.validate().unwrap_err().to_string();
12725        assert!(
12726            rendered.contains("caixa-teia"),
12727            "diagnostic must name the offending dep: {rendered}",
12728        );
12729        assert!(
12730            rendered.contains("'../caixa-teia'"),
12731            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
12732        );
12733        assert!(
12734            rendered.contains("0x27"),
12735            "diagnostic must surface the offending byte hex: {rendered:?}",
12736        );
12737        assert!(
12738            rendered.contains("quote-grouping"),
12739            "diagnostic must name the shell-quote-grouping footgun: {rendered:?}",
12740        );
12741        assert!(
12742            rendered.contains("string-literal"),
12743            "diagnostic must reference the cross-config-DSL string-literal-delimiter \
12744             vocabulary: {rendered:?}",
12745        );
12746    }
12747
12748    #[test]
12749    fn validate_rejects_path_fonte_with_caminho_carrying_shell_comment_lead() {
12750        // The canonical paste-from-shell-history-with-trailing-
12751        // annotation footgun: an author pastes a `cd ../caixa-teia
12752        // # legacy sibling` shell-history one-liner whose unquoted `#`
12753        // comment-lead separates the path from an inline annotation.
12754        // The POSIX shell trims the annotation to `../caixa-teia`
12755        // (POSIX.1-2017 §2.3 Token Recognition step 6), but
12756        // `Path::is_absolute` returns false on `..`, `#` is neither
12757        // a leading-byte sentinel nor a control byte nor `\` nor
12758        // `<` / `>` nor `|` nor `;` nor `&` nor backtick nor `*` /
12759        // `?` nor `(` / `)` nor `{` / `}` nor `[` / `]` nor `'` /
12760        // `"`, and the value's last byte isn't `/` — so the value
12761        // silently passed every prior arm. The resolver folded the
12762        // value through `Path::join` looking for a literal
12763        // `./../caixa-teia # legacy sibling` subdirectory and the
12764        // failure surfaced at resolve time with a non-self-locating
12765        // `No such file or directory` error. The new arm moves the
12766        // rejection to validate time and names the offending dep +
12767        // caminho + byte verbatim.
12768        let d = dep_with_fonte(DepSource::Path {
12769            caminho: "../caixa-teia # legacy sibling".into(),
12770        });
12771        let err = d.validate().unwrap_err();
12772        let DepError::FonteCaminhoShellComment {
12773            nome,
12774            caminho,
12775            byte,
12776        } = err
12777        else {
12778            panic!("expected FonteCaminhoShellComment, got {err:?}");
12779        };
12780        assert_eq!(nome, "caixa-teia");
12781        assert_eq!(caminho, "../caixa-teia # legacy sibling");
12782        assert_eq!(byte, b'#');
12783    }
12784
12785    #[test]
12786    fn validate_rejects_path_fonte_with_caminho_carrying_yaml_comment_paste() {
12787        // The symmetric YAML flow-scalar / values.yaml / K8s-manifest
12788        // cross-idiom-leak shape (`"../caixa-teia  # pin"` — the
12789        // canonical "I copied a `path: ../caixa-teia  # pin` YAML
12790        // scalar-plus-comment entry out of an aligned values.yaml and
12791        // dropped it verbatim into the `:caminho` slot" paste-idiom).
12792        // Pinned separately from the shell-history shape so the
12793        // gate's coverage extends from the single-space `#` shape to
12794        // the YAML-canonical double-space `  #` shape. YAML 1.2 §6.6
12795        // requires the `#` to be preceded by whitespace to lex as a
12796        // comment (bare `foo#bar` is a single scalar); the double-
12797        // space paste from an aligned manifest is the canonical
12798        // shape.
12799        let d = dep_with_fonte(DepSource::Path {
12800            caminho: "../caixa-teia  # pin".into(),
12801        });
12802        let err = d.validate().unwrap_err();
12803        assert!(
12804            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
12805            "got {err:?}",
12806        );
12807    }
12808
12809    #[test]
12810    fn validate_rejects_path_fonte_with_caminho_carrying_url_fragment_anchor() {
12811        // The URL-fragment-identifier paste shape
12812        // (`"../caixa-teia#readme"` — the canonical
12813        // paste-from-browser-address-bar permalink shape where the
12814        // browser preserved the `#anchor` tail on the copy). Pinned
12815        // separately from the whitespace-separated shell / YAML
12816        // comment shapes so the gate covers the unpadded RFC 3986
12817        // §3.5 fragment-delimiter position too, not only positions
12818        // preceded by unquoted whitespace. Peer with the immediate-
12819        // sibling `is_git_repo_url` arm on the `:fonte :repo` axis
12820        // (a68f818) which closes the same byte under the same URL-
12821        // fragment-identifier banner.
12822        let d = dep_with_fonte(DepSource::Path {
12823            caminho: "../caixa-teia#readme".into(),
12824        });
12825        let err = d.validate().unwrap_err();
12826        assert!(
12827            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
12828            "got {err:?}",
12829        );
12830    }
12831
12832    #[test]
12833    fn validate_rejects_path_fonte_with_caminho_carrying_leading_shell_comment() {
12834        // Leading-position `#` shape (`"#../caixa-teia"` — the
12835        // "I copied a shell-comment-out entry from a commented-out
12836        // dep row" footgun). Pinned separately from the embedded
12837        // shapes so the gate covers every position, not only
12838        // whitespace-preceded / mid-value.
12839        let d = dep_with_fonte(DepSource::Path {
12840            caminho: "#../caixa-teia".into(),
12841        });
12842        let err = d.validate().unwrap_err();
12843        assert!(
12844            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
12845            "got {err:?}",
12846        );
12847    }
12848
12849    #[test]
12850    fn validate_accepts_path_fonte_with_caminho_carrying_no_shell_comment() {
12851        // The positive-control pin: the gate targets only `#`,
12852        // never adjacent printable ASCII or POSIX-valid bytes. The
12853        // canonical relative POSIX path (`"../caixa-teia"`) and a
12854        // nested deeply-pathed variant with adjacent printable
12855        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
12856        // to validate cleanly so the gate doesn't widen to a "no
12857        // printable punctuation anywhere" sweep that would defeat
12858        // the entire path-fonte author surface. Peer with
12859        // `validate_accepts_path_fonte_with_caminho_carrying_no_quote_grouping`
12860        // on the immediate-predecessor arm.
12861        let d = dep_with_fonte(DepSource::Path {
12862            caminho: "../caixa-teia/sub-dir.v2".into(),
12863        });
12864        d.validate().unwrap();
12865    }
12866
12867    #[test]
12868    fn fonte_caminho_shell_quote_grouping_fires_before_shell_comment() {
12869        // Cascade pin on the immediate-predecessor arm: a value
12870        // carrying both `'` and `#` (`"../'x'#pin"` — the canonical
12871        // "I pasted a strong-quoted literal followed by a URL-
12872        // fragment permalink tail" footgun) routes through
12873        // `FonteCaminhoShellQuoteGrouping` not
12874        // `FonteCaminhoShellComment`. The shell-string-literal-
12875        // delimiter is the load-bearing root-cause edit on every
12876        // probe-as-both value; same cascade discipline every prior
12877        // `:caminho` arm establishes.
12878        let d = dep_with_fonte(DepSource::Path {
12879            caminho: "../'x'#pin".into(),
12880        });
12881        let err = d.validate().unwrap_err();
12882        assert!(
12883            matches!(
12884                err,
12885                DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
12886            ),
12887            "got {err:?}",
12888        );
12889    }
12890
12891    #[test]
12892    fn fonte_caminho_shell_bracket_expansion_fires_before_shell_comment() {
12893        // Cascade pin on the upstream shell-bracket-expansion arm:
12894        // a value carrying both `[` and `#` (`"../[a-z]#pin"` — the
12895        // canonical "I pasted a glob-character-class followed by a
12896        // URL-fragment tail" footgun) routes through
12897        // `FonteCaminhoShellBracketExpansion` not
12898        // `FonteCaminhoShellComment`. The glob-character-class
12899        // expansion is the load-bearing root-cause edit on every
12900        // probe-as-both value.
12901        let d = dep_with_fonte(DepSource::Path {
12902            caminho: "../[a-z]#pin".into(),
12903        });
12904        let err = d.validate().unwrap_err();
12905        assert!(
12906            matches!(
12907                err,
12908                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
12909            ),
12910            "got {err:?}",
12911        );
12912    }
12913
12914    #[test]
12915    fn fonte_caminho_shell_brace_expansion_fires_before_shell_comment() {
12916        // Cascade pin on the upstream shell-brace-expansion arm: a
12917        // value carrying both `{` and `#` (`"../{a,b}#pin"` — the
12918        // canonical "I pasted a brace-expansion fan followed by a
12919        // URL-fragment tail" footgun) routes through
12920        // `FonteCaminhoShellBraceExpansion` not
12921        // `FonteCaminhoShellComment`. The brace-expansion fan is the
12922        // load-bearing root-cause edit on every probe-as-both value.
12923        let d = dep_with_fonte(DepSource::Path {
12924            caminho: "../{a,b}#pin".into(),
12925        });
12926        let err = d.validate().unwrap_err();
12927        assert!(
12928            matches!(
12929                err,
12930                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
12931            ),
12932            "got {err:?}",
12933        );
12934    }
12935
12936    #[test]
12937    fn fonte_caminho_shell_subshell_grouping_fires_before_shell_comment() {
12938        // Cascade pin on the upstream shell-subshell-grouping arm:
12939        // a value carrying both `(` and `#` (`"../(cd foo)#pin"` —
12940        // the canonical "I pasted a subshell-grouping followed by a
12941        // URL-fragment tail" footgun) routes through
12942        // `FonteCaminhoShellSubshellGrouping` not
12943        // `FonteCaminhoShellComment`. The modern Bourne `$(<cmd>)`
12944        // command-substitution boundary is the load-bearing axis on
12945        // every probe-as-both value.
12946        let d = dep_with_fonte(DepSource::Path {
12947            caminho: "../(cd foo)#pin".into(),
12948        });
12949        let err = d.validate().unwrap_err();
12950        assert!(
12951            matches!(
12952                err,
12953                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
12954            ),
12955            "got {err:?}",
12956        );
12957    }
12958
12959    #[test]
12960    fn fonte_caminho_shell_glob_fires_before_shell_comment() {
12961        // Cascade pin on the upstream shell-glob arm: a value
12962        // carrying both `*` and `#` (`"../caixa-teia/*#pin"` — the
12963        // canonical "I pasted a `*` unbounded pathname-expansion
12964        // followed by a URL-fragment tail" footgun) routes through
12965        // `FonteCaminhoShellGlob` not `FonteCaminhoShellComment`.
12966        // The unbounded pathname-expansion sentinel is the load-
12967        // bearing root-cause edit on every probe-as-both value.
12968        let d = dep_with_fonte(DepSource::Path {
12969            caminho: "../caixa-teia/*#pin".into(),
12970        });
12971        let err = d.validate().unwrap_err();
12972        assert!(
12973            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12974            "got {err:?}",
12975        );
12976    }
12977
12978    #[test]
12979    fn fonte_caminho_shell_command_substitution_fires_before_shell_comment() {
12980        // Cascade pin on the upstream shell-command-substitution
12981        // arm: a value carrying both a backtick and `#`
12982        // (``"../`whoami`#pin"`` — the canonical "I pasted a
12983        // legacy-backtick command-substitution followed by a URL-
12984        // fragment tail" footgun) routes through
12985        // `FonteCaminhoShellCommandSubstitution` not
12986        // `FonteCaminhoShellComment`. The CWE-78 shell-command-
12987        // injection vector is the load-bearing root-cause edit on
12988        // every probe-as-both value.
12989        let d = dep_with_fonte(DepSource::Path {
12990            caminho: "../`whoami`#pin".into(),
12991        });
12992        let err = d.validate().unwrap_err();
12993        assert!(
12994            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
12995            "got {err:?}",
12996        );
12997    }
12998
12999    #[test]
13000    fn fonte_caminho_shell_background_fires_before_shell_comment() {
13001        // Cascade pin on the upstream shell-background arm: a value
13002        // carrying both `&` and `#` (`"../caixa-teia&pin#tail"` —
13003        // the canonical "I pasted a `cmd &` background-launch
13004        // followed by a URL-fragment tail" footgun) routes through
13005        // `FonteCaminhoShellBackground` not
13006        // `FonteCaminhoShellComment`. The background-launch tail is
13007        // the load-bearing root-cause edit on every probe-as-both
13008        // value.
13009        let d = dep_with_fonte(DepSource::Path {
13010            caminho: "../caixa-teia&pin#tail".into(),
13011        });
13012        let err = d.validate().unwrap_err();
13013        assert!(
13014            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
13015            "got {err:?}",
13016        );
13017    }
13018
13019    #[test]
13020    fn fonte_caminho_shell_semicolon_fires_before_shell_comment() {
13021        // Cascade pin on the upstream shell-semicolon arm: a value
13022        // carrying both `;` and `#` (`"../caixa-teia;pin#tail"` —
13023        // the canonical sequential-cleanup + URL-fragment paste
13024        // idiom) routes through `FonteCaminhoShellSemicolon` not
13025        // `FonteCaminhoShellComment`. The sequential-command-
13026        // separator paste is the load-bearing root-cause edit on
13027        // every probe-as-both value.
13028        let d = dep_with_fonte(DepSource::Path {
13029            caminho: "../caixa-teia;pin#tail".into(),
13030        });
13031        let err = d.validate().unwrap_err();
13032        assert!(
13033            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
13034            "got {err:?}",
13035        );
13036    }
13037
13038    #[test]
13039    fn fonte_caminho_shell_pipe_fires_before_shell_comment() {
13040        // Cascade pin on the upstream shell-pipe arm: a value
13041        // carrying both `|` and `#` (`"../caixa-teia|pin#tail"` —
13042        // the canonical pipeline-to-URL-fragment paste idiom) routes
13043        // through `FonteCaminhoShellPipe` not
13044        // `FonteCaminhoShellComment`. The pipeline-tail paste is
13045        // the load-bearing root-cause edit on every probe-as-both
13046        // value.
13047        let d = dep_with_fonte(DepSource::Path {
13048            caminho: "../caixa-teia|pin#tail".into(),
13049        });
13050        let err = d.validate().unwrap_err();
13051        assert!(
13052            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
13053            "got {err:?}",
13054        );
13055    }
13056
13057    #[test]
13058    fn fonte_caminho_shell_redirection_fires_before_shell_comment() {
13059        // Cascade pin on the upstream shell-redirection arm: a
13060        // value carrying both `>` and `#` (`"../caixa-teia>log#pin"`
13061        // — the canonical "I pasted a `cmd > log` redirect followed
13062        // by a URL-fragment tail" footgun) routes through
13063        // `FonteCaminhoShellRedirection` not
13064        // `FonteCaminhoShellComment`. The input/output redirection
13065        // metachar carries the more self-locating `byte` payload,
13066        // so the prior arm wins on every probe-as-both value.
13067        let d = dep_with_fonte(DepSource::Path {
13068            caminho: "../caixa-teia>log#pin".into(),
13069        });
13070        let err = d.validate().unwrap_err();
13071        assert!(
13072            matches!(
13073                err,
13074                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
13075            ),
13076            "got {err:?}",
13077        );
13078    }
13079
13080    #[test]
13081    fn fonte_caminho_backslash_fires_before_shell_comment() {
13082        // Cascade pin on the upstream backslash arm: a value
13083        // carrying both `\` and `#` (`"..\caixa-teia#pin"` — the
13084        // canonical "I pasted a Windows-shell path followed by a
13085        // URL-fragment tail" footgun) routes through
13086        // `FonteCaminhoBackslash` not `FonteCaminhoShellComment`.
13087        // The cross-host-OS-separator divergence is the load-
13088        // bearing axis on every probe-as-both value.
13089        let d = dep_with_fonte(DepSource::Path {
13090            caminho: "..\\caixa-teia#pin".into(),
13091        });
13092        let err = d.validate().unwrap_err();
13093        assert!(
13094            matches!(err, DepError::FonteCaminhoBackslash { .. }),
13095            "got {err:?}",
13096        );
13097    }
13098
13099    #[test]
13100    fn fonte_caminho_control_char_fires_before_shell_comment() {
13101        // Cascade pin on the embedded-control-byte arm: a value
13102        // carrying both a control byte and `#` (`"../foo\n#pin"` —
13103        // the canonical paste-from-multiline-doc footgun where a
13104        // newline landed mid-caminho between the path and an
13105        // annotation) routes through `FonteCaminhoControlChar` not
13106        // `FonteCaminhoShellComment`. The POSIX-syscall-rejected-
13107        // byte diagnostic is the load-bearing axis on every value
13108        // that probes positive for both — mirrors the cascade
13109        // discipline on every prior arm.
13110        let d = dep_with_fonte(DepSource::Path {
13111            caminho: "../foo\n#pin".into(),
13112        });
13113        let err = d.validate().unwrap_err();
13114        assert!(
13115            matches!(err, DepError::FonteCaminhoControlChar { .. }),
13116            "got {err:?}",
13117        );
13118    }
13119
13120    #[test]
13121    fn fonte_caminho_absolute_fires_before_shell_comment() {
13122        // Cascade pin on the load-bearing leading-byte arm: a
13123        // leading `/` value with embedded `#` (`"/etc/foo#pin"`)
13124        // routes through `FonteCaminhoAbsolute` not
13125        // `FonteCaminhoShellComment` — the host-layout-leak
13126        // diagnostic is the load-bearing axis, the fragment byte is
13127        // the secondary observation. Same precedence logic as every
13128        // prior leading-byte arm.
13129        let d = dep_with_fonte(DepSource::Path {
13130            caminho: "/etc/foo#pin".into(),
13131        });
13132        let err = d.validate().unwrap_err();
13133        assert!(
13134            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
13135            "got {err:?}",
13136        );
13137    }
13138
13139    #[test]
13140    fn fonte_caminho_var_expansion_fires_before_shell_comment() {
13141        // Cascade pin on the upstream leading-`$` var-expansion
13142        // arm: a value carrying both a leading `$` and a `#`
13143        // (`"$DIR/foo#pin"` — the canonical "I pasted a `$DIR`
13144        // shell-variable at the head of a sibling-workspace path
13145        // followed by a URL-fragment tail" footgun) routes through
13146        // `FonteCaminhoVarExpansion` not `FonteCaminhoShellComment`.
13147        // The leading-byte shell-variable-expansion is the more
13148        // self-locating diagnostic on values that probe as both.
13149        let d = dep_with_fonte(DepSource::Path {
13150            caminho: "$DIR/foo#pin".into(),
13151        });
13152        let err = d.validate().unwrap_err();
13153        assert!(
13154            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
13155            "got {err:?}",
13156        );
13157    }
13158
13159    #[test]
13160    fn fonte_caminho_shell_comment_fires_before_trailing_slash() {
13161        // Cascade pin on the immediate-successor arm: a value
13162        // carrying both `#` and a trailing `/`
13163        // (`"../caixa-teia#pin/"` — the canonical "I tab-completed
13164        // a URL-fragment-carrying path" footgun) routes through
13165        // `FonteCaminhoShellComment` not
13166        // `FonteCaminhoTrailingSlash`. The embedded fragment /
13167        // comment-lead byte is the more semantic-locating axis (an
13168        // author who removes the `#pin` fragment typically also
13169        // drops the trailing separator since both are paste-from-
13170        // URL / paste-from-shell-tab-completion artifacts).
13171        let d = dep_with_fonte(DepSource::Path {
13172            caminho: "../caixa-teia#pin/".into(),
13173        });
13174        let err = d.validate().unwrap_err();
13175        assert!(
13176            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. },),
13177            "got {err:?}",
13178        );
13179    }
13180
13181    #[test]
13182    fn fonte_caminho_shell_comment_diagnostic_carries_offending_dep_caminho_and_byte() {
13183        // Diagnostic-shape pin (peer with
13184        // `fonte_caminho_shell_quote_grouping_diagnostic_carries_offending_dep_caminho_and_byte`
13185        // on the immediate-predecessor arm): the error's Display
13186        // surfaces the offending `:nome`, the offending `:caminho`
13187        // verbatim, the offending byte's hex / character form, and
13188        // names the shell-comment / URL-fragment-identifier /
13189        // YAML-comment cross-config-DSL footgun explicitly so a
13190        // `feira lint` run can render the diagnostic without
13191        // re-parsing.
13192        let d = dep_with_fonte(DepSource::Path {
13193            caminho: "../caixa-teia#readme".into(),
13194        });
13195        let rendered = d.validate().unwrap_err().to_string();
13196        assert!(
13197            rendered.contains("caixa-teia"),
13198            "diagnostic must name the offending dep: {rendered}",
13199        );
13200        assert!(
13201            rendered.contains("../caixa-teia#readme"),
13202            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
13203        );
13204        assert!(
13205            rendered.contains("0x23"),
13206            "diagnostic must surface the offending byte hex: {rendered:?}",
13207        );
13208        assert!(
13209            rendered.contains("shell-comment") || rendered.contains("comment-lead"),
13210            "diagnostic must name the shell-comment footgun: {rendered:?}",
13211        );
13212        assert!(
13213            rendered.contains("fragment") || rendered.contains("URL-fragment"),
13214            "diagnostic must reference the URL-fragment-identifier vocabulary: \
13215             {rendered:?}",
13216        );
13217    }
13218
13219    #[test]
13220    fn validate_rejects_path_fonte_with_caminho_carrying_url_percent_encoded_space() {
13221        // The canonical paste-from-browser-address-bar percent-
13222        // encoded-space footgun: an author copies `../caixa%20teia`
13223        // out of a URL-encoded README hyperlink / browser address
13224        // bar / percent-encoded permalink expecting `%20` to decode
13225        // to a literal space at the filesystem layer. POSIX
13226        // `std::path::Path` treats `%` as a literal path-component
13227        // byte, so `Path::join` looks for a literal
13228        // `./../caixa%20teia` subdirectory. `Path::is_absolute`
13229        // returns false on `..`, `%` is neither a leading-byte
13230        // sentinel nor a control byte nor `\` nor `<` / `>` nor
13231        // `|` nor `;` nor `&` nor backtick nor `*` / `?` nor `(` /
13232        // `)` nor `{` / `}` nor `[` / `]` nor `'` / `"` nor `#`,
13233        // and the value's last byte isn't `/` — so the value
13234        // silently passed every prior arm. The new arm moves the
13235        // rejection to validate time and names the offending dep +
13236        // caminho + byte verbatim.
13237        let d = dep_with_fonte(DepSource::Path {
13238            caminho: "../caixa%20teia".into(),
13239        });
13240        let err = d.validate().unwrap_err();
13241        let DepError::FonteCaminhoUrlPercentEncoding {
13242            nome,
13243            caminho,
13244            byte,
13245        } = err
13246        else {
13247            panic!("expected FonteCaminhoUrlPercentEncoding, got {err:?}");
13248        };
13249        assert_eq!(nome, "caixa-teia");
13250        assert_eq!(caminho, "../caixa%20teia");
13251        assert_eq!(byte, b'%');
13252    }
13253
13254    #[test]
13255    fn validate_rejects_path_fonte_with_caminho_carrying_url_percent_encoded_slash() {
13256        // The over-encoded path-separator shape (`"../caixa%2Fteia"`
13257        // intending the `%2F` as the URL encoding of `/`) locks a
13258        // `path:../caixa%2Fteia` BLAKE3 closure that diverges from
13259        // the byte-identical `path:../caixa/teia` form. Pinned
13260        // separately from the space-encoded shape so the gate's
13261        // coverage extends past the single canonical `%20` example
13262        // to any two-hex-digit percent-encoded sequence.
13263        let d = dep_with_fonte(DepSource::Path {
13264            caminho: "../caixa%2Fteia".into(),
13265        });
13266        let err = d.validate().unwrap_err();
13267        assert!(
13268            matches!(
13269                err,
13270                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
13271            ),
13272            "got {err:?}",
13273        );
13274    }
13275
13276    #[test]
13277    fn validate_rejects_path_fonte_with_caminho_carrying_lone_percent() {
13278        // The lone-`%` malformed-escape shape (`"../caixa-teia%foo"`
13279        // where `%` isn't followed by two hex digits) — every
13280        // WHATWG-conformant URL parser rejects the value at parse
13281        // time per RFC 3986 §2.1, but the byte would silently ride
13282        // into the lacre before the resolver subprocess crosses the
13283        // URL-parser boundary. Pinned separately from the well-
13284        // formed `%HH` shapes so the gate covers every percent-
13285        // occurrence, not only strictly-conformant escapes.
13286        let d = dep_with_fonte(DepSource::Path {
13287            caminho: "../caixa-teia%foo".into(),
13288        });
13289        let err = d.validate().unwrap_err();
13290        assert!(
13291            matches!(
13292                err,
13293                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
13294            ),
13295            "got {err:?}",
13296        );
13297    }
13298
13299    #[test]
13300    fn validate_rejects_path_fonte_with_caminho_carrying_leading_yaml_directive() {
13301        // The YAML-directive-lead paste shape (`"%YAML/../caixa-teia"`
13302        // — the canonical paste-from-top-of-doc YAML directive
13303        // block cross-idiom leak per YAML 1.2 §6.8.1). Pinned
13304        // separately from embedded shapes so the gate covers the
13305        // leading-position `%` too, not only mid-value occurrences.
13306        let d = dep_with_fonte(DepSource::Path {
13307            caminho: "%YAML/../caixa-teia".into(),
13308        });
13309        let err = d.validate().unwrap_err();
13310        assert!(
13311            matches!(
13312                err,
13313                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
13314            ),
13315            "got {err:?}",
13316        );
13317    }
13318
13319    #[test]
13320    fn validate_rejects_path_fonte_with_caminho_carrying_printf_format_specifier() {
13321        // The printf-format-specifier paste shape
13322        // (`"../caixa-%s-teia"` — the canonical paste-from-shell-
13323        // diagnostic-one-liner `printf "path=%s\n" ...` idiom, CWE-
13324        // 134 format-string-injection vector). Pinned separately
13325        // from the URL-encoding shapes so the gate's rationale
13326        // extends past the RFC 3986 axis to the C / POSIX printf
13327        // format-directive-lead axis.
13328        let d = dep_with_fonte(DepSource::Path {
13329            caminho: "../caixa-%s-teia".into(),
13330        });
13331        let err = d.validate().unwrap_err();
13332        assert!(
13333            matches!(
13334                err,
13335                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
13336            ),
13337            "got {err:?}",
13338        );
13339    }
13340
13341    #[test]
13342    fn validate_accepts_path_fonte_with_caminho_carrying_no_percent() {
13343        // The positive-control pin: the gate targets only `%`,
13344        // never adjacent printable ASCII or POSIX-valid bytes. The
13345        // canonical relative POSIX path (`"../caixa-teia"`) and a
13346        // nested deeply-pathed variant with adjacent printable
13347        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
13348        // to validate cleanly so the gate doesn't widen to a "no
13349        // printable punctuation anywhere" sweep that would defeat
13350        // the entire path-fonte author surface. Peer with
13351        // `validate_accepts_path_fonte_with_caminho_carrying_no_shell_comment`
13352        // on the immediate-predecessor arm.
13353        let d = dep_with_fonte(DepSource::Path {
13354            caminho: "../caixa-teia/sub-dir.v2".into(),
13355        });
13356        d.validate().unwrap();
13357    }
13358
13359    #[test]
13360    fn fonte_caminho_shell_comment_fires_before_url_percent_encoding() {
13361        // Cascade pin on the immediate-predecessor arm: a value
13362        // carrying both `#` and `%` (`"../caixa-teia#pin%20"` — the
13363        // canonical "I pasted a URL-fragment permalink followed by a
13364        // percent-encoded space tail" footgun) routes through
13365        // `FonteCaminhoShellComment` not
13366        // `FonteCaminhoUrlPercentEncoding`. The URL-fragment-
13367        // identifier is the load-bearing downstream-truncation edit
13368        // on every probe-as-both value; same cascade discipline
13369        // every prior `:caminho` arm establishes.
13370        let d = dep_with_fonte(DepSource::Path {
13371            caminho: "../caixa-teia#pin%20".into(),
13372        });
13373        let err = d.validate().unwrap_err();
13374        assert!(
13375            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
13376            "got {err:?}",
13377        );
13378    }
13379
13380    #[test]
13381    fn fonte_caminho_shell_quote_grouping_fires_before_url_percent_encoding() {
13382        // Cascade pin on the upstream shell-quote-grouping arm: a
13383        // value carrying both `'` and `%` (`"../'x'%20teia"` — the
13384        // canonical "I pasted a strong-quoted literal followed by
13385        // a percent-encoded space" footgun) routes through
13386        // `FonteCaminhoShellQuoteGrouping` not
13387        // `FonteCaminhoUrlPercentEncoding`. The shell-string-
13388        // literal-delimiter is the load-bearing root-cause edit on
13389        // every probe-as-both value.
13390        let d = dep_with_fonte(DepSource::Path {
13391            caminho: "../'x'%20teia".into(),
13392        });
13393        let err = d.validate().unwrap_err();
13394        assert!(
13395            matches!(
13396                err,
13397                DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
13398            ),
13399            "got {err:?}",
13400        );
13401    }
13402
13403    #[test]
13404    fn fonte_caminho_backslash_fires_before_url_percent_encoding() {
13405        // Cascade pin on the upstream backslash arm: a value
13406        // carrying both `\` and `%` (`"..\\caixa%20teia"` — the
13407        // canonical "I pasted a Windows-shell path followed by a
13408        // percent-encoded space" footgun) routes through
13409        // `FonteCaminhoBackslash` not
13410        // `FonteCaminhoUrlPercentEncoding`. The cross-host-OS-
13411        // separator divergence is the load-bearing root-cause edit
13412        // on every probe-as-both value.
13413        let d = dep_with_fonte(DepSource::Path {
13414            caminho: "..\\caixa%20teia".into(),
13415        });
13416        let err = d.validate().unwrap_err();
13417        assert!(
13418            matches!(err, DepError::FonteCaminhoBackslash { .. }),
13419            "got {err:?}",
13420        );
13421    }
13422
13423    #[test]
13424    fn fonte_caminho_control_char_fires_before_url_percent_encoding() {
13425        // Cascade pin on the upstream control-char arm: a value
13426        // carrying both a NUL byte and `%` (`"../caixa\0%20teia"` —
13427        // the canonical "I pasted a paste-from-binary-blob path
13428        // followed by a percent-encoded space" footgun) routes
13429        // through `FonteCaminhoControlChar` not
13430        // `FonteCaminhoUrlPercentEncoding`. The POSIX-syscall-
13431        // rejected byte is the load-bearing root-cause edit on
13432        // every probe-as-both value.
13433        let d = dep_with_fonte(DepSource::Path {
13434            caminho: "../caixa\0%20teia".into(),
13435        });
13436        let err = d.validate().unwrap_err();
13437        assert!(
13438            matches!(err, DepError::FonteCaminhoControlChar { byte: 0x00, .. },),
13439            "got {err:?}",
13440        );
13441    }
13442
13443    #[test]
13444    fn fonte_caminho_absolute_fires_before_url_percent_encoding() {
13445        // Cascade pin on the upstream absolute-path arm: a value
13446        // that's both absolute and carries `%` (`"/etc/passwd%20"`
13447        // — the canonical "I pasted an absolute path with a
13448        // percent-encoded space tail" footgun) routes through
13449        // `FonteCaminhoAbsolute` not
13450        // `FonteCaminhoUrlPercentEncoding`. The host-layout-leak is
13451        // the load-bearing root-cause edit on every probe-as-both
13452        // value.
13453        let d = dep_with_fonte(DepSource::Path {
13454            caminho: "/etc/passwd%20".into(),
13455        });
13456        let err = d.validate().unwrap_err();
13457        assert!(
13458            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
13459            "got {err:?}",
13460        );
13461    }
13462
13463    #[test]
13464    fn fonte_caminho_var_expansion_fires_before_url_percent_encoding() {
13465        // Cascade pin on the upstream var-expansion arm: a value
13466        // starting with `$` and carrying `%` (`"$HOME/caixa%20teia"`
13467        // — the canonical "I pasted a `$HOME`-rooted path with a
13468        // percent-encoded space" footgun) routes through
13469        // `FonteCaminhoVarExpansion` not
13470        // `FonteCaminhoUrlPercentEncoding`. The shell-variable-
13471        // expansion is the load-bearing root-cause edit on every
13472        // probe-as-both value.
13473        let d = dep_with_fonte(DepSource::Path {
13474            caminho: "$HOME/caixa%20teia".into(),
13475        });
13476        let err = d.validate().unwrap_err();
13477        assert!(
13478            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
13479            "got {err:?}",
13480        );
13481    }
13482
13483    #[test]
13484    fn fonte_caminho_url_percent_encoding_fires_before_trailing_slash() {
13485        // Cascade pin on the immediate-successor arm: a value
13486        // carrying both `%` and a trailing `/`
13487        // (`"../caixa%20teia/"` — the canonical "I tab-completed a
13488        // percent-encoded-space-carrying path" footgun) routes
13489        // through `FonteCaminhoUrlPercentEncoding` not
13490        // `FonteCaminhoTrailingSlash`. The embedded percent-
13491        // encoding-escape byte is the more semantic-locating axis
13492        // (an author who decodes the `%20` to a literal space is
13493        // likely to also tab-strip the trailing separator since
13494        // both are paste-from-URL / paste-from-shell-tab-completion
13495        // artifacts).
13496        let d = dep_with_fonte(DepSource::Path {
13497            caminho: "../caixa%20teia/".into(),
13498        });
13499        let err = d.validate().unwrap_err();
13500        assert!(
13501            matches!(
13502                err,
13503                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
13504            ),
13505            "got {err:?}",
13506        );
13507    }
13508
13509    #[test]
13510    fn fonte_caminho_url_percent_encoding_diagnostic_carries_offending_dep_caminho_and_byte() {
13511        // Diagnostic-shape pin (peer with
13512        // `fonte_caminho_shell_comment_diagnostic_carries_offending_dep_caminho_and_byte`
13513        // on the immediate-predecessor arm): the error's Display
13514        // surfaces the offending `:nome`, the offending `:caminho`
13515        // verbatim, the offending byte's hex / character form, and
13516        // names the URL-percent-encoding-escape / printf-format-
13517        // specifier footgun explicitly so a `feira lint` run can
13518        // render the diagnostic without re-parsing.
13519        let d = dep_with_fonte(DepSource::Path {
13520            caminho: "../caixa%20teia".into(),
13521        });
13522        let rendered = d.validate().unwrap_err().to_string();
13523        assert!(
13524            rendered.contains("caixa-teia"),
13525            "diagnostic must name the offending dep: {rendered}",
13526        );
13527        assert!(
13528            rendered.contains("../caixa%20teia"),
13529            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
13530        );
13531        assert!(
13532            rendered.contains("0x25"),
13533            "diagnostic must surface the offending byte hex: {rendered:?}",
13534        );
13535        assert!(
13536            rendered.contains("percent-encoding") || rendered.contains("percent-encoded"),
13537            "diagnostic must name the URL-percent-encoding-escape footgun: {rendered:?}",
13538        );
13539        assert!(
13540            rendered.contains("printf") || rendered.contains("format-specifier"),
13541            "diagnostic must reference the printf-format-specifier vocabulary: \
13542             {rendered:?}",
13543        );
13544    }
13545
13546    #[test]
13547    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_var_expansion() {
13548        // The canonical embedded-`$` shell-variable-expansion paste
13549        // shape (`"../foo$HOME/bar"` — an author copies a partially-
13550        // substituted shell one-liner where the leading segment is a
13551        // literal `../foo` while the mid segment carries the un-
13552        // substituted `$HOME` template). The leading-`$` position is
13553        // already gated by the f4efe9c leading-byte arm which routes
13554        // through `FonteCaminhoVarExpansion`; this arm closes the
13555        // last positional gap on `$` — every position on the axis is
13556        // structurally rejected.
13557        let d = dep_with_fonte(DepSource::Path {
13558            caminho: "../foo$HOME/bar".into(),
13559        });
13560        let err = d.validate().unwrap_err();
13561        let DepError::FonteCaminhoShellVariableExpansion {
13562            nome,
13563            caminho,
13564            byte,
13565        } = err
13566        else {
13567            panic!("expected FonteCaminhoShellVariableExpansion, got {err:?}");
13568        };
13569        assert_eq!(nome, "caixa-teia");
13570        assert_eq!(caminho, "../foo$HOME/bar");
13571        assert_eq!(byte, b'$');
13572    }
13573
13574    #[test]
13575    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_braced_var_expansion() {
13576        // The symmetric braced-CI-manifest paste shape
13577        // (`"../foo${WORKSPACE}/bar"` — the canonical paste-from-
13578        // GitHub-Actions-workflow / paste-from-`.gitlab-ci.yml`
13579        // footgun). Pinned separately from the bare-`$VAR` shape so
13580        // the gate covers both POSIX shell §2.6 Parameter Expansion
13581        // syntactic forms, not only the unbraced variant. The
13582        // embedded `{` byte in `${...}` is also caught by the 598b770
13583        // shell-brace-expansion arm but that arm fires earlier in
13584        // the cascade — the `$` arm's coverage extends to `${...}`
13585        // structurally, so the diagnostic asserted here is the
13586        // brace-expansion one (which is a valid outcome; the point
13587        // of the pin is that the value never survives validation).
13588        let d = dep_with_fonte(DepSource::Path {
13589            caminho: "../foo${WORKSPACE}/bar".into(),
13590        });
13591        let err = d.validate().unwrap_err();
13592        assert!(
13593            matches!(
13594                err,
13595                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. }
13596                    | DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
13597            ),
13598            "got {err:?}",
13599        );
13600    }
13601
13602    #[test]
13603    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_command_substitution() {
13604        // The paste-from-shell-prompt command-substitution idiom
13605        // (`"../foo$(whoami)/bar"`). Pinned separately from the bare-
13606        // `$VAR` shape so the gate's rationale extends to POSIX shell
13607        // §2.6.3 Command Substitution (the modern `$(<cmd>)` form; the
13608        // legacy `` `<cmd>` `` form is already closed by the c370458
13609        // backtick arm). The embedded `(` byte in `$(...)` is also
13610        // caught structurally by the 0633c91 shell-subshell-grouping
13611        // arm which fires earlier in the cascade — the diagnostic
13612        // asserted here is either outcome, since both structurally
13613        // reject the value; the point of the pin is that the value
13614        // never survives validation.
13615        let d = dep_with_fonte(DepSource::Path {
13616            caminho: "../foo$(whoami)/bar".into(),
13617        });
13618        let err = d.validate().unwrap_err();
13619        assert!(
13620            matches!(
13621                err,
13622                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. }
13623                    | DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
13624            ),
13625            "got {err:?}",
13626        );
13627    }
13628
13629    #[test]
13630    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_positional_parameter() {
13631        // The paste-from-`Makefile` / paste-from-SQL-migration bare-
13632        // `$1` positional-parameter shape (`"../foo$1/bar"` — a Make
13633        // automatic-variable `$1` or a PostgreSQL bind-parameter `$1`
13634        // idiom copied into a caminho template). None of the prior
13635        // shell-metachar arms cover this shape (`1` is a bare digit;
13636        // no `(` / `{` / letter follows the `$`), so the arm is the
13637        // sole gate on the shape.
13638        let d = dep_with_fonte(DepSource::Path {
13639            caminho: "../foo$1/bar".into(),
13640        });
13641        let err = d.validate().unwrap_err();
13642        assert!(
13643            matches!(
13644                err,
13645                DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
13646            ),
13647            "got {err:?}",
13648        );
13649    }
13650
13651    #[test]
13652    fn validate_accepts_path_fonte_with_caminho_carrying_no_dollar() {
13653        // The positive-control pin (peer with
13654        // `validate_accepts_path_fonte_with_caminho_carrying_no_percent`
13655        // on the immediate-predecessor arm): the gate targets only
13656        // `$`, never adjacent printable ASCII or POSIX-valid bytes.
13657        // A relative POSIX path carrying dashes / dots / slashes /
13658        // digits (`"../caixa-teia/sub-dir.v2"`) must continue to
13659        // validate cleanly so the gate doesn't widen to a "no
13660        // printable punctuation anywhere" sweep that would defeat
13661        // the entire path-fonte author surface.
13662        let d = dep_with_fonte(DepSource::Path {
13663            caminho: "../caixa-teia/sub-dir.v2".into(),
13664        });
13665        d.validate().unwrap();
13666    }
13667
13668    #[test]
13669    fn fonte_caminho_var_expansion_fires_before_shell_variable_expansion() {
13670        // Cascade pin on the leading-`$` sibling arm at line 540: a
13671        // value starting with `$` and carrying an embedded `$` too
13672        // (`"$HOME/foo$WORKSPACE/bar"` — the canonical "I pasted a
13673        // fully-templated CI path with two un-substituted variables")
13674        // routes through `FonteCaminhoVarExpansion` not
13675        // `FonteCaminhoShellVariableExpansion`. The leading-byte
13676        // host-layout-leak is the load-bearing self-locating axis
13677        // (the leading position dominates the semantic-locating
13678        // rationale on every probe-as-both value); the embedded
13679        // arm's positional-agnostic sweep catches only values whose
13680        // leading byte doesn't route through the earlier leading-
13681        // byte arms.
13682        let d = dep_with_fonte(DepSource::Path {
13683            caminho: "$HOME/foo$WORKSPACE/bar".into(),
13684        });
13685        let err = d.validate().unwrap_err();
13686        assert!(
13687            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
13688            "got {err:?}",
13689        );
13690    }
13691
13692    #[test]
13693    fn fonte_caminho_url_percent_encoding_fires_before_shell_variable_expansion() {
13694        // Cascade pin on the immediate-predecessor arm: a value
13695        // carrying both `%` and embedded `$` (`"../foo%20$HOME/bar"`
13696        // — the canonical "I pasted a percent-encoded space adjacent
13697        // to a `$HOME` template") routes through
13698        // `FonteCaminhoUrlPercentEncoding` not
13699        // `FonteCaminhoShellVariableExpansion`. The URL-percent-
13700        // encoding-escape byte is the more semantic-locating axis
13701        // (the paste-from-browser-address-bar shape is the load-
13702        // bearing self-locating edit); same cascade discipline every
13703        // prior `:caminho` arm establishes.
13704        let d = dep_with_fonte(DepSource::Path {
13705            caminho: "../foo%20$HOME/bar".into(),
13706        });
13707        let err = d.validate().unwrap_err();
13708        assert!(
13709            matches!(
13710                err,
13711                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
13712            ),
13713            "got {err:?}",
13714        );
13715    }
13716
13717    #[test]
13718    fn fonte_caminho_shell_variable_expansion_fires_before_trailing_slash() {
13719        // Cascade pin on the immediate-successor arm: a value
13720        // carrying both embedded `$` and a trailing `/`
13721        // (`"../foo$HOME/bar/"` — the canonical "I tab-completed a
13722        // `$HOME`-template-carrying path") routes through
13723        // `FonteCaminhoShellVariableExpansion` not
13724        // `FonteCaminhoTrailingSlash`. The embedded shell-variable-
13725        // expansion byte is the more semantic-locating axis on
13726        // probe-as-both values (an author who substitutes the
13727        // `$HOME` template with a literal value is likely to also
13728        // tab-strip the trailing separator).
13729        let d = dep_with_fonte(DepSource::Path {
13730            caminho: "../foo$HOME/bar/".into(),
13731        });
13732        let err = d.validate().unwrap_err();
13733        assert!(
13734            matches!(
13735                err,
13736                DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
13737            ),
13738            "got {err:?}",
13739        );
13740    }
13741
13742    #[test]
13743    fn fonte_caminho_shell_variable_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
13744        // Diagnostic-shape pin (peer with
13745        // `fonte_caminho_url_percent_encoding_diagnostic_carries_offending_dep_caminho_and_byte`
13746        // on the immediate-predecessor arm): the error's Display
13747        // surfaces the offending `:nome`, the offending `:caminho`
13748        // verbatim, the offending byte's hex / character form, and
13749        // names the shell-variable-expansion / command-substitution
13750        // footgun explicitly so a `feira lint` run can render the
13751        // diagnostic without re-parsing.
13752        let d = dep_with_fonte(DepSource::Path {
13753            caminho: "../foo$HOME/bar".into(),
13754        });
13755        let rendered = d.validate().unwrap_err().to_string();
13756        assert!(
13757            rendered.contains("caixa-teia"),
13758            "diagnostic must name the offending dep: {rendered}",
13759        );
13760        assert!(
13761            rendered.contains("../foo$HOME/bar"),
13762            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
13763        );
13764        assert!(
13765            rendered.contains("0x24"),
13766            "diagnostic must surface the offending byte hex: {rendered:?}",
13767        );
13768        assert!(
13769            rendered.contains("variable-expansion") || rendered.contains("variable expansion"),
13770            "diagnostic must name the shell-variable-expansion footgun: {rendered:?}",
13771        );
13772        assert!(
13773            rendered.contains("command-substitution") || rendered.contains("command substitution"),
13774            "diagnostic must reference the command-substitution vocabulary: {rendered:?}",
13775        );
13776    }
13777
13778    #[test]
13779    fn validate_rejects_path_fonte_with_caminho_carrying_shell_history_expansion() {
13780        // The fail-before-pass-after pin for the canonical paste-from-
13781        // shell-history footgun on `:caminho`. An author copies a `cd
13782        // ../caixa-teia && !sudo make install` one-liner from a quick-
13783        // start README, intending the trailing `!sudo` as a shell-
13784        // history-expansion reference but the typed slot is itself a
13785        // byte-level string parser, not a shell context, so the byte
13786        // rides into the value verbatim. Until this arm landed the `!`
13787        // byte silently passed every prior `:caminho` cascade arm
13788        // (`!` isn't `\` / `<` / `>` / `|` / `;` / `&` / backtick /
13789        // `*` / `?` / `(` / `)` / `{` / `}` / `[` / `]` / `'` / `"` /
13790        // `#` / `%` / `$`); bash with the default `histexpand` mode
13791        // rewrites `!command` to the most recent history entry
13792        // beginning with `command`, the canonical RCE-class injection
13793        // vector when the byte rides into a shell argument executed
13794        // under `bash -i` (the operator-notebook interactive shell).
13795        let d = dep_with_fonte(DepSource::Path {
13796            caminho: "../caixa-teia!sudo".into(),
13797        });
13798        let err = d.validate().unwrap_err();
13799        let DepError::FonteCaminhoShellHistoryExpansion {
13800            nome,
13801            caminho,
13802            byte,
13803        } = err
13804        else {
13805            panic!("expected FonteCaminhoShellHistoryExpansion, got {err:?}");
13806        };
13807        assert_eq!(nome, "caixa-teia");
13808        assert_eq!(caminho, "../caixa-teia!sudo");
13809        assert_eq!(byte, b'!');
13810    }
13811
13812    #[test]
13813    fn validate_rejects_path_fonte_with_caminho_carrying_double_bang_history_reference() {
13814        // The symmetric `!!` repeat-prior-command paste idiom (peer with
13815        // `validate_rejects_git_fonte_with_repo_carrying_double_bang_history_reference`
13816        // on `is_git_repo_url`). Pinned separately from the wrapped
13817        // `!command` shape so a future diagnostic-surface change that
13818        // only checked the leading or paired-bang position surfaces
13819        // here — the per-byte arm fires anywhere `!` appears in the
13820        // value, including at consecutive positions in the middle.
13821        let d = dep_with_fonte(DepSource::Path {
13822            caminho: "../foo!!/bar".into(),
13823        });
13824        let err = d.validate().unwrap_err();
13825        assert!(
13826            matches!(
13827                err,
13828                DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
13829            ),
13830            "got {err:?}",
13831        );
13832    }
13833
13834    #[test]
13835    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_enthusiasm_bang() {
13836        // The English-typography enthusiasm-form paste-from-prose
13837        // idiom: an author writes `:caminho "../caixa-teia!"`
13838        // expecting the substrate to coerce it to a kebab-case slug.
13839        // Pinned separately from the `!<word>` shell-history shape so
13840        // the gate's rationale extends to the paste-from-prose surface
13841        // (the same rationale the peer `is_git_repo_url` bang arm at
13842        // 7d53c68 covers). None of the prior shell-metachar arms cover
13843        // this shape (no `!<word>` reference and no `!!` repeat), so
13844        // the arm is the sole gate on the shape.
13845        let d = dep_with_fonte(DepSource::Path {
13846            caminho: "../caixa-teia!".into(),
13847        });
13848        let err = d.validate().unwrap_err();
13849        assert!(
13850            matches!(
13851                err,
13852                DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
13853            ),
13854            "got {err:?}",
13855        );
13856    }
13857
13858    #[test]
13859    fn validate_accepts_path_fonte_with_caminho_carrying_no_bang() {
13860        // The positive-control pin (peer with
13861        // `validate_accepts_path_fonte_with_caminho_carrying_no_dollar`
13862        // on the immediate-predecessor arm): the gate targets only
13863        // `!`, never adjacent printable ASCII or POSIX-valid bytes.
13864        // A relative POSIX path carrying dashes / dots / slashes /
13865        // digits (`"../caixa-teia/sub-dir.v2"`) must continue to
13866        // validate cleanly so the gate doesn't widen to a "no
13867        // printable punctuation anywhere" sweep that would defeat
13868        // the entire path-fonte author surface.
13869        let d = dep_with_fonte(DepSource::Path {
13870            caminho: "../caixa-teia/sub-dir.v2".into(),
13871        });
13872        d.validate().unwrap();
13873    }
13874
13875    #[test]
13876    fn fonte_caminho_shell_variable_expansion_fires_before_shell_history_expansion() {
13877        // Cascade pin on the immediate-predecessor arm: a value
13878        // carrying both embedded `$` and `!` (`"../foo$HOME/bar!sudo"`
13879        // — the canonical "I pasted a `$HOME`-templated path adjacent
13880        // to a trailing `!sudo` history-expansion") routes through
13881        // `FonteCaminhoShellVariableExpansion` not
13882        // `FonteCaminhoShellHistoryExpansion`. The shell-variable-
13883        // expansion byte is the more semantic-locating axis on
13884        // probe-as-both values (the paste-from-CI-manifest-with-`$VAR`-
13885        // template shape is the load-bearing self-locating edit);
13886        // same cascade discipline every prior `:caminho` arm
13887        // establishes.
13888        let d = dep_with_fonte(DepSource::Path {
13889            caminho: "../foo$HOME/bar!sudo".into(),
13890        });
13891        let err = d.validate().unwrap_err();
13892        assert!(
13893            matches!(
13894                err,
13895                DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
13896            ),
13897            "got {err:?}",
13898        );
13899    }
13900
13901    #[test]
13902    fn fonte_caminho_shell_history_expansion_fires_before_trailing_slash() {
13903        // Cascade pin on the immediate-successor arm: a value carrying
13904        // both embedded `!` and a trailing `/` (`"../caixa-teia!sudo/"`
13905        // — the canonical "I tab-completed a `!sudo`-carrying path")
13906        // routes through `FonteCaminhoShellHistoryExpansion` not
13907        // `FonteCaminhoTrailingSlash`. The embedded shell-history-
13908        // expansion byte is the more semantic-locating axis on probe-
13909        // as-both values (an author who removes the `!sudo` history
13910        // reference is likely to also tab-strip the trailing separator).
13911        let d = dep_with_fonte(DepSource::Path {
13912            caminho: "../caixa-teia!sudo/".into(),
13913        });
13914        let err = d.validate().unwrap_err();
13915        assert!(
13916            matches!(
13917                err,
13918                DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
13919            ),
13920            "got {err:?}",
13921        );
13922    }
13923
13924    #[test]
13925    fn fonte_caminho_shell_history_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
13926        // Diagnostic-shape pin (peer with
13927        // `fonte_caminho_shell_variable_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
13928        // on the immediate-predecessor arm): the error's Display
13929        // surfaces the offending `:nome`, the offending `:caminho`
13930        // verbatim, the offending byte's hex / character form, and
13931        // names the shell-history-expansion / bang-operator footgun
13932        // explicitly so a `feira lint` run can render the diagnostic
13933        // without re-parsing.
13934        let d = dep_with_fonte(DepSource::Path {
13935            caminho: "../caixa-teia!sudo".into(),
13936        });
13937        let rendered = d.validate().unwrap_err().to_string();
13938        assert!(
13939            rendered.contains("caixa-teia"),
13940            "diagnostic must name the offending dep: {rendered}",
13941        );
13942        assert!(
13943            rendered.contains("../caixa-teia!sudo"),
13944            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
13945        );
13946        assert!(
13947            rendered.contains("0x21"),
13948            "diagnostic must surface the offending byte hex: {rendered:?}",
13949        );
13950        assert!(
13951            rendered.contains("history-expansion") || rendered.contains("history expansion"),
13952            "diagnostic must name the shell-history-expansion footgun: {rendered:?}",
13953        );
13954        assert!(
13955            rendered.contains("bang"),
13956            "diagnostic must reference the bang-operator vocabulary: {rendered:?}",
13957        );
13958    }
13959
13960    #[test]
13961    fn validate_rejects_path_fonte_with_caminho_carrying_shell_history_substitution() {
13962        // The fail-before-pass-after pin for the canonical paste-from-
13963        // shell-history-quick-substitution footgun on `:caminho`. An
13964        // author copies a `git clone <bad-url>` line from their terminal,
13965        // corrects it via bash's `^bad^good` quick-substitution history
13966        // operator (bash reference §9.3, `set -o histexpand` mode's
13967        // default for interactive sessions), and pastes the trailing
13968        // `^bad^good` substitution fragment into a `:caminho` value
13969        // without trimming the leading `git clone` prefix — the byte
13970        // rides into the manifest verbatim. Until this arm landed the
13971        // `^` byte silently passed every prior `:caminho` cascade arm
13972        // (`^` isn't `\` / `<` / `>` / `|` / `;` / `&` / backtick / `*`
13973        // / `?` / `(` / `)` / `{` / `}` / `[` / `]` / `'` / `"` / `#` /
13974        // `%` / `$` / `!`); bash with the default `histexpand` mode
13975        // rewrites the prior command's `bad` string to `good` and re-
13976        // executes it, the paired-operator half of the `set -o
13977        // histexpand` feature the peer `!` arm already closes the prefix
13978        // half of. The peer `is_git_repo_url` axis rejects the byte at
13979        // 49e142f under the same shell-history-substitution / RFC-3986-
13980        // unwise banner.
13981        let d = dep_with_fonte(DepSource::Path {
13982            caminho: "../foo^bad^good".into(),
13983        });
13984        let err = d.validate().unwrap_err();
13985        let DepError::FonteCaminhoShellHistorySubstitution {
13986            nome,
13987            caminho,
13988            byte,
13989        } = err
13990        else {
13991            panic!("expected FonteCaminhoShellHistorySubstitution, got {err:?}");
13992        };
13993        assert_eq!(nome, "caixa-teia");
13994        assert_eq!(caminho, "../foo^bad^good");
13995        assert_eq!(byte, b'^');
13996    }
13997
13998    #[test]
13999    fn validate_rejects_path_fonte_with_caminho_carrying_regex_negation_anchor() {
14000        // The symmetric paste-from-doc-grep-pipeline footgun (peer with
14001        // `validate_rejects_git_fonte_with_repo_carrying_caret_regex_anchor`
14002        // on `is_git_repo_url`). An author copies a `grep '^archived'`
14003        // regex-anchor / negation idiom from a doc snippet and the byte
14004        // rides in verbatim. Pinned separately from the `^old^new^`
14005        // quick-substitution shape so a future diagnostic-surface change
14006        // that only checked the paired-caret history-substitution
14007        // position surfaces here — the per-byte arm fires anywhere `^`
14008        // appears in the value, including at a solitary leading-of-
14009        // segment position.
14010        let d = dep_with_fonte(DepSource::Path {
14011            caminho: "../foo/^archived".into(),
14012        });
14013        let err = d.validate().unwrap_err();
14014        assert!(
14015            matches!(
14016                err,
14017                DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
14018            ),
14019            "got {err:?}",
14020        );
14021    }
14022
14023    #[test]
14024    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_history_substitution_open() {
14025        // The trailing-`^` history-substitution-open shape — an author
14026        // starts typing a `^bad^good` quick-substitution but pastes only
14027        // the leading `^` sentinel before context-switching (a bash-
14028        // reference §9.3 valid histexpand prefix on its own — even a
14029        // solitary `^` on the prior command's whole re-execution shape).
14030        // Pinned separately from the `^old^new^` full-form and the leading-
14031        // of-segment `^archived` regex-anchor shape so the gate's
14032        // rationale extends to the paste-from-shell-history-with-only-
14033        // the-first-byte-selected surface. None of the prior shell-
14034        // metachar arms cover this shape.
14035        let d = dep_with_fonte(DepSource::Path {
14036            caminho: "../caixa-teia^".into(),
14037        });
14038        let err = d.validate().unwrap_err();
14039        assert!(
14040            matches!(
14041                err,
14042                DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
14043            ),
14044            "got {err:?}",
14045        );
14046    }
14047
14048    #[test]
14049    fn validate_accepts_path_fonte_with_caminho_carrying_no_caret() {
14050        // The positive-control pin (peer with
14051        // `validate_accepts_path_fonte_with_caminho_carrying_no_bang`
14052        // on the immediate-predecessor arm): the gate targets only
14053        // `^`, never adjacent printable ASCII or POSIX-valid bytes.
14054        // A relative POSIX path carrying dashes / dots / slashes /
14055        // digits / underscore (`"../caixa-teia/sub_v2.rc"`) must
14056        // continue to validate cleanly so the gate doesn't widen to
14057        // a "no printable punctuation anywhere" sweep that would
14058        // defeat the entire path-fonte author surface.
14059        let d = dep_with_fonte(DepSource::Path {
14060            caminho: "../caixa-teia/sub_v2.rc".into(),
14061        });
14062        d.validate().unwrap();
14063    }
14064
14065    #[test]
14066    fn fonte_caminho_shell_history_expansion_fires_before_shell_history_substitution() {
14067        // Cascade pin on the immediate-predecessor arm: a value carrying
14068        // both embedded `!` and `^` (`"../foo!sudo^bad^good"` — the
14069        // canonical "I pasted a `!sudo` history-reference next to a
14070        // `^bad^good` quick-substitution") routes through
14071        // `FonteCaminhoShellHistoryExpansion` not
14072        // `FonteCaminhoShellHistorySubstitution`. The `!` prefix form is
14073        // the more semantic-locating axis on probe-as-both values (an
14074        // author who removes the `!sudo` reference is likely to also
14075        // strip the paired `^` substitution fragment); same cascade
14076        // discipline every prior `:caminho` arm establishes.
14077        let d = dep_with_fonte(DepSource::Path {
14078            caminho: "../foo!sudo^bad^good".into(),
14079        });
14080        let err = d.validate().unwrap_err();
14081        assert!(
14082            matches!(
14083                err,
14084                DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
14085            ),
14086            "got {err:?}",
14087        );
14088    }
14089
14090    #[test]
14091    fn fonte_caminho_shell_history_substitution_fires_before_trailing_slash() {
14092        // Cascade pin on the immediate-successor arm: a value carrying
14093        // both embedded `^` and a trailing `/` (`"../foo^bad^good/"` —
14094        // the canonical "I tab-completed a `^bad^good`-carrying path")
14095        // routes through `FonteCaminhoShellHistorySubstitution` not
14096        // `FonteCaminhoTrailingSlash`. The embedded shell-history-
14097        // substitution byte is the more semantic-locating axis on probe-
14098        // as-both values (an author who removes the `^bad^good`
14099        // substitution fragment is likely to also tab-strip the trailing
14100        // separator).
14101        let d = dep_with_fonte(DepSource::Path {
14102            caminho: "../foo^bad^good/".into(),
14103        });
14104        let err = d.validate().unwrap_err();
14105        assert!(
14106            matches!(
14107                err,
14108                DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
14109            ),
14110            "got {err:?}",
14111        );
14112    }
14113
14114    #[test]
14115    fn fonte_caminho_shell_history_substitution_diagnostic_carries_offending_dep_caminho_and_byte()
14116    {
14117        // Diagnostic-shape pin (peer with
14118        // `fonte_caminho_shell_history_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
14119        // on the immediate-predecessor arm): the error's Display
14120        // surfaces the offending `:nome`, the offending `:caminho`
14121        // verbatim, the offending byte's hex form, and names the
14122        // shell-history-substitution / RFC-3986-'unwise' / regex-
14123        // negation footgun explicitly so a `feira lint` run can render
14124        // the diagnostic without re-parsing.
14125        let d = dep_with_fonte(DepSource::Path {
14126            caminho: "../foo^bad^good".into(),
14127        });
14128        let rendered = d.validate().unwrap_err().to_string();
14129        assert!(
14130            rendered.contains("caixa-teia"),
14131            "diagnostic must name the offending dep: {rendered}",
14132        );
14133        assert!(
14134            rendered.contains("../foo^bad^good"),
14135            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
14136        );
14137        assert!(
14138            rendered.contains("0x5e") || rendered.contains("0x5E"),
14139            "diagnostic must surface the offending byte hex: {rendered:?}",
14140        );
14141        assert!(
14142            rendered.contains("history-substitution") || rendered.contains("history substitution"),
14143            "diagnostic must name the shell-history-substitution footgun: {rendered:?}",
14144        );
14145        assert!(
14146            rendered.contains("unwise"),
14147            "diagnostic must reference the RFC-3986 'unwise' set vocabulary: {rendered:?}",
14148        );
14149    }
14150
14151    #[test]
14152    fn fonte_repo_empty_fires_before_pin_missing() {
14153        // Order pin: empty `:repo` is the more self-locating diagnostic
14154        // (every git source needs a repo; the pin discussion is
14155        // secondary), so it fires before the pin-missing arm even when
14156        // both are violated. Mirrors the
14157        // `nome_empty_takes_precedence_over_versao_invalid` ordering
14158        // discipline on the per-entry layer.
14159        let d = dep_with_fonte(DepSource::Git {
14160            repo: String::new(),
14161            tag: None,
14162            rev: None,
14163            branch: None,
14164        });
14165        let err = d.validate().unwrap_err();
14166        assert!(
14167            matches!(err, DepError::FonteRepoEmpty { .. }),
14168            "got {err:?}"
14169        );
14170    }
14171
14172    #[test]
14173    fn fonte_pin_missing_fires_before_pin_empty() {
14174        // Order pin: a fully-None pin set is structurally distinct from
14175        // a Some(empty) pin — the first surfaces as FontePinMissing
14176        // (no axis chosen), the second as FontePinEmpty (axis chosen
14177        // but value blank). Pin the disjoint relationship so a future
14178        // unification collapses to one variant only as a structural
14179        // decision.
14180        let d = dep_with_fonte(DepSource::Git {
14181            repo: "github:pleme-io/caixa-teia".into(),
14182            tag: None,
14183            rev: None,
14184            branch: None,
14185        });
14186        assert!(matches!(
14187            d.validate().unwrap_err(),
14188            DepError::FontePinMissing { .. }
14189        ));
14190    }
14191
14192    #[test]
14193    fn nome_empty_takes_precedence_over_fonte_invalid() {
14194        // Order pin: a per-entry diagnostic without a non-empty :nome
14195        // can't be self-locating, so :nome "" fires first even when
14196        // :fonte is also malformed. Mirrors
14197        // `nome_empty_takes_precedence_over_versao_invalid` on the
14198        // adjacent axis.
14199        let mut d = dep_with_fonte(DepSource::Git {
14200            repo: String::new(),
14201            tag: None,
14202            rev: None,
14203            branch: None,
14204        });
14205        d.nome = String::new();
14206        assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
14207    }
14208
14209    #[test]
14210    fn versao_invalid_takes_precedence_over_fonte_invalid() {
14211        // Order pin: the :versao parse-side diagnostic is narrower than
14212        // the :fonte shape diagnostic — a malformed :versao always names
14213        // the parser's reason, which is more actionable than the
14214        // :fonte gate's "the pins are wrong" wording. Pin the ordering
14215        // so a re-ordering surfaces here.
14216        let mut d = dep_with_fonte(DepSource::Git {
14217            repo: String::new(),
14218            tag: None,
14219            rev: None,
14220            branch: None,
14221        });
14222        d.versao = "v0.1".into();
14223        let err = d.validate().unwrap_err();
14224        assert!(
14225            matches!(err, DepError::VersaoInvalid { ref nome, .. } if nome == "caixa-teia"),
14226            "got {err:?}"
14227        );
14228    }
14229
14230    #[test]
14231    fn fonte_invalid_diagnostic_carries_offending_nome() {
14232        // The diagnostic-shape pin: every :fonte error variant names
14233        // the offending dep's :nome verbatim, so the author can grep
14234        // caixa.lisp for the `:nome "<n>"` block and fix it in one
14235        // edit. Cover all seven variants so a future variant addition
14236        // forces a parallel diagnostic-shape decision.
14237        for (case, fonte) in [
14238            (
14239                "repo-empty",
14240                DepSource::Git {
14241                    repo: String::new(),
14242                    tag: Some("v1".into()),
14243                    rev: None,
14244                    branch: None,
14245                },
14246            ),
14247            (
14248                "repo-shape",
14249                DepSource::Git {
14250                    repo: "github:p/x ".into(),
14251                    tag: Some("v1".into()),
14252                    rev: None,
14253                    branch: None,
14254                },
14255            ),
14256            (
14257                "pin-missing",
14258                DepSource::Git {
14259                    repo: "github:p/x".into(),
14260                    tag: None,
14261                    rev: None,
14262                    branch: None,
14263                },
14264            ),
14265            (
14266                "pin-ambiguous",
14267                DepSource::Git {
14268                    repo: "github:p/x".into(),
14269                    tag: Some("v1".into()),
14270                    rev: None,
14271                    branch: Some("main".into()),
14272                },
14273            ),
14274            (
14275                "pin-empty",
14276                DepSource::Git {
14277                    repo: "github:p/x".into(),
14278                    tag: Some(String::new()),
14279                    rev: None,
14280                    branch: None,
14281                },
14282            ),
14283            (
14284                "caminho-empty",
14285                DepSource::Path {
14286                    caminho: String::new(),
14287                },
14288            ),
14289            (
14290                "caminho-absolute",
14291                DepSource::Path {
14292                    caminho: "/home/me/work/caixa-teia".into(),
14293                },
14294            ),
14295        ] {
14296            let d = dep_with_fonte(fonte);
14297            let msg = d
14298                .validate()
14299                .expect_err(&format!("{case}: expected fonte error"))
14300                .to_string();
14301            assert!(
14302                msg.contains("\"caixa-teia\""),
14303                "{case}: diagnostic must quote the offending :nome verbatim, got {msg:?}"
14304            );
14305        }
14306    }
14307
14308    // -- :tag / :branch value-shape gate ----------------------------------
14309
14310    #[test]
14311    fn validate_rejects_git_fonte_with_tag_carrying_trailing_space() {
14312        // The canonical paste-from-doc footgun on `:tag` — author
14313        // copies `"v0.1.0 "` (trailing space) out of a release-notes
14314        // paragraph. Until this gate landed the empty-pin arm passed
14315        // (the string isn't empty), the resolver issued
14316        // `git fetch <remote> tag 'v0.1.0 '`, and the failure
14317        // surfaced at clone time with a quoting-confused git error
14318        // far from the source caixa.lisp. The new gate moves the
14319        // check to caixa-build time and names the offending dep +
14320        // pin + value verbatim.
14321        let d = dep_with_fonte(DepSource::Git {
14322            repo: "github:pleme-io/caixa-teia".into(),
14323            tag: Some("v0.1.0 ".into()),
14324            rev: None,
14325            branch: None,
14326        });
14327        let err = d.validate().unwrap_err();
14328        let DepError::FontePinShape {
14329            nome,
14330            pin,
14331            value,
14332            reason,
14333        } = err
14334        else {
14335            panic!("expected FontePinShape, got other variant");
14336        };
14337        assert_eq!(nome, "caixa-teia");
14338        assert_eq!(pin, ":tag");
14339        assert_eq!(value, "v0.1.0 ");
14340        assert!(
14341            reason.contains("whitespace"),
14342            "reason must surface the whitespace arm, got {reason:?}"
14343        );
14344    }
14345
14346    #[test]
14347    fn validate_rejects_git_fonte_with_tag_carrying_lock_suffix() {
14348        // The `.lock` suffix is git's atomic-rename guard for
14349        // in-flight ref updates — a refname ending in `.lock` is
14350        // unwritable on disk. Pinned separately from the whitespace
14351        // arm so a future relaxation that admits one but not the
14352        // other surfaces here.
14353        let d = dep_with_fonte(DepSource::Git {
14354            repo: "github:pleme-io/caixa-teia".into(),
14355            tag: Some("v0.1.0.lock".into()),
14356            rev: None,
14357            branch: None,
14358        });
14359        let err = d.validate().unwrap_err();
14360        let DepError::FontePinShape {
14361            pin, value, reason, ..
14362        } = err
14363        else {
14364            panic!("expected FontePinShape, got other variant");
14365        };
14366        assert_eq!(pin, ":tag");
14367        assert_eq!(value, "v0.1.0.lock");
14368        assert!(
14369            reason.contains(".lock"),
14370            "reason must surface the .lock arm, got {reason:?}"
14371        );
14372    }
14373
14374    #[test]
14375    fn validate_rejects_git_fonte_with_branch_carrying_embedded_space() {
14376        // The canonical "branch name with spaces" footgun (`feature
14377        // foo`, `release branch`) — git's refname parser rejects raw
14378        // whitespace, and the failure surfaces at `git checkout
14379        // 'feature foo'` time with a quoting-confused error far from
14380        // the source caixa.lisp. Pinned on the `:branch` axis so the
14381        // gate-applies-to-both-:tag-and-:branch contract is a build-
14382        // error to relax.
14383        let d = dep_with_fonte(DepSource::Git {
14384            repo: "github:pleme-io/caixa-teia".into(),
14385            tag: None,
14386            rev: None,
14387            branch: Some("feature/foo bar".into()),
14388        });
14389        let err = d.validate().unwrap_err();
14390        let DepError::FontePinShape {
14391            pin, value, reason, ..
14392        } = err
14393        else {
14394            panic!("expected FontePinShape, got other variant");
14395        };
14396        assert_eq!(pin, ":branch");
14397        assert_eq!(value, "feature/foo bar");
14398        assert!(
14399            reason.contains("whitespace"),
14400            "reason must surface the whitespace arm, got {reason:?}"
14401        );
14402    }
14403
14404    #[test]
14405    fn validate_rejects_git_fonte_with_branch_carrying_qualified_prefix() {
14406        // The `refs/heads/main` shape — the canonical "I copied the
14407        // fully-qualified ref out of `git show-ref` instead of the
14408        // leaf" footgun. The caixa-resolver prepends `refs/heads/`
14409        // at clone time, so this resolves to a literal ref named
14410        // `refs/heads/refs/heads/main` on disk; the silent double-
14411        // prefix is the load-bearing reason to gate at validate.
14412        // The diagnostic must enumerate the leaf the author probably
14413        // meant (`"main"`) so the fix is one edit.
14414        let d = dep_with_fonte(DepSource::Git {
14415            repo: "github:pleme-io/caixa-teia".into(),
14416            tag: None,
14417            rev: None,
14418            branch: Some("refs/heads/main".into()),
14419        });
14420        let err = d.validate().unwrap_err();
14421        let DepError::FontePinShape {
14422            pin, value, reason, ..
14423        } = err
14424        else {
14425            panic!("expected FontePinShape, got other variant");
14426        };
14427        assert_eq!(pin, ":branch");
14428        assert_eq!(value, "refs/heads/main");
14429        assert!(
14430            reason.contains("fully-qualified"),
14431            "reason must surface the qualified-prefix arm, got {reason:?}"
14432        );
14433        assert!(
14434            reason.contains("\"main\""),
14435            "reason must quote the leaf the author probably meant, got {reason:?}"
14436        );
14437    }
14438
14439    #[test]
14440    fn validate_rejects_git_fonte_with_tag_carrying_qualified_prefix() {
14441        // Sibling arm of the qualified-prefix gate on the `:tag`
14442        // axis (`refs/tags/v0.1.0` — same `git show-ref` output-leak
14443        // footgun). Pinned separately so a future relaxation that
14444        // only catches the `:branch` arm surfaces here.
14445        let d = dep_with_fonte(DepSource::Git {
14446            repo: "github:pleme-io/caixa-teia".into(),
14447            tag: Some("refs/tags/v0.1.0".into()),
14448            rev: None,
14449            branch: None,
14450        });
14451        let err = d.validate().unwrap_err();
14452        let DepError::FontePinShape {
14453            pin, value, reason, ..
14454        } = err
14455        else {
14456            panic!("expected FontePinShape, got other variant");
14457        };
14458        assert_eq!(pin, ":tag");
14459        assert_eq!(value, "refs/tags/v0.1.0");
14460        assert!(
14461            reason.contains("fully-qualified"),
14462            "reason must surface the qualified-prefix arm, got {reason:?}"
14463        );
14464        assert!(
14465            reason.contains("\"v0.1.0\""),
14466            "reason must quote the leaf the author probably meant, got {reason:?}"
14467        );
14468    }
14469
14470    #[test]
14471    fn validate_rejects_git_fonte_with_branch_named_at() {
14472        // The bare `@` is git's alias for `HEAD`; a `:branch "@"` is
14473        // unsourceable. Pinned so a future relaxation that admits
14474        // any single-character refname surfaces here.
14475        let d = dep_with_fonte(DepSource::Git {
14476            repo: "github:pleme-io/caixa-teia".into(),
14477            tag: None,
14478            rev: None,
14479            branch: Some("@".into()),
14480        });
14481        let err = d.validate().unwrap_err();
14482        let DepError::FontePinShape { pin, value, .. } = err else {
14483            panic!("expected FontePinShape, got other variant");
14484        };
14485        assert_eq!(pin, ":branch");
14486        assert_eq!(value, "@");
14487    }
14488
14489    #[test]
14490    fn validate_rejects_git_fonte_with_tag_carrying_double_dot() {
14491        // Git's `<rev1>..<rev2>` range grammar reserves `..` —
14492        // a `:tag "../escape"` (path-traversal-shaped slug) silently
14493        // passes parse and surfaces as a refname-parse error or, on
14494        // older git, a literal `../escape` checkout that escapes the
14495        // refs/ directory tree. Pinned separately from the
14496        // qualified-prefix arm so a future relaxation that catches
14497        // one but not the other surfaces here.
14498        let d = dep_with_fonte(DepSource::Git {
14499            repo: "github:pleme-io/caixa-teia".into(),
14500            tag: Some("../escape".into()),
14501            rev: None,
14502            branch: None,
14503        });
14504        let err = d.validate().unwrap_err();
14505        let DepError::FontePinShape { pin, value, .. } = err else {
14506            panic!("expected FontePinShape, got other variant");
14507        };
14508        assert_eq!(pin, ":tag");
14509        assert_eq!(value, "../escape");
14510    }
14511
14512    #[test]
14513    fn validate_accepts_git_fonte_with_hierarchical_branch() {
14514        // The positive-control pin: hierarchical refnames with one or
14515        // more `/` separators (the `feature/foo` / `user/jdoe/feat`
14516        // canonical idiom) round-trip through the gate. Pinned
14517        // separately from the leaf-`"main"` positive control so a
14518        // future tightening that rejects all multi-component refnames
14519        // surfaces here.
14520        let d = dep_with_fonte(DepSource::Git {
14521            repo: "github:pleme-io/caixa-teia".into(),
14522            tag: None,
14523            rev: None,
14524            branch: Some("feature/checkout-rewrite".into()),
14525        });
14526        d.validate().unwrap();
14527    }
14528
14529    #[test]
14530    fn validate_accepts_git_fonte_with_prerelease_tag() {
14531        // The positive-control pin: semver pre-release shape
14532        // (`v0.1.0-alpha.1`) — the in-component dot is allowed
14533        // (only consecutive `..` and trailing `.` are rejected), the
14534        // mid-component hyphen is allowed. Pinned separately from
14535        // the bare-`"v0.1.0"` positive control so a future tightening
14536        // that rejects pre-release tags surfaces here.
14537        let d = dep_with_fonte(DepSource::Git {
14538            repo: "github:pleme-io/caixa-teia".into(),
14539            tag: Some("v0.1.0-alpha.1".into()),
14540            rev: None,
14541            branch: None,
14542        });
14543        d.validate().unwrap();
14544    }
14545
14546    #[test]
14547    fn validate_rejects_git_fonte_with_rev_carrying_refname_unfriendly_value() {
14548        // The `:rev` axis is routed through `crate::render::is_git_oid`
14549        // (a SHA's character set is `[0-9a-f]`, not a refname's), so a
14550        // value with refname-shape punctuation (here, a `:` mid-string
14551        // — would be a refname violation under `is_git_ref_name` too)
14552        // is rejected at the OID-shape gate. The two predicates
14553        // partition the `:fonte` pin axes structurally: an `:rev` value
14554        // that's a valid refname (`:rev "main"`, `:rev "v0.1.0"`) is
14555        // *still* rejected here because every refname character outside
14556        // `[0-9a-f]` fails the OID gate. Same shape as
14557        // `fonte_pin_shape_diagnostic_carries_offending_nome_pin_value`
14558        // on the refname-shaped axes — the diagnostic names the
14559        // offending dep + pin + value verbatim. The flip-from-accept
14560        // case the prior `:tag`/`:branch` gate left as a "future axis"
14561        // (e70d213) — now landed.
14562        let d = dep_with_fonte(DepSource::Git {
14563            repo: "github:pleme-io/caixa-teia".into(),
14564            tag: None,
14565            rev: Some("c0ffee:notarefname".into()),
14566            branch: None,
14567        });
14568        let err = d.validate().unwrap_err();
14569        let DepError::FontePinShape {
14570            nome,
14571            pin,
14572            value,
14573            reason,
14574        } = err
14575        else {
14576            panic!("expected FontePinShape, got other variant");
14577        };
14578        assert_eq!(nome, "caixa-teia");
14579        assert_eq!(pin, ":rev");
14580        assert_eq!(value, "c0ffee:notarefname");
14581        assert!(
14582            !reason.is_empty(),
14583            "FontePinShape `reason` must carry the predicate's wording verbatim"
14584        );
14585    }
14586
14587    #[test]
14588    fn validate_accepts_git_fonte_with_rev_full_sha1() {
14589        // The positive-control pin on the SHA-1 OID width: exactly 40
14590        // lowercase hex characters — the canonical `git rev-parse HEAD`
14591        // emission on a SHA-1-hashed repository (the default on every
14592        // pre-2.42 git and the canonical pleme-io substrate hash).
14593        // Pinned separately from the SHA-256 positive control so a
14594        // future tightening that only admits one width surfaces here.
14595        let d = dep_with_fonte(DepSource::Git {
14596            repo: "github:pleme-io/caixa-teia".into(),
14597            tag: None,
14598            rev: Some("0123456789abcdef0123456789abcdef01234567".into()),
14599            branch: None,
14600        });
14601        d.validate().unwrap();
14602    }
14603
14604    #[test]
14605    fn validate_accepts_git_fonte_with_rev_full_sha256() {
14606        // The positive-control pin on the SHA-256 OID width: exactly
14607        // 64 lowercase hex characters — `git`'s
14608        // `extensions.objectFormat = sha256` emission (GA since Git
14609        // 2.42 / Oct 2023). The substrate admits either canonical
14610        // width so an `:rev` authored against a SHA-256-hashed
14611        // upstream round-trips through the gate without per-repo
14612        // configuration. Pinned separately from the SHA-1 positive
14613        // control so a future tightening that drops one width surfaces
14614        // here as a structural decision.
14615        let d = dep_with_fonte(DepSource::Git {
14616            repo: "github:pleme-io/caixa-teia".into(),
14617            tag: None,
14618            rev: Some("0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef".into()),
14619            branch: None,
14620        });
14621        d.validate().unwrap();
14622    }
14623
14624    #[test]
14625    fn validate_rejects_git_fonte_with_rev_abbreviated_prefix() {
14626        // The canonical `git log --short` / `git rev-parse --short HEAD`
14627        // paste-from-release-notes footgun: a 7-char prefix (git's
14628        // default `core.abbrev`) silently passes string emptiness
14629        // checks and resolves to one commit today, but becomes ambiguous
14630        // tomorrow as the repo grows. Until this gate landed the empty-
14631        // pin arm passed (the string isn't empty) and the resolver
14632        // accepted the prefix through git's separate prefix-lookup pass
14633        // — defeating the reproducibility contract `:rev` carries vs.
14634        // `:tag` / `:branch`. The new gate moves the check to caixa-
14635        // build time and names the offending dep + pin + value verbatim.
14636        let d = dep_with_fonte(DepSource::Git {
14637            repo: "github:pleme-io/caixa-teia".into(),
14638            tag: None,
14639            rev: Some("c0ffee0".into()),
14640            branch: None,
14641        });
14642        let err = d.validate().unwrap_err();
14643        let DepError::FontePinShape {
14644            pin, value, reason, ..
14645        } = err
14646        else {
14647            panic!("expected FontePinShape, got other variant");
14648        };
14649        assert_eq!(pin, ":rev");
14650        assert_eq!(value, "c0ffee0");
14651        assert!(
14652            reason.contains("abbreviated") || reason.contains("ambiguous"),
14653            "reason must surface the abbreviation arm, got {reason:?}"
14654        );
14655    }
14656
14657    #[test]
14658    fn validate_rejects_git_fonte_with_rev_uppercase_hex() {
14659        // The canonical "I pasted the SHA in uppercase" footgun: `git
14660        // porcelain` emits OIDs lowercase exclusively, so an uppercase-
14661        // bearing `:rev` round-trips inconsistently across the
14662        // resolver's `git fetch <remote> <:rev>` ↔ `git rev-parse HEAD`
14663        // equality-check pipeline and fails the lacre's content-
14664        // addressing probe with a confusing case-only diff. Pinned
14665        // separately from the non-hex arm so a future relaxation that
14666        // admits one but not the other surfaces here.
14667        let d = dep_with_fonte(DepSource::Git {
14668            repo: "github:pleme-io/caixa-teia".into(),
14669            tag: None,
14670            rev: Some("DEADBEEFCAFEBABE0123456789ABCDEF01234567".into()),
14671            branch: None,
14672        });
14673        let err = d.validate().unwrap_err();
14674        let DepError::FontePinShape {
14675            pin, value, reason, ..
14676        } = err
14677        else {
14678            panic!("expected FontePinShape, got other variant");
14679        };
14680        assert_eq!(pin, ":rev");
14681        assert_eq!(value, "DEADBEEFCAFEBABE0123456789ABCDEF01234567");
14682        assert!(
14683            reason.contains("uppercase"),
14684            "reason must surface the uppercase arm, got {reason:?}"
14685        );
14686    }
14687
14688    #[test]
14689    fn validate_rejects_git_fonte_with_rev_refname_value() {
14690        // The cross-axis mis-slot footgun: `:rev "main"` — the author
14691        // conflated `:rev` (hex commit ID, immutable) and `:branch`
14692        // (mutable ref pointing at whatever HEAD is today). Until this
14693        // gate landed the resolver silently dispatched on the value
14694        // shape ("`main` doesn't look like a SHA, fall back to
14695        // refname"), defeating the `:rev` reproducibility contract.
14696        // The new gate rejects every non-hex value on the `:rev` axis,
14697        // so the `:rev`/`:branch` boundary is structurally enforced —
14698        // a refname in the `:rev` slot is a build error, not a
14699        // resolver-time silent reinterpretation.
14700        let d = dep_with_fonte(DepSource::Git {
14701            repo: "github:pleme-io/caixa-teia".into(),
14702            tag: None,
14703            rev: Some("main".into()),
14704            branch: None,
14705        });
14706        let err = d.validate().unwrap_err();
14707        let DepError::FontePinShape {
14708            pin, value, reason, ..
14709        } = err
14710        else {
14711            panic!("expected FontePinShape, got other variant");
14712        };
14713        assert_eq!(pin, ":rev");
14714        assert_eq!(value, "main");
14715        // 4 chars `main` fails the length arm before the character arm,
14716        // so the diagnostic surfaces the abbreviation wording (same
14717        // path the `c0ffee0` 7-char fixture lands on); the structural
14718        // assertion is just that the `:rev "main"` value is rejected.
14719        assert!(
14720            !reason.is_empty(),
14721            "FontePinShape reason must be non-empty for refname-shaped :rev"
14722        );
14723    }
14724
14725    #[test]
14726    fn validate_rejects_git_fonte_with_rev_tag_shaped_value() {
14727        // Sibling cross-axis mis-slot: `:rev "v0.1.0"` — the author
14728        // conflated `:rev` and `:tag`. Pinned separately from the
14729        // `:rev "main"` (`:branch` mis-slot) arm so a future relaxation
14730        // that catches one but not the other surfaces here. The
14731        // length arm fires first (6 chars ≠ 40 ≠ 64); the structural
14732        // assertion is just that the cross-axis mis-slot is a build
14733        // error, regardless of which sub-arm surfaces the diagnostic
14734        // (`is_git_oid` rejects at the first violation; longer
14735        // tag-shape values would hit the non-hex arm instead).
14736        let d = dep_with_fonte(DepSource::Git {
14737            repo: "github:pleme-io/caixa-teia".into(),
14738            tag: None,
14739            rev: Some("v0.1.0".into()),
14740            branch: None,
14741        });
14742        let err = d.validate().unwrap_err();
14743        let DepError::FontePinShape {
14744            pin, value, reason, ..
14745        } = err
14746        else {
14747            panic!("expected FontePinShape, got other variant");
14748        };
14749        assert_eq!(pin, ":rev");
14750        assert_eq!(value, "v0.1.0");
14751        assert!(
14752            !reason.is_empty(),
14753            "FontePinShape reason must be non-empty for tag-shaped :rev"
14754        );
14755    }
14756
14757    #[test]
14758    fn validate_rejects_git_fonte_with_rev_too_long() {
14759        // Boundary case on the upper end: 41 hex chars — one past the
14760        // SHA-1 width, well below the SHA-256 width. Pin so a future
14761        // relaxation that admits "long enough to be a SHA" without
14762        // matching either canonical width surfaces here. The diagnostic
14763        // names the offending length verbatim so the author's grep
14764        // target is unambiguous (either trim one char or paste the
14765        // full SHA-256).
14766        let too_long: String = "0".repeat(41);
14767        let d = dep_with_fonte(DepSource::Git {
14768            repo: "github:pleme-io/caixa-teia".into(),
14769            tag: None,
14770            rev: Some(too_long.clone()),
14771            branch: None,
14772        });
14773        let err = d.validate().unwrap_err();
14774        let DepError::FontePinShape {
14775            pin, value, reason, ..
14776        } = err
14777        else {
14778            panic!("expected FontePinShape, got other variant");
14779        };
14780        assert_eq!(pin, ":rev");
14781        assert_eq!(value, too_long);
14782        assert!(
14783            reason.contains("41"),
14784            "reason must surface the offending length verbatim, got {reason:?}"
14785        );
14786    }
14787
14788    #[test]
14789    fn validate_rejects_git_fonte_with_rev_carrying_whitespace() {
14790        // The canonical paste-from-doc footgun on `:rev` — author
14791        // copies `"deadbeefcafe…0123 "` (trailing space) out of a
14792        // commit-message paragraph. Until this gate landed the empty-
14793        // pin arm passed (the string isn't empty), the resolver issued
14794        // `git fetch <remote> 'deadbeef… '` and the failure surfaced at
14795        // clone time with a quoting-confused git error far from the
14796        // source caixa.lisp. The new gate moves the check to caixa-
14797        // build time. Length is 41 (40 hex + space) so the length arm
14798        // fires first — pinned separately from the pure-length arm to
14799        // ensure the diagnostic surfaces *some* parser wording, not
14800        // silently pass through.
14801        let with_space = "0123456789abcdef0123456789abcdef01234567 ".to_string();
14802        let d = dep_with_fonte(DepSource::Git {
14803            repo: "github:pleme-io/caixa-teia".into(),
14804            tag: None,
14805            rev: Some(with_space.clone()),
14806            branch: None,
14807        });
14808        let err = d.validate().unwrap_err();
14809        let DepError::FontePinShape {
14810            pin, value, reason, ..
14811        } = err
14812        else {
14813            panic!("expected FontePinShape, got other variant");
14814        };
14815        assert_eq!(pin, ":rev");
14816        assert_eq!(value, with_space);
14817        assert!(
14818            !reason.is_empty(),
14819            "FontePinShape reason must be non-empty for whitespace-bearing :rev"
14820        );
14821    }
14822
14823    #[test]
14824    fn fonte_pin_shape_diagnostic_carries_offending_nome_pin_value_for_rev() {
14825        // Diagnostic-shape pin on the `:rev` axis: every FontePinShape
14826        // variant on this axis names the offending dep's `:nome` + the
14827        // `:rev` axis + the offending value verbatim, so the author's
14828        // grep target is the literal `:rev "<value>"` block in
14829        // caixa.lisp. Sibling of the `fonte_pin_shape_diagnostic_
14830        // carries_offending_nome_pin_value` test on the refname-shaped
14831        // (`:tag` / `:branch`) axes.
14832        let d = dep_with_fonte(DepSource::Git {
14833            repo: "github:p/x".into(),
14834            tag: None,
14835            rev: Some("not-a-sha".into()),
14836            branch: None,
14837        });
14838        let msg = d
14839            .validate()
14840            .expect_err(":rev: expected FontePinShape")
14841            .to_string();
14842        assert!(
14843            msg.contains("\"caixa-teia\""),
14844            ":rev: diagnostic must quote the offending :nome verbatim, got {msg:?}"
14845        );
14846        assert!(
14847            msg.contains(":rev"),
14848            ":rev: diagnostic must name the offending pin axis, got {msg:?}"
14849        );
14850        assert!(
14851            msg.contains("not-a-sha"),
14852            ":rev: diagnostic must quote the offending value verbatim, got {msg:?}"
14853        );
14854    }
14855
14856    #[test]
14857    fn fonte_pin_empty_fires_before_pin_shape() {
14858        // Order pin: a `Some("")` `:tag` is the more self-locating
14859        // diagnostic (the author chose an axis but left it blank;
14860        // grep is unambiguous), so it fires before the shape gate
14861        // even when both arms would match. Pinned so a future
14862        // reordering surfaces here. Mirrors the
14863        // `fonte_repo_empty_fires_before_pin_missing` ordering
14864        // discipline on the peer per-axis arms.
14865        let d = dep_with_fonte(DepSource::Git {
14866            repo: "github:pleme-io/caixa-teia".into(),
14867            tag: Some(String::new()),
14868            rev: None,
14869            branch: None,
14870        });
14871        assert!(matches!(
14872            d.validate().unwrap_err(),
14873            DepError::FontePinEmpty { ref pin, .. } if pin == ":tag"
14874        ));
14875    }
14876
14877    #[test]
14878    fn fonte_pin_shape_fires_after_repo_empty() {
14879        // Order pin: `:repo ""` is the more self-locating axis
14880        // (every git source needs a repo; the per-pin shape gate is
14881        // secondary), so the repo-empty arm fires before the
14882        // per-pin shape arm even when both are violated. Pinned so
14883        // a future reordering surfaces here. Mirrors
14884        // `fonte_repo_empty_fires_before_pin_missing` on the
14885        // adjacent axis pair.
14886        let d = dep_with_fonte(DepSource::Git {
14887            repo: String::new(),
14888            tag: Some("v0.1.0 ".into()),
14889            rev: None,
14890            branch: None,
14891        });
14892        assert!(matches!(
14893            d.validate().unwrap_err(),
14894            DepError::FonteRepoEmpty { .. }
14895        ));
14896    }
14897
14898    #[test]
14899    fn fonte_pin_shape_diagnostic_carries_offending_nome_pin_value() {
14900        // Diagnostic-shape pin across both refname-shaped axes
14901        // (`:tag` + `:branch`): every `FontePinShape` variant names
14902        // the offending dep's `:nome` + the offending pin axis + the
14903        // offending value verbatim, so the author's grep target is
14904        // unambiguous (the literal `:tag "<value>"` / `:branch
14905        // "<value>"` lands in caixa.lisp with quotes). Cover both
14906        // pin axes so a future variant addition forces a parallel
14907        // diagnostic-shape decision.
14908        for (pin_label, fonte) in [
14909            (
14910                ":tag",
14911                DepSource::Git {
14912                    repo: "github:p/x".into(),
14913                    tag: Some("v0.1.0~1".into()),
14914                    rev: None,
14915                    branch: None,
14916                },
14917            ),
14918            (
14919                ":branch",
14920                DepSource::Git {
14921                    repo: "github:p/x".into(),
14922                    tag: None,
14923                    rev: None,
14924                    branch: Some("feature/foo*".into()),
14925                },
14926            ),
14927        ] {
14928            let d = dep_with_fonte(fonte);
14929            let msg = d
14930                .validate()
14931                .expect_err(&format!("{pin_label}: expected FontePinShape"))
14932                .to_string();
14933            assert!(
14934                msg.contains("\"caixa-teia\""),
14935                "{pin_label}: diagnostic must quote the offending :nome verbatim, got {msg:?}"
14936            );
14937            assert!(
14938                msg.contains(pin_label),
14939                "{pin_label}: diagnostic must name the offending pin axis, got {msg:?}"
14940            );
14941        }
14942    }
14943
14944    #[test]
14945    fn git_source_json_round_trip() {
14946        let src = DepSource::Git {
14947            repo: "github:pleme-io/caixa-teia".into(),
14948            tag: Some("v0.1.0".into()),
14949            rev: None,
14950            branch: None,
14951        };
14952        let s = serde_json::to_string(&src).unwrap();
14953        assert!(s.contains(&format!(
14954            r#""{tipo}":"{git}""#,
14955            tipo = crate::render::DEP_SOURCE_KEY_TIPO,
14956            git = crate::render::DEP_SOURCE_TIPO_GIT,
14957        )));
14958        assert!(s.contains(r#""repo":"github:pleme-io/caixa-teia""#));
14959        assert!(s.contains(r#""tag":"v0.1.0""#));
14960        assert!(!s.contains("rev"));
14961        assert!(!s.contains("branch"));
14962        let round: DepSource = serde_json::from_str(&s).unwrap();
14963        assert_eq!(round, src);
14964    }
14965
14966    // ── DEP_SOURCE_{KEY_TIPO,TIPO_GIT,TIPO_PATH} drift-detection ────────
14967    //
14968    // The `#[serde(tag = "tipo", rename_all = "lowercase")]` derive
14969    // attribute on [`DepSource`] pins three load-bearing byte-sequences
14970    // that flow into every serialized `Dep.fonte` block: the outer
14971    // discriminator-key `"tipo"` the `tag = "tipo"` attribute names, and
14972    // the two admitted variant-tag values `"git"` / `"path"` the
14973    // `rename_all = "lowercase"` attribute pins as the discriminator's
14974    // closed-set arms. The three pin tests below round-trip a
14975    // fully-populated variant of each arm through
14976    // [`serde_json::to_value`] and assert each canonical byte-sequence
14977    // appears at its axis — pins a hypothetical future
14978    // `tag = "type"` / `tag = "source_type"` typo, a `rename_all`
14979    // rebrand (`"UPPERCASE"` / `"snake_case"` / `"kebab-case"`), or a
14980    // Rust-side variant rename (`Git` → `Repository`, `Path` → `Local`)
14981    // at build time rather than at fetch time when the resolver's
14982    // `Dep.fonte` dispatch silently fails to match on the drifted
14983    // discriminator. Same "serialize-and-check" discipline the peer
14984    // `M2_LIMITS_KEY_*`, `M2_BEHAVIOR_KEY_ON_*`, `SUPERVISOR_KEY_*`,
14985    // and `MEMBRO_KEY_*` drift-detection pins carry — extended here
14986    // to the last `#[serde(tag = ..., rename_all = ...)]` discriminator
14987    // family in caixa-core lacking a lifted peer.
14988
14989    #[test]
14990    fn dep_source_git_serde_keys_match_lifted_dep_source_key_consts() {
14991        // Fail-before-pass-after: a future `tag = "type"` at the derive
14992        // attribute would serialize under `"type":"git"`, and this test
14993        // would trip because `"tipo"` no longer appears at the emitted
14994        // discriminator key. A future `rename_all = "kebab-case"` /
14995        // `"snake_case"` (both no-ops on `Git` since it lacks internal
14996        // word boundaries) is caught by the sibling
14997        // `dep_source_path_serde_keys_match_lifted_dep_source_key_consts`
14998        // pin below (Path has no internal boundary either but the pair
14999        // catches any per-arm inconsistency). A future variant rename
15000        // `Git` → `Repository` would emit `"tipo":"repository"` and
15001        // trip this pin.
15002        let src = DepSource::Git {
15003            repo: "github:pleme-io/caixa-teia".into(),
15004            tag: Some("v0.1.0".into()),
15005            rev: None,
15006            branch: None,
15007        };
15008        let json = serde_json::to_value(&src).unwrap();
15009        let obj = json.as_object().expect("Git serializes as a JSON object");
15010        assert_eq!(
15011            obj.get(crate::render::DEP_SOURCE_KEY_TIPO)
15012                .and_then(serde_json::Value::as_str),
15013            Some(crate::render::DEP_SOURCE_TIPO_GIT),
15014            "DepSource::Git must serialize the tipo discriminator at DEP_SOURCE_KEY_TIPO \
15015             with value DEP_SOURCE_TIPO_GIT — attribute drift or variant rename \
15016             detected in {json}"
15017        );
15018    }
15019
15020    #[test]
15021    fn dep_source_path_serde_keys_match_lifted_dep_source_key_consts() {
15022        // Fail-before-pass-after: a future variant rename `Path` →
15023        // `Local` / `Filesystem` would emit `"tipo":"local"` and trip
15024        // this pin. A per-consumer disambiguation as the `defcaixa`
15025        // macro stabilizes ("caminho" → "path" for English-uniformity)
15026        // is scoped to the inner field key, not the discriminator; this
15027        // pin is orthogonal to that and catches only the outer
15028        // discriminator drift.
15029        let src = DepSource::Path {
15030            caminho: "../caixa-teia".into(),
15031        };
15032        let json = serde_json::to_value(&src).unwrap();
15033        let obj = json.as_object().expect("Path serializes as a JSON object");
15034        assert_eq!(
15035            obj.get(crate::render::DEP_SOURCE_KEY_TIPO)
15036                .and_then(serde_json::Value::as_str),
15037            Some(crate::render::DEP_SOURCE_TIPO_PATH),
15038            "DepSource::Path must serialize the tipo discriminator at DEP_SOURCE_KEY_TIPO \
15039             with value DEP_SOURCE_TIPO_PATH — attribute drift or variant rename \
15040             detected in {json}"
15041        );
15042    }
15043
15044    #[test]
15045    fn dep_source_key_consts_are_pairwise_distinct() {
15046        // Cross-axis collapse detector: a hypothetical future edit that
15047        // accidentally set two of the three consts to the same byte
15048        // (`DEP_SOURCE_TIPO_GIT = "path"` typo matching a peer arm) would
15049        // pass every per-arm serialize pin above but silently collapse
15050        // the discriminator's closed-set arms onto one another; this pin
15051        // catches the collapse at build time.
15052        assert_ne!(
15053            crate::render::DEP_SOURCE_KEY_TIPO,
15054            crate::render::DEP_SOURCE_TIPO_GIT,
15055        );
15056        assert_ne!(
15057            crate::render::DEP_SOURCE_KEY_TIPO,
15058            crate::render::DEP_SOURCE_TIPO_PATH,
15059        );
15060        assert_ne!(
15061            crate::render::DEP_SOURCE_TIPO_GIT,
15062            crate::render::DEP_SOURCE_TIPO_PATH,
15063        );
15064    }
15065
15066    #[test]
15067    fn dep_source_tipo_variant_consts_are_ascii_lowercase_shape() {
15068        // Shape pin against `rename_all` drift: the two variant-tag
15069        // consts must be ASCII-lowercase-only to match the
15070        // `rename_all = "lowercase"` attribute the derive uses; a future
15071        // rebrand to `"UPPERCASE"` / `"PascalCase"` at the attribute
15072        // would emit `"GIT"` / `"Git"` instead and trip this pin.
15073        for (label, s) in [
15074            ("DEP_SOURCE_TIPO_GIT", crate::render::DEP_SOURCE_TIPO_GIT),
15075            ("DEP_SOURCE_TIPO_PATH", crate::render::DEP_SOURCE_TIPO_PATH),
15076        ] {
15077            assert!(!s.is_empty(), "{label} must not be empty");
15078            assert!(
15079                s.bytes().all(|b| b.is_ascii_lowercase()),
15080                "{label} must be ASCII-lowercase-only (matching \
15081                 rename_all = \"lowercase\"), got {s:?}",
15082            );
15083        }
15084    }
15085
15086    // ── per-entry :caracteristicas set-not-multiset gate ────────────
15087    //
15088    // Every Vec-keyed-by-name authoring surface on the typed Caixa
15089    // surface that identifies its entries by a name field now uniformly
15090    // closes the set-not-multiset discipline at build time (cite
15091    // `validate_caracteristicas`'s peer-axis enumeration). The
15092    // `:caracteristicas` axis is per-`Dep`: the feature-toggle slot is
15093    // set-shaped (a feature is either enabled or not — there is no
15094    // `feature × 2` semantic), so two entries naming the same feature
15095    // are a redundant declaration the caixa-resolver's lacre pipeline
15096    // would silently dedup at resolve time. The empty-feature arm
15097    // closes the parallel "operationally-meaningless value" axis on
15098    // the same slot. Same linear-walk + `HashSet` + first-collision
15099    // shape every peer set gate uses; same empty-first cascade every
15100    // peer per-entry shape + duplicate gate uses (the empty-feature
15101    // axis is the more-actionable defect since two `""` entries would
15102    // both report `caracteristica: ""` under a duplicate-first
15103    // ordering, with no way to distinguish the offending site).
15104
15105    fn dep_with_features(features: &[&str]) -> Dep {
15106        Dep {
15107            nome: "caixa-teia".into(),
15108            versao: "^0.1".into(),
15109            fonte: None,
15110            opcional: false,
15111            caracteristicas: features.iter().map(|s| (*s).into()).collect(),
15112        }
15113    }
15114
15115    #[test]
15116    fn validate_rejects_empty_caracteristica() {
15117        // Fail-before-pass-after pin: every pre-gate codebase accepted
15118        // `(:caracteristicas (""))` cleanly (the `Vec<String>` field
15119        // imposed no per-entry shape contract), the dep validated, and
15120        // the empty feature would have reached the future caixa-resolver
15121        // lacre pipeline as a no-op feature enable — silently dropping
15122        // the author's intent far from the source `caixa.lisp`. The new
15123        // gate surfaces the structural defect at the typed-validate
15124        // surface with a self-locating diagnostic naming the offending
15125        // dep's `:nome`.
15126        let d = dep_with_features(&[""]);
15127        assert!(
15128            matches!(d.validate().unwrap_err(), DepError::CaracteristicaEmpty { ref nome } if nome == "caixa-teia"),
15129            "expected CaracteristicaEmpty, got {:?}",
15130            d.validate(),
15131        );
15132    }
15133
15134    #[test]
15135    fn validate_rejects_duplicate_caracteristica() {
15136        // Fail-before-pass-after pin on the set-not-multiset arm: the
15137        // feature-toggle slot is set-shaped, so `(:caracteristicas
15138        // ("http" "http"))` is a redundant declaration the lacre
15139        // pipeline dedupes silently at resolve time. The diagnostic
15140        // names the offending dep + the colliding feature verbatim so
15141        // the author can grep their caixa.lisp for `:caracteristicas`
15142        // and fix it in one edit. First-collision determinism is
15143        // pinned separately below.
15144        let d = dep_with_features(&["http", "http"]);
15145        assert!(
15146            matches!(
15147                d.validate().unwrap_err(),
15148                DepError::CaracteristicaDuplicate { ref nome, ref caracteristica }
15149                    if nome == "caixa-teia" && caracteristica == "http"
15150            ),
15151            "expected CaracteristicaDuplicate, got {:?}",
15152            d.validate(),
15153        );
15154    }
15155
15156    #[test]
15157    fn validate_accepts_distinct_caracteristicas() {
15158        // The canonical authoring shape — every feature distinct — must
15159        // remain a clean pass (positive control sweep). Covers the
15160        // canonical kebab-case feature names a target caixa typically
15161        // declares.
15162        dep_with_features(&["http", "json", "tls"])
15163            .validate()
15164            .unwrap();
15165    }
15166
15167    #[test]
15168    fn validate_accepts_single_caracteristica() {
15169        // Single-element list is the minimum non-empty shape; passes
15170        // the gate as the identity of the duplicate check (no second
15171        // entry to collide with).
15172        dep_with_features(&["http"]).validate().unwrap();
15173    }
15174
15175    #[test]
15176    fn validate_accepts_empty_caracteristicas_list() {
15177        // The bare-dep authoring shape (`Dep::simple` / `Dep::git`)
15178        // produces `caracteristicas: Vec::new()`; the empty list is
15179        // the gate's empty-set identity and passes vacuously. Pin
15180        // this so a future tightening that requires ≥1 feature
15181        // surfaces here as a test failure rather than a silent
15182        // contract narrowing.
15183        Dep::simple("caixa-teia", "^0.1").validate().unwrap();
15184        assert!(dep_with_features(&[]).validate().is_ok());
15185    }
15186
15187    #[test]
15188    fn validate_caracteristica_empty_fires_before_duplicate() {
15189        // Empty-first cascade: an entry with an empty feature *and*
15190        // duplicate entries surfaces the empty diagnostic first. The
15191        // empty-feature axis is the more-actionable defect since
15192        // `caracteristica: ""` is unambiguous; under duplicate-first
15193        // ordering the diagnostic could report the empty string from
15194        // either of two empty entries with no way to distinguish.
15195        // Mirrors the peer empty-before-duplicate ordering
15196        // discipline every per-entry shape + duplicate gate establishes
15197        // (`SupervisorSpec::validate`'s `EmptyChildName` arm before
15198        // `DuplicateChildCaixa`, `validate_membros`'s
15199        // `MembroCaixaEmpty` arm before `MembroDuplicate`).
15200        let d = dep_with_features(&["", "http", "http"]);
15201        assert!(matches!(
15202            d.validate().unwrap_err(),
15203            DepError::CaracteristicaEmpty { .. }
15204        ));
15205    }
15206
15207    #[test]
15208    fn validate_caracteristica_duplicate_first_collision_determinism() {
15209        // Three matching entries: the second occurrence surfaces the
15210        // diagnostic (the second is the first *collision* — the first
15211        // entry is the establishing one, not a duplicate). Mirrors
15212        // every peer first-collision posture
15213        // (`SupervisorError::DuplicateChildCaixa` reports the second
15214        // collision, `AplicacaoError::MembroDuplicate` reports the
15215        // second, `DepError::DuplicateNome` reports the second).
15216        // Pinning this so a future shortcut that flips to last-
15217        // collision (or non-deterministic) surfaces here.
15218        let d = dep_with_features(&["http", "http", "http"]);
15219        assert!(matches!(
15220            d.validate().unwrap_err(),
15221            DepError::CaracteristicaDuplicate { ref caracteristica, .. } if caracteristica == "http"
15222        ));
15223    }
15224
15225    #[test]
15226    fn validate_per_entry_shape_fires_before_caracteristicas() {
15227        // Per-entry shape precedence: a dep with a malformed `:nome`
15228        // (uppercase) AND duplicate `:caracteristicas` surfaces the
15229        // narrower `NomeInvalid` diagnostic first, not the set-gate
15230        // diagnostic. The `:nome` is the self-locating axis (every
15231        // diagnostic from the caracteristicas gate quotes the
15232        // offending dep's `:nome` to anchor the grep target —
15233        // surfacing the malformed name first keeps that anchor
15234        // valid). Same precedence shape every peer per-entry-shape
15235        // arm establishes against its peer set-gate
15236        // (`validate_deps_per_entry_validate_fires_before_duplicate_in_deps`
15237        // on the cross-entry `:nome` axis).
15238        let d = Dep {
15239            nome: "Caixa-Teia".into(), // uppercase — DNS-1123 violation
15240            versao: "^0.1".into(),
15241            fonte: None,
15242            opcional: false,
15243            caracteristicas: vec!["http".into(), "http".into()],
15244        };
15245        assert!(matches!(
15246            d.validate().unwrap_err(),
15247            DepError::NomeInvalid { .. }
15248        ));
15249    }
15250
15251    // ── per-entry :caracteristicas value-shape gate ──────────────────
15252    //
15253    // Until this gate landed `:caracteristicas` only refused the empty
15254    // string and cross-entry duplicates: a non-empty distinct but
15255    // structurally invalid feature name silently passed validate and the
15256    // failure surfaced at `cargo metadata` time as Cargo's
15257    // `restricted_names::validate_feature_name` parser rejection, far from
15258    // the source `caixa.lisp` with no field naming which `:deps` entry's
15259    // `:caracteristicas` carried the typo. The lifted predicate makes the
15260    // Cargo-feature-name-grammar intersection-floor a substrate-level
15261    // invariant at validate time. Same trajectory as the eight peer
15262    // value-shape predicates each typed surface downstream of a structured
15263    // grammar already follows.
15264
15265    #[test]
15266    fn validate_rejects_caracteristica_with_leading_plus() {
15267        // Fail-before-pass-after pin on the canonical Cargo
15268        // `+<feature>` activation-form-in-feature-name-slot footgun.
15269        // Cargo's `[dependencies.<dep>.features]` list grammar accepts
15270        // `+optional-feature` as an enablement of a previously-disabled
15271        // feature; pasting that activation form into `:caracteristicas`
15272        // (which names the feature itself) silently passed pre-gate and
15273        // failed at `cargo metadata` parse time.
15274        let d = dep_with_features(&["+http"]);
15275        let err = d.validate().unwrap_err();
15276        assert!(
15277            matches!(
15278                err,
15279                DepError::CaracteristicaInvalid { ref nome, ref caracteristica, .. }
15280                    if nome == "caixa-teia" && caracteristica == "+http"
15281            ),
15282            "expected CaracteristicaInvalid, got {err:?}"
15283        );
15284    }
15285
15286    #[test]
15287    fn validate_rejects_caracteristica_with_leading_hyphen() {
15288        // Fail-before-pass-after pin on the leading-hyphen footgun. `-`
15289        // is a legitimate continuation character (kebab-case feature
15290        // names like `runtime-tokio` pass) but Cargo rejects it at the
15291        // start; the structural defect — and its CLI-argument-injection
15292        // adjacency at any downstream Cargo subprocess invocation — is
15293        // closed at validate time, not at `cargo metadata` time.
15294        let d = dep_with_features(&["-json"]);
15295        let err = d.validate().unwrap_err();
15296        assert!(
15297            matches!(
15298                err,
15299                DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "-json"
15300            ),
15301            "expected CaracteristicaInvalid, got {err:?}"
15302        );
15303    }
15304
15305    #[test]
15306    fn validate_rejects_caracteristica_with_leading_dot() {
15307        // Fail-before-pass-after pin on the leading-dot footgun. `.` is
15308        // a legitimate continuation character (version-suffix shapes
15309        // like `feat.v2` pass) but the leading-dot form is the
15310        // canonical dotted-version-suffix-as-feature-name confusion.
15311        let d = dep_with_features(&[".feat"]);
15312        let err = d.validate().unwrap_err();
15313        assert!(matches!(
15314            err,
15315            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == ".feat"
15316        ));
15317    }
15318
15319    #[test]
15320    fn validate_rejects_caracteristica_with_whitespace() {
15321        // Fail-before-pass-after pin on the embedded-whitespace footgun:
15322        // a feature name with a space inside is structurally a multi-
15323        // token blob (the canonical paste-from-doc footgun, or an
15324        // accidental `"http server"` where the author meant
15325        // `"http-server"`).
15326        let d = dep_with_features(&["http feature"]);
15327        let err = d.validate().unwrap_err();
15328        assert!(matches!(
15329            err,
15330            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http feature"
15331        ));
15332    }
15333
15334    #[test]
15335    fn validate_rejects_caracteristica_with_comma() {
15336        // Fail-before-pass-after pin on the embedded-comma footgun:
15337        // the list-separator-belongs-to-the-list-grammar
15338        // miscomprehension where the author writes
15339        // `:caracteristicas ("http,json")` intending two features but
15340        // the `Vec<String>` field consumes the bare token as one entry.
15341        let d = dep_with_features(&["http,json"]);
15342        let err = d.validate().unwrap_err();
15343        assert!(matches!(
15344            err,
15345            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http,json"
15346        ));
15347    }
15348
15349    #[test]
15350    fn validate_rejects_caracteristica_with_slash() {
15351        // Fail-before-pass-after pin on the embedded-slash footgun:
15352        // Cargo's `dep/feat` namespaced-dep syntax applies inside
15353        // `[dependencies.<dep>.features]` list entries that already
15354        // name the parent dep (so the syntax says "enable feature
15355        // `feat` on a transitive dep `dep`"); `:caracteristicas` is
15356        // per-dep already (a sibling slot on the `Dep` itself), so the
15357        // segment separator within an entry must be `-`, `_`, `+`,
15358        // or `.`. The diagnostic remediation points at the canonical
15359        // Cargo namespaced-dep discipline.
15360        let d = dep_with_features(&["http/json"]);
15361        let err = d.validate().unwrap_err();
15362        assert!(matches!(
15363            err,
15364            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http/json"
15365        ));
15366    }
15367
15368    #[test]
15369    fn validate_rejects_caracteristica_with_non_ascii() {
15370        // Fail-before-pass-after pin on the un-percent-encoded non-ASCII
15371        // byte footgun: NFC-vs-NFD normalization across filesystems
15372        // silently rewrites the feature-key, breaking the lacre's
15373        // content-addressing invariant. Pinned at a canonical
15374        // smart-quote-paste shape (`café`) where the raw `é` byte is the
15375        // documented APFS round-trip break.
15376        let d = dep_with_features(&["caf\u{e9}"]);
15377        let err = d.validate().unwrap_err();
15378        assert!(matches!(
15379            err,
15380            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "caf\u{e9}"
15381        ));
15382    }
15383
15384    #[test]
15385    fn validate_rejects_caracteristica_with_control_character() {
15386        // Fail-before-pass-after pin on the embedded-control-character
15387        // footgun: a CR/LF or any 0x00..0x1F / 0x7F byte landing in a
15388        // feature name is the canonical paste-from-multiline-doc
15389        // footgun the predicate's reason wording specifically calls out.
15390        let d = dep_with_features(&["http\njson"]);
15391        let err = d.validate().unwrap_err();
15392        assert!(matches!(err, DepError::CaracteristicaInvalid { .. }));
15393    }
15394
15395    #[test]
15396    fn validate_accepts_canonical_caracteristicas_shapes() {
15397        // Positive control sweep: every canonical Cargo feature name
15398        // shape the pleme-io ecosystem uses must still pass. Mirrors
15399        // the substrate-side `cargo_feature_name_accepts_canonical_forms`
15400        // sweep — drift between either landing site and the predicate's
15401        // accepted set is a build error visible at this pair of tests,
15402        // not a per-renderer "this passed validate but failed at
15403        // cargo metadata time" surprise on the next acceptance.
15404        for s in [
15405            "http",
15406            "json",
15407            "derive",
15408            "serde_json",
15409            "runtime-tokio",
15410            "tokio.full",
15411            "v0.1",
15412            "http+json",
15413            "_internal",
15414            "__private",
15415            "default",
15416            "rt-multi-thread",
15417            "feat.v2",
15418        ] {
15419            let d = dep_with_features(&[s]);
15420            d.validate().unwrap_or_else(|e| {
15421                panic!("canonical Cargo feature name {s:?} must pass validate: {e:?}")
15422            });
15423        }
15424    }
15425
15426    #[test]
15427    fn validate_caracteristica_empty_fires_before_invalid() {
15428        // Cascade precedence pin: an entry list with both an empty
15429        // feature AND an invalid-shape feature surfaces the
15430        // `CaracteristicaEmpty` arm first (the empty value carries no
15431        // self-locating data — `caracteristica: ""` is the diagnostic
15432        // with no way to anchor a grep target — so closing the empty
15433        // axis first preserves the per-entry-shape diagnostic's
15434        // self-locating discipline). Same empty-first cascade every
15435        // peer per-entry shape gate establishes
15436        // (`SupervisorSpec::validate`'s `EmptyChildName` before
15437        // `ChildCaixaInvalid`, `validate_membros`'s `MembroCaixaEmpty`
15438        // before `MembroCaixaInvalid`).
15439        let d = dep_with_features(&["", "+http"]);
15440        assert!(matches!(
15441            d.validate().unwrap_err(),
15442            DepError::CaracteristicaEmpty { .. }
15443        ));
15444    }
15445
15446    #[test]
15447    fn validate_caracteristica_invalid_fires_before_duplicate() {
15448        // Per-entry-shape precedence pin: an entry list with the same
15449        // invalid feature shape declared twice surfaces the
15450        // `CaracteristicaInvalid` diagnostic on the first entry, not
15451        // the `CaracteristicaDuplicate` on the second collision. The
15452        // per-entry shape gate fires before the cross-entry set gate
15453        // — same precedence shape every peer two-arm-plus-set gate
15454        // establishes (`SupervisorSpec::validate`'s
15455        // `ChildCaixaInvalid` before `DuplicateChildCaixa`,
15456        // `validate_membros`'s `MembroCaixaInvalid` before
15457        // `MembroDuplicate`, `Dep::validate`'s `NomeInvalid` before
15458        // cross-list `DuplicateNome`).
15459        let d = dep_with_features(&["+http", "+http"]);
15460        assert!(matches!(
15461            d.validate().unwrap_err(),
15462            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "+http"
15463        ));
15464    }
15465
15466    #[test]
15467    fn validate_rejects_caracteristica_at_65_byte_boundary() {
15468        // Boundary pin on the 64-byte cap — both the boundary-accepting
15469        // case and the boundary-exceeding case in one place, so a
15470        // future cap shift surfaces both arms simultaneously, mirroring
15471        // the peer `cargo_feature_name_rejects_at_65_byte_boundary`
15472        // predicate-level pin at the dep-axis landing site.
15473        let max_ok = "a".repeat(64);
15474        dep_with_features(&[&max_ok])
15475            .validate()
15476            .unwrap_or_else(|e| panic!("64-byte feature name must pass: {e:?}"));
15477        let too_long = "a".repeat(65);
15478        let d = dep_with_features(&[&too_long]);
15479        assert!(matches!(
15480            d.validate().unwrap_err(),
15481            DepError::CaracteristicaInvalid { .. }
15482        ));
15483    }
15484
15485    // ── self-dep cross-slot gate ─────────────────────────────────────
15486
15487    #[test]
15488    fn validate_no_self_dep_rejects_self_in_deps() {
15489        // A caixa whose `:deps` lists its own `:nome` is a one-node
15490        // cycle in the lacre closure's dep-graph traversal — rejected,
15491        // naming the parent and the offending list tag.
15492        let deps = vec![
15493            Dep::simple("caixa-teia", "^0.1"),
15494            Dep::simple("orquestra", "^0.1"),
15495        ];
15496        let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
15497        assert!(
15498            matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS),
15499            "got {err:?}"
15500        );
15501    }
15502
15503    #[test]
15504    fn validate_no_self_dep_rejects_self_in_deps_dev() {
15505        // Same gate on the `:deps-dev` axis — neither dep list is a
15506        // second-class citizen on the self-edge invariant.
15507        let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
15508        let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
15509        assert!(
15510            matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
15511            "got {err:?}"
15512        );
15513    }
15514
15515    #[test]
15516    fn validate_no_self_dep_deps_fires_before_deps_dev() {
15517        // Walk order pin: a caixa that self-references on both lists
15518        // surfaces the `:deps` arm first — the load-bearing axis the
15519        // lacre closure resolves at every build. Mirrors the canonical
15520        // [`Caixa::validate_deps`] cascade (`:deps` → `:deps-dev`).
15521        let deps = vec![Dep::simple("orquestra", "^0.1")];
15522        let deps_dev = vec![Dep::simple("orquestra", "^0.2")];
15523        let err = validate_no_self_dep(&deps, &deps_dev, "orquestra").unwrap_err();
15524        assert!(
15525            matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS),
15526            "got {err:?}"
15527        );
15528    }
15529
15530    #[test]
15531    fn validate_no_self_dep_accepts_distinct_names() {
15532        // Positive control: every dep names a distinct caixa. The
15533        // canonical author surface — peer of
15534        // [`validate_no_self_supervision_accepts_distinct_children`].
15535        let deps = vec![
15536            Dep::simple("caixa-teia", "^0.1"),
15537            Dep::simple("caixa-arch", "^0.1"),
15538        ];
15539        let deps_dev = vec![Dep::simple("caixa-test", "^0.1")];
15540        validate_no_self_dep(&deps, &deps_dev, "orquestra").unwrap();
15541    }
15542
15543    #[test]
15544    fn validate_no_self_dep_empty_lists_pass() {
15545        // A caixa with no declared deps has nothing to self-reference —
15546        // the gate is vacuously satisfied. Peer of
15547        // [`validate_no_self_supervision_empty_children_is_ok`].
15548        validate_no_self_dep(&[], &[], "orquestra").unwrap();
15549    }
15550
15551    #[test]
15552    fn validate_no_self_dep_diagnostic_carries_offending_list_and_nome() {
15553        // Diagnostic-shape pin (peer with
15554        // [`validate_no_self_supervision`]'s diagnostic): the error's
15555        // Display surfaces both the offending list tag and the
15556        // parent's `:nome` verbatim, so the author can grep their
15557        // caixa.lisp for the offending block in one edit. Names
15558        // `:bibliotecas` / `:exe` / `:servicos` as the corrective
15559        // surface — every legitimate "I want to use code from this
15560        // caixa" intent routes through one of those three slots.
15561        let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
15562        let rendered = validate_no_self_dep(&[], &deps_dev, "orquestra")
15563            .unwrap_err()
15564            .to_string();
15565        assert!(
15566            rendered.contains(crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
15567            "diagnostic must name the offending list tag: {rendered}",
15568        );
15569        assert!(
15570            rendered.contains("orquestra"),
15571            "diagnostic must quote the parent caixa name: {rendered}",
15572        );
15573        assert!(
15574            rendered.contains(":bibliotecas"),
15575            "diagnostic must point at the corrective code-surface slot: {rendered}",
15576        );
15577    }
15578
15579    #[test]
15580    fn validate_no_self_dep_accepts_coincidental_substring_match() {
15581        // Identity is exact-string equality, not substring — a dep
15582        // named `"orquestra-helper"` is a distinct caixa even when the
15583        // parent is `"orquestra"`. Pin the exact-match discipline so a
15584        // future relaxation that uses `contains` surfaces here, peer
15585        // with the supervision-tree and Aplicacao-membership gates
15586        // which all use exact-string equality on the typed identity.
15587        let deps = vec![Dep::simple("orquestra-helper", "^0.1")];
15588        validate_no_self_dep(&deps, &[], "orquestra").unwrap();
15589    }
15590
15591    // ── drift-detection: DEP_AUTHOR_KEY_{DEPS,DEPS_DEV} pin ─────────────
15592
15593    #[test]
15594    fn dep_author_key_consts_pin_canonical_kebab_case_labels() {
15595        // Scalar-value pin: the two author-facing kebab-case labels the
15596        // `(defcaixa … :deps ((…)) :deps-dev ((…)))` surface admits on
15597        // the two-list dep-graph slot axis, one arm per typed slot.
15598        // Mirrors the peer scalar-value pin the sibling
15599        // [`crate::M2_AUTHOR_KEY_LIMITS`] /
15600        // [`crate::M2_AUTHOR_KEY_BEHAVIOR`] /
15601        // [`crate::M2_AUTHOR_KEY_UPGRADE_FROM`] (f49c8b0) M2 top-level
15602        // author-labels, [`crate::M3_AUTHOR_KEY_MEMBROS`] etc.
15603        // (882f498) M3 top-level author-labels, and
15604        // [`crate::SUPERVISOR_AUTHOR_KEY_ESTRATEGIA`] etc. (be40492)
15605        // Supervisor top-level author-labels carry, so every kind-scoped
15606        // typed-slot-family axis routes through one canonical per-arm
15607        // declaration.
15608        //
15609        // A future rebrand (`:deps` → `:dependencies` matching Cargo's
15610        // verbatim key, `:deps-dev` → `:dev-dependencies` matching the
15611        // same, `:deps` / `:deps-dev` → `:runtime-deps` / `:dev-deps`
15612        // for symmetry) lands as an edit to exactly one const, and
15613        // every consumer that reaches for the label picks it up at
15614        // build time rather than at runtime as a downstream mismatch on
15615        // a `DepError::DuplicateNome { list: … }` diagnostic far from
15616        // the rename's commit.
15617        assert_eq!(crate::render::DEP_AUTHOR_KEY_DEPS, ":deps");
15618        assert_eq!(crate::render::DEP_AUTHOR_KEY_DEPS_DEV, ":deps-dev");
15619    }
15620
15621    #[test]
15622    fn dep_author_key_consts_are_pairwise_distinct() {
15623        // Distinct-labels pin: the two `:deps` / `:deps-dev` labels
15624        // must not collapse onto one byte-string. A future copy-paste
15625        // slip that renamed both consts to the same value (or a rebrand
15626        // that dropped the `-dev` suffix from one but not the other)
15627        // would leave every `DepError::DuplicateNome { list: … }`
15628        // diagnostic naming an unattributable list — the linter would
15629        // route the author to the wrong caixa.lisp block, or the
15630        // cross-list precedence gate
15631        // (`validate_deps_duplicate_in_deps_fires_before_duplicate_in_deps_dev`)
15632        // would surface a `:deps`-tagged diagnostic on a `:deps-dev`
15633        // duplicate. Peer of the sibling
15634        // `m2_author_key_consts_are_pairwise_distinct`-shape gates the
15635        // other top-level kind-scoped slot-family axes carry
15636        // (implicitly held by their different byte-values today).
15637        assert_ne!(
15638            crate::render::DEP_AUTHOR_KEY_DEPS,
15639            crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
15640            "DEP_AUTHOR_KEY_{{DEPS,DEPS_DEV}} consts must be pairwise-distinct \
15641             so a `DepError::DuplicateNome {{ list: … }}` diagnostic \
15642             self-locates the offending block in the author's caixa.lisp",
15643        );
15644    }
15645
15646    #[test]
15647    fn validate_no_self_dep_routes_through_lifted_dep_author_key_consts() {
15648        // Production-through-const pin: the two per-arm list tags
15649        // [`validate_no_self_dep`] threads onto the `list:` field of a
15650        // returned [`DepError::DepIsSelf`] route through the lifted
15651        // [`crate::DEP_AUTHOR_KEY_DEPS`] /
15652        // [`crate::DEP_AUTHOR_KEY_DEPS_DEV`] consts. A future drift at
15653        // the walker (a rename that reaches one arm but not the const,
15654        // or vice versa) surfaces here at build time rather than at
15655        // runtime as a `feira lint` diagnostic naming the wrong list
15656        // tag. Mirror of the peer
15657        // [`crate::Caixa::declared_servico_slots`] production tagger
15658        // pin (f49c8b0) on the sibling M2 top-level slot axis, extended
15659        // onto the two-list dep-graph gate.
15660        let deps = vec![Dep::simple("orquestra", "^0.1")];
15661        let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
15662        let DepError::DepIsSelf { list, .. } = err else {
15663            panic!("expected DepIsSelf from :deps walk");
15664        };
15665        assert_eq!(list, crate::render::DEP_AUTHOR_KEY_DEPS);
15666
15667        let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
15668        let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
15669        let DepError::DepIsSelf { list, .. } = err else {
15670            panic!("expected DepIsSelf from :deps-dev walk");
15671        };
15672        assert_eq!(list, crate::render::DEP_AUTHOR_KEY_DEPS_DEV);
15673    }
15674
15675    // ── Dep::nome accessor pins ───────────────────────────────────────
15676    //
15677    // Three coherence pins on the lifted `Dep::nome` accessor: byte-equal
15678    // projection over the plain-shorthand / explicit-git / explicit-path
15679    // fixture triad the [`Dep`] docstring lists (so the accessor's
15680    // accept-set is exercised across every author-surface `:fonte`
15681    // shape); by-borrow pointer identity so the projection stays
15682    // zero-copy at every consumer site; and validate-composition through
15683    // the [`validate_no_self_dep`] cross-slot gate reading its
15684    // parent-name equality check through the lifted accessor rather than
15685    // the raw field.
15686
15687    #[test]
15688    fn dep_nome_returns_declared_nome_across_fonte_shapes() {
15689        // Plain-shorthand form (`:fonte None`).
15690        assert_eq!(Dep::simple("caixa-teia", "^0.1").nome(), "caixa-teia");
15691        // Explicit git-source form with a tag pin — same accessor path.
15692        assert_eq!(
15693            Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0").nome(),
15694            "caixa-teia",
15695        );
15696        // Explicit path-source form.
15697        assert_eq!(
15698            Dep {
15699                nome: "caixa-teia".to_string(),
15700                versao: "0.1.0".to_string(),
15701                fonte: Some(DepSource::Path {
15702                    caminho: "../caixa-teia".to_string(),
15703                }),
15704                opcional: false,
15705                caracteristicas: Vec::new(),
15706            }
15707            .nome(),
15708            "caixa-teia",
15709        );
15710        // The empty-string `:nome` sentinel (which [`Dep::validate`]
15711        // refuses through the [`DepError::NomeEmpty`] arm) still round-
15712        // trips as an empty `&str` through the accessor — the accessor is
15713        // a projection, not a gate; the gate is [`Dep::validate`].
15714        assert_eq!(Dep::simple("", "^0.1").nome(), "");
15715    }
15716
15717    #[test]
15718    fn dep_nome_is_by_borrow_pointer_identity() {
15719        // Zero-copy pin: the accessor must borrow into the field's own
15720        // storage, not clone. If a future rewrite regresses to
15721        // `self.nome.clone().leak()` or an owned-buffer shape, the two
15722        // pointers diverge and this pin fails at build time.
15723        let d = Dep::simple("caixa-teia", "^0.1");
15724        assert!(std::ptr::eq(d.nome().as_ptr(), d.nome.as_ptr()));
15725    }
15726
15727    // ── Dep::versao_requirement accessor pins ─────────────────────────
15728    //
15729    // Three coherence pins on the lifted `Dep::versao_requirement`
15730    // accessor: byte-equal projection over the plain-shorthand /
15731    // explicit-git / explicit-path fixture triad the [`Dep`] docstring
15732    // lists plus the empty-sentinel that round-trips as `""` (the accessor
15733    // is a projection, not a gate; the gate is [`Dep::validate`]); by-
15734    // borrow pointer identity so the projection stays zero-copy at every
15735    // consumer site; and validate-composition through the
15736    // [`crate::render::require_valid_versao_requirement`] cascade reading
15737    // its requirement-shape check through the lifted accessor rather than
15738    // the raw field.
15739    #[test]
15740    fn dep_versao_requirement_returns_declared_versao_across_fonte_shapes() {
15741        // Plain-shorthand form (`:fonte None`).
15742        assert_eq!(
15743            Dep::simple("caixa-teia", "^0.1").versao_requirement(),
15744            "^0.1",
15745        );
15746        // Explicit git-source form with a tag pin — same accessor path.
15747        assert_eq!(
15748            Dep::git(
15749                "caixa-teia",
15750                "~0.1.2",
15751                "github:pleme-io/caixa-teia",
15752                "v0.1.0"
15753            )
15754            .versao_requirement(),
15755            "~0.1.2",
15756        );
15757        // Explicit path-source form.
15758        assert_eq!(
15759            Dep {
15760                nome: "caixa-teia".to_string(),
15761                versao: "0.1.0".to_string(),
15762                fonte: Some(DepSource::Path {
15763                    caminho: "../caixa-teia".to_string(),
15764                }),
15765                opcional: false,
15766                caracteristicas: Vec::new(),
15767            }
15768            .versao_requirement(),
15769            "0.1.0",
15770        );
15771        // The wildcard requirement (`"*"`) — the shorthand
15772        // `parse_requirement` accepts as `VersionReq::STAR` — round-trips
15773        // verbatim through the accessor as `"*"`, same byte-shape the
15774        // author wrote.
15775        assert_eq!(Dep::simple("caixa-teia", "*").versao_requirement(), "*");
15776        // The empty-string `:versao` sentinel (which [`Dep::validate`]
15777        // refuses through the [`DepError::VersaoEmpty`] arm) still round-
15778        // trips as an empty `&str` through the accessor — the accessor is
15779        // a projection, not a gate; the gate is [`Dep::validate`]. Peer
15780        // of the sibling [`Dep::nome`] empty-sentinel round-trip pin.
15781        assert_eq!(Dep::simple("caixa-teia", "").versao_requirement(), "");
15782    }
15783
15784    #[test]
15785    fn dep_versao_requirement_is_by_borrow_pointer_identity() {
15786        // Zero-copy pin: the accessor must borrow into the field's own
15787        // storage, not clone. If a future rewrite regresses to
15788        // `self.versao.clone().leak()` or an owned-buffer shape, the two
15789        // pointers diverge and this pin fails at build time. Peer of the
15790        // sibling [`Dep::nome`] pointer-identity pin — same by-borrow
15791        // discipline extended onto the requirement-carrying axis.
15792        let d = Dep::simple("caixa-teia", "^0.1");
15793        assert!(std::ptr::eq(
15794            d.versao_requirement().as_ptr(),
15795            d.versao.as_ptr(),
15796        ));
15797    }
15798
15799    #[test]
15800    fn dep_validate_reads_requirement_through_accessor() {
15801        // Composition pin: the [`Dep::validate`]
15802        // [`crate::render::require_valid_versao_requirement`] cascade
15803        // consumes the requirement string through the lifted accessor —
15804        // both the requirement-gate input and the
15805        // [`DepError::VersaoInvalid`] error-body carrier route through
15806        // `self.versao_requirement()`. A valid requirement passes
15807        // (positive control); a malformed-but-non-empty requirement fails
15808        // and the diagnostic quotes the offending byte-string verbatim
15809        // (same shape the accessor projects), so a future regression that
15810        // detoured the requirement carrier through a different byte-
15811        // string (say the parsed `VersionReq`'s `Display`, or a
15812        // normalized rewrite) would surface here at build time. The
15813        // empty-`:versao` arm fires the [`DepError::VersaoEmpty`] variant
15814        // ahead of the parse arm, pinning the empty-first cascade the
15815        // accessor's `""` sentinel round-trip acknowledges.
15816        Dep::simple("caixa-teia", "^0.1").validate().unwrap();
15817        let err = Dep::simple("caixa-teia", "v0.1").validate().unwrap_err();
15818        assert!(
15819            matches!(
15820                &err,
15821                DepError::VersaoInvalid {
15822                    nome,
15823                    versao,
15824                    ..
15825                } if nome == "caixa-teia" && versao == "v0.1",
15826            ),
15827            "expected VersaoInvalid quoting the accessor-projected requirement, got {err:?}",
15828        );
15829        let err = Dep::simple("caixa-teia", "").validate().unwrap_err();
15830        assert!(
15831            matches!(
15832                &err,
15833                DepError::VersaoEmpty { nome } if nome == "caixa-teia",
15834            ),
15835            "expected VersaoEmpty from the empty-first arm, got {err:?}",
15836        );
15837    }
15838
15839    // ── Dep::fonte accessor pins ──────────────────────────────────────
15840    //
15841    // Three coherence pins on the lifted `Dep::fonte` accessor: byte-
15842    // equal projection over the plain-shorthand (`:fonte None`) /
15843    // explicit-git-tag / explicit-path fixture triad the [`Dep`]
15844    // docstring lists (so the accessor's accept-set is exercised across
15845    // every author-surface `:fonte` shape and both `DepSource` variants);
15846    // pointer identity so the borrowed reference points into the field's
15847    // own `Option<DepSource>` storage (not a cloned side-buffer); and
15848    // validate-composition through the [`Dep::validate`] gate reading
15849    // its per-`:fonte` [`DepSource::validate`] delegation through the
15850    // lifted accessor rather than the raw `if let Some(ref fonte) =
15851    // self.fonte` bracket.
15852
15853    #[test]
15854    fn dep_fonte_returns_declared_source_across_shapes() {
15855        // Plain-shorthand form — `:fonte` omitted, accessor projects
15856        // the `None` partition the resolver-side default-fill treats
15857        // as "resolve through `github:<default-org>/<nome>`".
15858        assert!(Dep::simple("caixa-teia", "^0.1").fonte().is_none());
15859        // Explicit git-source form with a tag pin — same accessor path.
15860        let git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
15861        match git.fonte() {
15862            Some(DepSource::Git {
15863                repo,
15864                tag,
15865                rev,
15866                branch,
15867            }) => {
15868                assert_eq!(repo, "github:pleme-io/caixa-teia");
15869                assert_eq!(tag.as_deref(), Some("v0.1.0"));
15870                assert!(rev.is_none());
15871                assert!(branch.is_none());
15872            }
15873            other => panic!("expected explicit git :fonte, got {other:?}"),
15874        }
15875        // Explicit path-source form — the dev-only local-filesystem
15876        // arm the [`Dep`] docstring's third fixture carries.
15877        let path = Dep {
15878            nome: "caixa-teia".to_string(),
15879            versao: "0.1.0".to_string(),
15880            fonte: Some(DepSource::Path {
15881                caminho: "../caixa-teia".to_string(),
15882            }),
15883            opcional: false,
15884            caracteristicas: Vec::new(),
15885        };
15886        match path.fonte() {
15887            Some(DepSource::Path { caminho }) => {
15888                assert_eq!(caminho, "../caixa-teia");
15889            }
15890            other => panic!("expected explicit path :fonte, got {other:?}"),
15891        }
15892    }
15893
15894    #[test]
15895    fn dep_fonte_is_by_borrow_pointer_identity() {
15896        // Zero-copy pin: the accessor must borrow into the field's own
15897        // `Option<DepSource>` storage, not clone into a side buffer. If
15898        // a future rewrite regresses to `self.fonte.clone()` or an
15899        // owned-buffer shape, the two pointers diverge and this pin
15900        // fails at build time. Peer of the sibling per-`Dep` [`Dep::nome`]
15901        // (eba2cde) / [`Dep::versao_requirement`] (05529b1) pointer-
15902        // identity pins — same by-borrow discipline extended onto the
15903        // outer-`Dep` `Option<&Composite>` composite-reference axis.
15904        let d = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
15905        let accessed = d.fonte().expect("git :fonte present") as *const DepSource;
15906        let raw = d.fonte.as_ref().expect("git :fonte present") as *const DepSource;
15907        assert!(std::ptr::eq(accessed, raw));
15908    }
15909
15910    #[test]
15911    fn dep_validate_reads_fonte_through_accessor() {
15912        // Composition pin: [`Dep::validate`]'s per-`:fonte`
15913        // [`DepSource::validate`] delegation consumes the typed slot
15914        // through the lifted accessor — an author-omitted `:fonte`
15915        // still passes the outer gate (positive control), an explicit
15916        // well-formed git source with exactly one pin passes, and a
15917        // malformed git source (empty `:repo`) surfaces the
15918        // [`DepError::FonteRepoEmpty`] variant quoting the offending
15919        // dep's `:nome` verbatim so a future regression that detoured
15920        // the `:fonte` delegation through a different path (say a
15921        // per-scope override projector) would surface here at build
15922        // time. Peer of the sibling
15923        // `dep_validate_reads_requirement_through_accessor` composition
15924        // pin on the `:versao` axis.
15925        // Positive control 1: no `:fonte` at all.
15926        Dep::simple("caixa-teia", "^0.1").validate().unwrap();
15927        // Positive control 2: well-formed git source.
15928        Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0")
15929            .validate()
15930            .unwrap();
15931        // Negative control: empty `:repo` — the accessor still returns
15932        // `Some(&DepSource::Git { repo: "", … })` and the delegated
15933        // `DepSource::validate` gate raises the typed carrier.
15934        let bad = Dep {
15935            nome: "caixa-teia".to_string(),
15936            versao: "^0.1".to_string(),
15937            fonte: Some(DepSource::Git {
15938                repo: String::new(),
15939                tag: Some("v0.1.0".to_string()),
15940                rev: None,
15941                branch: None,
15942            }),
15943            opcional: false,
15944            caracteristicas: Vec::new(),
15945        };
15946        let err = bad.validate().unwrap_err();
15947        assert!(
15948            matches!(
15949                &err,
15950                DepError::FonteRepoEmpty { nome } if nome == "caixa-teia",
15951            ),
15952            "expected FonteRepoEmpty from the accessor-routed :fonte gate, got {err:?}",
15953        );
15954    }
15955
15956    #[test]
15957    fn validate_no_self_dep_reads_parent_equality_through_accessor() {
15958        // Composition pin: the cross-slot [`validate_no_self_dep`] gate
15959        // rejects a `:deps` entry whose `:nome` equals the parent caixa's
15960        // own `:nome` through the lifted accessor rather than the raw
15961        // field. Fails-before-passes-after: with the accessor lifted the
15962        // gate reads its equality check through `dep.nome() ==
15963        // parent_nome` on both the `:deps` and `:deps-dev` traversals, so
15964        // the diagnostic still names the offending list tag as expected.
15965        let deps = vec![Dep::simple("orquestra", "^0.1")];
15966        let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
15967        assert!(matches!(
15968            err,
15969            DepError::DepIsSelf {
15970                ref nome,
15971                list,
15972            } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS,
15973        ));
15974        let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
15975        let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
15976        assert!(matches!(
15977            err,
15978            DepError::DepIsSelf {
15979                ref nome,
15980                list,
15981            } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
15982        ));
15983        // A non-matching `:nome` passes through the accessor gate.
15984        let deps = vec![Dep::simple("caixa-teia", "^0.1")];
15985        validate_no_self_dep(&deps, &[], "orquestra").unwrap();
15986    }
15987
15988    // ── Dep::caracteristicas accessor pins ────────────────────────────
15989    //
15990    // Three coherence pins on the lifted `Dep::caracteristicas` accessor:
15991    // byte-equal projection over the default-empty / single-entry /
15992    // multi-entry fixture triad (so the accessor's accept-set is
15993    // exercised across every author-surface `:caracteristicas` shape,
15994    // matching the peer sibling family's fixture-triad discipline); by-
15995    // borrow pointer identity so the projection stays zero-copy at every
15996    // consumer site; and validate-composition through the
15997    // [`Dep::validate_caracteristicas`] gate reading its per-entry
15998    // linear walk through the lifted accessor rather than the raw
15999    // `for c in &self.caracteristicas` bracket.
16000
16001    #[test]
16002    fn dep_caracteristicas_returns_declared_features_across_shapes() {
16003        // Default-empty form — the [`Dep::simple`] constructor's
16004        // `Vec::new()` fill; the accessor projects the empty slice
16005        // verbatim (no `None` collapse).
16006        assert!(
16007            Dep::simple("caixa-teia", "^0.1")
16008                .caracteristicas()
16009                .is_empty(),
16010        );
16011        // Single-entry form — the canonical Cargo-shaped one-feature
16012        // enable ([`crate::render::is_cargo_feature_name`] accepts the
16013        // `"http"` byte-string as a valid feature name).
16014        let one = Dep {
16015            nome: "caixa-teia".to_string(),
16016            versao: "^0.1".to_string(),
16017            fonte: None,
16018            opcional: false,
16019            caracteristicas: vec!["http".to_string()],
16020        };
16021        assert_eq!(one.caracteristicas(), &["http".to_string()]);
16022        // Multi-entry form — the substrate's set-shaped multi-feature
16023        // enable, exercising the accessor over a length-two slice with
16024        // no duplicate collapse.
16025        let two = Dep {
16026            nome: "caixa-teia".to_string(),
16027            versao: "^0.1".to_string(),
16028            fonte: None,
16029            opcional: false,
16030            caracteristicas: vec!["http".to_string(), "json".to_string()],
16031        };
16032        assert_eq!(
16033            two.caracteristicas(),
16034            &["http".to_string(), "json".to_string()],
16035        );
16036    }
16037
16038    #[test]
16039    fn dep_caracteristicas_is_by_borrow_pointer_identity() {
16040        // Zero-copy pin: the accessor must borrow into the field's own
16041        // `Vec<String>` storage, not clone into a side buffer. If a
16042        // future rewrite regresses to `self.caracteristicas.clone()` or
16043        // an owned-buffer shape, the two pointers diverge and this pin
16044        // fails at build time. Peer of the sibling per-`Dep`
16045        // [`Dep::nome`] (eba2cde) / [`Dep::versao_requirement`] (05529b1)
16046        // / [`Dep::fonte`] (d65d1bf) pointer-identity pins — same by-
16047        // borrow discipline extended onto the outer-`Dep` `&[String]`
16048        // slice-projection axis.
16049        let d = Dep {
16050            nome: "caixa-teia".to_string(),
16051            versao: "^0.1".to_string(),
16052            fonte: None,
16053            opcional: false,
16054            caracteristicas: vec!["http".to_string(), "json".to_string()],
16055        };
16056        assert!(std::ptr::eq(
16057            d.caracteristicas().as_ptr(),
16058            d.caracteristicas.as_ptr(),
16059        ));
16060    }
16061
16062    #[test]
16063    fn dep_validate_reads_caracteristicas_through_accessor() {
16064        // Composition pin: [`Dep::validate_caracteristicas`]'s per-entry
16065        // linear walk consumes the feature-toggle list through the
16066        // lifted accessor — a well-formed `:caracteristicas` set passes
16067        // (positive control), an empty-string entry surfaces the
16068        // [`DepError::CaracteristicaEmpty`] variant quoting the offending
16069        // `Dep::nome`, and a within-list duplicate surfaces the
16070        // [`DepError::CaracteristicaDuplicate`] variant so a future
16071        // regression that detoured the walk through a different byte-
16072        // string list (say a per-scope override projector) would surface
16073        // here at build time. Peer of the sibling
16074        // `dep_validate_reads_fonte_through_accessor` /
16075        // `dep_validate_reads_requirement_through_accessor` composition
16076        // pins on the `:fonte` / `:versao` axes.
16077        // Positive control: two distinct well-formed feature names pass.
16078        Dep {
16079            nome: "caixa-teia".to_string(),
16080            versao: "^0.1".to_string(),
16081            fonte: None,
16082            opcional: false,
16083            caracteristicas: vec!["http".to_string(), "json".to_string()],
16084        }
16085        .validate()
16086        .unwrap();
16087        // Negative control 1: empty-string feature-name entry — the
16088        // accessor still returns `&[""]` and the walk raises the typed
16089        // empty-first carrier.
16090        let err = Dep {
16091            nome: "caixa-teia".to_string(),
16092            versao: "^0.1".to_string(),
16093            fonte: None,
16094            opcional: false,
16095            caracteristicas: vec![String::new()],
16096        }
16097        .validate()
16098        .unwrap_err();
16099        assert!(
16100            matches!(
16101                &err,
16102                DepError::CaracteristicaEmpty { nome } if nome == "caixa-teia",
16103            ),
16104            "expected CaracteristicaEmpty from the accessor-routed walk, got {err:?}",
16105        );
16106        // Negative control 2: within-list duplicate — the accessor's
16107        // slice view carries both entries, and the walk's dedup arm
16108        // raises the typed duplicate carrier quoting the offending
16109        // feature name verbatim.
16110        let err = Dep {
16111            nome: "caixa-teia".to_string(),
16112            versao: "^0.1".to_string(),
16113            fonte: None,
16114            opcional: false,
16115            caracteristicas: vec!["http".to_string(), "http".to_string()],
16116        }
16117        .validate()
16118        .unwrap_err();
16119        assert!(
16120            matches!(
16121                &err,
16122                DepError::CaracteristicaDuplicate {
16123                    nome,
16124                    caracteristica,
16125                } if nome == "caixa-teia" && caracteristica == "http",
16126            ),
16127            "expected CaracteristicaDuplicate from the accessor-routed dedup, got {err:?}",
16128        );
16129    }
16130
16131    // ── Dep::opcional accessor pins ───────────────────────────────────
16132    //
16133    // Two coherence pins on the lifted `Dep::opcional` accessor: byte-
16134    // equal projection over the default-`false` / explicit-`true`
16135    // fixture pair across the plain-shorthand (`:fonte None`) / explicit-
16136    // git-tag / explicit-path fixture triad the [`Dep`] docstring lists,
16137    // exercising the accessor's accept-set over every author-surface
16138    // `:fonte` shape × every author-surface `:opcional` shape; and by-
16139    // `Copy` idempotency so the projection stays value-return (no
16140    // silent detour to a fresh `&bool` borrow that would introduce a
16141    // lifetime on the return type the plain-`Copy`-scalar axis's `bool`
16142    // shape elides). No composition pin — `:opcional` does not
16143    // participate in [`Dep::validate`] (an opcional dep with any bool
16144    // value is validate-accepted; the missing-source arm is a resolver-
16145    // side runtime dispatch, not a build-time refusal), so the axis
16146    // reduces to the value-shape + `Copy` pin pair the peer
16147    // [`crate::Caixa::max_restarts`] / [`crate::Caixa::estrategia`]
16148    // outer-`Option<Copy>` accessor pins already carry.
16149
16150    #[test]
16151    fn dep_opcional_returns_declared_opcional_across_fonte_shapes() {
16152        // Default-`false` form via the [`Dep::simple`] constructor —
16153        // the accessor projects the `false` bit the default-fill sets.
16154        assert!(!Dep::simple("caixa-teia", "^0.1").opcional());
16155        // Default-`false` form via the [`Dep::git`] constructor — same
16156        // default fill; the accessor projects `false` regardless of the
16157        // `:fonte` arm.
16158        assert!(!Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0").opcional(),);
16159        // Explicit-`true` form × plain-shorthand `:fonte` — the
16160        // canonical author-surface "this dep may be missing" shape.
16161        let plain_true = Dep {
16162            nome: "caixa-teia".to_string(),
16163            versao: "^0.1".to_string(),
16164            fonte: None,
16165            opcional: true,
16166            caracteristicas: Vec::new(),
16167        };
16168        assert!(plain_true.opcional());
16169        // Explicit-`true` form × explicit git-source — the accessor
16170        // projects the bit verbatim regardless of the `:fonte` arm.
16171        let git_true = Dep {
16172            nome: "caixa-teia".to_string(),
16173            versao: "^0.1".to_string(),
16174            fonte: Some(DepSource::Git {
16175                repo: "github:pleme-io/caixa-teia".to_string(),
16176                tag: Some("v0.1.0".to_string()),
16177                rev: None,
16178                branch: None,
16179            }),
16180            opcional: true,
16181            caracteristicas: Vec::new(),
16182        };
16183        assert!(git_true.opcional());
16184        // Explicit-`true` form × explicit path-source — the dev-only
16185        // local-filesystem arm the [`Dep`] docstring's third fixture
16186        // carries.
16187        let path_true = Dep {
16188            nome: "caixa-teia".to_string(),
16189            versao: "0.1.0".to_string(),
16190            fonte: Some(DepSource::Path {
16191                caminho: "../caixa-teia".to_string(),
16192            }),
16193            opcional: true,
16194            caracteristicas: Vec::new(),
16195        };
16196        assert!(path_true.opcional());
16197    }
16198
16199    #[test]
16200    fn dep_opcional_projects_bool_by_copy() {
16201        // The by-`Copy` pin: [`Dep::opcional`] returns `bool` by value
16202        // (`bool: Copy`) — the accessor does not borrow `&self` past
16203        // the call (no lifetime on the return type), and calling the
16204        // accessor twice on the same [`Dep`] must yield discriminant-
16205        // equal values (idempotent, no side effects on `&self`). Peer
16206        // of the sibling outer-`Caixa` `Option<Copy>` by-`Copy`
16207        // `max_restarts_projects_option_by_copy` (eba5211) /
16208        // `estrategia_projects_option_by_copy` (ed04d3c) pins on the
16209        // outer-`Caixa` altitude — extended here to the outer-`Dep`
16210        // altitude's plain-`Copy` `bool` axis. The `Copy` discipline
16211        // replaces the pointer-equality claim the sibling per-`Dep`
16212        // by-borrow pins (`dep_nome_is_by_borrow_pointer_identity`
16213        // eba2cde, `dep_versao_requirement_is_by_borrow_pointer_identity`
16214        // 05529b1, `dep_fonte_is_by_borrow_pointer_identity` d65d1bf,
16215        // `dep_caracteristicas_is_by_borrow_pointer_identity` 9197944)
16216        // carry (a fresh `Copy` of a `Copy` discriminant is definitionally
16217        // the same discriminant, so the axis reduces to discriminant
16218        // equality).
16219        //
16220        // Pins against a future silent detour that returned a fresh
16221        // `&bool` reference (which would type-check but silently
16222        // introduce a borrow of `&self` past the call, collapsing the
16223        // load-bearing "no lifetime on the return type" `Copy`
16224        // projection the plain-`Copy`-scalar axis's `bool` shape
16225        // carries) or a stale-read side effect that flipped the outer
16226        // discriminant on successive calls.
16227        for opcional in [false, true] {
16228            let d = Dep {
16229                nome: "caixa-teia".to_string(),
16230                versao: "^0.1".to_string(),
16231                fonte: None,
16232                opcional,
16233                caracteristicas: Vec::new(),
16234            };
16235            let first = d.opcional();
16236            let second = d.opcional();
16237            assert_eq!(
16238                first, second,
16239                "Dep::opcional must be idempotent — two successive calls \
16240                 on the same &self must return the same bool",
16241            );
16242            assert_eq!(
16243                first, opcional,
16244                "Dep::opcional must return :opcional verbatim by Copy — \
16245                 got {first}, expected {opcional}",
16246            );
16247            assert_eq!(
16248                d.opcional(),
16249                d.opcional,
16250                "Dep::opcional accessor and self.opcional field access \
16251                 must byte-equal — a bit-flip drift would silently split \
16252                 the paired resolver-side drop-vs-error dispatch from \
16253                 the storage-side default-fill the [`Dep::simple`] / \
16254                 [`Dep::git`] constructor pair carries",
16255            );
16256        }
16257    }
16258
16259    // ── DepSource::sole_pin — sole-set git-pin accessor ─────────────────
16260
16261    #[test]
16262    fn sole_pin_returns_none_for_path_source() {
16263        // A path source carries no git-ref, so `sole_pin()` returns
16264        // `None` structurally — the sibling arm every git-fetching
16265        // consumer partitions off before reaching for a git-ref. Pins
16266        // the Path-arm branch of the accessor against a future silent
16267        // detour that treats a `Self::Path` as an unpinned-git source
16268        // and returns the wrong "no pin" signal (e.g. the empty string,
16269        // or a hard-coded `Some("HEAD")` matching the caixa-crd
16270        // path-arm `git_ref` fill).
16271        let s = DepSource::Path {
16272            caminho: "../local-caixa".to_string(),
16273        };
16274        assert_eq!(s.sole_pin(), None);
16275    }
16276
16277    #[test]
16278    fn sole_pin_returns_none_for_unpinned_git_source() {
16279        // The [`DepSource::default_github`] shorthand shape carries no
16280        // pin — every `tag`/`rev`/`branch` is `None`, and `sole_pin()`
16281        // returns `None`. This is the shape caixa-resolver's `fetch_dep`
16282        // materializes when the author omits `:fonte` entirely, then
16283        // hands to `fetch_git` which raises `ResolveError::MissingPin`
16284        // on the `None` arm — the accessor's return matches the arm
16285        // the resolver's diagnostic keys off.
16286        let s = DepSource::default_github("pleme-io", "caixa-teia");
16287        assert_eq!(s.sole_pin(), None);
16288    }
16289
16290    #[test]
16291    fn sole_pin_returns_rev_when_only_rev_is_set() {
16292        let s = DepSource::Git {
16293            repo: "github:o/x".into(),
16294            tag: None,
16295            rev: Some("deadbeefcafebabe1234567890abcdef12345678".into()),
16296            branch: None,
16297        };
16298        assert_eq!(
16299            s.sole_pin(),
16300            Some("deadbeefcafebabe1234567890abcdef12345678")
16301        );
16302    }
16303
16304    #[test]
16305    fn sole_pin_returns_tag_when_only_tag_is_set() {
16306        let s = DepSource::Git {
16307            repo: "github:o/x".into(),
16308            tag: Some("v0.1.0".into()),
16309            rev: None,
16310            branch: None,
16311        };
16312        assert_eq!(s.sole_pin(), Some("v0.1.0"));
16313    }
16314
16315    #[test]
16316    fn sole_pin_returns_branch_when_only_branch_is_set() {
16317        let s = DepSource::Git {
16318            repo: "github:o/x".into(),
16319            tag: None,
16320            rev: None,
16321            branch: Some("main".into()),
16322        };
16323        assert_eq!(s.sole_pin(), Some("main"));
16324    }
16325
16326    #[test]
16327    fn sole_pin_precedence_rev_beats_tag_and_branch() {
16328        // Precedence: rev > tag > branch. Validate() rejects
16329        // multiple-pin shapes, but the accessor's precedence is defined
16330        // for pre-validate consumers (the resolver's `MissingPin`
16331        // diagnostic path, the caixa-crd round-trip's default `"main"`
16332        // fallback) and as defense-in-depth if the gate is ever
16333        // bypassed. Pins the same precedence caixa-resolver's
16334        // `fetch_git` and caixa-crd's `dep_into_ref` already apply
16335        // inline.
16336        let s = DepSource::Git {
16337            repo: "github:o/x".into(),
16338            tag: Some("v1".into()),
16339            rev: Some("deadbeefcafebabe1234567890abcdef12345678".into()),
16340            branch: Some("main".into()),
16341        };
16342        assert_eq!(
16343            s.sole_pin(),
16344            Some("deadbeefcafebabe1234567890abcdef12345678")
16345        );
16346    }
16347
16348    #[test]
16349    fn sole_pin_precedence_tag_beats_branch_when_no_rev() {
16350        let s = DepSource::Git {
16351            repo: "github:o/x".into(),
16352            tag: Some("v1".into()),
16353            rev: None,
16354            branch: Some("main".into()),
16355        };
16356        assert_eq!(s.sole_pin(), Some("v1"));
16357    }
16358
16359    #[test]
16360    fn sole_pin_byte_equals_inline_rev_or_tag_or_branch_cascade() {
16361        // Fail-before-pass-after byte-parity pin: the substrate accessor
16362        // must return byte-identical to the inline
16363        // `rev.as_deref().or(tag.as_deref()).or(branch.as_deref())`
16364        // cascade both caixa-resolver's `fetch_git` and caixa-crd's
16365        // `dep_into_ref` open-coded pre-lift. Trips at caixa-core build
16366        // time if the accessor's precedence silently drifts from the
16367        // consumer-side cascade — the exact drift this lift converges
16368        // to one substrate primitive to close structurally.
16369        //
16370        // Iterates through the 2^3 = 8 combinations of (tag, rev,
16371        // branch) each-either-`None`-or-`Some`, so every arm of the
16372        // precedence cascade lands under the pin. `validate()` refuses
16373        // the 4 multi-pin combinations, but the accessor's return is
16374        // defined on all 8.
16375        let vals = [Some("R".to_string()), None];
16376        for tag in &vals {
16377            for rev in &vals {
16378                for branch in &vals {
16379                    let s = DepSource::Git {
16380                        repo: "github:o/x".into(),
16381                        tag: tag.clone(),
16382                        rev: rev.clone(),
16383                        branch: branch.clone(),
16384                    };
16385                    // The exact inline cascade the two pre-lift
16386                    // consumer sites hand-rolled, byte-for-byte.
16387                    let expected = rev.as_deref().or(tag.as_deref()).or(branch.as_deref());
16388                    assert_eq!(
16389                        s.sole_pin(),
16390                        expected,
16391                        "sole_pin() must byte-equal \
16392                         rev.or(tag).or(branch) for \
16393                         (tag={tag:?}, rev={rev:?}, branch={branch:?}) — \
16394                         a drift would silently split caixa-resolver's \
16395                         fetch_git checkout target from caixa-crd's \
16396                         dep_into_ref git_ref fill",
16397                    );
16398                }
16399            }
16400        }
16401    }
16402
16403    // Fail-before-pass-after pins on the eleven
16404    // [`fonte_caminho_ctors!`]-generated `DepError::fonte_caminho_*`
16405    // constructors folded from the [`DepSource::validate_caminho`]
16406    // wire-up sites. Each pins the generated ctor's output to the
16407    // pre-lift struct-literal on the same `(&str, &str)` fixture, so
16408    // any wrapper-side lowercase / trim / re-order / silent-field-swap
16409    // regression on the two-field `{ nome: nome.to_string(), caminho:
16410    // caminho.to_string() }` construction surfaces here rather than at
16411    // a downstream diagnostic-shape mismatch. Peer of the sibling
16412    // `empty_child_version_ctor_matches_struct_literal_wrap` /
16413    // `contrato_endpoint_empty_ctor_matches_struct_literal_wrap` /
16414    // `entrada_host_invalid_ctor_matches_struct_literal_wrap` /
16415    // `nome_only_ctor_routes_caixa_through_nome_accessor` equivalence
16416    // pins on the peer `SupervisorError` / `AplicacaoError` /
16417    // `LayoutError` / `LimitsError` / `UpgradeError` envelopes.
16418
16419    #[test]
16420    fn fonte_caminho_absolute_ctor_matches_struct_literal_wrap() {
16421        assert_eq!(
16422            DepError::fonte_caminho_absolute("caixa-teia", "/home/me/work/caixa-teia"),
16423            DepError::FonteCaminhoAbsolute {
16424                nome: "caixa-teia".to_string(),
16425                caminho: "/home/me/work/caixa-teia".to_string(),
16426            },
16427            "generated fonte_caminho_absolute ctor must produce byte-equal \
16428             DepError to the open-coded struct-literal wrap on the same \
16429             (&str, &str) fixture",
16430        );
16431    }
16432
16433    #[test]
16434    fn fonte_caminho_tilde_expansion_ctor_matches_struct_literal_wrap() {
16435        assert_eq!(
16436            DepError::fonte_caminho_tilde_expansion("caixa-teia", "~/work/caixa-teia"),
16437            DepError::FonteCaminhoTildeExpansion {
16438                nome: "caixa-teia".to_string(),
16439                caminho: "~/work/caixa-teia".to_string(),
16440            },
16441        );
16442    }
16443
16444    #[test]
16445    fn fonte_caminho_var_expansion_ctor_matches_struct_literal_wrap() {
16446        assert_eq!(
16447            DepError::fonte_caminho_var_expansion("caixa-teia", "$HOME/work/caixa-teia"),
16448            DepError::FonteCaminhoVarExpansion {
16449                nome: "caixa-teia".to_string(),
16450                caminho: "$HOME/work/caixa-teia".to_string(),
16451            },
16452        );
16453    }
16454
16455    #[test]
16456    fn fonte_caminho_leading_whitespace_ctor_matches_struct_literal_wrap() {
16457        assert_eq!(
16458            DepError::fonte_caminho_leading_whitespace("caixa-teia", " ../caixa-teia"),
16459            DepError::FonteCaminhoLeadingWhitespace {
16460                nome: "caixa-teia".to_string(),
16461                caminho: " ../caixa-teia".to_string(),
16462            },
16463        );
16464    }
16465
16466    #[test]
16467    fn fonte_caminho_leading_hyphen_ctor_matches_struct_literal_wrap() {
16468        assert_eq!(
16469            DepError::fonte_caminho_leading_hyphen("caixa-teia", "-rf"),
16470            DepError::FonteCaminhoLeadingHyphen {
16471                nome: "caixa-teia".to_string(),
16472                caminho: "-rf".to_string(),
16473            },
16474        );
16475    }
16476
16477    #[test]
16478    fn fonte_caminho_backslash_ctor_matches_struct_literal_wrap() {
16479        assert_eq!(
16480            DepError::fonte_caminho_backslash("caixa-teia", "..\\caixa-teia"),
16481            DepError::FonteCaminhoBackslash {
16482                nome: "caixa-teia".to_string(),
16483                caminho: "..\\caixa-teia".to_string(),
16484            },
16485        );
16486    }
16487
16488    #[test]
16489    fn fonte_caminho_shell_pipe_ctor_matches_struct_literal_wrap() {
16490        assert_eq!(
16491            DepError::fonte_caminho_shell_pipe("caixa-teia", "../caixa-teia|evil"),
16492            DepError::FonteCaminhoShellPipe {
16493                nome: "caixa-teia".to_string(),
16494                caminho: "../caixa-teia|evil".to_string(),
16495            },
16496        );
16497    }
16498
16499    #[test]
16500    fn fonte_caminho_shell_semicolon_ctor_matches_struct_literal_wrap() {
16501        assert_eq!(
16502            DepError::fonte_caminho_shell_semicolon("caixa-teia", "../caixa-teia;evil"),
16503            DepError::FonteCaminhoShellSemicolon {
16504                nome: "caixa-teia".to_string(),
16505                caminho: "../caixa-teia;evil".to_string(),
16506            },
16507        );
16508    }
16509
16510    #[test]
16511    fn fonte_caminho_shell_background_ctor_matches_struct_literal_wrap() {
16512        assert_eq!(
16513            DepError::fonte_caminho_shell_background("caixa-teia", "../caixa-teia&"),
16514            DepError::FonteCaminhoShellBackground {
16515                nome: "caixa-teia".to_string(),
16516                caminho: "../caixa-teia&".to_string(),
16517            },
16518        );
16519    }
16520
16521    #[test]
16522    fn fonte_caminho_shell_command_substitution_ctor_matches_struct_literal_wrap() {
16523        assert_eq!(
16524            DepError::fonte_caminho_shell_command_substitution(
16525                "caixa-teia",
16526                "../caixa-teia`whoami`",
16527            ),
16528            DepError::FonteCaminhoShellCommandSubstitution {
16529                nome: "caixa-teia".to_string(),
16530                caminho: "../caixa-teia`whoami`".to_string(),
16531            },
16532        );
16533    }
16534
16535    #[test]
16536    fn fonte_caminho_trailing_slash_ctor_matches_struct_literal_wrap() {
16537        assert_eq!(
16538            DepError::fonte_caminho_trailing_slash("caixa-teia", "../caixa-teia/"),
16539            DepError::FonteCaminhoTrailingSlash {
16540                nome: "caixa-teia".to_string(),
16541                caminho: "../caixa-teia/".to_string(),
16542            },
16543        );
16544    }
16545
16546    #[test]
16547    fn fonte_caminho_ctors_route_nome_and_caminho_through_to_string() {
16548        // Cross-axis pin: sweep the two constructor input axes
16549        // (`nome: &str`, `caminho: &str`) through a non-default fixture
16550        // pair against every generated arm in the
16551        // [`fonte_caminho_ctors!`] macro, so any wrapper-side lowercase
16552        // / trim / truncate / re-order on the two-field
16553        // `{ nome, caminho }` construction — or a silent field swap
16554        // between the two axes at codegen time — surfaces here rather
16555        // than at a downstream diagnostic-shape mismatch. Peer of the
16556        // sibling `supervisor_caixa_only_ctors_route_caixa_through_
16557        // to_string` cross-axis routing pin on the peer
16558        // `SupervisorError` envelope, extended here onto the
16559        // `DepError` `{ nome: String, caminho: String }` envelope so
16560        // every substrate-primitive ctor family in caixa-core
16561        // guarantees each `&str`-field construction routes the
16562        // caller's `&str` verbatim through `.to_string()`.
16563        let nome = "sibling-teia";
16564        let caminho = "../workspace/sibling";
16565        let cases: [(DepError, DepError); 11] = [
16566            (
16567                DepError::fonte_caminho_absolute(nome, caminho),
16568                DepError::FonteCaminhoAbsolute {
16569                    nome: nome.to_string(),
16570                    caminho: caminho.to_string(),
16571                },
16572            ),
16573            (
16574                DepError::fonte_caminho_tilde_expansion(nome, caminho),
16575                DepError::FonteCaminhoTildeExpansion {
16576                    nome: nome.to_string(),
16577                    caminho: caminho.to_string(),
16578                },
16579            ),
16580            (
16581                DepError::fonte_caminho_var_expansion(nome, caminho),
16582                DepError::FonteCaminhoVarExpansion {
16583                    nome: nome.to_string(),
16584                    caminho: caminho.to_string(),
16585                },
16586            ),
16587            (
16588                DepError::fonte_caminho_leading_whitespace(nome, caminho),
16589                DepError::FonteCaminhoLeadingWhitespace {
16590                    nome: nome.to_string(),
16591                    caminho: caminho.to_string(),
16592                },
16593            ),
16594            (
16595                DepError::fonte_caminho_leading_hyphen(nome, caminho),
16596                DepError::FonteCaminhoLeadingHyphen {
16597                    nome: nome.to_string(),
16598                    caminho: caminho.to_string(),
16599                },
16600            ),
16601            (
16602                DepError::fonte_caminho_backslash(nome, caminho),
16603                DepError::FonteCaminhoBackslash {
16604                    nome: nome.to_string(),
16605                    caminho: caminho.to_string(),
16606                },
16607            ),
16608            (
16609                DepError::fonte_caminho_shell_pipe(nome, caminho),
16610                DepError::FonteCaminhoShellPipe {
16611                    nome: nome.to_string(),
16612                    caminho: caminho.to_string(),
16613                },
16614            ),
16615            (
16616                DepError::fonte_caminho_shell_semicolon(nome, caminho),
16617                DepError::FonteCaminhoShellSemicolon {
16618                    nome: nome.to_string(),
16619                    caminho: caminho.to_string(),
16620                },
16621            ),
16622            (
16623                DepError::fonte_caminho_shell_background(nome, caminho),
16624                DepError::FonteCaminhoShellBackground {
16625                    nome: nome.to_string(),
16626                    caminho: caminho.to_string(),
16627                },
16628            ),
16629            (
16630                DepError::fonte_caminho_shell_command_substitution(nome, caminho),
16631                DepError::FonteCaminhoShellCommandSubstitution {
16632                    nome: nome.to_string(),
16633                    caminho: caminho.to_string(),
16634                },
16635            ),
16636            (
16637                DepError::fonte_caminho_trailing_slash(nome, caminho),
16638                DepError::FonteCaminhoTrailingSlash {
16639                    nome: nome.to_string(),
16640                    caminho: caminho.to_string(),
16641                },
16642            ),
16643        ];
16644        for (via_ctor, via_struct_literal) in cases {
16645            assert_eq!(
16646                via_ctor, via_struct_literal,
16647                "fonte_caminho_ctors!-generated ctor must route (nome, caminho) \
16648                 through `.to_string()` in declared field order — a field-swap or \
16649                 silent-conversion regression surfaces here rather than at a \
16650                 downstream diagnostic-shape mismatch",
16651            );
16652        }
16653    }
16654
16655    // ── `dep_nome_only_ctors!` — the paired `{ nome: String }` single-slot
16656    //    envelope on `DepError`, sibling of the peer `fonte_caminho_ctors!`
16657    //    (f85f145) on the `{ nome, caminho }` two-slot envelope of the same
16658    //    enum, and of `supervisor_caixa_only_ctors!` (db09650) on the peer
16659    //    `SupervisorError` envelope's `{ caixa: String }` single-slot axis.
16660
16661    #[test]
16662    fn versao_empty_ctor_matches_struct_literal_wrap() {
16663        assert_eq!(
16664            DepError::versao_empty("caixa-teia"),
16665            DepError::VersaoEmpty {
16666                nome: "caixa-teia".to_string(),
16667            },
16668        );
16669    }
16670
16671    #[test]
16672    fn fonte_repo_empty_ctor_matches_struct_literal_wrap() {
16673        assert_eq!(
16674            DepError::fonte_repo_empty("caixa-teia"),
16675            DepError::FonteRepoEmpty {
16676                nome: "caixa-teia".to_string(),
16677            },
16678        );
16679    }
16680
16681    #[test]
16682    fn fonte_pin_missing_ctor_matches_struct_literal_wrap() {
16683        assert_eq!(
16684            DepError::fonte_pin_missing("caixa-teia"),
16685            DepError::FontePinMissing {
16686                nome: "caixa-teia".to_string(),
16687            },
16688        );
16689    }
16690
16691    #[test]
16692    fn fonte_caminho_empty_ctor_matches_struct_literal_wrap() {
16693        assert_eq!(
16694            DepError::fonte_caminho_empty("caixa-teia"),
16695            DepError::FonteCaminhoEmpty {
16696                nome: "caixa-teia".to_string(),
16697            },
16698        );
16699    }
16700
16701    #[test]
16702    fn caracteristica_empty_ctor_matches_struct_literal_wrap() {
16703        assert_eq!(
16704            DepError::caracteristica_empty("caixa-teia"),
16705            DepError::CaracteristicaEmpty {
16706                nome: "caixa-teia".to_string(),
16707            },
16708        );
16709    }
16710
16711    #[test]
16712    fn dep_nome_only_ctors_route_nome_through_to_string() {
16713        // Cross-axis routing pin: sweep the single constructor input
16714        // axis (`nome: &str`) through a non-default fixture against
16715        // every generated arm in the [`dep_nome_only_ctors!`] macro, so
16716        // any wrapper-side lowercase / trim / truncate at codegen time
16717        // — or a silent field re-name away from the canonical `nome`
16718        // axis on any one variant — surfaces here rather than at a
16719        // downstream diagnostic-shape mismatch. Peer of the sibling
16720        // `fonte_caminho_ctors_route_nome_and_caminho_through_
16721        // to_string` cross-axis routing pin on the same envelope's
16722        // two-slot family (f85f145) and of the peer
16723        // `supervisor_caixa_only_ctors_route_caixa_through_to_string`
16724        // pin on the `SupervisorError` single-slot family (db09650).
16725        let nome = "sibling-teia";
16726        let cases: [(DepError, DepError); 5] = [
16727            (
16728                DepError::versao_empty(nome),
16729                DepError::VersaoEmpty {
16730                    nome: nome.to_string(),
16731                },
16732            ),
16733            (
16734                DepError::fonte_repo_empty(nome),
16735                DepError::FonteRepoEmpty {
16736                    nome: nome.to_string(),
16737                },
16738            ),
16739            (
16740                DepError::fonte_pin_missing(nome),
16741                DepError::FontePinMissing {
16742                    nome: nome.to_string(),
16743                },
16744            ),
16745            (
16746                DepError::fonte_caminho_empty(nome),
16747                DepError::FonteCaminhoEmpty {
16748                    nome: nome.to_string(),
16749                },
16750            ),
16751            (
16752                DepError::caracteristica_empty(nome),
16753                DepError::CaracteristicaEmpty {
16754                    nome: nome.to_string(),
16755                },
16756            ),
16757        ];
16758        for (via_ctor, via_struct_literal) in cases {
16759            assert_eq!(
16760                via_ctor, via_struct_literal,
16761                "dep_nome_only_ctors!-generated ctor must route `nome` \
16762                 through `.to_string()` onto the canonical `nome` field \
16763                 — a field-rename or silent-conversion regression surfaces \
16764                 here rather than at a downstream diagnostic-shape mismatch",
16765            );
16766        }
16767    }
16768
16769    // ── `dep_nome_list_ctors!` — the paired `{ nome: String, list:
16770    //    &'static str }` two-slot envelope on `DepError`, strict
16771    //    sibling of the peer `dep_nome_only_ctors!` (792aa92) on the
16772    //    same envelope's `{ nome: String }` one-slot shape and of the
16773    //    peer `supervisor_caixa_only_ctors!` (db09650) on the
16774    //    `SupervisorError` envelope's `{ caixa: String }` one-slot axis.
16775
16776    #[test]
16777    fn duplicate_nome_ctor_matches_struct_literal_wrap() {
16778        assert_eq!(
16779            DepError::duplicate_nome("caixa-teia", crate::render::DEP_AUTHOR_KEY_DEPS),
16780            DepError::DuplicateNome {
16781                nome: "caixa-teia".to_string(),
16782                list: crate::render::DEP_AUTHOR_KEY_DEPS,
16783            },
16784            "generated duplicate_nome ctor must produce byte-equal \
16785             `DepError::DuplicateNome` to the pre-lift struct-literal \
16786             wrap on the same scalar fixtures",
16787        );
16788    }
16789
16790    #[test]
16791    fn dep_is_self_ctor_matches_struct_literal_wrap() {
16792        assert_eq!(
16793            DepError::dep_is_self("orquestra", crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
16794            DepError::DepIsSelf {
16795                nome: "orquestra".to_string(),
16796                list: crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
16797            },
16798            "generated dep_is_self ctor must produce byte-equal \
16799             `DepError::DepIsSelf` to the pre-lift struct-literal \
16800             wrap on the same scalar fixtures",
16801        );
16802    }
16803
16804    #[test]
16805    fn dep_nome_list_ctors_route_nome_and_list_through_uniformly() {
16806        // Cross-axis routing pin: sweep the two constructor input axes
16807        // (`nome: &str`, `list: &'static str`) through non-default
16808        // fixtures against every generated arm in the
16809        // [`dep_nome_list_ctors!`] macro, so any wrapper-side
16810        // lowercase / trim / truncate at codegen time — or a silent
16811        // field re-name away from the canonical `nome` / `list` axes
16812        // on any one variant, or a `list` axis silently rerouted
16813        // through `.to_string()` instead of passed as `&'static str`
16814        // verbatim — surfaces here rather than at a downstream
16815        // diagnostic-shape mismatch. Peer of the sibling
16816        // `dep_nome_only_ctors_route_nome_through_to_string` pin
16817        // (792aa92) on the same envelope's one-slot family, and of the
16818        // peer
16819        // `supervisor_child_reason_ctors_route_reason_through_into_uniformly`
16820        // pin (d2ef2ec) on the sibling `SupervisorError` envelope's
16821        // two-slot `{ caixa: String, reason: String }` shape.
16822        let nome = "sibling-teia";
16823        let cases: [(DepError, DepError); 4] = [
16824            (
16825                DepError::duplicate_nome(nome, crate::render::DEP_AUTHOR_KEY_DEPS),
16826                DepError::DuplicateNome {
16827                    nome: nome.to_string(),
16828                    list: crate::render::DEP_AUTHOR_KEY_DEPS,
16829                },
16830            ),
16831            (
16832                DepError::duplicate_nome(nome, crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
16833                DepError::DuplicateNome {
16834                    nome: nome.to_string(),
16835                    list: crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
16836                },
16837            ),
16838            (
16839                DepError::dep_is_self(nome, crate::render::DEP_AUTHOR_KEY_DEPS),
16840                DepError::DepIsSelf {
16841                    nome: nome.to_string(),
16842                    list: crate::render::DEP_AUTHOR_KEY_DEPS,
16843                },
16844            ),
16845            (
16846                DepError::dep_is_self(nome, crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
16847                DepError::DepIsSelf {
16848                    nome: nome.to_string(),
16849                    list: crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
16850                },
16851            ),
16852        ];
16853        for (via_ctor, via_struct_literal) in cases {
16854            assert_eq!(
16855                via_ctor, via_struct_literal,
16856                "dep_nome_list_ctors!-generated ctor must route `nome` \
16857                 through `.to_string()` onto the canonical `nome` field \
16858                 and pass `list` verbatim onto the canonical `&'static str` \
16859                 `list` field — a field-rename, silent-conversion, or \
16860                 axis-swap regression surfaces here rather than at a \
16861                 downstream diagnostic-shape mismatch",
16862            );
16863        }
16864    }
16865
16866    // ── `fonte_pin_shape` — the paired `{ nome: String, pin: String,
16867    //    value: String, reason: String }` four-slot envelope on
16868    //    `DepError`, sibling of the peer `dep_nome_only_ctors!` (792aa92),
16869    //    `dep_nome_list_ctors!` (6f5e0cd), `fonte_caminho_ctors!` (f85f145),
16870    //    and `fonte_caminho_byte_ctors!` (0e35793) folds on the same
16871    //    envelope, and of the peer `contrato_pair_value_reason_ctors!`
16872    //    (14e13f1) four-slot fold on the sibling `AplicacaoError`
16873    //    envelope. Single-variant lift closing the last open-coded ctor
16874    //    site on the `:fonte (:tipo git …)` value-shape trajectory.
16875
16876    #[test]
16877    fn fonte_pin_shape_ctor_matches_struct_literal_wrap() {
16878        // Pre-lift equivalence pin on the [`DepError::fonte_pin_shape`]
16879        // ctor: sweep both wire-up-shape arms (the refname-pin arm
16880        // routing `":tag"` / `":branch"` value through
16881        // [`crate::render::is_git_ref_name`], and the hex-OID-pin arm
16882        // routing `":rev"` through [`crate::render::is_git_oid`]) and
16883        // assert byte-equal `PartialEq` against the pre-lift
16884        // struct-literal, so any wrapper-side field-rename /
16885        // silent-conversion regression surfaces here rather than at a
16886        // downstream diagnostic-shape mismatch. Peer of the sibling
16887        // per-envelope byte-equal ctor pins
16888        // ([`fonte_pin_missing_ctor_matches_struct_literal_wrap`],
16889        // [`duplicate_nome_ctor_matches_struct_literal_wrap`],
16890        // [`dep_is_self_ctor_matches_struct_literal_wrap`]).
16891        assert_eq!(
16892            DepError::fonte_pin_shape(
16893                "caixa-teia",
16894                ":tag",
16895                "v0.1.0 ",
16896                "trailing whitespace".to_string(),
16897            ),
16898            DepError::FontePinShape {
16899                nome: "caixa-teia".to_string(),
16900                pin: ":tag".to_string(),
16901                value: "v0.1.0 ".to_string(),
16902                reason: "trailing whitespace".to_string(),
16903            },
16904            "fonte_pin_shape ctor must produce byte-equal \
16905             `DepError::FontePinShape` to the pre-lift struct-literal \
16906             wrap on a refname-pin (`:tag` / `:branch`) fixture",
16907        );
16908        assert_eq!(
16909            DepError::fonte_pin_shape(
16910                "caixa-teia",
16911                ":rev",
16912                "DEADBEEF",
16913                "abbreviated OID rejected".to_string(),
16914            ),
16915            DepError::FontePinShape {
16916                nome: "caixa-teia".to_string(),
16917                pin: ":rev".to_string(),
16918                value: "DEADBEEF".to_string(),
16919                reason: "abbreviated OID rejected".to_string(),
16920            },
16921            "fonte_pin_shape ctor must produce byte-equal \
16922             `DepError::FontePinShape` to the pre-lift struct-literal \
16923             wrap on a hex-OID-pin (`:rev`) fixture",
16924        );
16925    }
16926
16927    #[test]
16928    fn fonte_pin_shape_ctor_routes_all_four_axes_through_to_string() {
16929        // Cross-axis routing pin: sweep every one of the four
16930        // constructor input axes (`nome: &str`, `pin: &str`,
16931        // `value: &str`, `reason: String`) through non-default
16932        // fixtures against the [`DepError::fonte_pin_shape`] ctor, so
16933        // any wrapper-side lowercase / trim / truncate at codegen time
16934        // — or a silent field re-name / axis-swap on any one of the
16935        // four fields, or a `reason` axis silently routed through
16936        // `.to_string()` instead of forwarded owned — surfaces here
16937        // rather than at a downstream diagnostic-shape mismatch. Peer
16938        // of the sibling
16939        // `dep_nome_only_ctors_route_nome_through_to_string` pin
16940        // (792aa92) and
16941        // `dep_nome_list_ctors_route_nome_and_list_through_uniformly`
16942        // pin (6f5e0cd) on the same envelope's one- and two-slot
16943        // families. Distinct-per-axis fixtures rule out any two-axis
16944        // swap (`nome` ↔ `pin`, `pin` ↔ `value`, `value` ↔ `reason`,
16945        // etc.) that would still pass a same-fixture-per-axis pin.
16946        let nome = "sibling-teia";
16947        let pin = ":branch";
16948        let value = "feature/bar";
16949        let reason = "embedded space".to_string();
16950        let via_ctor = DepError::fonte_pin_shape(nome, pin, value, reason.clone());
16951        let via_struct_literal = DepError::FontePinShape {
16952            nome: nome.to_string(),
16953            pin: pin.to_string(),
16954            value: value.to_string(),
16955            reason: reason.clone(),
16956        };
16957        assert_eq!(
16958            via_ctor, via_struct_literal,
16959            "fonte_pin_shape ctor must route `nome` / `pin` / `value` \
16960             through `.to_string()` onto their canonical fields and \
16961             forward `reason` owned onto the canonical `reason` field \
16962             — a field-rename, silent-conversion, or axis-swap \
16963             regression surfaces here rather than at a downstream \
16964             diagnostic-shape mismatch",
16965        );
16966        let DepError::FontePinShape {
16967            nome: n,
16968            pin: p,
16969            value: v,
16970            reason: r,
16971        } = via_ctor
16972        else {
16973            panic!("fonte_pin_shape ctor produced non-FontePinShape variant")
16974        };
16975        assert_eq!(n, nome);
16976        assert_eq!(p, pin);
16977        assert_eq!(v, value);
16978        assert_eq!(r, reason);
16979    }
16980
16981    // ── `fonte_caminho_byte_ctors!` — the paired `{ nome: String,
16982    //    caminho: String, byte: u8 }` three-slot envelope on `DepError`,
16983    //    strict sibling of the peer `fonte_caminho_ctors!` (f85f145) on
16984    //    the same envelope's `{ nome: String, caminho: String }` two-slot
16985    //    shape, and of the peer `dep_nome_only_ctors!` (792aa92) on the
16986    //    same envelope's `{ nome: String }` one-slot shape.
16987
16988    #[test]
16989    fn fonte_caminho_control_char_ctor_matches_struct_literal_wrap() {
16990        assert_eq!(
16991            DepError::fonte_caminho_control_char("caixa-teia", "../caixa-teia\x00foo", 0x00),
16992            DepError::FonteCaminhoControlChar {
16993                nome: "caixa-teia".to_string(),
16994                caminho: "../caixa-teia\x00foo".to_string(),
16995                byte: 0x00,
16996            },
16997        );
16998    }
16999
17000    #[test]
17001    fn fonte_caminho_shell_redirection_ctor_matches_struct_literal_wrap() {
17002        assert_eq!(
17003            DepError::fonte_caminho_shell_redirection("caixa-teia", "../caixa-teia>log", b'>'),
17004            DepError::FonteCaminhoShellRedirection {
17005                nome: "caixa-teia".to_string(),
17006                caminho: "../caixa-teia>log".to_string(),
17007                byte: b'>',
17008            },
17009        );
17010    }
17011
17012    #[test]
17013    #[allow(
17014        clippy::too_many_lines,
17015        reason = "cross-axis routing pin sweeps twelve typed variants, one per \
17016                  byte-classification arm on the {nome,caminho,byte} envelope; \
17017                  the linear per-variant repetition is exactly what the sweep \
17018                  is pinning — a helper macro would hide the shape the fold is \
17019                  keying on"
17020    )]
17021    fn fonte_caminho_byte_ctors_route_nome_caminho_and_byte_through_to_string() {
17022        // Cross-axis routing pin: sweep the three constructor input axes
17023        // (`nome: &str`, `caminho: &str`, `byte: u8`) through a
17024        // non-default fixture triple against every generated arm in the
17025        // [`fonte_caminho_byte_ctors!`] macro, so any wrapper-side
17026        // lowercase / trim / truncate on the two `&str` axes — a silent
17027        // field swap between `nome` and `caminho`, or a silent
17028        // re-classification of the offending byte — surfaces here rather
17029        // than at a downstream diagnostic-shape mismatch. Peer of the
17030        // sibling `fonte_caminho_ctors_route_nome_and_caminho_through_
17031        // to_string` cross-axis routing pin on the same envelope's
17032        // two-slot family (f85f145) and of the sibling
17033        // `dep_nome_only_ctors_route_nome_through_to_string` pin on the
17034        // same envelope's one-slot family (792aa92), extended here onto
17035        // the `{ nome: String, caminho: String, byte: u8 }` three-slot
17036        // envelope so every substrate-primitive ctor family in
17037        // caixa-core's `DepError` envelope guarantees each field routes
17038        // the caller's value verbatim through `.to_string()` (or byte-
17039        // identity for `byte: u8`) in declared field order.
17040        let nome = "sibling-teia";
17041        let caminho = "../workspace/sibling";
17042        let byte = 0x2A_u8;
17043        let cases: [(DepError, DepError); 12] = [
17044            (
17045                DepError::fonte_caminho_control_char(nome, caminho, byte),
17046                DepError::FonteCaminhoControlChar {
17047                    nome: nome.to_string(),
17048                    caminho: caminho.to_string(),
17049                    byte,
17050                },
17051            ),
17052            (
17053                DepError::fonte_caminho_shell_redirection(nome, caminho, byte),
17054                DepError::FonteCaminhoShellRedirection {
17055                    nome: nome.to_string(),
17056                    caminho: caminho.to_string(),
17057                    byte,
17058                },
17059            ),
17060            (
17061                DepError::fonte_caminho_shell_glob(nome, caminho, byte),
17062                DepError::FonteCaminhoShellGlob {
17063                    nome: nome.to_string(),
17064                    caminho: caminho.to_string(),
17065                    byte,
17066                },
17067            ),
17068            (
17069                DepError::fonte_caminho_shell_subshell_grouping(nome, caminho, byte),
17070                DepError::FonteCaminhoShellSubshellGrouping {
17071                    nome: nome.to_string(),
17072                    caminho: caminho.to_string(),
17073                    byte,
17074                },
17075            ),
17076            (
17077                DepError::fonte_caminho_shell_brace_expansion(nome, caminho, byte),
17078                DepError::FonteCaminhoShellBraceExpansion {
17079                    nome: nome.to_string(),
17080                    caminho: caminho.to_string(),
17081                    byte,
17082                },
17083            ),
17084            (
17085                DepError::fonte_caminho_shell_bracket_expansion(nome, caminho, byte),
17086                DepError::FonteCaminhoShellBracketExpansion {
17087                    nome: nome.to_string(),
17088                    caminho: caminho.to_string(),
17089                    byte,
17090                },
17091            ),
17092            (
17093                DepError::fonte_caminho_shell_quote_grouping(nome, caminho, byte),
17094                DepError::FonteCaminhoShellQuoteGrouping {
17095                    nome: nome.to_string(),
17096                    caminho: caminho.to_string(),
17097                    byte,
17098                },
17099            ),
17100            (
17101                DepError::fonte_caminho_shell_comment(nome, caminho, byte),
17102                DepError::FonteCaminhoShellComment {
17103                    nome: nome.to_string(),
17104                    caminho: caminho.to_string(),
17105                    byte,
17106                },
17107            ),
17108            (
17109                DepError::fonte_caminho_url_percent_encoding(nome, caminho, byte),
17110                DepError::FonteCaminhoUrlPercentEncoding {
17111                    nome: nome.to_string(),
17112                    caminho: caminho.to_string(),
17113                    byte,
17114                },
17115            ),
17116            (
17117                DepError::fonte_caminho_shell_variable_expansion(nome, caminho, byte),
17118                DepError::FonteCaminhoShellVariableExpansion {
17119                    nome: nome.to_string(),
17120                    caminho: caminho.to_string(),
17121                    byte,
17122                },
17123            ),
17124            (
17125                DepError::fonte_caminho_shell_history_expansion(nome, caminho, byte),
17126                DepError::FonteCaminhoShellHistoryExpansion {
17127                    nome: nome.to_string(),
17128                    caminho: caminho.to_string(),
17129                    byte,
17130                },
17131            ),
17132            (
17133                DepError::fonte_caminho_shell_history_substitution(nome, caminho, byte),
17134                DepError::FonteCaminhoShellHistorySubstitution {
17135                    nome: nome.to_string(),
17136                    caminho: caminho.to_string(),
17137                    byte,
17138                },
17139            ),
17140        ];
17141        for (via_ctor, via_struct_literal) in cases {
17142            assert_eq!(
17143                via_ctor, via_struct_literal,
17144                "fonte_caminho_byte_ctors!-generated ctor must route \
17145                 (nome, caminho, byte) through `.to_string()` / byte-\
17146                 identity in declared field order — a field-swap or \
17147                 silent-conversion regression surfaces here rather than \
17148                 at a downstream diagnostic-shape mismatch",
17149            );
17150        }
17151    }
17152}
17153
17154#[cfg(test)]
17155mod dep_source_is_variant_tests {
17156    use super::*;
17157
17158    fn all_variants() -> Vec<(DepSource, &'static str)> {
17159        vec![
17160            (
17161                DepSource::Git {
17162                    repo: "github:pleme-io/caixa-teia".into(),
17163                    tag: Some("v0.1.0".into()),
17164                    rev: None,
17165                    branch: None,
17166                },
17167                "Git",
17168            ),
17169            (
17170                DepSource::Path {
17171                    caminho: "../caixa-teia".into(),
17172                },
17173                "Path",
17174            ),
17175        ]
17176    }
17177
17178    fn predicate_row(s: &DepSource) -> [bool; 2] {
17179        [s.is_git(), s.is_path()]
17180    }
17181
17182    // Fail-before-pass-after pin on the [`gen_platform::IsVariant`]
17183    // derive-generated per-arm predicate partition — for every variant
17184    // in `all_variants()`, the observed 2-slot predicate row must equal
17185    // a one-hot row with the `true` at exactly the same index as the
17186    // variant's declaration order. Expected rows are generated live
17187    // from the enumeration rather than transcribed by hand, so a
17188    // copy-paste flip that reroutes one arm through the wrong predicate
17189    // lane trips at the identity-diagonal assertion the way every peer
17190    // sibling [`DepList`] / [`crate::CaixaKind`] / [`crate::CaixaDialeto`]
17191    // / [`crate::supervisor::RestartStrategy`] / [`crate::supervisor::RestartPolicy`]
17192    // / [`crate::upgrade::UpgradeInstruction`] /
17193    // [`crate::aplicacao::PlacementStrategy`] /
17194    // [`crate::aplicacao::RateLimitUnit`] /
17195    // [`crate::aplicacao::WitTarget`] /
17196    // [`crate::render::PathShapeViolation`] partition pin already does.
17197    #[test]
17198    fn dep_source_is_variant_predicates_partition_the_arm_set() {
17199        let variants = all_variants();
17200        for (idx, (variant, name)) in variants.iter().enumerate() {
17201            let observed = predicate_row(variant);
17202            let mut expected = [false; 2];
17203            expected[idx] = true;
17204            assert_eq!(
17205                observed, expected,
17206                "DepSource::{name} at declaration-order slot {idx} must \
17207                 satisfy exactly one is_* predicate (its own); observed \
17208                 row must equal the one-hot expected row — a drift \
17209                 would silently reroute one `:fonte`-arm consumer \
17210                 through the wrong predicate lane"
17211            );
17212        }
17213    }
17214
17215    // Byte-parity pin on the two field-agnostic `matches!` shapes the
17216    // per-arm arm-discriminator predicates replace at any future
17217    // consumer site (a `:fonte`-shape-only lint rule that flags path
17218    // deps outside dev-caixas via `dep.fonte().is_some_and(DepSource::is_path)`,
17219    // a future admission-webhook that rejects `:fonte` shapes outside
17220    // the `is_git()` accept-set, a caixa-lacre indexing pass that
17221    // dispatches on `s.is_git()` without extracting `repo` / `caminho`).
17222    // Refuses a future accidental split between the derived predicate
17223    // and its `matches!` shape — a hand-rolled shadow impl that
17224    // overrides one path, an accidental rebrand that leaves one
17225    // consumer on the raw `matches!` form — on the two load-bearing
17226    // `:fonte`-arm-discriminator axes every downstream substrate
17227    // consumer of the dep-source axis keys off.
17228    #[test]
17229    fn dep_source_is_git_and_is_path_byte_equal_matches_shape() {
17230        for (variant, name) in all_variants() {
17231            let via_matches_git = matches!(variant, DepSource::Git { .. });
17232            let via_predicate_git = variant.is_git();
17233            assert_eq!(
17234                via_predicate_git, via_matches_git,
17235                "DepSource::{name}.is_git() must byte-equal \
17236                 matches!(_, DepSource::Git {{ .. }}) — otherwise a \
17237                 future converged consumer site would silently \
17238                 disagree with its pre-lift shape"
17239            );
17240            let via_matches_path = matches!(variant, DepSource::Path { .. });
17241            let via_predicate_path = variant.is_path();
17242            assert_eq!(
17243                via_predicate_path, via_matches_path,
17244                "DepSource::{name}.is_path() must byte-equal \
17245                 matches!(_, DepSource::Path {{ .. }}) — otherwise a \
17246                 future converged consumer site would silently \
17247                 disagree with its pre-lift shape"
17248            );
17249        }
17250    }
17251
17252    // Cross-pin against every constructor path that materializes a
17253    // [`DepSource`] shape today (the [`DepSource::default_github`]
17254    // resolver-side fallback that materializes an unpinned
17255    // `github:<org>/<nome>` git shorthand, the [`Dep::git`] author-
17256    // surface constructor that materializes a pinned `:tag`-carrying
17257    // `DepSource::Git`, a hand-rolled `DepSource::Path` the dev-mode
17258    // fixture family builds inline). Every constructor's return must
17259    // satisfy the arm-discriminator predicate the constructor's
17260    // variant name matches — a future constructor addition (an
17261    // in-tree registry-fetch pin, a `DepSource::Feira` variant the
17262    // enclosing docstring already names as a trajectory item) surfaces
17263    // as a build-time failure that names the offending drift when its
17264    // return arm doesn't route through the paired predicate.
17265    #[test]
17266    fn dep_source_constructors_route_through_paired_is_variant_predicate() {
17267        let via_default_github = DepSource::default_github("pleme-io", "caixa-teia");
17268        assert!(
17269            via_default_github.is_git(),
17270            "DepSource::default_github must materialize a Git-arm shape — \
17271             a future constructor that routed through a non-Git arm \
17272             (a registry-fetch pin, a `DepSource::Feira` promotion) \
17273             would silently split the resolver's unpinned-shorthand \
17274             materializer from the sole_pin() precedence cascade"
17275        );
17276        assert!(
17277            !via_default_github.is_path(),
17278            "DepSource::default_github must NOT materialize a Path-arm \
17279             shape — the paired negation pin"
17280        );
17281
17282        let via_dep_git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0")
17283            .fonte
17284            .expect("Dep::git materializes a Some(fonte)");
17285        assert!(
17286            via_dep_git.is_git(),
17287            "Dep::git's `:fonte` materialization must land on the Git \
17288             arm — the author-surface pinned-git constructor's return \
17289             must route through the paired predicate"
17290        );
17291        assert!(!via_dep_git.is_path(), "paired negation pin");
17292
17293        let via_path = DepSource::Path {
17294            caminho: "../caixa-teia".into(),
17295        };
17296        assert!(
17297            via_path.is_path(),
17298            "the dev-mode Path-arm materialization must satisfy is_path()"
17299        );
17300        assert!(!via_path.is_git(), "paired negation pin");
17301    }
17302
17303    // ── `dep_nome_axis_reason_ctors!` — the `{ nome: String, <axis>:
17304    //    String, reason: String }` three-slot envelope on `DepError`,
17305    //    strict sibling of the peer `dep_nome_only_ctors!` (792aa92) on
17306    //    the one-slot `{ nome }` envelope, `dep_nome_list_ctors!`
17307    //    (6f5e0cd) on the two-slot `{ nome, list: &'static str }`
17308    //    envelope, `fonte_caminho_ctors!` (f85f145) on the two-slot
17309    //    `{ nome, caminho }` envelope, and `fonte_caminho_byte_ctors!`
17310    //    (0e35793) on the three-slot `{ nome, caminho, byte }` envelope.
17311
17312    #[test]
17313    fn versao_invalid_ctor_matches_struct_literal_wrap() {
17314        assert_eq!(
17315            DepError::versao_invalid("caixa-teia", "^0..1", "invalid comparator".to_string()),
17316            DepError::VersaoInvalid {
17317                nome: "caixa-teia".to_string(),
17318                versao: "^0..1".to_string(),
17319                reason: "invalid comparator".to_string(),
17320            },
17321            "versao_invalid ctor must produce byte-equal \
17322             `DepError::VersaoInvalid` to the pre-lift struct-literal wrap",
17323        );
17324    }
17325
17326    #[test]
17327    fn fonte_repo_shape_ctor_matches_struct_literal_wrap() {
17328        assert_eq!(
17329            DepError::fonte_repo_shape(
17330                "caixa-teia",
17331                "-upload-pack=evil",
17332                "leading dash rejected".to_string(),
17333            ),
17334            DepError::FonteRepoShape {
17335                nome: "caixa-teia".to_string(),
17336                repo: "-upload-pack=evil".to_string(),
17337                reason: "leading dash rejected".to_string(),
17338            },
17339            "fonte_repo_shape ctor must produce byte-equal \
17340             `DepError::FonteRepoShape` to the pre-lift struct-literal wrap",
17341        );
17342    }
17343
17344    #[test]
17345    fn caracteristica_invalid_ctor_matches_struct_literal_wrap() {
17346        assert_eq!(
17347            DepError::caracteristica_invalid(
17348                "caixa-teia",
17349                "bad feature!",
17350                "embedded space rejected".to_string(),
17351            ),
17352            DepError::CaracteristicaInvalid {
17353                nome: "caixa-teia".to_string(),
17354                caracteristica: "bad feature!".to_string(),
17355                reason: "embedded space rejected".to_string(),
17356            },
17357            "caracteristica_invalid ctor must produce byte-equal \
17358             `DepError::CaracteristicaInvalid` to the pre-lift struct-literal wrap",
17359        );
17360    }
17361
17362    #[test]
17363    fn dep_nome_axis_reason_ctors_route_nome_axis_and_reason_through_uniformly() {
17364        // Cross-axis routing pin: sweep the three constructor input axes
17365        // (`nome: &str`, `<axis>: &str`, `reason: String`) through
17366        // distinct-per-axis fixtures against every generated arm in the
17367        // [`dep_nome_axis_reason_ctors!`] macro, so any wrapper-side
17368        // lowercase / trim / truncate on the two `&str` axes — a silent
17369        // field swap between `nome`, the middle `<axis>` field, and
17370        // `reason`, or a `reason` axis silently rerouted through
17371        // `.to_string()` instead of forwarded owned — surfaces here rather
17372        // than at a downstream diagnostic-shape mismatch. Peer of the
17373        // sibling `fonte_caminho_byte_ctors_route_nome_caminho_and_byte_
17374        // through_to_string` (0e35793) cross-axis routing pin on the same
17375        // envelope's `{ nome, caminho, byte }` three-slot family and of
17376        // the peer `dep_nome_list_ctors_route_nome_and_list_through_
17377        // uniformly` (6f5e0cd) pin on the same envelope's two-slot family
17378        // — extended here onto the `{ nome, <axis>: String, reason:
17379        // String }` three-slot envelope so every substrate-primitive ctor
17380        // family in caixa-core's `DepError` envelope guarantees each field
17381        // routes the caller's value verbatim through `.to_string()` (or
17382        // owned-forward for `reason: String`) in declared field order.
17383        // Distinct-per-axis fixtures rule out any two-axis swap
17384        // (`nome` ↔ `<axis>`, `<axis>` ↔ `reason`) that would still pass a
17385        // same-fixture-per-axis pin.
17386        let nome = "sibling-teia";
17387        let axis = "distinct-axis-value";
17388        let reason = "distinct rejection sentence".to_string();
17389        assert_eq!(
17390            DepError::versao_invalid(nome, axis, reason.clone()),
17391            DepError::VersaoInvalid {
17392                nome: nome.to_string(),
17393                versao: axis.to_string(),
17394                reason: reason.clone(),
17395            },
17396            "versao_invalid must route `nome` → `nome`, `axis` → `versao`, \
17397             `reason` → `reason` in declared field order",
17398        );
17399        assert_eq!(
17400            DepError::fonte_repo_shape(nome, axis, reason.clone()),
17401            DepError::FonteRepoShape {
17402                nome: nome.to_string(),
17403                repo: axis.to_string(),
17404                reason: reason.clone(),
17405            },
17406            "fonte_repo_shape must route `nome` → `nome`, `axis` → `repo`, \
17407             `reason` → `reason` in declared field order",
17408        );
17409        assert_eq!(
17410            DepError::caracteristica_invalid(nome, axis, reason.clone()),
17411            DepError::CaracteristicaInvalid {
17412                nome: nome.to_string(),
17413                caracteristica: axis.to_string(),
17414                reason: reason.clone(),
17415            },
17416            "caracteristica_invalid must route `nome` → `nome`, \
17417             `axis` → `caracteristica`, `reason` → `reason` in declared \
17418             field order",
17419        );
17420    }
17421}