Skip to main content

caixa_core/
dep.rs

1use serde::{Deserialize, Serialize};
2use thiserror::Error;
3
4/// A single dependency declaration in a `caixa.lisp` manifest.
5///
6/// **Store model = Git, like Zig.** There is no central registry; a caixa is
7/// just a Git repo with a `caixa.lisp` at its root. When `:fonte` is omitted,
8/// the resolver falls back to `github:<default-org>/<nome>` (org defaults to
9/// `pleme-io`, override via `~/.config/caixa/config.yaml`).
10///
11/// ```lisp
12/// ;; Shorthand — resolves to github:pleme-io/caixa-teia (or your default org):
13/// (:nome "caixa-teia" :versao "^0.1")
14///
15/// ;; Explicit git source:
16/// (:nome "caixa-teia"
17///  :versao "^0.1"
18///  :fonte (:tipo git :repo "github:pleme-io/caixa-teia" :tag "v0.1.0"))
19///
20/// ;; Arbitrary git URL (not limited to GitHub):
21/// (:nome "private-caixa"
22///  :versao "*"
23///  :fonte (:tipo git :repo "ssh://git@git.example/team/priv-caixa.git" :branch "main"))
24///
25/// ;; Local path (dev only; not publishable):
26/// (:nome "caixa-teia"
27///  :versao "0.1.0"
28///  :fonte (:tipo path :caminho "../caixa-teia"))
29/// ```
30#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
31#[serde(rename_all = "camelCase")]
32pub struct Dep {
33    /// Caixa name — must match the target caixa's `:nome`.
34    pub nome: String,
35
36    /// Semver constraint string (`"^0.1"`, `"~0.1.2"`, `"0.1.0"`, `"*"`).
37    pub versao: String,
38
39    /// Where to fetch the caixa from. Defaults to the feira registry.
40    #[serde(default, skip_serializing_if = "Option::is_none")]
41    pub fonte: Option<DepSource>,
42
43    /// If true, a missing `:fonte` is not a build failure.
44    #[serde(default, skip_serializing_if = "is_false")]
45    pub opcional: bool,
46
47    /// Feature flags to enable on the target caixa.
48    #[serde(default, skip_serializing_if = "Vec::is_empty")]
49    pub caracteristicas: Vec<String>,
50}
51
52/// Where a dep is fetched from. Tagged via `:tipo` in Lisp.
53///
54/// Only two shapes — Git and local Path. No central registry variant: a caixa
55/// is just a Git repo. Omitting `:fonte` means *"use the default resolver
56/// convention"*, which is `github:<default-org>/<nome>`; the resolver fills
57/// that in when computing the lacre.
58///
59/// The [`gen_platform::IsVariant`] derive emits per-arm arm-discriminator
60/// predicates — [`Self::is_git`], [`Self::is_path`] — so every downstream
61/// consumer that only needs the arm-discriminator projection (not the
62/// borrowed field value) reaches for one typed dispatch on the substrate
63/// primitive rather than a hand-rolled `matches!(s, DepSource::X { .. })`
64/// literal. Extends the closed-set-typed-enum discipline the sibling
65/// caixa-core enums ([`crate::CaixaKind`], [`crate::CaixaDialeto`],
66/// [`crate::supervisor::RestartStrategy`], [`crate::supervisor::RestartPolicy`],
67/// [`crate::upgrade::UpgradeInstruction`], [`crate::aplicacao::PlacementStrategy`],
68/// [`crate::aplicacao::RateLimitUnit`], [`crate::aplicacao::WitTarget`],
69/// [`crate::render::PathShapeViolation`], [`DepList`]) and the sibling
70/// out-of-crate enums (caixa-arch's `InvariantKind` + `ArchVerdict`,
71/// caixa-lint's `Severity` + `FixSafety`, caixa-provedor's
72/// `FerriteRuntime`, caixa-theme's `Semantic`, caixa-flux's `GitRefSpec`,
73/// caixa-ast's `NodeKind` + `TriviaKind`) already carry onto the
74/// two-arm `:fonte` dep-source axis — the 17th closed-set typed enum
75/// on the caixa surface, and the first on the outer-`Dep` `:fonte`-slot
76/// axis every git-fetching consumer runs after the outer `:fonte` slot
77/// resolves to a shape.
78#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, gen_platform::IsVariant)]
79#[serde(tag = "tipo", rename_all = "lowercase")]
80pub enum DepSource {
81    /// Clone from Git. One of `:tag`, `:rev`, or `:branch` may be set.
82    /// `repo` can be a `github:org/repo` shorthand, a full `https://…` URL,
83    /// or any git-ssh URL.
84    Git {
85        repo: String,
86        #[serde(default, skip_serializing_if = "Option::is_none")]
87        tag: Option<String>,
88        #[serde(default, skip_serializing_if = "Option::is_none")]
89        rev: Option<String>,
90        #[serde(default, skip_serializing_if = "Option::is_none")]
91        branch: Option<String>,
92    },
93    /// Local filesystem path — dev only; cannot be published.
94    Path { caminho: String },
95}
96
97impl DepSource {
98    /// Build a registry-shorthand git source (`github:<org>/<nome>`).
99    ///
100    /// This is the resolver-side fallback for `dep.fonte: None`, not an
101    /// author-surface value — it carries no pin (`:tag`/`:rev`/`:branch`
102    /// all `None`) and is therefore rejected by [`Self::validate`]. The
103    /// resolver fills the pin in at fetch time from the resolved commit;
104    /// authors never serialize this shape as a `Dep::fonte` value.
105    #[must_use]
106    pub fn default_github(org: &str, nome: &str) -> Self {
107        Self::Git {
108            repo: format!("github:{org}/{nome}"),
109            tag: None,
110            rev: None,
111            branch: None,
112        }
113    }
114
115    /// Substrate-canonical per-`:fonte` sole-set git-pin scalar accessor
116    /// every consumer that reads "which single git ref does this source
117    /// resolve to?" keys off — returns the author-declared `:tag` /
118    /// `:rev` / `:branch` byte-string verbatim as an `Option<&str>`,
119    /// borrowed from the typed slot's own `Option<String>` storage; `None`
120    /// on [`Self::Path`] (a path source carries no git-ref) and on a
121    /// [`Self::Git`] variant whose `tag`, `rev`, and `branch` are all
122    /// `None` (the [`Self::default_github`] shorthand shape the resolver
123    /// materializes when the author omits `:fonte` — rejected by
124    /// [`Self::validate`], but the accessor's return is defined on this
125    /// arm too so pre-validate consumers reach for the same typed dispatch
126    /// as post-validate ones).
127    ///
128    /// **Precedence: rev > tag > branch.** The canonical precedence every
129    /// per-`:fonte` git-ref consumer already applies: caixa-resolver's
130    /// per-fetch `git checkout <ref>` reads through the same
131    /// `rev.or(tag).or(branch)` cascade at caixa-resolver/src/resolve.rs,
132    /// and caixa-crd's `dep_into_ref` `CaixaSource.git_ref` fill reads
133    /// through the same cascade at caixa-crd/src/conversion.rs. The
134    /// [`Self::validate`] gate enforces "exactly one pin set" — under
135    /// that invariant every accepted [`Self::Git`] carries exactly one
136    /// non-`None` pin and the precedence is unobservable, but the
137    /// precedence remains defined for pre-validate consumers (the
138    /// resolver's `MissingPin` diagnostic path, the caixa-crd
139    /// round-trip's default `"main"` fallback the author never sees a
140    /// diagnostic on) and defense-in-depth for a hypothetical future
141    /// state where multiple pins survive the gate. The precedence is
142    /// **rev before tag** because `:rev` (a git commit OID) is the
143    /// reproducibility-strongest identifier — an OID resolves to exactly
144    /// one commit regardless of which refname points at it, whereas
145    /// `:tag` and `:branch` are refnames the remote can silently move
146    /// (a tag re-push, a branch head advance); the resolver's freeze
147    /// step at fetch time promotes the resolved commit to `:rev` for
148    /// exactly this reason. **Tag before branch** because `:tag` is
149    /// conventionally immutable (a release tag) whereas `:branch` is
150    /// conventionally mutable (a tracking ref) — a caixa carrying both
151    /// a release tag and a tracking branch reads as "prefer the release
152    /// pin, fall through to the tracking pin only if the release is
153    /// missing". The cascade order also matches the byte-order every
154    /// per-`:tag`/`:rev`/`:branch` diagnostic tuple this crate emits
155    /// (`(":tag", tag), (":rev", rev), (":branch", branch)` — see
156    /// [`Self::validate`]'s `pins` array).
157    ///
158    /// Prior to this lift the "sole set pin" projection sat twice in the
159    /// workspace — inline at caixa-resolver's `fetch_git` (`let gitref =
160    /// rev.or(tag).or(branch).ok_or_else(|| ResolveError::MissingPin
161    /// { … })?;`) and at caixa-crd's `dep_into_ref`
162    /// (`git_ref: rev.clone().or(tag.clone()).or(branch.clone())
163    /// .unwrap_or_else(|| "main".to_string())`) — two open-coded copies
164    /// of the same precedence cascade with no compile-time link back to
165    /// the typed slot. A future extension of the pin axis to a richer
166    /// author surface (a `:commit` pin peer of `:rev` once the substrate
167    /// grows a signed-commit-verification pin, a `:ref` pin the M4
168    /// substrate operator resolves per-cluster ahead of fetch, a
169    /// promotion of the plain `Option<String>` pins to a typed
170    /// `GitPin::{Rev(Oid), Tag(RefName), Branch(RefName)}` newtype
171    /// once the sibling [`crate::render::is_git_oid`] /
172    /// [`crate::render::is_git_ref_name`] gates land as typed
173    /// constructors) would have had to be threaded through both
174    /// open-coded copies in lockstep or the resolver's `git checkout`
175    /// target would silently disagree with the CRD's `git_ref` fill —
176    /// an author's `(:fonte (:tipo git :repo "…" :rev "deadbeef" :tag
177    /// "v1"))` would ship with the resolver checking out `deadbeef`
178    /// while the CRD round-trip re-emitted a Dep pointing at `v1`, one
179    /// lacre closure disagreeing with the emitted K8s CR the operator
180    /// reads. Lifting the resolution to a typed method on the substrate
181    /// primitive means both downstream consumers reach for exactly one
182    /// typed dispatch — the resolver's accept-set migrates as a unit on
183    /// any future pin-axis addition.
184    ///
185    /// Peer of the sibling outer-`Dep` [`Dep::fonte`] (d65d1bf)
186    /// `Option<&DepSource>` composite-reference accessor on the outer-
187    /// `Dep` `:fonte`-slot axis — extended one nesting level down onto
188    /// the per-[`Self::Git`]-variant sole-set-pin projection axis every
189    /// git-fetching consumer runs after the outer `:fonte` slot resolves
190    /// to a [`Self::Git`] shape. Same "one typed dispatch on the
191    /// substrate primitive, thin projections at each consumer" discipline
192    /// the outer accessor family already carries.
193    #[must_use]
194    pub fn sole_pin(&self) -> Option<&str> {
195        match self {
196            Self::Git {
197                tag, rev, branch, ..
198            } => rev.as_deref().or(tag.as_deref()).or(branch.as_deref()),
199            Self::Path { .. } => None,
200        }
201    }
202
203    /// Validate the `:fonte` value-shape: every author-surface
204    /// `:fonte (:tipo git …)` must carry a non-empty `:repo` and
205    /// exactly one of `:tag` / `:rev` / `:branch` set to a non-empty
206    /// value; every `:fonte (:tipo path …)` must carry a non-empty
207    /// `:caminho`.
208    ///
209    /// Called from [`Dep::validate`] with the dep's `:nome` so every
210    /// diagnostic carries the offending entry verbatim — same
211    /// self-locating shape the `:deps :versao` (2420c44),
212    /// `:membros :versao` (9888b13), `:children :versao` (b38ff3a),
213    /// `:placement :clusters` (6cbb900), and `:membros :caixa`
214    /// (3f9d7a0) gates already expose.
215    ///
216    /// Until this gate landed `:fonte` was the only `:deps`-related
217    /// typed surface still untyped past `Caixa::from_lisp`:
218    /// - Empty `:repo` (`(:tipo git :repo "" :tag "v1")`) silently
219    ///   passed parse and surfaced as a git-clone failure at
220    ///   lacre-resolve time, far from the source caixa.lisp.
221    /// - A bare `(:tipo git :repo "…")` with no `:tag`/`:rev`/`:branch`
222    ///   passed parse and surfaced as the resolver's
223    ///   [`ResolveError::MissingPin`](../../caixa-resolver/src/resolve.rs)
224    ///   at fetch time, again far from the source caixa.lisp; lifting
225    ///   to validate-time gives the author the same diagnostic at the
226    ///   edit site.
227    /// - `(:tipo git :repo "…" :tag "v1" :branch "main")` — multiple
228    ///   pins set — passed parse and the resolver silently picked
229    ///   `:rev > :tag > :branch`, ignoring the other pins with no
230    ///   diagnostic; the author had no way to know their `:branch`
231    ///   was dropped. This is the canonical "pin drift" footgun.
232    /// - An empty pin value (`(:tipo git :repo "…" :tag "")`) silently
233    ///   passed parse and surfaced as `git checkout ""` at fetch time.
234    /// - Empty `:caminho` (`(:tipo path :caminho "")`) silently passed
235    ///   parse and surfaced as
236    ///   [`ResolveError::MissingPath`](../../caixa-resolver/src/resolve.rs)
237    ///   with `path: PathBuf("")` — not actionable.
238    ///
239    /// Each rejected shape maps to a typed
240    /// [`DepError::Fonte*`] variant that names the offending
241    /// dep's `:nome` and the specific axis, so the author can grep
242    /// their caixa.lisp for the `:nome "<nome>"` block and fix it in
243    /// one edit.
244    pub fn validate(&self, nome: &str) -> Result<(), DepError> {
245        match self {
246            Self::Git {
247                repo,
248                tag,
249                rev,
250                branch,
251            } => {
252                if repo.is_empty() {
253                    return Err(DepError::fonte_repo_empty(nome));
254                }
255                // The `:repo` value flows verbatim into the caixa-resolver's
256                // `git clone <repo>` subprocess invocation. Until this gate
257                // landed `:repo` was the last untyped `:fonte`-related axis
258                // past the empty arm: a malformed-but-non-empty repo URL
259                // (`":repo "github:p/x ""` trailing space, paste-from-doc;
260                // `":repo "-upload-pack=evil""` leading `-` — the canonical
261                // CLI-argument-injection vector at the `git clone` boundary;
262                // `":repo "pleme-io/caixa-teia""` missing scheme — `git clone`
263                // reads as a relative filesystem path rather than the
264                // GitHub-shorthand expansion; `":repo "github:p/x\n""`
265                // embedded newline; `":repo "github:café/x""` raw non-ASCII)
266                // silently passed validate and the failure surfaced at
267                // lacre-resolve time with a porcelain-quoting-confused error
268                // far from the source caixa.lisp. The lifted predicate makes
269                // the git-porcelain-URL intersection-floor a substrate-level
270                // invariant at validate time, peer with the three pin axes
271                // (`:tag` + `:branch` via [`crate::render::is_git_ref_name`],
272                // e70d213; `:rev` via [`crate::render::is_git_oid`], be07fd5)
273                // — every `:fonte (:tipo git …)` past validate is now
274                // structurally accept-shaped on every axis the resolver
275                // consumes (the `:repo` URL the `git clone` invokes against,
276                // the `:tag`/`:branch` refname `git fetch`/`git checkout`
277                // accepts, the `:rev` commit OID the lacre's content-
278                // addressing equality probe resolves), closing the
279                // `:fonte` slot's value-shape trajectory end-to-end.
280                if let Err(reason) = crate::render::is_git_repo_url(repo) {
281                    return Err(DepError::FonteRepoShape {
282                        nome: nome.to_string(),
283                        repo: repo.clone(),
284                        reason,
285                    });
286                }
287                let pins: [(&'static str, Option<&String>); 3] = [
288                    (":tag", tag.as_ref()),
289                    (":rev", rev.as_ref()),
290                    (":branch", branch.as_ref()),
291                ];
292                let set: Vec<&'static str> =
293                    pins.iter().filter_map(|(n, v)| v.map(|_| *n)).collect();
294                match set.len() {
295                    0 => {
296                        return Err(DepError::fonte_pin_missing(nome));
297                    }
298                    1 => {
299                        for (pin, value) in pins {
300                            if value.is_some_and(String::is_empty) {
301                                return Err(DepError::FontePinEmpty {
302                                    nome: nome.to_string(),
303                                    pin: pin.to_string(),
304                                });
305                            }
306                        }
307                    }
308                    _ => {
309                        return Err(DepError::FontePinAmbiguous {
310                            nome: nome.to_string(),
311                            pins: set.join(", "),
312                        });
313                    }
314                }
315                // Per-pin value-shape gate. The refname-shaped axes
316                // (`:tag` + `:branch`) route through
317                // [`crate::render::is_git_ref_name`]; the hex-OID-shaped
318                // `:rev` axis routes through
319                // [`crate::render::is_git_oid`]. The two predicates
320                // partition the `:fonte` pin axes structurally — refname
321                // vs. hex commit — so a cross-axis mis-slot (the
322                // canonical "I conflated `:rev` and `:branch`" footgun:
323                // `:rev "main"` defeating the reproducibility contract,
324                // `:tag "deadbeef…"` mis-slotting a SHA into the
325                // refname-shaped axis) lands at the offending axis's
326                // predicate, not at lacre-resolve `git fetch` /
327                // `git checkout` time. Their valid sets intersect at
328                // the empty set: every refname is rejected by
329                // `is_git_oid`, every OID is rejected by
330                // `is_git_ref_name`, structurally.
331                //
332                // Until this gate landed `:tag` / `:branch` were the
333                // refname-shaped axes still untyped past the empty-pin
334                // arm: a malformed-but-non-empty refname
335                // (`:tag "v0.1.0 "` trailing space — the canonical
336                // paste-from-doc footgun; `:tag "v0.1.0.lock"` colliding
337                // with git's atomic-rename guard suffix; `:tag "../escape"`
338                // path-traversal via consecutive dots; `:branch "main "`
339                // trailing space; `:branch "feature/foo bar"` embedded
340                // space; `:branch "@"` the literal HEAD alias;
341                // `:branch "refs/heads/main"` the fully-qualified ref
342                // copied from `git show-ref` output that resolves to
343                // a literal ref named `refs/heads/refs/heads/main` on
344                // disk) silently passed validate; the `:rev` axis was
345                // the last `:fonte`-related axis still untyped past the
346                // empty-pin arm: a malformed-but-non-empty hex-OID
347                // (`:rev "main"` conflating with `:branch` — the
348                // reproducibility-contract leak; `:rev "v0.1.0"`
349                // conflating with `:tag` — the same mis-slot on the
350                // refname/OID boundary; `:rev "c0ffee"` an abbreviated
351                // 6-char prefix that's ambiguous across repo history;
352                // `:rev "DEADBEEF…"` an uppercase OID that round-trips
353                // inconsistently against `git rev-parse HEAD`'s
354                // lowercase emission) silently passed validate and the
355                // failure surfaced at lacre-resolve `git fetch` /
356                // `git checkout` time with a quoting-confused error
357                // far from the source caixa.lisp, with no field naming
358                // which `:deps` entry carried the typo. Lifting both
359                // gates to caixa-build time matches the value-shape
360                // trajectory the peer typed axes already follow
361                // (c4213a4 typed WitContract endpoint/subject/slot;
362                // eb3456d :entrada :paths; c7d05ec :entrada :host;
363                // 4f0390b :contratos :endpoint; 6226bf4 :contratos :wit;
364                // 63e18a0 :contratos :subject; 2f4316e :contratos
365                // :slot; e70d213 :fonte :tag + :branch) — the typed
366                // slot's valid set matches its downstream consumer's
367                // accepted set (here, the git porcelain's refname /
368                // commit-OID grammars at `git fetch` / `git checkout`
369                // time), structurally. Same diagnostic shape every
370                // per-axis value-shape lift already exposes
371                // (`*Invalid { axis, reason }`); the `value:` field
372                // carries the offending refname / OID verbatim so the
373                // author can grep their caixa.lisp for the
374                // `:tag "<value>"` / `:branch "<value>"` /
375                // `:rev "<value>"` literal and fix it in one edit.
376                for (pin, value) in [(":tag", tag.as_ref()), (":branch", branch.as_ref())] {
377                    if let Some(v) = value
378                        && let Err(reason) = crate::render::is_git_ref_name(v)
379                    {
380                        return Err(DepError::FontePinShape {
381                            nome: nome.to_string(),
382                            pin: pin.to_string(),
383                            value: v.clone(),
384                            reason,
385                        });
386                    }
387                }
388                if let Some(v) = rev.as_ref()
389                    && let Err(reason) = crate::render::is_git_oid(v)
390                {
391                    return Err(DepError::FontePinShape {
392                        nome: nome.to_string(),
393                        pin: ":rev".to_string(),
394                        value: v.clone(),
395                        reason,
396                    });
397                }
398                Ok(())
399            }
400            Self::Path { caminho } => Self::validate_caminho(nome, caminho),
401        }
402    }
403
404    /// Reproducibility + path-API gate on the `:fonte (:tipo path …)`
405    /// `:caminho` axis. Walks the leading-byte cascade closed by the
406    /// b94fd83 (`/`), a5c248e (`~`), and f4efe9c (`$`) arms; the
407    /// orthogonal embedded-control-byte arm (d624c8d) covering
408    /// `0x00..=0x1F` plus `0x7F` anywhere in the value; and the
409    /// embedded-`\` Windows-path-separator arm closing the
410    /// cross-host-OS-separator divergence vector on the same
411    /// THEORY.md §V.2 render-determinism axis.
412    ///
413    /// Extracted from [`Self::validate`]'s `Self::Path` arm because the
414    /// per-arm cascade now spans nine diagnostic shapes — every new
415    /// `:caminho` arm (a future `&` / `;` / `|` shell-metachar arm,
416    /// a future glob-metachar `*` / `?` arm) lands here rather than
417    /// re-inflating `Self::validate`. The
418    /// function stays a thin per-arm linear walk for one reason: each
419    /// arm's diagnostic carries a distinct typed [`DepError`] variant
420    /// rather than a parser-shaped `reason` string, so collapsing the
421    /// cascade onto a generic [`crate::render`] predicate would regress
422    /// the per-arm self-locating diagnostic that `feira lint` consumers
423    /// depend on. The wrapped predicate trajectory ([`crate::render::is_dns_1123_label`],
424    /// [`crate::render::is_git_repo_url`], etc.) lives on the
425    /// reason-string-shaped axes; the `:caminho` axis keeps its
426    /// per-arm variant shape.
427    #[allow(
428        clippy::too_many_lines,
429        reason = "the per-arm cascade is structurally flat by design — every \
430                  `:caminho` arm carries its own typed [`DepError`] variant + \
431                  per-arm Why comment, so collapsing the cascade onto a generic \
432                  [`crate::render`] predicate would regress the per-arm self-locating \
433                  diagnostic the `feira lint` consumer surface depends on"
434    )]
435    fn validate_caminho(nome: &str, caminho: &str) -> Result<(), DepError> {
436        if caminho.is_empty() {
437            return Err(DepError::fonte_caminho_empty(nome));
438        }
439        // Reproducibility gate on the `:fonte (:tipo path …)`
440        // `:caminho` axis. The lacre pipeline embeds the value
441        // verbatim in its per-dep content-address
442        // (`conteudo: format!("path:{caminho}")`,
443        // caixa-resolver/src/resolve.rs:189) and that string
444        // folds into the BLAKE3 closure the lacre keys every
445        // downstream consumer (the substrate's reproducibility
446        // contract, CAIXA-SDLC §III.2 — the lacre is the
447        // build's content-addressed identity, peer of the Nix
448        // store path) against. Until this gate landed an
449        // absolute `:caminho` (`/home/me/work/caixa-teia` — the
450        // canonical "I dragged the folder out of Finder into
451        // my editor" footgun; `/Users/alice/dev/caixa-teia` on
452        // the macOS path-layout peer; the
453        // `${WORKSPACE}/caixa-teia` shell-expanded literal
454        // pasted from a CI manifest) silently passed validate
455        // and the failure surfaced *as a successful build with
456        // a divergent lacre*: the BLAKE3 closure on Alice's
457        // workstation differed from the closure on Bob's
458        // workstation, two CI runners with different
459        // `${HOME}` layouts emitted two distinct
460        // content-addresses for the byte-identical caixa, and
461        // the substrate's "the lacre is the build's identity"
462        // contract silently broke far from the source
463        // caixa.lisp — the most insidious failure mode the
464        // typed slot can carry (no error surfaces; the
465        // divergence is invisible until two machines compare
466        // lacres). The same THEORY.md §V.2 render-determinism
467        // discipline `is_sandboxed_relative_path` already
468        // applies on the M2 typed path-slots
469        // (`:behavior :on-*`, `:upgrade-from :state-change
470        // :script`, `:bibliotecas`, `:exe`, `:servicos`), here
471        // narrowed to the absolute-vs-relative axis only:
472        // `:fonte :caminho`'s canonical author-surface form is
473        // the `..`-traversing sibling-workspace path
474        // (`"../caixa-teia"`, the in-tree dev-dep frame), so a
475        // full `is_sandboxed_relative_path` lift would
476        // structurally reject every legitimate path-fonte
477        // dep. The narrower
478        // `std::path::Path::is_absolute` cut admits the
479        // sibling-workspace form while still rejecting the
480        // host-layout-leaking absolute shape — the
481        // reproducibility contract bites at exactly the
482        // absolute boundary, and that's the axis the
483        // substrate-level invariant is meant to hold. Same
484        // diagnostic shape every per-axis value-shape lift on
485        // the surrounding [`DepError::Fonte*`] cluster carries
486        // (the offending `:nome` + offending `:caminho`
487        // quoted verbatim so the author can grep their
488        // caixa.lisp for the `:caminho "<value>"` literal and
489        // fix it in one edit). The empty arm strictly
490        // precedes this arm so the blank-string footgun
491        // surfaces the more self-locating
492        // `FonteCaminhoEmpty` diagnostic (the empty string
493        // is not absolute under `Path::new("").is_absolute()`
494        // so the precedence is a no-op at value level — the
495        // pin matters only at the diagnostic-shape level if
496        // a future codec round-trip ever produces an empty
497        // string that probes as absolute).
498        if std::path::Path::new(caminho).is_absolute() {
499            return Err(DepError::fonte_caminho_absolute(nome, caminho));
500        }
501        // Reproducibility gate's tilde-expansion arm. The b94fd83
502        // `FonteCaminhoAbsolute` closes the leading-`/`
503        // host-layout-leak; a `:caminho "~/work/caixa-teia"` (the
504        // canonical paste-from-shell-prompt / paste-from-`cd ~`-
505        // doc footgun) silently passed both the empty arm and
506        // the absolute arm because `Path::new("~").is_absolute()`
507        // returns `false` — `~` is a shell-expansion convention,
508        // not a POSIX path component, so `std::path::Path` treats
509        // it as a literal directory-name segment. The lacre
510        // pipeline then embedded the value verbatim
511        // (`conteudo: format!("path:~/work/caixa-teia")`) and the
512        // failure mode forked per consumer:
513        //
514        //   - The caixa-resolver's `Path` arm folds `:caminho`
515        //     through `Path::new(caminho).join(<file>)` without
516        //     `~`-expansion, so the build looked for a literal
517        //     `./~/work/caixa-teia` subdirectory and failed at
518        //     resolve time with a `No such file or directory`
519        //     error far from the source caixa.lisp (the lacre
520        //     itself, though, was already byte-identical across
521        //     machines — every machine emitted the same
522        //     `path:~/work/caixa-teia` content-address).
523        //   - A future caixa-resolver pass that *does* expand `~`
524        //     (the canonical shell-convention idiom every
525        //     resolver eventually reaches for once an author
526        //     reports the literal-`~`-directory bug) would re-
527        //     introduce the host-layout-leak the b94fd83 absolute
528        //     gate closes: Alice's `~` expands to `/home/alice`,
529        //     Bob's to `/home/bob`, two CI runners with different
530        //     `$HOME` layouts resolve to two distinct paths for
531        //     the byte-identical caixa, and the substrate's
532        //     "the lacre is the build's identity" contract
533        //     silently breaks far from the source caixa.lisp.
534        //
535        // Closing the gate at `DepSource::validate` (here at the
536        // canonical caixa-build-time boundary, peer with the
537        // absolute arm above) refuses both failure modes
538        // structurally: the typed accepted set excludes every
539        // `~`-prefixed authoring shape, so the resolver is
540        // free to grow `~`-expansion (or any other convention-
541        // expansion the substrate adopts) without re-opening
542        // the host-layout-leak at the typed boundary. Same
543        // diagnostic shape every per-axis value-shape gate on
544        // the surrounding [`DepError::Fonte*`] cluster carries
545        // (the offending `:nome` + offending `:caminho` quoted
546        // verbatim so the author can grep their caixa.lisp for
547        // the `:caminho "<value>"` literal and fix it in one
548        // edit).
549        //
550        // The cascade preserves narrower-diagnostic-first
551        // ordering: `FonteCaminhoEmpty` → `FonteCaminhoAbsolute`
552        // → `FonteCaminhoTildeExpansion`. The empty arm
553        // structurally precedes both (the bytes "" / "~" don't
554        // overlap), and the absolute arm structurally precedes
555        // the tilde arm (an absolute path can't start with `~`
556        // since absolute paths start with `/`; the bytes "/" /
557        // "~" don't overlap either). Both arms are
558        // value-disjoint, so the precedence is a no-op at value
559        // level — the pin matters only at the diagnostic-shape
560        // level if a future codec round-trip ever produces a
561        // value that probes as both absolute and tilde-prefixed.
562        if caminho.starts_with('~') {
563            return Err(DepError::fonte_caminho_tilde_expansion(nome, caminho));
564        }
565        // Reproducibility gate's shell-variable-expansion arm.
566        // The b94fd83 `FonteCaminhoAbsolute` closes the leading-`/`
567        // host-layout-leak; the a5c248e `FonteCaminhoTildeExpansion`
568        // closes the leading-`~` shell-home-expansion shape; the
569        // leading-`$` is the sibling shell-variable-expansion shape
570        // — same host-layout-leaking semantic, different syntactic
571        // surface. A `:caminho "$HOME/work/caixa-teia"` (the
572        // canonical paste-from-`echo $HOME`-doc footgun) and the
573        // `${VAR}`-braced variant (`"${WORKSPACE}/caixa-teia"` —
574        // the canonical paste-from-CI-manifest footgun every
575        // GitHub Actions / GitLab CI / Drone manifest carries)
576        // silently passed every prior arm because
577        // `Path::is_absolute` returns false on `$` (the `$` is a
578        // shell convention, not a POSIX path component, so
579        // `std::path::Path` treats it as a literal directory-name
580        // segment) and the tilde arm's `starts_with('~')` doesn't
581        // fire.
582        //
583        // Same per-consumer failure-fork the tilde arm closes:
584        //
585        //   - The caixa-resolver's `Path` arm folds `:caminho`
586        //     through `Path::new(caminho).join(<file>)` without
587        //     `$`-expansion, so the build looks for a literal
588        //     `./$HOME/work/caixa-teia` subdirectory and fails at
589        //     resolve time with a `No such file or directory`
590        //     error far from the source caixa.lisp.
591        //   - A future caixa-resolver pass that *does* expand
592        //     `$VAR` (the shell-convention idiom every resolver
593        //     eventually reaches for once an author reports the
594        //     literal-`$HOME`-directory bug, especially for CI's
595        //     `${WORKSPACE}` idiom) would re-introduce the host-
596        //     layout-leak the b94fd83 absolute gate closes:
597        //     Alice's `$HOME` expands to `/home/alice`, Bob's to
598        //     `/home/bob`, two CI runners with different
599        //     `${WORKSPACE}` layouts resolve to two distinct
600        //     paths for the byte-identical caixa, and the
601        //     substrate's "the lacre is the build's identity"
602        //     contract silently breaks far from the source
603        //     caixa.lisp.
604        //
605        // Closing the gate at `DepSource::validate` (here at the
606        // canonical caixa-build-time boundary, peer with the
607        // absolute + tilde arms above) refuses both failure modes
608        // structurally. Same diagnostic shape every per-axis
609        // value-shape gate on the surrounding [`DepError::Fonte*`]
610        // cluster carries (the offending `:nome` + offending
611        // `:caminho` quoted verbatim).
612        //
613        // The cascade preserves narrower-diagnostic-first ordering:
614        // `FonteCaminhoEmpty` → `FonteCaminhoAbsolute` →
615        // `FonteCaminhoTildeExpansion` → `FonteCaminhoVarExpansion`.
616        // The empty arm structurally precedes all three subsequent
617        // arms; the absolute arm structurally precedes both the
618        // tilde and the var arms (absolute paths start with `/`,
619        // the bytes `/` / `~` / `$` don't overlap at the leading
620        // position); the tilde arm structurally precedes the var
621        // arm (`~` and `$` don't overlap at the leading position).
622        // Every pair is value-disjoint, so the precedence is a
623        // no-op at value level — the pin matters only at the
624        // diagnostic-shape level if a future codec round-trip ever
625        // produces a probe-as-both value.
626        //
627        // The gate covers every leading-`$` shape: the canonical
628        // `"$HOME/work/caixa-teia"` (POSIX shell), the braced
629        // `"${HOME}/work/caixa-teia"` (POSIX shell braces), the
630        // CI-manifest idiom `"${WORKSPACE}/caixa-teia"` (the
631        // GitHub Actions / GitLab CI / Drone paste footgun), the
632        // XDG idiom `"$XDG_CONFIG_HOME/caixa"`, and the bare `$`
633        // (degenerate "I meant `$HOME` and forgot the rest"). All
634        // shapes route through the same `caminho.starts_with('$')`
635        // byte check.
636        if caminho.starts_with('$') {
637            return Err(DepError::fonte_caminho_var_expansion(nome, caminho));
638        }
639        // Reproducibility gate's leading-space arm. The b94fd83 / a5c248e /
640        // f4efe9c arms closed the leading-byte host-layout-leak shapes
641        // (`/` / `~` / `$`); the embedded-control-byte arm below closes
642        // every byte in `0x00..=0x1F` plus `0x7F` (which already includes
643        // tab `0x09`, LF `0x0A`, CR `0x0D` — every ASCII whitespace
644        // *except* the ASCII space byte `0x20`). The bare ASCII space at
645        // the leading position is the orthogonal paste-from-aligned-doc
646        // shape that silently passed every prior arm: `Path::is_absolute`
647        // returns false on `" ../caixa-teia"` (the leading byte is `0x20`
648        // not `0x2F`), `0x20` is not `~` / `$` / `\` / a control byte, and
649        // the value's last byte is not `/`, so the canonical
650        // paste-from-aligned-`caixa.lisp`-doc footgun (every `:fonte`
651        // form in a multi-entry `:deps` block sits at the same column —
652        // an author selecting `"<sp><sp><sp>../caixa-teia"` and pasting
653        // it from the rendered alignment into a fresh entry preserves the
654        // leading whitespace verbatim) silently rendered as a path with
655        // a leading-space directory component the resolver folds through
656        // `Path::join` looking for a literal `./ ../caixa-teia`
657        // subdirectory that fails at resolve time with a non-self-
658        // locating `No such file or directory` error.
659        //
660        // The lacre pipeline's reproducibility contract bites
661        // strictly at this byte: `path:" ../caixa-teia"` and
662        // `path:"../caixa-teia"` yield distinct BLAKE3 closures
663        // (`conteudo: format!("path:{caminho}")`,
664        // caixa-resolver/src/resolve.rs:189) for the byte-divergent /
665        // semantic-identical caixa, and the substrate's "the lacre is
666        // the build's identity" contract (CAIXA-SDLC §III.2) silently
667        // breaks across two workstations whose authors differ only in
668        // paste-from-aligned-doc whitespace habits — the most insidious
669        // failure mode the typed slot can carry (no error surfaces; the
670        // divergence is invisible until two machines compare lacres).
671        //
672        // The arm fires AFTER the absolute / tilde / var leading-byte
673        // arms (each names the more self-locating shell-convention
674        // diagnostic on values that probe as that arm's leading-byte
675        // sentinel followed by a leading space — e.g.
676        // `:caminho "/  /foo"` surfaces `FonteCaminhoAbsolute` because
677        // the leading byte is `/`, not space) and BEFORE the
678        // embedded-control-byte arm (a leading-space value with an
679        // embedded control byte surfaces the broader leading-space
680        // diagnostic because the cascade walks leading-byte arms first
681        // — peer with how `FonteCaminhoAbsolute` precedes
682        // `FonteCaminhoControlChar` on `"/etc/passwd\n"`).
683        //
684        // The peer single-token-shaped axes already reject leading
685        // whitespace on the same paste-from-aligned-doc contract:
686        // [`crate::render::is_git_repo_url`] rejects leading whitespace
687        // on `:fonte :repo`, [`crate::render::is_git_ref_name`] rejects
688        // leading whitespace on `:fonte :tag`/`:branch`,
689        // [`crate::render::is_chart_description_shape`] rejects leading
690        // whitespace on `:descricao`,
691        // [`crate::render::is_spdx_expression_shape`] rejects leading
692        // whitespace on `:licenca`. Closing the same byte on
693        // `:fonte :caminho` makes the substrate-wide "no leading ASCII
694        // space anywhere in a typed string slot" invariant structurally
695        // consistent across every value-shape-gated typed surface (the
696        // `:caminho` axis was the last typed string surface still
697        // admitting a leading space byte).
698        if caminho.starts_with(' ') {
699            return Err(DepError::fonte_caminho_leading_whitespace(nome, caminho));
700        }
701        // Reproducibility gate's leading-`-` CLI-argument-injection arm.
702        // The b94fd83 + a5c248e + f4efe9c + LeadingWhitespace arms closed
703        // the four prior leading-byte shapes (`/` / `~` / `$` / space);
704        // this arm closes the orthogonal leading-`-` axis on the same
705        // subprocess-argument-boundary the peer `is_git_repo_url` arm
706        // (render.rs:2037, `-upload-pack=…` on `:fonte :repo`) and
707        // `is_git_ref_name` arm (render.rs:1381, 5a28454, `-stable` on
708        // `:fonte :tag` / `:branch`) already reject.
709        //
710        // The lacre pipeline embeds `:caminho` verbatim in its per-dep
711        // content-address (`conteudo: format!("path:{caminho}")`,
712        // caixa-resolver/src/resolve.rs:189) and the resolver folds the
713        // value through `Path::join` looking for a literal `./{caminho}`
714        // subdirectory. Every downstream subprocess that consumes the
715        // resolved path — a `git -C {caminho} <verb>` invocation, a
716        // future `feira tofu` `terraform -chdir={caminho}` shell-out, a
717        // future operator-side `nix build --path {caminho}` spawn, an
718        // `xargs` / `find {caminho}` / `stat {caminho}` /
719        // `rm -rf {caminho}` cleanup — reinterprets a leading-`-` value
720        // as a CLI flag rather than a positional path when the
721        // subprocess invocation does not carry a `--` argument-list
722        // terminator between the flag block and the path argument. The
723        // canonical footguns:
724        //
725        //   - `:caminho "-rf"` — bare short-flag paste (`rm -rf` /
726        //     `find -rf` reinterpretation; the byte the peer
727        //     `FonteCaminhoShellSemicolon` arm's `; rm -rf build`
728        //     example paste-idiom carries as its first token).
729        //   - `:caminho "-C"` — `git -C` config-injection paste
730        //     (`git -C -C` reinterprets the second `-C` as another
731        //     `--change-directory` flag rather than the path
732        //     argument; the canonical `git -C <path>` porcelain
733        //     idiom every multi-repo workspace tool carries).
734        //   - `:caminho "--upload-pack=cat /etc/passwd"` — the
735        //     canonical long-flag CLI-arg-injection vector at every
736        //     git porcelain entry point (`git clone`, `git fetch`,
737        //     `git ls-remote`) that consumes a path or URL
738        //     argument; peer with `is_git_repo_url`'s leading-`-`
739        //     arm (render.rs:2037) on the sibling `:fonte :repo`
740        //     axis, which the arm's diagnostic explicitly cites.
741        //   - `:caminho "--config=…"` / `:caminho "-c"` — git-config
742        //     override paste-idiom (paste-from-`git -c foo=bar`
743        //     shell-history footgun that reinterprets the value as
744        //     a `[foo] bar` config injection on every git porcelain
745        //     entry point).
746        //
747        // POSIX `std::path::Path` treats a leading `-` as a literal
748        // filename byte, so the resolver folds `-rf` through `Path::join`
749        // and looks for a literal `./-rf` subdirectory — the failure
750        // surfaces at resolve time with a non-self-locating `No such
751        // file or directory` error far from the source caixa.lisp, and
752        // the value rides through the lacre content-address into every
753        // downstream shell-spawned subprocess. On any consumer that
754        // shells out without the `--` terminator (the common case at
755        // every porcelain entry-point) the reinterpretation is silent
756        // and the failure mode is arbitrary-argument-injection.
757        //
758        // The arm fires AFTER the absolute / tilde / var / leading-space
759        // leading-byte arms (each names the more self-locating shell-
760        // convention diagnostic on values that probe as that arm's
761        // leading-byte sentinel — the byte sets are pairwise disjoint at
762        // the leading position, so the precedence pin is a no-op at
763        // value level, but the ordering keeps every leading-byte arm's
764        // diagnostic-shape stable) and BEFORE the embedded-control-byte
765        // arm (a leading-`-` value with an embedded control byte
766        // surfaces the narrower leading-`-` diagnostic because the
767        // cascade walks leading-byte arms first — peer with how
768        // `FonteCaminhoAbsolute` precedes `FonteCaminhoControlChar` on
769        // `"/etc/passwd\n"`, and how `FonteCaminhoLeadingWhitespace`
770        // precedes `FonteCaminhoControlChar` on `" ../foo\n"`).
771        //
772        // The peer single-token-shaped axes already reject leading `-`
773        // on the same CLI-arg-injection contract:
774        // [`crate::render::is_git_repo_url`] rejects it on `:fonte :repo`
775        // (render.rs:2037), [`crate::render::is_git_ref_name`] rejects
776        // it on `:fonte :tag` / `:fonte :branch` (render.rs:1381,
777        // 5a28454), [`crate::render::is_dns_1123_label`] rejects it on
778        // every DNS-1123-shaped axis (top-level Caixa `:nome`, `:membros
779        // :caixa`, `:children :caixa`, `:deps :nome`, cluster names),
780        // [`crate::render::is_cargo_feature_name`] rejects it on
781        // `:caracteristicas`, and the feira `init` / `add <nome>`
782        // positional gate (868c191) rejects it on the CLI positional
783        // itself. Closing the same byte on `:fonte :caminho` makes the
784        // substrate-wide "no leading `-` anywhere in a typed single-
785        // token string slot routed through a subprocess argument"
786        // invariant structurally consistent across every value-shape-
787        // gated typed surface (the `:caminho` axis was the last typed
788        // string surface still admitting a leading `-` byte).
789        if caminho.starts_with('-') {
790            return Err(DepError::fonte_caminho_leading_hyphen(nome, caminho));
791        }
792        // Reproducibility gate's embedded-control-byte arm. The
793        // b94fd83 + a5c248e + f4efe9c arms closed the three
794        // leading-byte host-layout-leak shapes (`/` / `~` / `$`);
795        // this arm closes the orthogonal embedded-control-byte
796        // axis — any ASCII control byte (`0x00..=0x1F` plus
797        // `0x7F` DEL) appearing anywhere in `:caminho`. Same
798        // shape every peer single-token-typed-slot value-shape
799        // predicate the surrounding [`crate::render`] cluster
800        // gates against (the lifted `is_git_repo_url` arm on
801        // `:fonte :repo`, the `is_git_ref_name` arm on
802        // `:tag`/`:branch`, the `is_chart_description_shape` /
803        // `is_chart_maintainer_name_shape` /
804        // `is_chart_keyword_shape` arms on the
805        // Helm-chart-shaped axes); now consistent on the
806        // `:caminho` axis too.
807        //
808        // Until this gate landed any embedded control byte
809        // silently passed validate, the lacre pipeline embedded
810        // the value verbatim in its per-dep content-address
811        // (`conteudo: format!("path:{caminho}")`,
812        // caixa-resolver/src/resolve.rs:189), and the failure
813        // forked per byte and per consumer:
814        //
815        //   - NUL (`0x00`) the canonical "POSIX paths cannot
816        //     contain a NUL byte" shape: every `std::fs` syscall
817        //     routes the path through `CString::new`, which
818        //     fails with `NulError` on the first NUL byte; the
819        //     build would surface a `NulError` at resolve time
820        //     far from the source caixa.lisp.
821        //   - LF (`0x0A`) / CR (`0x0D`) the canonical paste-from-
822        //     multiline-doc footgun: a `:caminho
823        //     "../caixa-teia\nrm -rf /"` value (paste landed mid-
824        //     `:caminho` block from a multi-line code-fence)
825        //     silently round-trips through `Path::join` but the
826        //     embedded newline class is a sibling of the CRLF-at-
827        //     subprocess-argument injection vector
828        //     `is_git_repo_url` already closes on `:repo`.
829        //   - Tab (`0x09`) the canonical paste-from-aligned-table
830        //     footgun: the tab is invisible in most editors, and
831        //     the lacre embeds the value verbatim so two
832        //     paste-from-distinct-tables yield divergent lacres
833        //     across host editors that strip vs preserve tabs.
834        //   - DEL (`0x7F`) + every other `0x00..=0x1F` byte: the
835        //     paste-from-binary-blob shape every peer single-
836        //     token-shaped slot rejects under the same
837        //     `b < 0x20 || b == 0x7F` predicate.
838        //
839        // Mirrors the cascade discipline every prior `:caminho`
840        // arm establishes: `FonteCaminhoEmpty` →
841        // `FonteCaminhoAbsolute` → `FonteCaminhoTildeExpansion`
842        // → `FonteCaminhoVarExpansion` →
843        // `FonteCaminhoLeadingWhitespace` →
844        // `FonteCaminhoLeadingHyphen` → `FonteCaminhoControlChar`.
845        // The six leading-byte arms structurally precede the
846        // embedded-byte arm because the leading-byte shapes are
847        // the more self-locating diagnostic on values that probe
848        // as both (e.g. `:caminho "/etc/passwd\n"` surfaces the
849        // narrower `FonteCaminhoAbsolute` rather than the broader
850        // embedded-control-byte arm); the precedence pin matters
851        // at the diagnostic-shape level even though the empty /
852        // absolute / tilde / var arms are value-disjoint from a
853        // bare control byte (which would itself be a leading
854        // byte under the empty / absolute / tilde / var arms'
855        // leading-position semantics, but those arms guard the
856        // specific shell-convention characters `/` / `~` / `$`
857        // — a leading `0x01` byte falls through to this arm).
858        for &b in caminho.as_bytes() {
859            if b < 0x20 || b == 0x7F {
860                return Err(DepError::FonteCaminhoControlChar {
861                    nome: nome.to_string(),
862                    caminho: caminho.to_string(),
863                    byte: b,
864                });
865            }
866        }
867        // Reproducibility gate's Windows-path-separator arm. The four
868        // leading-byte arms (`/` / `~` / `$`) and the embedded-
869        // control-byte arm close the host-layout-leaking + paste-from-
870        // multiline-doc shapes; the leading-`\` / embedded-`\` byte is
871        // the orthogonal cross-host-OS-separator shape — same render-
872        // determinism axis, different semantic mechanism. POSIX
873        // [`std::path::Path`] treats `\` (0x5C) as a literal byte
874        // inside a single path component (so `..\caixa-teia` is one
875        // directory named literally `..\caixa-teia`, sibling of `.`
876        // and `..`); Windows [`std::path::Path`] treats `\` as a
877        // primary path separator equal to `/` (so `..\caixa-teia` is
878        // the parent's sibling directory `caixa-teia`). The lacre
879        // pipeline embeds the value verbatim in its per-dep content-
880        // address (`conteudo: format!("path:{caminho}")`, caixa-
881        // resolver/src/resolve.rs:189), so byte-identical caixa.lisp
882        // values resolve to two distinct directories across runner
883        // OSes — the same THEORY.md §V.2 render-determinism contract
884        // the absolute / tilde / var arms protect, here against the
885        // cross-host-OS-separator divergence vector. Even on POSIX-
886        // only resolvers (the canonical pleme-io substrate posture),
887        // a `..\caixa-teia` (the Windows-Explorer "copy as path" /
888        // PowerShell `Get-Location` paste-idiom footgun) silently
889        // passes every prior arm because `Path::is_absolute` returns
890        // false on `..` and `\` is neither a leading-byte sentinel
891        // nor a control byte, then the resolver folds the value
892        // through `Path::new(caminho).join(<file>)` looking for a
893        // literal `./..\caixa-teia` subdirectory and fails at
894        // resolve time with a non-self-locating `No such file or
895        // directory` error far from the source caixa.lisp.
896        //
897        // The peer single-token-shaped axes on the same git-CLI /
898        // path-CLI consumer cluster already reject `\` under the same
899        // Windows-path-leak banner: [`crate::render::is_git_ref_name`]
900        // line 1441 (`"must not contain \\ … the canonical Windows-
901        // path-leak footgun; use / for hierarchical refs"`) gates
902        // `:fonte :tag` / `:fonte :branch` against the same byte,
903        // and [`crate::render::is_gateway_api_http_path`] line 506
904        // includes `\` in the eleven-byte RFC-3986-reserved rejection
905        // set on `:entrada :paths`. Closing the same byte on `:fonte
906        // :caminho` makes the substrate-wide "no Windows path
907        // separator anywhere in a typed string slot" invariant
908        // structurally consistent across every path-shaped typed
909        // surface (the `:caminho` axis was the last typed string
910        // surface still admitting `\`).
911        //
912        // The arm fires AFTER the control-char arm because the
913        // control-char diagnostic is the more self-locating axis on
914        // values that probe as both (`"..\caixa\0teia"` carries both
915        // a `\` and a NUL — NUL is the load-bearing POSIX-syscall-
916        // rejected byte, so `FonteCaminhoControlChar` wins). Same
917        // narrower-diagnostic-first cascade discipline every prior
918        // arm establishes. A pure-`\` value
919        // (`"..\caixa-teia"` with no control bytes) falls through
920        // every prior arm and lands here.
921        for &b in caminho.as_bytes() {
922            if b == b'\\' {
923                return Err(DepError::fonte_caminho_backslash(nome, caminho));
924            }
925        }
926        // Reproducibility gate's shell-redirection arm. The 3a4e1d7 backslash
927        // arm closes the cross-host-OS-separator vector; `<` (`0x3C`) and `>`
928        // (`0x3E`) are the orthogonal shell-redirection sentinels — same
929        // paste-from-shell-prompt footgun class, different syntactic surface.
930        // POSIX `std::path::Path` treats `<` / `>` as literal bytes inside a
931        // single path component (so `../caixa-teia>output` is one directory
932        // named literally `../caixa-teia>output`, sibling of `.` and `..`),
933        // but every interactive shell (bash / zsh / fish / nushell) lexes
934        // `<` / `>` as input / output redirection operators — a `:caminho
935        // "../caixa-teia>build.log"` (the canonical "I pasted a shell
936        // pipeline that wrote build output and forgot to trim the redirect"
937        // footgun) or `:caminho "../<input.lisp"` (the symmetric input-
938        // redirection paste idiom) silently passes every prior arm because
939        // `Path::is_absolute` returns false, `<` / `>` are neither leading-
940        // byte sentinels nor control bytes nor `\`, and the value's last byte
941        // isn't `/`. The resolver folds the value through
942        // `Path::new(caminho).join(<file>)` looking for a literal
943        // `./..\caixa-teia>build.log` subdirectory and fails at resolve time
944        // with a non-self-locating `No such file or directory` error far
945        // from the source caixa.lisp.
946        //
947        // The lacre pipeline embeds the value verbatim in its per-dep
948        // content-address (`conteudo: format!("path:{caminho}")`,
949        // caixa-resolver/src/resolve.rs:189), so a `<` / `>` byte lands in
950        // the BLAKE3 closure and rides downstream as part of the build's
951        // identity. The bytes carry a second class of hazard the prior
952        // separator-shaped arms don't: every typed-string slot whose value
953        // ever flows verbatim into a shell-spawned subprocess (the caixa-
954        // resolver's `git clone` invocation, a future `feira tofu` shell-
955        // out, a future operator-side `nix flake check` spawn) is the
956        // canonical CRLF-at-subprocess-argument / shell-metachar injection
957        // surface that every peer single-token-shaped typed slot already
958        // closes. The peer path-shaped axis `[crate::render::is_gateway_api_http_path]`
959        // (caixa-core/src/render.rs:506) rejects `<` / `>` as part of its
960        // eleven-byte RFC-3986-reserved set on `:entrada :paths`, and the
961        // peer git-ref-shaped axis `[crate::render::is_git_ref_name]` rejects
962        // `<` / `>` on `:fonte :tag` / `:fonte :branch` under the same
963        // shell-metachar-injection banner. The `:caminho` axis was the last
964        // typed string surface still admitting these two bytes; this arm
965        // closes the gap so the substrate-wide "no shell-redirection
966        // metacharacter anywhere in a typed string slot" invariant is now
967        // structurally consistent across every path-shaped typed surface.
968        //
969        // The arm fires AFTER the control-char arm + backslash arm because
970        // both prior arms carry more self-locating diagnostics on values
971        // that probe as both (`"..\foo<bar"` carries both `\` and `<` — the
972        // cross-OS-separator divergence is the load-bearing axis, so the
973        // backslash arm wins; `"../foo\n<bar"` carries both LF and `<` —
974        // the POSIX-syscall-rejected byte is the load-bearing axis, so the
975        // control-char arm wins). The arm fires BEFORE the trailing-`/` arm
976        // because the embedded redirection byte is the more semantic-
977        // locating axis on probe-as-both values (`"../foo</"` ends in `/`
978        // but the load-bearing diagnostic is the embedded `<` shell-
979        // redirection — the trailing `/` is the secondary observation, and
980        // an author who removes the `<` is likely to also tab-strip the
981        // trailing separator).
982        for &b in caminho.as_bytes() {
983            if b == b'<' || b == b'>' {
984                return Err(DepError::FonteCaminhoShellRedirection {
985                    nome: nome.to_string(),
986                    caminho: caminho.to_string(),
987                    byte: b,
988                });
989            }
990        }
991        // Reproducibility gate's shell-pipe arm. The e457141 shell-redirection
992        // arm closes the `<` / `>` input/output redirection sentinels; `|`
993        // (`0x7C`) is the orthogonal shell-pipe sentinel — same paste-from-
994        // shell-prompt footgun class, different syntactic surface. POSIX
995        // `std::path::Path` treats `|` as a literal path-component byte (so
996        // `../caixa-teia|tee` is one directory named literally
997        // `../caixa-teia|tee`, sibling of `.` and `..`), but every interactive
998        // shell (bash / zsh / fish / nushell) lexes `|` as the pipe operator
999        // — a `:caminho "../caixa-teia | grep foo"` (the canonical "I copied a
1000        // `ls ../caixa-teia | grep` line out of a shell-history block and
1001        // forgot to trim the pipeline tail" footgun) or `:caminho
1002        // "../foo||bar"` (the symmetric "I copied a `cmd-a || cmd-b` short-
1003        // circuit OR line" idiom) silently passes every prior arm because
1004        // `Path::is_absolute` returns false on `..`, `|` is neither a leading-
1005        // byte sentinel nor a control byte nor `\` nor `<` / `>`, and the
1006        // value's last byte isn't `/`. The resolver folds the value through
1007        // `Path::new(caminho).join(<file>)` looking for a literal
1008        // `./../caixa-teia | grep foo` subdirectory and fails at resolve time
1009        // with a non-self-locating `No such file or directory` error far
1010        // from the source caixa.lisp.
1011        //
1012        // The lacre pipeline embeds the value verbatim in its per-dep
1013        // content-address (`conteudo: format!("path:{caminho}")`,
1014        // caixa-resolver/src/resolve.rs:189), so a `|` byte lands in the
1015        // BLAKE3 closure and rides downstream as part of the build's identity
1016        // into every shell-spawned subprocess (the caixa-resolver's `git
1017        // clone` invocation, a future `feira tofu` shell-out, a future
1018        // operator-side `nix flake check` spawn) as the canonical CRLF-at-
1019        // subprocess-argument / shell-metachar injection surface every peer
1020        // single-token-shaped typed slot already closes. The peer path-shaped
1021        // axis [`crate::render::is_gateway_api_http_path`]
1022        // (caixa-core/src/render.rs:506) rejects `|` as part of its eleven-
1023        // byte RFC-3986-reserved set on `:entrada :paths`. The `:caminho`
1024        // axis was the last typed path-string surface still admitting this
1025        // byte; this arm closes the gap so the substrate-wide "no shell-
1026        // composition metacharacter anywhere in a typed string slot that
1027        // flows verbatim into a shell-spawned subprocess" invariant extends
1028        // from shell-redirection (`<` / `>`) to shell-pipe (`|`) on the
1029        // `:caminho` axis.
1030        //
1031        // The arm fires AFTER the shell-redirection arm because the prior
1032        // arm's two-byte `byte: u8` payload is the more self-locating axis on
1033        // values that probe as both (`"../caixa-teia<input|tee"` carries both
1034        // `<` and `|` — the input-redirection-paste idiom is the load-bearing
1035        // root-cause edit, so `FonteCaminhoShellRedirection` wins; same
1036        // cascade discipline every prior `:caminho` arm establishes). The arm
1037        // fires BEFORE the trailing-`/` arm because the embedded pipe byte is
1038        // the more semantic-locating axis on probe-as-both values
1039        // (`"../foo|tee/"` ends in `/` but the load-bearing diagnostic is the
1040        // embedded `|` shell-pipe — the trailing `/` is the secondary
1041        // observation, and an author who removes the `|` is likely to also
1042        // tab-strip the trailing separator).
1043        for &b in caminho.as_bytes() {
1044            if b == b'|' {
1045                return Err(DepError::fonte_caminho_shell_pipe(nome, caminho));
1046            }
1047        }
1048        // Reproducibility gate's shell-command-separator arm. The 124106f
1049        // shell-pipe arm closes the `|` byte; `;` (`0x3B`) is the orthogonal
1050        // shell-command-separator sentinel — same paste-from-shell-prompt
1051        // footgun class, different syntactic surface. POSIX `std::path::Path`
1052        // treats `;` as a literal path-component byte (so
1053        // `../caixa-teia;rm -rf /` is one directory named literally
1054        // `../caixa-teia;rm -rf /`, sibling of `.` and `..`), but every
1055        // interactive shell (bash / zsh / fish / nushell) lexes `;` as the
1056        // sequential-command terminator that fires the next command
1057        // regardless of the prior command's exit status — a `:caminho
1058        // "../caixa-teia; rm -rf build"` (the canonical "I pasted a shell
1059        // one-liner that chained a cleanup tail after the directory name"
1060        // footgun) or `:caminho "../foo;;bar"` (the symmetric "I copied a
1061        // POSIX `case` arm's `;;` terminator into the middle of a path"
1062        // idiom) silently passes every prior arm because `Path::is_absolute`
1063        // returns false on `..`, `;` is neither a leading-byte sentinel nor a
1064        // control byte nor `\` nor `<` / `>` nor `|`, and the value's last
1065        // byte isn't `/`. The resolver folds the value through
1066        // `Path::new(caminho).join(<file>)` looking for a literal
1067        // `./../caixa-teia; rm -rf build` subdirectory and fails at resolve
1068        // time with a non-self-locating `No such file or directory` error far
1069        // from the source caixa.lisp.
1070        //
1071        // The lacre pipeline embeds the value verbatim in its per-dep
1072        // content-address (`conteudo: format!("path:{caminho}")`,
1073        // caixa-resolver/src/resolve.rs:189), so a `;` byte lands in the
1074        // BLAKE3 closure and rides downstream as part of the build's identity
1075        // into every shell-spawned subprocess (the caixa-resolver's `git
1076        // clone` invocation, a future `feira tofu` shell-out, a future
1077        // operator-side `nix flake check` spawn) as the canonical
1078        // shell-metachar injection surface every peer single-token-shaped
1079        // typed slot already closes. The peer path-shaped axis
1080        // [`crate::render::is_gateway_api_http_path`]
1081        // (caixa-core/src/render.rs:506) rejects `;` as part of its eleven-
1082        // byte RFC-3986-reserved set on `:entrada :paths`. The `:caminho`
1083        // axis was the last typed path-string surface still admitting this
1084        // byte; this arm closes the gap so the substrate-wide "no shell-
1085        // composition metacharacter anywhere in a typed string slot that
1086        // flows verbatim into a shell-spawned subprocess" invariant extends
1087        // from shell-pipe (`|`) to shell-command-separator (`;`) on the
1088        // `:caminho` axis.
1089        //
1090        // The arm fires AFTER the shell-pipe arm because the prior arm's
1091        // canonical-cmd-a-|-cmd-b shape is the more common shell-history
1092        // paste idiom on values that probe as both (`"../caixa-teia | tee;
1093        // rm"` carries both `|` and `;` — the pipeline-tail paste is the
1094        // load-bearing root-cause edit, so `FonteCaminhoShellPipe` wins; same
1095        // cascade discipline every prior `:caminho` arm establishes). The arm
1096        // fires BEFORE the trailing-`/` arm because the embedded
1097        // command-separator byte is the more semantic-locating axis on
1098        // probe-as-both values (`"../foo;rm/"` ends in `/` but the
1099        // load-bearing diagnostic is the embedded `;` shell-command-
1100        // separator — the trailing `/` is the secondary observation, and an
1101        // author who removes the `;` is likely to also tab-strip the trailing
1102        // separator).
1103        for &b in caminho.as_bytes() {
1104            if b == b';' {
1105                return Err(DepError::fonte_caminho_shell_semicolon(nome, caminho));
1106            }
1107        }
1108        // Reproducibility gate's shell-background / logical-AND arm. The
1109        // 05c358e shell-command-separator arm closes the `;` byte; `&`
1110        // (`0x26`) is the orthogonal shell-background / list-AND sentinel
1111        // — same paste-from-shell-prompt footgun class, different
1112        // syntactic surface. POSIX `std::path::Path` treats `&` as a
1113        // literal path-component byte (so `../caixa-teia & sleep 1` is
1114        // one directory named literally `../caixa-teia & sleep 1`,
1115        // sibling of `.` and `..`), but every interactive shell
1116        // (bash / zsh / fish / nushell) lexes `&` two ways:
1117        //
1118        //   - Single `&` as the background-task terminator that detaches
1119        //     the prior command into the background and returns control
1120        //     to the prompt immediately (the canonical `cmd &` idiom
1121        //     every long-running pipeline uses);
1122        //   - Double `&&` as the logical-AND list operator that fires
1123        //     the next command only if the prior command succeeded (the
1124        //     canonical `make && make install` idiom every build script
1125        //     carries).
1126        //
1127        // A `:caminho "../caixa-teia & sleep 1"` (the canonical "I
1128        // pasted a `cd path & sleep 1` background-launch into the
1129        // `:caminho` slot" footgun) or `:caminho "../caixa-teia && make"`
1130        // (the symmetric "I copied a `cd path && make` build chain"
1131        // idiom) silently passes every prior arm because
1132        // `Path::is_absolute` returns false on `..`, `&` is neither a
1133        // leading-byte sentinel nor a control byte nor `\` nor
1134        // `<` / `>` nor `|` nor `;`, and the value's last byte isn't `/`.
1135        // The resolver folds the value through
1136        // `Path::new(caminho).join(<file>)` looking for a literal
1137        // `./../caixa-teia & sleep 1` subdirectory and fails at resolve
1138        // time with a non-self-locating `No such file or directory`
1139        // error far from the source caixa.lisp.
1140        //
1141        // The lacre pipeline embeds the value verbatim in its per-dep
1142        // content-address (`conteudo: format!("path:{caminho}")`,
1143        // caixa-resolver/src/resolve.rs:189), so an `&` byte lands in
1144        // the BLAKE3 closure and rides downstream as part of the build's
1145        // identity into every shell-spawned subprocess (the
1146        // caixa-resolver's `git clone` invocation, a future `feira tofu`
1147        // shell-out, a future operator-side `nix flake check` spawn) as
1148        // the canonical shell-metachar injection surface every peer
1149        // single-token-shaped typed slot already closes. The peer
1150        // path-shaped axis [`crate::render::is_gateway_api_http_path`]
1151        // (caixa-core/src/render.rs:506) rejects `&` as part of its
1152        // eleven-byte RFC-3986-reserved set on `:entrada :paths`. The
1153        // `:caminho` axis was the last typed path-string surface still
1154        // admitting this byte; this arm closes the gap so the
1155        // substrate-wide "no shell-composition metacharacter anywhere
1156        // in a typed string slot that flows verbatim into a
1157        // shell-spawned subprocess" invariant extends from
1158        // shell-command-separator (`;`) to shell-background /
1159        // logical-AND (`&`) on the `:caminho` axis.
1160        //
1161        // The arm fires AFTER the shell-command-separator arm because
1162        // the prior arm's `cmd-a; cmd-b` shape is the more common
1163        // shell-history paste idiom on values that probe as both
1164        // (`"../caixa-teia; rm & sleep"` carries both `;` and `&` — the
1165        // command-separator-tail paste is the load-bearing root-cause
1166        // edit, so `FonteCaminhoShellSemicolon` wins; same cascade
1167        // discipline every prior `:caminho` arm establishes). The arm
1168        // fires BEFORE the trailing-`/` arm because the embedded
1169        // background / list-AND byte is the more semantic-locating axis
1170        // on probe-as-both values (`"../foo&bar/"` ends in `/` but the
1171        // load-bearing diagnostic is the embedded `&` shell-background
1172        // / logical-AND metachar — the trailing `/` is the secondary
1173        // observation, and an author who removes the `&` is likely to
1174        // also tab-strip the trailing separator).
1175        for &b in caminho.as_bytes() {
1176            if b == b'&' {
1177                return Err(DepError::fonte_caminho_shell_background(nome, caminho));
1178            }
1179        }
1180        // Reproducibility gate's shell-command-substitution arm. The
1181        // e12e4f3 shell-background / logical-AND arm closes the `&`
1182        // byte; the backtick (`0x60`) is the orthogonal POSIX legacy
1183        // command-substitution sentinel — every POSIX shell (sh /
1184        // bash / zsh / dash / ksh / fish / nushell) lexes the byte as
1185        // the canonical legacy wrapper that runs the enclosed command
1186        // and substitutes its standard-output verbatim into the
1187        // surrounding word (a `whoami` wrapped in backticks expands
1188        // to the current user's name; a `cat /etc/passwd` wrapped in
1189        // backticks expands to the file's contents — the canonical
1190        // CWE-78 shell-command-injection vector every shell-side
1191        // hardening guide enumerates first). POSIX
1192        // `std::path::Path` treats backtick as a literal path-
1193        // component byte (so `../caixa-teia/<backtick>whoami<backtick>`
1194        // is one directory named literally that, sibling of `.` and
1195        // `..`).
1196        //
1197        // A `:caminho "../caixa-teia/<backtick>whoami<backtick>"` (the
1198        // canonical "I pasted a shell one-liner carrying a backticked
1199        // `whoami` command-substitution expansion into the `:caminho`
1200        // slot" footgun) or `:caminho "<backtick>pwd<backtick>/caixa-
1201        // teia"` (the symmetric "I copied a `<backtick>pwd<backtick>/
1202        // path` working-directory expansion") silently passes every
1203        // prior arm because `Path::is_absolute` returns false on
1204        // `..`, the backtick byte is neither a leading-byte sentinel
1205        // (the f4efe9c `FonteCaminhoVarExpansion` arm catches the
1206        // modern `$()` form at leading position only; backtick is
1207        // the orthogonal legacy form) nor a control byte nor `\` nor
1208        // `<` / `>` nor `|` nor `;` nor `&`, and the value's last
1209        // byte isn't `/`. The resolver folds the value through
1210        // `Path::new(caminho).join(<file>)` looking for a literal
1211        // subdirectory whose name embeds the backticked token and
1212        // fails at resolve time with a non-self-locating `No such
1213        // file or directory` error far from the source caixa.lisp.
1214        //
1215        // The lacre pipeline embeds the value verbatim in its per-
1216        // dep content-address (`conteudo: format!("path:{caminho}")`,
1217        // caixa-resolver/src/resolve.rs:189), so a backtick byte
1218        // lands in the BLAKE3 closure and rides downstream as part
1219        // of the build's identity into every shell-spawned
1220        // subprocess (the caixa-resolver's `git clone` invocation, a
1221        // future `feira tofu` shell-out, a future operator-side
1222        // `nix flake check` spawn) as the canonical shell-metachar
1223        // injection surface every peer single-token-shaped typed
1224        // slot already closes. The peer path-shaped axis
1225        // [`crate::render::is_gateway_api_http_path`]
1226        // (caixa-core/src/render.rs:506) rejects backtick as part of
1227        // its eleven-byte RFC-3986-reserved set on `:entrada
1228        // :paths`. The `:caminho` axis was the last typed path-
1229        // string surface still admitting this byte; this arm closes
1230        // the gap so the substrate-wide "no shell-composition
1231        // metacharacter anywhere in a typed string slot that flows
1232        // verbatim into a shell-spawned subprocess" invariant
1233        // extends from shell-background / logical-AND (`&`) to
1234        // shell-command-substitution (backtick) on the `:caminho`
1235        // axis.
1236        //
1237        // The arm fires AFTER the shell-background arm because the
1238        // prior arm's `cmd & sleep` shape is the more common shell-
1239        // history paste idiom on values that probe as both (a
1240        // `"../caixa-teia & <backtick>whoami<backtick>"` carries
1241        // both `&` and a backtick — the background-launch tail is
1242        // the load-bearing root-cause edit, so
1243        // `FonteCaminhoShellBackground` wins; same cascade
1244        // discipline every prior `:caminho` arm establishes). The
1245        // arm fires BEFORE the trailing-`/` arm because the
1246        // embedded command-substitution byte is the more semantic-
1247        // locating axis on probe-as-both values (a
1248        // `"../<backtick>whoami<backtick>/"` ends in `/` but the
1249        // load-bearing diagnostic is the embedded backtick shell-
1250        // command-substitution metachar — the trailing `/` is the
1251        // secondary observation, and an author who removes the
1252        // backtick is likely to also tab-strip the trailing
1253        // separator).
1254        for &b in caminho.as_bytes() {
1255            if b == b'`' {
1256                return Err(DepError::fonte_caminho_shell_command_substitution(
1257                    nome, caminho,
1258                ));
1259            }
1260        }
1261        // Reproducibility gate's shell-glob arm. The c4d62b3 shell-command-
1262        // substitution arm closes the backtick byte; `*` (`0x2A`) and `?`
1263        // (`0x3F`) are the orthogonal POSIX glob-expansion sentinels — same
1264        // paste-from-shell-prompt footgun class, different syntactic surface.
1265        // Every POSIX shell (sh / bash / zsh / dash / ksh / fish / nushell)
1266        // lexes `*` and `?` as pathname-expansion wildcards: `*` matches any
1267        // sequence of characters in a path component (including the empty
1268        // sequence), `?` matches exactly one character. POSIX
1269        // `std::path::Path` treats both bytes as literal path-component bytes
1270        // (so `../caixa-teia/*.lisp` is one directory named literally
1271        // `../caixa-teia/*.lisp`, sibling of `.` and `..`).
1272        //
1273        // A `:caminho "../caixa-teia/*"` (the canonical "I pasted a
1274        // `ls ../caixa-teia/*` shell-listing one-liner into the `:caminho`
1275        // slot" footgun) or `:caminho "../foo?"` (the symmetric "I copied a
1276        // `rm foo?` single-char-wildcard removal idiom") silently passes
1277        // every prior arm because `Path::is_absolute` returns false on `..`,
1278        // `*` / `?` are neither leading-byte sentinels nor control bytes nor
1279        // `\` nor `<` / `>` nor `|` nor `;` nor `&` nor backtick, and the
1280        // value's last byte isn't `/`. The resolver folds the value through
1281        // `Path::new(caminho).join(<file>)` looking for a literal
1282        // `./../caixa-teia/*` subdirectory and fails at resolve time with a
1283        // non-self-locating `No such file or directory` error far from the
1284        // source caixa.lisp.
1285        //
1286        // The lacre pipeline embeds the value verbatim in its per-dep
1287        // content-address (`conteudo: format!("path:{caminho}")`,
1288        // caixa-resolver/src/resolve.rs:189), so a `*` or `?` byte lands in
1289        // the BLAKE3 closure and rides downstream as part of the build's
1290        // identity into every shell-spawned subprocess (the caixa-resolver's
1291        // `git clone` invocation, a future `feira tofu` shell-out, a future
1292        // operator-side `nix flake check` spawn) as the canonical
1293        // shell-metachar / pathname-expansion surface every peer
1294        // single-token-shaped typed slot already closes. The peer path-shaped
1295        // axis [`crate::render::is_gateway_api_http_path`]
1296        // (caixa-core/src/render.rs:506) rejects `*` and `?` as part of its
1297        // eleven-byte RFC-3986-reserved set on `:entrada :paths`. The
1298        // `:caminho` axis was the last typed path-string surface still
1299        // admitting these two bytes; this arm closes the gap so the
1300        // substrate-wide "no shell-composition / glob-expansion
1301        // metacharacter anywhere in a typed string slot that flows verbatim
1302        // into a shell-spawned subprocess" invariant extends from
1303        // shell-command-substitution (backtick) to glob-expansion
1304        // (`*` / `?`) on the `:caminho` axis.
1305        //
1306        // The arm fires AFTER the backtick arm because the prior arm's
1307        // CWE-78 shell-command-injection vector is the load-bearing
1308        // diagnostic on values that probe as both (a `"../`whoami`/*"`
1309        // carries both backtick and `*` — the command-substitution paste
1310        // is the load-bearing root-cause edit, so
1311        // `FonteCaminhoShellCommandSubstitution` wins; same cascade
1312        // discipline every prior `:caminho` arm establishes). The arm
1313        // fires BEFORE the trailing-`/` arm because the embedded glob
1314        // byte is the more semantic-locating axis on probe-as-both values
1315        // (`"../foo*/"` ends in `/` but the load-bearing diagnostic is the
1316        // embedded `*` glob metachar — the trailing `/` is the secondary
1317        // observation, and an author who removes the `*` is likely to
1318        // also tab-strip the trailing separator).
1319        for &b in caminho.as_bytes() {
1320            if b == b'*' || b == b'?' {
1321                return Err(DepError::FonteCaminhoShellGlob {
1322                    nome: nome.to_string(),
1323                    caminho: caminho.to_string(),
1324                    byte: b,
1325                });
1326            }
1327        }
1328        // Reproducibility gate's shell-subshell-grouping arm. The cf9034b
1329        // shell-glob arm closes the `*` / `?` pathname-expansion sentinels;
1330        // `(` (`0x28`) and `)` (`0x29`) are the orthogonal POSIX subshell-
1331        // grouping sentinels — same paste-from-shell-prompt footgun class,
1332        // different syntactic surface. Every POSIX shell (sh / bash / zsh /
1333        // dash / ksh / fish / nushell) lexes the parenthesis pair as the
1334        // subshell-grouping operator: `(<cmd>)` runs `<cmd>` in a child
1335        // shell with a fresh environment scope (the canonical sandboxing
1336        // idiom every shell-history `(cd <path> && <cmd>)` one-liner uses
1337        // to scope a `cd` to one subshell without disturbing the parent's
1338        // working directory), and `$(<cmd>)` is the modern Bourne
1339        // command-substitution shape the upstream f4efe9c
1340        // `FonteCaminhoVarExpansion` arm closes the leading `$` byte of —
1341        // the closing `)` byte completes that substitution shape and must
1342        // be refused on the same axis (peer with the
1343        // [`crate::render::is_git_repo_url`] 3b99147 arm that closes the
1344        // same byte-pair on the sibling `:fonte :repo` axis under the
1345        // same shell-subshell-grouping + RFC-3986-sub-delims banner).
1346        // POSIX `std::path::Path` treats both bytes as literal path-
1347        // component bytes (so `../caixa-teia/(date)` is one directory
1348        // named literally `../caixa-teia/(date)`, sibling of `.` and
1349        // `..`).
1350        //
1351        // A `:caminho "../caixa-teia/$(date)/build"` (the canonical "I
1352        // pasted a `cd ../caixa-teia/$(date)/build` shell-history one-
1353        // liner whose modern command-substitution expansion lands the
1354        // current date as a subdirectory name" footgun) or `:caminho
1355        // "../(cd foo && pwd)/caixa-teia"` (the symmetric "I copied a
1356        // `(cd foo && pwd)` subshell-grouping working-directory probe
1357        // idiom") silently passes every prior arm because
1358        // `Path::is_absolute` returns false on `..`, `(` / `)` are
1359        // neither leading-byte sentinels nor control bytes nor `\` nor
1360        // `<` / `>` nor `|` nor `;` nor `&` nor backtick nor `*` / `?`,
1361        // and the value's last byte isn't `/`. The resolver folds the
1362        // value through `Path::new(caminho).join(<file>)` looking for a
1363        // literal `./../caixa-teia/$(date)/build` subdirectory and fails
1364        // at resolve time with a non-self-locating `No such file or
1365        // directory` error far from the source caixa.lisp.
1366        //
1367        // The lacre pipeline embeds the value verbatim in its per-dep
1368        // content-address (`conteudo: format!("path:{caminho}")`,
1369        // caixa-resolver/src/resolve.rs:189), so a `(` or `)` byte lands
1370        // in the BLAKE3 closure and rides downstream as part of the
1371        // build's identity into every shell-spawned subprocess (the
1372        // caixa-resolver's `git clone` invocation, a future `feira tofu`
1373        // shell-out, a future operator-side `nix flake check` spawn) as
1374        // the canonical shell-metachar / subshell-grouping surface every
1375        // peer single-token-shaped typed slot already closes. The peer
1376        // git-source axis [`crate::render::is_git_repo_url`] (3b99147)
1377        // rejects the same byte pair on `:fonte :repo` under the same
1378        // shell-subshell-grouping / RFC-3986-sub-delims banner. The
1379        // `:caminho` axis was the last typed path-string surface still
1380        // admitting these two bytes;
1381        // this arm closes the gap so the substrate-wide "no shell-
1382        // composition metacharacter anywhere in a typed string slot that
1383        // flows verbatim into a shell-spawned subprocess" invariant
1384        // extends from shell-glob (`*` / `?`) to shell-subshell-grouping
1385        // (`(` / `)`) on the `:caminho` axis. Together with the f4efe9c
1386        // leading-`$` arm, the typed `:caminho` accepted set now
1387        // structurally excludes the entire modern Bourne
1388        // command-substitution surface — leading `$` closes the
1389        // leading byte of every `$(<cmd>)` shape, this arm closes the
1390        // trailing `)` boundary.
1391        //
1392        // The arm fires AFTER the shell-glob arm because the prior arm's
1393        // `*` / `?` pathname-expansion shape is the more common shell-
1394        // history paste idiom on values that probe as both
1395        // (`"../caixa-teia/*(date)"` carries both `*` and `(` — the
1396        // glob-paste-tail is the load-bearing root-cause edit, so
1397        // `FonteCaminhoShellGlob` wins; same cascade discipline every
1398        // prior `:caminho` arm establishes). The arm fires BEFORE the
1399        // trailing-`/` arm because the embedded subshell-grouping byte
1400        // is the more semantic-locating axis on probe-as-both values
1401        // (`"../foo(date)/"` ends in `/` but the load-bearing diagnostic
1402        // is the embedded `(` shell-subshell-grouping metachar — the
1403        // trailing `/` is the secondary observation, and an author who
1404        // removes the `(` is likely to also tab-strip the trailing
1405        // separator).
1406        for &b in caminho.as_bytes() {
1407            if b == b'(' || b == b')' {
1408                return Err(DepError::FonteCaminhoShellSubshellGrouping {
1409                    nome: nome.to_string(),
1410                    caminho: caminho.to_string(),
1411                    byte: b,
1412                });
1413            }
1414        }
1415        // Reproducibility gate's shell-brace-expansion arm. The 0633c91
1416        // shell-subshell-grouping arm closes `(` / `)`; `{` (`0x7b`) and
1417        // `}` (`0x7d`) are the orthogonal shell-brace-expansion /
1418        // URI-Template-placeholder byte pair — same paste-from-shell-
1419        // prompt + paste-from-templated-doc footgun class, different
1420        // syntactic surface. Every POSIX-derived shell that implements
1421        // brace expansion (bash / zsh / ksh / fish; the canonical
1422        // `mkdir -p ../{caixa-teia,caixa-helm,caixa-flux}` /
1423        // `cp file{,.bak}` idiom every shell-history block carries)
1424        // expands `{a,b,c}` to the cross-product of its comma-separated
1425        // members and `{1..10}` to the integer range; RFC 6570 reserves
1426        // the matched pair for URI Template placeholders (the canonical
1427        // `https://{host}/{org}/{repo}` substitution shape every
1428        // OpenAPI / Swagger / Postman / GitHub Octokit client /
1429        // Helm chart-URL fragment / Mustache `{{org}}` doubled-brace
1430        // form carries), and Tera / Jinja2 / Handlebars / Go html/template
1431        // every IaC tool (Helm, Kustomize, Terraform's `${var}` cousin
1432        // shape) emit. POSIX `std::path::Path` treats both bytes as
1433        // literal path-component bytes (so `../{caixa-teia,caixa-helm}`
1434        // is one directory named literally `../{caixa-teia,caixa-helm}`,
1435        // sibling of `.` and `..`).
1436        //
1437        // A `:caminho "../{caixa-teia,caixa-helm}/build"` (the canonical
1438        // "I pasted a `cd ../{caixa-teia,caixa-helm}` shell brace-
1439        // expansion one-liner that fans across two siblings" footgun)
1440        // or `:caminho "../{{org}}/caixa-teia"` (the symmetric "I copied
1441        // a `{{org}}` Mustache / Helm template placeholder out of a
1442        // README quick-start and forgot to substitute") silently passes
1443        // every prior arm because `Path::is_absolute` returns false on
1444        // `..`, `{` / `}` are neither leading-byte sentinels nor control
1445        // bytes nor `\` nor `<` / `>` nor `|` nor `;` nor `&` nor
1446        // backtick nor `*` / `?` nor `(` / `)`, and the value's last
1447        // byte isn't `/`. The resolver folds the value through
1448        // `Path::new(caminho).join(<file>)` looking for a literal
1449        // `./../{caixa-teia,caixa-helm}/build` subdirectory and fails
1450        // at resolve time with a non-self-locating `No such file or
1451        // directory` error far from the source caixa.lisp.
1452        //
1453        // The lacre pipeline embeds the value verbatim in its per-dep
1454        // content-address (`conteudo: format!("path:{caminho}")`,
1455        // caixa-resolver/src/resolve.rs:189), so a `{` or `}` byte
1456        // lands in the BLAKE3 closure and rides downstream as part of
1457        // the build's identity into every shell-spawned subprocess
1458        // (the caixa-resolver's `git clone` invocation, a future
1459        // `feira tofu` shell-out, a future operator-side `nix flake
1460        // check` spawn) as the canonical shell-metachar / brace-
1461        // expansion surface every peer single-token-shaped typed
1462        // slot already closes. The peer git-source axis
1463        // [`crate::render::is_git_repo_url`] (42d8f9d — the URI Template
1464        // placeholder arm) rejects the same byte pair on `:fonte :repo`
1465        // under the same RFC-3986-'delims' / RFC-6570-URI-Template /
1466        // shell-brace-expansion banner. The `:caminho` axis was the last
1467        // typed path-string surface still admitting these two bytes;
1468        // this arm closes the gap so the substrate-wide "no shell-
1469        // composition metacharacter anywhere in a typed string slot
1470        // that flows verbatim into a shell-spawned subprocess"
1471        // invariant extends from shell-subshell-grouping (`(` / `)`)
1472        // to shell-brace-expansion (`{` / `}`) on the `:caminho` axis,
1473        // and the typed `:caminho` accepted set now also structurally
1474        // excludes the URI Template / templating-engine placeholder
1475        // surface that would silently round-trip through any
1476        // downstream IaC templating-engine layer.
1477        //
1478        // The arm fires AFTER the shell-subshell-grouping arm because
1479        // the prior arm's `(` / `)` shape is the more semantic-locating
1480        // axis on values that probe as both (`"../{cd foo}(date)"`
1481        // carries both `{` and `(` — the parenthesis-pair is the
1482        // load-bearing modern-Bourne-command-substitution surface the
1483        // prior arm closes; same cascade discipline every prior
1484        // `:caminho` arm establishes). The arm fires BEFORE the
1485        // trailing-`/` arm because the embedded brace-expansion byte
1486        // is the more semantic-locating axis on probe-as-both values
1487        // (`"../{caixa-teia,caixa-helm}/"` ends in `/` but the
1488        // load-bearing diagnostic is the embedded `{` brace-expansion
1489        // metachar — the trailing `/` is the secondary observation,
1490        // and an author who removes the `{` is likely to also tab-
1491        // strip the trailing separator).
1492        for &b in caminho.as_bytes() {
1493            if b == b'{' || b == b'}' {
1494                return Err(DepError::FonteCaminhoShellBraceExpansion {
1495                    nome: nome.to_string(),
1496                    caminho: caminho.to_string(),
1497                    byte: b,
1498                });
1499            }
1500        }
1501        // Reproducibility gate's shell-bracket-expansion arm. The 598b770
1502        // shell-brace-expansion arm closes `{` / `}`; `[` (`0x5b`) and
1503        // `]` (`0x5d`) are the orthogonal POSIX glob-character-class /
1504        // shell-`test`-builtin byte pair — same paste-from-shell-prompt
1505        // footgun class, different syntactic surface. Every POSIX shell
1506        // (sh / bash / zsh / dash / ksh / fish / nushell) lexes the
1507        // bracket pair as the glob character-class operator: `[abc]`
1508        // matches one of `a`, `b`, `c`; `[a-z]` matches any lowercase
1509        // ASCII letter; `[^x]` negates (the canonical
1510        // `ls *.[ch]` C-source-file glob and the `cd ../[a-z]*`
1511        // lowercase-sibling glob every shell-history block carries —
1512        // the orthogonal axis to the cf9034b `*` / `?` shell-glob arm
1513        // closing the unbounded pathname-expansion sentinels). The
1514        // bracket pair additionally carries the POSIX `test` /
1515        // `[` builtin command (`[ -d ../caixa-teia ] && cd ...` —
1516        // the canonical idiom every shell-script conditional uses) and
1517        // bash's `[[ ... ]]` extended-test grammar. Beyond shell, the
1518        // bracket pair is the TOML inline-array delimiter
1519        // (`features = ["a", "b"]` — the canonical paste-from-Cargo-
1520        // manifest cross-idiom-leak vector), the YAML flow-sequence
1521        // delimiter (`paths: [/a, /b]` — the canonical paste-from-
1522        // values.yaml cross-idiom leak), the JSON array delimiter,
1523        // and the POSIX-ERE / PCRE bracket-expression / character-
1524        // class anchor (the canonical paste-from-regex-doc shape).
1525        // POSIX `std::path::Path` treats both bytes as literal path-
1526        // component bytes (so `../[caixa-teia]` is one directory
1527        // named literally `../[caixa-teia]`, sibling of `.` and
1528        // `..`).
1529        //
1530        // A `:caminho "../caixa-[a-z]/build"` (the canonical "I
1531        // pasted a `cd ../caixa-[a-z]/build` glob-character-class
1532        // one-liner that matches every lowercase-sibling-suffix
1533        // sibling directory" footgun), `:caminho "../[caixa-teia]/
1534        // build"` (the symmetric "I pasted a TOML inline-array /
1535        // YAML flow-sequence shape out of an aligned manifest"
1536        // idiom), or `:caminho "../caixa-[ch]"` (the canonical
1537        // `*.[ch]` C-source character-class paste-from-shell-history
1538        // shape) silently passes every prior arm because
1539        // `Path::is_absolute` returns false on `..`, `[` / `]` are
1540        // neither leading-byte sentinels nor control bytes nor `\`
1541        // nor `<` / `>` nor `|` nor `;` nor `&` nor backtick nor
1542        // `*` / `?` nor `(` / `)` nor `{` / `}`, and the value's
1543        // last byte isn't `/`. The resolver folds the value through
1544        // `Path::new(caminho).join(<file>)` looking for a literal
1545        // `./../caixa-[a-z]/build` subdirectory and fails at resolve
1546        // time with a non-self-locating `No such file or directory`
1547        // error far from the source caixa.lisp.
1548        //
1549        // The lacre pipeline embeds the value verbatim in its per-dep
1550        // content-address (`conteudo: format!("path:{caminho}")`,
1551        // caixa-resolver/src/resolve.rs:189), so a `[` or `]` byte
1552        // lands in the BLAKE3 closure and rides downstream as part of
1553        // the build's identity into every shell-spawned subprocess
1554        // (the caixa-resolver's `git clone` invocation, a future
1555        // `feira tofu` shell-out, a future operator-side `nix flake
1556        // check` spawn) as the canonical shell-metachar / glob-
1557        // character-class / TOML-array surface every peer single-
1558        // token-shaped typed slot already closes. The `:caminho` axis
1559        // was the last typed path-string surface still admitting
1560        // these two bytes; this arm closes the gap so the substrate-
1561        // wide "no shell-composition metacharacter anywhere in a
1562        // typed string slot that flows verbatim into a shell-spawned
1563        // subprocess" invariant extends from shell-brace-expansion
1564        // (`{` / `}`) to shell-bracket-expansion (`[` / `]`) on the
1565        // `:caminho` axis. Together with the cf9034b `*` / `?` arm,
1566        // the typed `:caminho` accepted set now structurally excludes
1567        // the entire POSIX pathname-expansion / glob surface —
1568        // unbounded glob (`*` / `?`) AND bounded character-class
1569        // (`[abc]` / `[a-z]`).
1570        //
1571        // The arm fires AFTER the shell-brace-expansion arm because
1572        // the prior arm's `{` / `}` shape is the more semantic-
1573        // locating axis on values that probe as both
1574        // (`"../{a,b}[ch]"` carries both `{` and `[` — the brace-
1575        // expansion fan is the load-bearing root-cause edit, so
1576        // `FonteCaminhoShellBraceExpansion` wins; same cascade
1577        // discipline every prior `:caminho` arm establishes). The arm
1578        // fires BEFORE the trailing-`/` arm because the embedded
1579        // bracket-expansion byte is the more semantic-locating axis
1580        // on probe-as-both values (`"../[a-z]/"` ends in `/` but the
1581        // load-bearing diagnostic is the embedded `[` glob-character-
1582        // class metachar — the trailing `/` is the secondary
1583        // observation, and an author who removes the `[` is likely
1584        // to also tab-strip the trailing separator).
1585        for &b in caminho.as_bytes() {
1586            if b == b'[' || b == b']' {
1587                return Err(DepError::FonteCaminhoShellBracketExpansion {
1588                    nome: nome.to_string(),
1589                    caminho: caminho.to_string(),
1590                    byte: b,
1591                });
1592            }
1593        }
1594        // Reproducibility gate's shell-quote-grouping arm. The 986963b
1595        // shell-bracket-expansion arm closes `[` / `]`; `'` (`0x27`) and
1596        // `"` (`0x22`) are the orthogonal POSIX shell-string-literal
1597        // delimiter pair — same paste-from-shell-prompt footgun class,
1598        // different syntactic surface. Every POSIX shell (sh / bash /
1599        // zsh / dash / ksh / fish / nushell) lexes the pair as the
1600        // string-literal quoting operator: `'…'` is the strong
1601        // (no-expansion) single-quoted string and `"…"` is the weak
1602        // (variable-/command-substitution-preserving) double-quoted
1603        // string — the canonical `cd '../caixa-teia'` shell-history
1604        // idiom every path-with-embedded-whitespace paste block carries,
1605        // and the symmetric `git clone "$REPO"` weak-quoted CI-manifest
1606        // shape. Beyond shell, the two bytes carry the JSON string-literal
1607        // delimiter (`"key": "value"` — the canonical paste-from-JSON-
1608        // config cross-idiom-leak vector), the YAML double-quoted +
1609        // single-quoted flow-scalar delimiters (`path: "../caixa-teia"`
1610        // — the canonical paste-from-values.yaml / paste-from-K8s-YAML-
1611        // manifest cross-idiom leak), the TOML basic + literal string
1612        // delimiters (`path = "../caixa-teia"` — the canonical paste-
1613        // from-Cargo-manifest cross-idiom-leak vector), the tatara-lisp
1614        // string-literal delimiter itself (`(:caminho "../caixa-teia")`
1615        // — the canonical "I copied the entire `:caminho "..."` slot
1616        // rather than just the string body" author-surface footgun),
1617        // and RFC 3986 §2.2's `gen-delims` / `sub-delims` grammar which
1618        // excludes both bytes from the `unreserved / pct-encoded /
1619        // sub-delims / ":" / "@"` `pchar` production. POSIX
1620        // `std::path::Path` treats both bytes as literal path-component
1621        // bytes (so `../"caixa-teia"` is one directory named literally
1622        // `../"caixa-teia"`, sibling of `.` and `..`).
1623        //
1624        // A `:caminho "'../caixa-teia'"` (the canonical "I pasted a
1625        // `cd '../caixa-teia'` shell-history one-liner whose strong-
1626        // quoting preserved the sibling-workspace path verbatim across
1627        // the whitespace paste boundary" footgun), `:caminho
1628        // "\"../caixa-teia\""` (the symmetric weak-quoted paste-from-
1629        // JSON / paste-from-YAML flow-scalar / paste-from-TOML basic-
1630        // string / paste-from-tatara-lisp string-literal cross-idiom-
1631        // leak shape), or `:caminho "../\"caixa-teia\""` (the embedded-
1632        // quote "I pasted a JSON key-value pair fragment into the
1633        // middle of the path" idiom) silently passes every prior arm
1634        // because `Path::is_absolute` returns false on `..` / `'` /
1635        // `"`, `'` / `"` are neither leading-byte sentinels nor
1636        // control bytes nor `\` nor `<` / `>` nor `|` nor `;` nor `&`
1637        // nor backtick nor `*` / `?` nor `(` / `)` nor `{` / `}` nor
1638        // `[` / `]`, and the value's last byte isn't `/`. The resolver
1639        // folds the value through `Path::new(caminho).join(<file>)`
1640        // looking for a literal `./'../caixa-teia'` subdirectory and
1641        // fails at resolve time with a non-self-locating `No such file
1642        // or directory` error far from the source caixa.lisp.
1643        //
1644        // The lacre pipeline embeds the value verbatim in its per-dep
1645        // content-address (`conteudo: format!("path:{caminho}")`,
1646        // caixa-resolver/src/resolve.rs:189), so a `'` or `"` byte
1647        // lands in the BLAKE3 closure and rides downstream as part of
1648        // the build's identity into every shell-spawned subprocess
1649        // (the caixa-resolver's `git clone` invocation, a future
1650        // `feira tofu` shell-out, a future operator-side `nix flake
1651        // check` spawn) as the canonical shell-metachar / string-
1652        // literal-delimiter surface every peer single-token-shaped
1653        // typed slot already closes. The peer `:fonte :repo` axis
1654        // closes both bytes under the same shell-quote-grouping /
1655        // RFC-3986-sub-delims banner (e7a109f `'` shell-single-quote
1656        // + 4267d8b `"` shell-double-quote on `is_git_repo_url`). The
1657        // `:caminho` axis was the last typed path-string surface
1658        // still admitting these two bytes; this arm closes the gap
1659        // so the substrate-wide "no shell-composition metacharacter
1660        // anywhere in a typed string slot that flows verbatim into a
1661        // shell-spawned subprocess" invariant extends from shell-
1662        // bracket-expansion (`[` / `]`) to shell-quote-grouping (`'`
1663        // / `"`) on the `:caminho` axis. Together with the peer
1664        // JSON / YAML / TOML string-literal delimiters closing at
1665        // this arm and the 598b770 `{` / `}` brace-expansion arm
1666        // closing the templating-engine-placeholder boundary, the
1667        // typed `:caminho` accepted set now structurally excludes
1668        // the entire cross-config-DSL string-literal / templating
1669        // paste-from-aligned-manifest cross-idiom-leak surface that
1670        // would silently round-trip through any downstream JSON /
1671        // YAML / TOML / HCL / tatara-lisp parsing layer.
1672        //
1673        // The arm fires AFTER the shell-bracket-expansion arm because
1674        // the prior arm's `[` / `]` shape is the more semantic-
1675        // locating axis on values that probe as both (`"../[a-z]'x'"`
1676        // carries both `[` and `'` — the glob-character-class
1677        // expansion is the load-bearing root-cause edit, so
1678        // `FonteCaminhoShellBracketExpansion` wins; same cascade
1679        // discipline every prior `:caminho` arm establishes). The arm
1680        // fires BEFORE the trailing-`/` arm because the embedded
1681        // quote-grouping byte is the more semantic-locating axis on
1682        // probe-as-both values (`"../'caixa-teia'/"` ends in `/` but
1683        // the load-bearing diagnostic is the embedded `'` shell-
1684        // string-literal metachar — the trailing `/` is the secondary
1685        // observation, and an author who removes the `'` is likely to
1686        // also tab-strip the trailing separator).
1687        for &b in caminho.as_bytes() {
1688            if b == b'\'' || b == b'"' {
1689                return Err(DepError::FonteCaminhoShellQuoteGrouping {
1690                    nome: nome.to_string(),
1691                    caminho: caminho.to_string(),
1692                    byte: b,
1693                });
1694            }
1695        }
1696        // Reproducibility gate's shell-comment / URL-fragment / YAML-comment arm.
1697        // The d14cbc5 shell-quote-grouping arm closes `'` / `"`; `#` (`0x23`) is
1698        // the orthogonal "byte at which four distinct downstream parsers all
1699        // truncate the value at the first occurrence" surface, and no prior arm
1700        // has covered it on the `:caminho` axis. Every POSIX shell (sh / bash /
1701        // zsh / dash / ksh / fish / nushell) lexes an unquoted `#` at the head
1702        // of a word (or after unquoted whitespace) as the comment-lead: from
1703        // that byte to the end of the physical line is a comment discarded
1704        // before command parsing (`cd ../caixa-teia  # legacy sibling` — the
1705        // canonical paste-from-shell-history-with-trailing-annotation shape
1706        // every operator-notebook and CI-manifest carries; POSIX.1-2017 §2.3
1707        // Token Recognition step 6). YAML 1.2 §6.6 makes `#` the comment lead
1708        // at any position preceded by whitespace or at line-start (`path:
1709        // ../caixa-teia  # pin` — the canonical paste-from-values.yaml /
1710        // paste-from-K8s-manifest cross-idiom-leak shape). tatara-lisp itself
1711        // treats `;` as the comment-lead but a growing number of consumer
1712        // config-DSL layers (HCL, Terraform, Nix flake attributes, .env
1713        // dotenv-style files, gitconfig / .gitignore, ini / TOML) use `#` as
1714        // the comment-lead too — the pair extends the cross-config-DSL
1715        // paste-idiom surface the d14cbc5 quote-grouping arm and the 598b770
1716        // brace-expansion arm already cover on adjacent axes. RFC 3986 §3.5
1717        // reserves `#` as the URL fragment-identifier delimiter (the canonical
1718        // paste-from-browser-address-bar `github.com/foo/bar#readme` /
1719        // `github.com/foo/bar#L42` permalink shape, and the symmetric
1720        // Nix-flake-ref cross-idiom leak `github:foo/bar#packageName` where
1721        // `#` selects a flake output — the same axis the peer
1722        // [`crate::render::is_git_repo_url`] closes on the `:fonte :repo`
1723        // surface at a68f818 with the same downstream-drops-the-tail
1724        // rationale).
1725        //
1726        // POSIX `std::path::Path` treats `#` as a literal path-component byte,
1727        // so a `:caminho "../caixa-teia # legacy sibling"` (the canonical
1728        // paste-from-shell-history-with-trailing-annotation footgun),
1729        // `:caminho "../caixa-teia  # pin"` (the symmetric YAML flow-scalar
1730        // paste-with-trailing-comment shape), or `:caminho "../caixa-teia
1731        // #readme"` (the URL fragment paste-from-browser-address-bar shape)
1732        // silently passes every prior arm because `Path::is_absolute` returns
1733        // false on `..`, `#` is neither a leading-byte sentinel nor a control
1734        // byte nor `\` nor `<` / `>` nor `|` nor `;` nor `&` nor backtick nor
1735        // `*` / `?` nor `(` / `)` nor `{` / `}` nor `[` / `]` nor `'` / `"`,
1736        // and the value's last byte isn't `/`. The resolver folds the value
1737        // through `Path::new(caminho).join(<file>)` looking for a literal
1738        // subdirectory named `../caixa-teia # legacy sibling` and fails at
1739        // resolve time with a non-self-locating `No such file or directory`
1740        // error far from the source caixa.lisp — while every downstream
1741        // shell / YAML / URL parser silently truncates the value at the `#`
1742        // byte to `../caixa-teia`, so a `feira tofu` shell-out to a
1743        // `cd '{caminho}'` command line and a `nix flake check` invocation on
1744        // an emitted YAML `path:` scalar disagree with the resolver on which
1745        // directory the value names. Two workstations whose downstream
1746        // shell / YAML / URL parsing layers differ in unquoted-`#`
1747        // recognition emit divergent build artifacts for the byte-identical
1748        // caixa.lisp value.
1749        //
1750        // The lacre pipeline embeds the value verbatim in its per-dep
1751        // content-address (`conteudo: format!("path:{caminho}")`,
1752        // caixa-resolver/src/resolve.rs:189), so the byte lands in the BLAKE3
1753        // closure and rides downstream as part of the build's identity into
1754        // every shell-spawned subprocess (the caixa-resolver's `git clone`
1755        // invocation, a future `feira tofu` shell-out, a future operator-side
1756        // `nix flake check` spawn) as the canonical shell-metachar /
1757        // comment-lead / URL-fragment-delimiter surface every peer
1758        // single-token-shaped typed slot already closes. The peer `:fonte
1759        // :repo` axis closes the byte under the URL-fragment-identifier
1760        // banner (a68f818 `#` on `is_git_repo_url`); the `:caminho` axis was
1761        // the last typed path-string surface still admitting the byte. This
1762        // arm closes the gap so the substrate-wide "no shell-composition
1763        // metacharacter / comment-lead / URL-fragment-delimiter anywhere in a
1764        // typed string slot that flows verbatim into a shell-spawned
1765        // subprocess or downstream YAML / URL parser" invariant extends from
1766        // shell-quote-grouping (`'` / `"`) to shell-comment / URL-fragment
1767        // (`#`) on the `:caminho` axis. Together with the peer JSON / YAML /
1768        // TOML string-literal delimiters the d14cbc5 quote-grouping arm
1769        // closes and the 598b770 `{` / `}` brace-expansion arm closes on the
1770        // templating-engine-placeholder boundary, the typed `:caminho`
1771        // accepted set now structurally excludes the entire
1772        // paste-with-trailing-annotation / paste-from-URL-permalink /
1773        // paste-from-YAML-comment cross-idiom-leak surface that would
1774        // silently round-trip through any downstream shell / YAML / URL /
1775        // dotenv / gitconfig / HCL parsing layer to a different value than
1776        // the resolver's `Path::join` sees.
1777        //
1778        // The arm fires AFTER the shell-quote-grouping arm because the prior
1779        // arm's `'` / `"` shape is the more semantic-locating axis on values
1780        // that probe as both (`"../'x'#pin"` carries both `'` and `#` — the
1781        // shell-string-literal-delimiter is the load-bearing root-cause edit,
1782        // so `FonteCaminhoShellQuoteGrouping` wins; same cascade discipline
1783        // every prior `:caminho` arm establishes). The arm fires BEFORE the
1784        // trailing-`/` arm because the embedded comment-lead / fragment-
1785        // delimiter byte is the more semantic-locating axis on probe-as-both
1786        // values (`"../caixa-teia#pin/"` ends in `/` but the load-bearing
1787        // diagnostic is the embedded `#` — the trailing `/` is the secondary
1788        // observation, and an author who removes the `#pin` fragment is
1789        // likely to also tab-strip the trailing separator).
1790        for &b in caminho.as_bytes() {
1791            if b == b'#' {
1792                return Err(DepError::FonteCaminhoShellComment {
1793                    nome: nome.to_string(),
1794                    caminho: caminho.to_string(),
1795                    byte: b,
1796                });
1797            }
1798        }
1799        // Reproducibility gate's URL-percent-encoding-escape arm. The 6622063
1800        // shell-comment arm closes the `#` URL-fragment-identifier byte; `%`
1801        // (`0x25`) is the orthogonal RFC 3986 §2.1 URL percent-encoding-escape
1802        // byte — the mandatory encoding mechanism for every byte outside the
1803        // `unreserved` alphanumeric / `-` / `.` / `_` / `~` set, and `%`
1804        // itself must be percent-encoded as `%25` to appear literally inside
1805        // a URL value. The byte carries three distinct render-determinism
1806        // hazards on the `:caminho` axis, no prior arm has covered it, and
1807        // the peer `:fonte :repo` axis (a323db8 `%` on `is_git_repo_url`)
1808        // already closes the same byte under the same URL-percent-encoding
1809        // banner — the `:caminho` axis was the last typed path-string surface
1810        // still admitting the byte.
1811        //
1812        // First, the paste-from-browser-address-bar percent-encoded-space
1813        // footgun: an author copies `../caixa%20teia` out of a URL-encoded
1814        // README hyperlink / a browser address bar / a percent-encoded
1815        // permalink expecting `%20` to decode to a literal space at the
1816        // filesystem layer. POSIX `std::path::Path` treats the byte as a
1817        // literal path-component byte, so `Path::join` looks for a literal
1818        // `./../caixa%20teia` subdirectory and fails at resolve time with a
1819        // non-self-locating `No such file or directory` error far from the
1820        // source caixa.lisp — while the author's mental model was
1821        // `../caixa teia`, the decoded shape. Two authors whose only
1822        // difference is percent-encoding presence resolve to two distinct
1823        // BLAKE3 closures (`path:../caixa%20teia` vs `path:../caixa teia`)
1824        // for what they intended as the byte-identical sibling-workspace
1825        // dep. The lacre pipeline embeds the value verbatim in its per-dep
1826        // content-address (`conteudo: format!("path:{caminho}")`,
1827        // caixa-resolver/src/resolve.rs:189), so the divergence rides
1828        // downstream into the BLAKE3 closure and locks the substrate's
1829        // "the lacre is the build's identity" contract (CAIXA-SDLC §III.2)
1830        // to the wrong encoding — the same THEORY.md §V.2 render-
1831        // determinism vector every prior `:caminho` arm protects.
1832        //
1833        // Second, the printf-format-specifier lead footgun: `%` is the C /
1834        // POSIX printf format-directive lead-in (`%s`, `%d`, `%02x`, the
1835        // canonical `printf "path=%s\n" ../caixa-teia` invocation every
1836        // shell-diagnostic one-liner carries) and the printf builtin is
1837        // wired into every POSIX shell (bash / zsh / dash / ksh / busybox
1838        // ash) as the format-string lead. A `:caminho "../caixa-%s-teia"`
1839        // value flowing into any future `feira` verb that shells out with a
1840        // printf-formatted path template silently gets reinterpreted as a
1841        // format-directive rather than a literal byte — the canonical
1842        // CWE-134 format-string-injection vector.
1843        //
1844        // Third, the bash-job-control-specifier lead footgun: bash / zsh /
1845        // ksh reserve `%N` at word-start as the job-control specifier —
1846        // `%1` names "job 1", `%%` names "the current job", `%foo` names
1847        // "the most recent job whose command started with `foo`". A future
1848        // `feira` verb that invokes `kill %1` on a caminho-scoped
1849        // subprocess would silently redirect the signal to a wrong target.
1850        //
1851        // Beyond the three shell-side hazards, `%` is a first-class parser
1852        // byte in three cross-config-DSL layers the substrate's paste-idiom
1853        // surface routinely crosses: YAML 1.2 §6.8.1 lexes `%` at
1854        // line-start as the directive lead (`%YAML 1.2` / `%TAG` — a
1855        // `:caminho "%YAML/1.2/../caixa-teia"` paste from a top-of-doc
1856        // YAML directive block silently trips the YAML directive parser on
1857        // any downstream emitted YAML manifest); Prometheus / Grafana
1858        // template syntax uses `%(var)s` as the substitution lead; and Nix
1859        // interpolation uses `${var}` (not `%`) but Envsubst /
1860        // Kubernetes / OpenShift template layers use `%VAR%` as the
1861        // Windows-shell env-var-reference lead — the paste-from-`.bat` /
1862        // paste-from-PowerShell-`%env:PATH%` cross-idiom leak.
1863        //
1864        // The three malformed-`%HH` classes documented on the peer
1865        // `is_git_repo_url` `%` arm (a323db8) apply here too:
1866        //
1867        //   - The lone-`%` malformed-escape shape (`"../caixa-teia%foo"`
1868        //     where `%` isn't followed by two hex digits) — every WHATWG-
1869        //     conformant URL parser rejects the value at parse time per
1870        //     RFC 3986 §2.1, but the byte rides into the lacre before
1871        //     the resolver subprocess crosses the URL-parser boundary.
1872        //   - The over-encoded path-separator shape (`"../caixa%2Fteia"`
1873        //     intending the `%2F` as the URL encoding of `/`) locks a
1874        //     `path:../caixa%2Fteia` BLAKE3 closure that diverges from
1875        //     the byte-identical `path:../caixa/teia` form.
1876        //   - The double-encoded shape (`"../caixa%2520teia"` — the `%25`
1877        //     already itself an encoded `%`, so the intent was likely a
1878        //     literal `%20` that survived one round-trip through a
1879        //     URL-encoder that shouldn't have run) locks a triply-
1880        //     divergent closure across the encoded / once-decoded /
1881        //     twice-decoded chain.
1882        //
1883        // POSIX `std::path::Path` treats the byte as a literal path-
1884        // component byte, so a `:caminho "../caixa%20teia"` (the canonical
1885        // paste-from-browser-address-bar percent-encoded-space footgun),
1886        // `:caminho "%YAML/../caixa-teia"` (the symmetric paste-from-YAML-
1887        // directive-block cross-idiom leak), or `:caminho
1888        // "../caixa-%s-teia"` (the printf-format-specifier paste-from-
1889        // shell-diagnostic-one-liner shape) silently passes every prior arm
1890        // because `Path::is_absolute` returns false on `..`, `%` is neither
1891        // a leading-byte sentinel nor a control byte nor `\` nor `<` / `>`
1892        // nor `|` nor `;` nor `&` nor backtick nor `*` / `?` nor `(` / `)`
1893        // nor `{` / `}` nor `[` / `]` nor `'` / `"` nor `#`, and the
1894        // value's last byte isn't `/`. The resolver folds the value through
1895        // `Path::new(caminho).join(<file>)` looking for a literal
1896        // subdirectory named `../caixa%20teia` and fails at resolve time
1897        // with a non-self-locating `No such file or directory` error far
1898        // from the source caixa.lisp — while every downstream URL parser /
1899        // shell printf builtin / YAML directive parser silently
1900        // reinterprets the byte to a different value than the resolver's
1901        // `Path::join` sees. Two workstations whose downstream URL / shell
1902        // / YAML layers differ in `%HH` recognition emit divergent build
1903        // artifacts for the byte-identical caixa.lisp value.
1904        //
1905        // The lacre pipeline embeds the value verbatim in its per-dep
1906        // content-address (`conteudo: format!("path:{caminho}")`, caixa-
1907        // resolver/src/resolve.rs:189), so the byte lands in the BLAKE3
1908        // closure and rides into every shell-spawned subprocess (the
1909        // resolver's `git clone`, a future `feira tofu` shell-out, a
1910        // future operator-side `nix flake check` spawn) as the canonical
1911        // URL-percent-encoding-escape / printf-format-specifier / bash-
1912        // job-control-specifier surface every peer single-token-shaped
1913        // typed slot already closes. This arm closes the gap so the
1914        // substrate-wide "no URL-percent-encoding-escape / printf-format-
1915        // specifier / job-control-specifier / YAML-directive-lead byte
1916        // anywhere in a typed string slot that flows verbatim into a
1917        // shell-spawned subprocess or downstream URL / printf / YAML
1918        // parser" invariant extends from shell-comment / URL-fragment
1919        // (`#` — 6622063) to URL-percent-encoding-escape (`%`) on the
1920        // `:caminho` axis.
1921        //
1922        // The arm fires AFTER the shell-comment arm because the prior
1923        // arm's `#` shape is the more semantic-locating axis on values
1924        // that probe as both (`"../caixa%20teia#pin"` carries both `%`
1925        // and `#` — the URL-fragment-identifier is the load-bearing
1926        // downstream-truncation edit, so `FonteCaminhoShellComment` wins;
1927        // same cascade discipline every prior `:caminho` arm establishes).
1928        // The arm fires BEFORE the trailing-`/` arm because the embedded
1929        // percent-encoding-escape byte is the more semantic-locating axis
1930        // on probe-as-both values (`"../caixa%20teia/"` ends in `/` but
1931        // the load-bearing diagnostic is the embedded `%` percent-
1932        // encoding-escape — the trailing `/` is the secondary observation,
1933        // and an author who decodes the `%20` to a literal space is
1934        // likely to also tab-strip the trailing separator).
1935        for &b in caminho.as_bytes() {
1936            if b == b'%' {
1937                return Err(DepError::FonteCaminhoUrlPercentEncoding {
1938                    nome: nome.to_string(),
1939                    caminho: caminho.to_string(),
1940                    byte: b,
1941                });
1942            }
1943        }
1944        // Reproducibility gate's embedded-`$` shell-variable-expansion /
1945        // command-substitution / arithmetic-expansion arm. The f4efe9c
1946        // leading-`$` arm at line 540 routes `caminho.starts_with('$')`
1947        // through `FonteCaminhoVarExpansion` under the leading-byte-
1948        // sentinel host-layout-leak banner (peer with the b94fd83
1949        // absolute / a5c248e tilde leading-byte arms), but the arm
1950        // fires only at position 0 — a `:caminho "../foo$HOME/bar"`
1951        // (embedded `$HOME` in a nested path segment — the canonical
1952        // paste-from-`ls ../foo$HOME/bar`-shell-one-liner footgun where
1953        // an author copies a partially-substituted shell one-liner and
1954        // the leading segment is a literal `../foo` while the mid
1955        // segment carries the un-substituted `$HOME` template), a
1956        // `:caminho "../foo${WORKSPACE}/bar"` (the symmetric braced-CI-
1957        // manifest paste-from-`.gitlab-ci.yml` / paste-from-GitHub-
1958        // Actions-workflow shape), a `:caminho "../foo$(whoami)/bar"`
1959        // (the paste-from-shell-prompt command-substitution idiom), or
1960        // a `:caminho "../foo$((1+2))/bar"` (the arithmetic-expansion
1961        // idiom) silently passes every prior arm because
1962        // `Path::is_absolute` returns false on `..`, `$` is neither a
1963        // leading-byte sentinel (the f4efe9c arm fires only at position
1964        // 0) nor a control byte nor `\` nor `<` / `>` nor `|` nor `;`
1965        // nor `&` nor backtick nor `*` / `?` nor `(` / `)` nor `{` /
1966        // `}` nor `[` / `]` nor `'` / `"` nor `#` nor `%`, and the
1967        // value's last byte isn't `/`. Note that `$(...)` command-
1968        // substitution and `$((...))` arithmetic-expansion each carry
1969        // an embedded `(` byte that the 0633c91 shell-subshell-grouping
1970        // arm catches structurally at the earlier `(` position — but
1971        // an author who reaches for the sh-brace-substitution
1972        // `${VAR}` or the bare `$VAR` shape carries only the `$` byte,
1973        // which no prior arm covers. This arm closes the last
1974        // positional gap on the `$` byte on the `:caminho` axis so
1975        // every position — leading (`FonteCaminhoVarExpansion`) and
1976        // embedded (`FonteCaminhoShellVariableExpansion`) — is
1977        // structurally rejected.
1978        //
1979        // Every POSIX shell (sh / bash / zsh / dash / ksh / busybox
1980        // ash / fish / nushell) lexes `$` as the variable-expansion /
1981        // command-substitution / arithmetic-expansion operator per
1982        // POSIX.1-2017 §2.6 (Word Expansions): `$<name>` (Parameter
1983        // Expansion) expands a named variable, `${<name>}` (Parameter
1984        // Expansion braced form) does the same with an explicit token
1985        // boundary, `$(<cmd>)` (Command Substitution modern form,
1986        // `` `<cmd>` `` legacy form which the c370458 backtick arm
1987        // already closes) runs a subshell and substitutes its stdout,
1988        // and `$((<expr>))` (Arithmetic Expansion) evaluates an
1989        // arithmetic expression. Every form is a host-layout /
1990        // environment-state / shell-subprocess-side-effect leak when
1991        // the byte lands in a value the resolver passes to a shell-
1992        // spawned subprocess. Beyond the POSIX shell layer, `$` is
1993        // the Nix `${var}` string-interpolation lead (the paste-from-
1994        // `flake.nix` / paste-from-`.nix`-attribute cross-idiom leak
1995        // where an author copies `"${pkgs.hello}/bin/hello"` out of a
1996        // nix expression), the Make `$(var)` / `$@` / `$<` automatic-
1997        // variable lead (the paste-from-`Makefile` shape), the
1998        // JavaScript / TypeScript template-literal `${expr}` interp
1999        // lead (the paste-from-JS-template-string idiom in a
2000        // multi-lang-monorepo where a `path` attribute gets copied out
2001        // of a `package.json` script or a Vite config), the envsubst /
2002        // Kubernetes / OpenShift template `${VAR}` interp lead (the
2003        // paste-from-Helm-values / paste-from-K8s-manifest cross-idiom
2004        // leak), the PHP variable lead (`$_GET`, `$_ENV` — the paste-
2005        // from-`.php`-config footgun), the Perl scalar-variable lead
2006        // (`$foo`), the SASS / SCSS variable lead (`$primary-color`),
2007        // and the SQL bind-parameter lead in PostgreSQL / SQLite
2008        // (`$1`, `$2` — the paste-from-`.sql`-migration idiom). The
2009        // cross-idiom paste-footgun surface is broader than any single
2010        // shell layer — `$` is a first-class parser byte in nearly
2011        // every config / templating / build-system DSL the substrate's
2012        // paste-idiom surface routinely crosses. The peer `:fonte
2013        // :repo` axis closes the byte under the shell-variable-
2014        // expansion / URL-sub-delim banner (b9d187c `$` on
2015        // `is_git_repo_url`), the peer `:fonte :tag` / `:fonte :branch`
2016        // axes close `$` as part of `is_git_ref_name`'s printable-
2017        // ASCII-restricted grammar (`git check-ref-format` rejects the
2018        // byte outright), and the peer `:entrada :paths` axis closes
2019        // `$` via `is_gateway_api_http_path`'s eleven-byte RFC-3986-
2020        // reserved set. The `:caminho` axis was the last typed path-
2021        // string surface still admitting `$` at positions other than 0.
2022        //
2023        // POSIX `std::path::Path` treats `$` as a literal path-
2024        // component byte, so `:caminho "../foo$HOME/bar"` silently
2025        // routes through `Path::new(caminho).join(<file>)` looking for
2026        // a literal `./{caminho}` subdirectory that fails at resolve
2027        // time with a non-self-locating `No such file or directory`
2028        // error far from the source caixa.lisp. But every downstream
2029        // shell / envsubst / Nix / Make / K8s-template parser silently
2030        // reinterprets the byte to a different value than the
2031        // resolver's `Path::join` sees — so a `feira tofu` shell-out
2032        // to a `cd '{caminho}'` command line, a `nix flake check`
2033        // invocation on an emitted YAML `path:` scalar folded through
2034        // envsubst, or a `helm template` invocation with a
2035        // `values.yaml` `path: {caminho}` embedded in a `{{`-quoted
2036        // template all disagree with the resolver on which directory
2037        // the value names. Two workstations whose downstream shell /
2038        // envsubst / Nix / Make / K8s-template parsing layers differ
2039        // in `$VAR` recognition (or, worse, expand the byte against
2040        // divergent environments — Alice's `$HOME=/home/alice`, Bob's
2041        // `$HOME=/home/bob`) emit divergent build artifacts for the
2042        // byte-identical caixa.lisp value. Even in the case where the
2043        // resolver strictly does NOT expand `$VAR` (the current
2044        // implementation) the divergence still bites at the lacre-
2045        // identity axis: the lacre pipeline embeds the value verbatim
2046        // in its per-dep content-address (`conteudo:
2047        // format!("path:{caminho}")`, caixa-resolver/src/resolve.rs:189),
2048        // so `path:../foo$HOME/bar` locks a BLAKE3 closure distinct
2049        // from the byte-identical-semantic `path:../foo/home/alice/bar`
2050        // one author would have produced by substituting the literal
2051        // value at author time, defeating the THEORY.md §V.2 render-
2052        // determinism contract on the same axis every prior `:caminho`
2053        // arm protects.
2054        //
2055        // Beyond the render-determinism / host-layout-leak vectors,
2056        // `$` at any position in a value flowing verbatim into a
2057        // shell-spawned subprocess is the canonical CWE-78 shell-
2058        // command-injection surface every peer single-token-shaped
2059        // typed slot already closes. A `:caminho "../foo$(whoami)/bar"`
2060        // that rides into a future `feira tofu` shell-out as `cd
2061        // '../foo$(whoami)/bar'` gets substituted by the shell at
2062        // subprocess-argument-expansion time even inside single quotes
2063        // in fewer positions than one might expect (the substitution
2064        // fires only outside single-quoting per POSIX §2.2.2, but
2065        // eval-style wrappers and `sh -c` layers that route the value
2066        // through re-parsing round-trip the substitution — the same
2067        // vector the c370458 backtick arm closes at the sibling
2068        // command-substitution-legacy-form surface). Every future
2069        // `feira` verb that shells out with a `caminho`-formatted
2070        // subprocess argument silently inherits this substitution
2071        // vector unless the typed slot's accepted set structurally
2072        // excludes the byte.
2073        //
2074        // Frontier inspiration: OTP's `gen_server` return-value grammar
2075        // rejects mid-tuple shell-metachar bytes by construction —
2076        // `{noreply, State}` never carries a raw `$` because the
2077        // Erlang term type system has no notion of "string that gets
2078        // shelled out"; caixa's typed slots inherit the same
2079        // structural discipline (types-are-theorems, the compounding
2080        // mandate's leverage-point-1) by refusing values that would
2081        // silently reinterpret at any downstream layer. Peer with
2082        // Unison's content-addressed code (no ambient environment —
2083        // every reference is a hash, no `$VAR` substitution possible)
2084        // and Pony's capabilities (a path capability that carries a
2085        // `$` would be ill-typed at the reference layer).
2086        //
2087        // The arm fires AFTER the URL-percent-encoding-escape arm (the
2088        // e3558fa `%` arm) because a value carrying both `%` and `$`
2089        // (`"../foo%20$HOME/bar"` — the canonical "I pasted a percent-
2090        // encoded space next to a `$HOME` template") surfaces the
2091        // narrower URL-encoding diagnostic first — the paste-from-
2092        // browser-address-bar shape is the load-bearing self-locating
2093        // edit on every probe-as-both value; same cascade discipline
2094        // every prior `:caminho` arm establishes (a323db8 %  before
2095        // this arm, this arm before trailing-`/`). The arm fires
2096        // BEFORE the trailing-`/` arm because the embedded shell-
2097        // variable-expansion byte is the more semantic-locating axis
2098        // on probe-as-both values (`"../foo$HOME/bar/"` ends in `/`
2099        // but the load-bearing diagnostic is the embedded `$` — the
2100        // trailing `/` is the secondary observation, and an author
2101        // who substitutes the `$HOME` template with a literal value is
2102        // likely to also tab-strip the trailing separator).
2103        for &b in caminho.as_bytes() {
2104            if b == b'$' {
2105                return Err(DepError::FonteCaminhoShellVariableExpansion {
2106                    nome: nome.to_string(),
2107                    caminho: caminho.to_string(),
2108                    byte: b,
2109                });
2110            }
2111        }
2112        // Reproducibility gate's shell-history-expansion / RFC-3986-sub-delims
2113        // arm. The immediate-predecessor `$` embedded arm closes the shell-
2114        // variable-expansion / command-substitution byte; `!` (`0x21`) is the
2115        // orthogonal POSIX shell-history-expansion sentinel every interactive
2116        // shell with history enabled (bash / ksh / zsh's `bashcompat` /
2117        // csh / tcsh) lexes as the history-expansion prefix: `!command`
2118        // re-runs the most recent history entry beginning with `command`,
2119        // `!!` re-runs the prior command verbatim, `!$` substitutes the
2120        // last word of the prior command, `!:N` substitutes the Nth word,
2121        // `^old^new` rewrites the prior command's `old` to `new` (the
2122        // canonical set of `set -o histexpand` operators bash's default
2123        // interactive session enables). Beyond the shell-history layer,
2124        // RFC 3986 §2.2 lists `!` in the `sub-delims` set (the URL grammar
2125        // admits the byte inside a path segment, but every WHATWG-conformant
2126        // special-scheme URL parser percent-encodes it inside a query
2127        // component via the 'special-query percent-encode set' the peer
2128        // `is_git_repo_url` `*` / `(` / `)` / `'` arms close on); the byte
2129        // is also the C / C++ / Rust / JavaScript / Python bang-operator
2130        // (logical-negation prefix — the paste-from-source-code idiom where
2131        // an author copies `!path.exists()` out of a Rust snippet and the
2132        // trailing punctuation crosses the string-literal boundary); the
2133        // canonical English-typography emphasis / exclamation mark (the
2134        // paste-from-prose enthusiasm-form idiom where an author writes
2135        // `:caminho "../caixa-teia!"` expecting the substrate to coerce it
2136        // to a kebab-case slug); and the Nix flake-ref import-attribute
2137        // `import ./foo.nix { … }` sibling operator surface.
2138        //
2139        // POSIX `std::path::Path` treats `!` as a literal path-component
2140        // byte, so a `:caminho "../caixa-teia!sudo"` (the canonical paste-
2141        // from-shell-history footgun where the author copies a `cd
2142        // ../caixa-teia && !sudo make install` one-liner from a quick-
2143        // start README and the trailing `!sudo` rides in verbatim as a
2144        // history-expansion reference), a `:caminho "../foo!!/bar"` (the
2145        // `!!` repeat-prior-command paste idiom), a `:caminho
2146        // "../caixa-teia!"` (the English-typography enthusiasm-form
2147        // paste-from-prose footgun), or a `:caminho "../foo!$"` (the
2148        // last-word-substitution shape) silently pass every prior arm
2149        // because `Path::is_absolute` returns false on `..`, `!` is neither
2150        // a leading-byte sentinel nor a control byte nor `\` nor `<` / `>`
2151        // nor `|` nor `;` nor `&` nor backtick nor `*` / `?` nor `(` / `)`
2152        // nor `{` / `}` nor `[` / `]` nor `'` / `"` nor `#` nor `%` nor `$`,
2153        // and the value's last byte isn't `/`. The resolver folds the value
2154        // through `Path::new(caminho).join(<file>)` looking for a literal
2155        // `./../caixa-teia!sudo` subdirectory and fails at resolve time
2156        // with a non-self-locating `No such file or directory` error far
2157        // from the source caixa.lisp — while every downstream interactive
2158        // shell with `set -o histexpand` reinterprets the byte as the
2159        // history-expansion prefix, and the failure mode forks per
2160        // consumer: a `feira tofu` shell-out to a `cd '{caminho}'` command
2161        // line executed under `bash -i` (the operator-notebook interactive
2162        // shell) substitutes the `!sudo` reference to the most recent
2163        // history entry starting with `sudo`, silently invoking whatever
2164        // privileged command that entry named.
2165        //
2166        // The lacre pipeline embeds the value verbatim in its per-dep
2167        // content-address (`conteudo: format!("path:{caminho}")`,
2168        // caixa-resolver/src/resolve.rs:189), so the byte lands in the
2169        // BLAKE3 closure and rides into every shell-spawned subprocess
2170        // (the resolver's `git clone`, a future `feira tofu` shell-out,
2171        // a future operator-side `nix flake check` spawn) as the
2172        // canonical shell-history-expansion / RFC-3986-sub-delims surface
2173        // every peer single-token-shaped typed slot already closes. The
2174        // peer `:fonte :repo` axis closes the byte under the same shell-
2175        // history-expansion / RFC-3986-sub-delims banner (7d53c68 `!` on
2176        // `is_git_repo_url`); the `:caminho` axis was the last typed
2177        // path-string surface still admitting the byte. This arm closes
2178        // the gap so the substrate-wide "no shell-composition
2179        // metacharacter / history-expansion sentinel anywhere in a typed
2180        // string slot that flows verbatim into a shell-spawned subprocess"
2181        // invariant extends from shell-variable-expansion (`$`) to shell-
2182        // history-expansion (`!`) on the `:caminho` axis. Together with
2183        // the peer c370458 backtick command-substitution-legacy-form arm
2184        // and the b9d187c-`$`-embedded-variable-expansion arm on the
2185        // sibling `:repo` axis, the typed `:caminho` accepted set now
2186        // structurally excludes every byte the POSIX shell §2.6 Word
2187        // Expansions section, §2.3 Token Recognition step 6, and every
2188        // history-expansion / brace-expansion / pathname-expansion /
2189        // parameter-expansion / command-substitution / arithmetic-
2190        // expansion operator lexes as a first-class parser byte.
2191        //
2192        // Frontier inspiration: Unison's content-addressed code (no
2193        // ambient environment — every reference is a hash, no `!<num>`
2194        // history-index substitution possible; the caixa substrate's
2195        // lacre discipline arrives at the same guarantee by refusing
2196        // bytes at manifest-parse time that would reinterpret against
2197        // ambient shell history state); Pony's capabilities (a path
2198        // capability that carries a `!` would be ill-typed at the
2199        // reference layer).
2200        //
2201        // The arm fires AFTER the shell-variable-expansion arm because a
2202        // value carrying both `$` and `!` (`"../foo$HOME/bar!sudo"` — the
2203        // canonical "I pasted a `$HOME`-templated path adjacent to a
2204        // trailing `!sudo` history-expansion") surfaces the narrower
2205        // shell-variable-expansion diagnostic first — the paste-from-CI-
2206        // manifest-with-`$VAR`-template shape is the load-bearing self-
2207        // locating edit on every probe-as-both value; same cascade
2208        // discipline every prior `:caminho` arm establishes. The arm
2209        // fires BEFORE the trailing-`/` arm because the embedded shell-
2210        // history-expansion byte is the more semantic-locating axis on
2211        // probe-as-both values (`"../foo!sudo/"` ends in `/` but the
2212        // load-bearing diagnostic is the embedded `!` — the trailing `/`
2213        // is the secondary observation, and an author who removes the
2214        // `!sudo` history reference is likely to also tab-strip the
2215        // trailing separator).
2216        for &b in caminho.as_bytes() {
2217            if b == b'!' {
2218                return Err(DepError::FonteCaminhoShellHistoryExpansion {
2219                    nome: nome.to_string(),
2220                    caminho: caminho.to_string(),
2221                    byte: b,
2222                });
2223            }
2224        }
2225        // Reproducibility gate's shell-history-substitution / RFC-3986-unwise
2226        // / regex-anchor arm. The immediate-predecessor `!` arm closes the
2227        // POSIX `!command` / `!!` / `!$` history-expansion prefix; `^`
2228        // (`0x5E`) is the paired-operator half of the same bash-reference
2229        // §9.3 histexpand feature — the `^old^new^` "quick substitution"
2230        // form (POSIX bash rewrites the prior command's `old` string to
2231        // `new` and re-executes it, the canonical typo-correction one-
2232        // liner idiom `git clone <bad-url>` → `^bad^good` that pastes the
2233        // trailing substitution fragment verbatim into a `:caminho` value
2234        // when the author trims only the leading `git clone` prefix). The
2235        // peer `:fonte :repo` axis closes the byte under the same
2236        // shell-history-substitution / RFC-3986-unwise banner (49e142f `^`
2237        // on `is_git_repo_url`); the `:caminho` axis was the last typed
2238        // path-string surface still admitting the byte after 6a04767
2239        // landed the `!` arm.
2240        //
2241        // Beyond bash history-substitution, `^` carries five distinct
2242        // downstream-reinterpretation surfaces the typed slot's accepted
2243        // set must structurally exclude:
2244        //
2245        // 1. **RFC 3986 §2 'unwise' set** — the four-byte cross-transport
2246        //    layer set (`{`, `}`, `|`, `\`) plus `^` every URL parser is
2247        //    required to percent-encode-or-refuse at the wire boundary.
2248        //    The WHATWG URL spec's 'fragment percent-encode set' maps
2249        //    `^` → `%5E` at the query / fragment component transition;
2250        //    libcurl silently percent-encodes the byte on the wire, so a
2251        //    `:caminho "../foo^bar"` value the resolver's `Path::join`
2252        //    sees as a literal `./../foo^bar` subdirectory diverges from
2253        //    the byte-transformed `%5E` shape any downstream `feira tofu`
2254        //    curl-invocation or artifact-registry-fetch would emit — the
2255        //    canonical wire-boundary divergence vector the peer
2256        //    `{`, `}`, `|`, `\` `:caminho` arms already close (
2257        //    `FonteCaminhoShellBraceExpansion` at 598b770,
2258        //    `FonteCaminhoShellPipe` at the pipe arm,
2259        //    `FonteCaminhoBackslash` at the backslash arm).
2260        // 2. **Regex character-class negation prefix `[^abc]`** — the
2261        //    canonical paste-from-doc-regex-pipeline footgun where an
2262        //    author copies a `grep '[^abc]'` idiom from a docs quick-
2263        //    listing and the character-class negation byte rides in
2264        //    verbatim.
2265        // 3. **Bitwise XOR operator** in C / C++ / Rust / Python /
2266        //    JavaScript / Nix / Go — the paste-from-source-code idiom
2267        //    where an author copies an `x ^ y`-shaped expression out of
2268        //    a source snippet and the operator crosses the string-
2269        //    literal boundary.
2270        // 4. **Windows `cmd.exe` escape metacharacter** — the byte
2271        //    escapes the next character in a `cmd.exe` batch context (a
2272        //    peer of the backslash arm's Windows-separator-leak vector).
2273        //    A `:caminho "..^&whoami"` cross-platform paste-from-batch-
2274        //    file footgun reinterprets at every `cmd.exe`-spawned
2275        //    subprocess (the resolver's future Windows-runner shell-out,
2276        //    the operator's WinRM path, a future PowerShell-embedded
2277        //    invocation).
2278        // 5. **LaTeX / Markdown / BibTeX superscript operator** — the
2279        //    paste-from-typeset-doc footgun where a mathematical
2280        //    superscript notation (`x^2` / `M^T`) leaks from prose.
2281        //
2282        // POSIX `std::path::Path` treats `^` as a literal path-component
2283        // byte, so `:caminho "../foo^bar/baz"` (embedded quick-
2284        // substitution), `:caminho "../foo^"` (trailing history-
2285        // substitution-open shape), `:caminho "../[^a-z]/foo"` (regex-
2286        // negation-prefix paste from a grep pipeline; note the `[` / `]`
2287        // arm at 986963b fires first on this shape), or `:caminho
2288        // "../x^y"` (XOR-expression paste-from-source) all silently pass
2289        // every prior arm (`^` isn't `\` / `<` / `>` / `|` / `;` / `&` /
2290        // backtick / `*` / `?` / `(` / `)` / `{` / `}` / `[` / `]` / `'`
2291        // / `"` / `#` / `%` / `$` / `!`) and route through
2292        // `Path::new(caminho).join(<file>)` looking for a literal
2293        // `./{caminho}` subdirectory that fails at resolve time with a
2294        // non-self-locating `No such file or directory` error far from
2295        // the source caixa.lisp — while every downstream shell / curl /
2296        // regex / `cmd.exe` layer reinterprets the byte to its own
2297        // semantic.
2298        //
2299        // The lacre pipeline embeds the value verbatim in its per-dep
2300        // content-address (`conteudo: format!("path:{caminho}")`,
2301        // caixa-resolver/src/resolve.rs:189), so the byte lands in the
2302        // BLAKE3 closure and rides into every shell-spawned subprocess
2303        // (the resolver's `git clone`, a future `feira tofu` shell-out,
2304        // a future operator-side `nix flake check` spawn) as the
2305        // canonical shell-history-substitution / RFC-3986-unwise /
2306        // regex-negation surface every peer single-token-shaped typed
2307        // slot already closes. This arm together with the immediate-
2308        // predecessor `!` arm (6a04767) closes the full `set -o
2309        // histexpand` operator surface on the `:caminho` axis — the
2310        // `!command` / `!!` / `!$` prefix form via `!`, the `^old^new^`
2311        // quick-substitution form via `^` — so the substrate-wide "no
2312        // shell-history operator anywhere in a typed string slot that
2313        // flows verbatim into a shell-spawned subprocess" invariant
2314        // extends from the `!` prefix half to the `^` quick-substitution
2315        // half. Every peer bash-history operator now fails at manifest-
2316        // parse time with a self-locating diagnostic naming the offending
2317        // caixa.lisp rather than at resolve-time as a `Path::join`-
2318        // derived `No such file or directory` (harmless but non-self-
2319        // locating) or worse riding into a downstream `bash -i` context
2320        // that reinterprets the byte-pair against ambient history state.
2321        //
2322        // Frontier inspiration: bash reference §9.3 HISTORY EXPANSION
2323        // "Quick substitution. Repeat the previous command, replacing
2324        // string1 with string2." + RFC 3986 §2 'unwise' set
2325        // ("characters that gateways and other transport agents are
2326        // known to sometimes modify") + Pony's capabilities (a path
2327        // capability that carries a `^` would be ill-typed at the
2328        // reference layer, matching the same structural discipline the
2329        // sibling `!` history-expansion arm inherits from Unison's
2330        // content-addressed no-ambient-history discipline).
2331        //
2332        // The arm fires AFTER the shell-history-expansion `!` arm because
2333        // a value carrying both `!` and `^` (`"../foo!sudo^bad^good"` —
2334        // the canonical "I pasted a `!sudo` history-reference next to a
2335        // `^bad^good` quick-substitution") surfaces the narrower prefix-
2336        // form `!` diagnostic first — the `!` form is the load-bearing
2337        // self-locating edit on every probe-as-both value (an author who
2338        // removes the `!sudo` reference is likely to also strip the
2339        // paired `^` substitution fragment); same cascade discipline
2340        // every prior `:caminho` arm establishes. The arm fires BEFORE
2341        // the trailing-`/` arm because the embedded shell-history-
2342        // substitution byte is the more semantic-locating axis on
2343        // probe-as-both values (`"../foo^bar/"` ends in `/` but the
2344        // load-bearing diagnostic is the embedded `^` — the trailing `/`
2345        // is the secondary observation, and an author who removes the
2346        // `^bar` substitution fragment is likely to also tab-strip the
2347        // trailing separator).
2348        for &b in caminho.as_bytes() {
2349            if b == b'^' {
2350                return Err(DepError::FonteCaminhoShellHistorySubstitution {
2351                    nome: nome.to_string(),
2352                    caminho: caminho.to_string(),
2353                    byte: b,
2354                });
2355            }
2356        }
2357        // Reproducibility gate's trailing-`/` arm. The b94fd83 absolute arm
2358        // closes the leading-`/` host-layout-leak; the embedded-control-byte
2359        // arm closes any byte-in-the-`0x00..=0x1F` / `0x7F` range; the
2360        // backslash arm closes the cross-host-OS-separator vector. The
2361        // trailing-`/` is the orthogonal shell-tab-completion-on-a-directory
2362        // footgun — `Path::join("../caixa-teia")` and
2363        // `Path::join("../caixa-teia/")` resolve to the same directory
2364        // (POSIX path-component-walk treats trailing `/` as a no-op for
2365        // directory targets, which `:caminho` always names — the sibling-
2366        // workspace dep root is structurally a directory). The lacre
2367        // pipeline embeds the value verbatim in its per-dep content-address
2368        // (`conteudo: format!("path:{caminho}")`,
2369        // caixa-resolver/src/resolve.rs:189), so byte-identical caixa
2370        // semantic-meaning yields two distinct BLAKE3 closures depending on
2371        // whether the author shell-tab-completed the path (every interactive
2372        // shell appends `/` on tab-completing a directory, idiomatic in
2373        // bash / zsh / fish / nushell), pasted from `pwd` (which on most
2374        // shells emits without trailing `/`, but `realpath -e -m` on a
2375        // directory with trailing `/` preserves it), or copied a Cargo
2376        // `path = "../caixa-teia/"` entry from cross-substrate documentation
2377        // (Cargo accepts both shapes and folds them the same way). Two
2378        // workstations whose authors differ only in tab-completion habits
2379        // emit byte-divergent lacres for the byte-identical-semantic caixa,
2380        // and the substrate's "the lacre is the build's identity" contract
2381        // (CAIXA-SDLC §III.2) silently breaks far from the source caixa.lisp.
2382        //
2383        // Same THEORY.md §V.2 render-determinism axis every prior `:caminho`
2384        // arm protects, here against the trailing-separator divergence
2385        // vector: every typed slot's accepted set excludes byte-divergent
2386        // values that round-trip to the same downstream semantic. The peer
2387        // path-shaped axes already reject trailing separators on the same
2388        // contract: [`crate::render::is_gateway_api_http_path`] gates
2389        // `:entrada :paths` against any non-canonical normalization, and
2390        // [`crate::render::is_sandboxed_relative_path`] gates the M2 typed
2391        // path-slots (`:behavior :on-*`, `:upgrade-from :state-change
2392        // :script`, `:bibliotecas`, `:exe`, `:servicos`) against shapes
2393        // whose canonical form would re-introduce determinism divergence.
2394        //
2395        // The arm fires last in the cascade because every prior arm carries
2396        // a more self-locating diagnostic on values that probe as both
2397        // (e.g. `:caminho "../foo/\0/"` ends in `/` but the load-bearing
2398        // diagnostic is the NUL byte's POSIX-syscall-rejection — the
2399        // control-char arm wins; `:caminho "/etc/passwd/"` ends in `/` but
2400        // the load-bearing diagnostic is the absolute host-layout-leak —
2401        // the absolute arm wins; `:caminho "..\caixa-teia/"` ends in `/`
2402        // but the load-bearing diagnostic is the Windows-separator cross-
2403        // OS divergence — the backslash arm wins). The arm covers every
2404        // shape where the last byte is `/` regardless of length, including
2405        // the degenerate single-`/` (which the absolute arm catches first)
2406        // and the consecutive-`//` (where every prior arm passes on the
2407        // bytes other than the trailing `/`).
2408        if caminho.as_bytes().last() == Some(&b'/') {
2409            return Err(DepError::fonte_caminho_trailing_slash(nome, caminho));
2410        }
2411        Ok(())
2412    }
2413}
2414
2415impl Dep {
2416    /// Substrate-canonical per-`:deps` / `:deps-dev` entry `:nome` scalar
2417    /// accessor every consumer of the dep-graph identity axis keys off —
2418    /// returns the author-declared `:nome` byte-string verbatim as a
2419    /// `&str`, borrowed from the typed slot's own [`String`] storage.
2420    ///
2421    /// The `:deps :nome` / `:deps-dev :nome` slot carries the DNS-1123
2422    /// label that names the target caixa (validated by [`Self::validate`]
2423    /// through the shared [`crate::render::is_dns_1123_label`] predicate,
2424    /// same accept-set the peer caixa-identifier axes carry — top-level
2425    /// [`crate::Caixa::nome`], per-`:membros` [`crate::Membro::nome`],
2426    /// per-`:children` [`crate::supervisor::ChildSpec::nome`]). Every
2427    /// downstream consumer that fans on the dep's name-identity keys off
2428    /// this scalar: the [`crate::Caixa::validate_deps`] per-list
2429    /// [`crate::render::insert_first_seen`] dedup key + the paired
2430    /// [`DepError::DuplicateNome`] carrier the walk raises on collision,
2431    /// the cross-list [`validate_no_self_dep`] parent-name equality gate
2432    /// on both `:deps` and `:deps-dev` traversals, the `caixa-resolver`
2433    /// pipeline's `HashSet<String>` seen-set the closure walker gates
2434    /// requeueing off (`caixa-resolver/src/resolve.rs:55`), the resolver's
2435    /// per-transitive-target requeue path (`resolve.rs:63,66`), the
2436    /// [`crate::DepSource::default_github`]-shaped resolver-side shorthand
2437    /// fill-in that folds `:nome` into the fetched-git-URL (`resolve.rs:147`),
2438    /// every `caixa-resolver` `ResolveError::MissingPath` /
2439    /// `ResolveError::MissingPin` carrier that names the offending dep
2440    /// (`resolve.rs:177,206`), each resolved
2441    /// `caixa-lacre::LacreEntry` `nome:` field the closure hash keys off
2442    /// (`resolve.rs:108,113`), and the peer `feira lock` stub-resolver's
2443    /// `LacreEntry` emitter (`caixa-feira/src/cmd/lock.rs:59,61,64`).
2444    ///
2445    /// Prior to this lift the `.nome` byte-string was read inline at every
2446    /// production site — the [`crate::Caixa::validate_deps`] paired
2447    /// `dep.nome.as_str()` / `dep.nome.clone()` accesses on both `:deps`
2448    /// and `:deps-dev` traversals, the [`validate_no_self_dep`] pair of
2449    /// parent-equality checks, and every caixa-resolver / caixa-feira
2450    /// site enumerated above — open-coded field-accesses that expressed
2451    /// no compile-time link back to the typed slot. A future extension of
2452    /// the `:deps :nome` axis to a richer author surface (a per-scope
2453    /// alias table the resolver folds through the `~/.config/caixa/config.yaml`
2454    /// entry the [`crate::dep::Dep`] docstring already acknowledges, a
2455    /// namespace-qualified rewrite the future M4 lacre-federation layer
2456    /// applies per-cluster, a promotion of the plain [`String`] byte-string
2457    /// to a richer scoped-identifier newtype once cross-registry federation
2458    /// lands) would have had to be threaded through every open-coded copy
2459    /// in lockstep or two consumers would silently disagree on which caixa
2460    /// a given dep resolves to — the [`crate::Caixa::validate_deps`] dedup
2461    /// set treating the name as `"caixa-teia"` while the caixa-resolver
2462    /// closure walker treated it as `"tenant-a/caixa-teia"` would silently
2463    /// split the [`DepError::DuplicateNome`] refusal from the resolver's
2464    /// requeue-suppression seen-set, one build-time diagnostic
2465    /// disagreeing with the run-time closure the substrate's lacre
2466    /// pipeline actually materializes. Lifting the resolution rule to a
2467    /// typed method on the substrate primitive means every downstream
2468    /// consumer of the caixa's per-`:deps` identity surface reaches for
2469    /// exactly one typed dispatch — the resolver's accept-set migrates as
2470    /// a unit on any future axis addition.
2471    ///
2472    /// First accessor on the outer `Dep` type — opens the outer-`Dep`
2473    /// `&str`-return required-scalar projection pattern the sibling
2474    /// per-`Dep` `:versao` future lift folds on. Peer of the sibling
2475    /// per-`:membros` [`crate::Membro::nome`] (4a32abf) /
2476    /// per-`:children` [`crate::supervisor::ChildSpec::nome`] (dfb4a81)
2477    /// / top-level [`crate::Caixa::nome`] (e6b7d97) caixa-identity scalar
2478    /// accessors — same "one typed dispatch on the substrate primitive,
2479    /// thin projections at each consumer" discipline extended onto the
2480    /// third named-caixa-referencing axis (`:deps` / `:deps-dev`), the
2481    /// remaining unlifted caixa-name-referencing accessor family in the
2482    /// substrate. Named `nome()` to match the tatara-lisp author-surface
2483    /// term the field's docstring already reaches for ("Caixa name — must
2484    /// match the target caixa's `:nome`") and the peer caixa-identity
2485    /// accessor family the substrate already carries.
2486    #[must_use]
2487    pub const fn nome(&self) -> &str {
2488        self.nome.as_str()
2489    }
2490
2491    /// Substrate-canonical per-`:deps` / `:deps-dev` entry `:versao`
2492    /// Cargo-shaped semver-requirement scalar accessor every consumer of
2493    /// the dep-graph version-pin axis keys off — returns the author-
2494    /// declared `:versao` requirement byte-string verbatim as a `&str`,
2495    /// borrowed from the typed slot's own [`String`] storage.
2496    ///
2497    /// The `:deps :versao` / `:deps-dev :versao` slot carries the
2498    /// Cargo-shaped semver requirement string (`"^0.1"`, `"~0.1.2"`,
2499    /// `"0.1.0"`, `"*"`) the shared [`crate::version::parse_requirement`]
2500    /// entry-point consumes — same accept-set the peer requirement-
2501    /// carrying axes carry (per-`:membros`
2502    /// [`crate::Membro::versao_requirement`], per-`:children`
2503    /// [`crate::supervisor::ChildSpec::versao_requirement`]), validated
2504    /// through the shared
2505    /// [`crate::render::require_valid_versao_requirement`] cascade in
2506    /// [`Self::validate`]. Every downstream consumer that fans on the
2507    /// dep's version-pin keys off this scalar: the [`Self::validate`]
2508    /// `require_valid_versao_requirement` gate + the paired
2509    /// [`DepError::VersaoInvalid`] carrier the cascade raises on
2510    /// requirement-shape rejection, the `feira lock` stub-resolver's
2511    /// `format!("{}@{}", dep.nome(), dep.versao_requirement())`
2512    /// `conteudo` hash-input interpolation and the paired
2513    /// `LacreEntry.versao:` `String`-carry fill (`caixa-feira/src/cmd/lock.rs`),
2514    /// and the peer `feira lock` end-to-end fixture in `caixa-feira/tests/feira_e2e.rs`.
2515    ///
2516    /// Prior to this lift the `.versao` byte-string was read inline at
2517    /// every production site — the [`Self::validate`] paired
2518    /// `&self.versao` requirement-gate reference and `self.versao.clone()`
2519    /// error-body carrier, the `caixa-feira/src/cmd/lock.rs` paired
2520    /// `format!("{}@{}", dep.nome(), dep.versao)` `conteudo` interpolation
2521    /// and `versao: dep.versao.clone()` `LacreEntry` fill, and the
2522    /// `caixa-feira/tests/feira_e2e.rs` end-to-end fixture's pair of the
2523    /// same shapes — open-coded field-accesses that expressed no
2524    /// compile-time link back to the typed slot. A future extension of
2525    /// the `:deps :versao` axis to a richer author surface (a per-scope
2526    /// version-lock overlay the resolver folds through the
2527    /// `~/.config/caixa/config.yaml` entry the [`crate::dep::Dep`]
2528    /// docstring already acknowledges, a per-cluster canary-version
2529    /// overlay per MESH-COMPOSITION §III.2, a promotion of the plain
2530    /// [`String`] requirement to a richer parsed-`VersionReq` newtype
2531    /// once cross-registry federation lands) would have had to be
2532    /// threaded through every open-coded copy in lockstep or two
2533    /// consumers would silently disagree on which release constraint a
2534    /// given dep resolves to — the [`Self::validate`] requirement-gate
2535    /// call reading `"^0.1"` while the `feira lock` stub-resolver's
2536    /// `conteudo` hash-input read `"tenant-a-pin/^0.1"` would silently
2537    /// split the [`DepError::VersaoInvalid`] refusal from the lacre's
2538    /// content-addressed hash the substrate's fetch pipeline actually
2539    /// materializes, one build-time diagnostic disagreeing with the
2540    /// run-time closure. Lifting the resolution rule to a typed method
2541    /// on the substrate primitive means every downstream consumer of
2542    /// the caixa's per-`:deps` version-pin surface reaches for exactly
2543    /// one typed dispatch — the resolver's accept-set migrates as a
2544    /// unit on any future axis addition.
2545    ///
2546    /// Second accessor on the outer `Dep` type — folds on the outer-
2547    /// `Dep` `&str`-return required-scalar projection pattern the
2548    /// sibling per-`Dep` [`Self::nome`] (eba2cde) accessor opened. Peer
2549    /// of the per-`:membros` [`crate::Membro::versao_requirement`]
2550    /// (a40b0e3) / per-`:children`
2551    /// [`crate::supervisor::ChildSpec::versao_requirement`] (7844f4e
2552    /// family) member/child version-pin accessors — the three
2553    /// requirement-carrying axes (`Dep::versao_requirement` on the
2554    /// per-caixa dep-graph edge, `Membro::versao_requirement` on the M3
2555    /// Aplicacao side, `ChildSpec::versao_requirement` on the M2
2556    /// Supervisor side) now share one accessor discipline for the
2557    /// shared substrate concept "another caixa referenced by a
2558    /// Cargo-shaped semver requirement". The pair
2559    /// `(nome(), versao_requirement())` jointly projects the
2560    /// `(nome, versao)` field pair every dep-graph consumer that fans
2561    /// on per-dep identity + version pin keys off. Named
2562    /// `versao_requirement()` rather than `versao()` because the field's
2563    /// storage-side `.versao` label is already the author-surface term
2564    /// (`:versao`); the accessor's name carries the semantic role — the
2565    /// semver *requirement* string the shared
2566    /// [`crate::version::parse_requirement`] entry-point consumes — so a
2567    /// raw field access and a typed dispatch read differently at every
2568    /// consumer site. Matches the peer
2569    /// [`crate::Membro::versao_requirement`] /
2570    /// [`crate::supervisor::ChildSpec::versao_requirement`] naming
2571    /// discipline verbatim.
2572    #[must_use]
2573    pub const fn versao_requirement(&self) -> &str {
2574        self.versao.as_str()
2575    }
2576
2577    /// Substrate-canonical per-`:deps` / `:deps-dev` entry `:fonte`
2578    /// Zig-store-model per-dep source-tuple optional-composite-reference
2579    /// accessor every consumer of the dep-graph fetch-source axis keys
2580    /// off — returns the author-declared `:fonte` typed [`DepSource`]
2581    /// verbatim as an `Option<&DepSource>` borrowed from the typed slot's
2582    /// own `Option<DepSource>` storage, with `None` naming the "author
2583    /// omitted `:fonte`" shorthand every resolver-side default-fill
2584    /// (`caixa-feira/src/cmd/lock.rs`'s stub, `caixa-resolver/src/resolve.rs`'s
2585    /// canonical fetcher, per the [`DepSource::default_github`] fallback
2586    /// the [`Dep::fonte`] field docstring already documents) treats as
2587    /// the "resolve through the configured default host / org
2588    /// (`github:<default-org>/<nome>`)" partition.
2589    ///
2590    /// The `:deps :fonte` / `:deps-dev :fonte` slot carries the two-
2591    /// arm typed [`DepSource`] the `Zig-style git-only store model` the
2592    /// enclosing [`Dep`] docstring names — `DepSource::Git { repo, tag,
2593    /// rev, branch }` for the git-clone arm every published caixa
2594    /// resolves through, `DepSource::Path { caminho }` for the dev-only
2595    /// local-filesystem arm every unpublishable in-tree checkout
2596    /// resolves through. Every downstream consumer that fans on the
2597    /// dep's fetch-source keys off this accessor: [`Self::validate`]'s
2598    /// per-`:fonte` [`DepSource::validate`] delegation (which raises
2599    /// the empty-`:repo` / missing-pin / multiple-pin / empty-`:caminho`
2600    /// diagnostics through the [`DepError::Fonte*`] carrier family
2601    /// naming the offending `Dep::nome`), the caixa-crd conversion
2602    /// crate's `dep_into_ref` two-arm projection into the `CaixaSource`
2603    /// `{repo, git_ref}` pair the K8s-CR side consumes
2604    /// (`caixa-crd/src/conversion.rs`), and — through the paired
2605    /// resolver-side default-fill's `Option::unwrap_or_else` — every
2606    /// `caixa-feira` / `caixa-resolver` fetch site that requires a
2607    /// concrete `DepSource` at run time.
2608    ///
2609    /// Prior to this lift the `.fonte` typed slot was read inline at
2610    /// every production site — the [`Self::validate`]
2611    /// `if let Some(ref fonte) = self.fonte` bracket the per-`:fonte`
2612    /// gate delegates through, the caixa-crd `dep_into_ref`
2613    /// `d.fonte.as_ref().and_then(...)` two-arm `CaixaSource` projector,
2614    /// the resolver-side `caixa-feira/src/cmd/lock.rs` / `caixa-resolver/src/resolve.rs`
2615    /// `dep.fonte.clone().unwrap_or_else(...)` default-fill pair — open-
2616    /// coded field-accesses that expressed no compile-time link back to
2617    /// the typed slot. A future extension of the `:deps :fonte` axis
2618    /// to a richer author surface (a per-scope source-override table
2619    /// the resolver folds through the `~/.config/caixa/config.yaml`
2620    /// entry the [`Dep`] docstring already acknowledges, a per-org
2621    /// mirror-fallback list the future M4 lacre-federation resolver
2622    /// consults ahead of the `default_github` fallback, a promotion of
2623    /// the plain `Option<DepSource>` to a richer
2624    /// `{primary, mirrors, integrity}` triple once cross-registry
2625    /// federation lands, a per-dep `sri:sha256-…` integrity slot the
2626    /// M4 lacre gate binds against ahead of the git-fetch) would have
2627    /// had to be threaded through every open-coded copy in lockstep or
2628    /// two consumers would silently disagree on which fetch source a
2629    /// given dep resolves to — the [`Self::validate`] per-`:fonte`
2630    /// gate reading the author-declared source while the caixa-crd
2631    /// projector read a per-scope-override-resolved source would
2632    /// silently split the build-time refusal from the CR the
2633    /// substrate's admission pipeline actually materializes, one
2634    /// build-time diagnostic disagreeing with the run-time closure.
2635    /// Lifting the resolution rule to a typed method on the substrate
2636    /// primitive means every downstream consumer of the caixa's per-
2637    /// `:deps` fetch-source surface reaches for exactly one typed
2638    /// dispatch — the resolver's accept-set migrates as a unit on any
2639    /// future axis addition.
2640    ///
2641    /// First outer-`Dep` `Option<&Composite>`-return composite-reference
2642    /// accessor — opens the outer-`Dep` `Option<&Composite>` composite-
2643    /// reference projection pattern the sibling per-`Dep` `:opcional`
2644    /// (`Option<Copy>` — the plain-bool axis) / `:caracteristicas`
2645    /// (`&[String]` — the feature-flag list) future outer scalar / slice
2646    /// lifts fold on. Peer of the outer-top-level [`crate::Caixa`]
2647    /// `Option<&Composite>` composite-reference sub-family the
2648    /// [`crate::Caixa::limits`] (b2bd9d7) / [`crate::Caixa::behavior`]
2649    /// (35d8b52) / [`crate::Caixa::politicas`] (5d23d29) /
2650    /// [`crate::Caixa::placement`] (4fb8074) / [`crate::Caixa::entrada`]
2651    /// (e4128e4) accessors already close on the outer [`crate::Caixa`]
2652    /// altitude, and of the outer M3 mesh-slot [`crate::AplicacaoSpec`]
2653    /// altitude the sibling [`crate::AplicacaoSpec::entrada`] (d32111c)
2654    /// accessor already carries — extends that "one typed dispatch on
2655    /// the substrate primitive, thin projections at each consumer"
2656    /// discipline onto the third outer typed-slot altitude that carries
2657    /// an `Option<Composite>` axis (`Dep`, the outer per-dep-list-entry
2658    /// slot). Returns `Option<&DepSource>` (not the owning composite by
2659    /// copy or clone) because every downstream consumer of the fonte
2660    /// composite treats it as a read-only per-arm dispatch source — the
2661    /// reference-view is the narrowest borrow that supports every
2662    /// present + roadmapped consumer (per-arm match projection at the
2663    /// caixa-crd `CaixaSource` two-arm emitter, presence-probe early
2664    /// return on the "author-omitted `:fonte` ⇒ resolver-side
2665    /// `default_github` fill applies" partition every resolver
2666    /// consults, `.cloned()`-on-demand for the two resolver-side
2667    /// default-fill call sites that require an owned `DepSource` for
2668    /// `Option::unwrap_or_else`) without cloning the composite through
2669    /// every consumer's fast path. The `Option` half of the return-type
2670    /// preserves the load-bearing "author-omitted `:fonte` ⇒ resolver-
2671    /// side default applies" partition (not a default composite the
2672    /// downstream must reject on emptiness) — the accessor projects the
2673    /// raw `Option<DepSource>` slot's presence bit through the
2674    /// reference-return unchanged. Named `fonte()` to match the storage
2675    /// field's name verbatim and the tatara-lisp author-surface term
2676    /// (`:fonte`) the field's own docstring already carries.
2677    ///
2678    /// Declared `pub const fn` — the body projects through
2679    /// `Option::<DepSource>::as_ref`, const-stable since Rust 1.83 and
2680    /// well within the workspace MSRV, so every downstream `const`-
2681    /// context consumer of the per-`Dep` `:fonte` composite-reference
2682    /// accessor reaches through the same typed dispatch on the
2683    /// substrate primitive at const-eval time as at runtime. The
2684    /// paired [`dep_outer_accessor_family_is_const_fn`][pin] pin
2685    /// (a `const fn <name>_via_const_fn(d: &Dep) -> …` wrapper family
2686    /// that forwards through each lifted accessor) locks the posture
2687    /// load-bearing at caixa-core build time — any future accidental
2688    /// downgrade to non-`const` fails the wrapper with E0015
2689    /// (`cannot call non-const method`), strictly stronger than a
2690    /// runtime `assert!` and side-stepping the destructor-in-const
2691    /// restriction the `Dep` fixture's `String` / `Option<DepSource>`
2692    /// / `Vec<String>` carriers rule out. Peer of the sibling per-
2693    /// `WitContract` pre-projection accessor family's `const`-eval-
2694    /// surface pass (279823b) and of the outer-`Caixa` slice-return
2695    /// accessor family's parallel pass (231a968) — same "one canonical
2696    /// dispatch per axis, `const`-eval posture pinned at the substrate
2697    /// primitive, thin projections at each consumer" discipline
2698    /// extended onto the outer per-dep-list-entry [`Dep`] altitude.
2699    ///
2700    /// [pin]: tests::dep_outer_accessor_family_is_const_fn
2701    #[must_use]
2702    pub const fn fonte(&self) -> Option<&DepSource> {
2703        self.fonte.as_ref()
2704    }
2705
2706    /// Substrate-canonical per-`:deps` / `:deps-dev` entry
2707    /// `:caracteristicas` Cargo-shaped feature-toggle-set slice accessor
2708    /// every consumer of the dep-graph feature-flag axis keys off —
2709    /// returns the author-declared `:caracteristicas` feature-name list
2710    /// verbatim as a `&[String]` slice-view over the same backing buffer
2711    /// the raw `self.caracteristicas.as_slice()` field access borrows
2712    /// from. Empty-list-carrying (`:caracteristicas` is a default-empty
2713    /// axis every `Dep` supplies with `Vec::new()` when the author omits
2714    /// the slot; the [`crate::Caixa::from_lisp`] derive folds an omitted
2715    /// `:caracteristicas` through `#[serde(default)]` to `Vec::new()`,
2716    /// so a `Dep` past parse definitionally carries a `Vec<String>` slot
2717    /// — possibly empty — and the returned `&[String]` degenerates to
2718    /// an empty slice on that arm without any silent `None` collapse).
2719    ///
2720    /// The `:deps :caracteristicas` / `:deps-dev :caracteristicas` slot
2721    /// carries the set-shaped feature-toggle list the substrate walks
2722    /// through the [`Self::validate_caracteristicas`] per-entry shape +
2723    /// duplicate cascade — same Cargo `[dependencies.<dep>.features]`
2724    /// accept-set (per-entry Cargo-feature-name grammar via the shared
2725    /// [`crate::render::is_cargo_feature_name`] predicate, cross-entry
2726    /// uniqueness via the shared [`crate::render::insert_first_seen`]
2727    /// walk, empty-first / value-shape-second / duplicate-third
2728    /// precedence via the peer per-axis two-arm cascade discipline every
2729    /// substrate-blessed Vec-keyed-by-name slot already follows).
2730    /// Every downstream consumer that fans on the dep's feature-toggle
2731    /// keys off this accessor: [`Self::validate_caracteristicas`]'s
2732    /// per-entry linear walk that gates each feature-name byte-string
2733    /// through the empty / value-shape / duplicate arms (raising the
2734    /// [`DepError::CaracteristicaEmpty`] / [`DepError::CaracteristicaInvalid`]
2735    /// / [`DepError::CaracteristicaDuplicate`] carrier family naming the
2736    /// offending `Dep::nome`), and every future
2737    /// per-`Caixa`-manifest / caixa-resolver / caixa-crd feature-toggle-
2738    /// facing consumer the CAIXA-SDLC §I roadmap acknowledges (the
2739    /// future caixa-resolver per-dep feature-projection walk that folds
2740    /// the toggle set into the resolved [`crate::Caixa`]'s activated
2741    /// [`crate::render::CARGO_FEATURE_NAME_MAX_LEN`]-bounded feature
2742    /// closure ahead of the lacre hash, the future caixa-crd per-`spec.deps`
2743    /// features slice the K8s-CR admission gate consumes, the future
2744    /// per-cluster feature-overlay the M4 lacre-federation resolver
2745    /// composes ahead of the substrate-wide feature-name accept-set).
2746    ///
2747    /// Prior to this lift the `.caracteristicas` byte-string list was
2748    /// read inline at the [`Self::validate_caracteristicas`] `for c in
2749    /// &self.caracteristicas` walk — the only in-crate consumer of the
2750    /// raw field beyond the per-`Dep` constructor pair
2751    /// ([`Self::simple`] / [`Self::git`]) and the paired serde
2752    /// round-trip / per-test fixture-mutation paths — an open-coded
2753    /// field-access that expressed no compile-time link back to the
2754    /// typed slot. A future extension of the `:caracteristicas` axis to
2755    /// a richer author surface (a per-scope feature-overlay the resolver
2756    /// folds through the `~/.config/caixa/config.yaml` entry the
2757    /// [`Dep`] docstring already acknowledges, a per-cluster feature-
2758    /// activation overlay the future M4 lacre-federation layer applies
2759    /// per-CR, a promotion of the plain `Vec<String>` byte-string list
2760    /// to a richer parsed-feature-set newtype once the Cargo-shaped
2761    /// namespaced-dep `dep/feat` syntax the value-shape gate's
2762    /// docstring anticipates lands) would have had to be threaded
2763    /// through every open-coded copy in lockstep or two consumers
2764    /// would silently disagree on which feature closure a given dep
2765    /// activates — the [`Self::validate_caracteristicas`] gate walking
2766    /// the author-declared list while a downstream caixa-resolver
2767    /// consumer walked a per-scope-override-resolved list would
2768    /// silently split the build-time refusal from the lacre closure
2769    /// the substrate's fetch pipeline actually materializes, one
2770    /// build-time diagnostic disagreeing with the run-time closure.
2771    /// Lifting the resolution rule to a typed method on the substrate
2772    /// primitive means every downstream consumer of the caixa's per-
2773    /// `:deps` feature-toggle surface reaches for exactly one typed
2774    /// dispatch — the resolver's accept-set migrates as a unit on any
2775    /// future axis addition.
2776    ///
2777    /// First outer-`Dep` `&[T]`-return slice accessor — opens the
2778    /// outer-`Dep` `&[String]` slice projection pattern the sibling
2779    /// per-`Dep` `:opcional` (`bool` — the plain-`Copy`-scalar axis)
2780    /// future outer scalar lift folds on and closes the outer-`Dep`
2781    /// slot-family the sibling [`Self::nome`] (eba2cde) /
2782    /// [`Self::versao_requirement`] (05529b1) / [`Self::fonte`] (d65d1bf)
2783    /// accessors already open, leaving the `:opcional` `Copy`-scalar arm
2784    /// as the sole remaining unlifted outer-`Dep` slot. Peer of the
2785    /// outer top-level [`crate::Caixa`] `&[String]`-return foreign-code-
2786    /// slot sub-family ([`crate::Caixa::bibliotecas`] 8a36c23,
2787    /// [`crate::Caixa::exe`] 65d9527, [`crate::Caixa::servicos`]
2788    /// 611f78b) and the outer top-level [`crate::Caixa`] universal-axis
2789    /// text-tag family ([`crate::Caixa::autores`] b5d813f,
2790    /// [`crate::Caixa::etiquetas`] 78c7d3c) that already carry the
2791    /// `&[String]` slice-projection discipline on the outer-`Caixa`
2792    /// altitude — extends the "one typed dispatch on the substrate
2793    /// primitive, thin projections at each consumer" discipline onto the
2794    /// outer per-dep-list-entry [`Dep`] altitude's set-shaped byte-
2795    /// string list slot. Returns `&[String]` (not `&Vec<String>`)
2796    /// because every downstream consumer of the feature-toggle list
2797    /// treats it as a read-only sequence — the slice-view is the
2798    /// narrowest borrow that supports every present + roadmapped
2799    /// consumer (`.iter()`, `.len()`, `.is_empty()`) without leaking
2800    /// the backing `Vec`'s grow/push/reserve surface no consumer of
2801    /// the typed view reaches for (the storage-side `Vec` remains
2802    /// reachable through the `pub caracteristicas` field for the
2803    /// mutation-carrying serde round-trip and per-test fixture-mutation
2804    /// paths). Named `caracteristicas()` to match the storage field's
2805    /// name verbatim and the tatara-lisp author-surface term
2806    /// (`:caracteristicas`) the field's own docstring already carries.
2807    ///
2808    /// Declared `pub const fn` — the body projects through
2809    /// `Vec::<String>::as_slice`, const-stable since Rust 1.83 and
2810    /// well within the workspace MSRV, so every downstream `const`-
2811    /// context consumer of the per-`Dep` `:caracteristicas` slice-
2812    /// accessor reaches through the same typed dispatch on the
2813    /// substrate primitive at const-eval time as at runtime. Pinned
2814    /// load-bearing by the paired
2815    /// [`dep_outer_accessor_family_is_const_fn`][pin] wrapper family
2816    /// alongside its sibling [`Self::fonte`] — see [`Self::fonte`] for
2817    /// the full pin-shape rationale.
2818    ///
2819    /// [pin]: tests::dep_outer_accessor_family_is_const_fn
2820    #[must_use]
2821    pub const fn caracteristicas(&self) -> &[String] {
2822        self.caracteristicas.as_slice()
2823    }
2824
2825    /// Substrate-canonical per-`:deps` / `:deps-dev` entry `:opcional`
2826    /// missing-source-tolerance flag scalar accessor every consumer of
2827    /// the dep-graph opt-in-fetch axis keys off — returns the author-
2828    /// declared `:opcional` `bool` verbatim, `Copy`-projected from the
2829    /// typed slot's own `bool` storage (no borrow of `&self` past the
2830    /// call; the `Copy`-return arm matches the peer
2831    /// [`crate::Caixa::max_restarts`] (eba5211) `Option<u32>` `Copy`-
2832    /// projected sibling discipline the outer flat-spread family
2833    /// already carries). Default-`false` (`#[serde(default,
2834    /// skip_serializing_if = "is_false")]` on the storage slot, so a
2835    /// `Dep` past parse definitionally carries a `bool` — `false` when
2836    /// the author omits `:opcional` — and the returned value degenerates
2837    /// to `false` on that arm without any silent `None` collapse).
2838    ///
2839    /// The `:deps :opcional` / `:deps-dev :opcional` slot carries the
2840    /// per-entry "if this dep's `:fonte` cannot be resolved, treat the
2841    /// missing-source arm as a soft-fail rather than a build refusal"
2842    /// bit — the same Cargo-shaped `[dependencies.<dep>.optional = true]`
2843    /// accept-set (an opcional dep whose `:fonte` fails to resolve is
2844    /// dropped from the resolved dep-graph rather than tripping the
2845    /// build-refusal edge that a mandatory `:opcional false` entry
2846    /// would). Every downstream consumer that fans on the dep's
2847    /// missing-source-tolerance keys off this accessor: the future
2848    /// caixa-resolver's per-`:fonte` resolve-fail arm (drop-vs-error
2849    /// dispatch on the opcional bit ahead of the lacre closure
2850    /// materialization), the future caixa-crd per-`spec.deps`
2851    /// `optional` boolean the K8s-CR admission gate consumes on the
2852    /// per-dep partition, and the future feira / caixa-resolver /
2853    /// caixa-crd feature-projection walk that folds the opcional bit
2854    /// into the resolved feature-closure the future M4 lacre-federation
2855    /// layer emits.
2856    ///
2857    /// Prior to this lift the `.opcional` `bool` slot was read inline
2858    /// at the sole in-crate consumer site — the tests-module
2859    /// `registry_dep_is_minimal` fixture's `assert!(!d.opcional)` gate
2860    /// pinning the [`Self::simple`] constructor's default-`false` fill
2861    /// (the only in-crate read of the raw field beyond the per-`Dep`
2862    /// constructor pair [`Self::simple`] / [`Self::git`] and the paired
2863    /// serde round-trip / per-test fixture-mutation paths) — an open-
2864    /// coded field-access that expressed no compile-time link back to
2865    /// the typed slot. A future extension of the `:opcional` axis to a
2866    /// richer author surface (a per-scope opcional-override the resolver
2867    /// folds through the `~/.config/caixa/config.yaml` entry the [`Dep`]
2868    /// docstring already acknowledges, a per-cluster opcional-override
2869    /// the future M4 lacre-federation layer applies per-CR, a promotion
2870    /// of the plain `bool` to a richer `OpcionalPolicy { drop, warn,
2871    /// error }` tri-state once the CAIXA-SDLC §II opcional-policy
2872    /// roadmap lands) would have had to be threaded through every open-
2873    /// coded copy in lockstep or two consumers would silently disagree
2874    /// on which missing-source arm a given dep resolves to — the
2875    /// [`Self::simple`] constructor's default-`false` fill reading
2876    /// verbatim while a downstream caixa-resolver consumer read a per-
2877    /// scope-override-resolved bit would silently split the build-time
2878    /// arm from the lacre closure the substrate's fetch pipeline
2879    /// actually materializes, one build-time diagnostic disagreeing
2880    /// with the run-time closure. Lifting the resolution rule to a
2881    /// typed method on the substrate primitive means every downstream
2882    /// consumer of the caixa's per-`:deps` opcional-tolerance surface
2883    /// reaches for exactly one typed dispatch — the resolver's accept-
2884    /// set migrates as a unit on any future axis addition.
2885    ///
2886    /// Fifth and final outer-`Dep` accessor — closes the outer-`Dep`
2887    /// slot-family the sibling per-`Dep` [`Self::nome`] (eba2cde) /
2888    /// [`Self::versao_requirement`] (05529b1) / [`Self::fonte`] (d65d1bf)
2889    /// / [`Self::caracteristicas`] (9197944) accessors opened, so every
2890    /// outer-`Dep` slot (`:nome`, `:versao`, `:fonte`, `:opcional`,
2891    /// `:caracteristicas`) now routes through exactly one typed
2892    /// dispatch on the substrate primitive. First outer-`Dep`
2893    /// `bool`-return / plain-`Copy`-scalar accessor — opens the
2894    /// outer-`Dep` `Copy`-scalar projection pattern that folds on the
2895    /// peer outer-top-level [`crate::Caixa`] `Option<Copy>`
2896    /// flat-spread sub-family ([`crate::Caixa::max_restarts`] eba5211,
2897    /// [`crate::Caixa::estrategia`] ed04d3c) the outer-`Caixa` altitude
2898    /// already carries — extends the "one typed dispatch on the
2899    /// substrate primitive, thin projections at each consumer"
2900    /// discipline onto the outer per-dep-list-entry [`Dep`] altitude's
2901    /// bool-shaped missing-source-tolerance slot. Returns `bool` by
2902    /// `Copy` (not by `&bool` reference) because `bool` is `Copy` and
2903    /// every downstream consumer treats it as a plain discriminant
2904    /// value — the by-value return is the narrowest return-shape that
2905    /// supports every present + roadmapped consumer (`.then(…)` early
2906    /// return on the resolver-side drop-vs-error partition, direct
2907    /// bool composition with a per-scope-override projector, plain
2908    /// `if dep.opcional() { … }` early return at every future admission
2909    /// gate) without leaking the storage field's `bool`-in-`&self`
2910    /// lifetime the by-value return elides. Marked `pub const fn` so
2911    /// the accessor is `const`-callable — same discipline the peer
2912    /// [`crate::Caixa::max_restarts`] `Option<u32>` `Copy`-return
2913    /// accessor carries. Named `opcional()` to match the storage
2914    /// field's name verbatim and the tatara-lisp author-surface term
2915    /// (`:opcional`) the field's own docstring already carries.
2916    #[must_use]
2917    pub const fn opcional(&self) -> bool {
2918        self.opcional
2919    }
2920
2921    /// Build a minimal registry-sourced dep.
2922    #[must_use]
2923    pub fn simple(nome: impl Into<String>, versao: impl Into<String>) -> Self {
2924        Self {
2925            nome: nome.into(),
2926            versao: versao.into(),
2927            fonte: None,
2928            opcional: false,
2929            caracteristicas: Vec::new(),
2930        }
2931    }
2932
2933    /// Build a Git-sourced dep (tag-based).
2934    #[must_use]
2935    pub fn git(
2936        nome: impl Into<String>,
2937        versao: impl Into<String>,
2938        repo: impl Into<String>,
2939        tag: impl Into<String>,
2940    ) -> Self {
2941        Self {
2942            nome: nome.into(),
2943            versao: versao.into(),
2944            fonte: Some(DepSource::Git {
2945                repo: repo.into(),
2946                tag: Some(tag.into()),
2947                rev: None,
2948                branch: None,
2949            }),
2950            opcional: false,
2951            caracteristicas: Vec::new(),
2952        }
2953    }
2954
2955    /// Reject dependency entries whose `:nome` or `:versao` are empty,
2956    /// whose `:nome` is non-empty but not a valid DNS-1123 label,
2957    /// or whose `:versao` is non-empty but not a valid Cargo-shaped
2958    /// semver requirement.
2959    ///
2960    /// The author surface for `:deps :versao` (and `:deps-dev :versao`)
2961    /// is the same Cargo-shaped requirement string `:membros :versao`
2962    /// (validated at [`crate::AplicacaoSpec::validate`] since 9888b13)
2963    /// and `:children :versao` (validated at
2964    /// [`crate::SupervisorSpec::validate`] since b38ff3a) carry — and
2965    /// the lacre pipeline resolves all three axes through the same
2966    /// [`crate::parse_requirement`] entry-point. Until 2420c44 landed
2967    /// `:deps :versao` was the last `:versao` axis untyped past
2968    /// `Caixa::from_lisp`: a malformed-but-non-empty requirement
2969    /// (`"^bad-version"`, `"^^0.1"`, the canonical git-tag-shape-
2970    /// leaking-into-:versao `"v0.1"` typo, the accidental
2971    /// `"not-a-req"`) silently passed parse and the `semver::Error`
2972    /// surfaced at lacre-resolve time, far from the source
2973    /// caixa.lisp, with no field naming which `:deps` entry carried
2974    /// the typo. The diagnostic [`DepError::VersaoInvalid`] carries
2975    /// the offending entry's `:nome` + the offending `:versao`
2976    /// verbatim + the parser's own wording in `reason`, so the
2977    /// author's grep target is unambiguous.
2978    ///
2979    /// The author surface for `:deps :nome` is the same DNS-1123 label
2980    /// the peer caixa-identifier axes carry — top-level Caixa `:nome`
2981    /// (validated at [`crate::Caixa::validate_nome`] since 6c992f8),
2982    /// `:membros :caixa` (validated at
2983    /// [`crate::AplicacaoSpec::validate_membros`] since 3f9d7a0),
2984    /// `:children :caixa` (validated at
2985    /// [`crate::SupervisorSpec::validate`] since 31bfa43). A `:deps
2986    /// :nome` value flows verbatim through the lacre pipeline as the
2987    /// target caixa's `:nome` (which the gate at the *target* side now
2988    /// rejects if non-DNS-1123) and lands as the rendered caixa's
2989    /// `lareira-<nome>` Helm chart name segment, the per-dep
2990    /// `LABEL_PROGRAM` label value, and the `caixa-resolver`'s
2991    /// `~/.cache/caixa/<org>/<nome>` checkout-directory leaf. Until
2992    /// this gate landed `:deps :nome` was the fourth and last
2993    /// DNS-1123-shaped caixa-identifier axis still untyped past
2994    /// `Caixa::from_lisp`: a syntactically wrong dep name (`"Caixa-
2995    /// Teia"` uppercase — the canonical "I copied the README header"
2996    /// typo; `"caixa_teia"` underscore — the Go module / Python
2997    /// identifier leak; `"caixa-teia."` trailing dot — the FQDN
2998    /// confusion; `"-caixa-teia"` leading hyphen; a 64-byte slug)
2999    /// silently passed parse and surfaced at lacre-resolve time when
3000    /// the resolved target caixa's `:nome` failed *its* DNS-1123 gate
3001    /// — far from the source `:deps` entry, with a diagnostic naming
3002    /// the *target's* `:nome` rather than the dep entry that referenced
3003    /// it. Mirroring the 3f9d7a0 / 31bfa43 / 6c992f8 trajectory through
3004    /// the lifted [`crate::render::is_dns_1123_label`] predicate (the
3005    /// "before its third occurrence" PRIME DIRECTIVE boundary, THEORY.md
3006    /// §I.3.5): every `Dep::nome` past validate is DNS-1123-label-shaped,
3007    /// so every downstream consumer (caixa-resolver's lacre fetch,
3008    /// caixa-helm's `lareira-<nome>` chart name, the future M4 per-dep
3009    /// fan-out emitter) reaches for the name knowing the value is
3010    /// apiserver-valid without re-validating.
3011    ///
3012    /// Empty checks fire first (narrower diagnostic), parse last —
3013    /// same ordering discipline as
3014    /// [`crate::AplicacaoSpec::validate_membros`] and
3015    /// [`crate::SupervisorSpec::validate`]. `parse_requirement("")`
3016    /// returns `Ok(VersionReq::STAR)`, so the empty-`:versao` arm is
3017    /// structurally necessary even with the parse arm in place. The
3018    /// `:nome` shape gate runs after the `:nome` empty gate and before
3019    /// the `:versao` checks so a one-entry caixa.lisp with both wrong
3020    /// sees the name-side diagnostic first (the name is the
3021    /// self-locating axis — without it, the parse diagnostic can't
3022    /// quote `:nome "<bad>"`).
3023    pub fn validate(&self) -> Result<(), DepError> {
3024        if self.nome.is_empty() {
3025            return Err(DepError::NomeEmpty);
3026        }
3027        if let Err(reason) = crate::render::is_dns_1123_label(&self.nome) {
3028            return Err(DepError::NomeInvalid {
3029                nome: self.nome.clone(),
3030                reason,
3031            });
3032        }
3033        // Delegate the empty-first + `parse_requirement` cascade to the
3034        // shared [`crate::render::require_valid_versao_requirement`]
3035        // helper — same two-arm shape the peer
3036        // [`crate::AplicacaoSpec::validate_membros`] on `:membros
3037        // :versao` and [`crate::SupervisorSpec::validate`] on `:children
3038        // :versao` route through, so drift between the three axes'
3039        // accepted requirement sets is structurally impossible and the
3040        // parse-side no-op the empty-first arm closes (semver's empty
3041        // parse yields an implicit `*`) lives in exactly one predicate.
3042        crate::render::require_valid_versao_requirement(
3043            self.versao_requirement(),
3044            || DepError::versao_empty(&self.nome),
3045            |reason| DepError::VersaoInvalid {
3046                nome: self.nome.clone(),
3047                versao: self.versao_requirement().to_string(),
3048                reason,
3049            },
3050        )?;
3051        if let Some(fonte) = self.fonte() {
3052            fonte.validate(&self.nome)?;
3053        }
3054        self.validate_caracteristicas()?;
3055        Ok(())
3056    }
3057
3058    /// Reject per-entry `:caracteristicas` (feature-flag) values that
3059    /// are operationally meaningless. The `:caracteristicas` slot is
3060    /// a set of feature toggles to enable on the target caixa — same
3061    /// shape as Cargo's `[dependencies.<dep>.features]` list — and
3062    /// two structural footguns close here:
3063    ///
3064    ///   - empty-string entry (`(:caracteristicas (""))`): the future
3065    ///     caixa-resolver lacre pipeline would consume the empty
3066    ///     identifier as a no-op feature enable, silently dropping the
3067    ///     author's intent far from the source `caixa.lisp`;
3068    ///   - duplicate entry within one dep (`(:caracteristicas ("http"
3069    ///     "http"))`): the feature-toggle slot is set-shaped (enabling
3070    ///     a feature twice has no additional semantic — there is no
3071    ///     `feature × 2`), so two entries naming the same feature are
3072    ///     a silent miscount, the same set-not-multiset distinction
3073    ///     every peer Vec-keyed-by-name axis already closes
3074    ///     ([`crate::SupervisorError::DuplicateChildCaixa`] on
3075    ///     `:children :caixa`, [`crate::AplicacaoError::MembroDuplicate`]
3076    ///     on `:membros :caixa`, [`crate::AplicacaoError::ContratoDuplicate`]
3077    ///     on `:contratos`, [`crate::AplicacaoError::PlacementClusterDuplicate`]
3078    ///     on `:placement :clusters`, [`crate::AplicacaoError::EntradaPathDuplicate`]
3079    ///     on `:entrada :paths`, [`crate::UpgradeError::DuplicateFrom`]
3080    ///     on `:upgrade-from :from`, [`crate::UpgradeError::DuplicateLoadModule`]
3081    ///     / [`crate::UpgradeError::DuplicateStateChange`] /
3082    ///     [`crate::UpgradeError::DuplicateCleanup`] on the within-
3083    ///     entry `:upgrade-from` axes, and [`DepError::DuplicateNome`]
3084    ///     on the cross-entry `:deps`/`:deps-dev` `:nome` axis the
3085    ///     immediate-predecessor 359fba5 closed).
3086    ///
3087    /// Same linear-walk + `HashSet` + first-collision diagnostic shape
3088    /// every peer set-not-multiset gate uses; the empty arm fires
3089    /// before the duplicate arm so an entry with both an empty feature
3090    /// *and* a duplicate of some later feature surfaces the empty-
3091    /// shape diagnostic first (the empty-feature axis is the
3092    /// more-actionable defect since the missing-name renders the
3093    /// duplicate-key arm ambiguous: two `""` entries would both report
3094    /// `caracteristica: ""` with no way to distinguish the offending
3095    /// site). Empty-first cascade discipline mirrors every peer per-
3096    /// entry shape + duplicate gate
3097    /// (`SupervisorSpec::validate`'s `EmptyChildName` before
3098    /// `DuplicateChildCaixa`; `validate_membros`'s `MembroCaixaEmpty`
3099    /// before `MembroDuplicate`).
3100    ///
3101    /// The per-entry value-shape gate (Cargo-feature-name grammar via
3102    /// the lifted [`crate::render::is_cargo_feature_name`] predicate)
3103    /// fires between the empty arm and the duplicate arm — the
3104    /// canonical per-entry-shape-before-cross-entry-uniqueness
3105    /// precedence every peer two-arm + value-shape gate establishes
3106    /// ([`crate::SupervisorSpec::validate`]'s `EmptyChildName` →
3107    /// `ChildCaixaInvalid` → `DuplicateChildCaixa`,
3108    /// [`crate::AplicacaoSpec::validate_membros`]'s `MembroCaixaEmpty`
3109    /// → `MembroCaixaInvalid` → `MembroDuplicate`, [`Dep::validate`]'s
3110    /// `NomeEmpty` → `NomeInvalid` → cross-list `DuplicateNome`).
3111    /// Until the value-shape arm landed `:caracteristicas` accepted
3112    /// every non-empty distinct string — a structurally invalid
3113    /// feature name (`"http feature"` whitespace, `"+http"` the
3114    /// canonical paste-from-`+optional-feature` doc activation-form
3115    /// footgun, `"-flag"` leading hyphen, `".feat"` leading dot,
3116    /// `"http/json"` Cargo's `dep/feat` namespaced-dep syntax that
3117    /// only applies inside list-grammar contexts, `"http,json"`
3118    /// list-separator-belongs-to-the-list-grammar miscomprehension,
3119    /// `"café"` un-percent-encoded non-ASCII silently round-tripping
3120    /// inconsistently across NFC/NFD normalization, the 65-byte
3121    /// paste-from-binary slug) silently passed validate and the
3122    /// failure surfaced at `cargo metadata` time as the
3123    /// `restricted_names::validate_feature_name` parser's rejection,
3124    /// far from the source `caixa.lisp`, with no field naming which
3125    /// `:deps` entry's `:caracteristicas` carried the typo. The
3126    /// lifted predicate makes the Cargo-feature-name-grammar
3127    /// intersection-floor a substrate-level invariant at validate
3128    /// time — same trajectory as the eight peer
3129    /// [`crate::render`] value-shape predicates each typed surface
3130    /// downstream of a structured grammar already follows
3131    /// ([`is_dns_1123_label`](crate::render::is_dns_1123_label),
3132    /// [`is_gateway_api_http_path`](crate::render::is_gateway_api_http_path),
3133    /// [`is_wit_world_ref`](crate::render::is_wit_world_ref),
3134    /// [`is_nats_subject`](crate::render::is_nats_subject),
3135    /// [`is_wasi_keyvalue_slot`](crate::render::is_wasi_keyvalue_slot),
3136    /// [`is_git_ref_name`](crate::render::is_git_ref_name),
3137    /// [`is_git_oid`](crate::render::is_git_oid),
3138    /// [`is_git_repo_url`](crate::render::is_git_repo_url)).
3139    fn validate_caracteristicas(&self) -> Result<(), DepError> {
3140        let mut seen = std::collections::HashSet::new();
3141        for c in self.caracteristicas() {
3142            if c.is_empty() {
3143                return Err(DepError::caracteristica_empty(&self.nome));
3144            }
3145            if let Err(reason) = crate::render::is_cargo_feature_name(c) {
3146                return Err(DepError::CaracteristicaInvalid {
3147                    nome: self.nome.clone(),
3148                    caracteristica: c.clone(),
3149                    reason,
3150                });
3151            }
3152            crate::render::insert_first_seen(&mut seen, c.as_str(), || {
3153                DepError::CaracteristicaDuplicate {
3154                    nome: self.nome.clone(),
3155                    caracteristica: c.clone(),
3156                }
3157            })?;
3158        }
3159        Ok(())
3160    }
3161}
3162
3163/// Cross-slot coherence gate on the dep-graph axis: no `:deps` or
3164/// `:deps-dev` entry may name the caixa's own `:nome`.
3165///
3166/// A caixa that lists itself as a dep is a degenerate self-edge in the
3167/// lacre closure's dep-graph — the closure is a DAG rooted at the
3168/// caixa's `:nome`, and the caixa-resolver's lacre pipeline traverses
3169/// every `:deps` / `:deps-dev` entry's target by name. A self-dep
3170/// hands the resolver a node that is its own parent: a one-node cycle
3171/// it either rejects mid-traversal far from the source `caixa.lisp`
3172/// (the resolver detecting infinite recursion on the closure walk) or,
3173/// worse, recurses on until it exhausts its stack. Because every
3174/// `:nome` is a globally-unique substrate identity (DNS-1123 label +
3175/// lacre closure root), a dep entry whose `:nome` equals the caixa's
3176/// own `:nome` *is* the caixa itself, not a coincidentally-named peer.
3177///
3178/// Lives outside [`Caixa::validate_deps`] because the dep-list view
3179/// carries the entries but not the parent `:nome`; mirrors the
3180/// cross-slot self-edge gates [`crate::supervisor::validate_no_self_supervision`]
3181/// (ad4abf1) on the `:children :caixa` axis and
3182/// [`crate::aplicacao::validate_no_self_membership`] on the
3183/// `:membros :caixa` axis — the same "an edge from a graph node to
3184/// itself is structurally not a tree/graph edge" discipline, here on
3185/// the third typed-name-graph axis (the dep closure; the supervision
3186/// tree and the Aplicacao membership set were the prior two).
3187///
3188/// Walks `:deps` first then `:deps-dev` so the diagnostic for a caixa
3189/// that self-references on both axes surfaces the `:deps` arm first —
3190/// the load-bearing axis the lacre closure resolves at every build,
3191/// peer with the canonical [`Caixa::validate_deps`] walk order
3192/// (`:deps` → `:deps-dev`).
3193///
3194/// Carries the offending list tag (`":deps"` or `":deps-dev"`)
3195/// verbatim into the diagnostic so the author can grep their
3196/// `caixa.lisp` for the offending block in one edit — same
3197/// `list: &'static str` shape [`DepError::DuplicateNome`] (359fba5)
3198/// uses on the cross-list duplicate-name axis.
3199///
3200/// `Code paths` (`:bibliotecas` / `:exe` / `:servicos`) are the
3201/// substrate-blessed shape for referencing the caixa's *own* code, so
3202/// the diagnostic names them as the corrective surface — every
3203/// legitimate "I want to use code from this caixa" authoring intent
3204/// routes through one of those three slots, not a self-dep.
3205pub fn validate_no_self_dep(
3206    deps: &[Dep],
3207    deps_dev: &[Dep],
3208    parent_nome: &str,
3209) -> Result<(), DepError> {
3210    for dep in deps {
3211        if dep.nome() == parent_nome {
3212            return Err(DepError::DepIsSelf {
3213                nome: parent_nome.to_string(),
3214                list: crate::render::DEP_AUTHOR_KEY_DEPS,
3215            });
3216        }
3217    }
3218    for dep in deps_dev {
3219        if dep.nome() == parent_nome {
3220            return Err(DepError::DepIsSelf {
3221                nome: parent_nome.to_string(),
3222                list: crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
3223            });
3224        }
3225    }
3226    Ok(())
3227}
3228
3229/// Closed-set typed enum for the two dep-list author-surface axes every
3230/// top-level [`crate::Caixa`] carries — the runtime-closure `:deps` slot
3231/// (`Prod`) and the dev-only-closure `:deps-dev` slot (`Dev`). Every
3232/// substrate consumer that dispatches on "which of the two dep-lists"
3233/// (the `feira add` mutation head, the future per-cluster dev-closure-
3234/// audit overlay the M4 CR materializer resolves per-CR, the future
3235/// `caixa app graph` per-list dep summary, every future
3236/// `Caixa::push_dep` / `Caixa::deps_by_list` typed-method dispatch a
3237/// caller reaches for) reads through this enum rather than through a
3238/// bare `&'static str` — the closed-set is expressed at the type layer,
3239/// so a future third dep-list axis (a `:deps-build` build-only closure
3240/// once the substrate grows cross-artifact heterogeneous dep-graphs,
3241/// per CAIXA-SDLC §I) is one variant plus one arm per method and the
3242/// compiler enforces exhaustiveness on every consumer's `match` arms.
3243///
3244/// The wire byte-string [`Self::as_str`] returns is the same author-
3245/// surface tag the sibling [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3246/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] constants carry — the
3247/// [`DepError::DuplicateNome`] / [`DepError::DepIsSelf`] `list:
3248/// &'static str` payload family the substrate already emits routes
3249/// through the same source of truth (an author reading a
3250/// [`DepError::DuplicateNome`] refusal can grep their `caixa.lisp`
3251/// for the offending `:deps` / `:deps-dev` block in one edit whether
3252/// the diagnostic came from a `Caixa::validate_deps` walk or a
3253/// `Caixa::push_dep` mutation).
3254///
3255/// Same "closed-set typed-enum discriminator with canonical
3256/// projections per axis" discipline the sibling closed-set typed enums
3257/// on the caixa typed surface carry
3258/// ([`crate::aplicacao::PlacementStrategy`] cc8f749,
3259/// [`crate::aplicacao::RateLimitUnit`] 6bce03d,
3260/// [`crate::supervisor::RestartStrategy`],
3261/// [`crate::supervisor::RestartPolicy`],
3262/// [`crate::upgrade::UpgradeInstruction`], [`crate::CaixaKind`])
3263/// — extended onto the outer-`Caixa` two-list dep-graph axis, the
3264/// substrate's last unlifted closed-set-shaped `&'static str`-carrying
3265/// axis on the top-level manifest surface.
3266#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, gen_platform::IsVariant)]
3267pub enum DepList {
3268    /// Runtime-closure `:deps` axis — the load-bearing dep-list the
3269    /// lacre closure resolves at every build. Wire-format
3270    /// [`crate::render::DEP_AUTHOR_KEY_DEPS`].
3271    Prod,
3272    /// Dev-only-closure `:deps-dev` axis — Cargo's `[dev-dependencies]`
3273    /// table's dev-time-only visibility contract per CAIXA-SDLC §I.
3274    /// Wire-format [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`].
3275    Dev,
3276}
3277
3278impl DepList {
3279    /// Exhaustive iteration surface for every consumer that reads the
3280    /// full closed-set (the future M4 admission webhook's per-list
3281    /// summary rejection body, any future round-trip pin harness). A
3282    /// future variant addition extends this slice as a single edit and
3283    /// every consumer picks up the new entry by construction — the
3284    /// compiler-checked exhaustiveness on the sibling method `match`
3285    /// arms is the build-time guarantee that no arm forgets to grow.
3286    pub const ALL: &'static [Self] = &[Self::Prod, Self::Dev];
3287
3288    /// Canonical author-surface tag every substrate consumer that
3289    /// names the offending dep-list in a diagnostic reaches for —
3290    /// [`crate::render::DEP_AUTHOR_KEY_DEPS`] for [`Self::Prod`] and
3291    /// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] for [`Self::Dev`],
3292    /// the same `&'static str` payload the sibling
3293    /// [`DepError::DuplicateNome`] and [`DepError::DepIsSelf`] variants
3294    /// already carry. Routing every dep-list diagnostic through the
3295    /// closed-set enum's `as_str` closes the last `&'static str`-shape
3296    /// literal-carry axis on the two-list dep-graph surface — a
3297    /// future kebab-case rebrand (`":deps"` → `":packages"`) or a
3298    /// wire-format promotion (a distinct diagnostic form for the
3299    /// `Dev` arm) reaches every consumer through one edit on the
3300    /// canonical constant, not a coordinated rewrite across the
3301    /// substrate's dep-graph consumers.
3302    #[must_use]
3303    pub const fn as_str(self) -> &'static str {
3304        match self {
3305            Self::Prod => crate::render::DEP_AUTHOR_KEY_DEPS,
3306            Self::Dev => crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
3307        }
3308    }
3309
3310    /// Substrate-canonical reverse projection on the two-list dep-graph
3311    /// axis — parses the author-surface wire tag back to the typed
3312    /// variant, or `None` when `s` is outside the closed-set arm-string
3313    /// set [`Self::as_str`] emits. Dispatches on the same lifted
3314    /// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3315    /// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] constants the
3316    /// [`Self::as_str`] emitter walks, so the parse and emit halves of
3317    /// the round-trip migrate through one caixa-core edit on any future
3318    /// list-axis addition.
3319    ///
3320    /// Prior to this lift the substrate carried only the forward
3321    /// `Self → &str` projection on the two-list dep-graph axis (the
3322    /// [`Self::as_str`] emitter, the [`std::fmt::Display`] impl routed
3323    /// through it, the two [`DepError::DuplicateNome`] /
3324    /// [`DepError::DepIsSelf`] variants that carry the wire tag verbatim
3325    /// as a `&'static str` `list:` field). Every future consumer that
3326    /// wanted to promote the wire tag back to the typed enum (a future
3327    /// `feira dep --list <deps|deps-dev>` CLI arg-parse that binds the
3328    /// wire form into the typed enum before dispatching to
3329    /// [`crate::Caixa::deps_of`] / [`crate::Caixa::push_dep`], the M4
3330    /// `mesh.pleme.io/v1alpha1/Caixa` CR materializer's admission-time
3331    /// wire re-parse of the per-list diagnostic body, a future
3332    /// [`DepError`] widening that promotes the two `list: &'static str`
3333    /// fields to a typed `list: DepList` carry so downstream consumers
3334    /// dispatch on the enum rather than string-comparing the wire
3335    /// scalar) would have had to re-inline a two-arm `match s { ":deps"
3336    /// => …, ":deps-dev" => …, _ => … }` cascade that expressed no
3337    /// compile-time link back to the typed [`DepList`] enum. A future
3338    /// variant addition (a `:build-dep` or `:test-dep` third list once
3339    /// the substrate grows Cargo-style split-graphs, a `:tool-dep` for
3340    /// build-time-only tooling per the peer Cargo `[build-dependencies]`
3341    /// / `[target.<cfg>.dev-dependencies]` future admission surface)
3342    /// would silently split the wire byte-string the emitter walks from
3343    /// the parser's arm-set — the round-trip would carry the new list
3344    /// through the forward projection but land on the fallback silently
3345    /// at every non-updated reverse parser, far from the arm-addition
3346    /// commit that caused the drift. Lifting the resolver to a typed
3347    /// method on the substrate primitive closes the drift footgun by
3348    /// construction: the parser's accept-set is the same set the
3349    /// [`Self::as_str`] emitter walks (routed through the same lifted
3350    /// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3351    /// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] consts), so both halves
3352    /// of the round-trip migrate through one caixa-core edit on any
3353    /// future list-axis addition.
3354    ///
3355    /// Same closed-set-reverse-projection discipline the sibling
3356    /// [`crate::CaixaKind::from_wire`] (2aa6d23) /
3357    /// [`crate::supervisor::RestartStrategy::from_wire`] (4eec29c) /
3358    /// [`crate::supervisor::RestartPolicy::from_wire`] (dd32ccf) /
3359    /// [`crate::aplicacao::PlacementStrategy::from_wire`] (18c7342) /
3360    /// [`crate::aplicacao::RateLimitUnit::from_suffix`] typed enums
3361    /// carry on the peer wire-side `str → Self` axes — extended onto
3362    /// the two-list dep-graph closed-set axis, the sixth substrate-side
3363    /// closed-set typed enum on the caixa surface to converge on the
3364    /// two-way `str ↔ Self` round-trip. Method-named `from_wire` (not
3365    /// `from_str`) to match the peer shapes verbatim and side-step the
3366    /// derived [`std::str::FromStr`] impls the sibling
3367    /// [`gen_platform::FromStrKind`]-carrying axes install on their
3368    /// kebab-case dispatcher-catalog identity. Returns `Option<Self>`
3369    /// (rather than `Result<Self, _>`) to match the peer shapes: the
3370    /// caller picks the diagnostic form appropriate for its use site —
3371    /// a future `feira dep --list …` arg-parse that surfaces
3372    /// `unknown list: <arg>` at the CLI builds one on top by iterating
3373    /// [`Self::ALL`], while the future M4 admission-webhook's rejection
3374    /// path folds `None` onto its per-CR structured refusal body.
3375    #[must_use]
3376    pub fn from_wire(s: &str) -> Option<Self> {
3377        match s {
3378            crate::render::DEP_AUTHOR_KEY_DEPS => Some(Self::Prod),
3379            crate::render::DEP_AUTHOR_KEY_DEPS_DEV => Some(Self::Dev),
3380            _ => None,
3381        }
3382    }
3383}
3384
3385/// Route [`std::fmt::Display`] through [`DepList::as_str`], so every
3386/// consumer that formats the axis as user-facing text (a future
3387/// `feira app graph` per-list summary, a future M4 admission-webhook
3388/// rejection body naming the offending list, this crate's own
3389/// [`DepError`] `#[error(...)]` templates when they widen to carry a
3390/// typed [`DepList`]) lands on the same author-surface tag the
3391/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3392/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] constants carry. Same
3393/// as-str-through-Display convergence discipline the sibling
3394/// [`crate::aplicacao::PlacementStrategy`],
3395/// [`crate::aplicacao::RateLimitUnit`],
3396/// [`crate::supervisor::RestartStrategy`],
3397/// [`crate::supervisor::RestartPolicy`], and [`crate::CaixaKind`]
3398/// closed-set typed enums carry.
3399impl std::fmt::Display for DepList {
3400    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3401        f.write_str(self.as_str())
3402    }
3403}
3404
3405/// Errors raised by [`Dep::validate`].
3406///
3407/// Mirrors the per-axis error families the other `:versao`-carrying
3408/// typed surfaces expose
3409/// ([`crate::AplicacaoError::MembroVersaoEmpty`] /
3410/// [`crate::AplicacaoError::MembroVersaoInvalid`],
3411/// [`crate::SupervisorError::EmptyChildVersion`] /
3412/// [`crate::SupervisorError::ChildVersaoInvalid`]) so a future top-
3413/// level `CaixaError` (M4) sums these without reshaping the diagnostic.
3414#[derive(Debug, Error, PartialEq, Eq)]
3415pub enum DepError {
3416    #[error(
3417        ":deps entry has empty :nome (every dep must name a target caixa; \
3418         omit the entry instead of carrying an empty name)"
3419    )]
3420    NomeEmpty,
3421    #[error(
3422        ":deps entry :nome {nome:?} is not a valid DNS-1123 label: {reason} \
3423         (the value flows verbatim as the target caixa's `:nome`, the rendered \
3424         `lareira-<nome>` Helm chart name segment, the `LABEL_PROGRAM` label \
3425         value, and the resolver's checkout-directory leaf — each apiserver-side \
3426         schema rejects non-DNS-1123 names at admission time; use a lowercase \
3427         RFC 1123 label like `\"caixa-teia\"` or `\"pleme-mesh\"`, 1..=63 bytes, \
3428         pattern `^[a-z0-9]([-a-z0-9]*[a-z0-9])?$`)"
3429    )]
3430    NomeInvalid { nome: String, reason: String },
3431    #[error(
3432        ":deps entry {nome:?} has empty :versao (every dep must pin a semver \
3433         constraint that resolves through the lacre pipeline)"
3434    )]
3435    VersaoEmpty { nome: String },
3436    #[error(
3437        ":deps entry {nome:?} :versao {versao:?} is not a valid semver \
3438         requirement: {reason} (use Cargo-shaped forms like `\"^0.1\"`, \
3439         `\"~0.1.2\"`, `\"0.1.0\"`, or `\"*\"` — the same shape `:membros :versao` \
3440         and `:children :versao` carry; the lacre pipeline resolves all three \
3441         through the same parser)"
3442    )]
3443    VersaoInvalid {
3444        nome: String,
3445        versao: String,
3446        reason: String,
3447    },
3448    #[error(
3449        ":deps entry {nome:?} :fonte (:tipo git …) has empty :repo \
3450         (every git source must name a repo — use a `github:org/repo` \
3451         shorthand, an `https://…` URL, or an ssh-git URL; omit the \
3452         entire :fonte block to fall back to the default-host resolver \
3453         convention)"
3454    )]
3455    FonteRepoEmpty { nome: String },
3456    #[error(
3457        ":deps entry {nome:?} :fonte (:tipo git …) :repo {repo:?} has \
3458         invalid value-shape: {reason} (the value flows verbatim into the \
3459         caixa-resolver's `git clone <repo>` subprocess invocation; every \
3460         documented form carries a `:` separator and no whitespace / \
3461         control / non-ASCII bytes — use a `github:org/repo` shorthand, \
3462         an `https://host/path` / `ssh://[user@]host/path` / \
3463         `git://host/path` / `file:///path` URL, or the `git@host:path` \
3464         scp-style SSH form)"
3465    )]
3466    FonteRepoShape {
3467        nome: String,
3468        repo: String,
3469        reason: String,
3470    },
3471    #[error(
3472        ":deps entry {nome:?} :fonte (:tipo git …) has no pin set \
3473         (set exactly one of :tag, :rev, or :branch so the resolver \
3474         can pick a reproducible commit; omit the entire :fonte block \
3475         to fall back to the default-host resolver convention, which \
3476         resolves the latest tag matching :versao)"
3477    )]
3478    FontePinMissing { nome: String },
3479    #[error(
3480        ":deps entry {nome:?} :fonte (:tipo git …) has multiple pins \
3481         set ({pins}); exactly one of :tag, :rev, or :branch must be \
3482         set so the resolver's checkout target is unambiguous (the \
3483         resolver's silent precedence is :rev > :tag > :branch — if \
3484         you intended one specifically, drop the others)"
3485    )]
3486    FontePinAmbiguous { nome: String, pins: String },
3487    #[error(
3488        ":deps entry {nome:?} :fonte (:tipo git …) has empty {pin} \
3489         (a set pin must name a non-empty git ref; drop the {pin} key \
3490         entirely to fall through to another pin axis)"
3491    )]
3492    FontePinEmpty { nome: String, pin: String },
3493    #[error(
3494        ":deps entry {nome:?} :fonte (:tipo git …) {pin} {value:?} has invalid \
3495         value-shape: {reason} (the git porcelain enforces the same shape at \
3496         `git fetch` / `git checkout` time on every pin; use a leaf refname \
3497         like `\"v0.1.0\"` for `:tag` or `\"main\"` / `\"feature/foo\"` for \
3498         `:branch`, or a full 40/64 lowercase-hex commit OID for `:rev` — \
3499         drop any `refs/heads/` or `refs/tags/` prefix the caixa-resolver \
3500         prepends at clone time, and avoid abbreviated SHAs which are \
3501         ambiguous across repository history)"
3502    )]
3503    FontePinShape {
3504        nome: String,
3505        pin: String,
3506        value: String,
3507        reason: String,
3508    },
3509    #[error(
3510        ":deps entry {nome:?} :fonte (:tipo path …) has empty :caminho \
3511         (every path source must name a non-empty filesystem path; \
3512         omit the entire :fonte block to fall back to the default-host \
3513         resolver convention)"
3514    )]
3515    FonteCaminhoEmpty { nome: String },
3516    #[error(
3517        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} is \
3518         absolute (the lacre pipeline embeds the value verbatim in its \
3519         per-dep content-address `path:{caminho}` at \
3520         caixa-resolver/src/resolve.rs:189, so an absolute path makes the \
3521         BLAKE3 closure differ across machines — defeating the \
3522         reproducibility contract that's load-bearing for CSE; express \
3523         the path relative to the caixa.lisp location, e.g. \
3524         \"../caixa-teia\" for a sibling workspace dep)"
3525    )]
3526    FonteCaminhoAbsolute { nome: String, caminho: String },
3527    #[error(
3528        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
3529         with `~` (the leading-tilde is a shell-expansion convention, not a \
3530         POSIX path component — `Path::is_absolute` returns false on it, so \
3531         the b94fd83 absolute-path gate doesn't catch it, but the lacre \
3532         pipeline embeds the value verbatim in its per-dep content-address \
3533         `path:{caminho}` at caixa-resolver/src/resolve.rs:189 and the \
3534         caixa-resolver folds it through `Path::join` without `~`-expansion, \
3535         so the build looks for a literal `./{caminho}` subdirectory and \
3536         fails at resolve time far from the source caixa.lisp; even worse, a \
3537         future caixa-resolver pass that *does* expand `~` would silently \
3538         re-open the host-layout-leak the b94fd83 absolute gate closes — \
3539         Alice's `~` resolves to `/home/alice`, Bob's to `/home/bob`, two CI \
3540         runners with different `$HOME` layouts resolve to two distinct paths \
3541         for the byte-identical caixa, defeating the THEORY.md §V.2 render-\
3542         determinism contract; express the path relative to the caixa.lisp \
3543         location, e.g. \"../caixa-teia\" for a sibling workspace dep, or \
3544         spell out the full relative path explicitly if a workstation-rooted \
3545         dep is genuinely intended)"
3546    )]
3547    FonteCaminhoTildeExpansion { nome: String, caminho: String },
3548    #[error(
3549        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
3550         with `$` (the leading-`$` is a shell-variable-expansion convention, \
3551         not a POSIX path component — `Path::is_absolute` returns false on it \
3552         and the a5c248e tilde gate doesn't catch it, but the lacre pipeline \
3553         embeds the value verbatim in its per-dep content-address \
3554         `path:{caminho}` at caixa-resolver/src/resolve.rs:189 and the \
3555         caixa-resolver folds it through `Path::join` without `$`-expansion, \
3556         so the build looks for a literal `./{caminho}` subdirectory and \
3557         fails at resolve time far from the source caixa.lisp; even worse, a \
3558         future caixa-resolver pass that *does* expand `$VAR` (the canonical \
3559         shell-convention idiom that CI's `${{WORKSPACE}}` paste-idiom \
3560         invites) would silently re-open the host-layout-leak the b94fd83 \
3561         absolute gate closes — Alice's `$HOME` resolves to `/home/alice`, \
3562         Bob's to `/home/bob`, two CI runners with different `${{WORKSPACE}}` \
3563         layouts resolve to two distinct paths for the byte-identical caixa, \
3564         defeating the THEORY.md §V.2 render-determinism contract; express \
3565         the path relative to the caixa.lisp location, e.g. \"../caixa-teia\" \
3566         for a sibling workspace dep, or spell out the full relative path \
3567         explicitly if a workstation-rooted dep is genuinely intended)"
3568    )]
3569    FonteCaminhoVarExpansion { nome: String, caminho: String },
3570    #[error(
3571        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
3572         with a space (the leading ASCII space `0x20` is the orthogonal \
3573         paste-from-aligned-doc footgun that silently passes \
3574         `Path::is_absolute` and every prior leading-byte arm — \
3575         `\" ../caixa-teia\"` resolves via `Path::join` to a literal \
3576         `./ ../caixa-teia` subdirectory the resolver fails to find at \
3577         resolve time with a non-self-locating `No such file or directory` \
3578         error far from the source caixa.lisp; the lacre pipeline embeds \
3579         the value verbatim in its per-dep content-address `path:{caminho}` \
3580         at caixa-resolver/src/resolve.rs:189, so byte-divergent / \
3581         semantic-identical caixa values (` ../caixa-teia` vs \
3582         `../caixa-teia`) yield two distinct BLAKE3 closures across two \
3583         workstations whose authors differ only in paste-from-aligned- \
3584         caixa.lisp-doc whitespace habits — the most insidious failure \
3585         mode the typed slot can carry (no error surfaces; the divergence \
3586         is invisible until two machines compare lacres), defeating the \
3587         THEORY.md §V.2 render-determinism contract. The canonical \
3588         paste-from-aligned-`:deps`-block footgun (every `:fonte` form in \
3589         a multi-entry `:deps` block sits at the same column — an author \
3590         selecting `\"<sp><sp><sp>../caixa-teia\"` and pasting it from \
3591         the rendered alignment into a fresh entry preserves the leading \
3592         whitespace verbatim); peer `:fonte :repo` axis already rejects \
3593         leading whitespace via `is_git_repo_url`, `:fonte :tag` / \
3594         `:fonte :branch` via `is_git_ref_name`, `:descricao` via \
3595         `is_chart_description_shape`, `:licenca` via \
3596         `is_spdx_expression_shape`. Drop the leading space; express the \
3597         path as a bare relative single-token like \"../caixa-teia\")"
3598    )]
3599    FonteCaminhoLeadingWhitespace { nome: String, caminho: String },
3600    #[error(
3601        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
3602         with `-` (the canonical CLI-argument-injection footgun on the \
3603         `:caminho` axis — the lacre pipeline embeds the value verbatim in \
3604         its per-dep content-address `path:{caminho}` at \
3605         caixa-resolver/src/resolve.rs:189 and the caixa-resolver folds it \
3606         through `Path::join` looking for a literal `./{caminho}` \
3607         subdirectory. Every downstream subprocess that consumes the resolved \
3608         path — `git -C {caminho} <verb>`, `terraform -chdir={caminho}`, \
3609         `nix build --path {caminho}`, `find {caminho}`, `stat {caminho}`, \
3610         `cp -r {caminho} …`, `rm -rf {caminho}` — reinterprets a leading-`-` \
3611         value as a CLI flag rather than a positional path when the invocation \
3612         does not carry a `--` argument-list terminator between the flag block \
3613         and the path (the common case at every porcelain entry point). The \
3614         canonical footguns: `:caminho \"-rf\"` (bare short-flag paste), \
3615         `:caminho \"-C\"` (`git -C -C` config-injection paste), \
3616         `:caminho \"--upload-pack=cat /etc/passwd\"` (the canonical long-flag \
3617         CLI-arg-injection vector at every git porcelain entry point that \
3618         consumes a path or URL argument, peer with is_git_repo_url's \
3619         leading-`-` arm on the sibling `:fonte :repo` axis), \
3620         `:caminho \"--config=…\"` (`git -c foo=bar` config-override paste). \
3621         POSIX `std::path::Path` treats a leading `-` as a literal filename \
3622         byte so the resolver folds `\"-rf\"` through `Path::join` and looks \
3623         for a literal `./-rf` subdirectory that fails at resolve time with a \
3624         non-self-locating `No such file or directory` error far from the \
3625         source caixa.lisp — but on any downstream shell-out without `--` the \
3626         reinterpretation is silent and the failure mode is arbitrary-\
3627         argument-injection. Peer arms: `is_git_repo_url` (render.rs:2037) \
3628         rejects leading `-` on `:fonte :repo` for `git clone <repo>` CLI-\
3629         arg-injection; `is_git_ref_name` (render.rs:1381, 5a28454) rejects \
3630         leading `-` on `:fonte :tag` / `:branch` for `git checkout <ref>` \
3631         CLI-arg-injection; `is_dns_1123_label` rejects leading `-` on every \
3632         DNS-1123-shaped axis (top-level Caixa `:nome`, `:membros :caixa`, \
3633         `:children :caixa`, `:deps :nome`, cluster names); \
3634         `is_cargo_feature_name` rejects leading `-` on `:caracteristicas`; \
3635         the feira `init` / `add <nome>` positional gate (868c191) rejects \
3636         leading `-` on the CLI positional itself. Express the path as a bare \
3637         relative single-token like \"../caixa-teia\" — the sibling-workspace \
3638         directory name carries no leading-hyphen semantic, and `./` / `../` \
3639         prefixes structurally partition the leading-byte set to safe values.)"
3640    )]
3641    FonteCaminhoLeadingHyphen { nome: String, caminho: String },
3642    #[error(
3643        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains \
3644         ASCII control byte 0x{byte:02x} (POSIX paths reject NUL `0x00` outright — \
3645         every `std::fs` syscall routes the path through `CString::new` which \
3646         fails with `NulError` at resolve time; the lacre pipeline embeds the \
3647         value verbatim in its per-dep content-address `path:{caminho}` at \
3648         caixa-resolver/src/resolve.rs:189 so a control byte anywhere in the \
3649         value lands in the BLAKE3 closure and breaks the THEORY.md §V.2 render-\
3650         determinism contract — the canonical paste-from-multiline-doc \
3651         (`\\n`/`\\r`), paste-from-aligned-table (`\\t`), or paste-from-binary-\
3652         blob (`0x00`-DEL) footgun every peer single-token-shaped axis \
3653         (`:fonte :repo`, `:fonte :tag`/`:branch`, the Helm chart-string axes) \
3654         already gates against. Express the path as a relative single-line ASCII \
3655         string, e.g. \"../caixa-teia\" for a sibling workspace dep)"
3656    )]
3657    FonteCaminhoControlChar {
3658        nome: String,
3659        caminho: String,
3660        byte: u8,
3661    },
3662    #[error(
3663        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains `\\` \
3664         (POSIX `std::path::Path` treats `\\` as a literal byte inside a single path \
3665         component, so `..\\caixa-teia` is one directory named literally `..\\caixa-teia` — \
3666         not the parent's sibling — and the caixa-resolver folds the value through \
3667         `Path::join` looking for a literal `./{caminho}` subdirectory that fails at \
3668         resolve time with a non-self-locating `No such file or directory` error far \
3669         from the source caixa.lisp; Windows `std::path::Path` treats `\\` as a \
3670         primary path separator equal to `/`, so byte-identical caixa.lisp values \
3671         resolve to two distinct directories across runner OSes — the lacre pipeline \
3672         embeds the value verbatim in its per-dep content-address `path:{caminho}` at \
3673         caixa-resolver/src/resolve.rs:189, defeating the THEORY.md §V.2 render-\
3674         determinism contract via the cross-host-OS-separator divergence vector. The \
3675         canonical Windows-Explorer `Copy as path` / PowerShell `Get-Location` \
3676         paste-idiom footgun; peer `:fonte :tag` / `:fonte :branch` axis already \
3677         rejects `\\` via `is_git_ref_name` for the same Windows-path-leak reason, \
3678         and `:entrada :paths` rejects `\\` via `is_gateway_api_http_path`'s eleven-\
3679         byte RFC-3986-reserved set. Express the path with `/` as the separator, e.g. \
3680         \"../caixa-teia\" for a sibling workspace dep)"
3681    )]
3682    FonteCaminhoBackslash { nome: String, caminho: String },
3683    #[error(
3684        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3685         redirection metacharacter 0x{byte:02x} `{ch}` (every interactive shell — bash / \
3686         zsh / fish / nushell — lexes `<` and `>` as input / output redirection \
3687         operators, so `:caminho \"../caixa-teia>build.log\"` is the canonical \
3688         paste-from-shell-pipeline footgun where an author copies a `command > log` \
3689         tail without trimming the redirect; POSIX `std::path::Path` treats both bytes \
3690         as literal path-component bytes, 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 \
3693         file or directory` error far from the source caixa.lisp. The lacre pipeline \
3694         embeds 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 \
3696         and 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 CRLF-at-subprocess-argument / shell-metachar injection surface every \
3699         peer single-token-shaped typed slot already closes. The peer `:fonte :tag` / \
3700         `:fonte :branch` axis already rejects `<` / `>` via `is_git_ref_name`, and \
3701         `:entrada :paths` rejects them via `is_gateway_api_http_path`'s eleven-byte \
3702         RFC-3986-reserved set. Express the path as a bare relative single-token like \
3703         \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
3704         redirection semantic.",
3705        ch = *byte as char
3706    )]
3707    FonteCaminhoShellRedirection {
3708        nome: String,
3709        caminho: String,
3710        byte: u8,
3711    },
3712    #[error(
3713        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-pipe \
3714         metacharacter `|` (every interactive shell — bash / zsh / fish / nushell — lexes \
3715         `|` as the pipe operator that wires one command's stdout to the next command's \
3716         stdin, so `:caminho \"../caixa-teia | grep foo\"` is the canonical paste-from-\
3717         shell-history footgun where an author copies a `ls ../caixa-teia | grep` line \
3718         without trimming the pipeline tail, and `:caminho \"../foo||bar\"` is the \
3719         symmetric `cmd-a || cmd-b` short-circuit-OR paste shape; POSIX `std::path::Path` \
3720         treats `|` as a literal path-component byte, so the resolver folds the value \
3721         through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
3722         subdirectory and fails at resolve time with a non-self-locating `No such file or \
3723         directory` error far from the source caixa.lisp. The lacre pipeline embeds the \
3724         value verbatim in its per-dep content-address `path:{caminho}` at caixa-resolver/\
3725         src/resolve.rs:189, so the byte lands in the BLAKE3 closure and rides into every \
3726         shell-spawned subprocess (the resolver's `git clone`, a future `feira tofu` \
3727         shell-out, a future operator-side `nix` spawn) as the canonical CRLF-at-\
3728         subprocess-argument / shell-metachar injection surface every peer single-token-\
3729         shaped typed slot already closes. The peer `:entrada :paths` axis rejects `|` \
3730         via `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the \
3731         path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
3732         workspace directory name carries no shell-pipe semantic."
3733    )]
3734    FonteCaminhoShellPipe { nome: String, caminho: String },
3735    #[error(
3736        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3737         command-separator metacharacter `;` (every interactive shell — bash / zsh / fish \
3738         / nushell — lexes `;` as the sequential-command terminator that fires the next \
3739         command regardless of the prior command's exit status, so `:caminho \
3740         \"../caixa-teia; rm -rf build\"` is the canonical paste-from-shell-one-liner \
3741         footgun where an author copies a `cd path; do-thing` chain without trimming \
3742         the cleanup tail, and `:caminho \"../foo;;bar\"` is the symmetric POSIX `case` \
3743         arm `;;` terminator paste shape; POSIX `std::path::Path` treats `;` as a \
3744         literal path-component byte, so the resolver folds the value through \
3745         `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
3746         subdirectory and fails at resolve time with a non-self-locating `No such file \
3747         or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
3748         the value verbatim in its per-dep content-address `path:{caminho}` at \
3749         caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
3750         rides into every shell-spawned subprocess (the resolver's `git clone`, a \
3751         future `feira tofu` shell-out, a future operator-side `nix` spawn) as the \
3752         canonical shell-metachar injection surface every peer single-token-shaped \
3753         typed slot already closes. The peer `:entrada :paths` axis rejects `;` via \
3754         `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the \
3755         path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
3756         workspace directory name carries no shell-command-separator semantic."
3757    )]
3758    FonteCaminhoShellSemicolon { nome: String, caminho: String },
3759    #[error(
3760        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3761         background / list-AND metacharacter `&` (every interactive shell — bash / zsh \
3762         / fish / nushell — lexes `&` two ways: single `&` as the background-task \
3763         terminator detaching the prior command and returning control immediately to \
3764         the prompt, double `&&` as the logical-AND list operator firing the next \
3765         command only if the prior succeeded; POSIX `std::path::Path` treats it as a \
3766         literal byte. The canonical paste-from-shell-prompt footgun is a `cd path & \
3767         sleep 1` background-launch one-liner or a `cd path && make install` build-\
3768         chain idiom selected whole into the `:caminho` slot — the prior `;` arm at \
3769         05c358e closed the sequential-command-separator vector, this arm closes the \
3770         orthogonal background-task / logical-AND vector on the same paste-from-shell-\
3771         prompt class. The lacre pipeline embeds the value verbatim in its per-dep \
3772         content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the \
3773         byte lands in the BLAKE3 closure and rides into every shell-spawned \
3774         subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a \
3775         future operator-side `nix` spawn) as the canonical shell-metachar injection \
3776         surface every peer single-token-shaped typed slot already closes. The peer \
3777         `:entrada :paths` axis rejects `&` via `is_gateway_api_http_path`'s eleven-\
3778         byte RFC-3986-reserved set. Express the path as a bare relative single-token \
3779         like \"../caixa-teia\" — the sibling-workspace directory name carries no \
3780         shell-background / logical-AND semantic."
3781    )]
3782    FonteCaminhoShellBackground { nome: String, caminho: String },
3783    #[error(
3784        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3785         command-substitution metacharacter `` ` `` (every POSIX shell — sh / bash / zsh / \
3786         dash / ksh / fish / nushell — lexes the byte as the legacy command-substitution \
3787         wrapper that runs the enclosed command and substitutes its standard-output \
3788         verbatim into the surrounding word, so a backticked `whoami` expands to the \
3789         current user's name and a backticked `cat /etc/passwd` expands to the file's \
3790         contents — the canonical CWE-78 shell-command-injection vector; POSIX \
3791         `std::path::Path` treats the byte as a literal path-component byte. The canonical \
3792         paste-from-shell-prompt footgun is a `cd ../path/<backtick>whoami<backtick>` legacy substitution \
3793         one-liner or a `cd <backtick>pwd<backtick>/path` working-directory expansion idiom selected whole \
3794         into the `:caminho` slot — the prior `&` arm at e12e4f3 closed the shell-\
3795         background / logical-AND vector, this arm closes the orthogonal command-\
3796         substitution vector on the same paste-from-shell-prompt class (the modern `$()` \
3797         form is gated at leading position by the f4efe9c `FonteCaminhoVarExpansion` arm; \
3798         the legacy backtick form is the orthogonal axis). The lacre pipeline embeds the \
3799         value verbatim in its per-dep content-address `path:{caminho}` at \
3800         caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
3801         rides into every shell-spawned subprocess (the resolver's `git clone`, a future \
3802         `feira tofu` shell-out, a future operator-side `nix` spawn) as the canonical \
3803         shell-metachar injection surface every peer single-token-shaped typed slot \
3804         already closes. The peer `:entrada :paths` axis rejects the byte via \
3805         `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the path \
3806         as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
3807         directory name carries no shell-command-substitution semantic."
3808    )]
3809    FonteCaminhoShellCommandSubstitution { nome: String, caminho: String },
3810    #[error(
3811        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3812         glob / pathname-expansion metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — \
3813         sh / bash / zsh / dash / ksh / fish / nushell — lexes `*` and `?` as pathname-\
3814         expansion wildcards: `*` matches any sequence of characters in a path component \
3815         and `?` matches exactly one character, so a `:caminho \"../caixa-teia/*\"` is the \
3816         canonical paste-from-shell-listing footgun where an author copies a \
3817         `ls ../caixa-teia/*` listing without trimming the wildcard, and `:caminho \
3818         \"../foo?\"` is the symmetric single-char-wildcard paste shape; POSIX \
3819         `std::path::Path` treats both bytes as literal path-component bytes, so the \
3820         resolver folds the value through `Path::new(caminho).join(<file>)` looking for \
3821         a literal `./{caminho}` subdirectory and fails at resolve time with a non-self-\
3822         locating `No such file or directory` error far from the source caixa.lisp. The \
3823         lacre pipeline embeds the value verbatim in its per-dep content-address \
3824         `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in the \
3825         BLAKE3 closure and rides into every shell-spawned subprocess (the resolver's \
3826         `git clone`, a future `feira tofu` shell-out, a future operator-side `nix` \
3827         spawn) as the canonical shell-metachar / glob-expansion surface every peer \
3828         single-token-shaped typed slot already closes. The peer `:entrada :paths` axis \
3829         rejects `*` and `?` via `is_gateway_api_http_path`'s eleven-byte RFC-3986-\
3830         reserved set. Express the path as a bare relative single-token like \
3831         \"../caixa-teia\" — the sibling-workspace directory name carries no shell-glob \
3832         / pathname-expansion semantic.",
3833        ch = *byte as char
3834    )]
3835    FonteCaminhoShellGlob {
3836        nome: String,
3837        caminho: String,
3838        byte: u8,
3839    },
3840    #[error(
3841        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3842         subshell-grouping metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / \
3843         zsh / dash / ksh / fish / nushell — lexes `(` and `)` as the subshell-grouping \
3844         operator: `(<cmd>)` runs `<cmd>` in a child shell with a fresh environment scope \
3845         (the canonical `(cd <path> && <cmd>)` shell-history one-liner scopes a `cd` to one \
3846         subshell without disturbing the parent's working directory), and `$(<cmd>)` is the \
3847         modern Bourne command-substitution shape the leading-`$` `FonteCaminhoVarExpansion` \
3848         arm closes the leading byte of — together the two arms now structurally exclude the \
3849         entire `$(<cmd>)` substitution surface from the typed `:caminho` accepted set. \
3850         POSIX `std::path::Path` treats the byte as a literal path-component byte, so a \
3851         `:caminho \"../caixa-teia/$(date)/build\"` (the canonical paste-from-shell-history \
3852         modern-command-substitution footgun) or `:caminho \"../(cd foo && pwd)/caixa-teia\"` \
3853         (the symmetric subshell-grouping working-directory-probe paste idiom) silently passes \
3854         every prior arm and the resolver folds the value through `Path::new(caminho).join(\
3855         <file>)` looking for a literal subdirectory and fails at resolve time with a non-\
3856         self-locating `No such file or directory` error far from the source caixa.lisp. The \
3857         lacre pipeline embeds the value verbatim in its per-dep content-address `path:\
3858         {caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 \
3859         closure and rides into every shell-spawned subprocess (the resolver's `git clone`, a \
3860         future `feira tofu` shell-out, a future operator-side `nix` spawn) as the canonical \
3861         shell-metachar / subshell-grouping surface every peer single-token-shaped typed slot \
3862         already closes. The peer `:fonte :repo` axis (3b99147) closes the same byte under the \
3863         same shell-subshell-grouping / RFC-3986-sub-delims banner on `is_git_repo_url`, \
3864         together with the leading-`$` `FonteCaminhoVarExpansion` arm closing the leading byte \
3865         of every `$(<cmd>)` shape. Express the path as a bare relative single-token \
3866         like \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
3867         subshell-grouping semantic.",
3868        ch = *byte as char
3869    )]
3870    FonteCaminhoShellSubshellGrouping {
3871        nome: String,
3872        caminho: String,
3873        byte: u8,
3874    },
3875    #[error(
3876        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3877         brace-expansion / URI-Template placeholder metacharacter 0x{byte:02x} `{ch}` \
3878         (every POSIX-derived brace-expanding shell — bash / zsh / ksh / fish — lexes `{{` / \
3879         `}}` as the brace-expansion operator: `{{a,b,c}}` expands to the cross-product of \
3880         comma-separated members and `{{1..10}}` expands to the integer range — the \
3881         canonical `mkdir -p ../{{caixa-teia,caixa-helm,caixa-flux}}` / `cp file{{,.bak}}` \
3882         idiom every shell-history block carries; RFC 6570 reserves the matched pair for \
3883         URI Template placeholders (the canonical `https://{{host}}/{{org}}/{{repo}}` \
3884         substitution shape every OpenAPI / Swagger / Postman / GitHub Octokit client \
3885         library / Helm chart-URL fragment carries) and the Mustache / Handlebars / \
3886         Tera / Jinja2 / Go html/template doubled-brace substitution form every IaC \
3887         templating engine (Helm, Kustomize, Terraform's `${{var}}` cousin) emits. POSIX \
3888         `std::path::Path` treats the byte as a literal path-component byte, so a \
3889         `:caminho \"../{{caixa-teia,caixa-helm}}/build\"` (the canonical paste-from-\
3890         shell-history brace-expansion fan-across-siblings footgun) or `:caminho \"../{{{{org}}}}/\
3891         caixa-teia\"` (the symmetric paste-from-templated-doc URI-Template placeholder \
3892         idiom every README quick-start / OpenAPI spec / Helm chart `home:` field carries) \
3893         silently passes every prior arm and the resolver folds the value through \
3894         `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
3895         resolve time with a non-self-locating `No such file or directory` error far from \
3896         the source caixa.lisp. The lacre pipeline embeds the value verbatim in its \
3897         per-dep content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, \
3898         so the byte lands in the BLAKE3 closure and rides into every shell-spawned \
3899         subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a \
3900         future operator-side `nix` spawn) as the canonical shell-metachar / brace-\
3901         expansion / URI-Template-placeholder surface every peer single-token-shaped \
3902         typed slot already closes. The peer `:fonte :repo` axis (42d8f9d) closes the \
3903         same byte pair on `is_git_repo_url` under the same RFC-3986-'delims' / \
3904         RFC-6570-URI-Template / shell-brace-expansion banner. Express the path as a \
3905         bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
3906         directory name carries no shell-brace-expansion / URI-Template-placeholder \
3907         semantic; if two siblings actually need pinning, author two separate `:deps` \
3908         entries rather than one brace-expanded `:caminho` value.",
3909        ch = *byte as char
3910    )]
3911    FonteCaminhoShellBraceExpansion {
3912        nome: String,
3913        caminho: String,
3914        byte: u8,
3915    },
3916    #[error(
3917        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3918         bracket-expansion / POSIX glob-character-class / shell-`test`-builtin metacharacter \
3919         0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / nushell \
3920         — lexes the bracket pair as the glob character-class operator: `[abc]` matches one of \
3921         `a` / `b` / `c`, `[a-z]` matches any lowercase ASCII letter, `[^x]` negates — the \
3922         canonical `ls *.[ch]` C-source-file glob and `cd ../caixa-[a-z]*` lowercase-sibling \
3923         glob every shell-history block carries; the bracket pair additionally carries the \
3924         POSIX `test` / `[` builtin command (`[ -d ../caixa-teia ] && cd ...` every shell-\
3925         script conditional uses) and bash's `[[ ... ]]` extended-test grammar; beyond shell \
3926         the pair is the TOML inline-array delimiter (`features = [\"a\", \"b\"]` — the \
3927         canonical paste-from-Cargo-manifest cross-idiom-leak vector), the YAML flow-sequence \
3928         delimiter (`paths: [/a, /b]` — the canonical paste-from-values.yaml cross-idiom \
3929         leak), the JSON array delimiter, and the POSIX-ERE / PCRE bracket-expression anchor. \
3930         POSIX `std::path::Path` treats the byte as a literal path-component byte, so a \
3931         `:caminho \"../caixa-[a-z]/build\"` (the canonical paste-from-shell-history glob-\
3932         character-class fan-across-siblings footgun) or `:caminho \"../[caixa-teia]/build\"` \
3933         (the symmetric paste-from-TOML-array / paste-from-YAML-flow-sequence cross-idiom \
3934         leak) silently passes every prior arm and the resolver folds the value through \
3935         `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
3936         resolve time with a non-self-locating `No such file or directory` error far from \
3937         the source caixa.lisp. The lacre pipeline embeds the value verbatim in its per-dep \
3938         content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte \
3939         lands in the BLAKE3 closure and rides into every shell-spawned subprocess (the \
3940         resolver's `git clone`, a future `feira tofu` shell-out, a future operator-side \
3941         `nix` spawn) as the canonical shell-metachar / glob-character-class / TOML-array \
3942         surface every peer single-token-shaped typed slot already closes. Express the path \
3943         as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
3944         directory name carries no shell-bracket-expansion / glob-character-class / array-\
3945         literal semantic; if a family of sibling caixas actually needs pinning, author \
3946         separate `:deps` entries rather than one character-class-expanded `:caminho` value.",
3947        ch = *byte as char
3948    )]
3949    FonteCaminhoShellBracketExpansion {
3950        nome: String,
3951        caminho: String,
3952        byte: u8,
3953    },
3954    #[error(
3955        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3956         quote-grouping / cross-config-DSL string-literal-delimiter metacharacter \
3957         0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / \
3958         nushell — lexes `'` as the strong string-literal delimiter (`'…'` — no expansion) \
3959         and `\"` as the weak string-literal delimiter (`\"…\"` — variable- / command-\
3960         substitution-preserving); the canonical `cd '../caixa-teia'` shell-history idiom \
3961         every path-with-embedded-whitespace paste block carries and the symmetric \
3962         `git clone \"$REPO\"` weak-quoted CI-manifest shape both leak the pair verbatim. \
3963         Beyond shell the pair is the JSON string-literal delimiter (`\"key\": \"value\"` — \
3964         the canonical paste-from-JSON-config cross-idiom-leak vector), the YAML double- \
3965         and single-quoted flow-scalar delimiter (`path: \"../caixa-teia\"` — the canonical \
3966         paste-from-values.yaml / paste-from-K8s-YAML-manifest cross-idiom leak), the TOML \
3967         basic and literal string delimiter (`path = \"../caixa-teia\"` — the canonical \
3968         paste-from-Cargo-manifest cross-idiom leak), the tatara-lisp string-literal \
3969         delimiter itself (`(:caminho \"../caixa-teia\")` — the canonical \"I copied the \
3970         entire `:caminho \"...\"` slot rather than just the string body\" author-surface \
3971         footgun), and RFC 3986 §2.2's `gen-delims` / `sub-delims` grammar which excludes \
3972         both bytes from the `pchar = unreserved / pct-encoded / sub-delims / \":\" / \"@\"` \
3973         production. POSIX `std::path::Path` treats the byte as a literal path-component \
3974         byte, so a `:caminho \"'../caixa-teia'\"` (the canonical paste-from-shell-history \
3975         strong-quoted sibling-workspace path footgun) or `:caminho \"\\\"../caixa-teia\\\"\"` \
3976         (the symmetric weak-quoted paste-from-JSON / paste-from-YAML flow-scalar / paste-\
3977         from-TOML basic-string / paste-from-tatara-lisp string-literal cross-idiom-leak \
3978         shape) silently passes every prior arm and the resolver folds the value through \
3979         `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
3980         resolve time with a non-self-locating `No such file or directory` error far from \
3981         the source caixa.lisp. The lacre pipeline embeds the value verbatim in its per-dep \
3982         content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte \
3983         lands in the BLAKE3 closure and rides into every shell-spawned subprocess (the \
3984         resolver's `git clone`, a future `feira tofu` shell-out, a future operator-side \
3985         `nix` spawn) as the canonical shell-metachar / string-literal-delimiter surface \
3986         every peer single-token-shaped typed slot already closes. The peer `:fonte :repo` \
3987         axis closes both bytes under the same shell-quote-grouping / RFC-3986-sub-delims \
3988         banner (e7a109f `'` shell-single-quote + 4267d8b `\"` shell-double-quote on \
3989         `is_git_repo_url`). Express the path as a bare relative single-token like \
3990         \"../caixa-teia\" — the sibling-workspace directory name carries no shell-quote-\
3991         grouping / string-literal-delimiter semantic; strip the outer quote pair from the \
3992         paste (the tatara-lisp `:caminho \"...\"` slot already carries the string-literal \
3993         quoting on the outer syntactic layer, so an inner quote pair would nest and \
3994         desugar to a broken layer).",
3995        ch = *byte as char
3996    )]
3997    FonteCaminhoShellQuoteGrouping {
3998        nome: String,
3999        caminho: String,
4000        byte: u8,
4001    },
4002    #[error(
4003        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4004         comment / URL-fragment-identifier / YAML-comment cross-config-DSL metacharacter \
4005         0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / \
4006         nushell — lexes an unquoted `#` at the head of a word or after unquoted \
4007         whitespace as the comment-lead per POSIX.1-2017 §2.3 Token Recognition step 6, \
4008         discarding the byte and everything after it to the end of the physical line \
4009         before command parsing (`cd ../caixa-teia  # legacy sibling` — the canonical \
4010         paste-from-shell-history-with-trailing-annotation shape every operator-notebook \
4011         and CI-manifest carries); YAML 1.2 §6.6 makes `#` the comment-lead at any \
4012         position preceded by whitespace or at line-start (`path: ../caixa-teia  # pin` \
4013         — the canonical paste-from-values.yaml / paste-from-K8s-manifest cross-idiom-\
4014         leak); RFC 3986 §3.5 reserves `#` as the URL fragment-identifier delimiter (the \
4015         canonical paste-from-browser-address-bar `github.com/foo/bar#readme` / \
4016         `github.com/foo/bar#L42` permalink shape, and the symmetric Nix-flake-ref \
4017         cross-idiom leak `github:foo/bar#packageName` where `#` selects a flake \
4018         output); the same cross-config-DSL surface extends to HCL / Terraform / Nix \
4019         flake attributes / dotenv `.env` / gitconfig / .gitignore / ini / TOML where \
4020         `#` is likewise the comment-lead. POSIX `std::path::Path` treats the byte as a \
4021         literal path-component byte, so a `:caminho \"../caixa-teia # legacy sibling\"` \
4022         (the canonical paste-from-shell-history-with-trailing-annotation footgun), \
4023         `:caminho \"../caixa-teia  # pin\"` (the symmetric YAML flow-scalar paste-with-\
4024         trailing-comment shape), or `:caminho \"../caixa-teia#readme\"` (the URL \
4025         fragment paste-from-browser-address-bar shape) silently passes every prior arm \
4026         and the resolver folds the value through `Path::new(caminho).join(<file>)` \
4027         looking for a literal subdirectory named `../caixa-teia # legacy sibling` and \
4028         fails at resolve time with a non-self-locating `No such file or directory` \
4029         error far from the source caixa.lisp — while every downstream shell / YAML / \
4030         URL parser silently truncates the value at the `#` byte to `../caixa-teia`, so \
4031         a `feira tofu` shell-out and a `nix flake check` on an emitted YAML `path:` \
4032         scalar disagree with the resolver on which directory the value names. The \
4033         lacre pipeline embeds the value verbatim in its per-dep content-address \
4034         `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in \
4035         the BLAKE3 closure and rides into every shell-spawned subprocess (the \
4036         resolver's `git clone`, a future `feira tofu` shell-out, a future operator-\
4037         side `nix` spawn) as the canonical shell-metachar / comment-lead / URL-\
4038         fragment-delimiter surface every peer single-token-shaped typed slot already \
4039         closes. The peer `:fonte :repo` axis closes the byte under the same URL-\
4040         fragment-identifier banner (a68f818 `#` on `is_git_repo_url`). Express the \
4041         path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
4042         workspace directory name carries no shell-comment / URL-fragment / YAML-\
4043         comment semantic; move any trailing annotation to a tatara-lisp `;`-comment \
4044         on the surrounding form (`;; legacy sibling` above the `(:caminho ...)` slot) \
4045         and drop any `#fragment` tail entirely (fragment identifiers select \
4046         renderings, not directories, and `:caminho` names a directory).",
4047        ch = *byte as char
4048    )]
4049    FonteCaminhoShellComment {
4050        nome: String,
4051        caminho: String,
4052        byte: u8,
4053    },
4054    #[error(
4055        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains URL-\
4056         percent-encoding-escape / printf-format-specifier / bash-job-control-specifier \
4057         / YAML-directive-lead metacharacter 0x{byte:02x} `{ch}` (RFC 3986 §2.1 reserves \
4058         `%` as the URL percent-encoding-escape — `%HH` is the mandatory encoding \
4059         mechanism for every byte outside the `unreserved` alphanumeric / `-` / `.` / \
4060         `_` / `~` set, and `%` itself must be percent-encoded as `%25` to appear \
4061         literally inside a URL value. The canonical paste-from-browser-address-bar \
4062         percent-encoded-space footgun (an author copies `../caixa%20teia` out of a URL-\
4063         encoded README hyperlink / browser address bar / percent-encoded permalink \
4064         expecting `%20` to decode to a literal space at the filesystem layer) locks two \
4065         distinct BLAKE3 closures (`path:../caixa%20teia` vs `path:../caixa teia`) for \
4066         what the author intended as the byte-identical sibling-workspace dep. POSIX \
4067         `std::path::Path` treats the byte as a literal path-component byte, so \
4068         `Path::join` looks for a literal `./{caminho}` subdirectory and fails at \
4069         resolve time with a non-self-locating `No such file or directory` error far \
4070         from the source caixa.lisp — while every downstream URL parser / shell printf \
4071         builtin / YAML directive parser silently reinterprets the byte to a different \
4072         value than the resolver's `Path::join` sees. Beyond the URL-encoding hazard, \
4073         `%` is the C / POSIX printf format-directive lead-in (`%s`, `%d`, `%02x` — \
4074         wired into every POSIX shell's `printf` builtin, the canonical CWE-134 format-\
4075         string-injection vector); the bash / zsh / ksh job-control-specifier lead-in \
4076         (`%1` names \"job 1\", `%%` names \"the current job\", `%foo` names \"the most \
4077         recent job whose command started with `foo`\" — a future `kill %1` invocation \
4078         silently redirects the signal to a wrong target); the YAML 1.2 §6.8.1 \
4079         directive lead-in (`%YAML 1.2` / `%TAG` — the paste-from-top-of-doc YAML \
4080         directive block cross-idiom leak); and the Windows-shell env-var-reference \
4081         lead-in (`%PATH%` — the paste-from-`.bat` / paste-from-PowerShell-`%env:PATH%` \
4082         cross-idiom leak). The lacre pipeline embeds the value verbatim in its per-dep \
4083         content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the \
4084         byte lands in the BLAKE3 closure and rides into every shell-spawned subprocess \
4085         (the resolver's `git clone`, a future `feira tofu` shell-out, a future \
4086         operator-side `nix` spawn) as the canonical URL-percent-encoding-escape / \
4087         printf-format-specifier / job-control-specifier surface every peer single-\
4088         token-shaped typed slot already closes. The peer `:fonte :repo` axis closes \
4089         the byte under the same URL-percent-encoding-escape banner (a323db8 `%` on \
4090         `is_git_repo_url`). Express the path as a bare relative single-token like \
4091         \"../caixa-teia\" — the sibling-workspace directory name carries no URL-\
4092         percent-encoding-escape / format-specifier / job-control semantic; substitute \
4093         any `%20` percent-encoded-space with a literal space then reject the whole \
4094         value at the leading-whitespace / embedded-`?` arm on the same axis (a caixa \
4095         directory name never carries an embedded space in practice); drop any \
4096         `%2F`-encoded path separator in favor of a literal `/`; and drop any leading \
4097         `%YAML` / `%PATH%` cross-idiom-leak prefix entirely.",
4098        ch = *byte as char
4099    )]
4100    FonteCaminhoUrlPercentEncoding {
4101        nome: String,
4102        caminho: String,
4103        byte: u8,
4104    },
4105    #[error(
4106        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4107         variable-expansion / command-substitution / arithmetic-expansion / cross-config-\
4108         DSL-interpolation metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — sh / \
4109         bash / zsh / dash / ksh / busybox ash / fish / nushell — lexes `$` per \
4110         POSIX.1-2017 §2.6 as the variable-expansion `$<name>` / braced-form `${{<name>}}` \
4111         / command-substitution `$(<cmd>)` / arithmetic-expansion `$((<expr>))` operator; \
4112         Nix uses `${{var}}` as the string-interpolation lead, Make uses `$(var)` / `$@` \
4113         / `$<` for variables and automatic-variables, JavaScript / TypeScript template \
4114         literals use `${{expr}}` for interpolation, envsubst / Kubernetes / OpenShift \
4115         templates use `${{VAR}}` for env-var-reference, PHP uses `$_GET` / `$_ENV` for \
4116         superglobals, Perl uses `$foo` for scalars, SASS / SCSS uses `$primary-color` \
4117         for variables, and PostgreSQL / SQLite use `$1` / `$2` for bind parameters — \
4118         the byte is a first-class parser byte in nearly every config / templating / \
4119         build-system DSL the substrate's paste-idiom surface routinely crosses. POSIX \
4120         `std::path::Path` treats the byte as a literal path-component byte, so the \
4121         canonical paste-from-shell-one-liner `:caminho \"../foo$HOME/bar\"` / paste-\
4122         from-CI-manifest `:caminho \"../foo${{WORKSPACE}}/bar\"` / paste-from-shell-\
4123         prompt `:caminho \"../foo$(whoami)/bar\"` footguns silently pass every prior \
4124         cascade arm (`$` isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / \
4125         `?` / `(` / `)` / `{{` / `}}` / `[` / `]` / `'` / `\"` / `#` / `%`) and route \
4126         through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
4127         subdirectory that fails at resolve time with a non-self-locating `No such file \
4128         or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
4129         the value verbatim in its per-dep content-address `path:{caminho}` at \
4130         caixa-resolver/src/resolve.rs:189, so byte-identical caixa.lisp values differing \
4131         only in whether the author substituted `$HOME` / `${{WORKSPACE}}` at author \
4132         time lock to two distinct BLAKE3 closures across two workstations whose \
4133         downstream envsubst / Nix / Make / K8s-template layers differ in `$VAR` \
4134         recognition — defeating the THEORY.md §V.2 render-determinism contract on the \
4135         same axis every prior `:caminho` arm protects. Beyond the determinism vector, \
4136         `$` at any position in a value flowing verbatim into a shell-spawned subprocess \
4137         is the canonical CWE-78 shell-command-injection surface every peer single-\
4138         token-shaped typed slot already closes: peer `:fonte :repo` axis rejects `$` \
4139         under the shell-variable-expansion / URL-sub-delim banner via `is_git_repo_url` \
4140         (b9d187c), peer `:fonte :tag` / `:fonte :branch` axes reject `$` as part of \
4141         `is_git_ref_name`'s printable-ASCII-restricted grammar (`git check-ref-format` \
4142         rejects the byte outright), and peer `:entrada :paths` axis rejects `$` via \
4143         `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. The leading-`$` \
4144         position on the same axis routes through `FonteCaminhoVarExpansion` at the \
4145         f4efe9c leading-byte arm; this arm closes the last positional gap on the byte \
4146         so every position — leading and embedded — is structurally rejected. Substitute \
4147         the `$VAR` / `${{VAR}}` / `$(cmd)` template with the literal value at author \
4148         time, or express the path as a bare relative single-token like \
4149         \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
4150         variable-expansion / command-substitution / arithmetic-expansion semantic.",
4151        ch = *byte as char
4152    )]
4153    FonteCaminhoShellVariableExpansion {
4154        nome: String,
4155        caminho: String,
4156        byte: u8,
4157    },
4158    #[error(
4159        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4160         history-expansion / RFC-3986-sub-delims / bang-operator metacharacter 0x{byte:02x} \
4161         `{ch}` (every interactive POSIX shell with history enabled — bash / ksh / zsh's \
4162         `bashcompat` / csh / tcsh — lexes `!` as the history-expansion prefix per bash \
4163         reference §9.3: `!command` re-runs the most recent history entry beginning with \
4164         `command`, `!!` re-runs the prior command verbatim, `!$` substitutes the last \
4165         word of the prior command, `!:N` substitutes the Nth word of the prior command, \
4166         and the substitution fires at every history-expansion-enabled shell context — \
4167         `set -o histexpand` is bash's default for interactive sessions and the layer \
4168         every `feira tofu` / `git clone` / `nix flake check` subprocess-argument \
4169         invocation crosses when spawned under `bash -i`. Beyond shell history, RFC 3986 \
4170         §2.2 lists `!` in the `sub-delims` set (the URL grammar admits the byte inside \
4171         a path segment, but every WHATWG-conformant special-scheme URL parser percent-\
4172         encodes it inside a query component via the 'special-query percent-encode set' \
4173         the peer `is_git_repo_url` `*` / `(` / `)` / `'` arms close on); the byte is \
4174         also the C / C++ / Rust / JavaScript / Python bang-operator (logical-negation \
4175         prefix — the paste-from-source-code idiom where an author copies \
4176         `!path.exists()` out of a Rust snippet and the trailing punctuation crosses \
4177         the string-literal boundary); the canonical English-typography emphasis / \
4178         exclamation mark (the paste-from-prose enthusiasm-form idiom where an author \
4179         writes `:caminho \"../caixa-teia!\"` expecting the substrate to coerce it to a \
4180         kebab-case slug); and the Nix flake-ref attribute-selection operator surface. \
4181         POSIX `std::path::Path` treats `!` as a literal path-component byte, so the \
4182         canonical paste-from-shell-history footgun `:caminho \"../caixa-teia!sudo\"` \
4183         (an author copies a `cd ../caixa-teia && !sudo make install` one-liner from a \
4184         quick-start README and the trailing `!sudo` rides in verbatim as a history-\
4185         expansion reference), the symmetric `:caminho \"../foo!!/bar\"` (the `!!` \
4186         repeat-prior-command paste idiom), the English-typography `:caminho \
4187         \"../caixa-teia!\"` (paste-from-prose enthusiasm-form), and the last-word-\
4188         substitution `:caminho \"../foo!$\"` shape silently pass every prior cascade \
4189         arm (`!` isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / `?` / `(` \
4190         / `)` / `{{` / `}}` / `[` / `]` / `'` / `\"` / `#` / `%` / `$`) and route \
4191         through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
4192         subdirectory that fails at resolve time with a non-self-locating `No such file \
4193         or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
4194         the value verbatim in its per-dep content-address `path:{caminho}` at \
4195         caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
4196         rides into every shell-spawned subprocess (the resolver's `git clone`, a \
4197         future `feira tofu` shell-out, a future operator-side `nix flake check` spawn) \
4198         as the canonical shell-history-expansion / RFC-3986-sub-delims surface every \
4199         peer single-token-shaped typed slot already closes. The peer `:fonte :repo` \
4200         axis closes the byte under the same shell-history-expansion / RFC-3986-sub-\
4201         delims banner (7d53c68 `!` on `is_git_repo_url`). Express the path as a bare \
4202         relative single-token like \"../caixa-teia\" — the sibling-workspace directory \
4203         name carries no shell-history-expansion / bang-operator semantic; drop any \
4204         `!sudo` / `!!` / `!$` history-expansion trailing paste-from-shell-history \
4205         idiom; and drop any trailing English-typography exclamation mark that pasted \
4206         from prose.",
4207        ch = *byte as char
4208    )]
4209    FonteCaminhoShellHistoryExpansion {
4210        nome: String,
4211        caminho: String,
4212        byte: u8,
4213    },
4214    #[error(
4215        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4216         history-substitution / RFC-3986-'unwise' / regex-negation metacharacter 0x{byte:02x} \
4217         `{ch}` (POSIX bash's `set -o histexpand` mode — the default for every interactive \
4218         session and every `bash -i` subprocess-argument context `feira tofu` / `git clone` / \
4219         `nix flake check` cross — lexes `^old^new^` per bash reference §9.3 as the 'quick \
4220         substitution' history operator that rewrites the prior command's `old` string to \
4221         `new` and re-executes it verbatim, the canonical typo-correction one-liner idiom \
4222         (`git clone <bad-url>` → `^bad^good` typo-fix-and-rerun the paste-from-shell-\
4223         history author trims only the leading `git clone` prefix from). RFC 3986 §2 lists \
4224         `^` in the 'unwise' set every URL parser is required to percent-encode-or-refuse at \
4225         the wire boundary, and the WHATWG URL spec's 'fragment percent-encode set' maps \
4226         `^` → `%5E` at the query / fragment component transition, so `Path::join` on the \
4227         literal value diverges from every downstream `feira tofu` curl-invocation / \
4228         artifact-registry-fetch that percent-encodes the byte before the wire. `^` is also \
4229         the regex character-class negation prefix (`[^abc]`), the bitwise XOR operator in \
4230         C / C++ / Rust / Python / JavaScript / Nix / Go, the Windows `cmd.exe` escape \
4231         metacharacter, and the LaTeX / Markdown / BibTeX superscript operator. POSIX \
4232         `std::path::Path` treats `^` as a literal path-component byte, so \
4233         `:caminho \"../foo^bar/baz\"` (embedded quick-substitution), `:caminho \
4234         \"../foo^\"` (trailing history-substitution-open shape), or `:caminho \"../x^y\"` \
4235         (XOR-expression paste-from-source) silently pass every prior cascade arm (`^` \
4236         isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / `?` / `(` / `)` / `{{` \
4237         / `}}` / `[` / `]` / `'` / `\"` / `#` / `%` / `$` / `!`) and route through \
4238         `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` subdirectory \
4239         that fails at resolve time with a non-self-locating `No such file or directory` \
4240         error far from the source caixa.lisp. The lacre pipeline embeds the value verbatim \
4241         in its per-dep content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, \
4242         so the byte lands in the BLAKE3 closure and rides into every shell-spawned \
4243         subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a future \
4244         operator-side `nix flake check` spawn) as the canonical shell-history-substitution \
4245         / RFC-3986-unwise surface every peer single-token-shaped typed slot already closes. \
4246         The peer `:fonte :repo` axis closes the byte under the same shell-history-\
4247         substitution / RFC-3986-unwise banner (49e142f `^` on `is_git_repo_url`). Together \
4248         with the immediate-predecessor `!` arm (6a04767) this arm closes the full `set -o \
4249         histexpand` operator surface on the `:caminho` axis — the `!command` / `!!` / `!$` \
4250         prefix form via `!`, the `^old^new^` quick-substitution form via `^`. Express the \
4251         path as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
4252         directory name carries no shell-history-substitution / regex-negation / XOR-operator \
4253         semantic; drop any `^old^new` history-substitution paste-from-shell-history idiom; \
4254         drop any trailing `^` history-substitution-open fragment.",
4255        ch = *byte as char
4256    )]
4257    FonteCaminhoShellHistorySubstitution {
4258        nome: String,
4259        caminho: String,
4260        byte: u8,
4261    },
4262    #[error(
4263        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} has a trailing \
4264         `/` (the resolver's `Path::join` resolves `\"../caixa-teia\"` and \
4265         `\"../caixa-teia/\"` to the same directory, but the lacre pipeline embeds the \
4266         value verbatim in its per-dep content-address `path:{caminho}` at \
4267         caixa-resolver/src/resolve.rs:189, so two authors whose only difference is \
4268         shell tab-completion emit byte-divergent BLAKE3 closures for the same caixa — \
4269         defeating the THEORY.md §V.2 render-determinism contract via the trailing-\
4270         separator vector (the canonical paste-from-shell-tab-completion + paste-from-\
4271         `pwd`-with-`/`-suffix footgun, and the canonical Cargo-style `path = \
4272         \"../caixa-teia/\"` paste-from-Cargo-manifest cross-idiom leak). Drop the \
4273         trailing `/`; every `:caminho` value names a sibling-workspace directory \
4274         already, so the trailing separator carries no information. Use \
4275         `\"../caixa-teia\"` rather than `\"../caixa-teia/\"`)"
4276    )]
4277    FonteCaminhoTrailingSlash { nome: String, caminho: String },
4278    #[error(
4279        "{list} carries duplicate entry :nome {nome:?} — every dep list keys its \
4280         entries by caixa name (Cargo's [dependencies] / [dev-dependencies] tables \
4281         apply the same set-not-multiset discipline; one package per table), and \
4282         two entries naming the same caixa carry two version constraints / source \
4283         pins / feature sets for one identity. The caixa-resolver's lacre pipeline \
4284         consumes the list as a `HashMap`-keyed-by-`:nome` lookup: the second entry \
4285         silently overwrites the first at the resolver-side `concrete_versao` step, \
4286         and the dropped entry's pin / features never reach the closure — far from \
4287         the source caixa.lisp, with no field naming which `:deps` entry was the \
4288         silent loser. If two version constraints are genuinely needed (the rare \
4289         multi-version closure case the lacre pipeline doesn't yet support), the \
4290         author surface is two distinct caixa names (e.g. a `caixa-teia-v01` / \
4291         `caixa-teia-v02` aliased pair); within one list, one entry per caixa name."
4292    )]
4293    DuplicateNome { nome: String, list: &'static str },
4294    #[error(
4295        ":deps entry {nome:?} has empty :caracteristicas entry — every feature flag must \
4296         name a non-empty identifier on the target caixa (Cargo's [dependencies.<dep>.features] \
4297         applies the same per-entry non-empty discipline). An empty feature flag reaches the \
4298         caixa-resolver's lacre pipeline as a no-op feature enable, silently dropping the \
4299         author's intent far from the source caixa.lisp; drop the empty entry, or replace it \
4300         with the canonical kebab-case feature name the target caixa declares."
4301    )]
4302    CaracteristicaEmpty { nome: String },
4303    #[error(
4304        ":deps entry {nome:?} :caracteristicas entry {caracteristica:?} is not a valid Cargo \
4305         feature name: {reason} (the value flows verbatim into Cargo's \
4306         [dependencies.<dep>.features] list and Cargo's `restricted_names::validate_feature_name` \
4307         parser enforces the same shape at `cargo metadata` time; use a single-token \
4308         identifier like `\"http\"`, `\"derive\"`, or `\"runtime-tokio\"` — kebab-case ASCII \
4309         alphanumeric with `-`, `_`, `+`, or `.` as continuation characters, starting with \
4310         an ASCII alphanumeric or `_`)"
4311    )]
4312    CaracteristicaInvalid {
4313        nome: String,
4314        caracteristica: String,
4315        reason: String,
4316    },
4317    #[error(
4318        ":deps entry {nome:?} :caracteristicas carries duplicate feature {caracteristica:?} — \
4319         every feature-flag list keys its entries by name (Cargo's \
4320         [dependencies.<dep>.features] applies the same set-not-multiset discipline; one entry \
4321         per feature per dep), and two entries naming the same feature are a redundant \
4322         set-membership declaration for one identity (the feature-toggle slot is set-shaped; \
4323         enabling a feature twice has no additional semantic). The caixa-resolver's lacre \
4324         pipeline consumes the list as a set-shaped feature toggle — the resolver enables the \
4325         feature once regardless of declaration count, so the duplicate's pin / position never \
4326         reaches the closure with no field naming the silent loser. One entry per feature per \
4327         dep; if two distinct features are intended, name each verbatim."
4328    )]
4329    CaracteristicaDuplicate {
4330        nome: String,
4331        caracteristica: String,
4332    },
4333    #[error(
4334        "{list} entry :nome {nome:?} names the caixa itself — a caixa cannot depend \
4335         on itself (the lacre closure's dep-graph traversal is rooted at the caixa's \
4336         :nome, and a self-dep would be a one-node cycle the caixa-resolver either \
4337         rejects mid-traversal far from the source caixa.lisp or recurses on until \
4338         it exhausts its stack). Every :nome is globally-unique substrate identity, \
4339         so a :deps / :deps-dev entry whose :nome equals the parent caixa's :nome \
4340         *is* the parent itself, not a coincidentally-named peer. Drop the \
4341         self-referential dep entry — to reference code from this caixa, use \
4342         :bibliotecas / :exe / :servicos (the substrate-blessed shape for \
4343         referencing the caixa's own code surface) instead."
4344    )]
4345    DepIsSelf { nome: String, list: &'static str },
4346}
4347
4348// Fold the eleven `DepError::FonteCaminho<Variant> { nome: nome.to_string(),
4349// caminho: caminho.to_string() }` two-slot struct-variant wire-up sites at
4350// [`DepSource::validate_caminho`] onto one substrate primitive per typed
4351// variant — the paired `{ nome: String, caminho: String }` two-slot family
4352// on [`DepError`], sibling of the peer
4353// [`crate::supervisor::supervisor_caixa_only_ctors!`] (db09650, 3 variants
4354// on `{ caixa: String }`) on the `SupervisorError` envelope, the peer
4355// [`crate::aplicacao::contrato_empty_pair_ctors!`] (8580068, 4 variants on
4356// `{ de, para }`), [`crate::aplicacao::aplicacao_field_reason_ctors!`]
4357// (981060b, 7 variants on `{ <field>: String, reason: String }`),
4358// [`crate::aplicacao::contrato_target_ctors!`] (14b81d5, 2 variants on
4359// `{ de, para, wit, expected }`), and
4360// [`crate::aplicacao::contrato_pair_value_reason_ctors!`] (14e13f1, 3
4361// variants on `{ de, para, <field>: String, reason: String }`) on the
4362// `AplicacaoError` envelopes, the peer
4363// [`crate::layout::layout_violation_ctors!`] (131ca0d, 16 variants on
4364// `{ caixa, issue }`), [`crate::layout::layout_slot_kind_ctors!`]
4365// (0419438, 4 variants on `{ caixa, kind, slots }`),
4366// [`crate::LayoutError::missing_entry`] (1b09f9d, one variant on
4367// `{ kind, path }`), and [`crate::layout::layout_nome_only_ctors!`]
4368// (3fe3dd7, 6 variants on `<Variant>(String)`) on the `LayoutError`
4369// envelopes, the peer three [`crate::limits::limits_codec_value_*_ctors!`]
4370// codec-family macros (81c856c, 12 wire-ups) on the `LimitsError`
4371// envelope, and the peer [`crate::upgrade::upgrade_from_script_ctors!`]
4372// (8e67041, 3 variants on `{ from: String, script: PathBuf }`) on the
4373// `UpgradeError` envelope. First fold family on this `DepError` envelope.
4374//
4375// Each of the eleven wire-up sites on this shape (the leading-byte cascade
4376// closing the seven `FonteCaminho{Absolute, TildeExpansion, VarExpansion,
4377// LeadingWhitespace, LeadingHyphen}` arms; the orthogonal single-metachar
4378// cascade closing `FonteCaminhoBackslash` on `\`; the shell-lexer-metachar
4379// cascade closing `FonteCaminhoShell{Pipe, Semicolon, Background,
4380// CommandSubstitution}` on the four single-byte shell operators; and the
4381// trailing-`/` reproducibility arm closing `FonteCaminhoTrailingSlash`)
4382// opened the identical `DepError::FonteCaminho<Variant> { nome:
4383// nome.to_string(), caminho: caminho.to_string() }` four-line
4384// struct-literal against the same `(nome: &str, caminho: &str)` local pair
4385// — the exact "same block re-inlined at every consumer" shape the PRIME
4386// DIRECTIVE names as a bug, on the same altitude the peer `LayoutError` /
4387// `AplicacaoError` / `SupervisorError` / `LimitsError` / `UpgradeError`
4388// families each closed on their sibling envelopes. The eleven variants
4389// share one `{ nome: String, caminho: String }` shape, so the fold routes
4390// each wire-up site through one dispatch per typed variant.
4391//
4392// The macro below generates one `#[must_use]` inherent constructor per
4393// variant of shape `fn <ctor>(nome: &str, caminho: &str) -> Self`, so every
4394// wire-up site collapses onto one dispatch:
4395// `DepError::<ctor>(nome, caminho)`, byte-equal to the pre-lift
4396// struct-literal on the same `(&str, &str)` fixture. The uniform two-field
4397// construction (`nome.to_string()` / `caminho.to_string()`) is spelled
4398// once — inside the macro — rather than at every wire-up site.
4399//
4400// The three sibling shapes on this envelope carrying additional payload
4401// (the `FonteCaminhoEmpty` one-field `{ nome }` shape at the empty-first
4402// arm, the twelve `FonteCaminho<Variant> { nome, caminho, byte }`
4403// three-field shapes at the per-byte-classification arms, and the
4404// per-arm `FonteCaminho{ControlChar,ShellRedirection,ShellGlob,
4405// ShellSubshellGrouping,ShellBraceExpansion,ShellBracketExpansion,
4406// ShellQuoteGrouping,ShellComment,UrlPercentEncoding,
4407// ShellVariableExpansion,ShellHistoryExpansion,ShellHistorySubstitution}`
4408// cluster) stay on their pre-lift open-coded shape — each carries a
4409// distinct field set (`byte: u8` naming the offending byte) that would
4410// break the uniform-two-field routing this macro promises. Each is one
4411// wire-up per variant already, so extending the fold to a per-shape
4412// sibling macro is future compounding work rather than duplication this
4413// lift needs to close.
4414//
4415// Every future consumer that wants to construct one of these eleven
4416// variants outside the current in-crate [`DepSource::validate_caminho`]
4417// wire-up sites (a deferred `caixa-resolver` per-`:caminho` re-validator
4418// at lacre-resolve time re-checking the same value-shape axes the resolver
4419// consumes, a future `feira validate --deps` per-caixa admission verb
4420// re-checking the `:fonte :caminho` axis, a per-lacre overlay resolver
4421// rejecting a `:caminho` value against a cluster-local snapshot) now
4422// reaches each variant through one call rather than re-inlining the
4423// four-line struct-literal in lockstep with the eleven in-crate wire-up
4424// sites.
4425macro_rules! fonte_caminho_ctors {
4426    ($($ctor:ident => $variant:ident),* $(,)?) => {
4427        impl DepError {
4428            $(
4429                #[doc = concat!(
4430                    "Construct a [`DepError::",
4431                    stringify!($variant),
4432                    "`] naming the offending `:deps :nome` + `:fonte ",
4433                    "(:tipo path …) :caminho` pair. Folds the uniform ",
4434                    "`Self::",
4435                    stringify!($variant),
4436                    " { nome: nome.to_string(), caminho: caminho.to_string() }` ",
4437                    "two-slot struct-literal onto one substrate primitive so ",
4438                    "every [`DepSource::validate_caminho`] wire-up on this ",
4439                    "variant reads through one dispatch rather than the ",
4440                    "pre-lift four-line open-coded block."
4441                )]
4442                #[must_use]
4443                pub fn $ctor(nome: &str, caminho: &str) -> Self {
4444                    Self::$variant {
4445                        nome: nome.to_string(),
4446                        caminho: caminho.to_string(),
4447                    }
4448                }
4449            )*
4450        }
4451    };
4452}
4453
4454fonte_caminho_ctors! {
4455    fonte_caminho_absolute => FonteCaminhoAbsolute,
4456    fonte_caminho_tilde_expansion => FonteCaminhoTildeExpansion,
4457    fonte_caminho_var_expansion => FonteCaminhoVarExpansion,
4458    fonte_caminho_leading_whitespace => FonteCaminhoLeadingWhitespace,
4459    fonte_caminho_leading_hyphen => FonteCaminhoLeadingHyphen,
4460    fonte_caminho_backslash => FonteCaminhoBackslash,
4461    fonte_caminho_shell_pipe => FonteCaminhoShellPipe,
4462    fonte_caminho_shell_semicolon => FonteCaminhoShellSemicolon,
4463    fonte_caminho_shell_background => FonteCaminhoShellBackground,
4464    fonte_caminho_shell_command_substitution => FonteCaminhoShellCommandSubstitution,
4465    fonte_caminho_trailing_slash => FonteCaminhoTrailingSlash,
4466}
4467
4468// Fold the five `DepError::<Variant> { nome: <owner>.clone_or_to_string() }`
4469// single-slot struct-variant wire-up sites scattered across
4470// [`Dep::validate`] / [`Dep::validate_caracteristicas`] /
4471// [`DepSource::validate`] / [`DepSource::validate_caminho`] onto one
4472// substrate primitive per typed variant — the paired `{ nome: String }`
4473// single-slot family on [`DepError`], sibling of the peer
4474// [`fonte_caminho_ctors!`] (f85f145, 11 variants on
4475// `{ nome: String, caminho: String }`) on the sibling two-slot envelope of
4476// the same enum, and of the peer
4477// [`crate::supervisor::supervisor_caixa_only_ctors!`] (db09650, 3 variants
4478// on `{ caixa: String }`) on the `SupervisorError` envelope's single-slot
4479// axis. Second fold family on this `DepError` envelope, and the first on
4480// the single-`{ nome }` shape.
4481//
4482// The five wire-up sites this fold closes each opened the identical
4483// `DepError::<Variant> { nome: <owner>.to_string_or_clone() }` three-line
4484// struct-literal against the same `nome: &str` (or `self.nome: &String`)
4485// local — the exact "same block re-inlined at every consumer" shape the
4486// PRIME DIRECTIVE names as a bug. The five variants share one
4487// `{ nome: String }` shape, so the fold routes each wire-up site through
4488// one dispatch per typed variant.
4489//
4490// The macro below generates one `#[must_use]` inherent constructor per
4491// variant of shape `fn <ctor>(nome: &str) -> Self`, so every wire-up site
4492// collapses onto one dispatch: `DepError::<ctor>(nome)`, byte-equal to the
4493// pre-lift struct-literal on the same `&str` fixture. The uniform
4494// one-field construction (`nome.to_string()`) is spelled once — inside
4495// the macro — rather than at every wire-up site. Callers that hold a
4496// `String` (`self.nome`) pass `&self.nome`, which auto-derefs to `&str`
4497// and lets the macro-owned `.to_string()` produce the fresh owning copy
4498// the enum variant needs; the semantics collapse onto the same
4499// `.clone()`-equivalent one this fold replaces at every site.
4500//
4501// The sibling `NomeEmpty` unit-variant (`enum DepError { NomeEmpty, … }`)
4502// on the same envelope stays on its pre-lift open-coded wire-up shape —
4503// it carries no `nome` field (the offending `:nome` value *is* the empty
4504// string this variant catches) so the uniform `fn(nome: &str) -> Self`
4505// signature this macro promises does not apply. Every future consumer
4506// that wants to construct one of these five variants outside the current
4507// in-crate wire-up sites (a deferred `caixa-resolver` per-`:versao` /
4508// `:caracteristicas` / `:fonte :repo` / `:fonte :pin` / `:fonte :caminho`
4509// re-validator at lacre-resolve time, a future `feira validate --deps`
4510// per-caixa admission verb, a per-lacre overlay resolver rejecting one of
4511// these empty-value shapes against a cluster-local snapshot) now reaches
4512// each variant through one call rather than re-inlining the three-line
4513// struct-literal in lockstep with the five in-crate wire-up sites.
4514macro_rules! dep_nome_only_ctors {
4515    ($($ctor:ident => $variant:ident),* $(,)?) => {
4516        impl DepError {
4517            $(
4518                #[doc = concat!(
4519                    "Construct a [`DepError::",
4520                    stringify!($variant),
4521                    "`] naming the offending `:deps :nome`. Folds the ",
4522                    "uniform `Self::",
4523                    stringify!($variant),
4524                    " { nome: nome.to_string() }` one-field ",
4525                    "struct-literal onto one substrate primitive so every ",
4526                    "in-crate wire-up on this variant reads through one ",
4527                    "dispatch rather than the pre-lift three-line ",
4528                    "open-coded block."
4529                )]
4530                #[must_use]
4531                pub fn $ctor(nome: &str) -> Self {
4532                    Self::$variant { nome: nome.to_string() }
4533                }
4534            )*
4535        }
4536    };
4537}
4538
4539dep_nome_only_ctors! {
4540    versao_empty => VersaoEmpty,
4541    fonte_repo_empty => FonteRepoEmpty,
4542    fonte_pin_missing => FontePinMissing,
4543    fonte_caminho_empty => FonteCaminhoEmpty,
4544    caracteristica_empty => CaracteristicaEmpty,
4545}
4546
4547#[allow(clippy::trivially_copy_pass_by_ref)]
4548fn is_false(b: &bool) -> bool {
4549    !*b
4550}
4551
4552#[cfg(test)]
4553mod tests {
4554    use super::*;
4555
4556    #[test]
4557    fn registry_dep_is_minimal() {
4558        let d = Dep::simple("caixa-teia", "^0.1");
4559        assert_eq!(d.nome, "caixa-teia");
4560        assert_eq!(d.versao, "^0.1");
4561        assert!(d.fonte.is_none());
4562        assert!(!d.opcional());
4563        assert!(d.caracteristicas().is_empty());
4564    }
4565
4566    #[test]
4567    fn dep_string_scalar_accessor_pair_is_const_fn() {
4568        // Fail-before-pass-after pin on [`Dep::nome`] +
4569        // [`Dep::versao_requirement`]'s `const`-eval-surface posture.
4570        // Each accessor projects the per-`:deps` / per-`:deps-dev`
4571        // entry's [`String`] storage through the `pub const fn`
4572        // [`String::as_str`] (const-stable since Rust 1.87, well
4573        // within the workspace MSRV) — any future accidental
4574        // downgrade to non-`const` fails the corresponding
4575        // `<name>_via_const_fn` wrapper at caixa-core build time with
4576        // E0015 (`cannot call non-const method`), strictly stronger
4577        // than a runtime `assert!`. Sibling of the peer
4578        // per-M2/M3/universal-axis `String → &str` scalar-accessor
4579        // family pins on the sibling `const`-eval-surface passes
4580        // ([`crate::Caixa::nome`] / [`crate::Caixa::versao`] at the
4581        // top-level manifest, [`crate::CaixaVersion::as_str`] at the
4582        // typed-newtype wrapper, [`crate::aplicacao::Membro::nome`] /
4583        // [`crate::aplicacao::Membro::versao_requirement`] at the M3
4584        // membership axis, [`crate::aplicacao::Entrada::hostname`] /
4585        // [`crate::aplicacao::Entrada::destination`] at the M3
4586        // ingress axis, [`crate::supervisor::ChildSpec::nome`] /
4587        // [`crate::supervisor::ChildSpec::versao_requirement`] at the
4588        // M2 supervisor-tree axis,
4589        // [`crate::upgrade::UpgradeFromEntry::prior_versao`] at the
4590        // M2 upgrade axis, and the per-`:contratos`
4591        // [`crate::aplicacao::WitContract::source`] /
4592        // [`crate::aplicacao::WitContract::destination`] /
4593        // [`crate::aplicacao::WitContract::world_ref`] trio the
4594        // sibling pin at 279823b already anchors).
4595        const fn nome_via_const_fn(d: &Dep) -> &str {
4596            d.nome()
4597        }
4598        const fn versao_via_const_fn(d: &Dep) -> &str {
4599            d.versao_requirement()
4600        }
4601        for (nome, versao) in [
4602            ("caixa-teia", "^0.1"),
4603            ("caixa-mesh", "~0.2.3"),
4604            ("caixa-helm", "*"),
4605        ] {
4606            let d = Dep::simple(nome, versao);
4607            assert_eq!(nome_via_const_fn(&d), d.nome());
4608            assert_eq!(versao_via_const_fn(&d), d.versao_requirement());
4609            assert_eq!(d.nome(), nome);
4610            assert_eq!(d.versao_requirement(), versao);
4611        }
4612    }
4613
4614    #[test]
4615    fn dep_outer_accessor_family_is_const_fn() {
4616        // Fail-before-pass-after pin on [`Dep::fonte`] +
4617        // [`Dep::caracteristicas`]'s `const`-eval-surface posture.
4618        // Each accessor projects the per-`:deps` / per-`:deps-dev`
4619        // entry's composite / list storage through a `pub const fn`
4620        // stdlib method (`Option::<DepSource>::as_ref` /
4621        // `Vec::<String>::as_slice`, both const-stable since Rust
4622        // 1.83, well within the workspace MSRV). Any future
4623        // accidental downgrade to non-`const` fails the corresponding
4624        // `<name>_via_const_fn` wrapper at caixa-core build time with
4625        // E0015 (`cannot call non-const method`), strictly stronger
4626        // than a runtime `assert!` and side-stepping the destructor-
4627        // in-const restriction the `Dep` fixture's `String` /
4628        // `Option<DepSource>` / `Vec<String>` carriers rule out on the
4629        // direct-`const _: () = assert!(...)` residence.
4630        //
4631        // Peer of the sibling per-`Dep` scalar-accessor pair pin
4632        // [`dep_string_scalar_accessor_pair_is_const_fn`] on the same
4633        // outer per-dep-list-entry [`Dep`] altitude — this pin extends
4634        // the `const`-eval-surface discipline onto the composite-
4635        // reference and slice-return arms of the outer-`Dep` accessor
4636        // family, closing the four-slot outer surface (`:nome` +
4637        // `:versao` + `:fonte` + `:caracteristicas`) on the `const`-fn
4638        // posture. The `:opcional` `bool` arm already carries the
4639        // posture through [`Dep::opcional`]'s prior `pub const fn`
4640        // declaration, so this pin lands the last two unlifted
4641        // outer-`Dep` accessors and closes the family.
4642        const fn fonte_via_const_fn(d: &Dep) -> Option<&DepSource> {
4643            d.fonte()
4644        }
4645        const fn caracteristicas_via_const_fn(d: &Dep) -> &[String] {
4646            d.caracteristicas()
4647        }
4648        // `Dep::simple` — no `:fonte`, empty `:caracteristicas`.
4649        let empty = Dep::simple("caixa-teia", "^0.1");
4650        assert!(fonte_via_const_fn(&empty).is_none());
4651        assert_eq!(fonte_via_const_fn(&empty), empty.fonte());
4652        assert!(caracteristicas_via_const_fn(&empty).is_empty());
4653        assert_eq!(
4654            caracteristicas_via_const_fn(&empty),
4655            empty.caracteristicas()
4656        );
4657        // `Dep::git` — `:fonte` is `Some(Git{…})`, `:caracteristicas`
4658        // still empty.
4659        let git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
4660        assert!(fonte_via_const_fn(&git).is_some());
4661        assert_eq!(fonte_via_const_fn(&git), git.fonte());
4662        assert_eq!(caracteristicas_via_const_fn(&git), git.caracteristicas());
4663        // Populated `:caracteristicas` — exercise the non-empty
4664        // slice-view arm to pin the accessor's borrow shape against
4665        // both a `Vec::new()` empty backing buffer and a populated one.
4666        let mut with_features = Dep::simple("caixa-teia", "^0.1");
4667        with_features.caracteristicas = vec!["feat-a".into(), "feat-b".into()];
4668        assert_eq!(caracteristicas_via_const_fn(&with_features).len(), 2);
4669        assert_eq!(
4670            caracteristicas_via_const_fn(&with_features),
4671            with_features.caracteristicas()
4672        );
4673    }
4674
4675    #[test]
4676    fn git_dep_carries_tag() {
4677        let d = Dep::git("t", "*", "github:o/r", "v1");
4678        match d.fonte {
4679            Some(DepSource::Git {
4680                ref repo, ref tag, ..
4681            }) => {
4682                assert_eq!(repo, "github:o/r");
4683                assert_eq!(tag.as_deref(), Some("v1"));
4684            }
4685            _ => panic!("expected Git source"),
4686        }
4687    }
4688
4689    #[test]
4690    fn validate_accepts_simple_dep() {
4691        Dep::simple("caixa-teia", "^0.1").validate().unwrap();
4692    }
4693
4694    #[test]
4695    fn validate_rejects_empty_nome() {
4696        // The fail-before-pass-after pin for `:nome ""`: the empty-name
4697        // arm fires first so the per-entry parse-side diagnostic doesn't
4698        // emit a useless `nome: ""` reference.
4699        let mut d = Dep::simple("placeholder", "^0.1");
4700        d.nome = String::new();
4701        assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
4702    }
4703
4704    #[test]
4705    fn validate_rejects_empty_versao() {
4706        // `parse_requirement("")` returns `Ok(VersionReq::STAR)` (the
4707        // semver crate accepts the empty string as a wildcard match),
4708        // so the empty-`:versao` arm is structurally necessary even
4709        // with the parse arm in place — mirrors `MembroVersaoEmpty` /
4710        // `EmptyChildVersion` ordering on the other two `:versao` axes.
4711        let mut d = Dep::simple("caixa-teia", "ignored");
4712        d.versao = String::new();
4713        let err = d.validate().unwrap_err();
4714        assert!(
4715            matches!(err, DepError::VersaoEmpty { ref nome } if nome == "caixa-teia"),
4716            "got {err:?}"
4717        );
4718    }
4719
4720    // ── value-shape: DNS-1123 label on :deps :nome ────────────────────────
4721
4722    #[test]
4723    fn validate_rejects_nome_with_uppercase() {
4724        // The fail-before-pass-after pin: a non-empty but uppercase
4725        // `:nome` silently passed `validate()` on every pre-gate
4726        // codebase because the prior shape only refused the empty
4727        // string. The DNS-1123 violation surfaced far downstream at
4728        // lacre-resolve time when the *target* caixa's `:nome` failed
4729        // its own gate — far from the `:deps` entry, with a diagnostic
4730        // naming the target rather than the dep entry that referenced
4731        // it. Same fail-before-pass-after fixture pinned for
4732        // `:membros :caixa` (3f9d7a0), `:children :caixa` (31bfa43),
4733        // and Caixa `:nome` (6c992f8).
4734        let d = Dep::simple("Caixa-Teia", "^0.1");
4735        let err = d.validate().unwrap_err();
4736        assert!(
4737            matches!(
4738                err,
4739                DepError::NomeInvalid { ref nome, ref reason }
4740                    if nome == "Caixa-Teia" && reason.contains("uppercase")
4741            ),
4742            "got {err:?}"
4743        );
4744    }
4745
4746    #[test]
4747    fn validate_rejects_nome_with_underscore() {
4748        // RFC 1123 allows `[a-z0-9-]` only; underscore is the canonical
4749        // "I'm thinking of Go module names / Python identifiers" leak.
4750        // Same fixture pinned for the peer caixa-identifier axes.
4751        let d = Dep::simple("caixa_teia", "^0.1");
4752        let err = d.validate().unwrap_err();
4753        assert!(
4754            matches!(
4755                err,
4756                DepError::NomeInvalid { ref nome, ref reason }
4757                    if nome == "caixa_teia" && reason.contains('_')
4758            ),
4759            "got {err:?}"
4760        );
4761    }
4762
4763    #[test]
4764    fn validate_rejects_nome_with_dot() {
4765        // A `:deps :nome` is a single DNS-1123 *label*, not a
4766        // subdomain — dots are rejected. The `"caixa.teia"` shape is
4767        // the canonical "I confused the dep name with the FQDN /
4768        // namespace" footgun, distinct from the legitimate
4769        // `:fonte :repo "github:org/caixa-teia"` axis.
4770        let d = Dep::simple("caixa.teia", "^0.1");
4771        let err = d.validate().unwrap_err();
4772        assert!(
4773            matches!(
4774                err,
4775                DepError::NomeInvalid { ref nome, ref reason }
4776                    if nome == "caixa.teia" && reason.contains('.')
4777            ),
4778            "got {err:?}"
4779        );
4780    }
4781
4782    #[test]
4783    fn validate_rejects_nome_with_leading_hyphen() {
4784        // RFC 1123 requires alphanumeric at both label boundaries.
4785        // Pinned in parity with the peer DNS-1123 fixtures.
4786        let d = Dep::simple("-caixa-teia", "^0.1");
4787        let err = d.validate().unwrap_err();
4788        assert!(
4789            matches!(
4790                err,
4791                DepError::NomeInvalid { ref nome, ref reason }
4792                    if nome == "-caixa-teia" && reason.contains("alphanumeric")
4793            ),
4794            "got {err:?}"
4795        );
4796    }
4797
4798    #[test]
4799    fn validate_rejects_nome_with_trailing_hyphen() {
4800        let d = Dep::simple("caixa-teia-", "^0.1");
4801        let err = d.validate().unwrap_err();
4802        assert!(
4803            matches!(
4804                err,
4805                DepError::NomeInvalid { ref nome, ref reason }
4806                    if nome == "caixa-teia-" && reason.contains("alphanumeric")
4807            ),
4808            "got {err:?}"
4809        );
4810    }
4811
4812    #[test]
4813    fn validate_rejects_nome_with_slash() {
4814        // The canonical "I copied the GitHub repo path into `:nome`
4815        // instead of `:fonte :repo`" typo. A `/` in the name leaks the
4816        // lacre-side `:repositorio` shape (`pleme-io/caixa-teia`) into
4817        // the local-name slot. Same fixture pinned for `:membros
4818        // :caixa` (3f9d7a0).
4819        let d = Dep::simple("pleme-io/caixa-teia", "^0.1");
4820        let err = d.validate().unwrap_err();
4821        assert!(
4822            matches!(
4823                err,
4824                DepError::NomeInvalid { ref nome, ref reason }
4825                    if nome == "pleme-io/caixa-teia" && reason.contains('/')
4826            ),
4827            "got {err:?}"
4828        );
4829    }
4830
4831    #[test]
4832    fn validate_rejects_nome_too_long() {
4833        // 64-byte label — one over the RFC 1035 / RFC 1123 label cap.
4834        // Built from a valid character set so the length-bound
4835        // diagnostic surfaces before any per-character check (the
4836        // order pin parallel to the per-character predicates inside
4837        // [`crate::render::is_dns_1123_label`]).
4838        let long = "a".repeat(64);
4839        let d = Dep::simple(&long, "^0.1");
4840        let err = d.validate().unwrap_err();
4841        assert!(
4842            matches!(
4843                err,
4844                DepError::NomeInvalid { ref nome, ref reason }
4845                    if nome.len() == 64 && reason.contains("max length of 63")
4846            ),
4847            "got {err:?}"
4848        );
4849    }
4850
4851    #[test]
4852    fn validate_accepts_canonical_nome_labels() {
4853        // Positive-control sweep — every form the K8s apiserver
4854        // accepts as a DNS-1123 label must round-trip through
4855        // validate. Covers a hyphen-bearing label, a numeric-suffix
4856        // label, a leading-digit label, a single-character label, and
4857        // a 63-byte (exactly the cap) label — the same fixture set
4858        // the peer `:membros :caixa` / `:children :caixa` positive
4859        // controls pin.
4860        for nome in [
4861            "caixa-teia",
4862            "caixa-resolver2",
4863            "2nd-tier-cache",
4864            "x",
4865            "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0",
4866        ] {
4867            Dep::simple(nome, "^0.1")
4868                .validate()
4869                .unwrap_or_else(|e| panic!("canonical label {nome:?} must validate, got {e:?}"));
4870        }
4871    }
4872
4873    #[test]
4874    fn nome_empty_takes_precedence_over_nome_invalid() {
4875        // Ordering pin: `NomeEmpty` is the more self-locating
4876        // diagnostic on `""` and must lead — `is_dns_1123_label` is
4877        // only reached after the empty-check fires at the call site.
4878        // Mirrors `membro_caixa_empty_takes_precedence_over_invalid`
4879        // (3f9d7a0) on the peer caixa-identifier axis.
4880        let mut d = Dep::simple("placeholder", "^0.1");
4881        d.nome = String::new();
4882        assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
4883    }
4884
4885    #[test]
4886    fn nome_invalid_fires_before_versao_empty() {
4887        // Ordering pin: a malformed `:nome` fires before any `:versao`
4888        // axis check on the *same* entry — the per-entry shape gates
4889        // run top-to-bottom (nome empty → nome shape → versao empty →
4890        // versao parse → fonte shape), so a one-entry caixa.lisp with
4891        // both wrong sees the name-side diagnostic first (the name is
4892        // the self-locating axis — without a valid name, the parse
4893        // diagnostic can't quote `:nome "<bad>"`). Same ordering
4894        // discipline as `membro_caixa_invalid_fires_before_versao_check`
4895        // (3f9d7a0).
4896        let mut d = Dep::simple("Caixa-Teia", "^0.1");
4897        d.versao = String::new();
4898        let err = d.validate().unwrap_err();
4899        assert!(
4900            matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
4901            "got {err:?}"
4902        );
4903    }
4904
4905    #[test]
4906    fn nome_invalid_fires_before_versao_invalid() {
4907        // Ordering pin: a malformed `:nome` fires before the `:versao`
4908        // parse-side check on the *same* entry. Pin separately from
4909        // the empty-versao ordering so a future re-ordering surfaces
4910        // here, parallel to the b0c8389 / c4213a4 trajectory.
4911        let d = Dep::simple("Caixa-Teia", "^^0.1");
4912        let err = d.validate().unwrap_err();
4913        assert!(
4914            matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
4915            "got {err:?}"
4916        );
4917    }
4918
4919    #[test]
4920    fn nome_invalid_fires_before_fonte_invalid() {
4921        // Ordering pin: a malformed `:nome` fires before the `:fonte`
4922        // shape check on the *same* entry. The `:fonte` diagnostic
4923        // names the offending dep's `:nome` verbatim (via
4924        // `DepSource::validate(&self.nome)`), so a non-self-locating
4925        // name would taint the downstream diagnostic too — the gate
4926        // ordering keeps both diagnostics individually self-locating.
4927        let mut d = Dep::simple("Caixa-Teia", "^0.1");
4928        d.fonte = Some(DepSource::Git {
4929            repo: String::new(),
4930            tag: None,
4931            rev: None,
4932            branch: None,
4933        });
4934        let err = d.validate().unwrap_err();
4935        assert!(
4936            matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
4937            "got {err:?}"
4938        );
4939    }
4940
4941    #[test]
4942    fn nome_invalid_diagnostic_carries_offending_name() {
4943        // The diagnostic-shape pin: the error names the offending
4944        // `:nome` value verbatim so the author can grep their
4945        // caixa.lisp without re-running the build, and carries a
4946        // non-empty `reason` from `is_dns_1123_label` so the
4947        // predicate's own wording flows through to the diagnostic.
4948        // Same shape as `MembroCaixaInvalid` (3f9d7a0),
4949        // `ChildCaixaInvalid` (31bfa43), `ManifestError::NomeInvalid`
4950        // (6c992f8) — the four DNS-1123 caixa-identifier axes now
4951        // share a structurally-equivalent diagnostic family.
4952        let d = Dep::simple("Caixa_Teia", "^0.1");
4953        let err = d.validate().unwrap_err();
4954        let DepError::NomeInvalid { nome, reason } = err else {
4955            panic!("expected NomeInvalid, got other variant");
4956        };
4957        assert_eq!(nome, "Caixa_Teia");
4958        assert!(
4959            !reason.is_empty(),
4960            "NomeInvalid `reason` must carry the predicate's wording verbatim"
4961        );
4962    }
4963
4964    #[test]
4965    fn validate_rejects_invalid_versao_requirement() {
4966        // The fail-before-pass-after pin: a non-empty but malformed
4967        // requirement (`"^bad-version"`) silently passed every pre-gate
4968        // codebase because `:deps :versao` wasn't validated. The parse
4969        // failure surfaced far downstream at lacre-resolve time with a
4970        // `semver::Error` that didn't name which `:deps` entry carried
4971        // the typo. The new gate moves the check to caixa-build time
4972        // at the source caixa.lisp.
4973        let d = Dep::simple("caixa-teia", "^bad-version");
4974        let err = d.validate().unwrap_err();
4975        assert!(
4976            matches!(
4977                err,
4978                DepError::VersaoInvalid { ref nome, ref versao, .. }
4979                    if nome == "caixa-teia" && versao == "^bad-version"
4980            ),
4981            "got {err:?}"
4982        );
4983    }
4984
4985    #[test]
4986    fn validate_rejects_versao_with_double_caret_typo() {
4987        // `"^^0.1"` is the canonical doubled-caret typo — looks like a
4988        // Cargo-shaped requirement on first glance but fails the parser
4989        // because semver doesn't accept stacked operators. Pin this
4990        // adjacent-shape footgun explicitly so a future relaxation that
4991        // accepts "looks-canonical-but-isn't" forms surfaces here, in
4992        // parity with the `:membros` / `:children` fixtures.
4993        let d = Dep::simple("caixa-teia", "^^0.1");
4994        let err = d.validate().unwrap_err();
4995        assert!(
4996            matches!(
4997                err,
4998                DepError::VersaoInvalid { ref nome, ref versao, .. }
4999                    if nome == "caixa-teia" && versao == "^^0.1"
5000            ),
5001            "got {err:?}"
5002        );
5003    }
5004
5005    #[test]
5006    fn validate_rejects_versao_with_v_prefixed_tag() {
5007        // `"v0.1"` is the canonical "git-tag-shape leaking into the
5008        // semver requirement slot" typo — an author copies the
5009        // publish-side git-tag string verbatim into `:versao`, but
5010        // Cargo's semver parser rejects the leading `v`. Same fixture
5011        // pinned for `:membros :versao` (9888b13) and `:children
5012        // :versao` (b38ff3a). (Bare `x`-glob shorthands like `^0.1.x`
5013        // are *accepted* by the semver crate as an `*` wildcard on the
5014        // patch axis — they're a Cargo-side valid shape, not a typo.)
5015        let d = Dep::simple("caixa-teia", "v0.1");
5016        let err = d.validate().unwrap_err();
5017        assert!(
5018            matches!(
5019                err,
5020                DepError::VersaoInvalid { ref nome, ref versao, .. }
5021                    if nome == "caixa-teia" && versao == "v0.1"
5022            ),
5023            "got {err:?}"
5024        );
5025    }
5026
5027    #[test]
5028    fn validate_accepts_canonical_versao_forms() {
5029        // The five Cargo-shaped requirement forms `:membros :versao`
5030        // and `:children :versao` already accept via
5031        // `crate::parse_requirement` must pass the deps gate without
5032        // re-validating at the resolver layer. Pin every leg so a
5033        // future tightening of the canonical set surfaces here as a
5034        // test failure.
5035        for form in [
5036            "^0.1",      // caret — minor-range pin (the most common shape)
5037            "~0.1.2",    // tilde — patch-range pin
5038            "0.1.0",     // exact — single-version pin
5039            "*",         // wildcard — explicitly any-version
5040            ">=0.1, <2", // multi-range — comma-separated comparators
5041        ] {
5042            Dep::simple("caixa-teia", form)
5043                .validate()
5044                .unwrap_or_else(|e| panic!("canonical form {form:?} must validate, got {e:?}"));
5045        }
5046    }
5047
5048    #[test]
5049    fn versao_empty_takes_precedence_over_invalid() {
5050        // Order pin: the existing `VersaoEmpty` diagnostic (which
5051        // doesn't try to parse) fires before the new `VersaoInvalid`
5052        // parse-side diagnostic, so an empty `:versao` keeps its
5053        // narrower error message — `parse_requirement("")` would
5054        // otherwise return `Ok(STAR)` and silently pass, but the empty
5055        // arm catches it first.
5056        let mut d = Dep::simple("caixa-teia", "ignored");
5057        d.versao = String::new();
5058        let err = d.validate().unwrap_err();
5059        assert!(
5060            matches!(err, DepError::VersaoEmpty { ref nome } if nome == "caixa-teia"),
5061            "got {err:?}"
5062        );
5063    }
5064
5065    #[test]
5066    fn nome_empty_takes_precedence_over_versao_invalid() {
5067        // Order pin: even when `:versao` is malformed and would raise
5068        // its own diagnostic, `:nome ""` fires first because the
5069        // per-entry parse diagnostic needs a non-empty name to be
5070        // self-locating. Mirrors the
5071        // `membros_validation_runs_before_contratos_membership_check`
5072        // ordering on the typed-graph layer.
5073        let mut d = Dep::simple("placeholder", "^bad");
5074        d.nome = String::new();
5075        let err = d.validate().unwrap_err();
5076        assert_eq!(err, DepError::NomeEmpty);
5077    }
5078
5079    #[test]
5080    fn versao_invalid_diagnostic_carries_offending_versao() {
5081        // The diagnostic-shape pin: the error names the offending
5082        // `:versao` value verbatim so the author can grep their
5083        // caixa.lisp without re-running the build, and carries a
5084        // non-empty `reason` from `semver::VersionReq::parse` so the
5085        // parser's own wording flows through to the diagnostic.
5086        let d = Dep::simple("caixa-teia", "not-a-req");
5087        let err = d.validate().unwrap_err();
5088        let DepError::VersaoInvalid {
5089            nome,
5090            versao,
5091            reason,
5092        } = err
5093        else {
5094            panic!("expected VersaoInvalid, got other variant");
5095        };
5096        assert_eq!(nome, "caixa-teia");
5097        assert_eq!(versao, "not-a-req");
5098        assert!(
5099            !reason.is_empty(),
5100            "VersaoInvalid `reason` must carry the parser's wording verbatim"
5101        );
5102    }
5103
5104    // -- :fonte value-shape gate ------------------------------------------
5105
5106    fn dep_with_fonte(fonte: DepSource) -> Dep {
5107        let mut d = Dep::simple("caixa-teia", "^0.1");
5108        d.fonte = Some(fonte);
5109        d
5110    }
5111
5112    #[test]
5113    fn validate_accepts_git_fonte_with_tag() {
5114        // The positive-control pin on the canonical git source — exactly
5115        // one of :tag/:rev/:branch set, non-empty :repo. Mirrors the
5116        // shape every existing caixa-resolver integration test uses.
5117        let d = dep_with_fonte(DepSource::Git {
5118            repo: "github:pleme-io/caixa-teia".into(),
5119            tag: Some("v0.1.0".into()),
5120            rev: None,
5121            branch: None,
5122        });
5123        d.validate().unwrap();
5124    }
5125
5126    #[test]
5127    fn validate_accepts_git_fonte_with_rev() {
5128        // Each of the three pin axes is independently a valid single-pin
5129        // shape; pin the :rev arm so a future relaxation that only
5130        // accepts :tag surfaces here. The value is a full 40-hex SHA-1
5131        // OID — the canonical `git rev-parse HEAD` emission shape the
5132        // `crate::render::is_git_oid` value-shape gate now requires;
5133        // abbreviated OIDs are ambiguous across repo history and
5134        // rejected at this gate (pinned separately by
5135        // `validate_rejects_git_fonte_with_rev_abbreviated_prefix`).
5136        let d = dep_with_fonte(DepSource::Git {
5137            repo: "github:pleme-io/caixa-teia".into(),
5138            tag: None,
5139            rev: Some("c0ffee0123abcdef0123456789abcdef01234567".into()),
5140            branch: None,
5141        });
5142        d.validate().unwrap();
5143    }
5144
5145    #[test]
5146    fn validate_accepts_git_fonte_with_branch() {
5147        // The :branch arm is the third valid single-pin shape — pinned
5148        // separately so the gate-accepts-all-three-pin-axes contract is
5149        // a build-error to relax.
5150        let d = dep_with_fonte(DepSource::Git {
5151            repo: "github:pleme-io/caixa-teia".into(),
5152            tag: None,
5153            rev: None,
5154            branch: Some("main".into()),
5155        });
5156        d.validate().unwrap();
5157    }
5158
5159    #[test]
5160    fn validate_accepts_path_fonte() {
5161        // The positive-control pin on the path source — non-empty
5162        // :caminho, no pin axes (paths have no commit identity). Pinned
5163        // so a future "paths must also pin a rev" tightening surfaces
5164        // here as a structural decision, not a silent break.
5165        let d = dep_with_fonte(DepSource::Path {
5166            caminho: "../caixa-teia".into(),
5167        });
5168        d.validate().unwrap();
5169    }
5170
5171    #[test]
5172    fn validate_rejects_git_fonte_with_empty_repo() {
5173        // The fail-before-pass-after pin for `(:tipo git :repo "" :tag
5174        // "v1")`: the empty-repo shape silently passed every pre-gate
5175        // codebase because `:fonte` wasn't validated. The git-clone
5176        // failure surfaced far downstream at lacre-resolve time with no
5177        // field naming which `:deps` entry carried the typo. The new
5178        // gate moves the check to caixa-build time at the source
5179        // caixa.lisp.
5180        let d = dep_with_fonte(DepSource::Git {
5181            repo: String::new(),
5182            tag: Some("v0.1.0".into()),
5183            rev: None,
5184            branch: None,
5185        });
5186        let err = d.validate().unwrap_err();
5187        assert!(
5188            matches!(err, DepError::FonteRepoEmpty { ref nome } if nome == "caixa-teia"),
5189            "got {err:?}"
5190        );
5191    }
5192
5193    // -- :repo value-shape gate -------------------------------------------
5194    //
5195    // The `:fonte (:tipo git :repo …)` value flows verbatim into the
5196    // caixa-resolver's `git clone <repo>` subprocess. The pre-gate
5197    // codebase admitted any non-empty string; the new
5198    // [`crate::render::is_git_repo_url`] predicate gates the git-porcelain
5199    // URL intersection-floor at validate time, peer with the three pin
5200    // axes (`:tag` + `:branch` via `is_git_ref_name`, `:rev` via
5201    // `is_git_oid`). Every test in this section is a fail-before /
5202    // pass-after pin on a specific authoring footgun.
5203
5204    #[test]
5205    fn validate_rejects_git_fonte_with_repo_carrying_trailing_space() {
5206        // The canonical paste-from-doc footgun on `:repo` — an author
5207        // copies `"github:pleme-io/caixa-teia "` (trailing space) out of
5208        // a doc paragraph. Until this gate landed the empty-repo arm
5209        // passed (the string isn't empty), the resolver issued
5210        // `git clone 'github:pleme-io/caixa-teia '`, and the failure
5211        // surfaced at clone time with a quoting-confused error far from
5212        // the source caixa.lisp. Same paste-from-doc footgun the
5213        // `:tag "v0.1.0 "` gate (e70d213) closes on the peer refname
5214        // axis — now closed on the `:repo` URL axis too.
5215        let d = dep_with_fonte(DepSource::Git {
5216            repo: "github:pleme-io/caixa-teia ".into(),
5217            tag: Some("v0.1.0".into()),
5218            rev: None,
5219            branch: None,
5220        });
5221        let err = d.validate().unwrap_err();
5222        let DepError::FonteRepoShape { nome, repo, reason } = err else {
5223            panic!("expected FonteRepoShape, got other variant");
5224        };
5225        assert_eq!(nome, "caixa-teia");
5226        assert_eq!(repo, "github:pleme-io/caixa-teia ");
5227        assert!(
5228            reason.contains("whitespace"),
5229            "reason must surface the whitespace arm, got {reason:?}"
5230        );
5231    }
5232
5233    #[test]
5234    fn validate_rejects_git_fonte_with_repo_starting_with_dash() {
5235        // The canonical CLI-argument-injection footgun at the `git clone`
5236        // subprocess boundary — `:repo "-upload-pack=evil"` makes git's
5237        // argv parser read the value as a CLI flag, escaping the
5238        // subprocess argument boundary. The `--` separator workaround
5239        // does not fix the typed slot's accepted set; the gate rejects
5240        // the shape upstream at validate time so the resolver never
5241        // invokes a `git clone -…` subprocess.
5242        let d = dep_with_fonte(DepSource::Git {
5243            repo: "-upload-pack=evil".into(),
5244            tag: Some("v0.1.0".into()),
5245            rev: None,
5246            branch: None,
5247        });
5248        let err = d.validate().unwrap_err();
5249        let DepError::FonteRepoShape { repo, reason, .. } = err else {
5250            panic!("expected FonteRepoShape, got other variant");
5251        };
5252        assert_eq!(repo, "-upload-pack=evil");
5253        assert!(
5254            reason.contains("must not start with `-`"),
5255            "reason must surface the leading-`-` arm, got {reason:?}"
5256        );
5257    }
5258
5259    #[test]
5260    fn validate_rejects_git_fonte_with_repo_carrying_embedded_newline() {
5261        // The canonical paste-from-multiline-doc footgun — a `:repo`
5262        // string with an embedded `\n` silently breaks git's URL parser
5263        // and is a class of CRLF-injection at the subprocess-argument
5264        // boundary. Caught by the control-char arm (0x0A < 0x20).
5265        let d = dep_with_fonte(DepSource::Git {
5266            repo: "github:pleme-io/caixa-teia\nrm -rf /".into(),
5267            tag: Some("v0.1.0".into()),
5268            rev: None,
5269            branch: None,
5270        });
5271        let err = d.validate().unwrap_err();
5272        let DepError::FonteRepoShape { reason, .. } = err else {
5273            panic!("expected FonteRepoShape, got other variant");
5274        };
5275        assert!(
5276            reason.contains("control character"),
5277            "reason must surface the control-char arm, got {reason:?}"
5278        );
5279    }
5280
5281    #[test]
5282    fn validate_rejects_git_fonte_with_repo_carrying_tab() {
5283        // Tab is the sibling whitespace footgun (the canonical
5284        // copy-from-aligned-table paste); pinned separately from the
5285        // space arm so a future relaxation that only catches one
5286        // surfaces here.
5287        let d = dep_with_fonte(DepSource::Git {
5288            repo: "github:pleme-io/caixa-teia\t".into(),
5289            tag: Some("v0.1.0".into()),
5290            rev: None,
5291            branch: None,
5292        });
5293        let err = d.validate().unwrap_err();
5294        assert!(
5295            matches!(
5296                err,
5297                DepError::FonteRepoShape { ref reason, .. }
5298                    if reason.contains("whitespace")
5299            ),
5300            "got {err:?}"
5301        );
5302    }
5303
5304    #[test]
5305    fn validate_rejects_git_fonte_with_repo_carrying_non_ascii() {
5306        // IDN hosts must be pre-encoded as Punycode (`xn--…`) — raw
5307        // non-ASCII silently breaks at git's URL parser and round-trips
5308        // inconsistently across NFC/NFD normalization on APFS /
5309        // case-folding filesystems. Same intersection-floor
5310        // [`is_git_ref_name`] enforces on the refname axes.
5311        let d = dep_with_fonte(DepSource::Git {
5312            repo: "https://github.com/pleme-io/café".into(),
5313            tag: Some("v0.1.0".into()),
5314            rev: None,
5315            branch: None,
5316        });
5317        let err = d.validate().unwrap_err();
5318        assert!(
5319            matches!(
5320                err,
5321                DepError::FonteRepoShape { ref reason, .. }
5322                    if reason.contains("non-ASCII")
5323            ),
5324            "got {err:?}"
5325        );
5326    }
5327
5328    #[test]
5329    fn validate_rejects_git_fonte_with_repo_carrying_fragment_anchor() {
5330        // The fail-before-pass-after pin for the canonical paste-from-
5331        // browser-address-bar footgun on `:repo`: an author copies a
5332        // GitHub permalink to a README anchor / line-permalink and
5333        // forgets to trim the `#fragment` tail. Until this arm landed
5334        // `:repo "https://github.com/pleme-io/caixa-teia#readme"`
5335        // silently passed every prior arm (no whitespace, no control
5336        // chars, no non-ASCII, contains a `:`, doesn't start with `-`
5337        // or `:`), libcurl's URL parser stripped the `#readme` tail
5338        // before opening the HTTPS transport, and the lacre embedded
5339        // the value verbatim in its per-dep BLAKE3 closure — two
5340        // authors whose values differ only in their fragment anchor
5341        // (`#readme` vs `#L42`) resolve to the byte-identical upstream
5342        // `git clone` but lock to two distinct lacres, defeating the
5343        // THEORY.md §V.2 render-determinism contract. Same value-shape
5344        // axis-floor every peer typed surface enforces; peer `:fonte
5345        // :tag` / `:fonte :branch` already reject the byte-class through
5346        // `is_git_ref_name`'s alphabet (refs are leaf identifiers, no
5347        // URL grammar admitted) and `:entrada :paths` rejects `#` as
5348        // part of `is_gateway_api_http_path`'s RFC-3986-reserved set.
5349        let d = dep_with_fonte(DepSource::Git {
5350            repo: "https://github.com/pleme-io/caixa-teia#readme".into(),
5351            tag: Some("v0.1.0".into()),
5352            rev: None,
5353            branch: None,
5354        });
5355        let err = d.validate().unwrap_err();
5356        let DepError::FonteRepoShape { nome, repo, reason } = err else {
5357            panic!("expected FonteRepoShape, got other variant");
5358        };
5359        assert_eq!(nome, "caixa-teia");
5360        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia#readme");
5361        assert!(
5362            reason.contains("must not contain `#`"),
5363            "reason must surface the fragment-`#` arm, got {reason:?}"
5364        );
5365        assert!(
5366            reason.contains("fragment"),
5367            "reason must name the URL fragment grammar, got {reason:?}"
5368        );
5369    }
5370
5371    #[test]
5372    fn validate_rejects_git_fonte_with_repo_carrying_flake_ref_fragment() {
5373        // The symmetric paste-from-Nix-flake-ref footgun — an author
5374        // confuses the Nix flake-reference idiom (`github:foo/
5375        // bar#packageName`, where `#packageName` selects a flake
5376        // output) with the bare git `:repo` shape. The pleme-io
5377        // substrate authors compose flakes downstream of caixa
5378        // (caixa-flake renders a flake.nix), so the cross-idiom leak
5379        // is the canonical near-miss: the author writes the
5380        // flake-ref shape into a git `:repo` slot. Pinned separately
5381        // from the HTTPS-anchor arm so a future relaxation that
5382        // narrows to one URL scheme surfaces here.
5383        let d = dep_with_fonte(DepSource::Git {
5384            repo: "github:pleme-io/caixa-teia#caixa-teia".into(),
5385            tag: Some("v0.1.0".into()),
5386            rev: None,
5387            branch: None,
5388        });
5389        let err = d.validate().unwrap_err();
5390        let DepError::FonteRepoShape { reason, .. } = err else {
5391            panic!("expected FonteRepoShape, got other variant");
5392        };
5393        assert!(
5394            reason.contains("must not contain `#`"),
5395            "reason must surface the fragment-`#` arm, got {reason:?}"
5396        );
5397        assert!(
5398            reason.contains("Nix flake"),
5399            "reason must name the Nix-flake-ref cross-idiom footgun, got {reason:?}"
5400        );
5401    }
5402
5403    #[test]
5404    fn validate_rejects_git_fonte_with_repo_carrying_query_string() {
5405        // The fail-before-pass-after pin for the canonical paste-from-
5406        // browser-address-bar footgun on `:repo` (peer with the
5407        // a68f818 fragment-`#` arm on the same axis). An author
5408        // copies a GitHub tab deep-link out of the address bar and
5409        // forgets to trim the `?tab=…` query tail. Until this arm
5410        // landed `:repo "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file"`
5411        // silently passed every prior arm (no whitespace, no control
5412        // chars, no non-ASCII, no `#` fragment, contains a `:`,
5413        // doesn't start with `-` or `:`); GitHub silently ignored
5414        // the `?query` tail and served the same repo regardless;
5415        // the lacre embedded the value verbatim in its per-dep
5416        // BLAKE3 closure — two authors whose values differ only in
5417        // their query tail (`?tab=readme-ov-file` vs `?ref=main` vs
5418        // `?utm_source=twitter`) resolve to the byte-identical
5419        // upstream `git clone` but lock to two distinct lacres,
5420        // defeating the THEORY.md §V.2 render-determinism contract
5421        // on the same axis the `#` fragment arm closes. Same value-
5422        // shape axis-floor every peer typed surface enforces; peer
5423        // `:fonte :tag` / `:fonte :branch` already reject the byte-
5424        // class through `is_git_ref_name`'s alphabet (refspec glob
5425        // wildcards, caixa-core/src/render.rs:1426) and `:entrada
5426        // :paths` rejects `?` as the query separator in
5427        // `is_gateway_api_http_path` (caixa-core/src/render.rs:473).
5428        let d = dep_with_fonte(DepSource::Git {
5429            repo: "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file".into(),
5430            tag: Some("v0.1.0".into()),
5431            rev: None,
5432            branch: None,
5433        });
5434        let err = d.validate().unwrap_err();
5435        let DepError::FonteRepoShape { nome, repo, reason } = err else {
5436            panic!("expected FonteRepoShape, got other variant");
5437        };
5438        assert_eq!(nome, "caixa-teia");
5439        assert_eq!(
5440            repo,
5441            "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file"
5442        );
5443        assert!(
5444            reason.contains("must not contain `?`"),
5445            "reason must surface the query-`?` arm, got {reason:?}"
5446        );
5447        assert!(
5448            reason.contains("query"),
5449            "reason must name the URL query grammar, got {reason:?}"
5450        );
5451    }
5452
5453    #[test]
5454    fn validate_rejects_git_fonte_with_repo_carrying_utm_tracker() {
5455        // The symmetric paste-from-social-share footgun — an author
5456        // copies a repo URL out of a Slack unfurl / Twitter share /
5457        // newsletter link / Discord embed and forgets to trim the
5458        // `?utm_source=…` / `?utm_medium=…` / `?utm_campaign=…`
5459        // campaign-tracker tail. Every major social-share / unfurl /
5460        // newsletter platform appends these UTM parameters; the
5461        // canonical near-miss on the `:repo` axis. Pinned separately
5462        // from the GitHub-tab-deep-link arm so a future relaxation
5463        // that narrows to one query-parameter class surfaces here.
5464        let d = dep_with_fonte(DepSource::Git {
5465            repo: "https://github.com/pleme-io/caixa-teia?utm_source=twitter&utm_campaign=launch"
5466                .into(),
5467            tag: Some("v0.1.0".into()),
5468            rev: None,
5469            branch: None,
5470        });
5471        let err = d.validate().unwrap_err();
5472        let DepError::FonteRepoShape { reason, .. } = err else {
5473            panic!("expected FonteRepoShape, got other variant");
5474        };
5475        assert!(
5476            reason.contains("must not contain `?`"),
5477            "reason must surface the query-`?` arm, got {reason:?}"
5478        );
5479        assert!(
5480            reason.contains("campaign-tracker"),
5481            "reason must name the campaign-tracker paste footgun, got {reason:?}"
5482        );
5483    }
5484
5485    #[test]
5486    fn fonte_repo_fragment_fires_before_query_when_fragment_first() {
5487        // Cascade pin: the fragment-`#` arm and the query-`?` arm are
5488        // both per-byte arms inside the same `for &b in s.as_bytes()`
5489        // loop, so the byte that appears first in the value's byte
5490        // order wins. A `:repo "https://github.com/p/x#readme?ref=main"`
5491        // (fragment before query — unusual URL-grammar but value-
5492        // disjoint at byte level) carries both `#` and `?`; the `#`
5493        // byte appears first, so the fragment-`#` arm fires, surfacing
5494        // the more self-locating diagnostic on the byte the author
5495        // pasted earliest in the URL. Mirrors the peer cascade
5496        // discipline `fonte_repo_control_char_fires_before_fragment`
5497        // pins on the prior `:repo` byte-class arm.
5498        let d = dep_with_fonte(DepSource::Git {
5499            repo: "https://github.com/pleme-io/caixa-teia#readme?ref=main".into(),
5500            tag: Some("v0.1.0".into()),
5501            rev: None,
5502            branch: None,
5503        });
5504        let err = d.validate().unwrap_err();
5505        let DepError::FonteRepoShape { reason, .. } = err else {
5506            panic!("expected FonteRepoShape, got other variant");
5507        };
5508        assert!(
5509            reason.contains("must not contain `#`"),
5510            "reason must surface the fragment-`#` arm (fires before query-`?` when \
5511             `#` byte appears first in value), got {reason:?}"
5512        );
5513    }
5514
5515    #[test]
5516    fn fonte_repo_control_char_fires_before_fragment() {
5517        // Cascade pin: the control-char arm structurally precedes the
5518        // fragment-`#` arm. A value like `"github:p/x\n#readme"` probes
5519        // positive on both arms (contains LF and `#`), but the narrower
5520        // POSIX-syscall-rejected / CRLF-injection-class diagnostic
5521        // (`control character`) wins so the author sees the more
5522        // self-locating arm first. Mirrors the peer cascade discipline
5523        // every prior `:repo` byte-class arm establishes.
5524        let d = dep_with_fonte(DepSource::Git {
5525            repo: "github:pleme-io/caixa-teia\n#readme".into(),
5526            tag: Some("v0.1.0".into()),
5527            rev: None,
5528            branch: None,
5529        });
5530        let err = d.validate().unwrap_err();
5531        let DepError::FonteRepoShape { reason, .. } = err else {
5532            panic!("expected FonteRepoShape, got other variant");
5533        };
5534        assert!(
5535            reason.contains("control character"),
5536            "reason must surface the control-char arm, got {reason:?}"
5537        );
5538    }
5539
5540    #[test]
5541    fn validate_rejects_git_fonte_with_repo_carrying_embedded_backslash() {
5542        // The fail-before-pass-after pin for the canonical Windows-
5543        // file-path-confusion footgun on `:repo` (peer with the 3a4e1d7
5544        // backslash arm on the sibling `:caminho` path-fonte axis).
5545        // An author pastes a Windows Explorer address-bar / PowerShell
5546        // `Get-Location` output into a `file://` URL slot, producing
5547        // `file:///C:\Users\me\caixa-teia`. Until this arm landed the
5548        // value silently passed every prior arm (no whitespace, no
5549        // control chars, no non-ASCII, no `#`, no `?`, doesn't start
5550        // with `-` or `:`); libcurl's URL parser silently translates
5551        // `\` → `/` on some platforms and refuses it on others, so
5552        // the byte rides verbatim into the lacre's per-dep content-
5553        // address but is silently rewritten / rejected at the wire —
5554        // two authors whose `:repo` values differ only in backslash-
5555        // vs-forward-slash (`file:///C:\path` vs `file:///C:/path`)
5556        // resolve to the byte-identical local clone but lock to two
5557        // distinct BLAKE3 closures, defeating the THEORY.md §V.2
5558        // render-determinism contract on the same axis the `#`
5559        // fragment and `?` query arms close. Same value-shape axis-
5560        // floor every peer typed surface enforces; the `:caminho`
5561        // 3a4e1d7 arm closes the same byte on the path-fonte axis.
5562        let d = dep_with_fonte(DepSource::Git {
5563            repo: "file:///C:\\Users\\me\\caixa-teia".into(),
5564            tag: Some("v0.1.0".into()),
5565            rev: None,
5566            branch: None,
5567        });
5568        let err = d.validate().unwrap_err();
5569        let DepError::FonteRepoShape { nome, repo, reason } = err else {
5570            panic!("expected FonteRepoShape, got other variant");
5571        };
5572        assert_eq!(nome, "caixa-teia");
5573        assert_eq!(repo, "file:///C:\\Users\\me\\caixa-teia");
5574        assert!(
5575            reason.contains("must not contain `\\`"),
5576            "reason must surface the backslash-`\\` arm, got {reason:?}"
5577        );
5578        assert!(
5579            reason.contains("Windows"),
5580            "reason must name the Windows-path-confusion footgun, got {reason:?}"
5581        );
5582    }
5583
5584    #[test]
5585    fn validate_rejects_git_fonte_with_repo_carrying_mangled_https_backslashes() {
5586        // The symmetric Win32-shell-mangled-slashes footgun — an author
5587        // copies `https://github.com/foo/bar` into a Win32 shell that
5588        // rewrites every `/` to `\` (the canonical `cmd.exe` path-
5589        // separator-coercion bug), pastes the result into a `:repo`
5590        // slot, and produces `https:\\github.com\foo\bar`. Pinned
5591        // separately from the `file://` Explorer-paste arm so a future
5592        // relaxation that narrows to one URL scheme surfaces here.
5593        let d = dep_with_fonte(DepSource::Git {
5594            repo: "https:\\\\github.com\\pleme-io\\caixa-teia".into(),
5595            tag: Some("v0.1.0".into()),
5596            rev: None,
5597            branch: None,
5598        });
5599        let err = d.validate().unwrap_err();
5600        let DepError::FonteRepoShape { reason, .. } = err else {
5601            panic!("expected FonteRepoShape, got other variant");
5602        };
5603        assert!(
5604            reason.contains("must not contain `\\`"),
5605            "reason must surface the backslash-`\\` arm, got {reason:?}"
5606        );
5607        assert!(
5608            reason.contains("path separator") || reason.contains("path-segment separator"),
5609            "reason must name the URL path-segment separator grammar, got {reason:?}"
5610        );
5611    }
5612
5613    #[test]
5614    fn fonte_repo_fragment_fires_before_backslash_when_fragment_first() {
5615        // Cascade pin: the fragment-`#` arm and the backslash-`\` arm
5616        // are both per-byte arms inside the same `for &b in s.as_bytes()`
5617        // loop, so the byte that appears first in the value's byte order
5618        // wins. A `:repo "https://github.com/p/x#readme\\foo"` carries
5619        // both `#` and `\`; the `#` byte appears first, so the fragment-
5620        // `#` arm fires, surfacing the more self-locating diagnostic on
5621        // the byte the author pasted earliest in the URL. Mirrors the
5622        // peer cascade discipline `fonte_repo_fragment_fires_before_query_when_fragment_first`
5623        // pins on the prior `:repo` byte-class arm.
5624        let d = dep_with_fonte(DepSource::Git {
5625            repo: "https://github.com/pleme-io/caixa-teia#readme\\foo".into(),
5626            tag: Some("v0.1.0".into()),
5627            rev: None,
5628            branch: None,
5629        });
5630        let err = d.validate().unwrap_err();
5631        let DepError::FonteRepoShape { reason, .. } = err else {
5632            panic!("expected FonteRepoShape, got other variant");
5633        };
5634        assert!(
5635            reason.contains("must not contain `#`"),
5636            "reason must surface the fragment-`#` arm (fires before backslash-`\\` when \
5637             `#` byte appears first in value), got {reason:?}"
5638        );
5639    }
5640
5641    #[test]
5642    fn validate_rejects_git_fonte_with_repo_carrying_uri_template_placeholder() {
5643        // The fail-before-pass-after pin for the canonical URI Template
5644        // (RFC 6570) placeholder footgun on `:repo`. An author copies a
5645        // README quick-start snippet / OpenAPI `servers:` URL / Helm
5646        // chart `home:` template that carries unresolved
5647        // `{org}` / `{repo}` placeholders and pastes the raw template
5648        // into the `:repo` slot, expecting the substrate to resolve the
5649        // placeholder downstream. Until this arm landed the value
5650        // silently passed every prior arm (no whitespace, no control
5651        // chars, no non-ASCII, no `#`, no `?`, no `\`, doesn't start
5652        // with `-` or `:`); libcurl percent-encodes `{` / `}` to `%7B`
5653        // / `%7D` on the wire, so the byte rides verbatim into the
5654        // lacre's per-dep content-address but round-trips inconsistently
5655        // between the lacre's per-dep content-address and the
5656        // resolver's `git clone <repo>` invocation, defeating the
5657        // THEORY.md §V.2 render-determinism contract on the same axis
5658        // the `#` fragment, `?` query, and `\` backslash arms close;
5659        // every git porcelain entry-point additionally fetches a
5660        // nonexistent literal-`{placeholder}`-named path far from the
5661        // source caixa.lisp.
5662        let d = dep_with_fonte(DepSource::Git {
5663            repo: "https://github.com/{org}/caixa-teia".into(),
5664            tag: Some("v0.1.0".into()),
5665            rev: None,
5666            branch: None,
5667        });
5668        let err = d.validate().unwrap_err();
5669        let DepError::FonteRepoShape { nome, repo, reason } = err else {
5670            panic!("expected FonteRepoShape, got other variant");
5671        };
5672        assert_eq!(nome, "caixa-teia");
5673        assert_eq!(repo, "https://github.com/{org}/caixa-teia");
5674        assert!(
5675            reason.contains("must not contain `{`"),
5676            "reason must surface the open-brace `{{` arm, got {reason:?}"
5677        );
5678        assert!(
5679            reason.contains("URI Template") || reason.contains("RFC 6570"),
5680            "reason must name the RFC 6570 URI Template grammar, got {reason:?}"
5681        );
5682    }
5683
5684    #[test]
5685    fn validate_rejects_git_fonte_with_repo_carrying_handlebars_doubled_brace() {
5686        // The symmetric Mustache / Handlebars doubled-brace
5687        // substitution-form footgun every CI / IaC templating engine
5688        // (Argo Workflows, Jinja2, Liquid, Vue / Angular interpolation,
5689        // GitHub Actions `${{ … }}` even though Actions uses `${{`) /
5690        // chart README quick-start snippet emits. Pinned separately
5691        // from the single-`{` `{org}` arm so a future relaxation that
5692        // narrows to one substitution-form surfaces here.
5693        let d = dep_with_fonte(DepSource::Git {
5694            repo: "https://github.com/{{org}}/caixa-teia".into(),
5695            tag: Some("v0.1.0".into()),
5696            rev: None,
5697            branch: None,
5698        });
5699        let err = d.validate().unwrap_err();
5700        let DepError::FonteRepoShape { reason, .. } = err else {
5701            panic!("expected FonteRepoShape, got other variant");
5702        };
5703        assert!(
5704            reason.contains("must not contain `{`"),
5705            "reason must surface the open-brace `{{` arm, got {reason:?}"
5706        );
5707    }
5708
5709    #[test]
5710    fn validate_rejects_git_fonte_with_repo_carrying_closing_brace_only() {
5711        // Asymmetric `}`-only shape — covers the closing-brace-by-
5712        // itself footgun (an author truncated `{org}/{repo}` mid-edit
5713        // and left a trailing `}` from the prior template fragment,
5714        // or pasted a value that included a closing brace from a
5715        // surrounding shell context). Pinned to ensure the predicate
5716        // refuses each brace independently rather than only when both
5717        // appear — a future regression that ANDs the two byte tests
5718        // surfaces here.
5719        let d = dep_with_fonte(DepSource::Git {
5720            repo: "https://github.com/pleme-io/caixa-teia}".into(),
5721            tag: Some("v0.1.0".into()),
5722            rev: None,
5723            branch: None,
5724        });
5725        let err = d.validate().unwrap_err();
5726        let DepError::FonteRepoShape { reason, .. } = err else {
5727            panic!("expected FonteRepoShape, got other variant");
5728        };
5729        assert!(
5730            reason.contains("must not contain `}`"),
5731            "reason must surface the close-brace `}}` arm, got {reason:?}"
5732        );
5733    }
5734
5735    #[test]
5736    fn fonte_repo_fragment_fires_before_template_placeholder_when_fragment_first() {
5737        // Cascade pin: the fragment-`#` arm and the template-`{` /
5738        // `}` arm are both per-byte arms inside the same
5739        // `for &b in s.as_bytes()` loop, so the byte that appears
5740        // first in the value's byte order wins. A `:repo
5741        // "https://github.com/p/x#readme{org}"` carries both `#` and
5742        // `{`; the `#` byte appears first, so the fragment-`#` arm
5743        // fires, surfacing the more self-locating diagnostic on the
5744        // byte the author pasted earliest in the URL. Mirrors the
5745        // peer cascade discipline `fonte_repo_fragment_fires_before_backslash_when_fragment_first`
5746        // pins on the prior `:repo` byte-class arm.
5747        let d = dep_with_fonte(DepSource::Git {
5748            repo: "https://github.com/pleme-io/caixa-teia#readme{org}".into(),
5749            tag: Some("v0.1.0".into()),
5750            rev: None,
5751            branch: None,
5752        });
5753        let err = d.validate().unwrap_err();
5754        let DepError::FonteRepoShape { reason, .. } = err else {
5755            panic!("expected FonteRepoShape, got other variant");
5756        };
5757        assert!(
5758            reason.contains("must not contain `#`"),
5759            "reason must surface the fragment-`#` arm (fires before template-`{{` when \
5760             `#` byte appears first in value), got {reason:?}"
5761        );
5762    }
5763
5764    #[test]
5765    fn validate_rejects_git_fonte_with_repo_carrying_output_redirection() {
5766        // The fail-before-pass-after pin for the canonical
5767        // shell-output-redirection footgun on `:repo`: an author
5768        // pastes a shell-pipeline tail (`git clone <repo> > build.log`
5769        // / `… >output.txt`) into the `:repo` slot without trimming
5770        // the redirect. Until this arm landed the value silently
5771        // passed every prior arm (no whitespace, no control chars,
5772        // no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, doesn't
5773        // start with `-` or `:`); RFC 3986 §2 lists `<` / `>` in the
5774        // 'delims' / 'unwise' set and the WHATWG URL spec's fragment
5775        // percent-encode set maps `>` → `%3E` on the wire, so the
5776        // byte rides verbatim into the lacre's per-dep BLAKE3 closure
5777        // but is silently rewritten or rejected at libcurl's URL-
5778        // parser layer — two authors whose values differ only in
5779        // their redirect tail (`>build.log` vs nothing) resolve to
5780        // the byte-identical upstream `git clone` but lock to two
5781        // distinct lacres, defeating the THEORY.md §V.2 render-
5782        // determinism contract. Peer with the `:caminho` axis's
5783        // `FonteCaminhoShellRedirection` arm (e457141) on the sibling
5784        // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
5785        // byte RFC-3986-reserved set on `:entrada :paths`.
5786        let d = dep_with_fonte(DepSource::Git {
5787            repo: "https://github.com/pleme-io/caixa-teia>build.log".into(),
5788            tag: Some("v0.1.0".into()),
5789            rev: None,
5790            branch: None,
5791        });
5792        let err = d.validate().unwrap_err();
5793        let DepError::FonteRepoShape { nome, repo, reason } = err else {
5794            panic!("expected FonteRepoShape, got other variant");
5795        };
5796        assert_eq!(nome, "caixa-teia");
5797        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia>build.log");
5798        assert!(
5799            reason.contains("must not contain `>`"),
5800            "reason must surface the output-redirection `>` arm, got {reason:?}"
5801        );
5802        assert!(
5803            reason.contains("redirection") || reason.contains("'delims'"),
5804            "reason must name the shell-redirection / RFC-3986-unwise rationale, got {reason:?}"
5805        );
5806    }
5807
5808    #[test]
5809    fn validate_rejects_git_fonte_with_repo_carrying_input_redirection() {
5810        // The symmetric shell-input-redirection footgun — an author
5811        // pastes a shell-pipeline head (`git clone <input.url` /
5812        // `cat <README.md`) into the `:repo` slot. Pinned separately
5813        // from the `>`-output arm so a future relaxation that only
5814        // catches one of the two redirect bytes surfaces here. Peer
5815        // with the `:caminho` axis's `FonteCaminhoShellRedirection`
5816        // arm which closes both `<` and `>` under the same banner.
5817        let d = dep_with_fonte(DepSource::Git {
5818            repo: "https://github.com/pleme-io/caixa-teia<input.url".into(),
5819            tag: Some("v0.1.0".into()),
5820            rev: None,
5821            branch: None,
5822        });
5823        let err = d.validate().unwrap_err();
5824        let DepError::FonteRepoShape { reason, .. } = err else {
5825            panic!("expected FonteRepoShape, got other variant");
5826        };
5827        assert!(
5828            reason.contains("must not contain `<`"),
5829            "reason must surface the input-redirection `<` arm, got {reason:?}"
5830        );
5831        assert!(
5832            reason.contains("RFC 3986") || reason.contains("'unwise'"),
5833            "reason must name the RFC 3986 'unwise' grammar, got {reason:?}"
5834        );
5835    }
5836
5837    #[test]
5838    fn validate_rejects_git_fonte_with_repo_carrying_backtick_command_substitution() {
5839        // The fail-before-pass-after pin for the canonical
5840        // paste-from-shell-prompt-with-backticked-substitution footgun
5841        // on `:repo` (peer with the c4d62b3 backtick arm on the sibling
5842        // `:caminho` path-fonte axis). An author pastes a URL whose
5843        // segment carries a backticked command-substitution wrapper
5844        // (`` `whoami` ``, `` `git config user.name` ``, `` `pwd` ``)
5845        // from a doc / README quick-start snippet that expected the
5846        // substrate to substitute the value downstream. Until this arm
5847        // landed the value silently passed every prior arm (no
5848        // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
5849        // no `\`, no `{`/`}`, no `<`/`>`, doesn't start with `-` or
5850        // `:`); RFC 3986 §2 lists the backtick byte in the 'delims' /
5851        // 'unwise' set and the WHATWG URL spec's fragment percent-
5852        // encode set maps `` ` `` → `%60` on the wire, so the byte
5853        // rides verbatim into the lacre's per-dep BLAKE3 closure but
5854        // is silently rewritten or rejected at libcurl's URL-parser
5855        // layer — two authors whose values differ only in their
5856        // backtick wrapper (`` `whoami` `` vs nothing) resolve to the
5857        // byte-identical upstream `git clone` but lock to two distinct
5858        // lacres, defeating the THEORY.md §V.2 render-determinism
5859        // contract. Peer with the `:caminho` axis's
5860        // `FonteCaminhoShellCommandSubstitution` arm (c4d62b3) on the
5861        // sibling path-fonte axis, and `is_gateway_api_http_path`'s
5862        // eleven-byte RFC-3986-reserved set on `:entrada :paths`.
5863        let d = dep_with_fonte(DepSource::Git {
5864            repo: "https://github.com/pleme-io/`whoami`/caixa-teia".into(),
5865            tag: Some("v0.1.0".into()),
5866            rev: None,
5867            branch: None,
5868        });
5869        let err = d.validate().unwrap_err();
5870        let DepError::FonteRepoShape { nome, repo, reason } = err else {
5871            panic!("expected FonteRepoShape, got other variant");
5872        };
5873        assert_eq!(nome, "caixa-teia");
5874        assert_eq!(repo, "https://github.com/pleme-io/`whoami`/caixa-teia");
5875        assert!(
5876            reason.contains("must not contain `` ` ``"),
5877            "reason must surface the backtick command-substitution arm, got {reason:?}"
5878        );
5879        assert!(
5880            reason.contains("command-substitution") || reason.contains("'unwise'"),
5881            "reason must name the shell-command-substitution / RFC-3986-unwise rationale, \
5882             got {reason:?}"
5883        );
5884    }
5885
5886    #[test]
5887    fn fonte_repo_fragment_fires_before_backtick_when_fragment_first() {
5888        // Cascade pin: the fragment-`#` arm and the backtick command-
5889        // substitution arm are both per-byte arms inside the same
5890        // `for &b in s.as_bytes()` loop, so the byte that appears first
5891        // in the value's byte order wins. A `:repo
5892        // "https://github.com/p/x#readme/`whoami`"` carries both `#`
5893        // and backtick; the `#` byte appears first, so the fragment-
5894        // `#` arm fires, surfacing the more self-locating diagnostic
5895        // on the byte the author pasted earliest in the URL. Mirrors
5896        // the peer cascade discipline
5897        // `fonte_repo_fragment_fires_before_shell_redirection_when_fragment_first`
5898        // pins on the prior `:repo` byte-class arm.
5899        let d = dep_with_fonte(DepSource::Git {
5900            repo: "https://github.com/pleme-io/caixa-teia#readme/`whoami`".into(),
5901            tag: Some("v0.1.0".into()),
5902            rev: None,
5903            branch: None,
5904        });
5905        let err = d.validate().unwrap_err();
5906        let DepError::FonteRepoShape { reason, .. } = err else {
5907            panic!("expected FonteRepoShape, got other variant");
5908        };
5909        assert!(
5910            reason.contains("must not contain `#`"),
5911            "reason must surface the fragment-`#` arm (fires before backtick when `#` byte \
5912             appears first in value), got {reason:?}"
5913        );
5914    }
5915
5916    #[test]
5917    fn fonte_repo_shell_redirection_fires_before_backtick_when_redirection_first() {
5918        // Cascade pin: the shell-redirection `<` / `>` arm and the
5919        // backtick command-substitution arm are both per-byte arms
5920        // inside the same `for &b in s.as_bytes()` loop, so the byte
5921        // that appears first in the value's byte order wins. A `:repo
5922        // "https://github.com/p/x>build.log/`whoami`"` carries both
5923        // `>` and backtick; the `>` byte appears first, so the
5924        // shell-redirection arm fires, surfacing the more self-
5925        // locating diagnostic on the byte the author pasted earliest
5926        // in the URL. Pins the natural-order cascade so a future
5927        // reorder of the per-byte arms surfaces here.
5928        let d = dep_with_fonte(DepSource::Git {
5929            repo: "https://github.com/pleme-io/caixa-teia>build.log/`whoami`".into(),
5930            tag: Some("v0.1.0".into()),
5931            rev: None,
5932            branch: None,
5933        });
5934        let err = d.validate().unwrap_err();
5935        let DepError::FonteRepoShape { reason, .. } = err else {
5936            panic!("expected FonteRepoShape, got other variant");
5937        };
5938        assert!(
5939            reason.contains("must not contain `>`"),
5940            "reason must surface the shell-redirection `>` arm (fires before backtick when \
5941             `>` byte appears first in value), got {reason:?}"
5942        );
5943    }
5944
5945    #[test]
5946    fn fonte_repo_fragment_fires_before_shell_redirection_when_fragment_first() {
5947        // Cascade pin: the fragment-`#` arm and the shell-redirection
5948        // `<` / `>` arm are both per-byte arms inside the same
5949        // `for &b in s.as_bytes()` loop, so the byte that appears
5950        // first in the value's byte order wins. A `:repo
5951        // "https://github.com/p/x#readme>build.log"` carries both
5952        // `#` and `>`; the `#` byte appears first, so the fragment-
5953        // `#` arm fires, surfacing the more self-locating diagnostic
5954        // on the byte the author pasted earliest in the URL. Mirrors
5955        // the peer cascade discipline
5956        // `fonte_repo_fragment_fires_before_template_placeholder_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>build.log".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 shell-redirection `>` when \
5971             `#` byte appears first in value), got {reason:?}"
5972        );
5973    }
5974
5975    #[test]
5976    fn validate_rejects_git_fonte_with_repo_carrying_shell_pipe() {
5977        // The fail-before-pass-after pin for the canonical
5978        // paste-from-shell-prompt-with-piped-pipeline footgun on
5979        // `:repo` (peer with the 124106f pipe arm on the sibling
5980        // `:caminho` path-fonte axis). An author pastes a shell
5981        // pipeline (`git clone <url> | tee build.log`,
5982        // `git ls-remote <url> | head`) into the `:repo` slot,
5983        // forgetting to trim the `| <consumer>` tail. Until this arm
5984        // landed the value silently passed every prior arm (no
5985        // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
5986        // no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, doesn't start
5987        // with `-` or `:`); RFC 3986 §2 lists the pipe byte in the
5988        // 'unwise' set and the WHATWG URL spec's fragment percent-
5989        // encode set maps `|` → `%7C` on the wire, so the byte rides
5990        // verbatim into the lacre's per-dep BLAKE3 closure but is
5991        // silently rewritten or rejected at libcurl's URL-parser
5992        // layer — two authors whose values differ only in their pipe
5993        // tail (`|tee build.log` vs nothing) resolve to the byte-
5994        // identical upstream `git clone` but lock to two distinct
5995        // lacres, defeating the THEORY.md §V.2 render-determinism
5996        // contract. Peer with the `:caminho` axis's
5997        // `FonteCaminhoShellPipe` arm (124106f) on the sibling path-
5998        // fonte axis, and `is_gateway_api_http_path`'s eleven-byte
5999        // RFC-3986-reserved set on `:entrada :paths`.
6000        let d = dep_with_fonte(DepSource::Git {
6001            repo: "https://github.com/pleme-io/caixa-teia|tee build.log".into(),
6002            tag: Some("v0.1.0".into()),
6003            rev: None,
6004            branch: None,
6005        });
6006        let err = d.validate().unwrap_err();
6007        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6008            panic!("expected FonteRepoShape, got other variant");
6009        };
6010        assert_eq!(nome, "caixa-teia");
6011        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia|tee build.log");
6012        assert!(
6013            reason.contains("must not contain `|`"),
6014            "reason must surface the shell-pipe arm, got {reason:?}"
6015        );
6016        assert!(
6017            reason.contains("pipe") || reason.contains("'unwise'"),
6018            "reason must name the shell-pipe / RFC-3986-unwise rationale, got {reason:?}"
6019        );
6020    }
6021
6022    #[test]
6023    fn fonte_repo_fragment_fires_before_pipe_when_fragment_first() {
6024        // Cascade pin: the fragment-`#` arm and the pipe arm are both
6025        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
6026        // so the byte that appears first in the value's byte order
6027        // wins. A `:repo "https://github.com/p/x#readme|tee"` carries
6028        // both `#` and `|`; the `#` byte appears first, so the
6029        // fragment-`#` arm fires, surfacing the more self-locating
6030        // diagnostic on the byte the author pasted earliest in the
6031        // URL. Mirrors the peer cascade discipline
6032        // `fonte_repo_fragment_fires_before_backtick_when_fragment_first`
6033        // pins on the prior `:repo` byte-class arm.
6034        let d = dep_with_fonte(DepSource::Git {
6035            repo: "https://github.com/pleme-io/caixa-teia#readme|tee".into(),
6036            tag: Some("v0.1.0".into()),
6037            rev: None,
6038            branch: None,
6039        });
6040        let err = d.validate().unwrap_err();
6041        let DepError::FonteRepoShape { reason, .. } = err else {
6042            panic!("expected FonteRepoShape, got other variant");
6043        };
6044        assert!(
6045            reason.contains("must not contain `#`"),
6046            "reason must surface the fragment-`#` arm (fires before pipe when `#` byte \
6047             appears first in value), got {reason:?}"
6048        );
6049    }
6050
6051    #[test]
6052    fn fonte_repo_backtick_fires_before_pipe_when_backtick_first() {
6053        // Cascade pin: the backtick arm and the pipe arm are both per-
6054        // byte arms inside the same `for &b in s.as_bytes()` loop, so
6055        // the byte that appears first in the value's byte order wins.
6056        // A `:repo "https://github.com/p/x/`whoami`|tee"` carries both
6057        // `` ` `` and `|`; the backtick byte appears first, so the
6058        // backtick arm fires, surfacing the more self-locating
6059        // diagnostic on the byte the author pasted earliest in the
6060        // URL. Pins the natural-order cascade so a future reorder of
6061        // the per-byte arms surfaces here.
6062        let d = dep_with_fonte(DepSource::Git {
6063            repo: "https://github.com/pleme-io/caixa-teia/`whoami`|tee".into(),
6064            tag: Some("v0.1.0".into()),
6065            rev: None,
6066            branch: None,
6067        });
6068        let err = d.validate().unwrap_err();
6069        let DepError::FonteRepoShape { reason, .. } = err else {
6070            panic!("expected FonteRepoShape, got other variant");
6071        };
6072        assert!(
6073            reason.contains("must not contain `` ` ``"),
6074            "reason must surface the backtick arm (fires before pipe when `` ` `` byte \
6075             appears first in value), got {reason:?}"
6076        );
6077    }
6078
6079    #[test]
6080    fn validate_rejects_git_fonte_with_repo_carrying_shell_command_separator() {
6081        // The fail-before-pass-after pin for the canonical
6082        // paste-from-shell-prompt-with-sequential-command-tail footgun
6083        // on `:repo` (peer with the 05c358e `;` arm on the sibling
6084        // `:caminho` path-fonte axis). An author pastes a shell
6085        // one-liner that chained a cleanup tail after the URL
6086        // (`git clone <url>; rm -rf build`, `git ls-remote <url>;
6087        // echo done`) into the `:repo` slot, forgetting to trim the
6088        // `; <cmd>` tail. Until this arm landed the value silently
6089        // passed every prior `is_git_repo_url` arm (no whitespace, no
6090        // control chars, no non-ASCII, no `#`, no `?`, no `\`, no
6091        // `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, doesn't start with
6092        // `-` or `:`); RFC 3986 §2 lists `;` in the 'sub-delims' /
6093        // reserved set and the WHATWG URL spec's fragment percent-
6094        // encode set maps `;` → `%3B` on the wire, so the byte rides
6095        // verbatim into the lacre's per-dep BLAKE3 closure but is
6096        // silently rewritten at libcurl's URL-parser layer — two
6097        // authors whose values differ only in their sequential-command
6098        // tail (`; rm -rf build` vs nothing) resolve to the byte-
6099        // identical upstream `git clone` but lock to two distinct
6100        // lacres, defeating the THEORY.md §V.2 render-determinism
6101        // contract. Peer with the `:caminho` axis's
6102        // `FonteCaminhoShellSemicolon` arm (05c358e) on the sibling
6103        // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
6104        // byte RFC-3986-reserved set on `:entrada :paths`.
6105        let d = dep_with_fonte(DepSource::Git {
6106            repo: "https://github.com/pleme-io/caixa-teia; rm -rf build".into(),
6107            tag: Some("v0.1.0".into()),
6108            rev: None,
6109            branch: None,
6110        });
6111        let err = d.validate().unwrap_err();
6112        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6113            panic!("expected FonteRepoShape, got other variant");
6114        };
6115        assert_eq!(nome, "caixa-teia");
6116        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia; rm -rf build");
6117        assert!(
6118            reason.contains("must not contain `;`"),
6119            "reason must surface the shell-command-separator arm, got {reason:?}"
6120        );
6121        assert!(
6122            reason.contains("sequential-command") || reason.contains("'sub-delims'"),
6123            "reason must name the shell-command-separator / RFC-3986-sub-delims \
6124             rationale, got {reason:?}"
6125        );
6126    }
6127
6128    #[test]
6129    fn fonte_repo_fragment_fires_before_semicolon_when_fragment_first() {
6130        // Cascade pin: the fragment-`#` arm and the semicolon arm are
6131        // both per-byte arms inside the same `for &b in s.as_bytes()`
6132        // loop, so the byte that appears first in the value's byte
6133        // order wins. A `:repo "https://github.com/p/x#readme; rm"`
6134        // carries both `#` and `;`; the `#` byte appears first, so the
6135        // fragment-`#` arm fires, surfacing the more self-locating
6136        // diagnostic on the byte the author pasted earliest in the URL.
6137        // Mirrors the peer cascade discipline
6138        // `fonte_repo_fragment_fires_before_pipe_when_fragment_first`
6139        // pins on the prior `:repo` byte-class arm.
6140        let d = dep_with_fonte(DepSource::Git {
6141            repo: "https://github.com/pleme-io/caixa-teia#readme; rm".into(),
6142            tag: Some("v0.1.0".into()),
6143            rev: None,
6144            branch: None,
6145        });
6146        let err = d.validate().unwrap_err();
6147        let DepError::FonteRepoShape { reason, .. } = err else {
6148            panic!("expected FonteRepoShape, got other variant");
6149        };
6150        assert!(
6151            reason.contains("must not contain `#`"),
6152            "reason must surface the fragment-`#` arm (fires before semicolon when `#` \
6153             byte appears first in value), got {reason:?}"
6154        );
6155    }
6156
6157    #[test]
6158    fn fonte_repo_pipe_fires_before_semicolon_when_pipe_first() {
6159        // Cascade pin: the pipe arm and the semicolon arm are both
6160        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
6161        // so the byte that appears first in the value's byte order
6162        // wins. A `:repo "https://github.com/p/x|tee; rm"` carries
6163        // both `|` and `;`; the `|` byte appears first, so the
6164        // pipe arm fires, surfacing the more self-locating diagnostic
6165        // on the byte the author pasted earliest in the URL. Pins the
6166        // natural-order cascade so a future reorder of the per-byte
6167        // arms surfaces here.
6168        let d = dep_with_fonte(DepSource::Git {
6169            repo: "https://github.com/pleme-io/caixa-teia|tee; rm".into(),
6170            tag: Some("v0.1.0".into()),
6171            rev: None,
6172            branch: None,
6173        });
6174        let err = d.validate().unwrap_err();
6175        let DepError::FonteRepoShape { reason, .. } = err else {
6176            panic!("expected FonteRepoShape, got other variant");
6177        };
6178        assert!(
6179            reason.contains("must not contain `|`"),
6180            "reason must surface the pipe arm (fires before semicolon when `|` byte \
6181             appears first in value), got {reason:?}"
6182        );
6183    }
6184
6185    #[test]
6186    fn validate_rejects_git_fonte_with_repo_carrying_shell_background() {
6187        // The fail-before-pass-after pin for the canonical
6188        // paste-from-shell-prompt-with-background-launch-tail footgun
6189        // on `:repo` (peer with the e12e4f3 `&` arm on the sibling
6190        // `:caminho` path-fonte axis). An author pastes a shell one-
6191        // liner that detached the clone into the background
6192        // (`git clone <url> & sleep 1`, `git clone <url> && cd …`)
6193        // into the `:repo` slot, forgetting to trim the `& <cmd>` /
6194        // `&& <cmd>` tail. Until this arm landed the value silently
6195        // passed every prior `is_git_repo_url` arm (no whitespace,
6196        // no control chars, no non-ASCII, no `#`, no `?`, no `\`,
6197        // no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no `;`,
6198        // doesn't start with `-` or `:`); RFC 3986 §2 lists `&` in
6199        // the 'sub-delims' / reserved set and the WHATWG URL spec's
6200        // fragment percent-encode set maps `&` → `%26` on the wire,
6201        // so the byte rides verbatim into the lacre's per-dep
6202        // BLAKE3 closure but is silently rewritten at libcurl's
6203        // URL-parser layer — two authors whose values differ only
6204        // in their background-launch tail (`& sleep 1` vs nothing)
6205        // resolve to the byte-identical upstream `git clone` but
6206        // lock to two distinct lacres, defeating the THEORY.md
6207        // §V.2 render-determinism contract. Peer with the
6208        // `:caminho` axis's `FonteCaminhoShellBackground` arm
6209        // (e12e4f3) on the sibling path-fonte axis, and
6210        // `is_gateway_api_http_path`'s eleven-byte RFC-3986-
6211        // reserved set on `:entrada :paths`.
6212        let d = dep_with_fonte(DepSource::Git {
6213            repo: "https://github.com/pleme-io/caixa-teia&sleep".into(),
6214            tag: Some("v0.1.0".into()),
6215            rev: None,
6216            branch: None,
6217        });
6218        let err = d.validate().unwrap_err();
6219        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6220            panic!("expected FonteRepoShape, got other variant");
6221        };
6222        assert_eq!(nome, "caixa-teia");
6223        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia&sleep");
6224        assert!(
6225            reason.contains("must not contain `&`"),
6226            "reason must surface the shell-background / logical-AND arm, got {reason:?}"
6227        );
6228        assert!(
6229            reason.contains("background-task") || reason.contains("'sub-delims'"),
6230            "reason must name the shell-background / RFC-3986-sub-delims rationale, \
6231             got {reason:?}"
6232        );
6233    }
6234
6235    #[test]
6236    fn validate_rejects_git_fonte_with_repo_carrying_logical_and() {
6237        // The fail-before-pass-after pin for the symmetric `&&`
6238        // logical-AND build-chain paste footgun: an author pastes
6239        // a `git clone <url> && cd <repo>` build-chain one-liner
6240        // and forgets to trim the `&& <cmd>` tail. The `&&` shape
6241        // is the same `&` byte twice in a row; the per-byte arm
6242        // fires on the first `&` it sees. Pinned separately from
6243        // the single-`&` background-launch shape so a future
6244        // diagnostic-surface change that special-cased the
6245        // doubled-byte form surfaces here.
6246        let d = dep_with_fonte(DepSource::Git {
6247            repo: "github:pleme-io/caixa-teia&&echo".into(),
6248            tag: Some("v0.1.0".into()),
6249            rev: None,
6250            branch: None,
6251        });
6252        let err = d.validate().unwrap_err();
6253        let DepError::FonteRepoShape { reason, .. } = err else {
6254            panic!("expected FonteRepoShape, got other variant");
6255        };
6256        assert!(
6257            reason.contains("must not contain `&`"),
6258            "reason must surface the shell-background / logical-AND arm on the doubled-`&&` \
6259             shape too, got {reason:?}"
6260        );
6261    }
6262
6263    #[test]
6264    fn fonte_repo_fragment_fires_before_background_when_fragment_first() {
6265        // Cascade pin: the fragment-`#` arm and the background-`&`
6266        // arm are both per-byte arms inside the same `for &b in
6267        // s.as_bytes()` loop, so the byte that appears first in the
6268        // value's byte order wins. A `:repo
6269        // "https://github.com/p/x#readme & sleep"` carries both `#`
6270        // and `&`; the `#` byte appears first, so the fragment-`#`
6271        // arm fires, surfacing the more self-locating diagnostic on
6272        // the byte the author pasted earliest in the URL. Mirrors
6273        // the peer cascade discipline
6274        // `fonte_repo_fragment_fires_before_semicolon_when_fragment_first`
6275        // on the prior `:repo` byte-class arm.
6276        let d = dep_with_fonte(DepSource::Git {
6277            repo: "https://github.com/pleme-io/caixa-teia#readme&sleep".into(),
6278            tag: Some("v0.1.0".into()),
6279            rev: None,
6280            branch: None,
6281        });
6282        let err = d.validate().unwrap_err();
6283        let DepError::FonteRepoShape { reason, .. } = err else {
6284            panic!("expected FonteRepoShape, got other variant");
6285        };
6286        assert!(
6287            reason.contains("must not contain `#`"),
6288            "reason must surface the fragment-`#` arm (fires before background-`&` when `#` \
6289             byte appears first in value), got {reason:?}"
6290        );
6291    }
6292
6293    #[test]
6294    fn fonte_repo_semicolon_fires_before_background_when_semicolon_first() {
6295        // Cascade pin: the semicolon arm and the background-`&` arm
6296        // are both per-byte arms inside the same `for &b in
6297        // s.as_bytes()` loop, so the byte that appears first in the
6298        // value's byte order wins. A `:repo
6299        // "https://github.com/p/x; rm & sleep"` carries both `;` and
6300        // `&`; the `;` byte appears first, so the semicolon arm
6301        // fires, surfacing the more self-locating diagnostic on the
6302        // byte the author pasted earliest in the URL. Pins the
6303        // natural-order cascade so a future reorder of the per-byte
6304        // arms surfaces here.
6305        let d = dep_with_fonte(DepSource::Git {
6306            repo: "https://github.com/pleme-io/caixa-teia;rm&sleep".into(),
6307            tag: Some("v0.1.0".into()),
6308            rev: None,
6309            branch: None,
6310        });
6311        let err = d.validate().unwrap_err();
6312        let DepError::FonteRepoShape { reason, .. } = err else {
6313            panic!("expected FonteRepoShape, got other variant");
6314        };
6315        assert!(
6316            reason.contains("must not contain `;`"),
6317            "reason must surface the semicolon arm (fires before background-`&` when `;` \
6318             byte appears first in value), got {reason:?}"
6319        );
6320    }
6321
6322    #[test]
6323    fn validate_rejects_git_fonte_with_repo_carrying_shell_variable_expansion() {
6324        // The fail-before-pass-after pin for the canonical
6325        // paste-from-shell-prompt-with-unsubstituted-variable footgun
6326        // on `:repo` (peer with the f4efe9c `$` arm on the sibling
6327        // `:caminho` path-fonte axis). An author pastes a shell one-
6328        // liner that referenced an environment variable
6329        // (`git clone https://github.com/$ORG/x`, `git clone
6330        // github:$USER/repo`) into the `:repo` slot, forgetting to
6331        // substitute the literal value at author time. Until this arm
6332        // landed the value silently passed every prior
6333        // `is_git_repo_url` arm (no whitespace, no control chars, no
6334        // non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no `<`/`>`,
6335        // no `` ` ``, no `|`, no `;`, no `&`, doesn't start with `-`
6336        // or `:`); RFC 3986 §2 lists `$` in the 'sub-delims' /
6337        // reserved set and the WHATWG URL spec's fragment percent-
6338        // encode set maps `$` → `%24` on the wire, so the byte rides
6339        // verbatim into the lacre's per-dep BLAKE3 closure but is
6340        // silently rewritten at libcurl's URL-parser layer — two
6341        // authors whose values differ only in their `$VAR` /
6342        // `${VAR}` / `$(cmd)` expansion tail resolve to the byte-
6343        // identical upstream `git clone` but lock to two distinct
6344        // lacres, defeating the THEORY.md §V.2 render-determinism
6345        // contract. Beyond determinism, the value is a structural
6346        // host-layout leak: two authors with the same `:repo` slot
6347        // but different `$ORG` / `$HOME` / `$WORKSPACE` resolve
6348        // different upstreams. Peer with the `:caminho` axis's
6349        // `FonteCaminhoVarExpansion` arm (f4efe9c) on the sibling
6350        // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
6351        // byte RFC-3986-reserved set on `:entrada :paths`.
6352        let d = dep_with_fonte(DepSource::Git {
6353            repo: "https://github.com/$ORG/caixa-teia".into(),
6354            tag: Some("v0.1.0".into()),
6355            rev: None,
6356            branch: None,
6357        });
6358        let err = d.validate().unwrap_err();
6359        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6360            panic!("expected FonteRepoShape, got other variant");
6361        };
6362        assert_eq!(nome, "caixa-teia");
6363        assert_eq!(repo, "https://github.com/$ORG/caixa-teia");
6364        assert!(
6365            reason.contains("must not contain `$`"),
6366            "reason must surface the shell-variable-expansion arm, got {reason:?}"
6367        );
6368        assert!(
6369            reason.contains("variable-expansion") || reason.contains("'sub-delims'"),
6370            "reason must name the shell-variable-expansion / RFC-3986-sub-delims \
6371             rationale, got {reason:?}"
6372        );
6373    }
6374
6375    #[test]
6376    fn validate_rejects_git_fonte_with_repo_carrying_braced_variable_expansion() {
6377        // The fail-before-pass-after pin for the symmetric POSIX-
6378        // shell braced `${VAR}` expansion paste footgun: an author
6379        // pastes a CI-manifest line `git clone
6380        // https://github.com/${WORKSPACE}/x` (the canonical GitHub
6381        // Actions / GitLab CI / Drone shape) and forgets to
6382        // substitute the literal value. The `${...}` shape is the
6383        // same `$` byte at the leading position of the expansion;
6384        // the per-byte arm fires on the `$`. Pinned separately from
6385        // the bare-`$VAR` shape so a future diagnostic-surface
6386        // change that special-cased the braced form surfaces here.
6387        let d = dep_with_fonte(DepSource::Git {
6388            repo: "https://github.com/${WORKSPACE}/caixa-teia".into(),
6389            tag: Some("v0.1.0".into()),
6390            rev: None,
6391            branch: None,
6392        });
6393        let err = d.validate().unwrap_err();
6394        let DepError::FonteRepoShape { reason, .. } = err else {
6395            panic!("expected FonteRepoShape, got other variant");
6396        };
6397        assert!(
6398            reason.contains("must not contain `$`"),
6399            "reason must surface the shell-variable-expansion arm on the braced `${{...}}` \
6400             shape too, got {reason:?}"
6401        );
6402    }
6403
6404    #[test]
6405    fn fonte_repo_fragment_fires_before_var_expansion_when_fragment_first() {
6406        // Cascade pin: the fragment-`#` arm and the var-expansion-`$`
6407        // arm are both per-byte arms inside the same `for &b in
6408        // s.as_bytes()` loop, so the byte that appears first in the
6409        // value's byte order wins. A `:repo
6410        // "https://github.com/p/x#readme$HOME"` carries both `#` and
6411        // `$`; the `#` byte appears first, so the fragment-`#` arm
6412        // fires, surfacing the more self-locating diagnostic on the
6413        // byte the author pasted earliest in the URL. Mirrors the
6414        // peer cascade discipline
6415        // `fonte_repo_fragment_fires_before_background_when_fragment_first`
6416        // on the prior `:repo` byte-class arm.
6417        let d = dep_with_fonte(DepSource::Git {
6418            repo: "https://github.com/pleme-io/caixa-teia#readme$HOME".into(),
6419            tag: Some("v0.1.0".into()),
6420            rev: None,
6421            branch: None,
6422        });
6423        let err = d.validate().unwrap_err();
6424        let DepError::FonteRepoShape { reason, .. } = err else {
6425            panic!("expected FonteRepoShape, got other variant");
6426        };
6427        assert!(
6428            reason.contains("must not contain `#`"),
6429            "reason must surface the fragment-`#` arm (fires before var-expansion-`$` when \
6430             `#` byte appears first in value), got {reason:?}"
6431        );
6432    }
6433
6434    #[test]
6435    fn fonte_repo_background_fires_before_var_expansion_when_background_first() {
6436        // Cascade pin: the background-`&` arm and the
6437        // var-expansion-`$` arm are both per-byte arms inside the
6438        // same `for &b in s.as_bytes()` loop, so the byte that
6439        // appears first in the value's byte order wins. A `:repo
6440        // "https://github.com/p/x&sleep$HOME"` carries both `&` and
6441        // `$`; the `&` byte appears first, so the background arm
6442        // fires, surfacing the more self-locating diagnostic on the
6443        // byte the author pasted earliest in the URL. Pins the
6444        // natural-order cascade so a future reorder of the per-byte
6445        // arms surfaces here — `$` is the most recent byte-class arm,
6446        // so the cascade-pin sweep extends to cover every immediately
6447        // prior byte arm (`#`, `&`) firing first when ordered ahead
6448        // of `$` in the value.
6449        let d = dep_with_fonte(DepSource::Git {
6450            repo: "https://github.com/pleme-io/caixa-teia&sleep$HOME".into(),
6451            tag: Some("v0.1.0".into()),
6452            rev: None,
6453            branch: None,
6454        });
6455        let err = d.validate().unwrap_err();
6456        let DepError::FonteRepoShape { reason, .. } = err else {
6457            panic!("expected FonteRepoShape, got other variant");
6458        };
6459        assert!(
6460            reason.contains("must not contain `&`"),
6461            "reason must surface the background-`&` arm (fires before var-expansion-`$` when \
6462             `&` byte appears first in value), got {reason:?}"
6463        );
6464    }
6465
6466    #[test]
6467    fn validate_rejects_git_fonte_with_repo_carrying_shell_glob_wildcard() {
6468        // The fail-before-pass-after pin for the canonical
6469        // paste-from-shell-prompt glob footgun on `:repo` (peer with
6470        // the cf9034b `*` / `?` arm on the sibling `:caminho`
6471        // path-fonte axis). An author pastes a shell one-liner that
6472        // referenced a glob expansion (`ls
6473        // github.com/pleme-io/caixa-*`, `git clone
6474        // github:pleme-io/caixa-*`) into the `:repo` slot, forgetting
6475        // to substitute the literal repo name. Until this arm landed
6476        // the `*` byte silently passed every prior `is_git_repo_url`
6477        // arm (no whitespace, no control chars, no non-ASCII, no `#`,
6478        // no `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`,
6479        // no `;`, no `&`, no `$`, doesn't start with `-` or `:`); RFC
6480        // 3986 §2 lists `*` in the 'sub-delims' / reserved set and
6481        // the WHATWG URL spec's special-query percent-encode set maps
6482        // `*` → `%2A` on the wire, so the byte rides verbatim into
6483        // the lacre's per-dep BLAKE3 closure but is silently
6484        // rewritten at libcurl's URL-parser layer — two authors
6485        // whose values differ only in their asterisk presence
6486        // resolve to the byte-identical upstream `git clone` but
6487        // lock to two distinct lacres, defeating the THEORY.md §V.2
6488        // render-determinism contract. Peer with the `:caminho`
6489        // axis's `FonteCaminhoShellGlob` arm (cf9034b) on the
6490        // sibling path-fonte axis, and the `is_git_ref_name`
6491        // refspec-wildcard cascade on the `:fonte :tag` / `:branch`
6492        // axes.
6493        let d = dep_with_fonte(DepSource::Git {
6494            repo: "https://github.com/pleme-io/caixa-*".into(),
6495            tag: Some("v0.1.0".into()),
6496            rev: None,
6497            branch: None,
6498        });
6499        let err = d.validate().unwrap_err();
6500        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6501            panic!("expected FonteRepoShape, got other variant");
6502        };
6503        assert_eq!(nome, "caixa-teia");
6504        assert_eq!(repo, "https://github.com/pleme-io/caixa-*");
6505        assert!(
6506            reason.contains("must not contain `*`"),
6507            "reason must surface the shell-glob arm, got {reason:?}"
6508        );
6509        assert!(
6510            reason.contains("pathname-expansion") || reason.contains("'sub-delims'"),
6511            "reason must name the shell-glob / pathname-expansion / \
6512             RFC-3986-sub-delims rationale, got {reason:?}"
6513        );
6514    }
6515
6516    #[test]
6517    fn validate_rejects_git_fonte_with_repo_carrying_recursive_shell_glob() {
6518        // The fail-before-pass-after pin for the symmetric bash
6519        // `globstar` recursive-glob paste footgun: an author pastes
6520        // a `ls github.com/pleme-io/**/x` (the canonical
6521        // `globstar`-shopt-enabled recursive-listing tail) into the
6522        // `:repo` slot. The `**` shape is two `*` bytes adjacent;
6523        // the per-byte arm fires on the first `*`. Pinned
6524        // separately from the single-`*` shape so a future
6525        // diagnostic-surface change that special-cased the
6526        // double-`*` form surfaces here.
6527        let d = dep_with_fonte(DepSource::Git {
6528            repo: "https://github.com/pleme-io/**/caixa-teia".into(),
6529            tag: Some("v0.1.0".into()),
6530            rev: None,
6531            branch: None,
6532        });
6533        let err = d.validate().unwrap_err();
6534        let DepError::FonteRepoShape { reason, .. } = err else {
6535            panic!("expected FonteRepoShape, got other variant");
6536        };
6537        assert!(
6538            reason.contains("must not contain `*`"),
6539            "reason must surface the shell-glob arm on the `**` recursive-glob shape too, \
6540             got {reason:?}"
6541        );
6542    }
6543
6544    #[test]
6545    fn fonte_repo_fragment_fires_before_glob_when_fragment_first() {
6546        // Cascade pin: the fragment-`#` arm and the glob-`*` arm are
6547        // both per-byte arms inside the same `for &b in s.as_bytes()`
6548        // loop, so the byte that appears first in the value's byte
6549        // order wins. A `:repo
6550        // "https://github.com/p/x#readme*tail"` carries both `#` and
6551        // `*`; the `#` byte appears first, so the fragment-`#` arm
6552        // fires, surfacing the more self-locating diagnostic on the
6553        // byte the author pasted earliest in the URL. Mirrors the
6554        // peer cascade discipline
6555        // `fonte_repo_fragment_fires_before_var_expansion_when_fragment_first`
6556        // on the prior `:repo` byte-class arm.
6557        let d = dep_with_fonte(DepSource::Git {
6558            repo: "https://github.com/pleme-io/caixa-teia#readme*tail".into(),
6559            tag: Some("v0.1.0".into()),
6560            rev: None,
6561            branch: None,
6562        });
6563        let err = d.validate().unwrap_err();
6564        let DepError::FonteRepoShape { reason, .. } = err else {
6565            panic!("expected FonteRepoShape, got other variant");
6566        };
6567        assert!(
6568            reason.contains("must not contain `#`"),
6569            "reason must surface the fragment-`#` arm (fires before glob-`*` when `#` byte \
6570             appears first in value), got {reason:?}"
6571        );
6572    }
6573
6574    #[test]
6575    fn fonte_repo_var_expansion_fires_before_glob_when_var_expansion_first() {
6576        // Cascade pin: the var-expansion-`$` arm and the glob-`*`
6577        // arm are both per-byte arms inside the same `for &b in
6578        // s.as_bytes()` loop, so the byte that appears first in the
6579        // value's byte order wins. A `:repo
6580        // "https://github.com/p/$ORG-*"` carries both `$` and `*`;
6581        // the `$` byte appears first, so the var-expansion arm
6582        // fires, surfacing the more self-locating diagnostic on the
6583        // byte the author pasted earliest in the URL. Pins the
6584        // natural-order cascade so a future reorder of the per-byte
6585        // arms surfaces here — `*` is the most recent byte-class
6586        // arm, so the cascade-pin sweep extends to cover the
6587        // immediately prior `$` byte arm firing first when ordered
6588        // ahead of `*` in the value.
6589        let d = dep_with_fonte(DepSource::Git {
6590            repo: "https://github.com/pleme-io/$ORG-caixa-*".into(),
6591            tag: Some("v0.1.0".into()),
6592            rev: None,
6593            branch: None,
6594        });
6595        let err = d.validate().unwrap_err();
6596        let DepError::FonteRepoShape { reason, .. } = err else {
6597            panic!("expected FonteRepoShape, got other variant");
6598        };
6599        assert!(
6600            reason.contains("must not contain `$`"),
6601            "reason must surface the var-expansion-`$` arm (fires before glob-`*` when `$` \
6602             byte appears first in value), got {reason:?}"
6603        );
6604    }
6605
6606    #[test]
6607    fn validate_rejects_git_fonte_with_repo_carrying_subshell_open_paren() {
6608        // The fail-before-pass-after pin for the canonical paste-from-
6609        // shell-prompt subshell-grouping footgun on `:repo`. An author
6610        // pastes a doc / README snippet carrying a regex-alternation
6611        // grouping shape (`https://github.com/(foo|bar)/repo`) or a
6612        // dynamic-config-substitution wrapper (`$(<cmd>)`) into the
6613        // `:repo` slot, forgetting to substitute one literal org name.
6614        // Until this arm landed the `(` byte silently passed every
6615        // prior `is_git_repo_url` arm (no whitespace, no control
6616        // chars, no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no
6617        // `<`/`>`, no `` ` ``, no `|`, no `;`, no `&`, no `$`, no
6618        // `*`, doesn't start with `-` or `:`); RFC 3986 §2 lists `(`
6619        // / `)` in the 'sub-delims' / reserved set, and the WHATWG
6620        // URL spec's special-query percent-encode set maps `(` →
6621        // `%28` and `)` → `%29` on the wire, so the byte rides
6622        // verbatim into the lacre's per-dep BLAKE3 closure but is
6623        // silently rewritten at libcurl's URL-parser layer —
6624        // defeating the THEORY.md §V.2 render-determinism contract on
6625        // the same axis the prior twelve byte-class arms close.
6626        let d = dep_with_fonte(DepSource::Git {
6627            repo: "https://github.com/(foo|bar)/caixa-teia".into(),
6628            tag: Some("v0.1.0".into()),
6629            rev: None,
6630            branch: None,
6631        });
6632        let err = d.validate().unwrap_err();
6633        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6634            panic!("expected FonteRepoShape, got other variant");
6635        };
6636        assert_eq!(nome, "caixa-teia");
6637        assert_eq!(repo, "https://github.com/(foo|bar)/caixa-teia");
6638        assert!(
6639            reason.contains("must not contain `(`"),
6640            "reason must surface the subshell-open-paren arm, got {reason:?}"
6641        );
6642        assert!(
6643            reason.contains("subshell-grouping") || reason.contains("'sub-delims'"),
6644            "reason must name the shell-subshell-grouping / RFC-3986-sub-delims rationale, \
6645             got {reason:?}"
6646        );
6647    }
6648
6649    #[test]
6650    fn validate_rejects_git_fonte_with_repo_carrying_subshell_close_paren() {
6651        // The symmetric arm pin on the closing `)` byte: an author
6652        // pastes a `$(date)` command-substitution wrapper or a
6653        // regex-alternation `(foo|bar)` tail into the `:repo` slot.
6654        // Pinned separately from the opening `(` shape so a future
6655        // diagnostic-surface change that only checked one boundary
6656        // surfaces here. The `(` byte appears earlier in the
6657        // canonical regex / subshell wrapper so the per-byte loop
6658        // fires on `(` first; this test exercises a `:repo` value
6659        // carrying only the closing `)` byte (no opening paren) so
6660        // the `)` arm fires directly — pinning the byte-class arm
6661        // independent of order.
6662        let d = dep_with_fonte(DepSource::Git {
6663            repo: "github:pleme-io/caixa-teia)tail".into(),
6664            tag: Some("v0.1.0".into()),
6665            rev: None,
6666            branch: None,
6667        });
6668        let err = d.validate().unwrap_err();
6669        let DepError::FonteRepoShape { reason, .. } = err else {
6670            panic!("expected FonteRepoShape, got other variant");
6671        };
6672        assert!(
6673            reason.contains("must not contain `)`"),
6674            "reason must surface the subshell-close-paren arm on the bare `)` shape, \
6675             got {reason:?}"
6676        );
6677    }
6678
6679    #[test]
6680    fn fonte_repo_fragment_fires_before_subshell_when_fragment_first() {
6681        // Cascade pin: the fragment-`#` arm and the subshell-`(` arm
6682        // are both per-byte arms inside the same `for &b in
6683        // s.as_bytes()` loop, so the byte that appears first in the
6684        // value's byte order wins. A `:repo
6685        // "https://github.com/p/x#readme(tail)"` carries both `#` and
6686        // `(`; the `#` byte appears first, so the fragment-`#` arm
6687        // fires, surfacing the more self-locating diagnostic on the
6688        // byte the author pasted earliest in the URL. Mirrors the
6689        // peer cascade discipline
6690        // `fonte_repo_fragment_fires_before_glob_when_fragment_first`
6691        // on the prior `:repo` byte-class arm.
6692        let d = dep_with_fonte(DepSource::Git {
6693            repo: "https://github.com/pleme-io/caixa-teia#readme(tail)".into(),
6694            tag: Some("v0.1.0".into()),
6695            rev: None,
6696            branch: None,
6697        });
6698        let err = d.validate().unwrap_err();
6699        let DepError::FonteRepoShape { reason, .. } = err else {
6700            panic!("expected FonteRepoShape, got other variant");
6701        };
6702        assert!(
6703            reason.contains("must not contain `#`"),
6704            "reason must surface the fragment-`#` arm (fires before subshell-`(` when `#` \
6705             byte appears first in value), got {reason:?}"
6706        );
6707    }
6708
6709    #[test]
6710    fn fonte_repo_glob_fires_before_subshell_when_glob_first() {
6711        // Cascade pin: the glob-`*` arm (the immediate-predecessor
6712        // byte-class arm, 3902a9a) and the subshell-`(` arm are both
6713        // per-byte arms inside the same `for &b in s.as_bytes()`
6714        // loop, so the byte that appears first in the value's byte
6715        // order wins. A `:repo
6716        // "https://github.com/p/x-*-(date)"` carries both `*` and
6717        // `(`; the `*` byte appears first, so the glob arm fires,
6718        // surfacing the more self-locating diagnostic on the byte
6719        // the author pasted earliest in the URL. Pins the natural-
6720        // order cascade so a future reorder of the per-byte arms
6721        // surfaces here — `(` is the most recent byte-class arm,
6722        // so the cascade-pin sweep extends to cover the immediately
6723        // prior `*` byte arm firing first when ordered ahead of `(`
6724        // in the value.
6725        let d = dep_with_fonte(DepSource::Git {
6726            repo: "https://github.com/pleme-io/caixa-teia-*-(date)".into(),
6727            tag: Some("v0.1.0".into()),
6728            rev: None,
6729            branch: None,
6730        });
6731        let err = d.validate().unwrap_err();
6732        let DepError::FonteRepoShape { reason, .. } = err else {
6733            panic!("expected FonteRepoShape, got other variant");
6734        };
6735        assert!(
6736            reason.contains("must not contain `*`"),
6737            "reason must surface the glob-`*` arm (fires before subshell-`(` when `*` byte \
6738             appears first in value), got {reason:?}"
6739        );
6740    }
6741
6742    #[test]
6743    fn validate_rejects_git_fonte_with_repo_carrying_shell_double_quote() {
6744        // The fail-before-pass-after pin for the canonical paste-from-
6745        // doc-shell-quoting footgun on `:repo`. An author copies a
6746        // README quick-start snippet (`$ git clone "https://github.com/
6747        // foo/bar"`) and keeps the surrounding double-quote bytes when
6748        // pasting into the `:repo` slot — the doc wraps the URL in
6749        // double quotes so the shell doesn't re-lex metachars inside,
6750        // but the typed slot is itself a byte-level string parser, not
6751        // a shell context, so the quote bytes ride into the value
6752        // verbatim. Until this arm landed the `"` byte silently passed
6753        // every prior `is_git_repo_url` arm (no whitespace, no control
6754        // chars, no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no
6755        // `<`/`>`, no `` ` ``, no `|`, no `;`, no `&`, no `$`, no `*`,
6756        // no `(`/`)`, doesn't start with `-` or `:`); RFC 3986 §2 lists
6757        // `"` in the strict four-byte 'delims' subset (with `<`, `>`,
6758        // `` ` ``) every URL parser is required to refuse or percent-
6759        // encode, and the WHATWG URL spec's 'C0 control percent-encode
6760        // set' maps `"` → `%22` on the wire, so the byte rides verbatim
6761        // into the lacre's per-dep BLAKE3 closure but is silently
6762        // rewritten at libcurl's URL-parser layer, defeating the
6763        // THEORY.md §V.2 render-determinism contract.
6764        let d = dep_with_fonte(DepSource::Git {
6765            repo: "\"https://github.com/pleme-io/caixa-teia\"".into(),
6766            tag: Some("v0.1.0".into()),
6767            rev: None,
6768            branch: None,
6769        });
6770        let err = d.validate().unwrap_err();
6771        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6772            panic!("expected FonteRepoShape, got other variant");
6773        };
6774        assert_eq!(nome, "caixa-teia");
6775        assert_eq!(repo, "\"https://github.com/pleme-io/caixa-teia\"");
6776        assert!(
6777            reason.contains("must not contain `\"`"),
6778            "reason must surface the shell-double-quote arm, got {reason:?}"
6779        );
6780        assert!(
6781            reason.contains("double-quote") || reason.contains("'delims'"),
6782            "reason must name the shell-double-quote / RFC-3986-delims rationale, \
6783             got {reason:?}"
6784        );
6785    }
6786
6787    #[test]
6788    fn validate_rejects_git_fonte_with_repo_carrying_stray_trailing_double_quote() {
6789        // The symmetric stray-quote tail pin: an author pastes only a
6790        // closing `"` from a shell-history line like `git clone
6791        // "https://github.com/foo/bar" && cd …` (the trim went too
6792        // far in one direction but not the other) into the `:repo`
6793        // slot. Pinned separately from the wrapped-quote shape so a
6794        // future diagnostic-surface change that only checked one
6795        // boundary (only leading, only trailing, only paired) surfaces
6796        // here — the per-byte arm fires anywhere `"` appears.
6797        let d = dep_with_fonte(DepSource::Git {
6798            repo: "github:pleme-io/caixa-teia\"".into(),
6799            tag: Some("v0.1.0".into()),
6800            rev: None,
6801            branch: None,
6802        });
6803        let err = d.validate().unwrap_err();
6804        let DepError::FonteRepoShape { reason, .. } = err else {
6805            panic!("expected FonteRepoShape, got other variant");
6806        };
6807        assert!(
6808            reason.contains("must not contain `\"`"),
6809            "reason must surface the shell-double-quote arm on the trailing-`\"` shape, \
6810             got {reason:?}"
6811        );
6812    }
6813
6814    #[test]
6815    fn fonte_repo_fragment_fires_before_double_quote_when_fragment_first() {
6816        // Cascade pin: the fragment-`#` arm and the double-quote arm
6817        // are both per-byte arms inside the same `for &b in
6818        // s.as_bytes()` loop, so the byte that appears first in the
6819        // value's byte order wins. A `:repo
6820        // "https://github.com/p/x#readme\"tail"` carries both `#` and
6821        // `"`; the `#` byte appears first, so the fragment-`#` arm
6822        // fires, surfacing the more self-locating diagnostic on the
6823        // byte the author pasted earliest in the URL.
6824        let d = dep_with_fonte(DepSource::Git {
6825            repo: "https://github.com/pleme-io/caixa-teia#readme\"tail".into(),
6826            tag: Some("v0.1.0".into()),
6827            rev: None,
6828            branch: None,
6829        });
6830        let err = d.validate().unwrap_err();
6831        let DepError::FonteRepoShape { reason, .. } = err else {
6832            panic!("expected FonteRepoShape, got other variant");
6833        };
6834        assert!(
6835            reason.contains("must not contain `#`"),
6836            "reason must surface the fragment-`#` arm (fires before double-quote when `#` \
6837             byte appears first in value), got {reason:?}"
6838        );
6839    }
6840
6841    #[test]
6842    fn fonte_repo_subshell_fires_before_double_quote_when_subshell_first() {
6843        // Cascade pin: the subshell-`(` arm (the immediate-predecessor
6844        // byte-class arm, 3b99147) and the double-quote arm are both
6845        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
6846        // so the byte that appears first in the value's byte order
6847        // wins. A `:repo "github:p/x(date)\"tail"` carries both `(`
6848        // and `"`; the `(` byte appears first, so the subshell arm
6849        // fires, surfacing the more self-locating diagnostic on the
6850        // byte the author pasted earliest in the URL. Pins the natural-
6851        // order cascade so a future reorder of the per-byte arms
6852        // surfaces here — `"` is the most recent byte-class arm, so
6853        // the cascade-pin sweep extends to cover the immediately prior
6854        // `(` byte arm firing first when ordered ahead of `"` in the
6855        // value.
6856        let d = dep_with_fonte(DepSource::Git {
6857            repo: "github:pleme-io/caixa-teia(date)\"tail".into(),
6858            tag: Some("v0.1.0".into()),
6859            rev: None,
6860            branch: None,
6861        });
6862        let err = d.validate().unwrap_err();
6863        let DepError::FonteRepoShape { reason, .. } = err else {
6864            panic!("expected FonteRepoShape, got other variant");
6865        };
6866        assert!(
6867            reason.contains("must not contain `(`"),
6868            "reason must surface the subshell-`(` arm (fires before double-quote when `(` \
6869             byte appears first in value), got {reason:?}"
6870        );
6871    }
6872
6873    #[test]
6874    fn validate_rejects_git_fonte_with_repo_carrying_shell_single_quote() {
6875        // The fail-before-pass-after pin for the canonical paste-from-
6876        // doc-strong-quoting footgun on `:repo`. An author copies a
6877        // security-conscious README quick-start snippet (`$ git clone
6878        // 'https://github.com/foo/bar'`) and keeps the surrounding
6879        // single-quote bytes when pasting into the `:repo` slot — the
6880        // doc strong-quotes the URL so the shell suppresses every form
6881        // of expansion on the bytes inside (no `$`, no backtick, no
6882        // glob, no word-splitting), but the typed slot is itself a
6883        // byte-level string parser, not a shell context, so the quote
6884        // bytes ride into the value verbatim. Until this arm landed the
6885        // `'` byte silently passed every prior `is_git_repo_url` arm
6886        // (no whitespace, no control chars, no non-ASCII, no `#`, no
6887        // `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no
6888        // `;`, no `&`, no `$`, no `*`, no `(`/`)`, no `"`, doesn't start
6889        // with `-` or `:`); RFC 3986 §2.2 lists `'` in the 'sub-delims'
6890        // set, peer with the `\"` 'delims' double-quote arm and the
6891        // partner ASCII shell-string-delimiter byte every byte-level
6892        // string parser sharing a value-shape with a shell argument
6893        // must refuse on a URL-shaped slot.
6894        let d = dep_with_fonte(DepSource::Git {
6895            repo: "'https://github.com/pleme-io/caixa-teia'".into(),
6896            tag: Some("v0.1.0".into()),
6897            rev: None,
6898            branch: None,
6899        });
6900        let err = d.validate().unwrap_err();
6901        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6902            panic!("expected FonteRepoShape, got other variant");
6903        };
6904        assert_eq!(nome, "caixa-teia");
6905        assert_eq!(repo, "'https://github.com/pleme-io/caixa-teia'");
6906        assert!(
6907            reason.contains("must not contain `'`"),
6908            "reason must surface the shell-single-quote arm, got {reason:?}"
6909        );
6910        assert!(
6911            reason.contains("single-quote") || reason.contains("strong-quote"),
6912            "reason must name the shell-single-quote / strong-quote rationale, \
6913             got {reason:?}"
6914        );
6915    }
6916
6917    #[test]
6918    fn validate_rejects_git_fonte_with_repo_carrying_english_apostrophe() {
6919        // The symmetric English-typography pin: an author writes
6920        // `:repo "github:p/repo's-fork"` (the possessive-form paste-
6921        // from-prose idiom every README / commit-message / chat-thread
6922        // reference to a repo carries) expecting the substrate to
6923        // coerce it to a kebab-case slug — but the byte rides into the
6924        // lacre verbatim. Pinned separately from the wrapped-quote
6925        // shape so a future diagnostic-surface change that only checked
6926        // the boundary positions (only leading, only trailing, only
6927        // paired) surfaces here — the per-byte arm fires anywhere `'`
6928        // appears in the value.
6929        let d = dep_with_fonte(DepSource::Git {
6930            repo: "github:pleme-io/repo's-fork".into(),
6931            tag: Some("v0.1.0".into()),
6932            rev: None,
6933            branch: None,
6934        });
6935        let err = d.validate().unwrap_err();
6936        let DepError::FonteRepoShape { reason, .. } = err else {
6937            panic!("expected FonteRepoShape, got other variant");
6938        };
6939        assert!(
6940            reason.contains("must not contain `'`"),
6941            "reason must surface the shell-single-quote arm on the mid-string \
6942             apostrophe shape, got {reason:?}"
6943        );
6944    }
6945
6946    #[test]
6947    fn fonte_repo_fragment_fires_before_single_quote_when_fragment_first() {
6948        // Cascade pin: the fragment-`#` arm and the single-quote arm
6949        // are both per-byte arms inside the same `for &b in
6950        // s.as_bytes()` loop, so the byte that appears first in the
6951        // value's byte order wins. A `:repo
6952        // "https://github.com/p/x#readme'tail"` carries both `#` and
6953        // `'`; the `#` byte appears first, so the fragment-`#` arm
6954        // fires, surfacing the more self-locating diagnostic on the
6955        // byte the author pasted earliest in the URL.
6956        let d = dep_with_fonte(DepSource::Git {
6957            repo: "https://github.com/pleme-io/caixa-teia#readme'tail".into(),
6958            tag: Some("v0.1.0".into()),
6959            rev: None,
6960            branch: None,
6961        });
6962        let err = d.validate().unwrap_err();
6963        let DepError::FonteRepoShape { reason, .. } = err else {
6964            panic!("expected FonteRepoShape, got other variant");
6965        };
6966        assert!(
6967            reason.contains("must not contain `#`"),
6968            "reason must surface the fragment-`#` arm (fires before single-quote when `#` \
6969             byte appears first in value), got {reason:?}"
6970        );
6971    }
6972
6973    #[test]
6974    fn fonte_repo_double_quote_fires_before_single_quote_when_double_quote_first() {
6975        // Cascade pin: the double-quote-`"` arm (the immediate-predecessor
6976        // byte-class arm, 4267d8b) and the single-quote arm are both
6977        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
6978        // so the byte that appears first in the value's byte order
6979        // wins. A `:repo "github:p/x\"mid'tail"` carries both `"` and
6980        // `'`; the `"` byte appears first, so the double-quote arm
6981        // fires, surfacing the more self-locating diagnostic on the
6982        // byte the author pasted earliest in the URL. Pins the natural-
6983        // order cascade so a future reorder of the per-byte arms
6984        // surfaces here — `'` is the most recent byte-class arm, so
6985        // the cascade-pin sweep extends to cover the immediately prior
6986        // `"` byte arm firing first when ordered ahead of `'` in the
6987        // value.
6988        let d = dep_with_fonte(DepSource::Git {
6989            repo: "github:pleme-io/caixa-teia\"mid'tail".into(),
6990            tag: Some("v0.1.0".into()),
6991            rev: None,
6992            branch: None,
6993        });
6994        let err = d.validate().unwrap_err();
6995        let DepError::FonteRepoShape { reason, .. } = err else {
6996            panic!("expected FonteRepoShape, got other variant");
6997        };
6998        assert!(
6999            reason.contains("must not contain `\"`"),
7000            "reason must surface the double-quote arm (fires before single-quote when `\"` \
7001             byte appears first in value), got {reason:?}"
7002        );
7003    }
7004
7005    #[test]
7006    fn validate_rejects_git_fonte_with_repo_carrying_shell_history_expansion() {
7007        // The fail-before-pass-after pin for the canonical paste-from-
7008        // shell-history footgun on `:repo`. An author copies a `git
7009        // clone <url>!sudo make install` one-liner from a README's
7010        // quick-start snippet, intending the trailing `!sudo` as a
7011        // shell-history-expansion reference but the typed slot is itself
7012        // a byte-level string parser, not a shell context, so the byte
7013        // rides into the value verbatim. Until this arm landed the `!`
7014        // byte silently passed every prior `is_git_repo_url` arm (no
7015        // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
7016        // no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no `;`,
7017        // no `&`, no `$`, no `*`, no `(`/`)`, no `"`, no `'`, doesn't
7018        // start with `-` or `:`); bash with the default `histexpand`
7019        // mode rewrites `!command` to the most recent history entry
7020        // beginning with `command`, the canonical RCE-class injection
7021        // vector when the byte rides into a shell argument.
7022        let d = dep_with_fonte(DepSource::Git {
7023            repo: "https://github.com/pleme-io/caixa-teia!sudo".into(),
7024            tag: Some("v0.1.0".into()),
7025            rev: None,
7026            branch: None,
7027        });
7028        let err = d.validate().unwrap_err();
7029        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7030            panic!("expected FonteRepoShape, got other variant");
7031        };
7032        assert_eq!(nome, "caixa-teia");
7033        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia!sudo");
7034        assert!(
7035            reason.contains("must not contain `!`"),
7036            "reason must surface the shell-history-expansion arm, got {reason:?}"
7037        );
7038        assert!(
7039            reason.contains("history-expansion") || reason.contains("bang"),
7040            "reason must name the shell-history-expansion / bang rationale, got {reason:?}"
7041        );
7042    }
7043
7044    #[test]
7045    fn validate_rejects_git_fonte_with_repo_carrying_double_bang_history_reference() {
7046        // The symmetric `!!` repeat-prior-command pin: an author paste-
7047        // trims a `git clone <url>` retry idiom from shell history that
7048        // expands to the previous command via `!!`. Pinned separately
7049        // from the wrapped `!command` shape so a future diagnostic-
7050        // surface change that only checked the leading or paired-bang
7051        // position surfaces here — the per-byte arm fires anywhere `!`
7052        // appears in the value.
7053        let d = dep_with_fonte(DepSource::Git {
7054            repo: "github:pleme-io/caixa-teia!!".into(),
7055            tag: Some("v0.1.0".into()),
7056            rev: None,
7057            branch: None,
7058        });
7059        let err = d.validate().unwrap_err();
7060        let DepError::FonteRepoShape { reason, .. } = err else {
7061            panic!("expected FonteRepoShape, got other variant");
7062        };
7063        assert!(
7064            reason.contains("must not contain `!`"),
7065            "reason must surface the shell-history-expansion arm on the trailing-`!!` shape, \
7066             got {reason:?}"
7067        );
7068    }
7069
7070    #[test]
7071    fn fonte_repo_fragment_fires_before_bang_when_fragment_first() {
7072        // Cascade pin: the fragment-`#` arm and the bang arm are both
7073        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
7074        // so the byte that appears first in the value's byte order
7075        // wins. A `:repo "https://github.com/p/x#readme!tail"` carries
7076        // both `#` and `!`; the `#` byte appears first, so the
7077        // fragment-`#` arm fires, surfacing the more self-locating
7078        // diagnostic on the byte the author pasted earliest in the URL.
7079        let d = dep_with_fonte(DepSource::Git {
7080            repo: "https://github.com/pleme-io/caixa-teia#readme!tail".into(),
7081            tag: Some("v0.1.0".into()),
7082            rev: None,
7083            branch: None,
7084        });
7085        let err = d.validate().unwrap_err();
7086        let DepError::FonteRepoShape { reason, .. } = err else {
7087            panic!("expected FonteRepoShape, got other variant");
7088        };
7089        assert!(
7090            reason.contains("must not contain `#`"),
7091            "reason must surface the fragment-`#` arm (fires before bang when `#` byte \
7092             appears first in value), got {reason:?}"
7093        );
7094    }
7095
7096    #[test]
7097    fn fonte_repo_single_quote_fires_before_bang_when_single_quote_first() {
7098        // Cascade pin: the single-quote-`'` arm (the immediate-predecessor
7099        // byte-class arm, e7a109f) and the bang arm are both per-byte
7100        // arms inside the same `for &b in s.as_bytes()` loop, so the
7101        // byte that appears first in the value's byte order wins. A
7102        // `:repo "github:p/x'mid!tail"` carries both `'` and `!`; the
7103        // `'` byte appears first, so the single-quote arm fires,
7104        // surfacing the more self-locating diagnostic on the byte the
7105        // author pasted earliest in the URL. Pins the natural-order
7106        // cascade so a future reorder of the per-byte arms surfaces
7107        // here — `!` is the most recent byte-class arm, so the
7108        // cascade-pin sweep extends to cover the immediately prior `'`
7109        // byte arm firing first when ordered ahead of `!` in the value.
7110        let d = dep_with_fonte(DepSource::Git {
7111            repo: "github:pleme-io/caixa-teia'mid!tail".into(),
7112            tag: Some("v0.1.0".into()),
7113            rev: None,
7114            branch: None,
7115        });
7116        let err = d.validate().unwrap_err();
7117        let DepError::FonteRepoShape { reason, .. } = err else {
7118            panic!("expected FonteRepoShape, got other variant");
7119        };
7120        assert!(
7121            reason.contains("must not contain `'`"),
7122            "reason must surface the single-quote arm (fires before bang when `'` byte \
7123             appears first in value), got {reason:?}"
7124        );
7125    }
7126
7127    #[test]
7128    fn validate_rejects_git_fonte_with_repo_carrying_list_separator_comma() {
7129        // The fail-before-pass-after pin for the canonical
7130        // list-separator-belongs-to-list-grammar footgun on `:repo`.
7131        // An author copies a `git clone <a>, <b>, <c>` paste-from-CSV
7132        // one-liner from a multi-repo bootstrap doc, intending the
7133        // comma to separate multiple repo entries but the typed
7134        // `:repo` slot names *one* repo (the list-separator belongs
7135        // to the `:deps` list grammar, not to the value). Until this
7136        // arm landed the `,` byte silently passed every prior
7137        // `is_git_repo_url` arm (no whitespace, no control chars, no
7138        // non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no `<`/`>`,
7139        // no `` ` ``, no `|`, no `;`, no `&`, no `$`, no `*`, no
7140        // `(`/`)`, no `"`, no `'`, no `!`, doesn't start with `-` or
7141        // `:`); the byte rode into the lacre's per-dep content-
7142        // address and the resolver's `git clone <repo>` subprocess
7143        // invocation, where no host's repo registry resolved the
7144        // comma-bearing slug.
7145        let d = dep_with_fonte(DepSource::Git {
7146            repo: "github:pleme-io/caixa-teia,github:pleme-io/caixa-feira".into(),
7147            tag: Some("v0.1.0".into()),
7148            rev: None,
7149            branch: None,
7150        });
7151        let err = d.validate().unwrap_err();
7152        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7153            panic!("expected FonteRepoShape, got other variant");
7154        };
7155        assert_eq!(nome, "caixa-teia");
7156        assert_eq!(
7157            repo,
7158            "github:pleme-io/caixa-teia,github:pleme-io/caixa-feira"
7159        );
7160        assert!(
7161            reason.contains("must not contain `,`"),
7162            "reason must surface the list-separator-comma arm, got {reason:?}"
7163        );
7164        assert!(
7165            reason.contains("list-separator") || reason.contains("sub-delims"),
7166            "reason must name the list-separator / RFC-3986-sub-delims rationale, \
7167             got {reason:?}"
7168        );
7169    }
7170
7171    #[test]
7172    fn validate_rejects_git_fonte_with_repo_carrying_trailing_comma() {
7173        // The symmetric trailing-`,` paste-from-prose pin: an author
7174        // writes `:repo "github:pleme-io/caixa-feira,"` (the trailing
7175        // comma every README-prose list-of-projects sentence carries,
7176        // mistakenly retained when the slug is pasted mid-sentence)
7177        // expecting the substrate to coerce it to a kebab-case slug.
7178        // Pinned separately from the wrapped mid-token shape so a
7179        // future diagnostic-surface change that only checked the
7180        // leading or paired-comma position surfaces here — the
7181        // per-byte arm fires anywhere `,` appears in the value.
7182        let d = dep_with_fonte(DepSource::Git {
7183            repo: "github:pleme-io/caixa-feira,".into(),
7184            tag: Some("v0.1.0".into()),
7185            rev: None,
7186            branch: None,
7187        });
7188        let err = d.validate().unwrap_err();
7189        let DepError::FonteRepoShape { reason, .. } = err else {
7190            panic!("expected FonteRepoShape, got other variant");
7191        };
7192        assert!(
7193            reason.contains("must not contain `,`"),
7194            "reason must surface the list-separator-comma arm on the trailing-`,` shape, \
7195             got {reason:?}"
7196        );
7197    }
7198
7199    #[test]
7200    fn fonte_repo_fragment_fires_before_comma_when_fragment_first() {
7201        // Cascade pin: the fragment-`#` arm and the comma arm are
7202        // both per-byte arms inside the same `for &b in s.as_bytes()`
7203        // loop, so the byte that appears first in the value's byte
7204        // order wins. A `:repo "https://github.com/p/x#readme,tail"`
7205        // carries both `#` and `,`; the `#` byte appears first, so
7206        // the fragment-`#` arm fires, surfacing the more self-
7207        // locating diagnostic on the byte the author pasted earliest
7208        // in the URL.
7209        let d = dep_with_fonte(DepSource::Git {
7210            repo: "https://github.com/pleme-io/caixa-teia#readme,tail".into(),
7211            tag: Some("v0.1.0".into()),
7212            rev: None,
7213            branch: None,
7214        });
7215        let err = d.validate().unwrap_err();
7216        let DepError::FonteRepoShape { reason, .. } = err else {
7217            panic!("expected FonteRepoShape, got other variant");
7218        };
7219        assert!(
7220            reason.contains("must not contain `#`"),
7221            "reason must surface the fragment-`#` arm (fires before comma when `#` byte \
7222             appears first in value), got {reason:?}"
7223        );
7224    }
7225
7226    #[test]
7227    fn fonte_repo_bang_fires_before_comma_when_bang_first() {
7228        // Cascade pin: the bang-`!` arm (the immediate-predecessor
7229        // byte-class arm, 7d53c68) and the comma arm are both
7230        // per-byte arms inside the same `for &b in s.as_bytes()`
7231        // loop, so the byte that appears first in the value's byte
7232        // order wins. A `:repo "github:p/x!mid,tail"` carries both
7233        // `!` and `,`; the `!` byte appears first, so the bang arm
7234        // fires, surfacing the more self-locating diagnostic on the
7235        // byte the author pasted earliest in the URL. Pins the
7236        // natural-order cascade so a future reorder of the per-byte
7237        // arms surfaces here — `,` is the most recent byte-class
7238        // arm, so the cascade-pin sweep extends to cover the
7239        // immediately prior `!` byte arm firing first when ordered
7240        // ahead of `,` in the value.
7241        let d = dep_with_fonte(DepSource::Git {
7242            repo: "github:pleme-io/caixa-teia!mid,tail".into(),
7243            tag: Some("v0.1.0".into()),
7244            rev: None,
7245            branch: None,
7246        });
7247        let err = d.validate().unwrap_err();
7248        let DepError::FonteRepoShape { reason, .. } = err else {
7249            panic!("expected FonteRepoShape, got other variant");
7250        };
7251        assert!(
7252            reason.contains("must not contain `!`"),
7253            "reason must surface the bang arm (fires before comma when `!` byte \
7254             appears first in value), got {reason:?}"
7255        );
7256    }
7257
7258    #[test]
7259    fn validate_rejects_git_fonte_with_repo_carrying_shell_env_var_assignment() {
7260        // The fail-before-pass-after pin for the canonical
7261        // shell-env-var-assignment-belongs-to-shell-grammar footgun
7262        // on `:repo`. An author copies
7263        // `GIT_TERMINAL_PROMPT=0 git clone <url>` (or
7264        // `GIT_SSL_NO_VERIFY=1 git clone <url>`, `HTTPS_PROXY=…
7265        // git clone <url>`, etc. — the canonical
7266        // git-troubleshooting README idiom for a one-shot env-var
7267        // scoped to the `git clone` invocation) from a shell-prompt
7268        // one-liner, intending the `KEY=VALUE` prefix as a shell-
7269        // grammar env-var assignment but the typed `:repo` slot is
7270        // a value parser, not a shell context, so the bytes ride
7271        // into the value verbatim. Until this arm landed the `=`
7272        // byte silently passed every prior `is_git_repo_url` arm
7273        // (no whitespace, no control chars, no non-ASCII, no `#`,
7274        // no `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no
7275        // `|`, no `;`, no `&`, no `$`, no `*`, no `(`/`)`, no `"`,
7276        // no `'`, no `!`, no `,`, doesn't start with `-` or `:`);
7277        // the byte rode into the lacre's per-dep content-address
7278        // and the resolver's `git clone <repo>` subprocess
7279        // invocation, where the upstream host's git porcelain
7280        // fetched a literal `GIT_TERMINAL_PROMPT=0 https://…`-shaped
7281        // path that no host's repo registry resolves.
7282        let d = dep_with_fonte(DepSource::Git {
7283            repo: "GIT_TERMINAL_PROMPT=0 https://github.com/pleme-io/caixa-teia".into(),
7284            tag: Some("v0.1.0".into()),
7285            rev: None,
7286            branch: None,
7287        });
7288        let err = d.validate().unwrap_err();
7289        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7290            panic!("expected FonteRepoShape, got other variant");
7291        };
7292        assert_eq!(nome, "caixa-teia");
7293        assert_eq!(
7294            repo,
7295            "GIT_TERMINAL_PROMPT=0 https://github.com/pleme-io/caixa-teia"
7296        );
7297        // The `=` byte at position 19 of `GIT_TERMINAL_PROMPT=0 …`
7298        // appears before the ` ` byte at position 21, so the `=`
7299        // arm fires (not the whitespace arm) — both arms guard
7300        // the slot, but the per-byte for-loop scans left-to-right
7301        // and the first matching byte wins.
7302        assert!(
7303            reason.contains("must not contain `=`"),
7304            "reason must surface the equals-`=` arm on the env-var-assignment \
7305             paste shape, got {reason:?}"
7306        );
7307        assert!(
7308            reason.contains("env-var-assignment") || reason.contains("KEY=VALUE"),
7309            "reason must name the shell-env-var-assignment rationale, got {reason:?}"
7310        );
7311    }
7312
7313    #[test]
7314    fn validate_rejects_git_fonte_with_repo_carrying_gitconfig_url_key_prefix() {
7315        // The symmetric paste-from-gitconfig pin: an author copies
7316        // `url=https://github.com/p/x` from `git config --get-all
7317        // remote.origin.url` output, a `.gitconfig` `[remote
7318        // "origin"] url = https://…` ini-stanza paste, or a
7319        // `git config remote.origin.url <value>` doc snippet,
7320        // intending the `url=` prefix as the ini-key but the typed
7321        // `:repo` slot is a URL value parser, not a gitconfig
7322        // grammar. With no leading whitespace and no earlier-arm
7323        // bytes in the value, the `=` arm itself fires (rather
7324        // than cascading to the whitespace arm as in the env-var
7325        // paste shape). Pinned separately so a future diagnostic-
7326        // surface change that only checked the whitespace-leading
7327        // shape surfaces here — the per-byte arm fires anywhere
7328        // `=` appears in the value.
7329        let d = dep_with_fonte(DepSource::Git {
7330            repo: "url=https://github.com/pleme-io/caixa-feira".into(),
7331            tag: Some("v0.1.0".into()),
7332            rev: None,
7333            branch: None,
7334        });
7335        let err = d.validate().unwrap_err();
7336        let DepError::FonteRepoShape { reason, .. } = err else {
7337            panic!("expected FonteRepoShape, got other variant");
7338        };
7339        assert!(
7340            reason.contains("must not contain `=`"),
7341            "reason must surface the equals-`=` arm on the `url=…` gitconfig \
7342             paste shape, got {reason:?}"
7343        );
7344        assert!(
7345            reason.contains("key-value-separator") || reason.contains("sub-delims"),
7346            "reason must name the key-value-separator / RFC-3986-sub-delims \
7347             rationale, got {reason:?}"
7348        );
7349    }
7350
7351    #[test]
7352    fn fonte_repo_fragment_fires_before_equals_when_fragment_first() {
7353        // Cascade pin: the fragment-`#` arm and the `=` arm are
7354        // both per-byte arms inside the same `for &b in s.as_bytes()`
7355        // loop, so the byte that appears first in the value's byte
7356        // order wins. A `:repo "https://github.com/p/x#readme=tail"`
7357        // carries both `#` and `=`; the `#` byte appears first, so
7358        // the fragment-`#` arm fires, surfacing the more self-
7359        // locating diagnostic on the byte the author pasted earliest
7360        // in the URL.
7361        let d = dep_with_fonte(DepSource::Git {
7362            repo: "https://github.com/pleme-io/caixa-teia#readme=tail".into(),
7363            tag: Some("v0.1.0".into()),
7364            rev: None,
7365            branch: None,
7366        });
7367        let err = d.validate().unwrap_err();
7368        let DepError::FonteRepoShape { reason, .. } = err else {
7369            panic!("expected FonteRepoShape, got other variant");
7370        };
7371        assert!(
7372            reason.contains("must not contain `#`"),
7373            "reason must surface the fragment-`#` arm (fires before equals when \
7374             `#` byte appears first in value), got {reason:?}"
7375        );
7376    }
7377
7378    #[test]
7379    fn fonte_repo_comma_fires_before_equals_when_comma_first() {
7380        // Cascade pin: the comma-`,` arm (the immediate-predecessor
7381        // byte-class arm, 775b80e) and the `=` arm are both per-byte
7382        // arms inside the same `for &b in s.as_bytes()` loop, so
7383        // the byte that appears first in the value's byte order
7384        // wins. A `:repo "github:p/x,mid=tail"` carries both `,`
7385        // and `=`; the `,` byte appears first, so the comma arm
7386        // fires, surfacing the more self-locating diagnostic on
7387        // the byte the author pasted earliest in the URL. Pins the
7388        // natural-order cascade so a future reorder of the per-byte
7389        // arms surfaces here — `=` is the most recent byte-class
7390        // arm, so the cascade-pin sweep extends to cover the
7391        // immediately prior `,` byte arm firing first when ordered
7392        // ahead of `=` in the value.
7393        let d = dep_with_fonte(DepSource::Git {
7394            repo: "github:pleme-io/caixa-teia,mid=tail".into(),
7395            tag: Some("v0.1.0".into()),
7396            rev: None,
7397            branch: None,
7398        });
7399        let err = d.validate().unwrap_err();
7400        let DepError::FonteRepoShape { reason, .. } = err else {
7401            panic!("expected FonteRepoShape, got other variant");
7402        };
7403        assert!(
7404            reason.contains("must not contain `,`"),
7405            "reason must surface the comma arm (fires before equals when `,` byte \
7406             appears first in value), got {reason:?}"
7407        );
7408    }
7409
7410    #[test]
7411    fn validate_rejects_git_fonte_with_repo_carrying_percent_encoded_space() {
7412        // The fail-before-pass-after pin for the canonical paste-from-
7413        // browser-address-bar percent-encoded-space footgun on `:repo`.
7414        // An author copies `https://github.com/p/x%20test` from a
7415        // browser address bar (or a percent-encoded README hyperlink,
7416        // or a `curl --data-urlencode` shell-pipeline output)
7417        // intending `%20` as the URL encoding of a literal space; the
7418        // typed `:repo` slot already rejects the literal space byte
7419        // (the whitespace arm at the top of `is_git_repo_url`), so an
7420        // author trying to express "I really meant a space" reaches
7421        // for percent-encoding. Until this arm landed the `%` byte
7422        // silently passed every prior `is_git_repo_url` arm and rode
7423        // verbatim into the lacre's per-dep content-address — but
7424        // libcurl re-percent-encodes `%` to `%25` on the wire (since
7425        // `%` is reserved as the escape-sequence lead-in), so the
7426        // wire request becomes `https://github.com/p/x%2520test`, a
7427        // path the lacre's content-address never names. The classic
7428        // render-determinism violation on the encoding-mechanism axis
7429        // itself.
7430        let d = dep_with_fonte(DepSource::Git {
7431            repo: "https://github.com/pleme-io/caixa-teia%20test".into(),
7432            tag: Some("v0.1.0".into()),
7433            rev: None,
7434            branch: None,
7435        });
7436        let err = d.validate().unwrap_err();
7437        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7438            panic!("expected FonteRepoShape, got other variant");
7439        };
7440        assert_eq!(nome, "caixa-teia");
7441        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia%20test");
7442        assert!(
7443            reason.contains("must not contain `%`"),
7444            "reason must surface the percent-`%` arm on the percent-encoded-space \
7445             paste shape, got {reason:?}"
7446        );
7447        assert!(
7448            reason.contains("percent-encoding") || reason.contains("%25"),
7449            "reason must name the percent-encoding / `%25` re-encoding rationale, \
7450             got {reason:?}"
7451        );
7452    }
7453
7454    #[test]
7455    fn validate_rejects_git_fonte_with_repo_carrying_percent_encoded_slash() {
7456        // The symmetric over-encoded-path-separator pin: an author
7457        // writes `:repo "https://github.com/p%2Fx"` intending the
7458        // `%2F` as the URL encoding of `/` (the canonical
7459        // paste-from-OpenAPI-spec / paste-from-percent-encoded-template
7460        // footgun every API client library and OAuth redirect-URI
7461        // documentation surfaces — the `/` is the URL-path-separator
7462        // and some templates percent-encode it to escape interpretation
7463        // as a path separator). The GitHub Smart-HTTP transport
7464        // resolves the URL's path-segment grammar before the
7465        // percent-decoding pass, so the value identifies a different
7466        // resource on the wire than the literal-`/` form the lacre's
7467        // content-address must agree with — two authors whose `:repo`
7468        // values differ only in their `/` vs `%2F` presence lock to
7469        // two distinct BLAKE3 closures for the byte-identical upstream
7470        // `git clone`. Pinned separately so a future diagnostic
7471        // surface that only catches the `%20` shape surfaces here too.
7472        let d = dep_with_fonte(DepSource::Git {
7473            repo: "https://github.com/pleme-io%2Fcaixa-teia".into(),
7474            tag: Some("v0.1.0".into()),
7475            rev: None,
7476            branch: None,
7477        });
7478        let err = d.validate().unwrap_err();
7479        let DepError::FonteRepoShape { reason, .. } = err else {
7480            panic!("expected FonteRepoShape, got other variant");
7481        };
7482        assert!(
7483            reason.contains("must not contain `%`"),
7484            "reason must surface the percent-`%` arm on the over-encoded-path \
7485             shape, got {reason:?}"
7486        );
7487        assert!(
7488            reason.contains("render-determinism") || reason.contains("BLAKE3"),
7489            "reason must name the render-determinism / BLAKE3-closure rationale, \
7490             got {reason:?}"
7491        );
7492    }
7493
7494    #[test]
7495    fn fonte_repo_fragment_fires_before_percent_when_fragment_first() {
7496        // Cascade pin: the fragment-`#` arm and the `%` arm are both
7497        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
7498        // so the byte that appears first in the value's byte order
7499        // wins. A `:repo "https://github.com/p/x#sec%20tail"` carries
7500        // both `#` and `%`; the `#` byte appears first, so the
7501        // fragment-`#` arm fires, surfacing the more self-locating
7502        // diagnostic on the byte the author pasted earliest in the URL.
7503        let d = dep_with_fonte(DepSource::Git {
7504            repo: "https://github.com/pleme-io/caixa-teia#sec%20tail".into(),
7505            tag: Some("v0.1.0".into()),
7506            rev: None,
7507            branch: None,
7508        });
7509        let err = d.validate().unwrap_err();
7510        let DepError::FonteRepoShape { reason, .. } = err else {
7511            panic!("expected FonteRepoShape, got other variant");
7512        };
7513        assert!(
7514            reason.contains("must not contain `#`"),
7515            "reason must surface the fragment-`#` arm (fires before percent when \
7516             `#` byte appears first in value), got {reason:?}"
7517        );
7518    }
7519
7520    #[test]
7521    fn fonte_repo_equals_fires_before_percent_when_equals_first() {
7522        // Cascade pin: the equals-`=` arm (the immediate-predecessor
7523        // byte-class arm, acf99af) and the `%` arm are both per-byte
7524        // arms inside the same `for &b in s.as_bytes()` loop, so the
7525        // byte that appears first in the value's byte order wins.
7526        // A `:repo "github:p/x=mid%20tail"` carries both `=` and `%`;
7527        // the `=` byte appears first, so the equals arm fires,
7528        // surfacing the more self-locating diagnostic on the byte the
7529        // author pasted earliest in the URL. Pins the natural-order
7530        // cascade so a future reorder of the per-byte arms surfaces
7531        // here — `%` is the most recent byte-class arm, so the
7532        // cascade-pin sweep extends to cover the immediately prior
7533        // `=` byte arm firing first when ordered ahead of `%` in the
7534        // value.
7535        let d = dep_with_fonte(DepSource::Git {
7536            repo: "github:pleme-io/caixa-teia=mid%20tail".into(),
7537            tag: Some("v0.1.0".into()),
7538            rev: None,
7539            branch: None,
7540        });
7541        let err = d.validate().unwrap_err();
7542        let DepError::FonteRepoShape { reason, .. } = err else {
7543            panic!("expected FonteRepoShape, got other variant");
7544        };
7545        assert!(
7546            reason.contains("must not contain `=`"),
7547            "reason must surface the equals arm (fires before percent when `=` byte \
7548             appears first in value), got {reason:?}"
7549        );
7550    }
7551
7552    #[test]
7553    fn validate_rejects_git_fonte_with_repo_carrying_caret_history_substitution() {
7554        // The fail-before-pass-after pin for the canonical paste-from-
7555        // shell-history footgun on `:repo`. An author copies a
7556        // `git clone <url>` line from their terminal followed by a
7557        // bash / ksh / zsh `^typo^fix^` quick-edit-and-rerun shell-
7558        // history shorthand (the `^old^new^` form re-runs the prior
7559        // history entry with the first `old` substituted by `new`,
7560        // bash's default behavior on interactive sessions with
7561        // `set -o histexpand`), forgetting to trim the trailing
7562        // `^...^...` shell-history fragment from the URL value. The
7563        // `^` byte sits in the RFC 3986 §2 'unwise' set (peer with
7564        // `{`, `}`, `|`, `\\` — the strictest of the §2 reserved
7565        // classes), the WHATWG URL spec's 'fragment percent-encode
7566        // set' maps `^` → `%5E` on the wire, so the byte rides
7567        // verbatim into the lacre's per-dep content-address but
7568        // libcurl re-encodes it to `%5E` at `git clone` time — the
7569        // classic render-determinism violation on the same axis the
7570        // peer `%`, `=`, `,`, `!`, `'`, `"`, `(`, `)`, `*`, `$`,
7571        // `&`, `;`, `|`, backtick, `<`, `>`, `{`, `}`, `\\`, `?`,
7572        // `#` arms close.
7573        let d = dep_with_fonte(DepSource::Git {
7574            repo: "https://github.com/pleme-io/caixa-teia^typo^fix".into(),
7575            tag: Some("v0.1.0".into()),
7576            rev: None,
7577            branch: None,
7578        });
7579        let err = d.validate().unwrap_err();
7580        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7581            panic!("expected FonteRepoShape, got other variant");
7582        };
7583        assert_eq!(nome, "caixa-teia");
7584        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia^typo^fix");
7585        assert!(
7586            reason.contains("must not contain `^`"),
7587            "reason must surface the caret-`^` arm on the paste-from-shell-history \
7588             shape, got {reason:?}"
7589        );
7590        assert!(
7591            reason.contains("history-substitution") || reason.contains("%5E"),
7592            "reason must name the shell-history-substitution / `%5E` wire-encoding \
7593             rationale, got {reason:?}"
7594        );
7595    }
7596
7597    #[test]
7598    fn validate_rejects_git_fonte_with_repo_carrying_caret_regex_anchor() {
7599        // The symmetric paste-from-doc-grep-pipeline footgun: an
7600        // author writes `:repo "github:p/^archived"` after copying a
7601        // `grep '^archived'` regex-anchor / negation idiom from a
7602        // doc / README quick-listing snippet, expecting the substrate
7603        // to coerce it to a literal repo name. The byte rides
7604        // verbatim into the lacre's per-dep content-address and
7605        // diverges from the byte-identical literal `archived` form
7606        // every other author authored — the canonical render-
7607        // determinism violation pin on the second footgun shape the
7608        // caret-`^` arm closes.
7609        let d = dep_with_fonte(DepSource::Git {
7610            repo: "github:pleme-io/^archived".into(),
7611            tag: Some("v0.1.0".into()),
7612            rev: None,
7613            branch: None,
7614        });
7615        let err = d.validate().unwrap_err();
7616        let DepError::FonteRepoShape { reason, .. } = err else {
7617            panic!("expected FonteRepoShape, got other variant");
7618        };
7619        assert!(
7620            reason.contains("must not contain `^`"),
7621            "reason must surface the caret-`^` arm on the regex-anchor shape, \
7622             got {reason:?}"
7623        );
7624        assert!(
7625            reason.contains("render-determinism") || reason.contains("BLAKE3"),
7626            "reason must name the render-determinism / BLAKE3-closure rationale, \
7627             got {reason:?}"
7628        );
7629    }
7630
7631    #[test]
7632    fn fonte_repo_percent_fires_before_caret_when_percent_first() {
7633        // Cascade pin: the `%` arm (the immediate-predecessor byte-
7634        // class arm, a323db8) and the `^` arm are both per-byte arms
7635        // inside the same `for &b in s.as_bytes()` loop, so the byte
7636        // that appears first in the value's byte order wins. A
7637        // `:repo "https://github.com/p/x%20mid^tail"` carries both
7638        // `%` and `^`; the `%` byte appears first, so the percent
7639        // arm fires, surfacing the more self-locating diagnostic on
7640        // the byte the author pasted earliest in the URL. Pins the
7641        // natural-order cascade so a future reorder of the per-byte
7642        // arms surfaces here — `^` is the most recent byte-class arm,
7643        // so the cascade-pin sweep extends to cover the immediately
7644        // prior `%` byte arm firing first when ordered ahead of `^`
7645        // in the value.
7646        let d = dep_with_fonte(DepSource::Git {
7647            repo: "https://github.com/pleme-io/caixa-teia%20mid^tail".into(),
7648            tag: Some("v0.1.0".into()),
7649            rev: None,
7650            branch: None,
7651        });
7652        let err = d.validate().unwrap_err();
7653        let DepError::FonteRepoShape { reason, .. } = err else {
7654            panic!("expected FonteRepoShape, got other variant");
7655        };
7656        assert!(
7657            reason.contains("must not contain `%`"),
7658            "reason must surface the percent arm (fires before caret when `%` byte \
7659             appears first in value), got {reason:?}"
7660        );
7661    }
7662
7663    #[test]
7664    fn validate_rejects_git_fonte_with_repo_missing_colon_separator() {
7665        // The "I dropped the scheme" footgun — `:repo "pleme-io/caixa-teia"`
7666        // (no `github:` prefix, no scheme). Every documented form
7667        // carries a `:` (`github:`, `https://`, `ssh://`, `git://`,
7668        // `file://`, or `git@host:path`); a bare `org/repo` is
7669        // ambiguous (`git clone` reads as a relative filesystem path
7670        // rather than the GitHub-shorthand expansion the author
7671        // probably intended) and the gate rejects the shape upstream.
7672        let d = dep_with_fonte(DepSource::Git {
7673            repo: "pleme-io/caixa-teia".into(),
7674            tag: Some("v0.1.0".into()),
7675            rev: None,
7676            branch: None,
7677        });
7678        let err = d.validate().unwrap_err();
7679        let DepError::FonteRepoShape { reason, .. } = err else {
7680            panic!("expected FonteRepoShape, got other variant");
7681        };
7682        assert!(
7683            reason.contains("must contain a `:`"),
7684            "reason must surface the missing-`:` arm, got {reason:?}"
7685        );
7686        assert!(
7687            reason.contains("github:"),
7688            "reason must name the canonical `github:` shorthand prefix, got {reason:?}"
7689        );
7690    }
7691
7692    #[test]
7693    fn validate_rejects_git_fonte_with_repo_leading_colon() {
7694        // The "empty scheme" footgun — `:repo ":foo"` has a zero-length
7695        // scheme that no git porcelain entry-point accepts. Pinned
7696        // separately from the missing-`:` arm because a value with a
7697        // leading `:` does technically contain a `:` separator; the
7698        // shape gate rejects on a dedicated arm so the diagnostic
7699        // names the specific footgun.
7700        let d = dep_with_fonte(DepSource::Git {
7701            repo: ":pleme-io/caixa-teia".into(),
7702            tag: Some("v0.1.0".into()),
7703            rev: None,
7704            branch: None,
7705        });
7706        let err = d.validate().unwrap_err();
7707        let DepError::FonteRepoShape { reason, .. } = err else {
7708            panic!("expected FonteRepoShape, got other variant");
7709        };
7710        assert!(
7711            reason.contains("must not start with `:`"),
7712            "reason must surface the leading-`:` arm, got {reason:?}"
7713        );
7714    }
7715
7716    #[test]
7717    fn validate_rejects_git_fonte_with_repo_too_long() {
7718        // The cap arm — a `:repo` value longer than
7719        // [`crate::render::GIT_REPO_URL_MAX_LEN`] (2048) bytes is
7720        // structurally untenable on every realistic landing site (the
7721        // resolver's `git clone` invocation, the future M4 CR
7722        // materializer's per-dep `repo:` axis); a value of that length
7723        // is almost certainly a paste-from-binary slug.
7724        let too_long = format!(
7725            "github:pleme-io/{}",
7726            "x".repeat(crate::render::GIT_REPO_URL_MAX_LEN)
7727        );
7728        let d = dep_with_fonte(DepSource::Git {
7729            repo: too_long.clone(),
7730            tag: Some("v0.1.0".into()),
7731            rev: None,
7732            branch: None,
7733        });
7734        let err = d.validate().unwrap_err();
7735        let DepError::FonteRepoShape { reason, .. } = err else {
7736            panic!("expected FonteRepoShape, got other variant");
7737        };
7738        assert!(
7739            reason.contains("2048"),
7740            "reason must name the cap, got {reason:?}"
7741        );
7742    }
7743
7744    #[test]
7745    fn validate_accepts_canonical_git_fonte_repo_shapes() {
7746        // The positive-control sweep: every documented author shape on
7747        // the `:fonte :repo` axis ([`crate::DepSource::Git`] doc comment)
7748        // must pass the value-shape gate. Pinned so a future tightening
7749        // (e.g. forbidding `http://` in favor of `https://`-only) surfaces
7750        // here as a structural decision. Each form is exercised with the
7751        // same canonical `:tag` pin so only the `:repo` axis varies.
7752        for repo in [
7753            // The pleme-io registry-shorthand convention — `github:org/repo`.
7754            "github:pleme-io/caixa-teia",
7755            // Other host-aliased shorthands (the resolver's pluggable
7756            // host-prefix table).
7757            "gitlab:pleme-io/caixa-teia",
7758            "codeberg:pleme-io/caixa-teia",
7759            "sourcehut:~pleme-io/caixa-teia",
7760            // Full HTTPS URL with and without `.git` suffix.
7761            "https://github.com/pleme-io/caixa-teia",
7762            "https://github.com/pleme-io/caixa-teia.git",
7763            // HTTP (rare; dev / mirror).
7764            "http://example.com/pleme-io/caixa-teia.git",
7765            // SSH URL.
7766            "ssh://git@github.com/pleme-io/caixa-teia.git",
7767            "ssh://git@git.example.com:2222/pleme-io/caixa-teia.git",
7768            // Scp-style SSH — the canonical `git@host:path` short form.
7769            "git@github.com:pleme-io/caixa-teia.git",
7770            "git@git.example.com:team/private.git",
7771            // Anonymous git protocol.
7772            "git://git.example.com/pleme-io/caixa-teia.git",
7773            // Local file URL (dev path).
7774            "file:///tmp/caixa-teia",
7775        ] {
7776            let d = dep_with_fonte(DepSource::Git {
7777                repo: repo.into(),
7778                tag: Some("v0.1.0".into()),
7779                rev: None,
7780                branch: None,
7781            });
7782            d.validate()
7783                .unwrap_or_else(|e| panic!("canonical repo {repo:?} must validate, got {e:?}"));
7784        }
7785    }
7786
7787    #[test]
7788    fn fonte_repo_empty_takes_precedence_over_shape() {
7789        // Order pin: the existing `FonteRepoEmpty` diagnostic (narrower
7790        // diagnostic; doesn't try to parse the URL shape) fires before
7791        // the new `FonteRepoShape` per-axis gate, so an empty `:repo`
7792        // keeps its narrower error message. Mirrors
7793        // `fonte_repo_empty_fires_before_pin_missing` (already pinned)
7794        // on the ordering layer.
7795        let d = dep_with_fonte(DepSource::Git {
7796            repo: String::new(),
7797            tag: Some("v0.1.0".into()),
7798            rev: None,
7799            branch: None,
7800        });
7801        let err = d.validate().unwrap_err();
7802        assert!(
7803            matches!(err, DepError::FonteRepoEmpty { .. }),
7804            "got {err:?}"
7805        );
7806    }
7807
7808    #[test]
7809    fn fonte_repo_shape_fires_before_pin_missing() {
7810        // Order pin: a malformed `:repo` value on a dep with no pin set
7811        // surfaces the `:repo` shape diagnostic (the more self-locating
7812        // axis — the `:repo` is the load-bearing identity of the source;
7813        // a missing pin is downstream from "do we even know the repo")
7814        // rather than collapsing onto the pin-missing diagnostic. The
7815        // shape gate runs inline before the pin enumeration in
7816        // `DepSource::validate`.
7817        let d = dep_with_fonte(DepSource::Git {
7818            repo: "pleme-io/caixa-teia".into(), // missing `:` separator
7819            tag: None,
7820            rev: None,
7821            branch: None,
7822        });
7823        let err = d.validate().unwrap_err();
7824        assert!(
7825            matches!(err, DepError::FonteRepoShape { .. }),
7826            "got {err:?}"
7827        );
7828    }
7829
7830    #[test]
7831    fn fonte_repo_shape_diagnostic_carries_offending_repo_verbatim() {
7832        // The diagnostic-shape pin: the error names the offending
7833        // `:repo` value verbatim plus a non-empty parser-shaped `reason`
7834        // so the author can grep their caixa.lisp without re-running
7835        // the build. Mirrors the diagnostic-shape sweep on every prior
7836        // value-shape gate (3f9d7a0, 6cbb900, c7d05ec, e70d213, be07fd5).
7837        let d = dep_with_fonte(DepSource::Git {
7838            repo: "pleme-io/caixa-teia".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 { nome, repo, reason } = err else {
7845            panic!("expected FonteRepoShape, got other variant");
7846        };
7847        assert_eq!(nome, "caixa-teia");
7848        assert_eq!(repo, "pleme-io/caixa-teia");
7849        assert!(
7850            !reason.is_empty(),
7851            "FonteRepoShape `reason` must carry the predicate's wording verbatim"
7852        );
7853    }
7854
7855    #[test]
7856    fn validate_rejects_git_fonte_with_no_pin() {
7857        // The fail-before-pass-after pin for the canonical
7858        // `(:tipo git :repo "github:pleme-io/x")` shape with no
7859        // :tag/:rev/:branch — until this gate landed the resolver's
7860        // ResolveError::MissingPin surfaced at fetch time, far from the
7861        // source caixa.lisp. The new gate moves the check to validate
7862        // time and names the offending dep.
7863        let d = dep_with_fonte(DepSource::Git {
7864            repo: "github:pleme-io/caixa-teia".into(),
7865            tag: None,
7866            rev: None,
7867            branch: None,
7868        });
7869        let err = d.validate().unwrap_err();
7870        assert!(
7871            matches!(err, DepError::FontePinMissing { ref nome } if nome == "caixa-teia"),
7872            "got {err:?}"
7873        );
7874    }
7875
7876    #[test]
7877    fn validate_rejects_git_fonte_with_ambiguous_tag_and_branch() {
7878        // The canonical "pin drift" footgun: an author writes
7879        // `:tag "v1"` and later adds `:branch "main"` without removing
7880        // the :tag, and the resolver silently picks :tag (precedence
7881        // :rev > :tag > :branch). The :branch was dropped with no
7882        // diagnostic. The gate now rejects multi-pin shapes so the
7883        // author makes the precedence explicit at the source.
7884        let d = dep_with_fonte(DepSource::Git {
7885            repo: "github:pleme-io/caixa-teia".into(),
7886            tag: Some("v0.1.0".into()),
7887            rev: None,
7888            branch: Some("main".into()),
7889        });
7890        let err = d.validate().unwrap_err();
7891        let DepError::FontePinAmbiguous { nome, pins } = err else {
7892            panic!("expected FontePinAmbiguous");
7893        };
7894        assert_eq!(nome, "caixa-teia");
7895        assert!(pins.contains(":tag"));
7896        assert!(pins.contains(":branch"));
7897        assert!(!pins.contains(":rev"));
7898    }
7899
7900    #[test]
7901    fn validate_rejects_git_fonte_with_ambiguous_tag_and_rev() {
7902        // Sibling arm of the pin-drift footgun: :tag + :rev set
7903        // simultaneously. Pinned separately so a future relaxation
7904        // that only catches the (:tag, :branch) pair surfaces here.
7905        let d = dep_with_fonte(DepSource::Git {
7906            repo: "github:pleme-io/caixa-teia".into(),
7907            tag: Some("v0.1.0".into()),
7908            rev: Some("c0ffee".into()),
7909            branch: None,
7910        });
7911        let err = d.validate().unwrap_err();
7912        let DepError::FontePinAmbiguous { nome, pins } = err else {
7913            panic!("expected FontePinAmbiguous");
7914        };
7915        assert_eq!(nome, "caixa-teia");
7916        assert!(pins.contains(":tag"));
7917        assert!(pins.contains(":rev"));
7918    }
7919
7920    #[test]
7921    fn validate_rejects_git_fonte_with_all_three_pins() {
7922        // The maximal ambiguity case — every pin axis set. Pinned so a
7923        // future relaxation that only catches pairs surfaces here. The
7924        // diagnostic must enumerate every offending axis so the author
7925        // sees the full set, not just the first match.
7926        let d = dep_with_fonte(DepSource::Git {
7927            repo: "github:pleme-io/caixa-teia".into(),
7928            tag: Some("v0.1.0".into()),
7929            rev: Some("c0ffee".into()),
7930            branch: Some("main".into()),
7931        });
7932        let err = d.validate().unwrap_err();
7933        let DepError::FontePinAmbiguous { nome, pins } = err else {
7934            panic!("expected FontePinAmbiguous");
7935        };
7936        assert_eq!(nome, "caixa-teia");
7937        assert!(pins.contains(":tag"));
7938        assert!(pins.contains(":rev"));
7939        assert!(pins.contains(":branch"));
7940    }
7941
7942    #[test]
7943    fn validate_rejects_git_fonte_with_empty_tag_pin() {
7944        // The empty-pin arm: exactly one pin axis is `Some(_)`, but its
7945        // inner string is empty. Distinct from FontePinMissing (where
7946        // every axis is None) — pinned separately so a future
7947        // tightening collapsing them surfaces here as a structural
7948        // decision.
7949        let d = dep_with_fonte(DepSource::Git {
7950            repo: "github:pleme-io/caixa-teia".into(),
7951            tag: Some(String::new()),
7952            rev: None,
7953            branch: None,
7954        });
7955        let err = d.validate().unwrap_err();
7956        let DepError::FontePinEmpty { nome, pin } = err else {
7957            panic!("expected FontePinEmpty");
7958        };
7959        assert_eq!(nome, "caixa-teia");
7960        assert_eq!(pin, ":tag");
7961    }
7962
7963    #[test]
7964    fn validate_rejects_git_fonte_with_empty_rev_pin() {
7965        // Sibling arm — the empty-pin diagnostic names which axis
7966        // carries the empty value, so the author's grep target is
7967        // unambiguous.
7968        let d = dep_with_fonte(DepSource::Git {
7969            repo: "github:pleme-io/caixa-teia".into(),
7970            tag: None,
7971            rev: Some(String::new()),
7972            branch: None,
7973        });
7974        let err = d.validate().unwrap_err();
7975        let DepError::FontePinEmpty { nome, pin } = err else {
7976            panic!("expected FontePinEmpty");
7977        };
7978        assert_eq!(nome, "caixa-teia");
7979        assert_eq!(pin, ":rev");
7980    }
7981
7982    #[test]
7983    fn validate_rejects_path_fonte_with_empty_caminho() {
7984        // The fail-before-pass-after pin for `(:tipo path :caminho "")`:
7985        // until this gate landed the resolver's
7986        // ResolveError::MissingPath surfaced with `path: PathBuf("")` at
7987        // fetch time — not actionable. The new gate moves the check to
7988        // validate time and names the offending dep.
7989        let d = dep_with_fonte(DepSource::Path {
7990            caminho: String::new(),
7991        });
7992        let err = d.validate().unwrap_err();
7993        assert!(
7994            matches!(err, DepError::FonteCaminhoEmpty { ref nome } if nome == "caixa-teia"),
7995            "got {err:?}"
7996        );
7997    }
7998
7999    #[test]
8000    fn validate_rejects_path_fonte_with_absolute_caminho() {
8001        // The fail-before-pass-after pin for the absolute-`:caminho`
8002        // shape: `(:tipo path :caminho "/home/me/work/caixa-teia")`.
8003        // Until this gate landed an absolute `:caminho` silently
8004        // passed validate; the lacre pipeline embedded the
8005        // host-specific filesystem path verbatim in its
8006        // content-address (`conteudo: format!("path:{caminho}")`,
8007        // caixa-resolver/src/resolve.rs:189), so the BLAKE3 closure
8008        // differed per machine — the build succeeded but two CI
8009        // runners with different `${HOME}` layouts emitted two
8010        // distinct lacres for the byte-identical caixa, silently
8011        // breaking the THEORY.md §V.2 render-determinism contract
8012        // far from the source caixa.lisp. The new gate moves the
8013        // check to validate time and names the offending dep +
8014        // caminho verbatim.
8015        let d = dep_with_fonte(DepSource::Path {
8016            caminho: "/home/me/work/caixa-teia".into(),
8017        });
8018        let err = d.validate().unwrap_err();
8019        let DepError::FonteCaminhoAbsolute { nome, caminho } = err else {
8020            panic!("expected FonteCaminhoAbsolute, got other variant");
8021        };
8022        assert_eq!(nome, "caixa-teia");
8023        assert_eq!(caminho, "/home/me/work/caixa-teia");
8024    }
8025
8026    #[test]
8027    fn validate_accepts_path_fonte_with_parent_escape_caminho() {
8028        // The canonical sibling-workspace dep form
8029        // (`:caminho "../caixa-teia"`) remains accepted. The
8030        // absolute-path gate above is specifically narrower than the
8031        // shared [`crate::render::is_sandboxed_relative_path`]
8032        // predicate (which additionally forbids `..` traversal): a
8033        // local-path dep's canonical author surface is the in-tree
8034        // sibling-workspace path, so a full sandboxed-relative-path
8035        // lift would structurally reject every legitimate path-fonte
8036        // dep. Pinned so a future tightening to the full predicate
8037        // surfaces here as a structural decision, not a silent break.
8038        let d = dep_with_fonte(DepSource::Path {
8039            caminho: "../caixa-teia".into(),
8040        });
8041        d.validate().unwrap();
8042    }
8043
8044    #[test]
8045    fn validate_accepts_path_fonte_with_deeply_nested_relative_caminho() {
8046        // A multi-segment relative `:caminho`
8047        // (`"vendor/forks/caixa-teia"`) remains accepted — the
8048        // absolute-path gate brackets the host-layout-leaking shape
8049        // at the leading-`/` boundary only; every relative shape past
8050        // the empty arm continues to pass. Pinned alongside the
8051        // `..`-traversal positive control so a future tightening
8052        // surfaces the full set of legitimate relative forms here
8053        // rather than at a downstream consumer.
8054        let d = dep_with_fonte(DepSource::Path {
8055            caminho: "vendor/forks/caixa-teia".into(),
8056        });
8057        d.validate().unwrap();
8058    }
8059
8060    #[test]
8061    fn validate_rejects_path_fonte_with_tilde_prefix_caminho() {
8062        // The fail-before-pass-after pin for the tilde-expansion
8063        // `:caminho` shape: `(:tipo path :caminho "~/work/caixa-teia")`.
8064        // Until this gate landed the b94fd83 absolute arm let `~/foo`
8065        // through (`Path::is_absolute` returns false on a leading `~`
8066        // — the tilde is a shell-expansion convention, not a POSIX
8067        // path component), so the lacre embedded the value verbatim
8068        // and the resolver folded it through `Path::join` without
8069        // expansion, looking for a literal `./~/work/caixa-teia`
8070        // subdirectory and failing at resolve time with a
8071        // `No such file or directory` error far from the source
8072        // caixa.lisp. The new gate moves the check to validate time
8073        // and names the offending dep + caminho verbatim.
8074        let d = dep_with_fonte(DepSource::Path {
8075            caminho: "~/work/caixa-teia".into(),
8076        });
8077        let err = d.validate().unwrap_err();
8078        let DepError::FonteCaminhoTildeExpansion { nome, caminho } = err else {
8079            panic!("expected FonteCaminhoTildeExpansion, got {err:?}");
8080        };
8081        assert_eq!(nome, "caixa-teia");
8082        assert_eq!(caminho, "~/work/caixa-teia");
8083    }
8084
8085    #[test]
8086    fn validate_rejects_path_fonte_with_bare_tilde_caminho() {
8087        // The bare `~` form (canonical "I meant `$HOME` and forgot
8088        // the rest"): both the leading-tilde arm catches it and the
8089        // canonical-user-tilde shell idiom (`~alice/dev/caixa-teia`)
8090        // sweeps through the same arm. Pinned both to ensure the
8091        // gate doesn't narrow to `~/` only.
8092        for s in ["~", "~alice/dev/caixa-teia", "~/", "~root/work"] {
8093            let d = dep_with_fonte(DepSource::Path { caminho: s.into() });
8094            let err = d.validate().unwrap_err();
8095            assert!(
8096                matches!(err, DepError::FonteCaminhoTildeExpansion { .. }),
8097                "{s:?} → {err:?}",
8098            );
8099        }
8100    }
8101
8102    #[test]
8103    fn validate_accepts_path_fonte_with_mid_path_tilde_caminho() {
8104        // The leading-`~` is the canonical shell-expansion footgun —
8105        // a tilde mid-path (`"../foo~bar/caixa-teia"` — the canonical
8106        // backup-file-suffix idiom) is a legitimate POSIX path byte
8107        // with no shell-expansion semantic at the leading position.
8108        // Pinned so the gate doesn't widen to a full no-tilde-anywhere
8109        // sweep that would break every legitimate-shape backup-file
8110        // path.
8111        let d = dep_with_fonte(DepSource::Path {
8112            caminho: "../foo~bar/caixa-teia".into(),
8113        });
8114        d.validate().unwrap();
8115    }
8116
8117    #[test]
8118    fn fonte_caminho_empty_fires_before_tilde_expansion() {
8119        // Cascade pin: the empty arm structurally precedes the
8120        // tilde arm (the bytes `""` and `"~"` don't overlap), but the
8121        // pin establishes the precedence at the diagnostic-shape
8122        // level should a future codec round-trip ever produce a
8123        // probe-as-both value. Mirrors the peer
8124        // `fonte_repo_empty_fires_before_pin_missing` cascade
8125        // discipline.
8126        let d = dep_with_fonte(DepSource::Path {
8127            caminho: String::new(),
8128        });
8129        let err = d.validate().unwrap_err();
8130        assert!(
8131            matches!(err, DepError::FonteCaminhoEmpty { .. }),
8132            "got {err:?}",
8133        );
8134    }
8135
8136    #[test]
8137    fn fonte_caminho_tilde_diagnostic_carries_offending_dep_and_caminho() {
8138        // Diagnostic-shape pin (peer with
8139        // `validate_rejects_path_fonte_with_absolute_caminho`'s
8140        // payload assertion): the error's Display surfaces both the
8141        // offending `:nome` and the offending `:caminho` verbatim
8142        // so a `feira lint` run can render the diagnostic without
8143        // re-parsing.
8144        let d = dep_with_fonte(DepSource::Path {
8145            caminho: "~alice/dev/caixa-teia".into(),
8146        });
8147        let rendered = d.validate().unwrap_err().to_string();
8148        assert!(
8149            rendered.contains("caixa-teia"),
8150            "diagnostic must name the offending dep: {rendered}",
8151        );
8152        assert!(
8153            rendered.contains("~alice/dev/caixa-teia"),
8154            "diagnostic must quote the offending caminho: {rendered}",
8155        );
8156        assert!(
8157            rendered.contains('~'),
8158            "diagnostic must reference the tilde footgun: {rendered}",
8159        );
8160    }
8161
8162    #[test]
8163    fn validate_rejects_path_fonte_with_dollar_prefix_caminho() {
8164        // The fail-before-pass-after pin for the shell-variable-
8165        // expansion `:caminho` shape: `(:tipo path :caminho
8166        // "$HOME/work/caixa-teia")`. Until this gate landed the
8167        // b94fd83 absolute arm + the a5c248e tilde arm both let
8168        // `$HOME/foo` through (`Path::is_absolute` returns false on
8169        // a leading `$` — the `$` is a shell convention, not a POSIX
8170        // path component; `starts_with('~')` returns false too), so
8171        // the lacre embedded the value verbatim and the resolver
8172        // folded it through `Path::join` without `$`-expansion,
8173        // looking for a literal `./$HOME/work/caixa-teia`
8174        // subdirectory and failing at resolve time with a
8175        // `No such file or directory` error far from the source
8176        // caixa.lisp. The new gate moves the check to validate time
8177        // and names the offending dep + caminho verbatim.
8178        let d = dep_with_fonte(DepSource::Path {
8179            caminho: "$HOME/work/caixa-teia".into(),
8180        });
8181        let err = d.validate().unwrap_err();
8182        let DepError::FonteCaminhoVarExpansion { nome, caminho } = err else {
8183            panic!("expected FonteCaminhoVarExpansion, got {err:?}");
8184        };
8185        assert_eq!(nome, "caixa-teia");
8186        assert_eq!(caminho, "$HOME/work/caixa-teia");
8187    }
8188
8189    #[test]
8190    fn validate_rejects_path_fonte_with_dollar_brace_prefix_caminho() {
8191        // Sweep over every leading-`$` shape: the `${VAR}`-braced
8192        // form (canonical "paste-from-CI-manifest" footgun every
8193        // GitHub Actions / GitLab CI / Drone manifest carries on
8194        // `${WORKSPACE}`), the XDG idiom (`$XDG_CONFIG_HOME/caixa`,
8195        // canonical "I'm referencing a per-user config dir"),
8196        // and the bare `$` (canonical "I meant `$HOME` and forgot
8197        // the rest"). All shapes route through the same gate's
8198        // byte check. Pinned so the gate doesn't narrow to a
8199        // single shape (e.g. `$HOME/` only).
8200        for s in [
8201            "${HOME}/work/caixa-teia",
8202            "${WORKSPACE}/caixa-teia",
8203            "$XDG_CONFIG_HOME/caixa",
8204            "$",
8205        ] {
8206            let d = dep_with_fonte(DepSource::Path { caminho: s.into() });
8207            let err = d.validate().unwrap_err();
8208            assert!(
8209                matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
8210                "{s:?} → {err:?}",
8211            );
8212        }
8213    }
8214
8215    #[test]
8216    fn validate_rejects_path_fonte_with_mid_path_dollar_caminho() {
8217        // The `$` byte is the canonical shell-variable-expansion /
8218        // command-substitution / arithmetic-expansion sentinel and
8219        // is rejected at *every* position on the `:caminho` axis: the
8220        // leading arm surfaces `FonteCaminhoVarExpansion`, the
8221        // embedded arm surfaces `FonteCaminhoShellVariableExpansion`
8222        // (6620f39). Pinned so a future arm doesn't narrow the gate
8223        // back to the leading position and re-open the paste-from-
8224        // shell-one-liner `"../foo$HOME/bar"` / paste-from-CI-
8225        // manifest `"../foo${WORKSPACE}/bar"` / paste-from-shell-
8226        // prompt `"../foo$(whoami)/bar"` cross-idiom-leak surface on
8227        // the lacre content-address (`path:{caminho}`,
8228        // caixa-resolver/src/resolve.rs:189).
8229        let d = dep_with_fonte(DepSource::Path {
8230            caminho: "../foo$bar/caixa-teia".into(),
8231        });
8232        let err = d.validate().unwrap_err();
8233        assert!(
8234            matches!(
8235                err,
8236                DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
8237            ),
8238            "got {err:?}",
8239        );
8240    }
8241
8242    #[test]
8243    fn fonte_caminho_tilde_fires_before_var_expansion() {
8244        // Cascade pin: the tilde arm structurally precedes the var
8245        // arm (the bytes `~` and `$` don't overlap at the leading
8246        // position), but the pin establishes the precedence at the
8247        // diagnostic-shape level should a future codec round-trip
8248        // ever produce a probe-as-both value. Mirrors the peer
8249        // `fonte_caminho_empty_fires_before_tilde_expansion` cascade
8250        // discipline on the immediate-predecessor arm.
8251        let d = dep_with_fonte(DepSource::Path {
8252            caminho: "~/work/caixa-teia".into(),
8253        });
8254        let err = d.validate().unwrap_err();
8255        assert!(
8256            matches!(err, DepError::FonteCaminhoTildeExpansion { .. }),
8257            "got {err:?}",
8258        );
8259    }
8260
8261    #[test]
8262    fn fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho() {
8263        // Diagnostic-shape pin (peer with
8264        // `fonte_caminho_tilde_diagnostic_carries_offending_dep_and_caminho`'s
8265        // payload assertion on the immediate-predecessor arm): the
8266        // error's Display surfaces both the offending `:nome` and
8267        // the offending `:caminho` verbatim plus the `$` footgun
8268        // character itself so a `feira lint` run can render the
8269        // diagnostic without re-parsing.
8270        let d = dep_with_fonte(DepSource::Path {
8271            caminho: "${WORKSPACE}/caixa-teia".into(),
8272        });
8273        let rendered = d.validate().unwrap_err().to_string();
8274        assert!(
8275            rendered.contains("caixa-teia"),
8276            "diagnostic must name the offending dep: {rendered}",
8277        );
8278        assert!(
8279            rendered.contains("${WORKSPACE}/caixa-teia"),
8280            "diagnostic must quote the offending caminho: {rendered}",
8281        );
8282        assert!(
8283            rendered.contains('$'),
8284            "diagnostic must reference the dollar footgun: {rendered}",
8285        );
8286    }
8287
8288    #[test]
8289    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_nul() {
8290        // The fail-before-pass-after pin for the load-bearing NUL byte:
8291        // POSIX paths cannot contain `0x00` (every `std::fs` syscall
8292        // routes the path through `CString::new` which fails with
8293        // `NulError`); until this gate landed a `:caminho
8294        // "../caixa\0teia"` silently passed validate, the lacre
8295        // pipeline embedded the value verbatim, and the failure
8296        // surfaced at the resolver's `Path::join` → `CString::new`
8297        // boundary with a non-self-locating `NulError` far from the
8298        // source caixa.lisp. The new gate moves the check to validate
8299        // time and names the offending dep + caminho + offending byte
8300        // verbatim.
8301        let d = dep_with_fonte(DepSource::Path {
8302            caminho: "../caixa\0teia".into(),
8303        });
8304        let err = d.validate().unwrap_err();
8305        let DepError::FonteCaminhoControlChar {
8306            nome,
8307            caminho,
8308            byte,
8309        } = err
8310        else {
8311            panic!("expected FonteCaminhoControlChar, got {err:?}");
8312        };
8313        assert_eq!(nome, "caixa-teia");
8314        assert_eq!(caminho, "../caixa\0teia");
8315        assert_eq!(byte, 0x00);
8316    }
8317
8318    #[test]
8319    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_newline() {
8320        // The canonical paste-from-multiline-doc footgun on `:caminho`
8321        // — author copies `"../caixa-teia\n"` (trailing newline) out
8322        // of a multi-line code-fence or, worse, a `:caminho
8323        // "../caixa-teia\nrm -rf /"` value (CRLF-at-subprocess-argument
8324        // injection sibling on the path axis the `is_git_repo_url`
8325        // control-char arm already closes on `:repo`). Pinned
8326        // separately from the NUL arm so a future relaxation that
8327        // catches one but not the other surfaces here.
8328        let d = dep_with_fonte(DepSource::Path {
8329            caminho: "../caixa-teia\n".into(),
8330        });
8331        let err = d.validate().unwrap_err();
8332        let DepError::FonteCaminhoControlChar { byte, .. } = err else {
8333            panic!("expected FonteCaminhoControlChar, got {err:?}");
8334        };
8335        assert_eq!(byte, 0x0A);
8336    }
8337
8338    #[test]
8339    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_carriage_return() {
8340        // The CRLF sibling of the LF arm — Windows-line-ending
8341        // paste-from-multiline-doc on a `\r\n`-terminated buffer
8342        // leaves a stray `\r` mid-string after the LF strip. Pinned
8343        // separately from the LF arm so a future relaxation that
8344        // only catches LF surfaces here.
8345        let d = dep_with_fonte(DepSource::Path {
8346            caminho: "../caixa-teia\r".into(),
8347        });
8348        let err = d.validate().unwrap_err();
8349        let DepError::FonteCaminhoControlChar { byte, .. } = err else {
8350            panic!("expected FonteCaminhoControlChar, got {err:?}");
8351        };
8352        assert_eq!(byte, 0x0D);
8353    }
8354
8355    #[test]
8356    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_tab() {
8357        // The canonical paste-from-aligned-table footgun — a `\t`
8358        // mid-`:caminho` is invisible in most editors but rides
8359        // through the lacre's content-address verbatim, so two
8360        // paste-from-distinct-tables (one editor strips tabs, one
8361        // preserves them) yield divergent lacres for the byte-
8362        // identical-looking caixa. Pinned separately from the
8363        // whitespace-shaped LF/CR arms so a future relaxation that
8364        // narrows to line-terminator-only surfaces here.
8365        let d = dep_with_fonte(DepSource::Path {
8366            caminho: "../caixa\tteia".into(),
8367        });
8368        let err = d.validate().unwrap_err();
8369        let DepError::FonteCaminhoControlChar { byte, .. } = err else {
8370            panic!("expected FonteCaminhoControlChar, got {err:?}");
8371        };
8372        assert_eq!(byte, 0x09);
8373    }
8374
8375    #[test]
8376    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_del() {
8377        // The DEL byte (`0x7F`) closes the upper-end paste-from-
8378        // binary-blob footgun — the gate's contract is `b < 0x20 ||
8379        // b == 0x7F`, matching the `is_git_repo_url` /
8380        // `is_git_ref_name` predicates' control-char arms. Pinned
8381        // separately from the lower-range arms so a future narrowing
8382        // to `< 0x20` only surfaces here.
8383        let d = dep_with_fonte(DepSource::Path {
8384            caminho: "../caixa\x7fteia".into(),
8385        });
8386        let err = d.validate().unwrap_err();
8387        let DepError::FonteCaminhoControlChar { byte, .. } = err else {
8388            panic!("expected FonteCaminhoControlChar, got {err:?}");
8389        };
8390        assert_eq!(byte, 0x7F);
8391    }
8392
8393    #[test]
8394    fn validate_accepts_path_fonte_with_caminho_carrying_high_bit_utf8() {
8395        // The control-byte arm targets `0x00..=0x1F` + `0x7F` only —
8396        // high-bit / non-ASCII UTF-8 bytes are not gated. POSIX paths
8397        // are opaque byte sequences and UTF-8 multi-byte sequences
8398        // are a legitimate filename shape (the `café-teia/foo` idiom).
8399        // Pinned so the gate doesn't widen to a full ASCII-only sweep
8400        // that would break every legitimate-shape UTF-8 path.
8401        let d = dep_with_fonte(DepSource::Path {
8402            caminho: "../café-teia/foo".into(),
8403        });
8404        d.validate().unwrap();
8405    }
8406
8407    #[test]
8408    fn fonte_caminho_var_fires_before_control_char() {
8409        // Cascade pin: the var-expansion arm structurally precedes the
8410        // control-char arm. A value like `"$\n"` probes positive on
8411        // both arms (`starts_with('$')` and contains LF), but the
8412        // narrower leading-byte diagnostic (`FonteCaminhoVarExpansion`)
8413        // wins so the author sees the more self-locating shell-
8414        // expansion arm first. Mirrors the
8415        // `fonte_caminho_tilde_fires_before_var_expansion` cascade
8416        // discipline on the immediate-predecessor arm.
8417        let d = dep_with_fonte(DepSource::Path {
8418            caminho: "$HOME\n".into(),
8419        });
8420        let err = d.validate().unwrap_err();
8421        assert!(
8422            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
8423            "got {err:?}",
8424        );
8425    }
8426
8427    #[test]
8428    fn validate_rejects_path_fonte_with_leading_space_caminho() {
8429        // The fail-before-pass-after pin for the leading ASCII space
8430        // `:caminho` shape: `(:tipo path :caminho " ../caixa-teia")`.
8431        // Until this gate landed the b94fd83 absolute arm + the a5c248e
8432        // tilde arm + the f4efe9c var arm + the d624c8d control-byte arm
8433        // all let `" ../caixa-teia"` through: `Path::is_absolute` returns
8434        // false on a leading space (the leading byte is `0x20`, not `0x2F`),
8435        // `starts_with('~')` / `starts_with('$')` return false, and `0x20`
8436        // is not in the `0x00..=0x1F` plus `0x7F` control-byte set (the
8437        // four ASCII whitespace bytes `0x09` tab, `0x0A` LF, `0x0D` CR
8438        // are caught, but the most common whitespace `0x20` space is
8439        // not). The lacre embedded the value verbatim and the resolver
8440        // folded it through `Path::join` looking for a literal `./ ../
8441        // caixa-teia` subdirectory and failing at resolve time with a
8442        // non-self-locating `No such file or directory` error far from
8443        // the source caixa.lisp. The new gate moves the check to
8444        // validate time and names the offending dep + caminho verbatim.
8445        let d = dep_with_fonte(DepSource::Path {
8446            caminho: " ../caixa-teia".into(),
8447        });
8448        let err = d.validate().unwrap_err();
8449        let DepError::FonteCaminhoLeadingWhitespace { nome, caminho } = err else {
8450            panic!("expected FonteCaminhoLeadingWhitespace, got {err:?}");
8451        };
8452        assert_eq!(nome, "caixa-teia");
8453        assert_eq!(caminho, " ../caixa-teia");
8454    }
8455
8456    #[test]
8457    fn validate_rejects_path_fonte_with_multiple_leading_spaces_caminho() {
8458        // The aligned-doc paste footgun sweep: more than one leading
8459        // space (`"   ../caixa-teia"` — the canonical "I selected the
8460        // aligned column from a four-`:fonte`-entry `:deps` block"
8461        // paste) routes through the same gate's `starts_with(' ')`
8462        // byte check. Pinned so the gate doesn't narrow to a
8463        // single-space prefix.
8464        let d = dep_with_fonte(DepSource::Path {
8465            caminho: "   ../caixa-teia".into(),
8466        });
8467        let err = d.validate().unwrap_err();
8468        assert!(
8469            matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
8470            "got {err:?}",
8471        );
8472    }
8473
8474    #[test]
8475    fn validate_accepts_path_fonte_with_mid_path_space_caminho() {
8476        // The leading-space is the canonical paste-from-aligned-doc
8477        // footgun — a space mid-path (`"../my dir/caixa-teia"` — the
8478        // canonical "I have a directory with a space in its name"
8479        // idiom; ASCII `0x20` is a valid POSIX filename byte) is a
8480        // legitimate path with no whitespace-leak semantic at the
8481        // non-leading position. Pinned so the gate doesn't widen to a
8482        // full no-space-anywhere sweep that would break every
8483        // legitimate-shape space-in-filename path.
8484        let d = dep_with_fonte(DepSource::Path {
8485            caminho: "../my dir/caixa-teia".into(),
8486        });
8487        d.validate().unwrap();
8488    }
8489
8490    #[test]
8491    fn fonte_caminho_var_fires_before_leading_whitespace() {
8492        // Cascade pin: the var-expansion arm structurally precedes the
8493        // leading-whitespace arm. A value like `"$ "` would probe positive
8494        // on var (`starts_with('$')`) but the leading-byte arms walk
8495        // left-to-right so the var arm fires on the leading `$` before
8496        // the leading-whitespace arm probes. Mirrors the
8497        // `fonte_caminho_tilde_fires_before_var_expansion` cascade
8498        // discipline on the immediate-predecessor arms.
8499        let d = dep_with_fonte(DepSource::Path {
8500            caminho: "$VAR".into(),
8501        });
8502        let err = d.validate().unwrap_err();
8503        assert!(
8504            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
8505            "got {err:?}",
8506        );
8507    }
8508
8509    #[test]
8510    fn fonte_caminho_leading_whitespace_fires_before_control_char() {
8511        // Cascade pin: the leading-whitespace arm structurally precedes
8512        // the control-char arm. A value like `" ../foo\n"` probes
8513        // positive on both (starts with space AND contains LF), but
8514        // the narrower leading-byte diagnostic
8515        // (`FonteCaminhoLeadingWhitespace`) wins so the author sees the
8516        // more self-locating paste-from-aligned-doc arm first. Mirrors
8517        // the `fonte_caminho_var_fires_before_control_char` cascade
8518        // discipline on the immediate-predecessor arm.
8519        let d = dep_with_fonte(DepSource::Path {
8520            caminho: " ../foo\n".into(),
8521        });
8522        let err = d.validate().unwrap_err();
8523        assert!(
8524            matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
8525            "got {err:?}",
8526        );
8527    }
8528
8529    #[test]
8530    fn fonte_caminho_leading_whitespace_diagnostic_carries_offending_dep_and_caminho() {
8531        // Diagnostic-shape pin (peer with
8532        // `fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho`'s
8533        // payload assertion on the immediate-predecessor arm): the
8534        // error's Display surfaces both the offending `:nome` and the
8535        // offending `:caminho` verbatim, so a `feira lint` run can
8536        // render the diagnostic without re-parsing and the author can
8537        // grep their caixa.lisp for `:caminho "<value>"` and fix it in
8538        // one edit.
8539        let d = dep_with_fonte(DepSource::Path {
8540            caminho: " ../caixa-teia".into(),
8541        });
8542        let rendered = d.validate().unwrap_err().to_string();
8543        assert!(
8544            rendered.contains("caixa-teia"),
8545            "diagnostic must name the offending dep: {rendered}",
8546        );
8547        assert!(
8548            rendered.contains(" ../caixa-teia"),
8549            "diagnostic must quote the offending caminho: {rendered}",
8550        );
8551        assert!(
8552            rendered.contains("space"),
8553            "diagnostic must name the space footgun: {rendered}",
8554        );
8555    }
8556
8557    #[test]
8558    fn fonte_caminho_absolute_fires_before_control_char() {
8559        // Cascade pin on the sibling leading-byte arm: a leading `/`
8560        // value with embedded control byte (`"/etc/passwd\n"`) routes
8561        // through `FonteCaminhoAbsolute` not `FonteCaminhoControlChar`
8562        // — the host-layout-leak diagnostic is the load-bearing axis,
8563        // the control byte is the secondary observation. Same precedence
8564        // logic on every prior leading-byte arm.
8565        let d = dep_with_fonte(DepSource::Path {
8566            caminho: "/etc/passwd\n".into(),
8567        });
8568        let err = d.validate().unwrap_err();
8569        assert!(
8570            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
8571            "got {err:?}",
8572        );
8573    }
8574
8575    #[test]
8576    fn validate_rejects_path_fonte_with_leading_hyphen_caminho() {
8577        // The fail-before-pass-after pin for the leading-`-` CLI-arg-
8578        // injection `:caminho` shape sweep. Until this gate landed
8579        // every prior leading-byte arm passed a leading-`-` value
8580        // through: `Path::is_absolute` returns false on `-` (the
8581        // leading byte is `0x2D`, not `0x2F`), `starts_with('~')` /
8582        // `starts_with('$')` / `starts_with(' ')` all return false,
8583        // and `0x2D` sits outside the control-byte set. The lacre
8584        // embedded the value verbatim and the resolver folded it
8585        // through `Path::join` looking for a literal `./-rf` /
8586        // `./-C` / `./--upload-pack=…` subdirectory; the failure at
8587        // `Path::join` time is non-self-locating but harmless, while
8588        // the failure at every downstream `git -C {caminho}` /
8589        // `terraform -chdir={caminho}` / `find {caminho}` shell-out
8590        // is arbitrary-CLI-arg-injection because none of those
8591        // porcelains carry a `--` argument-list terminator between
8592        // the flag block and the path argument. The new arm moves the
8593        // rejection to `Caixa::from_lisp` boundary time and names
8594        // the offending dep + caminho verbatim.
8595        //
8596        // Sweep spans the canonical CLI-arg-injection shapes matching
8597        // the peer sweep on the sibling `is_git_ref_name` /
8598        // `is_git_repo_url` axes: short-flag `-rf` (the `rm -rf` /
8599        // `find -rf` reinterpretation vector), `-C` (the `git -C`
8600        // change-directory-config-injection paste), long-flag
8601        // `--upload-pack=cat /etc/passwd` (the canonical
8602        // arbitrary-command-execution vector on every git porcelain
8603        // entry point), git-config-injection `--config=core.merge=ours`,
8604        // and the degenerate single-byte `-` value.
8605        for caminho in [
8606            "-rf",
8607            "-C",
8608            "--upload-pack=cat /etc/passwd",
8609            "--config=core.merge=ours",
8610            "-",
8611        ] {
8612            let d = dep_with_fonte(DepSource::Path {
8613                caminho: caminho.into(),
8614            });
8615            let err = d.validate().unwrap_err();
8616            let DepError::FonteCaminhoLeadingHyphen { nome, caminho: got } = err else {
8617                panic!("expected FonteCaminhoLeadingHyphen for {caminho:?}, got {err:?}");
8618            };
8619            assert_eq!(nome, "caixa-teia");
8620            assert_eq!(got, caminho);
8621        }
8622    }
8623
8624    #[test]
8625    fn validate_accepts_path_fonte_with_mid_path_hyphen_caminho() {
8626        // The leading-`-` is the canonical CLI-arg-injection footgun
8627        // — a `-` anywhere else in the path (`"../caixa-teia"` — the
8628        // canonical kebab-separator-between-alphanumeric-segments
8629        // shape every DNS-1123-shaped caixa name carries; `"../-hidden"`
8630        // — a mid-path segment starting with `-`, still a legitimate
8631        // POSIX filename byte at that non-leading position because the
8632        // subprocess reads the whole `{caminho}` value as one positional
8633        // argument, so only the very first byte of the composite path
8634        // string is at the CLI-arg-injection boundary) is a legitimate
8635        // path with no CLI-flag-reinterpretation semantic at the non-
8636        // leading position of the top-level value. Pinned so the gate
8637        // doesn't widen to a full no-`-`-anywhere sweep that would
8638        // break every legitimate-shape kebab-in-filename path (i.e.
8639        // essentially every sibling-workspace caixa dep).
8640        for caminho in [
8641            "../caixa-teia",
8642            "../caixa-teia/-hidden",
8643            "./my-lib",
8644            "../foo-bar/baz",
8645        ] {
8646            let d = dep_with_fonte(DepSource::Path {
8647                caminho: caminho.into(),
8648            });
8649            d.validate()
8650                .unwrap_or_else(|e| panic!("mid-path `-` caminho {caminho:?} must pass: {e:?}"));
8651        }
8652    }
8653
8654    #[test]
8655    fn fonte_caminho_leading_whitespace_fires_before_leading_hyphen() {
8656        // Cascade pin: the leading-whitespace arm structurally precedes
8657        // the leading-hyphen arm. A value like `" -rf"` probes positive
8658        // on both (leading space AND, one byte in, a `-` — though the
8659        // leading-hyphen arm probes only the very first byte so it
8660        // wouldn't fire on this value; the pin instead documents the
8661        // arm order on the more common "leading space then a hyphen"
8662        // paste-from-aligned-doc paste-flag-shell-one-liner idiom).
8663        // The narrower leading-space diagnostic (the paste-from-aligned-
8664        // doc footgun) wins so the author sees the more self-locating
8665        // whitespace arm first. Mirrors the
8666        // `fonte_caminho_var_fires_before_leading_whitespace` cascade
8667        // discipline on the immediate-predecessor arm.
8668        let d = dep_with_fonte(DepSource::Path {
8669            caminho: " -rf".into(),
8670        });
8671        let err = d.validate().unwrap_err();
8672        assert!(
8673            matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
8674            "got {err:?}",
8675        );
8676    }
8677
8678    #[test]
8679    fn fonte_caminho_leading_hyphen_fires_before_control_char() {
8680        // Cascade pin: the leading-hyphen arm structurally precedes
8681        // the control-char arm. A value like `"-rf\n"` probes positive
8682        // on both (starts with `-` AND contains LF), but the narrower
8683        // leading-byte diagnostic (`FonteCaminhoLeadingHyphen`) wins so
8684        // the author sees the more self-locating CLI-arg-injection arm
8685        // first. Mirrors the
8686        // `fonte_caminho_leading_whitespace_fires_before_control_char`
8687        // cascade discipline on the immediate-predecessor arm.
8688        let d = dep_with_fonte(DepSource::Path {
8689            caminho: "-rf\n".into(),
8690        });
8691        let err = d.validate().unwrap_err();
8692        assert!(
8693            matches!(err, DepError::FonteCaminhoLeadingHyphen { .. }),
8694            "got {err:?}",
8695        );
8696    }
8697
8698    #[test]
8699    fn fonte_caminho_leading_hyphen_diagnostic_carries_offending_dep_and_caminho() {
8700        // Diagnostic-shape pin (peer with
8701        // `fonte_caminho_leading_whitespace_diagnostic_carries_offending_dep_and_caminho`'s
8702        // payload assertion on the immediate-predecessor arm): the
8703        // error's Display surfaces both the offending `:nome` and the
8704        // offending `:caminho` verbatim plus the CLI-argument-injection
8705        // vocabulary, so a `feira lint` run can render the diagnostic
8706        // without re-parsing and the author can grep their caixa.lisp
8707        // for `:caminho "<value>"` and fix it in one edit.
8708        let d = dep_with_fonte(DepSource::Path {
8709            caminho: "--upload-pack=cat /etc/passwd".into(),
8710        });
8711        let rendered = d.validate().unwrap_err().to_string();
8712        assert!(
8713            rendered.contains("caixa-teia"),
8714            "diagnostic must name the offending dep: {rendered}",
8715        );
8716        assert!(
8717            rendered.contains("--upload-pack=cat /etc/passwd"),
8718            "diagnostic must quote the offending caminho: {rendered}",
8719        );
8720        assert!(
8721            rendered.contains("CLI-argument-injection"),
8722            "diagnostic must name the CLI-argument-injection vector: {rendered}",
8723        );
8724        assert!(
8725            rendered.contains("`-`"),
8726            "diagnostic must name the offending byte: {rendered}",
8727        );
8728    }
8729
8730    #[test]
8731    fn fonte_caminho_control_diagnostic_carries_offending_dep_caminho_byte() {
8732        // Diagnostic-shape pin (peer with
8733        // `fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho`'s
8734        // payload assertion on the immediate-predecessor arm): the
8735        // error's Display surfaces the offending `:nome`, the
8736        // offending `:caminho` verbatim, and the offending byte in
8737        // hex form (`0x09` for tab) so a `feira lint` run can render
8738        // the diagnostic without re-parsing.
8739        let d = dep_with_fonte(DepSource::Path {
8740            caminho: "../caixa\tteia".into(),
8741        });
8742        let rendered = d.validate().unwrap_err().to_string();
8743        assert!(
8744            rendered.contains("caixa-teia"),
8745            "diagnostic must name the offending dep: {rendered}",
8746        );
8747        assert!(
8748            rendered.contains("../caixa\tteia"),
8749            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
8750        );
8751        assert!(
8752            rendered.contains("0x09"),
8753            "diagnostic must name the offending byte in hex: {rendered:?}",
8754        );
8755    }
8756
8757    #[test]
8758    fn validate_rejects_path_fonte_with_caminho_carrying_backslash() {
8759        // The fail-before-pass-after pin for the canonical Windows-
8760        // path-separator paste footgun: an author who pastes a path
8761        // from Windows-Explorer's `Copy as path`, PowerShell's
8762        // `Get-Location`, or any CMD/Cygwin/MSYS shell prompt
8763        // produces `..\caixa-teia`-shape values that silently passed
8764        // every prior arm (`Path::is_absolute("..\\caixa-teia")` is
8765        // false; `\` is neither a leading-byte sentinel nor a
8766        // control byte). On POSIX resolvers the value rides through
8767        // `Path::join` as a literal directory name and fails at
8768        // resolve time with `No such file or directory`; on Windows
8769        // resolvers the value resolves to the parent's sibling — two
8770        // distinct directories for the byte-identical caixa.lisp.
8771        // The new arm moves the rejection to validate time and names
8772        // the offending dep + caminho verbatim.
8773        let d = dep_with_fonte(DepSource::Path {
8774            caminho: "..\\caixa-teia".into(),
8775        });
8776        let err = d.validate().unwrap_err();
8777        let DepError::FonteCaminhoBackslash { nome, caminho } = err else {
8778            panic!("expected FonteCaminhoBackslash, got {err:?}");
8779        };
8780        assert_eq!(nome, "caixa-teia");
8781        assert_eq!(caminho, "..\\caixa-teia");
8782    }
8783
8784    #[test]
8785    fn validate_rejects_path_fonte_with_caminho_carrying_windows_drive_letter() {
8786        // The Windows drive-letter paste shape (`C:\work\caixa-teia`
8787        // out of Explorer / `cd`-and-`pwd`-on-Windows). On POSIX
8788        // hosts `Path::is_absolute("C:\\work\\caixa-teia")` returns
8789        // false (POSIX absolute paths start with `/`, drive letters
8790        // are not a POSIX concept), so the b94fd83 absolute arm
8791        // doesn't fire; the value contains `\` bytes that this arm
8792        // now catches with the more self-locating Windows-path-
8793        // separator diagnostic. Pinned separately from the bare
8794        // `..\caixa-teia` shape so a future arm that targets only
8795        // leading-`..\` doesn't regress the drive-letter coverage.
8796        let d = dep_with_fonte(DepSource::Path {
8797            caminho: "C:\\work\\caixa-teia".into(),
8798        });
8799        let err = d.validate().unwrap_err();
8800        assert!(
8801            matches!(err, DepError::FonteCaminhoBackslash { .. }),
8802            "got {err:?}",
8803        );
8804    }
8805
8806    #[test]
8807    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_backslash() {
8808        // The trailing-`\` shape (`..\caixa-teia\` — the canonical
8809        // PowerShell tab-completion-on-a-directory append). Pinned
8810        // separately from the embedded-`\` shape so the gate's
8811        // contract is "any `\` anywhere", not "any `\` not at end".
8812        let d = dep_with_fonte(DepSource::Path {
8813            caminho: "..\\caixa-teia\\".into(),
8814        });
8815        let err = d.validate().unwrap_err();
8816        assert!(
8817            matches!(err, DepError::FonteCaminhoBackslash { .. }),
8818            "got {err:?}",
8819        );
8820    }
8821
8822    #[test]
8823    fn validate_accepts_path_fonte_with_caminho_carrying_legitimate_forward_slash() {
8824        // The positive-control pin: the gate targets `\` only,
8825        // never `/`. The canonical relative POSIX path
8826        // (`../caixa-teia/foo/bar`) must continue to validate cleanly
8827        // so legitimate nested-directory deps aren't broken. Pinned
8828        // so the gate doesn't accidentally widen to a "no path
8829        // separators at all" sweep.
8830        let d = dep_with_fonte(DepSource::Path {
8831            caminho: "../caixa-teia/foo/bar".into(),
8832        });
8833        d.validate().unwrap();
8834    }
8835
8836    #[test]
8837    fn fonte_caminho_control_char_fires_before_backslash() {
8838        // Cascade pin: the control-char arm structurally precedes the
8839        // backslash arm. A value like `"..\caixa\0teia"` probes
8840        // positive on both (`\` byte + NUL byte), but the control-
8841        // char diagnostic wins so the author sees the more self-
8842        // locating POSIX-syscall-rejected-byte diagnostic first
8843        // (NUL outright breaks `CString::new` at every `std::fs`
8844        // syscall boundary; the `\` divergence is the cross-OS-
8845        // separator axis). Mirrors the
8846        // `fonte_caminho_var_fires_before_control_char` cascade
8847        // discipline on the immediate-predecessor arm.
8848        let d = dep_with_fonte(DepSource::Path {
8849            caminho: "..\\caixa\0teia".into(),
8850        });
8851        let err = d.validate().unwrap_err();
8852        assert!(
8853            matches!(err, DepError::FonteCaminhoControlChar { .. }),
8854            "got {err:?}",
8855        );
8856    }
8857
8858    #[test]
8859    fn fonte_caminho_absolute_fires_before_backslash() {
8860        // Cascade pin on the load-bearing leading-byte arm: a leading
8861        // `/` value with embedded `\` (`/etc/passwd\foo`) routes
8862        // through `FonteCaminhoAbsolute` not `FonteCaminhoBackslash`
8863        // — the host-layout-leak diagnostic is the load-bearing
8864        // axis, the `\` byte is the secondary observation. Same
8865        // precedence logic as every prior leading-byte arm.
8866        let d = dep_with_fonte(DepSource::Path {
8867            caminho: "/etc/passwd\\foo".into(),
8868        });
8869        let err = d.validate().unwrap_err();
8870        assert!(
8871            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
8872            "got {err:?}",
8873        );
8874    }
8875
8876    #[test]
8877    fn fonte_caminho_var_fires_before_backslash() {
8878        // Cascade pin on the var-expansion arm: a leading-`$` value
8879        // with embedded `\` (`$WORKSPACE\caixa-teia` — the canonical
8880        // PowerShell-env-var paste-from-CI-manifest footgun) routes
8881        // through `FonteCaminhoVarExpansion` not `FonteCaminhoBackslash`.
8882        // The shell-expansion diagnostic is the more self-locating
8883        // axis since both the leading `$` and the embedded `\`
8884        // are Windows-shell artifacts but the `$` is the root-cause
8885        // surface (an author who removes the `$` is likely to leave
8886        // the `\` too).
8887        let d = dep_with_fonte(DepSource::Path {
8888            caminho: "$WORKSPACE\\caixa-teia".into(),
8889        });
8890        let err = d.validate().unwrap_err();
8891        assert!(
8892            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
8893            "got {err:?}",
8894        );
8895    }
8896
8897    #[test]
8898    fn fonte_caminho_backslash_diagnostic_carries_offending_dep_and_caminho() {
8899        // Diagnostic-shape pin (peer with the prior
8900        // `fonte_caminho_*_diagnostic_carries_*` payload assertions
8901        // on every preceding arm): the error's Display surfaces the
8902        // offending `:nome` and the offending `:caminho` verbatim
8903        // so a `feira lint` run can render the diagnostic without
8904        // re-parsing.
8905        let d = dep_with_fonte(DepSource::Path {
8906            caminho: "..\\caixa-teia".into(),
8907        });
8908        let rendered = d.validate().unwrap_err().to_string();
8909        assert!(
8910            rendered.contains("caixa-teia"),
8911            "diagnostic must name the offending dep: {rendered}",
8912        );
8913        assert!(
8914            rendered.contains("..\\caixa-teia"),
8915            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
8916        );
8917        assert!(
8918            rendered.contains('\\'),
8919            "diagnostic must reference the backslash footgun: {rendered:?}",
8920        );
8921    }
8922
8923    #[test]
8924    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_slash() {
8925        // The fail-before-pass-after pin for the canonical trailing-`/`
8926        // paste footgun: an author who shell-tab-completes a sibling
8927        // directory (every interactive shell — bash/zsh/fish/nushell —
8928        // appends `/` on tab-completing a directory) produces
8929        // `"../caixa-teia/"`-shape values that silently passed every
8930        // prior arm (the leading byte is `.`, no control bytes, no
8931        // backslash). `Path::join` resolves both shapes to the same
8932        // directory at the resolver, but the lacre embeds the value
8933        // verbatim and the BLAKE3 closures diverge across two
8934        // workstations whose authors differ only in tab-completion
8935        // habits.
8936        let d = dep_with_fonte(DepSource::Path {
8937            caminho: "../caixa-teia/".into(),
8938        });
8939        let err = d.validate().unwrap_err();
8940        let DepError::FonteCaminhoTrailingSlash { nome, caminho } = err else {
8941            panic!("expected FonteCaminhoTrailingSlash, got {err:?}");
8942        };
8943        assert_eq!(nome, "caixa-teia");
8944        assert_eq!(caminho, "../caixa-teia/");
8945    }
8946
8947    #[test]
8948    fn validate_rejects_path_fonte_with_caminho_carrying_bare_dot_slash() {
8949        // The `"./"` shape (the canonical "I meant the caixa.lisp's own
8950        // directory and tab-completed it" footgun). Pinned separately
8951        // from the canonical `"../caixa-teia/"` shape so the gate's
8952        // contract is "any trailing `/`", not "trailing `/` after a leaf
8953        // name".
8954        let d = dep_with_fonte(DepSource::Path {
8955            caminho: "./".into(),
8956        });
8957        let err = d.validate().unwrap_err();
8958        assert!(
8959            matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
8960            "got {err:?}",
8961        );
8962    }
8963
8964    #[test]
8965    fn validate_rejects_path_fonte_with_caminho_carrying_consecutive_trailing_slashes() {
8966        // The `"foo//"` shape (the canonical "I pasted from a CI manifest
8967        // that double-templated `${VAR}/` over an already-`/`-suffixed
8968        // path" footgun). The gate fires on the last byte being `/`
8969        // regardless of how many `/` precede it; the arm contract is
8970        // "the value ends with `/`", structurally.
8971        let d = dep_with_fonte(DepSource::Path {
8972            caminho: "../caixa-teia//".into(),
8973        });
8974        let err = d.validate().unwrap_err();
8975        assert!(
8976            matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
8977            "got {err:?}",
8978        );
8979    }
8980
8981    #[test]
8982    fn validate_rejects_path_fonte_with_caminho_carrying_dotdot_trailing_slash() {
8983        // The `"../"` shape (the canonical "I want the parent" tab-
8984        // completion footgun on a bare `..` path). Pinned separately so
8985        // the gate doesn't accidentally narrow to "trailing `/` only on
8986        // multi-segment paths".
8987        let d = dep_with_fonte(DepSource::Path {
8988            caminho: "../".into(),
8989        });
8990        let err = d.validate().unwrap_err();
8991        assert!(
8992            matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
8993            "got {err:?}",
8994        );
8995    }
8996
8997    #[test]
8998    fn validate_accepts_path_fonte_with_caminho_carrying_internal_slashes() {
8999        // The positive-control pin: the gate targets the trailing byte
9000        // only, never internal `/` separators. The canonical nested
9001        // relative POSIX path (`"../caixa-teia/foo/bar"`) must continue
9002        // to validate cleanly so legitimate deeply-nested deps aren't
9003        // broken. Pinned so the gate doesn't accidentally widen to a
9004        // "no `/` separators anywhere" sweep that would defeat the
9005        // entire path-fonte author surface.
9006        let d = dep_with_fonte(DepSource::Path {
9007            caminho: "../caixa-teia/foo/bar".into(),
9008        });
9009        d.validate().unwrap();
9010    }
9011
9012    #[test]
9013    fn validate_accepts_path_fonte_with_caminho_carrying_bare_dot() {
9014        // The positive-control pin on the degenerate single-`.` shape
9015        // (the canonical "the caixa.lisp's own directory" idiom). The
9016        // gate fires on the trailing byte being `/`, not on the path
9017        // being short, so `"."` (one byte, not `/`) must continue to
9018        // validate cleanly.
9019        let d = dep_with_fonte(DepSource::Path {
9020            caminho: ".".into(),
9021        });
9022        d.validate().unwrap();
9023    }
9024
9025    #[test]
9026    fn fonte_caminho_control_char_fires_before_trailing_slash() {
9027        // Cascade pin: the control-char arm structurally precedes the
9028        // trailing-slash arm. A value like `"../foo\n/"` ends in `/`
9029        // but the embedded LF (`0x0A`) is the load-bearing diagnostic
9030        // (control bytes are the paste-from-multiline-doc footgun the
9031        // d624c8d arm already closes). Mirrors the
9032        // `fonte_caminho_control_char_fires_before_backslash` cascade
9033        // discipline on the immediate-predecessor arm.
9034        let d = dep_with_fonte(DepSource::Path {
9035            caminho: "../foo\n/".into(),
9036        });
9037        let err = d.validate().unwrap_err();
9038        assert!(
9039            matches!(err, DepError::FonteCaminhoControlChar { .. }),
9040            "got {err:?}",
9041        );
9042    }
9043
9044    #[test]
9045    fn fonte_caminho_backslash_fires_before_trailing_slash() {
9046        // Cascade pin on the backslash arm: a value like `"..\foo/"`
9047        // ends in `/` but the embedded `\` is the load-bearing
9048        // diagnostic (the cross-host-OS-separator divergence vector
9049        // the 3a4e1d7 arm closes). Same precedence logic as the prior
9050        // narrower-diagnostic-first cascade.
9051        let d = dep_with_fonte(DepSource::Path {
9052            caminho: "..\\caixa-teia/".into(),
9053        });
9054        let err = d.validate().unwrap_err();
9055        assert!(
9056            matches!(err, DepError::FonteCaminhoBackslash { .. }),
9057            "got {err:?}",
9058        );
9059    }
9060
9061    #[test]
9062    fn fonte_caminho_absolute_fires_before_trailing_slash() {
9063        // Cascade pin on the load-bearing leading-byte arm: a leading
9064        // `/` value with a trailing `/` (`"/etc/passwd/"`) routes
9065        // through `FonteCaminhoAbsolute` not `FonteCaminhoTrailingSlash`
9066        // — the host-layout-leak diagnostic is the load-bearing axis,
9067        // the trailing `/` is the secondary observation. Same
9068        // precedence logic as every prior leading-byte arm.
9069        let d = dep_with_fonte(DepSource::Path {
9070            caminho: "/etc/passwd/".into(),
9071        });
9072        let err = d.validate().unwrap_err();
9073        assert!(
9074            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
9075            "got {err:?}",
9076        );
9077    }
9078
9079    #[test]
9080    fn fonte_caminho_trailing_slash_diagnostic_carries_offending_dep_and_caminho() {
9081        // Diagnostic-shape pin (peer with the prior
9082        // `fonte_caminho_*_diagnostic_carries_*` payload assertions on
9083        // every preceding arm): the error's Display surfaces the
9084        // offending `:nome` and the offending `:caminho` verbatim so a
9085        // `feira lint` run can render the diagnostic without re-parsing.
9086        let d = dep_with_fonte(DepSource::Path {
9087            caminho: "../caixa-teia/".into(),
9088        });
9089        let rendered = d.validate().unwrap_err().to_string();
9090        assert!(
9091            rendered.contains("caixa-teia"),
9092            "diagnostic must name the offending dep: {rendered}",
9093        );
9094        assert!(
9095            rendered.contains("../caixa-teia/"),
9096            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
9097        );
9098        assert!(
9099            rendered.contains("trailing"),
9100            "diagnostic must reference the trailing-slash footgun: {rendered:?}",
9101        );
9102    }
9103
9104    // -- :caminho shell-redirection metacharacter arm -----------------------
9105
9106    #[test]
9107    fn validate_rejects_path_fonte_with_caminho_carrying_gt_redirection() {
9108        // The fail-before-pass-after pin for the canonical output-redirection
9109        // paste footgun: an author copies a shell pipeline tail
9110        // (`"../caixa-teia>build.log"` — the canonical "I selected the whole
9111        // line including the `> build.log` redirect" idiom) and silently
9112        // passed every prior arm (`Path::is_absolute` false on `..`, no
9113        // control bytes, no backslash, doesn't end in `/`). The lacre
9114        // embedded the value verbatim, the resolver folded it through
9115        // `Path::join` looking for a literal `./../caixa-teia>build.log`
9116        // subdirectory, and the failure surfaced at resolve time with a
9117        // non-self-locating `No such file or directory` error. The new arm
9118        // moves the rejection to validate time and names the offending dep
9119        // + caminho + byte verbatim.
9120        let d = dep_with_fonte(DepSource::Path {
9121            caminho: "../caixa-teia>build.log".into(),
9122        });
9123        let err = d.validate().unwrap_err();
9124        let DepError::FonteCaminhoShellRedirection {
9125            nome,
9126            caminho,
9127            byte,
9128        } = err
9129        else {
9130            panic!("expected FonteCaminhoShellRedirection, got {err:?}");
9131        };
9132        assert_eq!(nome, "caixa-teia");
9133        assert_eq!(caminho, "../caixa-teia>build.log");
9134        assert_eq!(byte, b'>');
9135    }
9136
9137    #[test]
9138    fn validate_rejects_path_fonte_with_caminho_carrying_lt_redirection() {
9139        // The symmetric input-redirection paste shape
9140        // (`"../caixa-teia<input.lisp"` — the canonical "I copied a
9141        // `command < input.lisp` line from a tatara-lisp REPL log"
9142        // idiom). Pinned separately from the `>` shape so the gate's
9143        // contract is "any `<` or `>` anywhere", not single-byte coverage.
9144        let d = dep_with_fonte(DepSource::Path {
9145            caminho: "../caixa-teia<input.lisp".into(),
9146        });
9147        let err = d.validate().unwrap_err();
9148        let DepError::FonteCaminhoShellRedirection { byte, .. } = err else {
9149            panic!("expected FonteCaminhoShellRedirection, got {err:?}");
9150        };
9151        assert_eq!(byte, b'<');
9152    }
9153
9154    #[test]
9155    fn validate_rejects_path_fonte_with_caminho_carrying_leading_gt_redirection() {
9156        // Leading-position `>` shape (`">../caixa-teia"` — the degenerate
9157        // "I forgot the source side of the redirect" idiom). Pinned
9158        // separately from the embedded-byte shapes so the gate covers
9159        // every position, not only mid-path.
9160        let d = dep_with_fonte(DepSource::Path {
9161            caminho: ">../caixa-teia".into(),
9162        });
9163        let err = d.validate().unwrap_err();
9164        assert!(
9165            matches!(
9166                err,
9167                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
9168            ),
9169            "got {err:?}",
9170        );
9171    }
9172
9173    #[test]
9174    fn validate_rejects_path_fonte_with_caminho_carrying_double_gt_append() {
9175        // The bash append-redirection shape (`"../caixa-teia>>build.log"` —
9176        // the canonical "I copied a `>>` append redirect" idiom). The arm
9177        // fires on the first `>` encountered; pinned so a future arm that
9178        // tries to distinguish `>` from `>>` doesn't break the broader
9179        // contract.
9180        let d = dep_with_fonte(DepSource::Path {
9181            caminho: "../caixa-teia>>build.log".into(),
9182        });
9183        let err = d.validate().unwrap_err();
9184        assert!(
9185            matches!(
9186                err,
9187                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
9188            ),
9189            "got {err:?}",
9190        );
9191    }
9192
9193    #[test]
9194    fn validate_accepts_path_fonte_with_caminho_carrying_no_redirection() {
9195        // The positive-control pin: the gate targets only `<` / `>`,
9196        // never adjacent printable ASCII or POSIX-valid bytes. The
9197        // canonical relative POSIX path (`"../caixa-teia"`) and a
9198        // nested deeply-pathed variant (`"../caixa-teia/foo/bar"`) must
9199        // continue to validate cleanly so the gate doesn't widen to a
9200        // "no printable punctuation anywhere" sweep that would defeat
9201        // the entire path-fonte author surface.
9202        let d = dep_with_fonte(DepSource::Path {
9203            caminho: "../caixa-teia/foo/bar".into(),
9204        });
9205        d.validate().unwrap();
9206    }
9207
9208    #[test]
9209    fn fonte_caminho_backslash_fires_before_shell_redirection() {
9210        // Cascade pin on the immediate-predecessor arm: a value carrying
9211        // both `\` and `<` / `>` (`"..\caixa-teia>build.log"` — the
9212        // canonical "I pasted a Windows-shell command with output
9213        // redirect" footgun) routes through `FonteCaminhoBackslash` not
9214        // `FonteCaminhoShellRedirection`. The cross-host-OS-separator
9215        // divergence is the load-bearing axis (an author who removes
9216        // the `\` is the root-cause edit; the `>` falls away in the
9217        // same edit since it's downstream of the Windows-shell
9218        // convention).
9219        let d = dep_with_fonte(DepSource::Path {
9220            caminho: "..\\caixa-teia>build.log".into(),
9221        });
9222        let err = d.validate().unwrap_err();
9223        assert!(
9224            matches!(err, DepError::FonteCaminhoBackslash { .. }),
9225            "got {err:?}",
9226        );
9227    }
9228
9229    #[test]
9230    fn fonte_caminho_control_char_fires_before_shell_redirection() {
9231        // Cascade pin on the embedded-control-byte arm: a value carrying
9232        // both a control byte and `<` / `>` (`"../foo\n>bar"` — the
9233        // canonical paste-from-multiline-doc footgun where a newline
9234        // landed mid-caminho) routes through `FonteCaminhoControlChar`
9235        // not `FonteCaminhoShellRedirection`. The POSIX-syscall-
9236        // rejected-byte / NUL-`CString::new`-fail diagnostic is the
9237        // load-bearing axis on every value that probes positive for
9238        // both — mirrors the cascade discipline on every prior arm.
9239        let d = dep_with_fonte(DepSource::Path {
9240            caminho: "../foo\n>bar".into(),
9241        });
9242        let err = d.validate().unwrap_err();
9243        assert!(
9244            matches!(err, DepError::FonteCaminhoControlChar { .. }),
9245            "got {err:?}",
9246        );
9247    }
9248
9249    #[test]
9250    fn fonte_caminho_absolute_fires_before_shell_redirection() {
9251        // Cascade pin on the load-bearing leading-byte arm: a leading
9252        // `/` value with embedded `<` / `>` (`"/etc/passwd>out"`)
9253        // routes through `FonteCaminhoAbsolute` not
9254        // `FonteCaminhoShellRedirection` — the host-layout-leak
9255        // diagnostic is the load-bearing axis, the `>` byte is the
9256        // secondary observation. Same precedence logic as every prior
9257        // leading-byte arm.
9258        let d = dep_with_fonte(DepSource::Path {
9259            caminho: "/etc/passwd>out".into(),
9260        });
9261        let err = d.validate().unwrap_err();
9262        assert!(
9263            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
9264            "got {err:?}",
9265        );
9266    }
9267
9268    #[test]
9269    fn fonte_caminho_shell_redirection_fires_before_trailing_slash() {
9270        // Cascade pin on the immediate-successor arm: a value carrying
9271        // both `<` / `>` and a trailing `/` (`"../foo></"` — the
9272        // canonical "I tab-completed a path that already had a
9273        // redirect" footgun) routes through `FonteCaminhoShellRedirection`
9274        // not `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
9275        // the more semantic-locating axis (an author who removes the
9276        // `<` / `>` typically also drops the trailing separator since
9277        // both are paste-from-shell artifacts).
9278        let d = dep_with_fonte(DepSource::Path {
9279            caminho: "../foo></".into(),
9280        });
9281        let err = d.validate().unwrap_err();
9282        assert!(
9283            matches!(
9284                err,
9285                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
9286            ),
9287            "got {err:?}",
9288        );
9289    }
9290
9291    #[test]
9292    fn fonte_caminho_shell_redirection_diagnostic_carries_offending_dep_caminho_byte() {
9293        // Diagnostic-shape pin (peer with
9294        // `fonte_caminho_control_diagnostic_carries_offending_dep_caminho_byte`'s
9295        // payload assertion on the closest peer arm that also carries a
9296        // `byte` field): the error's Display surfaces the offending
9297        // `:nome`, the offending `:caminho` verbatim, and the offending
9298        // byte in hex (`0x3c` for `<`, `0x3e` for `>`) so a `feira lint`
9299        // run can render the diagnostic without re-parsing.
9300        let d = dep_with_fonte(DepSource::Path {
9301            caminho: "../caixa-teia>build.log".into(),
9302        });
9303        let rendered = d.validate().unwrap_err().to_string();
9304        assert!(
9305            rendered.contains("caixa-teia"),
9306            "diagnostic must name the offending dep: {rendered}",
9307        );
9308        assert!(
9309            rendered.contains("../caixa-teia>build.log"),
9310            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
9311        );
9312        assert!(
9313            rendered.contains("0x3e"),
9314            "diagnostic must name the offending byte in hex: {rendered:?}",
9315        );
9316        assert!(
9317            rendered.contains("redirection"),
9318            "diagnostic must name the shell-redirection footgun: {rendered:?}",
9319        );
9320    }
9321
9322    // -- :caminho shell-pipe metacharacter arm ----------------------------
9323
9324    #[test]
9325    fn validate_rejects_path_fonte_with_caminho_carrying_pipe() {
9326        // The fail-before-pass-after pin for the canonical shell-pipe
9327        // paste footgun: an author copies a shell-history line
9328        // (`"../caixa-teia | grep foo"` — the canonical "I selected
9329        // the whole `ls dir | grep` line out of zsh history") and
9330        // silently passed every prior arm (`Path::is_absolute` false
9331        // on `..`, no control bytes, no backslash, no `<` / `>`,
9332        // doesn't end in `/`). The lacre embedded the value verbatim,
9333        // the resolver folded it through `Path::join` looking for a
9334        // literal `./../caixa-teia | grep foo` subdirectory, and the
9335        // failure surfaced at resolve time with a non-self-locating
9336        // `No such file or directory` error. The new arm moves the
9337        // rejection to validate time and names the offending dep +
9338        // caminho verbatim.
9339        let d = dep_with_fonte(DepSource::Path {
9340            caminho: "../caixa-teia | grep foo".into(),
9341        });
9342        let err = d.validate().unwrap_err();
9343        let DepError::FonteCaminhoShellPipe { nome, caminho } = err else {
9344            panic!("expected FonteCaminhoShellPipe, got {err:?}");
9345        };
9346        assert_eq!(nome, "caixa-teia");
9347        assert_eq!(caminho, "../caixa-teia | grep foo");
9348    }
9349
9350    #[test]
9351    fn validate_rejects_path_fonte_with_caminho_carrying_leading_pipe() {
9352        // Leading-position `|` shape (`"|../caixa-teia"` — the
9353        // degenerate "I forgot the source side of the pipe" idiom).
9354        // Pinned separately from the embedded-byte shape so the gate
9355        // covers every position, not only mid-path.
9356        let d = dep_with_fonte(DepSource::Path {
9357            caminho: "|../caixa-teia".into(),
9358        });
9359        let err = d.validate().unwrap_err();
9360        assert!(
9361            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
9362            "got {err:?}",
9363        );
9364    }
9365
9366    #[test]
9367    fn validate_rejects_path_fonte_with_caminho_carrying_double_pipe_or() {
9368        // The bash short-circuit-OR shape (`"../caixa-teia||fallback"`
9369        // — the canonical "I copied a `cmd-a || cmd-b` fallback line"
9370        // idiom). The arm fires on the first `|` encountered; pinned
9371        // so a future arm that tries to distinguish `|` from `||`
9372        // doesn't break the broader contract.
9373        let d = dep_with_fonte(DepSource::Path {
9374            caminho: "../caixa-teia||fallback".into(),
9375        });
9376        let err = d.validate().unwrap_err();
9377        assert!(
9378            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
9379            "got {err:?}",
9380        );
9381    }
9382
9383    #[test]
9384    fn validate_accepts_path_fonte_with_caminho_carrying_no_pipe() {
9385        // The positive-control pin: the gate targets only `|`, never
9386        // adjacent printable ASCII or POSIX-valid bytes. The canonical
9387        // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
9388        // pathed variant with adjacent printable punctuation
9389        // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
9390        // cleanly so the gate doesn't widen to a "no printable
9391        // punctuation anywhere" sweep that would defeat the entire
9392        // path-fonte author surface.
9393        let d = dep_with_fonte(DepSource::Path {
9394            caminho: "../caixa-teia/sub-dir.v2".into(),
9395        });
9396        d.validate().unwrap();
9397    }
9398
9399    #[test]
9400    fn fonte_caminho_shell_redirection_fires_before_shell_pipe() {
9401        // Cascade pin on the immediate-predecessor arm: a value carrying
9402        // both `<` / `>` and `|` (`"../caixa-teia<input|tee"` — the
9403        // canonical "I pasted a `cmd < input | tee` pipeline tail"
9404        // footgun) routes through `FonteCaminhoShellRedirection` not
9405        // `FonteCaminhoShellPipe`. The input/output redirection
9406        // metachar carries the more self-locating `byte: u8` payload
9407        // (it names which of `<` or `>` triggered), so the prior arm
9408        // wins on every probe-as-both value — same cascade discipline
9409        // every prior `:caminho` arm establishes.
9410        let d = dep_with_fonte(DepSource::Path {
9411            caminho: "../caixa-teia<input|tee".into(),
9412        });
9413        let err = d.validate().unwrap_err();
9414        assert!(
9415            matches!(
9416                err,
9417                DepError::FonteCaminhoShellRedirection { byte: b'<', .. }
9418            ),
9419            "got {err:?}",
9420        );
9421    }
9422
9423    #[test]
9424    fn fonte_caminho_backslash_fires_before_shell_pipe() {
9425        // Cascade pin on the upstream backslash arm: a value carrying
9426        // both `\` and `|` (`"..\caixa-teia|tee"` — the canonical
9427        // "I pasted a Windows-shell command with pipe to tee"
9428        // footgun) routes through `FonteCaminhoBackslash` not
9429        // `FonteCaminhoShellPipe`. The cross-host-OS-separator
9430        // divergence is the load-bearing axis on every probe-as-both
9431        // value (an author who removes the `\` is the root-cause edit;
9432        // the `|` falls away in the same edit since it's downstream of
9433        // the Windows-shell convention).
9434        let d = dep_with_fonte(DepSource::Path {
9435            caminho: "..\\caixa-teia|tee".into(),
9436        });
9437        let err = d.validate().unwrap_err();
9438        assert!(
9439            matches!(err, DepError::FonteCaminhoBackslash { .. }),
9440            "got {err:?}",
9441        );
9442    }
9443
9444    #[test]
9445    fn fonte_caminho_control_char_fires_before_shell_pipe() {
9446        // Cascade pin on the embedded-control-byte arm: a value
9447        // carrying both a control byte and `|` (`"../foo\n|bar"` —
9448        // the canonical paste-from-multiline-doc footgun where a
9449        // newline landed mid-caminho) routes through
9450        // `FonteCaminhoControlChar` not `FonteCaminhoShellPipe`. The
9451        // POSIX-syscall-rejected-byte / NUL-`CString::new`-fail
9452        // diagnostic is the load-bearing axis on every value that
9453        // probes positive for both — mirrors the cascade discipline
9454        // on every prior arm.
9455        let d = dep_with_fonte(DepSource::Path {
9456            caminho: "../foo\n|bar".into(),
9457        });
9458        let err = d.validate().unwrap_err();
9459        assert!(
9460            matches!(err, DepError::FonteCaminhoControlChar { .. }),
9461            "got {err:?}",
9462        );
9463    }
9464
9465    #[test]
9466    fn fonte_caminho_absolute_fires_before_shell_pipe() {
9467        // Cascade pin on the load-bearing leading-byte arm: a leading
9468        // `/` value with embedded `|` (`"/etc/passwd|tee"`) routes
9469        // through `FonteCaminhoAbsolute` not `FonteCaminhoShellPipe`
9470        // — the host-layout-leak diagnostic is the load-bearing axis,
9471        // the `|` byte is the secondary observation. Same precedence
9472        // logic as every prior leading-byte arm.
9473        let d = dep_with_fonte(DepSource::Path {
9474            caminho: "/etc/passwd|tee".into(),
9475        });
9476        let err = d.validate().unwrap_err();
9477        assert!(
9478            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
9479            "got {err:?}",
9480        );
9481    }
9482
9483    #[test]
9484    fn fonte_caminho_shell_pipe_fires_before_trailing_slash() {
9485        // Cascade pin on the immediate-successor arm: a value carrying
9486        // both `|` and a trailing `/` (`"../foo|tee/"` — the canonical
9487        // "I tab-completed a path that already had a pipeline tail"
9488        // footgun) routes through `FonteCaminhoShellPipe` not
9489        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
9490        // the more semantic-locating axis (an author who removes the
9491        // `|` typically also drops the trailing separator since both
9492        // are paste-from-shell artifacts).
9493        let d = dep_with_fonte(DepSource::Path {
9494            caminho: "../foo|tee/".into(),
9495        });
9496        let err = d.validate().unwrap_err();
9497        assert!(
9498            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
9499            "got {err:?}",
9500        );
9501    }
9502
9503    #[test]
9504    fn fonte_caminho_shell_pipe_diagnostic_carries_offending_dep_and_caminho() {
9505        // Diagnostic-shape pin (peer with
9506        // `fonte_caminho_backslash_diagnostic_carries_offending_dep_and_caminho`
9507        // on the closest single-byte peer arm): the error's Display
9508        // surfaces the offending `:nome` and the offending `:caminho`
9509        // verbatim, and names the shell-pipe footgun explicitly so a
9510        // `feira lint` run can render the diagnostic without
9511        // re-parsing.
9512        let d = dep_with_fonte(DepSource::Path {
9513            caminho: "../caixa-teia | grep foo".into(),
9514        });
9515        let rendered = d.validate().unwrap_err().to_string();
9516        assert!(
9517            rendered.contains("caixa-teia"),
9518            "diagnostic must name the offending dep: {rendered}",
9519        );
9520        assert!(
9521            rendered.contains("../caixa-teia | grep foo"),
9522            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
9523        );
9524        assert!(
9525            rendered.contains('|'),
9526            "diagnostic must reference the pipe footgun: {rendered:?}",
9527        );
9528        assert!(
9529            rendered.contains("pipe"),
9530            "diagnostic must name the shell-pipe footgun: {rendered:?}",
9531        );
9532    }
9533
9534    // -- :caminho shell-command-separator metacharacter arm ---------------
9535
9536    #[test]
9537    fn validate_rejects_path_fonte_with_caminho_carrying_semicolon() {
9538        // The fail-before-pass-after pin for the canonical shell-command-
9539        // separator paste footgun: an author copies a shell one-liner
9540        // (`"../caixa-teia; rm -rf build"` — the canonical "I selected the
9541        // whole `cd path; do-thing` chain out of a shell-history block")
9542        // and silently passed every prior arm (`Path::is_absolute` false
9543        // on `..`, no control bytes, no backslash, no `<` / `>`, no `|`,
9544        // doesn't end in `/`). The lacre embedded the value verbatim, the
9545        // resolver folded it through `Path::join` looking for a literal
9546        // `./../caixa-teia; rm -rf build` subdirectory, and the failure
9547        // surfaced at resolve time with a non-self-locating `No such file
9548        // or directory` error. The new arm moves the rejection to validate
9549        // time and names the offending dep + caminho verbatim.
9550        let d = dep_with_fonte(DepSource::Path {
9551            caminho: "../caixa-teia; rm -rf build".into(),
9552        });
9553        let err = d.validate().unwrap_err();
9554        let DepError::FonteCaminhoShellSemicolon { nome, caminho } = err else {
9555            panic!("expected FonteCaminhoShellSemicolon, got {err:?}");
9556        };
9557        assert_eq!(nome, "caixa-teia");
9558        assert_eq!(caminho, "../caixa-teia; rm -rf build");
9559    }
9560
9561    #[test]
9562    fn validate_rejects_path_fonte_with_caminho_carrying_leading_semicolon() {
9563        // Leading-position `;` shape (`";../caixa-teia"` — the degenerate
9564        // "I forgot the prior command side of the separator" idiom).
9565        // Pinned separately from the embedded-byte shape so the gate
9566        // covers every position, not only mid-path.
9567        let d = dep_with_fonte(DepSource::Path {
9568            caminho: ";../caixa-teia".into(),
9569        });
9570        let err = d.validate().unwrap_err();
9571        assert!(
9572            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
9573            "got {err:?}",
9574        );
9575    }
9576
9577    #[test]
9578    fn validate_rejects_path_fonte_with_caminho_carrying_double_semicolon() {
9579        // The POSIX `case` arm `;;` terminator shape
9580        // (`"../caixa-teia;;next"` — the canonical "I copied a `case`
9581        // arm tail" idiom). The arm fires on the first `;` encountered;
9582        // pinned so a future arm that tries to distinguish `;` from `;;`
9583        // doesn't break the broader contract.
9584        let d = dep_with_fonte(DepSource::Path {
9585            caminho: "../caixa-teia;;next".into(),
9586        });
9587        let err = d.validate().unwrap_err();
9588        assert!(
9589            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
9590            "got {err:?}",
9591        );
9592    }
9593
9594    #[test]
9595    fn validate_accepts_path_fonte_with_caminho_carrying_no_semicolon() {
9596        // The positive-control pin: the gate targets only `;`, never
9597        // adjacent printable ASCII or POSIX-valid bytes. The canonical
9598        // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
9599        // pathed variant with adjacent printable punctuation
9600        // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
9601        // cleanly so the gate doesn't widen to a "no printable
9602        // punctuation anywhere" sweep that would defeat the entire
9603        // path-fonte author surface.
9604        let d = dep_with_fonte(DepSource::Path {
9605            caminho: "../caixa-teia/sub-dir.v2".into(),
9606        });
9607        d.validate().unwrap();
9608    }
9609
9610    #[test]
9611    fn fonte_caminho_shell_pipe_fires_before_shell_semicolon() {
9612        // Cascade pin on the immediate-predecessor arm: a value carrying
9613        // both `|` and `;` (`"../caixa-teia | tee; rm"` — the canonical
9614        // "I pasted a `cmd | tee; cleanup` chain" footgun) routes through
9615        // `FonteCaminhoShellPipe` not `FonteCaminhoShellSemicolon`. The
9616        // pipeline-tail paste is the load-bearing root-cause edit on
9617        // every probe-as-both value (an author who removes the `|`
9618        // typically also drops the trailing `; cleanup` since both are
9619        // the same paste-from-shell-history artifact) — same cascade
9620        // discipline every prior `:caminho` arm establishes.
9621        let d = dep_with_fonte(DepSource::Path {
9622            caminho: "../caixa-teia | tee; rm".into(),
9623        });
9624        let err = d.validate().unwrap_err();
9625        assert!(
9626            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
9627            "got {err:?}",
9628        );
9629    }
9630
9631    #[test]
9632    fn fonte_caminho_shell_redirection_fires_before_shell_semicolon() {
9633        // Cascade pin on the upstream shell-redirection arm: a value
9634        // carrying both `<` / `>` and `;` (`"../caixa-teia>log; rm"` —
9635        // the canonical "I pasted a `cmd > log; cleanup` chain"
9636        // footgun) routes through `FonteCaminhoShellRedirection` not
9637        // `FonteCaminhoShellSemicolon`. The input/output redirection
9638        // metachar carries the more self-locating `byte: u8` payload
9639        // (it names which of `<` or `>` triggered), so the prior arm
9640        // wins on every probe-as-both value.
9641        let d = dep_with_fonte(DepSource::Path {
9642            caminho: "../caixa-teia>log; rm".into(),
9643        });
9644        let err = d.validate().unwrap_err();
9645        assert!(
9646            matches!(
9647                err,
9648                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
9649            ),
9650            "got {err:?}",
9651        );
9652    }
9653
9654    #[test]
9655    fn fonte_caminho_backslash_fires_before_shell_semicolon() {
9656        // Cascade pin on the upstream backslash arm: a value carrying
9657        // both `\` and `;` (`"..\caixa-teia;rm"` — the canonical "I
9658        // pasted a Windows-shell `cd ..\path; cleanup` chain") routes
9659        // through `FonteCaminhoBackslash` not `FonteCaminhoShellSemicolon`.
9660        // The cross-host-OS-separator divergence is the load-bearing axis
9661        // on every probe-as-both value (an author who removes the `\` is
9662        // the root-cause edit; the `;` falls away in the same edit since
9663        // it's downstream of the Windows-shell convention).
9664        let d = dep_with_fonte(DepSource::Path {
9665            caminho: "..\\caixa-teia;rm".into(),
9666        });
9667        let err = d.validate().unwrap_err();
9668        assert!(
9669            matches!(err, DepError::FonteCaminhoBackslash { .. }),
9670            "got {err:?}",
9671        );
9672    }
9673
9674    #[test]
9675    fn fonte_caminho_control_char_fires_before_shell_semicolon() {
9676        // Cascade pin on the embedded-control-byte arm: a value carrying
9677        // both a control byte and `;` (`"../foo\n;bar"` — the canonical
9678        // paste-from-multiline-doc footgun where a newline landed mid-
9679        // caminho) routes through `FonteCaminhoControlChar` not
9680        // `FonteCaminhoShellSemicolon`. The POSIX-syscall-rejected-byte
9681        // / NUL-`CString::new`-fail diagnostic is the load-bearing axis
9682        // on every value that probes positive for both — mirrors the
9683        // cascade discipline on every prior arm.
9684        let d = dep_with_fonte(DepSource::Path {
9685            caminho: "../foo\n;bar".into(),
9686        });
9687        let err = d.validate().unwrap_err();
9688        assert!(
9689            matches!(err, DepError::FonteCaminhoControlChar { .. }),
9690            "got {err:?}",
9691        );
9692    }
9693
9694    #[test]
9695    fn fonte_caminho_absolute_fires_before_shell_semicolon() {
9696        // Cascade pin on the load-bearing leading-byte arm: a leading
9697        // `/` value with embedded `;` (`"/etc/passwd;rm"`) routes
9698        // through `FonteCaminhoAbsolute` not `FonteCaminhoShellSemicolon`
9699        // — the host-layout-leak diagnostic is the load-bearing axis,
9700        // the `;` byte is the secondary observation. Same precedence
9701        // logic as every prior leading-byte arm.
9702        let d = dep_with_fonte(DepSource::Path {
9703            caminho: "/etc/passwd;rm".into(),
9704        });
9705        let err = d.validate().unwrap_err();
9706        assert!(
9707            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
9708            "got {err:?}",
9709        );
9710    }
9711
9712    #[test]
9713    fn fonte_caminho_shell_semicolon_fires_before_trailing_slash() {
9714        // Cascade pin on the immediate-successor arm: a value carrying
9715        // both `;` and a trailing `/` (`"../foo;rm/"` — the canonical
9716        // "I tab-completed a path that already had a `; cleanup` tail"
9717        // footgun) routes through `FonteCaminhoShellSemicolon` not
9718        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
9719        // the more semantic-locating axis (an author who removes the
9720        // `;` typically also drops the trailing separator since both
9721        // are paste-from-shell artifacts).
9722        let d = dep_with_fonte(DepSource::Path {
9723            caminho: "../foo;rm/".into(),
9724        });
9725        let err = d.validate().unwrap_err();
9726        assert!(
9727            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
9728            "got {err:?}",
9729        );
9730    }
9731
9732    #[test]
9733    fn fonte_caminho_shell_semicolon_diagnostic_carries_offending_dep_and_caminho() {
9734        // Diagnostic-shape pin (peer with
9735        // `fonte_caminho_shell_pipe_diagnostic_carries_offending_dep_and_caminho`
9736        // on the closest single-byte peer arm): the error's Display
9737        // surfaces the offending `:nome` and the offending `:caminho`
9738        // verbatim, and names the shell-command-separator footgun
9739        // explicitly so a `feira lint` run can render the diagnostic
9740        // without re-parsing.
9741        let d = dep_with_fonte(DepSource::Path {
9742            caminho: "../caixa-teia; rm -rf build".into(),
9743        });
9744        let rendered = d.validate().unwrap_err().to_string();
9745        assert!(
9746            rendered.contains("caixa-teia"),
9747            "diagnostic must name the offending dep: {rendered}",
9748        );
9749        assert!(
9750            rendered.contains("../caixa-teia; rm -rf build"),
9751            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
9752        );
9753        assert!(
9754            rendered.contains(';'),
9755            "diagnostic must reference the semicolon footgun: {rendered:?}",
9756        );
9757        assert!(
9758            rendered.contains("command-separator"),
9759            "diagnostic must name the shell-command-separator footgun: {rendered:?}",
9760        );
9761    }
9762
9763    #[test]
9764    fn validate_rejects_path_fonte_with_caminho_carrying_ampersand() {
9765        // The fail-before-pass-after pin for the canonical shell-
9766        // background-task paste footgun: an author copies a shell one-
9767        // liner (`"../caixa-teia & sleep 1"` — the canonical "I selected
9768        // the whole `cd path & sleep 1` background-launch out of a
9769        // shell-history block") and silently passed every prior arm
9770        // (`Path::is_absolute` false on `..`, no control bytes, no
9771        // backslash, no `<` / `>`, no `|`, no `;`, doesn't end in `/`).
9772        // The lacre embedded the value verbatim, the resolver folded it
9773        // through `Path::join` looking for a literal `./../caixa-teia &
9774        // sleep 1` subdirectory, and the failure surfaced at resolve
9775        // time with a non-self-locating `No such file or directory`
9776        // error. The new arm moves the rejection to validate time and
9777        // names the offending dep + caminho verbatim.
9778        let d = dep_with_fonte(DepSource::Path {
9779            caminho: "../caixa-teia & sleep 1".into(),
9780        });
9781        let err = d.validate().unwrap_err();
9782        let DepError::FonteCaminhoShellBackground { nome, caminho } = err else {
9783            panic!("expected FonteCaminhoShellBackground, got {err:?}");
9784        };
9785        assert_eq!(nome, "caixa-teia");
9786        assert_eq!(caminho, "../caixa-teia & sleep 1");
9787    }
9788
9789    #[test]
9790    fn validate_rejects_path_fonte_with_caminho_carrying_leading_ampersand() {
9791        // Leading-position `&` shape (`"&../caixa-teia"` — the
9792        // degenerate "I forgot the prior command side of the
9793        // background terminator" idiom). Pinned separately from the
9794        // embedded-byte shape so the gate covers every position, not
9795        // only mid-path.
9796        let d = dep_with_fonte(DepSource::Path {
9797            caminho: "&../caixa-teia".into(),
9798        });
9799        let err = d.validate().unwrap_err();
9800        assert!(
9801            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
9802            "got {err:?}",
9803        );
9804    }
9805
9806    #[test]
9807    fn validate_rejects_path_fonte_with_caminho_carrying_double_ampersand() {
9808        // The logical-AND `&&` shape (`"../caixa-teia && make"` — the
9809        // canonical "I copied a `cd path && make` build chain" idiom
9810        // every Makefile / shell-script wraps). The arm fires on the
9811        // first `&` encountered; pinned so a future arm that tries to
9812        // distinguish `&` from `&&` doesn't break the broader contract.
9813        let d = dep_with_fonte(DepSource::Path {
9814            caminho: "../caixa-teia && make".into(),
9815        });
9816        let err = d.validate().unwrap_err();
9817        assert!(
9818            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
9819            "got {err:?}",
9820        );
9821    }
9822
9823    #[test]
9824    fn validate_accepts_path_fonte_with_caminho_carrying_no_ampersand() {
9825        // The positive-control pin: the gate targets only `&`, never
9826        // adjacent printable ASCII or POSIX-valid bytes. The canonical
9827        // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
9828        // pathed variant with adjacent printable punctuation
9829        // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
9830        // cleanly so the gate doesn't widen to a "no printable
9831        // punctuation anywhere" sweep that would defeat the entire
9832        // path-fonte author surface.
9833        let d = dep_with_fonte(DepSource::Path {
9834            caminho: "../caixa-teia/sub-dir.v2".into(),
9835        });
9836        d.validate().unwrap();
9837    }
9838
9839    #[test]
9840    fn fonte_caminho_shell_semicolon_fires_before_shell_background() {
9841        // Cascade pin on the immediate-predecessor arm: a value carrying
9842        // both `;` and `&` (`"../caixa-teia; rm & sleep"` — the
9843        // canonical "I pasted a `cmd; cleanup & sleep` chain" footgun)
9844        // routes through `FonteCaminhoShellSemicolon` not
9845        // `FonteCaminhoShellBackground`. The sequential-command-
9846        // separator paste is the more common shell-history paste idiom
9847        // on every probe-as-both value (an author who removes the `;`
9848        // typically also drops the trailing `& sleep` since both are
9849        // paste-from-shell-history artifacts) — same cascade discipline
9850        // every prior `:caminho` arm establishes.
9851        let d = dep_with_fonte(DepSource::Path {
9852            caminho: "../caixa-teia; rm & sleep".into(),
9853        });
9854        let err = d.validate().unwrap_err();
9855        assert!(
9856            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
9857            "got {err:?}",
9858        );
9859    }
9860
9861    #[test]
9862    fn fonte_caminho_shell_pipe_fires_before_shell_background() {
9863        // Cascade pin on the upstream shell-pipe arm: a value carrying
9864        // both `|` and `&` (`"../caixa-teia | tee & sleep"` — the
9865        // canonical "I pasted a `cmd | tee & sleep` background-pipeline
9866        // chain" footgun) routes through `FonteCaminhoShellPipe` not
9867        // `FonteCaminhoShellBackground`. The pipeline-tail paste is the
9868        // load-bearing root-cause edit on every probe-as-both value.
9869        let d = dep_with_fonte(DepSource::Path {
9870            caminho: "../caixa-teia | tee & sleep".into(),
9871        });
9872        let err = d.validate().unwrap_err();
9873        assert!(
9874            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
9875            "got {err:?}",
9876        );
9877    }
9878
9879    #[test]
9880    fn fonte_caminho_shell_redirection_fires_before_shell_background() {
9881        // Cascade pin on the upstream shell-redirection arm: a value
9882        // carrying both `>` and `&` (`"../caixa-teia>log & sleep"` —
9883        // the canonical "I pasted a `cmd > log & sleep` background-
9884        // redirect chain" footgun) routes through
9885        // `FonteCaminhoShellRedirection` not
9886        // `FonteCaminhoShellBackground`. The input/output redirection
9887        // metachar carries the more self-locating `byte: u8` payload
9888        // (it names which of `<` or `>` triggered), so the prior arm
9889        // wins on every probe-as-both value.
9890        let d = dep_with_fonte(DepSource::Path {
9891            caminho: "../caixa-teia>log & sleep".into(),
9892        });
9893        let err = d.validate().unwrap_err();
9894        assert!(
9895            matches!(
9896                err,
9897                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
9898            ),
9899            "got {err:?}",
9900        );
9901    }
9902
9903    #[test]
9904    fn fonte_caminho_backslash_fires_before_shell_background() {
9905        // Cascade pin on the upstream backslash arm: a value carrying
9906        // both `\` and `&` (`"..\caixa-teia & sleep"` — the canonical
9907        // "I pasted a Windows-shell `cd ..\path & sleep` background-
9908        // launch chain") routes through `FonteCaminhoBackslash` not
9909        // `FonteCaminhoShellBackground`. The cross-host-OS-separator
9910        // divergence is the load-bearing axis on every probe-as-both
9911        // value (an author who removes the `\` is the root-cause edit;
9912        // the `&` falls away in the same edit since it's downstream of
9913        // the Windows-shell convention).
9914        let d = dep_with_fonte(DepSource::Path {
9915            caminho: "..\\caixa-teia & sleep".into(),
9916        });
9917        let err = d.validate().unwrap_err();
9918        assert!(
9919            matches!(err, DepError::FonteCaminhoBackslash { .. }),
9920            "got {err:?}",
9921        );
9922    }
9923
9924    #[test]
9925    fn fonte_caminho_control_char_fires_before_shell_background() {
9926        // Cascade pin on the embedded-control-byte arm: a value
9927        // carrying both a control byte and `&` (`"../foo\n&sleep"` —
9928        // the canonical paste-from-multiline-doc footgun where a
9929        // newline landed mid-caminho) routes through
9930        // `FonteCaminhoControlChar` not `FonteCaminhoShellBackground`.
9931        // The POSIX-syscall-rejected-byte / NUL-`CString::new`-fail
9932        // diagnostic is the load-bearing axis on every value that
9933        // probes positive for both — mirrors the cascade discipline on
9934        // every prior arm.
9935        let d = dep_with_fonte(DepSource::Path {
9936            caminho: "../foo\n&sleep".into(),
9937        });
9938        let err = d.validate().unwrap_err();
9939        assert!(
9940            matches!(err, DepError::FonteCaminhoControlChar { .. }),
9941            "got {err:?}",
9942        );
9943    }
9944
9945    #[test]
9946    fn fonte_caminho_absolute_fires_before_shell_background() {
9947        // Cascade pin on the load-bearing leading-byte arm: a leading
9948        // `/` value with embedded `&` (`"/etc/passwd & sleep"`) routes
9949        // through `FonteCaminhoAbsolute` not
9950        // `FonteCaminhoShellBackground` — the host-layout-leak
9951        // diagnostic is the load-bearing axis, the `&` byte is the
9952        // secondary observation. Same precedence logic as every prior
9953        // leading-byte arm.
9954        let d = dep_with_fonte(DepSource::Path {
9955            caminho: "/etc/passwd & sleep".into(),
9956        });
9957        let err = d.validate().unwrap_err();
9958        assert!(
9959            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
9960            "got {err:?}",
9961        );
9962    }
9963
9964    #[test]
9965    fn fonte_caminho_shell_background_fires_before_trailing_slash() {
9966        // Cascade pin on the immediate-successor arm: a value carrying
9967        // both `&` and a trailing `/` (`"../foo&sleep/"` — the
9968        // canonical "I tab-completed a path that already had a `&
9969        // sleep` background-launch tail" footgun) routes through
9970        // `FonteCaminhoShellBackground` not `FonteCaminhoTrailingSlash`.
9971        // The embedded shell-metachar is the more semantic-locating
9972        // axis (an author who removes the `&` typically also drops
9973        // the trailing separator since both are paste-from-shell
9974        // artifacts).
9975        let d = dep_with_fonte(DepSource::Path {
9976            caminho: "../foo&sleep/".into(),
9977        });
9978        let err = d.validate().unwrap_err();
9979        assert!(
9980            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
9981            "got {err:?}",
9982        );
9983    }
9984
9985    #[test]
9986    fn fonte_caminho_shell_background_diagnostic_carries_offending_dep_and_caminho() {
9987        // Diagnostic-shape pin (peer with
9988        // `fonte_caminho_shell_semicolon_diagnostic_carries_offending_dep_and_caminho`
9989        // on the closest single-byte peer arm): the error's Display
9990        // surfaces the offending `:nome` and the offending `:caminho`
9991        // verbatim, and names the shell-background / logical-AND
9992        // footgun explicitly so a `feira lint` run can render the
9993        // diagnostic without re-parsing.
9994        let d = dep_with_fonte(DepSource::Path {
9995            caminho: "../caixa-teia & sleep 1".into(),
9996        });
9997        let rendered = d.validate().unwrap_err().to_string();
9998        assert!(
9999            rendered.contains("caixa-teia"),
10000            "diagnostic must name the offending dep: {rendered}",
10001        );
10002        assert!(
10003            rendered.contains("../caixa-teia & sleep 1"),
10004            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10005        );
10006        assert!(
10007            rendered.contains('&'),
10008            "diagnostic must reference the ampersand footgun: {rendered:?}",
10009        );
10010        assert!(
10011            rendered.contains("background") || rendered.contains("list-AND"),
10012            "diagnostic must name the shell-background / logical-AND footgun: {rendered:?}",
10013        );
10014    }
10015
10016    #[test]
10017    fn validate_rejects_path_fonte_with_caminho_carrying_backtick() {
10018        // The fail-before-pass-after pin for the canonical shell-
10019        // command-substitution paste footgun: an author copies a
10020        // POSIX legacy backticked one-liner (`"../caixa-teia/`whoami`"`
10021        // — the canonical "I pasted a path that included a `pwd`
10022        // / `whoami` / `date` legacy command-substitution expansion
10023        // out of a shell-history block") and silently passed every
10024        // prior arm (`Path::is_absolute` false on `..`, no control
10025        // bytes, no `\`, no `<` / `>`, no `|`, no `;`, no `&`, doesn't
10026        // end in `/`). The lacre embedded the value verbatim, the
10027        // resolver folded it through `Path::join` looking for a
10028        // literal `./../caixa-teia/`whoami`` subdirectory, and the
10029        // failure surfaced at resolve time with a non-self-locating
10030        // `No such file or directory` error. The new arm moves the
10031        // rejection to validate time and names the offending dep +
10032        // caminho verbatim.
10033        let d = dep_with_fonte(DepSource::Path {
10034            caminho: "../caixa-teia/`whoami`".into(),
10035        });
10036        let err = d.validate().unwrap_err();
10037        let DepError::FonteCaminhoShellCommandSubstitution { nome, caminho } = err else {
10038            panic!("expected FonteCaminhoShellCommandSubstitution, got {err:?}");
10039        };
10040        assert_eq!(nome, "caixa-teia");
10041        assert_eq!(caminho, "../caixa-teia/`whoami`");
10042    }
10043
10044    #[test]
10045    fn validate_rejects_path_fonte_with_caminho_carrying_leading_backtick() {
10046        // Leading-position backtick shape (``"`pwd`/caixa-teia"`` —
10047        // the canonical `<backtick>pwd<backtick>/path` working-
10048        // directory expansion shape every shell-side path-composition
10049        // idiom carries). Pinned separately from the embedded-byte
10050        // shape so the gate covers every position, not only mid-path.
10051        let d = dep_with_fonte(DepSource::Path {
10052            caminho: "`pwd`/caixa-teia".into(),
10053        });
10054        let err = d.validate().unwrap_err();
10055        assert!(
10056            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
10057            "got {err:?}",
10058        );
10059    }
10060
10061    #[test]
10062    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_backtick() {
10063        // Trailing-position backtick shape (`"../caixa-teia`"` — the
10064        // degenerate "I selected an unbalanced backtick out of a
10065        // shell-history block" idiom that probes for the cascade's
10066        // last-byte handling). The trailing-`/` arm fires only on
10067        // last-byte `/`; an unbalanced trailing backtick must route
10068        // through this arm regardless of position.
10069        let d = dep_with_fonte(DepSource::Path {
10070            caminho: "../caixa-teia`".into(),
10071        });
10072        let err = d.validate().unwrap_err();
10073        assert!(
10074            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
10075            "got {err:?}",
10076        );
10077    }
10078
10079    #[test]
10080    fn validate_rejects_path_fonte_with_caminho_carrying_balanced_backtick_pair() {
10081        // The canonical balanced-pair shape (``"../<backtick>cat
10082        // /etc/passwd<backtick>"`` — the canonical CWE-78 shell-
10083        // command-injection paste idiom every shell-side hardening
10084        // guide enumerates first). The arm fires on the first
10085        // backtick encountered; pinned so a future arm that tries to
10086        // distinguish the opening from the closing byte doesn't break
10087        // the broader contract.
10088        let d = dep_with_fonte(DepSource::Path {
10089            caminho: "../`cat /etc/passwd`".into(),
10090        });
10091        let err = d.validate().unwrap_err();
10092        assert!(
10093            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
10094            "got {err:?}",
10095        );
10096    }
10097
10098    #[test]
10099    fn validate_accepts_path_fonte_with_caminho_carrying_no_backtick() {
10100        // The positive-control pin: the gate targets only the
10101        // backtick byte, never adjacent printable ASCII or POSIX-
10102        // valid bytes. The canonical relative POSIX path
10103        // (`"../caixa-teia"`) and a nested deeply-pathed variant with
10104        // adjacent printable punctuation
10105        // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
10106        // cleanly so the gate doesn't widen to a "no printable
10107        // punctuation anywhere" sweep that would defeat the entire
10108        // path-fonte author surface.
10109        let d = dep_with_fonte(DepSource::Path {
10110            caminho: "../caixa-teia/sub-dir.v2".into(),
10111        });
10112        d.validate().unwrap();
10113    }
10114
10115    #[test]
10116    fn fonte_caminho_shell_background_fires_before_shell_command_substitution() {
10117        // Cascade pin on the immediate-predecessor arm: a value
10118        // carrying both `&` and a backtick (``"../caixa-teia &
10119        // <backtick>sleep 1<backtick>"`` — the canonical "I pasted a
10120        // `cmd & <backtick>sleep N<backtick>` background-launch +
10121        // command-substitution chain" footgun) routes through
10122        // `FonteCaminhoShellBackground` not
10123        // `FonteCaminhoShellCommandSubstitution`. The background-
10124        // launch tail is the more common shell-history paste idiom
10125        // on every probe-as-both value — same cascade discipline
10126        // every prior `:caminho` arm establishes.
10127        let d = dep_with_fonte(DepSource::Path {
10128            caminho: "../caixa-teia & `sleep 1`".into(),
10129        });
10130        let err = d.validate().unwrap_err();
10131        assert!(
10132            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
10133            "got {err:?}",
10134        );
10135    }
10136
10137    #[test]
10138    fn fonte_caminho_shell_semicolon_fires_before_shell_command_substitution() {
10139        // Cascade pin on the upstream shell-semicolon arm: a value
10140        // carrying both `;` and a backtick (``"../caixa-teia;
10141        // <backtick>whoami<backtick>"`` — the canonical "I pasted a
10142        // `cmd; <backtick>follow-up<backtick>` sequential-chain
10143        // footgun) routes through `FonteCaminhoShellSemicolon` not
10144        // `FonteCaminhoShellCommandSubstitution`. The sequential-
10145        // command-separator paste is the load-bearing root-cause
10146        // edit on every probe-as-both value.
10147        let d = dep_with_fonte(DepSource::Path {
10148            caminho: "../caixa-teia; `whoami`".into(),
10149        });
10150        let err = d.validate().unwrap_err();
10151        assert!(
10152            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
10153            "got {err:?}",
10154        );
10155    }
10156
10157    #[test]
10158    fn fonte_caminho_shell_pipe_fires_before_shell_command_substitution() {
10159        // Cascade pin on the upstream shell-pipe arm: a value
10160        // carrying both `|` and a backtick (``"../caixa-teia |
10161        // <backtick>tee log<backtick>"`` — the canonical pipeline-to-
10162        // command-substitution paste idiom) routes through
10163        // `FonteCaminhoShellPipe` not
10164        // `FonteCaminhoShellCommandSubstitution`. The pipeline-tail
10165        // paste is the load-bearing root-cause edit on every
10166        // probe-as-both value.
10167        let d = dep_with_fonte(DepSource::Path {
10168            caminho: "../caixa-teia | `tee log`".into(),
10169        });
10170        let err = d.validate().unwrap_err();
10171        assert!(
10172            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10173            "got {err:?}",
10174        );
10175    }
10176
10177    #[test]
10178    fn fonte_caminho_shell_redirection_fires_before_shell_command_substitution() {
10179        // Cascade pin on the upstream shell-redirection arm: a value
10180        // carrying both `>` and a backtick (``"../caixa-teia>log
10181        // <backtick>date<backtick>"`` — the canonical "I pasted a
10182        // `cmd > log <backtick>date<backtick>` redirect-plus-
10183        // substitution chain" footgun) routes through
10184        // `FonteCaminhoShellRedirection` not
10185        // `FonteCaminhoShellCommandSubstitution`. The input/output
10186        // redirection metachar carries the more self-locating `byte`
10187        // payload (it names which of `<` or `>` triggered), so the
10188        // prior arm wins on every probe-as-both value.
10189        let d = dep_with_fonte(DepSource::Path {
10190            caminho: "../caixa-teia>log `date`".into(),
10191        });
10192        let err = d.validate().unwrap_err();
10193        assert!(
10194            matches!(
10195                err,
10196                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
10197            ),
10198            "got {err:?}",
10199        );
10200    }
10201
10202    #[test]
10203    fn fonte_caminho_backslash_fires_before_shell_command_substitution() {
10204        // Cascade pin on the upstream backslash arm: a value
10205        // carrying both `\` and a backtick (``"..\caixa-teia
10206        // <backtick>whoami<backtick>"`` — the canonical "I pasted a
10207        // Windows-shell `cd ..\path <backtick>whoami<backtick>`
10208        // chain") routes through `FonteCaminhoBackslash` not
10209        // `FonteCaminhoShellCommandSubstitution`. The cross-host-OS-
10210        // separator divergence is the load-bearing axis on every
10211        // probe-as-both value (an author who removes the `\` is the
10212        // root-cause edit; the backtick falls away in the same edit
10213        // since it's downstream of the Windows-shell convention).
10214        let d = dep_with_fonte(DepSource::Path {
10215            caminho: "..\\caixa-teia `whoami`".into(),
10216        });
10217        let err = d.validate().unwrap_err();
10218        assert!(
10219            matches!(err, DepError::FonteCaminhoBackslash { .. }),
10220            "got {err:?}",
10221        );
10222    }
10223
10224    #[test]
10225    fn fonte_caminho_control_char_fires_before_shell_command_substitution() {
10226        // Cascade pin on the embedded-control-byte arm: a value
10227        // carrying both a control byte and a backtick (`"../foo\n
10228        // `whoami`"` — the canonical paste-from-multiline-doc
10229        // footgun where a newline landed mid-caminho between two
10230        // paste fragments) routes through `FonteCaminhoControlChar`
10231        // not `FonteCaminhoShellCommandSubstitution`. The POSIX-
10232        // syscall-rejected-byte / NUL-`CString::new`-fail diagnostic
10233        // is the load-bearing axis on every value that probes
10234        // positive for both — mirrors the cascade discipline on
10235        // every prior arm.
10236        let d = dep_with_fonte(DepSource::Path {
10237            caminho: "../foo\n`whoami`".into(),
10238        });
10239        let err = d.validate().unwrap_err();
10240        assert!(
10241            matches!(err, DepError::FonteCaminhoControlChar { .. }),
10242            "got {err:?}",
10243        );
10244    }
10245
10246    #[test]
10247    fn fonte_caminho_absolute_fires_before_shell_command_substitution() {
10248        // Cascade pin on the load-bearing leading-byte arm: a
10249        // leading `/` value with embedded backtick (``"/etc/passwd
10250        // <backtick>whoami<backtick>"``) routes through
10251        // `FonteCaminhoAbsolute` not
10252        // `FonteCaminhoShellCommandSubstitution` — the host-layout-
10253        // leak diagnostic is the load-bearing axis, the backtick
10254        // byte is the secondary observation. Same precedence logic
10255        // as every prior leading-byte arm.
10256        let d = dep_with_fonte(DepSource::Path {
10257            caminho: "/etc/passwd `whoami`".into(),
10258        });
10259        let err = d.validate().unwrap_err();
10260        assert!(
10261            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10262            "got {err:?}",
10263        );
10264    }
10265
10266    #[test]
10267    fn fonte_caminho_shell_command_substitution_fires_before_trailing_slash() {
10268        // Cascade pin on the immediate-successor arm: a value
10269        // carrying both a backtick and a trailing `/`
10270        // (``"../`whoami`/"`` — the canonical "I tab-completed a
10271        // path that already had a backticked `whoami` substitution
10272        // tail" footgun) routes through
10273        // `FonteCaminhoShellCommandSubstitution` not
10274        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
10275        // is the more semantic-locating axis (an author who removes
10276        // the backtick typically also drops the trailing separator
10277        // since both are paste-from-shell artifacts).
10278        let d = dep_with_fonte(DepSource::Path {
10279            caminho: "../`whoami`/".into(),
10280        });
10281        let err = d.validate().unwrap_err();
10282        assert!(
10283            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
10284            "got {err:?}",
10285        );
10286    }
10287
10288    #[test]
10289    fn fonte_caminho_shell_command_substitution_diagnostic_carries_offending_dep_and_caminho() {
10290        // Diagnostic-shape pin (peer with
10291        // `fonte_caminho_shell_background_diagnostic_carries_offending_dep_and_caminho`
10292        // on the closest single-byte peer arm): the error's Display
10293        // surfaces the offending `:nome` and the offending `:caminho`
10294        // verbatim, and names the shell-command-substitution footgun
10295        // explicitly so a `feira lint` run can render the diagnostic
10296        // without re-parsing.
10297        let d = dep_with_fonte(DepSource::Path {
10298            caminho: "../caixa-teia/`whoami`".into(),
10299        });
10300        let rendered = d.validate().unwrap_err().to_string();
10301        assert!(
10302            rendered.contains("caixa-teia"),
10303            "diagnostic must name the offending dep: {rendered}",
10304        );
10305        assert!(
10306            rendered.contains("../caixa-teia/`whoami`"),
10307            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10308        );
10309        assert!(
10310            rendered.contains('`'),
10311            "diagnostic must reference the backtick footgun: {rendered:?}",
10312        );
10313        assert!(
10314            rendered.contains("command-substitution"),
10315            "diagnostic must name the shell-command-substitution footgun: {rendered:?}",
10316        );
10317    }
10318
10319    #[test]
10320    fn validate_rejects_path_fonte_with_caminho_carrying_star_glob() {
10321        // The fail-before-pass-after pin for the canonical pathname-
10322        // expansion paste footgun: an author copies an `ls
10323        // ../caixa-teia/*` shell-listing tail into the `:caminho`
10324        // slot and silently passes every prior arm
10325        // (`Path::is_absolute` false on `..`, no control bytes, no
10326        // `\`, no `<` / `>`, no `|`, no `;`, no `&`, no backtick,
10327        // doesn't end in `/`). The lacre embedded the value
10328        // verbatim, the resolver folded it through `Path::join`
10329        // looking for a literal `./../caixa-teia/*` subdirectory,
10330        // and the failure surfaced at resolve time with a non-self-
10331        // locating `No such file or directory` error. The new arm
10332        // moves the rejection to validate time and names the
10333        // offending dep + caminho + byte verbatim.
10334        let d = dep_with_fonte(DepSource::Path {
10335            caminho: "../caixa-teia/*".into(),
10336        });
10337        let err = d.validate().unwrap_err();
10338        let DepError::FonteCaminhoShellGlob {
10339            nome,
10340            caminho,
10341            byte,
10342        } = err
10343        else {
10344            panic!("expected FonteCaminhoShellGlob, got {err:?}");
10345        };
10346        assert_eq!(nome, "caixa-teia");
10347        assert_eq!(caminho, "../caixa-teia/*");
10348        assert_eq!(byte, b'*');
10349    }
10350
10351    #[test]
10352    fn validate_rejects_path_fonte_with_caminho_carrying_question_glob() {
10353        // The symmetric single-char-wildcard paste shape
10354        // (`"../foo?"` — the canonical "I copied a `rm foo?` line
10355        // out of shell history" idiom). Pinned separately from the
10356        // `*` shape so the gate's contract is "any `*` or `?`
10357        // anywhere", not single-byte coverage.
10358        let d = dep_with_fonte(DepSource::Path {
10359            caminho: "../foo?".into(),
10360        });
10361        let err = d.validate().unwrap_err();
10362        let DepError::FonteCaminhoShellGlob { byte, .. } = err else {
10363            panic!("expected FonteCaminhoShellGlob, got {err:?}");
10364        };
10365        assert_eq!(byte, b'?');
10366    }
10367
10368    #[test]
10369    fn validate_rejects_path_fonte_with_caminho_carrying_leading_star_glob() {
10370        // Leading-position `*` shape (`"*/caixa-teia"` — the
10371        // degenerate "I selected only the wildcard prefix out of a
10372        // shell-glob expression" idiom). Pinned separately from the
10373        // embedded-byte shapes so the gate covers every position,
10374        // not only mid-path.
10375        let d = dep_with_fonte(DepSource::Path {
10376            caminho: "*/caixa-teia".into(),
10377        });
10378        let err = d.validate().unwrap_err();
10379        assert!(
10380            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
10381            "got {err:?}",
10382        );
10383    }
10384
10385    #[test]
10386    fn validate_rejects_path_fonte_with_caminho_carrying_double_star_recursive_glob() {
10387        // The bash/zsh `globstar` recursive-glob shape
10388        // (`"../caixa-teia/**/foo"` — the canonical "I copied a
10389        // `find ../caixa-teia/**/foo` recursive expansion" idiom).
10390        // The arm fires on the first `*` encountered; pinned so a
10391        // future arm that tries to distinguish single `*` from
10392        // double `**` doesn't break the broader contract.
10393        let d = dep_with_fonte(DepSource::Path {
10394            caminho: "../caixa-teia/**/foo".into(),
10395        });
10396        let err = d.validate().unwrap_err();
10397        assert!(
10398            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
10399            "got {err:?}",
10400        );
10401    }
10402
10403    #[test]
10404    fn validate_rejects_path_fonte_with_caminho_carrying_dotted_extension_glob() {
10405        // The canonical extension-glob shape (`"../caixa-teia/*.lisp"`
10406        // — the "I selected `*.lisp` to mean every Lisp source file
10407        // in the dep root" footgun the prior arms structurally
10408        // cannot catch since `.` is a POSIX-valid path-component
10409        // byte). Pinned so the gate's contract covers the most
10410        // idiomatic glob-paste shape every author meets first.
10411        let d = dep_with_fonte(DepSource::Path {
10412            caminho: "../caixa-teia/*.lisp".into(),
10413        });
10414        let err = d.validate().unwrap_err();
10415        assert!(
10416            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
10417            "got {err:?}",
10418        );
10419    }
10420
10421    #[test]
10422    fn validate_accepts_path_fonte_with_caminho_carrying_no_glob() {
10423        // The positive-control pin: the gate targets only `*` /
10424        // `?`, never adjacent printable ASCII or POSIX-valid bytes.
10425        // The canonical relative POSIX path (`"../caixa-teia"`) and
10426        // a nested deeply-pathed variant with adjacent printable
10427        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
10428        // to validate cleanly so the gate doesn't widen to a "no
10429        // printable punctuation anywhere" sweep that would defeat
10430        // the entire path-fonte author surface.
10431        let d = dep_with_fonte(DepSource::Path {
10432            caminho: "../caixa-teia/sub-dir.v2".into(),
10433        });
10434        d.validate().unwrap();
10435    }
10436
10437    #[test]
10438    fn fonte_caminho_shell_command_substitution_fires_before_shell_glob() {
10439        // Cascade pin on the immediate-predecessor arm: a value
10440        // carrying both a backtick and `*` (``"../`whoami`/*"`` —
10441        // the canonical "I pasted a `cd <backtick>whoami<backtick>/*`
10442        // command-substitution + glob chain") routes through
10443        // `FonteCaminhoShellCommandSubstitution` not
10444        // `FonteCaminhoShellGlob`. The CWE-78 shell-command-
10445        // injection vector is the load-bearing root-cause edit on
10446        // every probe-as-both value — same cascade discipline every
10447        // prior `:caminho` arm establishes.
10448        let d = dep_with_fonte(DepSource::Path {
10449            caminho: "../`whoami`/*".into(),
10450        });
10451        let err = d.validate().unwrap_err();
10452        assert!(
10453            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
10454            "got {err:?}",
10455        );
10456    }
10457
10458    #[test]
10459    fn fonte_caminho_shell_background_fires_before_shell_glob() {
10460        // Cascade pin on the upstream shell-background arm: a value
10461        // carrying both `&` and `*` (`"../caixa-teia & ls /*"` — the
10462        // canonical "I pasted a `cmd & ls /*` background + glob
10463        // chain" footgun) routes through `FonteCaminhoShellBackground`
10464        // not `FonteCaminhoShellGlob`. The background-launch tail is
10465        // the load-bearing root-cause edit on every probe-as-both
10466        // value.
10467        let d = dep_with_fonte(DepSource::Path {
10468            caminho: "../caixa-teia & ls /*".into(),
10469        });
10470        let err = d.validate().unwrap_err();
10471        assert!(
10472            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
10473            "got {err:?}",
10474        );
10475    }
10476
10477    #[test]
10478    fn fonte_caminho_shell_semicolon_fires_before_shell_glob() {
10479        // Cascade pin on the upstream shell-semicolon arm: a value
10480        // carrying both `;` and `*` (`"../caixa-teia; rm *"` — the
10481        // canonical sequential-cleanup + glob paste idiom) routes
10482        // through `FonteCaminhoShellSemicolon` not
10483        // `FonteCaminhoShellGlob`. The sequential-command-separator
10484        // paste is the load-bearing root-cause edit on every
10485        // probe-as-both value.
10486        let d = dep_with_fonte(DepSource::Path {
10487            caminho: "../caixa-teia; rm *".into(),
10488        });
10489        let err = d.validate().unwrap_err();
10490        assert!(
10491            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
10492            "got {err:?}",
10493        );
10494    }
10495
10496    #[test]
10497    fn fonte_caminho_shell_pipe_fires_before_shell_glob() {
10498        // Cascade pin on the upstream shell-pipe arm: a value
10499        // carrying both `|` and `*` (`"../caixa-teia | ls *"` — the
10500        // canonical pipeline-to-glob paste idiom) routes through
10501        // `FonteCaminhoShellPipe` not `FonteCaminhoShellGlob`. The
10502        // pipeline-tail paste is the load-bearing root-cause edit
10503        // on every probe-as-both value.
10504        let d = dep_with_fonte(DepSource::Path {
10505            caminho: "../caixa-teia | ls *".into(),
10506        });
10507        let err = d.validate().unwrap_err();
10508        assert!(
10509            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10510            "got {err:?}",
10511        );
10512    }
10513
10514    #[test]
10515    fn fonte_caminho_shell_redirection_fires_before_shell_glob() {
10516        // Cascade pin on the upstream shell-redirection arm: a value
10517        // carrying both `>` and `*` (`"../caixa-teia>log *"` — the
10518        // canonical "I pasted a `cmd > log *` redirect-plus-glob
10519        // chain" footgun) routes through
10520        // `FonteCaminhoShellRedirection` not `FonteCaminhoShellGlob`.
10521        // The input/output redirection metachar carries the more
10522        // self-locating `byte` payload (it names which of `<` or `>`
10523        // triggered), so the prior arm wins on every probe-as-both
10524        // value.
10525        let d = dep_with_fonte(DepSource::Path {
10526            caminho: "../caixa-teia>log *".into(),
10527        });
10528        let err = d.validate().unwrap_err();
10529        assert!(
10530            matches!(
10531                err,
10532                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
10533            ),
10534            "got {err:?}",
10535        );
10536    }
10537
10538    #[test]
10539    fn fonte_caminho_backslash_fires_before_shell_glob() {
10540        // Cascade pin on the upstream backslash arm: a value
10541        // carrying both `\` and `*` (`"..\caixa-teia\*"` — the
10542        // canonical "I pasted a Windows-shell `cd ..\path\*` glob
10543        // expression" footgun) routes through
10544        // `FonteCaminhoBackslash` not `FonteCaminhoShellGlob`. The
10545        // cross-host-OS-separator divergence is the load-bearing
10546        // axis on every probe-as-both value (an author who removes
10547        // the `\` is the root-cause edit; the `*` falls away in the
10548        // same edit since it's downstream of the Windows-shell
10549        // convention).
10550        let d = dep_with_fonte(DepSource::Path {
10551            caminho: "..\\caixa-teia\\*".into(),
10552        });
10553        let err = d.validate().unwrap_err();
10554        assert!(
10555            matches!(err, DepError::FonteCaminhoBackslash { .. }),
10556            "got {err:?}",
10557        );
10558    }
10559
10560    #[test]
10561    fn fonte_caminho_control_char_fires_before_shell_glob() {
10562        // Cascade pin on the embedded-control-byte arm: a value
10563        // carrying both a control byte and `*` (`"../foo\n*"` — the
10564        // canonical paste-from-multiline-doc footgun where a
10565        // newline landed mid-caminho between two paste fragments)
10566        // routes through `FonteCaminhoControlChar` not
10567        // `FonteCaminhoShellGlob`. The POSIX-syscall-rejected-byte /
10568        // NUL-`CString::new`-fail diagnostic is the load-bearing
10569        // axis on every value that probes positive for both —
10570        // mirrors the cascade discipline on every prior arm.
10571        let d = dep_with_fonte(DepSource::Path {
10572            caminho: "../foo\n*".into(),
10573        });
10574        let err = d.validate().unwrap_err();
10575        assert!(
10576            matches!(err, DepError::FonteCaminhoControlChar { .. }),
10577            "got {err:?}",
10578        );
10579    }
10580
10581    #[test]
10582    fn fonte_caminho_absolute_fires_before_shell_glob() {
10583        // Cascade pin on the load-bearing leading-byte arm: a
10584        // leading `/` value with embedded `*` (`"/etc/*"`) routes
10585        // through `FonteCaminhoAbsolute` not `FonteCaminhoShellGlob`
10586        // — the host-layout-leak diagnostic is the load-bearing
10587        // axis, the glob byte is the secondary observation. Same
10588        // precedence logic as every prior leading-byte arm.
10589        let d = dep_with_fonte(DepSource::Path {
10590            caminho: "/etc/*".into(),
10591        });
10592        let err = d.validate().unwrap_err();
10593        assert!(
10594            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10595            "got {err:?}",
10596        );
10597    }
10598
10599    #[test]
10600    fn fonte_caminho_shell_glob_fires_before_trailing_slash() {
10601        // Cascade pin on the immediate-successor arm: a value
10602        // carrying both `*` and a trailing `/` (`"../foo*/"` — the
10603        // canonical "I tab-completed a path that already had a
10604        // glob-expansion tail" footgun) routes through
10605        // `FonteCaminhoShellGlob` not `FonteCaminhoTrailingSlash`.
10606        // The embedded shell-metachar is the more semantic-locating
10607        // axis (an author who removes the `*` typically also drops
10608        // the trailing separator since both are paste-from-shell
10609        // artifacts).
10610        let d = dep_with_fonte(DepSource::Path {
10611            caminho: "../foo*/".into(),
10612        });
10613        let err = d.validate().unwrap_err();
10614        assert!(
10615            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
10616            "got {err:?}",
10617        );
10618    }
10619
10620    #[test]
10621    fn fonte_caminho_shell_glob_diagnostic_carries_offending_dep_caminho_and_byte() {
10622        // Diagnostic-shape pin (peer with
10623        // `fonte_caminho_shell_redirection_diagnostic_*` on the
10624        // closest two-byte peer arm): the error's Display surfaces
10625        // the offending `:nome`, the offending `:caminho` verbatim,
10626        // the offending byte's hex / character form, and names the
10627        // shell-glob / pathname-expansion footgun explicitly so a
10628        // `feira lint` run can render the diagnostic without
10629        // re-parsing.
10630        let d = dep_with_fonte(DepSource::Path {
10631            caminho: "../caixa-teia/*.lisp".into(),
10632        });
10633        let rendered = d.validate().unwrap_err().to_string();
10634        assert!(
10635            rendered.contains("caixa-teia"),
10636            "diagnostic must name the offending dep: {rendered}",
10637        );
10638        assert!(
10639            rendered.contains("../caixa-teia/*.lisp"),
10640            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10641        );
10642        assert!(
10643            rendered.contains("0x2a"),
10644            "diagnostic must surface the offending byte hex: {rendered:?}",
10645        );
10646        assert!(
10647            rendered.contains("glob"),
10648            "diagnostic must name the shell-glob footgun: {rendered:?}",
10649        );
10650        assert!(
10651            rendered.contains("pathname-expansion"),
10652            "diagnostic must reference the POSIX pathname-expansion vocabulary: {rendered:?}",
10653        );
10654    }
10655
10656    #[test]
10657    fn validate_rejects_path_fonte_with_caminho_carrying_modern_command_substitution() {
10658        // The fail-before-pass-after pin for the canonical modern-Bourne
10659        // command-substitution paste footgun: an author copies a
10660        // `cd ../caixa-teia/$(date)/build` shell-history one-liner whose
10661        // `$(<cmd>)` expansion would land the current date as a
10662        // subdirectory name and silently passed every prior arm
10663        // (`Path::is_absolute` false on `..`, no control bytes, no `\`,
10664        // no `<` / `>`, no `|`, no `;`, no `&`, no backtick, no `*` /
10665        // `?`, doesn't end in `/`; the leading-`$` f4efe9c
10666        // `FonteCaminhoVarExpansion` arm doesn't fire because the `$`
10667        // sits mid-path). The lacre embedded the value verbatim, the
10668        // resolver folded it through `Path::join` looking for a literal
10669        // `./../caixa-teia/$(date)/build` subdirectory, and the failure
10670        // surfaced at resolve time with a non-self-locating `No such
10671        // file or directory` error. The new arm moves the rejection to
10672        // validate time and names the offending dep + caminho + byte
10673        // verbatim. The arm fires on the first `(` encountered (the
10674        // opening byte of `$(date)`).
10675        let d = dep_with_fonte(DepSource::Path {
10676            caminho: "../caixa-teia/$(date)/build".into(),
10677        });
10678        let err = d.validate().unwrap_err();
10679        let DepError::FonteCaminhoShellSubshellGrouping {
10680            nome,
10681            caminho,
10682            byte,
10683        } = err
10684        else {
10685            panic!("expected FonteCaminhoShellSubshellGrouping, got {err:?}");
10686        };
10687        assert_eq!(nome, "caixa-teia");
10688        assert_eq!(caminho, "../caixa-teia/$(date)/build");
10689        assert_eq!(byte, b'(');
10690    }
10691
10692    #[test]
10693    fn validate_rejects_path_fonte_with_caminho_carrying_close_paren() {
10694        // The symmetric close-paren paste shape (`"../caixa-teia)"` —
10695        // the degenerate "I selected an unbalanced closing paren out of
10696        // a shell-history block" idiom that probes for the cascade's
10697        // last-byte handling on a value carrying only the closing byte).
10698        // Pinned separately from the open-paren shape so the gate's
10699        // contract is "any `(` or `)` anywhere", not single-byte
10700        // coverage. Mirrors the peer `validate_rejects_path_fonte_with_\
10701        // caminho_carrying_question_glob` shape on the immediate-
10702        // predecessor `FonteCaminhoShellGlob` arm.
10703        let d = dep_with_fonte(DepSource::Path {
10704            caminho: "../caixa-teia)".into(),
10705        });
10706        let err = d.validate().unwrap_err();
10707        let DepError::FonteCaminhoShellSubshellGrouping { byte, .. } = err else {
10708            panic!("expected FonteCaminhoShellSubshellGrouping, got {err:?}");
10709        };
10710        assert_eq!(byte, b')');
10711    }
10712
10713    #[test]
10714    fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_paren() {
10715        // Leading-position `(` shape (`"(cd foo)/caixa-teia"` — the
10716        // canonical "I selected a `(cd foo)` subshell-grouping prefix
10717        // out of a `(cd foo) && cmd` shell-history one-liner" idiom).
10718        // Pinned separately from the embedded-byte shape so the gate
10719        // covers every position, not only mid-path.
10720        let d = dep_with_fonte(DepSource::Path {
10721            caminho: "(cd foo)/caixa-teia".into(),
10722        });
10723        let err = d.validate().unwrap_err();
10724        assert!(
10725            matches!(
10726                err,
10727                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
10728            ),
10729            "got {err:?}",
10730        );
10731    }
10732
10733    #[test]
10734    fn validate_rejects_path_fonte_with_caminho_carrying_balanced_subshell_grouping_pair() {
10735        // The canonical balanced-pair shape (`"../(pwd)/caixa-teia"`
10736        // — the canonical "I copied a `(pwd)` working-directory-probe
10737        // subshell-grouping idiom every shell-history block carries"
10738        // footgun). The value carries no other cascade-preceding
10739        // shell metachar (`&` / `;` / `|` / `<` / `>` / backtick /
10740        // `*` / `?`) so the arm fires on the first `(` encountered;
10741        // pinned so a future arm that tries to distinguish the
10742        // opening from the closing byte doesn't break the broader
10743        // contract. Mirrors the peer
10744        // `validate_rejects_path_fonte_with_caminho_carrying_balanced_\
10745        // backtick_pair` shape on the upstream `FonteCaminhoShell\
10746        // CommandSubstitution` arm.
10747        let d = dep_with_fonte(DepSource::Path {
10748            caminho: "../(pwd)/caixa-teia".into(),
10749        });
10750        let err = d.validate().unwrap_err();
10751        assert!(
10752            matches!(
10753                err,
10754                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
10755            ),
10756            "got {err:?}",
10757        );
10758    }
10759
10760    #[test]
10761    fn validate_accepts_path_fonte_with_caminho_carrying_no_subshell_grouping() {
10762        // The positive-control pin: the gate targets only `(` / `)`,
10763        // never adjacent printable ASCII or POSIX-valid bytes. The
10764        // canonical relative POSIX path (`"../caixa-teia"`) and a
10765        // nested deeply-pathed variant with adjacent printable
10766        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue to
10767        // validate cleanly so the gate doesn't widen to a "no printable
10768        // punctuation anywhere" sweep that would defeat the entire
10769        // path-fonte author surface.
10770        let d = dep_with_fonte(DepSource::Path {
10771            caminho: "../caixa-teia/sub-dir.v2".into(),
10772        });
10773        d.validate().unwrap();
10774    }
10775
10776    #[test]
10777    fn fonte_caminho_shell_glob_fires_before_shell_subshell_grouping() {
10778        // Cascade pin on the immediate-predecessor arm: a value
10779        // carrying both `*` and `(` (`"../caixa-teia/*(date)"` — the
10780        // canonical "I pasted a glob expansion followed by a
10781        // subshell-grouping tail" footgun) routes through
10782        // `FonteCaminhoShellGlob` not
10783        // `FonteCaminhoShellSubshellGrouping`. The pathname-expansion
10784        // shape is the more common shell-history paste idiom on every
10785        // probe-as-both value — same cascade discipline every prior
10786        // `:caminho` arm establishes.
10787        let d = dep_with_fonte(DepSource::Path {
10788            caminho: "../caixa-teia/*(date)".into(),
10789        });
10790        let err = d.validate().unwrap_err();
10791        assert!(
10792            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
10793            "got {err:?}",
10794        );
10795    }
10796
10797    #[test]
10798    fn fonte_caminho_shell_command_substitution_fires_before_shell_subshell_grouping() {
10799        // Cascade pin on the upstream shell-command-substitution arm: a
10800        // value carrying both a backtick and `(` (``"../`whoami`/$(date)"``
10801        // — the canonical "I pasted a legacy-backtick + modern-paren
10802        // command-substitution chain" footgun) routes through
10803        // `FonteCaminhoShellCommandSubstitution` not
10804        // `FonteCaminhoShellSubshellGrouping`. The CWE-78 shell-
10805        // command-injection vector is the load-bearing root-cause edit
10806        // on every probe-as-both value.
10807        let d = dep_with_fonte(DepSource::Path {
10808            caminho: "../`whoami`/$(date)".into(),
10809        });
10810        let err = d.validate().unwrap_err();
10811        assert!(
10812            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
10813            "got {err:?}",
10814        );
10815    }
10816
10817    #[test]
10818    fn fonte_caminho_shell_background_fires_before_shell_subshell_grouping() {
10819        // Cascade pin on the upstream shell-background arm: a value
10820        // carrying both `&` and `(` (`"../caixa-teia & (cd foo)"` —
10821        // the canonical "I pasted a `cmd & (cd foo)` background-launch
10822        // + subshell-grouping chain" footgun) routes through
10823        // `FonteCaminhoShellBackground` not
10824        // `FonteCaminhoShellSubshellGrouping`. The background-launch
10825        // tail is the load-bearing root-cause edit on every probe-as-
10826        // both value.
10827        let d = dep_with_fonte(DepSource::Path {
10828            caminho: "../caixa-teia & (cd foo)".into(),
10829        });
10830        let err = d.validate().unwrap_err();
10831        assert!(
10832            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
10833            "got {err:?}",
10834        );
10835    }
10836
10837    #[test]
10838    fn fonte_caminho_shell_semicolon_fires_before_shell_subshell_grouping() {
10839        // Cascade pin on the upstream shell-semicolon arm: a value
10840        // carrying both `;` and `(` (`"../caixa-teia; (cd foo)"` —
10841        // the canonical sequential-cleanup + subshell-grouping paste
10842        // idiom) routes through `FonteCaminhoShellSemicolon` not
10843        // `FonteCaminhoShellSubshellGrouping`. The sequential-command-
10844        // separator paste is the load-bearing root-cause edit on
10845        // every probe-as-both value.
10846        let d = dep_with_fonte(DepSource::Path {
10847            caminho: "../caixa-teia; (cd foo)".into(),
10848        });
10849        let err = d.validate().unwrap_err();
10850        assert!(
10851            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
10852            "got {err:?}",
10853        );
10854    }
10855
10856    #[test]
10857    fn fonte_caminho_shell_pipe_fires_before_shell_subshell_grouping() {
10858        // Cascade pin on the upstream shell-pipe arm: a value carrying
10859        // both `|` and `(` (`"../caixa-teia | (tee log)"` — the
10860        // canonical pipeline-to-subshell-grouping paste idiom) routes
10861        // through `FonteCaminhoShellPipe` not
10862        // `FonteCaminhoShellSubshellGrouping`. The pipeline-tail paste
10863        // is the load-bearing root-cause edit on every probe-as-both
10864        // value.
10865        let d = dep_with_fonte(DepSource::Path {
10866            caminho: "../caixa-teia | (tee log)".into(),
10867        });
10868        let err = d.validate().unwrap_err();
10869        assert!(
10870            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10871            "got {err:?}",
10872        );
10873    }
10874
10875    #[test]
10876    fn fonte_caminho_shell_redirection_fires_before_shell_subshell_grouping() {
10877        // Cascade pin on the upstream shell-redirection arm: a value
10878        // carrying both `>` and `(` (`"../caixa-teia>log (cd foo)"` —
10879        // the canonical "I pasted a `cmd > log (cd foo)` redirect-
10880        // plus-subshell-grouping chain" footgun) routes through
10881        // `FonteCaminhoShellRedirection` not
10882        // `FonteCaminhoShellSubshellGrouping`. The input/output
10883        // redirection metachar carries the more self-locating `byte`
10884        // payload (it names which of `<` or `>` triggered), so the
10885        // prior arm wins on every probe-as-both value.
10886        let d = dep_with_fonte(DepSource::Path {
10887            caminho: "../caixa-teia>log (cd foo)".into(),
10888        });
10889        let err = d.validate().unwrap_err();
10890        assert!(
10891            matches!(
10892                err,
10893                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
10894            ),
10895            "got {err:?}",
10896        );
10897    }
10898
10899    #[test]
10900    fn fonte_caminho_backslash_fires_before_shell_subshell_grouping() {
10901        // Cascade pin on the upstream backslash arm: a value carrying
10902        // both `\` and `(` (`"..\caixa-teia\(cd foo)"` — the canonical
10903        // "I pasted a Windows-shell `cd ..\path\(cmd)` chain") routes
10904        // through `FonteCaminhoBackslash` not
10905        // `FonteCaminhoShellSubshellGrouping`. The cross-host-OS-
10906        // separator divergence is the load-bearing axis on every
10907        // probe-as-both value (an author who removes the `\` is the
10908        // root-cause edit; the `(` falls away in the same edit since
10909        // it's downstream of the Windows-shell convention).
10910        let d = dep_with_fonte(DepSource::Path {
10911            caminho: "..\\caixa-teia\\(cd foo)".into(),
10912        });
10913        let err = d.validate().unwrap_err();
10914        assert!(
10915            matches!(err, DepError::FonteCaminhoBackslash { .. }),
10916            "got {err:?}",
10917        );
10918    }
10919
10920    #[test]
10921    fn fonte_caminho_control_char_fires_before_shell_subshell_grouping() {
10922        // Cascade pin on the embedded-control-byte arm: a value
10923        // carrying both a control byte and `(` (`"../foo\n(cd bar)"` —
10924        // the canonical paste-from-multiline-doc footgun where a
10925        // newline landed mid-caminho between two paste fragments)
10926        // routes through `FonteCaminhoControlChar` not
10927        // `FonteCaminhoShellSubshellGrouping`. The POSIX-syscall-
10928        // rejected-byte / NUL-`CString::new`-fail diagnostic is the
10929        // load-bearing axis on every value that probes positive for
10930        // both — mirrors the cascade discipline on every prior arm.
10931        let d = dep_with_fonte(DepSource::Path {
10932            caminho: "../foo\n(cd bar)".into(),
10933        });
10934        let err = d.validate().unwrap_err();
10935        assert!(
10936            matches!(err, DepError::FonteCaminhoControlChar { .. }),
10937            "got {err:?}",
10938        );
10939    }
10940
10941    #[test]
10942    fn fonte_caminho_absolute_fires_before_shell_subshell_grouping() {
10943        // Cascade pin on the load-bearing leading-byte arm: a leading
10944        // `/` value with embedded `(` (`"/etc/(cd foo)"`) routes
10945        // through `FonteCaminhoAbsolute` not
10946        // `FonteCaminhoShellSubshellGrouping` — the host-layout-leak
10947        // diagnostic is the load-bearing axis, the subshell-grouping
10948        // byte is the secondary observation. Same precedence logic as
10949        // every prior leading-byte arm.
10950        let d = dep_with_fonte(DepSource::Path {
10951            caminho: "/etc/(cd foo)".into(),
10952        });
10953        let err = d.validate().unwrap_err();
10954        assert!(
10955            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10956            "got {err:?}",
10957        );
10958    }
10959
10960    #[test]
10961    fn fonte_caminho_var_expansion_fires_before_shell_subshell_grouping() {
10962        // Cascade pin on the upstream leading-`$` var-expansion arm: a
10963        // value carrying both a leading `$` and a `(` (`"$(date)/\
10964        // caixa-teia"` — the canonical "I pasted a `$(date)` modern-
10965        // command-substitution at the head of a sibling-workspace
10966        // path" footgun) routes through `FonteCaminhoVarExpansion` not
10967        // `FonteCaminhoShellSubshellGrouping`. The leading-byte
10968        // shell-variable-expansion is the more self-locating diagnostic
10969        // on values that probe as both — same load-bearing-leading-
10970        // byte cascade discipline every prior `:caminho` arm
10971        // establishes. Closing both halves of `$(<cmd>)` structurally
10972        // (leading `$` here, trailing `)` on the new arm) excludes the
10973        // entire modern Bourne command-substitution surface from the
10974        // typed `:caminho` accepted set; the cascade preserves the
10975        // narrower leading-byte diagnostic on values that probe both
10976        // halves at the canonical leading position.
10977        let d = dep_with_fonte(DepSource::Path {
10978            caminho: "$(date)/caixa-teia".into(),
10979        });
10980        let err = d.validate().unwrap_err();
10981        assert!(
10982            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
10983            "got {err:?}",
10984        );
10985    }
10986
10987    #[test]
10988    fn fonte_caminho_shell_subshell_grouping_fires_before_trailing_slash() {
10989        // Cascade pin on the immediate-successor arm: a value carrying
10990        // both `(` and a trailing `/` (`"../(cd foo)/"` — the canonical
10991        // "I tab-completed a path that already had a subshell-grouping
10992        // expansion tail" footgun) routes through
10993        // `FonteCaminhoShellSubshellGrouping` not
10994        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
10995        // the more semantic-locating axis (an author who removes the
10996        // `(` typically also drops the trailing separator since both
10997        // are paste-from-shell artifacts).
10998        let d = dep_with_fonte(DepSource::Path {
10999            caminho: "../(cd foo)/".into(),
11000        });
11001        let err = d.validate().unwrap_err();
11002        assert!(
11003            matches!(
11004                err,
11005                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
11006            ),
11007            "got {err:?}",
11008        );
11009    }
11010
11011    #[test]
11012    fn fonte_caminho_shell_subshell_grouping_diagnostic_carries_offending_dep_caminho_and_byte() {
11013        // Diagnostic-shape pin (peer with
11014        // `fonte_caminho_shell_glob_diagnostic_carries_offending_dep_caminho_and_byte`
11015        // on the closest two-byte peer arm): the error's Display
11016        // surfaces the offending `:nome`, the offending `:caminho`
11017        // verbatim, the offending byte's hex / character form, and
11018        // names the shell-subshell-grouping footgun explicitly so a
11019        // `feira lint` run can render the diagnostic without re-
11020        // parsing.
11021        let d = dep_with_fonte(DepSource::Path {
11022            caminho: "../caixa-teia/$(date)/build".into(),
11023        });
11024        let rendered = d.validate().unwrap_err().to_string();
11025        assert!(
11026            rendered.contains("caixa-teia"),
11027            "diagnostic must name the offending dep: {rendered}",
11028        );
11029        assert!(
11030            rendered.contains("../caixa-teia/$(date)/build"),
11031            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11032        );
11033        assert!(
11034            rendered.contains("0x28"),
11035            "diagnostic must surface the offending byte hex: {rendered:?}",
11036        );
11037        assert!(
11038            rendered.contains("subshell-grouping"),
11039            "diagnostic must name the shell-subshell-grouping footgun: {rendered:?}",
11040        );
11041        assert!(
11042            rendered.contains("command-substitution"),
11043            "diagnostic must reference the `$(<cmd>)` command-substitution vocabulary: \
11044             {rendered:?}",
11045        );
11046    }
11047
11048    // ── shell-brace-expansion / URI-Template-placeholder arm ───────────
11049    //
11050    // Peer with the prior `FonteCaminhoShellSubshellGrouping` (`(` /
11051    // `)`) byte-pair arm: the same per-byte cascade with the same
11052    // self-locating `byte: u8` diagnostic on the orthogonal `{` /
11053    // `}` brace-expansion / URI-Template placeholder axis. The peer
11054    // [`crate::render::is_git_repo_url`] (42d8f9d) closes the same
11055    // byte pair on the sibling `:fonte :repo` axis under the same
11056    // banner.
11057
11058    #[test]
11059    fn validate_rejects_path_fonte_with_caminho_carrying_brace_expansion_fan_across_siblings() {
11060        // The fail-before-pass-after pin for the canonical paste-from-
11061        // shell-history brace-expansion footgun: an author copies a
11062        // `cd ../{caixa-teia,caixa-helm}/build` shell-history one-
11063        // liner whose `{a,b}` brace expansion fans across two siblings
11064        // and silently passed every prior arm (`Path::is_absolute`
11065        // false on `..`, no control bytes, no `\`, no `<` / `>`, no
11066        // `|`, no `;`, no `&`, no backtick, no `*` / `?`, no `(` /
11067        // `)`, doesn't end in `/`; the leading-`$` f4efe9c
11068        // `FonteCaminhoVarExpansion` arm doesn't fire because the
11069        // value starts with `..` not `$`). The lacre embedded the
11070        // value verbatim, the resolver folded it through `Path::join`
11071        // looking for a literal `./../{caixa-teia,caixa-helm}/build`
11072        // subdirectory, and the failure surfaced at resolve time with
11073        // a non-self-locating `No such file or directory` error. The
11074        // new arm moves the rejection to validate time and names the
11075        // offending dep + caminho + byte verbatim. The arm fires on
11076        // the first `{` encountered.
11077        let d = dep_with_fonte(DepSource::Path {
11078            caminho: "../{caixa-teia,caixa-helm}/build".into(),
11079        });
11080        let err = d.validate().unwrap_err();
11081        let DepError::FonteCaminhoShellBraceExpansion {
11082            nome,
11083            caminho,
11084            byte,
11085        } = err
11086        else {
11087            panic!("expected FonteCaminhoShellBraceExpansion, got {err:?}");
11088        };
11089        assert_eq!(nome, "caixa-teia");
11090        assert_eq!(caminho, "../{caixa-teia,caixa-helm}/build");
11091        assert_eq!(byte, b'{');
11092    }
11093
11094    #[test]
11095    fn validate_rejects_path_fonte_with_caminho_carrying_close_brace() {
11096        // The symmetric close-brace paste shape (`"../caixa-teia}"` —
11097        // the degenerate "I selected an unbalanced closing brace out
11098        // of a shell-history block" idiom that probes for the
11099        // cascade's last-byte handling on a value carrying only the
11100        // closing byte). Pinned separately from the open-brace shape
11101        // so the gate's contract is "any `{` or `}` anywhere", not
11102        // single-byte coverage. Mirrors the peer
11103        // `validate_rejects_path_fonte_with_caminho_carrying_close_paren`
11104        // shape on the immediate-predecessor `FonteCaminhoShellSubshellGrouping`
11105        // arm.
11106        let d = dep_with_fonte(DepSource::Path {
11107            caminho: "../caixa-teia}".into(),
11108        });
11109        let err = d.validate().unwrap_err();
11110        let DepError::FonteCaminhoShellBraceExpansion { byte, .. } = err else {
11111            panic!("expected FonteCaminhoShellBraceExpansion, got {err:?}");
11112        };
11113        assert_eq!(byte, b'}');
11114    }
11115
11116    #[test]
11117    fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_brace() {
11118        // Leading-position `{` shape (`"{caixa-teia,caixa-helm}/build"`
11119        // — the canonical "I selected a `{a,b}` brace-expansion prefix
11120        // out of a shell-history one-liner" idiom). Pinned separately
11121        // from the embedded-byte shape so the gate covers every
11122        // position, not only mid-path.
11123        let d = dep_with_fonte(DepSource::Path {
11124            caminho: "{caixa-teia,caixa-helm}/build".into(),
11125        });
11126        let err = d.validate().unwrap_err();
11127        assert!(
11128            matches!(
11129                err,
11130                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
11131            ),
11132            "got {err:?}",
11133        );
11134    }
11135
11136    #[test]
11137    fn validate_rejects_path_fonte_with_caminho_carrying_uri_template_placeholder() {
11138        // The canonical URI-Template / Mustache / Helm doubled-brace
11139        // placeholder shape (`"../{{org}}/caixa-teia"` — the canonical
11140        // "I copied a `https://github.com/{{org}}/caixa-teia` README
11141        // quick-start / OpenAPI spec / Helm chart `home:` template
11142        // and forgot to substitute the placeholder" footgun). The arm
11143        // fires on the first `{` encountered; pinned so the gate's
11144        // coverage extends from the bare-brace shell-history shape to
11145        // the doubled-brace URI-Template / templating-engine shape.
11146        // Mirrors the peer 42d8f9d `is_git_repo_url` arm on the
11147        // sibling `:fonte :repo` axis.
11148        let d = dep_with_fonte(DepSource::Path {
11149            caminho: "../{{org}}/caixa-teia".into(),
11150        });
11151        let err = d.validate().unwrap_err();
11152        assert!(
11153            matches!(
11154                err,
11155                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
11156            ),
11157            "got {err:?}",
11158        );
11159    }
11160
11161    #[test]
11162    fn validate_rejects_path_fonte_with_caminho_carrying_brace_range_expansion() {
11163        // The canonical bash brace-range-expansion shape (`"../caixa-
11164        // v{1..10}"` — the `{1..10}` sequence expansion every bash /
11165        // zsh `for i in {1..10}; do …; done` idiom uses, the symmetric
11166        // sequence-range form to the `{a,b,c}` comma-separated form).
11167        // The arm fires on the first `{` encountered; pinned so the
11168        // gate's coverage extends from the comma-separated form to
11169        // the integer-range form.
11170        let d = dep_with_fonte(DepSource::Path {
11171            caminho: "../caixa-v{1..10}".into(),
11172        });
11173        let err = d.validate().unwrap_err();
11174        assert!(
11175            matches!(
11176                err,
11177                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
11178            ),
11179            "got {err:?}",
11180        );
11181    }
11182
11183    #[test]
11184    fn validate_accepts_path_fonte_with_caminho_carrying_no_brace_expansion() {
11185        // The positive-control pin: the gate targets only `{` / `}`,
11186        // never adjacent printable ASCII or POSIX-valid bytes. The
11187        // canonical relative POSIX path (`"../caixa-teia"`) and a
11188        // nested deeply-pathed variant with adjacent printable
11189        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue to
11190        // validate cleanly so the gate doesn't widen to a "no
11191        // printable punctuation anywhere" sweep that would defeat
11192        // the entire path-fonte author surface. Peer with
11193        // `validate_accepts_path_fonte_with_caminho_carrying_no_subshell_grouping`
11194        // on the immediate-predecessor arm.
11195        let d = dep_with_fonte(DepSource::Path {
11196            caminho: "../caixa-teia/sub-dir.v2".into(),
11197        });
11198        d.validate().unwrap();
11199    }
11200
11201    #[test]
11202    fn fonte_caminho_shell_subshell_grouping_fires_before_shell_brace_expansion() {
11203        // Cascade pin on the immediate-predecessor arm: a value
11204        // carrying both `(` and `{` (`"../(cd foo)/{a,b}"` — the
11205        // canonical "I pasted a subshell-grouping followed by a
11206        // brace-expansion tail" footgun) routes through
11207        // `FonteCaminhoShellSubshellGrouping` not
11208        // `FonteCaminhoShellBraceExpansion`. The subshell-grouping
11209        // shape is the more semantic-locating axis on every probe-
11210        // as-both value because it closes both halves of the modern
11211        // Bourne `$(<cmd>)` command-substitution surface — same
11212        // cascade discipline every prior `:caminho` arm establishes.
11213        let d = dep_with_fonte(DepSource::Path {
11214            caminho: "../(cd foo)/{a,b}".into(),
11215        });
11216        let err = d.validate().unwrap_err();
11217        assert!(
11218            matches!(
11219                err,
11220                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
11221            ),
11222            "got {err:?}",
11223        );
11224    }
11225
11226    #[test]
11227    fn fonte_caminho_shell_glob_fires_before_shell_brace_expansion() {
11228        // Cascade pin on the upstream shell-glob arm: a value carrying
11229        // both `*` and `{` (`"../caixa-teia/*{a,b}"` — the canonical
11230        // "I pasted a glob expansion followed by a brace-expansion
11231        // tail" footgun) routes through `FonteCaminhoShellGlob` not
11232        // `FonteCaminhoShellBraceExpansion`. The pathname-expansion
11233        // shape is the load-bearing root-cause edit on every
11234        // probe-as-both value.
11235        let d = dep_with_fonte(DepSource::Path {
11236            caminho: "../caixa-teia/*{a,b}".into(),
11237        });
11238        let err = d.validate().unwrap_err();
11239        assert!(
11240            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
11241            "got {err:?}",
11242        );
11243    }
11244
11245    #[test]
11246    fn fonte_caminho_shell_command_substitution_fires_before_shell_brace_expansion() {
11247        // Cascade pin on the upstream shell-command-substitution arm:
11248        // a value carrying both a backtick and `{` (``"../`whoami`/{a,b}"``
11249        // — the canonical "I pasted a legacy-backtick command-
11250        // substitution followed by a brace-expansion fan-out" footgun)
11251        // routes through `FonteCaminhoShellCommandSubstitution` not
11252        // `FonteCaminhoShellBraceExpansion`. The CWE-78 shell-
11253        // command-injection vector is the load-bearing root-cause
11254        // edit on every probe-as-both value.
11255        let d = dep_with_fonte(DepSource::Path {
11256            caminho: "../`whoami`/{a,b}".into(),
11257        });
11258        let err = d.validate().unwrap_err();
11259        assert!(
11260            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11261            "got {err:?}",
11262        );
11263    }
11264
11265    #[test]
11266    fn fonte_caminho_shell_background_fires_before_shell_brace_expansion() {
11267        // Cascade pin on the upstream shell-background arm: a value
11268        // carrying both `&` and `{` (`"../caixa-teia & {a,b}"` — the
11269        // canonical "I pasted a `cmd & {fork-fan}` background-launch
11270        // + brace-expansion chain" footgun) routes through
11271        // `FonteCaminhoShellBackground` not
11272        // `FonteCaminhoShellBraceExpansion`. The background-launch
11273        // tail is the load-bearing root-cause edit on every
11274        // probe-as-both value.
11275        let d = dep_with_fonte(DepSource::Path {
11276            caminho: "../caixa-teia & {a,b}".into(),
11277        });
11278        let err = d.validate().unwrap_err();
11279        assert!(
11280            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11281            "got {err:?}",
11282        );
11283    }
11284
11285    #[test]
11286    fn fonte_caminho_shell_semicolon_fires_before_shell_brace_expansion() {
11287        // Cascade pin on the upstream shell-semicolon arm: a value
11288        // carrying both `;` and `{` (`"../caixa-teia; {a,b}"` — the
11289        // canonical sequential-cleanup + brace-expansion paste
11290        // idiom) routes through `FonteCaminhoShellSemicolon` not
11291        // `FonteCaminhoShellBraceExpansion`. The sequential-command-
11292        // separator paste is the load-bearing root-cause edit on
11293        // every probe-as-both value.
11294        let d = dep_with_fonte(DepSource::Path {
11295            caminho: "../caixa-teia; {a,b}".into(),
11296        });
11297        let err = d.validate().unwrap_err();
11298        assert!(
11299            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11300            "got {err:?}",
11301        );
11302    }
11303
11304    #[test]
11305    fn fonte_caminho_shell_pipe_fires_before_shell_brace_expansion() {
11306        // Cascade pin on the upstream shell-pipe arm: a value
11307        // carrying both `|` and `{` (`"../caixa-teia | {tee,cat}"`
11308        // — the canonical pipeline-to-brace-expansion paste idiom)
11309        // routes through `FonteCaminhoShellPipe` not
11310        // `FonteCaminhoShellBraceExpansion`. The pipeline-tail paste
11311        // is the load-bearing root-cause edit on every probe-as-
11312        // both value.
11313        let d = dep_with_fonte(DepSource::Path {
11314            caminho: "../caixa-teia | {tee,cat}".into(),
11315        });
11316        let err = d.validate().unwrap_err();
11317        assert!(
11318            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11319            "got {err:?}",
11320        );
11321    }
11322
11323    #[test]
11324    fn fonte_caminho_shell_redirection_fires_before_shell_brace_expansion() {
11325        // Cascade pin on the upstream shell-redirection arm: a value
11326        // carrying both `>` and `{` (`"../caixa-teia>log {a,b}"` —
11327        // the canonical "I pasted a `cmd > log {a,b}` redirect-
11328        // plus-brace-expansion chain" footgun) routes through
11329        // `FonteCaminhoShellRedirection` not
11330        // `FonteCaminhoShellBraceExpansion`. The input/output
11331        // redirection metachar carries the more self-locating
11332        // `byte` payload, so the prior arm wins on every probe-
11333        // as-both value.
11334        let d = dep_with_fonte(DepSource::Path {
11335            caminho: "../caixa-teia>log {a,b}".into(),
11336        });
11337        let err = d.validate().unwrap_err();
11338        assert!(
11339            matches!(
11340                err,
11341                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11342            ),
11343            "got {err:?}",
11344        );
11345    }
11346
11347    #[test]
11348    fn fonte_caminho_backslash_fires_before_shell_brace_expansion() {
11349        // Cascade pin on the upstream backslash arm: a value
11350        // carrying both `\` and `{` (`"..\caixa-teia\{a,b}"` — the
11351        // canonical "I pasted a Windows-shell `cd ..\path\{a,b}`
11352        // chain") routes through `FonteCaminhoBackslash` not
11353        // `FonteCaminhoShellBraceExpansion`. The cross-host-OS-
11354        // separator divergence is the load-bearing axis on every
11355        // probe-as-both value.
11356        let d = dep_with_fonte(DepSource::Path {
11357            caminho: "..\\caixa-teia\\{a,b}".into(),
11358        });
11359        let err = d.validate().unwrap_err();
11360        assert!(
11361            matches!(err, DepError::FonteCaminhoBackslash { .. }),
11362            "got {err:?}",
11363        );
11364    }
11365
11366    #[test]
11367    fn fonte_caminho_control_char_fires_before_shell_brace_expansion() {
11368        // Cascade pin on the embedded-control-byte arm: a value
11369        // carrying both a control byte and `{` (`"../foo\n{a,b}"` —
11370        // the canonical paste-from-multiline-doc footgun where a
11371        // newline landed mid-caminho between two paste fragments)
11372        // routes through `FonteCaminhoControlChar` not
11373        // `FonteCaminhoShellBraceExpansion`. The POSIX-syscall-
11374        // rejected-byte / NUL-`CString::new`-fail diagnostic is the
11375        // load-bearing axis on every value that probes positive for
11376        // both — mirrors the cascade discipline on every prior arm.
11377        let d = dep_with_fonte(DepSource::Path {
11378            caminho: "../foo\n{a,b}".into(),
11379        });
11380        let err = d.validate().unwrap_err();
11381        assert!(
11382            matches!(err, DepError::FonteCaminhoControlChar { .. }),
11383            "got {err:?}",
11384        );
11385    }
11386
11387    #[test]
11388    fn fonte_caminho_absolute_fires_before_shell_brace_expansion() {
11389        // Cascade pin on the load-bearing leading-byte arm: a
11390        // leading `/` value with embedded `{` (`"/etc/{a,b}"`)
11391        // routes through `FonteCaminhoAbsolute` not
11392        // `FonteCaminhoShellBraceExpansion` — the host-layout-leak
11393        // diagnostic is the load-bearing axis, the brace-expansion
11394        // byte is the secondary observation. Same precedence logic
11395        // as every prior leading-byte arm.
11396        let d = dep_with_fonte(DepSource::Path {
11397            caminho: "/etc/{a,b}".into(),
11398        });
11399        let err = d.validate().unwrap_err();
11400        assert!(
11401            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11402            "got {err:?}",
11403        );
11404    }
11405
11406    #[test]
11407    fn fonte_caminho_var_expansion_fires_before_shell_brace_expansion() {
11408        // Cascade pin on the upstream leading-`$` var-expansion
11409        // arm: a value carrying both a leading `$` and a `{`
11410        // (`"${ORG}/caixa-teia"` — the canonical "I pasted a
11411        // `${ORG}` shell-variable + curly-brace expansion at the
11412        // head of a sibling-workspace path" footgun) routes through
11413        // `FonteCaminhoVarExpansion` not
11414        // `FonteCaminhoShellBraceExpansion`. The leading-byte
11415        // shell-variable-expansion is the more self-locating
11416        // diagnostic on values that probe as both — same
11417        // load-bearing-leading-byte cascade discipline every prior
11418        // `:caminho` arm establishes.
11419        let d = dep_with_fonte(DepSource::Path {
11420            caminho: "${ORG}/caixa-teia".into(),
11421        });
11422        let err = d.validate().unwrap_err();
11423        assert!(
11424            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
11425            "got {err:?}",
11426        );
11427    }
11428
11429    #[test]
11430    fn fonte_caminho_shell_brace_expansion_fires_before_trailing_slash() {
11431        // Cascade pin on the immediate-successor arm: a value
11432        // carrying both `{` and a trailing `/`
11433        // (`"../{caixa-teia,caixa-helm}/"` — the canonical "I
11434        // tab-completed a path that already had a brace-expansion
11435        // expansion tail" footgun) routes through
11436        // `FonteCaminhoShellBraceExpansion` not
11437        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
11438        // is the more semantic-locating axis (an author who removes
11439        // the `{` typically also drops the trailing separator since
11440        // both are paste-from-shell artifacts).
11441        let d = dep_with_fonte(DepSource::Path {
11442            caminho: "../{caixa-teia,caixa-helm}/".into(),
11443        });
11444        let err = d.validate().unwrap_err();
11445        assert!(
11446            matches!(
11447                err,
11448                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
11449            ),
11450            "got {err:?}",
11451        );
11452    }
11453
11454    #[test]
11455    fn fonte_caminho_shell_brace_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
11456        // Diagnostic-shape pin (peer with
11457        // `fonte_caminho_shell_subshell_grouping_diagnostic_carries_offending_dep_caminho_and_byte`
11458        // on the closest two-byte peer arm): the error's Display
11459        // surfaces the offending `:nome`, the offending `:caminho`
11460        // verbatim, the offending byte's hex / character form, and
11461        // names the shell-brace-expansion / URI-Template footgun
11462        // explicitly so a `feira lint` run can render the diagnostic
11463        // without re-parsing.
11464        let d = dep_with_fonte(DepSource::Path {
11465            caminho: "../{caixa-teia,caixa-helm}/build".into(),
11466        });
11467        let rendered = d.validate().unwrap_err().to_string();
11468        assert!(
11469            rendered.contains("caixa-teia"),
11470            "diagnostic must name the offending dep: {rendered}",
11471        );
11472        assert!(
11473            rendered.contains("../{caixa-teia,caixa-helm}/build"),
11474            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11475        );
11476        assert!(
11477            rendered.contains("0x7b"),
11478            "diagnostic must surface the offending byte hex: {rendered:?}",
11479        );
11480        assert!(
11481            rendered.contains("brace-expansion"),
11482            "diagnostic must name the shell-brace-expansion footgun: {rendered:?}",
11483        );
11484        assert!(
11485            rendered.contains("URI Template"),
11486            "diagnostic must reference the RFC-6570 URI-Template-placeholder vocabulary: \
11487             {rendered:?}",
11488        );
11489    }
11490
11491    #[test]
11492    fn validate_rejects_path_fonte_with_caminho_carrying_bracket_glob_character_class() {
11493        // The canonical paste-from-shell-history bracket-glob /
11494        // character-class footgun: an author copies a
11495        // `cd ../caixa-[a-z]/build` shell-history one-liner whose
11496        // `[a-z]` POSIX glob character-class matches every lowercase-
11497        // ASCII-suffix sibling caixa directory and silently passed
11498        // every prior arm (`Path::is_absolute` false on `..`, no
11499        // control bytes, no `\`, no `<` / `>`, no `|`, no `;`, no
11500        // `&`, no backtick, no `*` / `?`, no `(` / `)`, no `{` /
11501        // `}`, doesn't end in `/`; the leading-`$` f4efe9c
11502        // `FonteCaminhoVarExpansion` arm doesn't fire because the
11503        // value starts with `..` not `$`). The lacre embedded the
11504        // value verbatim, the resolver folded it through
11505        // `Path::join` looking for a literal `./../caixa-[a-z]/
11506        // build` subdirectory, and the failure surfaced at resolve
11507        // time with a non-self-locating `No such file or directory`
11508        // error. The new arm moves the rejection to validate time
11509        // and names the offending dep + caminho + byte verbatim.
11510        // The arm fires on the first `[` encountered.
11511        let d = dep_with_fonte(DepSource::Path {
11512            caminho: "../caixa-[a-z]/build".into(),
11513        });
11514        let err = d.validate().unwrap_err();
11515        let DepError::FonteCaminhoShellBracketExpansion {
11516            nome,
11517            caminho,
11518            byte,
11519        } = err
11520        else {
11521            panic!("expected FonteCaminhoShellBracketExpansion, got {err:?}");
11522        };
11523        assert_eq!(nome, "caixa-teia");
11524        assert_eq!(caminho, "../caixa-[a-z]/build");
11525        assert_eq!(byte, b'[');
11526    }
11527
11528    #[test]
11529    fn validate_rejects_path_fonte_with_caminho_carrying_close_bracket() {
11530        // The symmetric close-bracket paste shape (`"../caixa-teia]"`
11531        // — the degenerate "I selected an unbalanced closing bracket
11532        // out of a glob character-class block" idiom that probes for
11533        // the cascade's last-byte handling on a value carrying only
11534        // the closing byte). Pinned separately from the open-bracket
11535        // shape so the gate's contract is "any `[` or `]` anywhere",
11536        // not single-byte coverage. Mirrors the peer
11537        // `validate_rejects_path_fonte_with_caminho_carrying_close_brace`
11538        // shape on the immediate-predecessor
11539        // `FonteCaminhoShellBraceExpansion` arm.
11540        let d = dep_with_fonte(DepSource::Path {
11541            caminho: "../caixa-teia]".into(),
11542        });
11543        let err = d.validate().unwrap_err();
11544        let DepError::FonteCaminhoShellBracketExpansion { byte, .. } = err else {
11545            panic!("expected FonteCaminhoShellBracketExpansion, got {err:?}");
11546        };
11547        assert_eq!(byte, b']');
11548    }
11549
11550    #[test]
11551    fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_bracket() {
11552        // Leading-position `[` shape (`"[caixa-teia]/build"` — the
11553        // canonical "I selected a `[caixa-teia]` TOML-table-header /
11554        // glob-character-class prefix out of an aligned config /
11555        // shell-history one-liner" idiom). Pinned separately from
11556        // the embedded-byte shape so the gate covers every position,
11557        // not only mid-path.
11558        let d = dep_with_fonte(DepSource::Path {
11559            caminho: "[caixa-teia]/build".into(),
11560        });
11561        let err = d.validate().unwrap_err();
11562        assert!(
11563            matches!(
11564                err,
11565                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
11566            ),
11567            "got {err:?}",
11568        );
11569    }
11570
11571    #[test]
11572    fn validate_rejects_path_fonte_with_caminho_carrying_toml_inline_array() {
11573        // The canonical TOML inline-array / YAML flow-sequence
11574        // paste shape (`"../[\"a\", \"b\"]/caixa-teia"` — the
11575        // canonical "I copied a `features = [\"a\", \"b\"]` TOML
11576        // inline-array out of a sibling-Cargo manifest" cross-idiom
11577        // leak; the symmetric YAML flow-sequence form `paths: [/a,
11578        // /b]` paste-from-values.yaml shape carries the same
11579        // bracket pair). The arm fires on the first `[` encountered;
11580        // pinned so the gate's coverage extends from the bare-
11581        // bracket glob-character-class shape to the TOML / YAML /
11582        // JSON array-literal shape.
11583        let d = dep_with_fonte(DepSource::Path {
11584            caminho: "../[\"a\", \"b\"]/caixa-teia".into(),
11585        });
11586        let err = d.validate().unwrap_err();
11587        assert!(
11588            matches!(
11589                err,
11590                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
11591            ),
11592            "got {err:?}",
11593        );
11594    }
11595
11596    #[test]
11597    fn validate_rejects_path_fonte_with_caminho_carrying_shell_test_builtin() {
11598        // The canonical POSIX `test` / `[` builtin command paste
11599        // shape (`"../[ -d caixa-teia ]"` — the `[ <expr> ]` shell-
11600        // script conditional every paste-from-shell-script idiom
11601        // carries; bash's `[[ <expr> ]]` extended-test grammar
11602        // would surface the same byte pair). The arm fires on the
11603        // first `[` encountered; pinned so the gate's coverage
11604        // extends from the embedded-glob-character-class shape to
11605        // the leading-`test`-builtin / extended-test form.
11606        let d = dep_with_fonte(DepSource::Path {
11607            caminho: "../[ -d caixa-teia ]".into(),
11608        });
11609        let err = d.validate().unwrap_err();
11610        assert!(
11611            matches!(
11612                err,
11613                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
11614            ),
11615            "got {err:?}",
11616        );
11617    }
11618
11619    #[test]
11620    fn validate_accepts_path_fonte_with_caminho_carrying_no_bracket_expansion() {
11621        // The positive-control pin: the gate targets only `[` /
11622        // `]`, never adjacent printable ASCII or POSIX-valid bytes.
11623        // The canonical relative POSIX path (`"../caixa-teia"`) and
11624        // a nested deeply-pathed variant with adjacent printable
11625        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
11626        // to validate cleanly so the gate doesn't widen to a "no
11627        // printable punctuation anywhere" sweep that would defeat
11628        // the entire path-fonte author surface. Peer with
11629        // `validate_accepts_path_fonte_with_caminho_carrying_no_brace_expansion`
11630        // on the immediate-predecessor arm.
11631        let d = dep_with_fonte(DepSource::Path {
11632            caminho: "../caixa-teia/sub-dir.v2".into(),
11633        });
11634        d.validate().unwrap();
11635    }
11636
11637    #[test]
11638    fn fonte_caminho_shell_brace_expansion_fires_before_shell_bracket_expansion() {
11639        // Cascade pin on the immediate-predecessor arm: a value
11640        // carrying both `{` and `[` (`"../{a,b}[ch]"` — the
11641        // canonical "I pasted a brace-expansion fan followed by a
11642        // glob-character-class tail" footgun) routes through
11643        // `FonteCaminhoShellBraceExpansion` not
11644        // `FonteCaminhoShellBracketExpansion`. The brace-expansion
11645        // fan is the load-bearing root-cause edit on every
11646        // probe-as-both value because the bracket-class tail
11647        // typically rides on a prior brace-expansion expansion;
11648        // same cascade discipline every prior `:caminho` arm
11649        // establishes.
11650        let d = dep_with_fonte(DepSource::Path {
11651            caminho: "../{a,b}[ch]".into(),
11652        });
11653        let err = d.validate().unwrap_err();
11654        assert!(
11655            matches!(
11656                err,
11657                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
11658            ),
11659            "got {err:?}",
11660        );
11661    }
11662
11663    #[test]
11664    fn fonte_caminho_shell_subshell_grouping_fires_before_shell_bracket_expansion() {
11665        // Cascade pin on the upstream shell-subshell-grouping arm:
11666        // a value carrying both `(` and `[` (`"../(cd foo)/[ch]"` —
11667        // the canonical "I pasted a subshell-grouping followed by
11668        // a glob-character-class tail" footgun) routes through
11669        // `FonteCaminhoShellSubshellGrouping` not
11670        // `FonteCaminhoShellBracketExpansion`. The modern Bourne
11671        // `$(<cmd>)` command-substitution boundary is the load-
11672        // bearing axis on every probe-as-both value.
11673        let d = dep_with_fonte(DepSource::Path {
11674            caminho: "../(cd foo)/[ch]".into(),
11675        });
11676        let err = d.validate().unwrap_err();
11677        assert!(
11678            matches!(
11679                err,
11680                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
11681            ),
11682            "got {err:?}",
11683        );
11684    }
11685
11686    #[test]
11687    fn fonte_caminho_shell_glob_fires_before_shell_bracket_expansion() {
11688        // Cascade pin on the upstream shell-glob arm: a value
11689        // carrying both `*` and `[` (`"../caixa-teia/*[ch]"` — the
11690        // canonical "I pasted a `*.[ch]` C-source-file glob whose
11691        // unbounded `*` precedes the bracket character-class"
11692        // footgun) routes through `FonteCaminhoShellGlob` not
11693        // `FonteCaminhoShellBracketExpansion`. The unbounded
11694        // pathname-expansion sentinel is the load-bearing root-
11695        // cause edit on every probe-as-both value — the unbounded
11696        // `*` carries the more aggressive expansion vector than
11697        // the bounded `[ch]` class, so the prior arm wins.
11698        let d = dep_with_fonte(DepSource::Path {
11699            caminho: "../caixa-teia/*[ch]".into(),
11700        });
11701        let err = d.validate().unwrap_err();
11702        assert!(
11703            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
11704            "got {err:?}",
11705        );
11706    }
11707
11708    #[test]
11709    fn fonte_caminho_shell_command_substitution_fires_before_shell_bracket_expansion() {
11710        // Cascade pin on the upstream shell-command-substitution
11711        // arm: a value carrying both a backtick and `[`
11712        // (``"../`whoami`/[ch]"`` — the canonical "I pasted a
11713        // legacy-backtick command-substitution followed by a
11714        // glob-character-class tail" footgun) routes through
11715        // `FonteCaminhoShellCommandSubstitution` not
11716        // `FonteCaminhoShellBracketExpansion`. The CWE-78 shell-
11717        // command-injection vector is the load-bearing root-cause
11718        // edit on every probe-as-both value.
11719        let d = dep_with_fonte(DepSource::Path {
11720            caminho: "../`whoami`/[ch]".into(),
11721        });
11722        let err = d.validate().unwrap_err();
11723        assert!(
11724            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11725            "got {err:?}",
11726        );
11727    }
11728
11729    #[test]
11730    fn fonte_caminho_shell_background_fires_before_shell_bracket_expansion() {
11731        // Cascade pin on the upstream shell-background arm: a
11732        // value carrying both `&` and `[` (`"../caixa-teia & [ch]"`
11733        // — the canonical "I pasted a `cmd & [glob]` background-
11734        // launch + bracket-class chain" footgun) routes through
11735        // `FonteCaminhoShellBackground` not
11736        // `FonteCaminhoShellBracketExpansion`. The background-
11737        // launch tail is the load-bearing root-cause edit on
11738        // every probe-as-both value.
11739        let d = dep_with_fonte(DepSource::Path {
11740            caminho: "../caixa-teia & [ch]".into(),
11741        });
11742        let err = d.validate().unwrap_err();
11743        assert!(
11744            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11745            "got {err:?}",
11746        );
11747    }
11748
11749    #[test]
11750    fn fonte_caminho_shell_semicolon_fires_before_shell_bracket_expansion() {
11751        // Cascade pin on the upstream shell-semicolon arm: a value
11752        // carrying both `;` and `[` (`"../caixa-teia; [ch]"` — the
11753        // canonical sequential-cleanup + bracket-class paste
11754        // idiom) routes through `FonteCaminhoShellSemicolon` not
11755        // `FonteCaminhoShellBracketExpansion`. The sequential-
11756        // command-separator paste is the load-bearing root-cause
11757        // edit on every probe-as-both value.
11758        let d = dep_with_fonte(DepSource::Path {
11759            caminho: "../caixa-teia; [ch]".into(),
11760        });
11761        let err = d.validate().unwrap_err();
11762        assert!(
11763            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11764            "got {err:?}",
11765        );
11766    }
11767
11768    #[test]
11769    fn fonte_caminho_shell_pipe_fires_before_shell_bracket_expansion() {
11770        // Cascade pin on the upstream shell-pipe arm: a value
11771        // carrying both `|` and `[` (`"../caixa-teia | [tee]"` —
11772        // the canonical pipeline-to-bracket-class paste idiom)
11773        // routes through `FonteCaminhoShellPipe` not
11774        // `FonteCaminhoShellBracketExpansion`. The pipeline-tail
11775        // paste is the load-bearing root-cause edit on every
11776        // probe-as-both value.
11777        let d = dep_with_fonte(DepSource::Path {
11778            caminho: "../caixa-teia | [tee]".into(),
11779        });
11780        let err = d.validate().unwrap_err();
11781        assert!(
11782            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11783            "got {err:?}",
11784        );
11785    }
11786
11787    #[test]
11788    fn fonte_caminho_shell_redirection_fires_before_shell_bracket_expansion() {
11789        // Cascade pin on the upstream shell-redirection arm: a
11790        // value carrying both `>` and `[` (`"../caixa-teia>log
11791        // [ch]"` — the canonical "I pasted a `cmd > log [glob]`
11792        // redirect-plus-bracket chain" footgun) routes through
11793        // `FonteCaminhoShellRedirection` not
11794        // `FonteCaminhoShellBracketExpansion`. The input/output
11795        // redirection metachar carries the more self-locating
11796        // `byte` payload, so the prior arm wins on every
11797        // probe-as-both value.
11798        let d = dep_with_fonte(DepSource::Path {
11799            caminho: "../caixa-teia>log [ch]".into(),
11800        });
11801        let err = d.validate().unwrap_err();
11802        assert!(
11803            matches!(
11804                err,
11805                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11806            ),
11807            "got {err:?}",
11808        );
11809    }
11810
11811    #[test]
11812    fn fonte_caminho_backslash_fires_before_shell_bracket_expansion() {
11813        // Cascade pin on the upstream backslash arm: a value
11814        // carrying both `\` and `[` (`"..\caixa-teia\[ch]"` — the
11815        // canonical "I pasted a Windows-shell `cd ..\path\[glob]`
11816        // chain") routes through `FonteCaminhoBackslash` not
11817        // `FonteCaminhoShellBracketExpansion`. The cross-host-OS-
11818        // separator divergence is the load-bearing axis on every
11819        // probe-as-both value.
11820        let d = dep_with_fonte(DepSource::Path {
11821            caminho: "..\\caixa-teia\\[ch]".into(),
11822        });
11823        let err = d.validate().unwrap_err();
11824        assert!(
11825            matches!(err, DepError::FonteCaminhoBackslash { .. }),
11826            "got {err:?}",
11827        );
11828    }
11829
11830    #[test]
11831    fn fonte_caminho_control_char_fires_before_shell_bracket_expansion() {
11832        // Cascade pin on the embedded-control-byte arm: a value
11833        // carrying both a control byte and `[` (`"../foo\n[ch]"` —
11834        // the canonical paste-from-multiline-doc footgun where a
11835        // newline landed mid-caminho between two paste fragments)
11836        // routes through `FonteCaminhoControlChar` not
11837        // `FonteCaminhoShellBracketExpansion`. The POSIX-syscall-
11838        // rejected-byte / NUL-`CString::new`-fail diagnostic is
11839        // the load-bearing axis on every value that probes
11840        // positive for both — mirrors the cascade discipline on
11841        // every prior arm.
11842        let d = dep_with_fonte(DepSource::Path {
11843            caminho: "../foo\n[ch]".into(),
11844        });
11845        let err = d.validate().unwrap_err();
11846        assert!(
11847            matches!(err, DepError::FonteCaminhoControlChar { .. }),
11848            "got {err:?}",
11849        );
11850    }
11851
11852    #[test]
11853    fn fonte_caminho_absolute_fires_before_shell_bracket_expansion() {
11854        // Cascade pin on the load-bearing leading-byte arm: a
11855        // leading `/` value with embedded `[` (`"/etc/[ch]"`)
11856        // routes through `FonteCaminhoAbsolute` not
11857        // `FonteCaminhoShellBracketExpansion` — the host-layout-
11858        // leak diagnostic is the load-bearing axis, the bracket-
11859        // expansion byte is the secondary observation. Same
11860        // precedence logic as every prior leading-byte arm.
11861        let d = dep_with_fonte(DepSource::Path {
11862            caminho: "/etc/[ch]".into(),
11863        });
11864        let err = d.validate().unwrap_err();
11865        assert!(
11866            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11867            "got {err:?}",
11868        );
11869    }
11870
11871    #[test]
11872    fn fonte_caminho_var_expansion_fires_before_shell_bracket_expansion() {
11873        // Cascade pin on the upstream leading-`$` var-expansion
11874        // arm: a value carrying both a leading `$` and a `[`
11875        // (`"$DIR/[ch]"` — the canonical "I pasted a `$DIR` shell-
11876        // variable + bracket-class at the head of a sibling-
11877        // workspace path" footgun) routes through
11878        // `FonteCaminhoVarExpansion` not
11879        // `FonteCaminhoShellBracketExpansion`. The leading-byte
11880        // shell-variable-expansion is the more self-locating
11881        // diagnostic on values that probe as both — same
11882        // load-bearing-leading-byte cascade discipline every
11883        // prior `:caminho` arm establishes.
11884        let d = dep_with_fonte(DepSource::Path {
11885            caminho: "$DIR/[ch]".into(),
11886        });
11887        let err = d.validate().unwrap_err();
11888        assert!(
11889            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
11890            "got {err:?}",
11891        );
11892    }
11893
11894    #[test]
11895    fn fonte_caminho_shell_bracket_expansion_fires_before_trailing_slash() {
11896        // Cascade pin on the immediate-successor arm: a value
11897        // carrying both `[` and a trailing `/` (`"../[a-z]/"` —
11898        // the canonical "I tab-completed a path that already had
11899        // a bracket-glob-character-class expansion tail" footgun)
11900        // routes through `FonteCaminhoShellBracketExpansion` not
11901        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
11902        // is the more semantic-locating axis (an author who
11903        // removes the `[` typically also drops the trailing
11904        // separator since both are paste-from-shell artifacts).
11905        let d = dep_with_fonte(DepSource::Path {
11906            caminho: "../[a-z]/".into(),
11907        });
11908        let err = d.validate().unwrap_err();
11909        assert!(
11910            matches!(
11911                err,
11912                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
11913            ),
11914            "got {err:?}",
11915        );
11916    }
11917
11918    #[test]
11919    fn fonte_caminho_shell_bracket_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
11920        // Diagnostic-shape pin (peer with
11921        // `fonte_caminho_shell_brace_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
11922        // on the closest two-byte peer arm): the error's Display
11923        // surfaces the offending `:nome`, the offending `:caminho`
11924        // verbatim, the offending byte's hex / character form, and
11925        // names the shell-bracket-expansion / glob-character-class
11926        // footgun explicitly so a `feira lint` run can render the
11927        // diagnostic without re-parsing.
11928        let d = dep_with_fonte(DepSource::Path {
11929            caminho: "../caixa-[a-z]/build".into(),
11930        });
11931        let rendered = d.validate().unwrap_err().to_string();
11932        assert!(
11933            rendered.contains("caixa-teia"),
11934            "diagnostic must name the offending dep: {rendered}",
11935        );
11936        assert!(
11937            rendered.contains("../caixa-[a-z]/build"),
11938            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11939        );
11940        assert!(
11941            rendered.contains("0x5b"),
11942            "diagnostic must surface the offending byte hex: {rendered:?}",
11943        );
11944        assert!(
11945            rendered.contains("bracket-expansion"),
11946            "diagnostic must name the shell-bracket-expansion footgun: {rendered:?}",
11947        );
11948        assert!(
11949            rendered.contains("glob-character-class"),
11950            "diagnostic must reference the POSIX glob-character-class vocabulary: \
11951             {rendered:?}",
11952        );
11953    }
11954
11955    #[test]
11956    fn validate_rejects_path_fonte_with_caminho_carrying_single_quote_grouping() {
11957        // The canonical paste-from-shell-history strong-quoted
11958        // sibling-workspace-path footgun: an author copies a
11959        // `cd '../caixa-teia'` shell-history one-liner whose strong-
11960        // quoting preserved the path across a whitespace paste
11961        // boundary and silently passed every prior arm
11962        // (`Path::is_absolute` false on `'..`, no control bytes, no
11963        // `\`, no `<` / `>`, no `|`, no `;`, no `&`, no backtick, no
11964        // `*` / `?`, no `(` / `)`, no `{` / `}`, no `[` / `]`,
11965        // doesn't end in `/`; the leading-`$` f4efe9c
11966        // `FonteCaminhoVarExpansion` arm doesn't fire because the
11967        // value starts with `'` not `$`). The lacre embedded the
11968        // value verbatim, the resolver folded it through
11969        // `Path::join` looking for a literal `./'../caixa-teia'`
11970        // subdirectory, and the failure surfaced at resolve time
11971        // with a non-self-locating `No such file or directory`
11972        // error. The new arm moves the rejection to validate time
11973        // and names the offending dep + caminho + byte verbatim.
11974        // The arm fires on the first `'` encountered.
11975        let d = dep_with_fonte(DepSource::Path {
11976            caminho: "'../caixa-teia'".into(),
11977        });
11978        let err = d.validate().unwrap_err();
11979        let DepError::FonteCaminhoShellQuoteGrouping {
11980            nome,
11981            caminho,
11982            byte,
11983        } = err
11984        else {
11985            panic!("expected FonteCaminhoShellQuoteGrouping, got {err:?}");
11986        };
11987        assert_eq!(nome, "caixa-teia");
11988        assert_eq!(caminho, "'../caixa-teia'");
11989        assert_eq!(byte, b'\'');
11990    }
11991
11992    #[test]
11993    fn validate_rejects_path_fonte_with_caminho_carrying_double_quote_grouping() {
11994        // The symmetric weak-quoted paste shape (`"\"../caixa-teia\""`
11995        // — the canonical paste-from-JSON-config / paste-from-YAML-
11996        // flow-scalar / paste-from-TOML-basic-string / paste-from-
11997        // tatara-lisp-string-literal cross-idiom leak). Pinned
11998        // separately from the single-quote shape so the gate's
11999        // contract is "any `'` or `\"` anywhere", not single-byte
12000        // coverage. Mirrors the peer
12001        // `validate_rejects_path_fonte_with_caminho_carrying_close_bracket`
12002        // shape on the immediate-predecessor
12003        // `FonteCaminhoShellBracketExpansion` arm.
12004        let d = dep_with_fonte(DepSource::Path {
12005            caminho: "\"../caixa-teia\"".into(),
12006        });
12007        let err = d.validate().unwrap_err();
12008        let DepError::FonteCaminhoShellQuoteGrouping { byte, .. } = err else {
12009            panic!("expected FonteCaminhoShellQuoteGrouping, got {err:?}");
12010        };
12011        assert_eq!(byte, b'"');
12012    }
12013
12014    #[test]
12015    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_double_quote() {
12016        // Embedded-position `"` shape (`"../\"caixa-teia\""` — the
12017        // canonical "I pasted a JSON key-value pair fragment into
12018        // the middle of the path" idiom). Pinned separately from
12019        // the leading-byte shape so the gate covers every position,
12020        // not only leading.
12021        let d = dep_with_fonte(DepSource::Path {
12022            caminho: "../\"caixa-teia\"".into(),
12023        });
12024        let err = d.validate().unwrap_err();
12025        assert!(
12026            matches!(
12027                err,
12028                DepError::FonteCaminhoShellQuoteGrouping { byte: b'"', .. },
12029            ),
12030            "got {err:?}",
12031        );
12032    }
12033
12034    #[test]
12035    fn validate_rejects_path_fonte_with_caminho_carrying_yaml_flow_scalar_paste() {
12036        // The canonical YAML double-quoted flow-scalar cross-idiom
12037        // leak shape (`"path: \"../caixa-teia\""` — the "I copied a
12038        // `path: \"...\"` YAML flow-scalar entry out of an aligned
12039        // values.yaml / K8s manifest and dropped it verbatim into
12040        // the `:caminho` slot including the `path: ` key prefix"
12041        // paste-idiom). The arm fires on the first `"` encountered;
12042        // pinned so the gate's coverage extends from the bare-quote
12043        // paste shape to the aligned-YAML-manifest cross-idiom-leak
12044        // shape.
12045        let d = dep_with_fonte(DepSource::Path {
12046            caminho: "path: \"../caixa-teia\"".into(),
12047        });
12048        let err = d.validate().unwrap_err();
12049        assert!(
12050            matches!(
12051                err,
12052                DepError::FonteCaminhoShellQuoteGrouping { byte: b'"', .. },
12053            ),
12054            "got {err:?}",
12055        );
12056    }
12057
12058    #[test]
12059    fn validate_accepts_path_fonte_with_caminho_carrying_no_quote_grouping() {
12060        // The positive-control pin: the gate targets only `'` /
12061        // `"`, never adjacent printable ASCII or POSIX-valid bytes.
12062        // The canonical relative POSIX path (`"../caixa-teia"`) and
12063        // a nested deeply-pathed variant with adjacent printable
12064        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
12065        // to validate cleanly so the gate doesn't widen to a "no
12066        // printable punctuation anywhere" sweep that would defeat
12067        // the entire path-fonte author surface. Peer with
12068        // `validate_accepts_path_fonte_with_caminho_carrying_no_bracket_expansion`
12069        // on the immediate-predecessor arm.
12070        let d = dep_with_fonte(DepSource::Path {
12071            caminho: "../caixa-teia/sub-dir.v2".into(),
12072        });
12073        d.validate().unwrap();
12074    }
12075
12076    #[test]
12077    fn fonte_caminho_shell_bracket_expansion_fires_before_shell_quote_grouping() {
12078        // Cascade pin on the immediate-predecessor arm: a value
12079        // carrying both `[` and `'` (`"../[a-z]'x'"` — the canonical
12080        // "I pasted a glob-character-class followed by a strong-
12081        // quoted literal tail" footgun) routes through
12082        // `FonteCaminhoShellBracketExpansion` not
12083        // `FonteCaminhoShellQuoteGrouping`. The glob-character-class
12084        // expansion is the load-bearing root-cause edit on every
12085        // probe-as-both value; same cascade discipline every prior
12086        // `:caminho` arm establishes.
12087        let d = dep_with_fonte(DepSource::Path {
12088            caminho: "../[a-z]'x'".into(),
12089        });
12090        let err = d.validate().unwrap_err();
12091        assert!(
12092            matches!(
12093                err,
12094                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
12095            ),
12096            "got {err:?}",
12097        );
12098    }
12099
12100    #[test]
12101    fn fonte_caminho_shell_brace_expansion_fires_before_shell_quote_grouping() {
12102        // Cascade pin on the upstream shell-brace-expansion arm: a
12103        // value carrying both `{` and `'` (`"../{a,b}'x'"` — the
12104        // canonical "I pasted a brace-expansion fan followed by a
12105        // strong-quoted literal tail" footgun) routes through
12106        // `FonteCaminhoShellBraceExpansion` not
12107        // `FonteCaminhoShellQuoteGrouping`. The brace-expansion fan
12108        // is the load-bearing root-cause edit on every probe-as-
12109        // both value.
12110        let d = dep_with_fonte(DepSource::Path {
12111            caminho: "../{a,b}'x'".into(),
12112        });
12113        let err = d.validate().unwrap_err();
12114        assert!(
12115            matches!(
12116                err,
12117                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
12118            ),
12119            "got {err:?}",
12120        );
12121    }
12122
12123    #[test]
12124    fn fonte_caminho_shell_subshell_grouping_fires_before_shell_quote_grouping() {
12125        // Cascade pin on the upstream shell-subshell-grouping arm:
12126        // a value carrying both `(` and `'` (`"../(cd foo)/'x'"` —
12127        // the canonical "I pasted a subshell-grouping followed by
12128        // a strong-quoted literal tail" footgun) routes through
12129        // `FonteCaminhoShellSubshellGrouping` not
12130        // `FonteCaminhoShellQuoteGrouping`. The modern Bourne
12131        // `$(<cmd>)` command-substitution boundary is the load-
12132        // bearing axis on every probe-as-both value.
12133        let d = dep_with_fonte(DepSource::Path {
12134            caminho: "../(cd foo)/'x'".into(),
12135        });
12136        let err = d.validate().unwrap_err();
12137        assert!(
12138            matches!(
12139                err,
12140                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
12141            ),
12142            "got {err:?}",
12143        );
12144    }
12145
12146    #[test]
12147    fn fonte_caminho_shell_glob_fires_before_shell_quote_grouping() {
12148        // Cascade pin on the upstream shell-glob arm: a value
12149        // carrying both `*` and `'` (`"../caixa-teia/*'x'"` — the
12150        // canonical "I pasted a `*` unbounded pathname-expansion
12151        // followed by a strong-quoted literal tail" footgun) routes
12152        // through `FonteCaminhoShellGlob` not
12153        // `FonteCaminhoShellQuoteGrouping`. The unbounded pathname-
12154        // expansion sentinel is the load-bearing root-cause edit
12155        // on every probe-as-both value.
12156        let d = dep_with_fonte(DepSource::Path {
12157            caminho: "../caixa-teia/*'x'".into(),
12158        });
12159        let err = d.validate().unwrap_err();
12160        assert!(
12161            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12162            "got {err:?}",
12163        );
12164    }
12165
12166    #[test]
12167    fn fonte_caminho_shell_command_substitution_fires_before_shell_quote_grouping() {
12168        // Cascade pin on the upstream shell-command-substitution
12169        // arm: a value carrying both a backtick and `'`
12170        // (``"../`whoami`/'x'"`` — the canonical "I pasted a
12171        // legacy-backtick command-substitution followed by a
12172        // strong-quoted literal tail" footgun) routes through
12173        // `FonteCaminhoShellCommandSubstitution` not
12174        // `FonteCaminhoShellQuoteGrouping`. The CWE-78 shell-
12175        // command-injection vector is the load-bearing root-cause
12176        // edit on every probe-as-both value.
12177        let d = dep_with_fonte(DepSource::Path {
12178            caminho: "../`whoami`/'x'".into(),
12179        });
12180        let err = d.validate().unwrap_err();
12181        assert!(
12182            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
12183            "got {err:?}",
12184        );
12185    }
12186
12187    #[test]
12188    fn fonte_caminho_shell_background_fires_before_shell_quote_grouping() {
12189        // Cascade pin on the upstream shell-background arm: a value
12190        // carrying both `&` and `'` (`"../caixa-teia & 'x'"` — the
12191        // canonical "I pasted a `cmd & 'literal'` background-launch
12192        // + quote chain" footgun) routes through
12193        // `FonteCaminhoShellBackground` not
12194        // `FonteCaminhoShellQuoteGrouping`. The background-launch
12195        // tail is the load-bearing root-cause edit on every
12196        // probe-as-both value.
12197        let d = dep_with_fonte(DepSource::Path {
12198            caminho: "../caixa-teia & 'x'".into(),
12199        });
12200        let err = d.validate().unwrap_err();
12201        assert!(
12202            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
12203            "got {err:?}",
12204        );
12205    }
12206
12207    #[test]
12208    fn fonte_caminho_shell_semicolon_fires_before_shell_quote_grouping() {
12209        // Cascade pin on the upstream shell-semicolon arm: a value
12210        // carrying both `;` and `'` (`"../caixa-teia; 'x'"` — the
12211        // canonical sequential-cleanup + quote paste idiom) routes
12212        // through `FonteCaminhoShellSemicolon` not
12213        // `FonteCaminhoShellQuoteGrouping`. The sequential-command-
12214        // separator paste is the load-bearing root-cause edit on
12215        // every probe-as-both value.
12216        let d = dep_with_fonte(DepSource::Path {
12217            caminho: "../caixa-teia; 'x'".into(),
12218        });
12219        let err = d.validate().unwrap_err();
12220        assert!(
12221            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
12222            "got {err:?}",
12223        );
12224    }
12225
12226    #[test]
12227    fn fonte_caminho_shell_pipe_fires_before_shell_quote_grouping() {
12228        // Cascade pin on the upstream shell-pipe arm: a value
12229        // carrying both `|` and `'` (`"../caixa-teia | 'x'"` — the
12230        // canonical pipeline-to-quoted-literal paste idiom) routes
12231        // through `FonteCaminhoShellPipe` not
12232        // `FonteCaminhoShellQuoteGrouping`. The pipeline-tail paste
12233        // is the load-bearing root-cause edit on every probe-as-
12234        // both value.
12235        let d = dep_with_fonte(DepSource::Path {
12236            caminho: "../caixa-teia | 'x'".into(),
12237        });
12238        let err = d.validate().unwrap_err();
12239        assert!(
12240            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
12241            "got {err:?}",
12242        );
12243    }
12244
12245    #[test]
12246    fn fonte_caminho_shell_redirection_fires_before_shell_quote_grouping() {
12247        // Cascade pin on the upstream shell-redirection arm: a
12248        // value carrying both `>` and `'` (`"../caixa-teia>log 'x'"`
12249        // — the canonical "I pasted a `cmd > log 'literal'`
12250        // redirect-plus-quote chain" footgun) routes through
12251        // `FonteCaminhoShellRedirection` not
12252        // `FonteCaminhoShellQuoteGrouping`. The input/output
12253        // redirection metachar carries the more self-locating
12254        // `byte` payload, so the prior arm wins on every probe-as-
12255        // both value.
12256        let d = dep_with_fonte(DepSource::Path {
12257            caminho: "../caixa-teia>log 'x'".into(),
12258        });
12259        let err = d.validate().unwrap_err();
12260        assert!(
12261            matches!(
12262                err,
12263                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
12264            ),
12265            "got {err:?}",
12266        );
12267    }
12268
12269    #[test]
12270    fn fonte_caminho_backslash_fires_before_shell_quote_grouping() {
12271        // Cascade pin on the upstream backslash arm: a value
12272        // carrying both `\` and `'` (`"..\caixa-teia\'x'"` — the
12273        // canonical "I pasted a Windows-shell `cd ..\path\'literal'`
12274        // chain" footgun) routes through `FonteCaminhoBackslash`
12275        // not `FonteCaminhoShellQuoteGrouping`. The cross-host-OS-
12276        // separator divergence is the load-bearing axis on every
12277        // probe-as-both value.
12278        let d = dep_with_fonte(DepSource::Path {
12279            caminho: "..\\caixa-teia\\'x'".into(),
12280        });
12281        let err = d.validate().unwrap_err();
12282        assert!(
12283            matches!(err, DepError::FonteCaminhoBackslash { .. }),
12284            "got {err:?}",
12285        );
12286    }
12287
12288    #[test]
12289    fn fonte_caminho_control_char_fires_before_shell_quote_grouping() {
12290        // Cascade pin on the embedded-control-byte arm: a value
12291        // carrying both a control byte and `'` (`"../foo\n'x'"` —
12292        // the canonical paste-from-multiline-doc footgun where a
12293        // newline landed mid-caminho between two paste fragments)
12294        // routes through `FonteCaminhoControlChar` not
12295        // `FonteCaminhoShellQuoteGrouping`. The POSIX-syscall-
12296        // rejected-byte / NUL-`CString::new`-fail diagnostic is
12297        // the load-bearing axis on every value that probes
12298        // positive for both — mirrors the cascade discipline on
12299        // every prior arm.
12300        let d = dep_with_fonte(DepSource::Path {
12301            caminho: "../foo\n'x'".into(),
12302        });
12303        let err = d.validate().unwrap_err();
12304        assert!(
12305            matches!(err, DepError::FonteCaminhoControlChar { .. }),
12306            "got {err:?}",
12307        );
12308    }
12309
12310    #[test]
12311    fn fonte_caminho_absolute_fires_before_shell_quote_grouping() {
12312        // Cascade pin on the load-bearing leading-byte arm: a
12313        // leading `/` value with embedded `'` (`"/etc/'x'"`) routes
12314        // through `FonteCaminhoAbsolute` not
12315        // `FonteCaminhoShellQuoteGrouping` — the host-layout-leak
12316        // diagnostic is the load-bearing axis, the quote byte is
12317        // the secondary observation. Same precedence logic as every
12318        // prior leading-byte arm.
12319        let d = dep_with_fonte(DepSource::Path {
12320            caminho: "/etc/'x'".into(),
12321        });
12322        let err = d.validate().unwrap_err();
12323        assert!(
12324            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
12325            "got {err:?}",
12326        );
12327    }
12328
12329    #[test]
12330    fn fonte_caminho_var_expansion_fires_before_shell_quote_grouping() {
12331        // Cascade pin on the upstream leading-`$` var-expansion
12332        // arm: a value carrying both a leading `$` and a `'`
12333        // (`"$DIR/'x'"` — the canonical "I pasted a `$DIR` shell-
12334        // variable + quoted literal at the head of a sibling-
12335        // workspace path" footgun) routes through
12336        // `FonteCaminhoVarExpansion` not
12337        // `FonteCaminhoShellQuoteGrouping`. The leading-byte
12338        // shell-variable-expansion is the more self-locating
12339        // diagnostic on values that probe as both — same
12340        // load-bearing-leading-byte cascade discipline every
12341        // prior `:caminho` arm establishes.
12342        let d = dep_with_fonte(DepSource::Path {
12343            caminho: "$DIR/'x'".into(),
12344        });
12345        let err = d.validate().unwrap_err();
12346        assert!(
12347            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
12348            "got {err:?}",
12349        );
12350    }
12351
12352    #[test]
12353    fn fonte_caminho_shell_quote_grouping_fires_before_trailing_slash() {
12354        // Cascade pin on the immediate-successor arm: a value
12355        // carrying both `'` and a trailing `/` (`"../'caixa-teia'/"`
12356        // — the canonical "I tab-completed a path whose strong-
12357        // quoted body already carried the quoting from a shell-
12358        // history paste" footgun) routes through
12359        // `FonteCaminhoShellQuoteGrouping` not
12360        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
12361        // is the more semantic-locating axis (an author who removes
12362        // the `'` typically also drops the trailing separator since
12363        // both are paste-from-shell artifacts).
12364        let d = dep_with_fonte(DepSource::Path {
12365            caminho: "../'caixa-teia'/".into(),
12366        });
12367        let err = d.validate().unwrap_err();
12368        assert!(
12369            matches!(
12370                err,
12371                DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
12372            ),
12373            "got {err:?}",
12374        );
12375    }
12376
12377    #[test]
12378    fn fonte_caminho_shell_quote_grouping_diagnostic_carries_offending_dep_caminho_and_byte() {
12379        // Diagnostic-shape pin (peer with
12380        // `fonte_caminho_shell_bracket_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
12381        // on the closest two-byte peer arm): the error's Display
12382        // surfaces the offending `:nome`, the offending `:caminho`
12383        // verbatim, the offending byte's hex / character form, and
12384        // names the shell-quote-grouping / cross-config-DSL-string-
12385        // literal-delimiter footgun explicitly so a `feira lint`
12386        // run can render the diagnostic without re-parsing.
12387        let d = dep_with_fonte(DepSource::Path {
12388            caminho: "'../caixa-teia'".into(),
12389        });
12390        let rendered = d.validate().unwrap_err().to_string();
12391        assert!(
12392            rendered.contains("caixa-teia"),
12393            "diagnostic must name the offending dep: {rendered}",
12394        );
12395        assert!(
12396            rendered.contains("'../caixa-teia'"),
12397            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
12398        );
12399        assert!(
12400            rendered.contains("0x27"),
12401            "diagnostic must surface the offending byte hex: {rendered:?}",
12402        );
12403        assert!(
12404            rendered.contains("quote-grouping"),
12405            "diagnostic must name the shell-quote-grouping footgun: {rendered:?}",
12406        );
12407        assert!(
12408            rendered.contains("string-literal"),
12409            "diagnostic must reference the cross-config-DSL string-literal-delimiter \
12410             vocabulary: {rendered:?}",
12411        );
12412    }
12413
12414    #[test]
12415    fn validate_rejects_path_fonte_with_caminho_carrying_shell_comment_lead() {
12416        // The canonical paste-from-shell-history-with-trailing-
12417        // annotation footgun: an author pastes a `cd ../caixa-teia
12418        // # legacy sibling` shell-history one-liner whose unquoted `#`
12419        // comment-lead separates the path from an inline annotation.
12420        // The POSIX shell trims the annotation to `../caixa-teia`
12421        // (POSIX.1-2017 §2.3 Token Recognition step 6), but
12422        // `Path::is_absolute` returns false on `..`, `#` is neither
12423        // a leading-byte sentinel nor a control byte nor `\` nor
12424        // `<` / `>` nor `|` nor `;` nor `&` nor backtick nor `*` /
12425        // `?` nor `(` / `)` nor `{` / `}` nor `[` / `]` nor `'` /
12426        // `"`, and the value's last byte isn't `/` — so the value
12427        // silently passed every prior arm. The resolver folded the
12428        // value through `Path::join` looking for a literal
12429        // `./../caixa-teia # legacy sibling` subdirectory and the
12430        // failure surfaced at resolve time with a non-self-locating
12431        // `No such file or directory` error. The new arm moves the
12432        // rejection to validate time and names the offending dep +
12433        // caminho + byte verbatim.
12434        let d = dep_with_fonte(DepSource::Path {
12435            caminho: "../caixa-teia # legacy sibling".into(),
12436        });
12437        let err = d.validate().unwrap_err();
12438        let DepError::FonteCaminhoShellComment {
12439            nome,
12440            caminho,
12441            byte,
12442        } = err
12443        else {
12444            panic!("expected FonteCaminhoShellComment, got {err:?}");
12445        };
12446        assert_eq!(nome, "caixa-teia");
12447        assert_eq!(caminho, "../caixa-teia # legacy sibling");
12448        assert_eq!(byte, b'#');
12449    }
12450
12451    #[test]
12452    fn validate_rejects_path_fonte_with_caminho_carrying_yaml_comment_paste() {
12453        // The symmetric YAML flow-scalar / values.yaml / K8s-manifest
12454        // cross-idiom-leak shape (`"../caixa-teia  # pin"` — the
12455        // canonical "I copied a `path: ../caixa-teia  # pin` YAML
12456        // scalar-plus-comment entry out of an aligned values.yaml and
12457        // dropped it verbatim into the `:caminho` slot" paste-idiom).
12458        // Pinned separately from the shell-history shape so the
12459        // gate's coverage extends from the single-space `#` shape to
12460        // the YAML-canonical double-space `  #` shape. YAML 1.2 §6.6
12461        // requires the `#` to be preceded by whitespace to lex as a
12462        // comment (bare `foo#bar` is a single scalar); the double-
12463        // space paste from an aligned manifest is the canonical
12464        // shape.
12465        let d = dep_with_fonte(DepSource::Path {
12466            caminho: "../caixa-teia  # pin".into(),
12467        });
12468        let err = d.validate().unwrap_err();
12469        assert!(
12470            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
12471            "got {err:?}",
12472        );
12473    }
12474
12475    #[test]
12476    fn validate_rejects_path_fonte_with_caminho_carrying_url_fragment_anchor() {
12477        // The URL-fragment-identifier paste shape
12478        // (`"../caixa-teia#readme"` — the canonical
12479        // paste-from-browser-address-bar permalink shape where the
12480        // browser preserved the `#anchor` tail on the copy). Pinned
12481        // separately from the whitespace-separated shell / YAML
12482        // comment shapes so the gate covers the unpadded RFC 3986
12483        // §3.5 fragment-delimiter position too, not only positions
12484        // preceded by unquoted whitespace. Peer with the immediate-
12485        // sibling `is_git_repo_url` arm on the `:fonte :repo` axis
12486        // (a68f818) which closes the same byte under the same URL-
12487        // fragment-identifier banner.
12488        let d = dep_with_fonte(DepSource::Path {
12489            caminho: "../caixa-teia#readme".into(),
12490        });
12491        let err = d.validate().unwrap_err();
12492        assert!(
12493            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
12494            "got {err:?}",
12495        );
12496    }
12497
12498    #[test]
12499    fn validate_rejects_path_fonte_with_caminho_carrying_leading_shell_comment() {
12500        // Leading-position `#` shape (`"#../caixa-teia"` — the
12501        // "I copied a shell-comment-out entry from a commented-out
12502        // dep row" footgun). Pinned separately from the embedded
12503        // shapes so the gate covers every position, not only
12504        // whitespace-preceded / mid-value.
12505        let d = dep_with_fonte(DepSource::Path {
12506            caminho: "#../caixa-teia".into(),
12507        });
12508        let err = d.validate().unwrap_err();
12509        assert!(
12510            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
12511            "got {err:?}",
12512        );
12513    }
12514
12515    #[test]
12516    fn validate_accepts_path_fonte_with_caminho_carrying_no_shell_comment() {
12517        // The positive-control pin: the gate targets only `#`,
12518        // never adjacent printable ASCII or POSIX-valid bytes. The
12519        // canonical relative POSIX path (`"../caixa-teia"`) and a
12520        // nested deeply-pathed variant with adjacent printable
12521        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
12522        // to validate cleanly so the gate doesn't widen to a "no
12523        // printable punctuation anywhere" sweep that would defeat
12524        // the entire path-fonte author surface. Peer with
12525        // `validate_accepts_path_fonte_with_caminho_carrying_no_quote_grouping`
12526        // on the immediate-predecessor arm.
12527        let d = dep_with_fonte(DepSource::Path {
12528            caminho: "../caixa-teia/sub-dir.v2".into(),
12529        });
12530        d.validate().unwrap();
12531    }
12532
12533    #[test]
12534    fn fonte_caminho_shell_quote_grouping_fires_before_shell_comment() {
12535        // Cascade pin on the immediate-predecessor arm: a value
12536        // carrying both `'` and `#` (`"../'x'#pin"` — the canonical
12537        // "I pasted a strong-quoted literal followed by a URL-
12538        // fragment permalink tail" footgun) routes through
12539        // `FonteCaminhoShellQuoteGrouping` not
12540        // `FonteCaminhoShellComment`. The shell-string-literal-
12541        // delimiter is the load-bearing root-cause edit on every
12542        // probe-as-both value; same cascade discipline every prior
12543        // `:caminho` arm establishes.
12544        let d = dep_with_fonte(DepSource::Path {
12545            caminho: "../'x'#pin".into(),
12546        });
12547        let err = d.validate().unwrap_err();
12548        assert!(
12549            matches!(
12550                err,
12551                DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
12552            ),
12553            "got {err:?}",
12554        );
12555    }
12556
12557    #[test]
12558    fn fonte_caminho_shell_bracket_expansion_fires_before_shell_comment() {
12559        // Cascade pin on the upstream shell-bracket-expansion arm:
12560        // a value carrying both `[` and `#` (`"../[a-z]#pin"` — the
12561        // canonical "I pasted a glob-character-class followed by a
12562        // URL-fragment tail" footgun) routes through
12563        // `FonteCaminhoShellBracketExpansion` not
12564        // `FonteCaminhoShellComment`. The glob-character-class
12565        // expansion is the load-bearing root-cause edit on every
12566        // probe-as-both value.
12567        let d = dep_with_fonte(DepSource::Path {
12568            caminho: "../[a-z]#pin".into(),
12569        });
12570        let err = d.validate().unwrap_err();
12571        assert!(
12572            matches!(
12573                err,
12574                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
12575            ),
12576            "got {err:?}",
12577        );
12578    }
12579
12580    #[test]
12581    fn fonte_caminho_shell_brace_expansion_fires_before_shell_comment() {
12582        // Cascade pin on the upstream shell-brace-expansion arm: a
12583        // value carrying both `{` and `#` (`"../{a,b}#pin"` — the
12584        // canonical "I pasted a brace-expansion fan followed by a
12585        // URL-fragment tail" footgun) routes through
12586        // `FonteCaminhoShellBraceExpansion` not
12587        // `FonteCaminhoShellComment`. The brace-expansion fan is the
12588        // load-bearing root-cause edit on every probe-as-both value.
12589        let d = dep_with_fonte(DepSource::Path {
12590            caminho: "../{a,b}#pin".into(),
12591        });
12592        let err = d.validate().unwrap_err();
12593        assert!(
12594            matches!(
12595                err,
12596                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
12597            ),
12598            "got {err:?}",
12599        );
12600    }
12601
12602    #[test]
12603    fn fonte_caminho_shell_subshell_grouping_fires_before_shell_comment() {
12604        // Cascade pin on the upstream shell-subshell-grouping arm:
12605        // a value carrying both `(` and `#` (`"../(cd foo)#pin"` —
12606        // the canonical "I pasted a subshell-grouping followed by a
12607        // URL-fragment tail" footgun) routes through
12608        // `FonteCaminhoShellSubshellGrouping` not
12609        // `FonteCaminhoShellComment`. The modern Bourne `$(<cmd>)`
12610        // command-substitution boundary is the load-bearing axis on
12611        // every probe-as-both value.
12612        let d = dep_with_fonte(DepSource::Path {
12613            caminho: "../(cd foo)#pin".into(),
12614        });
12615        let err = d.validate().unwrap_err();
12616        assert!(
12617            matches!(
12618                err,
12619                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
12620            ),
12621            "got {err:?}",
12622        );
12623    }
12624
12625    #[test]
12626    fn fonte_caminho_shell_glob_fires_before_shell_comment() {
12627        // Cascade pin on the upstream shell-glob arm: a value
12628        // carrying both `*` and `#` (`"../caixa-teia/*#pin"` — the
12629        // canonical "I pasted a `*` unbounded pathname-expansion
12630        // followed by a URL-fragment tail" footgun) routes through
12631        // `FonteCaminhoShellGlob` not `FonteCaminhoShellComment`.
12632        // The unbounded pathname-expansion sentinel is the load-
12633        // bearing root-cause edit on every probe-as-both value.
12634        let d = dep_with_fonte(DepSource::Path {
12635            caminho: "../caixa-teia/*#pin".into(),
12636        });
12637        let err = d.validate().unwrap_err();
12638        assert!(
12639            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12640            "got {err:?}",
12641        );
12642    }
12643
12644    #[test]
12645    fn fonte_caminho_shell_command_substitution_fires_before_shell_comment() {
12646        // Cascade pin on the upstream shell-command-substitution
12647        // arm: a value carrying both a backtick and `#`
12648        // (``"../`whoami`#pin"`` — the canonical "I pasted a
12649        // legacy-backtick command-substitution followed by a URL-
12650        // fragment tail" footgun) routes through
12651        // `FonteCaminhoShellCommandSubstitution` not
12652        // `FonteCaminhoShellComment`. The CWE-78 shell-command-
12653        // injection vector is the load-bearing root-cause edit on
12654        // every probe-as-both value.
12655        let d = dep_with_fonte(DepSource::Path {
12656            caminho: "../`whoami`#pin".into(),
12657        });
12658        let err = d.validate().unwrap_err();
12659        assert!(
12660            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
12661            "got {err:?}",
12662        );
12663    }
12664
12665    #[test]
12666    fn fonte_caminho_shell_background_fires_before_shell_comment() {
12667        // Cascade pin on the upstream shell-background arm: a value
12668        // carrying both `&` and `#` (`"../caixa-teia&pin#tail"` —
12669        // the canonical "I pasted a `cmd &` background-launch
12670        // followed by a URL-fragment tail" footgun) routes through
12671        // `FonteCaminhoShellBackground` not
12672        // `FonteCaminhoShellComment`. The background-launch tail is
12673        // the load-bearing root-cause edit on every probe-as-both
12674        // value.
12675        let d = dep_with_fonte(DepSource::Path {
12676            caminho: "../caixa-teia&pin#tail".into(),
12677        });
12678        let err = d.validate().unwrap_err();
12679        assert!(
12680            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
12681            "got {err:?}",
12682        );
12683    }
12684
12685    #[test]
12686    fn fonte_caminho_shell_semicolon_fires_before_shell_comment() {
12687        // Cascade pin on the upstream shell-semicolon arm: a value
12688        // carrying both `;` and `#` (`"../caixa-teia;pin#tail"` —
12689        // the canonical sequential-cleanup + URL-fragment paste
12690        // idiom) routes through `FonteCaminhoShellSemicolon` not
12691        // `FonteCaminhoShellComment`. The sequential-command-
12692        // separator paste is the load-bearing root-cause edit on
12693        // every probe-as-both value.
12694        let d = dep_with_fonte(DepSource::Path {
12695            caminho: "../caixa-teia;pin#tail".into(),
12696        });
12697        let err = d.validate().unwrap_err();
12698        assert!(
12699            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
12700            "got {err:?}",
12701        );
12702    }
12703
12704    #[test]
12705    fn fonte_caminho_shell_pipe_fires_before_shell_comment() {
12706        // Cascade pin on the upstream shell-pipe arm: a value
12707        // carrying both `|` and `#` (`"../caixa-teia|pin#tail"` —
12708        // the canonical pipeline-to-URL-fragment paste idiom) routes
12709        // through `FonteCaminhoShellPipe` not
12710        // `FonteCaminhoShellComment`. The pipeline-tail paste is
12711        // the load-bearing root-cause edit on every probe-as-both
12712        // value.
12713        let d = dep_with_fonte(DepSource::Path {
12714            caminho: "../caixa-teia|pin#tail".into(),
12715        });
12716        let err = d.validate().unwrap_err();
12717        assert!(
12718            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
12719            "got {err:?}",
12720        );
12721    }
12722
12723    #[test]
12724    fn fonte_caminho_shell_redirection_fires_before_shell_comment() {
12725        // Cascade pin on the upstream shell-redirection arm: a
12726        // value carrying both `>` and `#` (`"../caixa-teia>log#pin"`
12727        // — the canonical "I pasted a `cmd > log` redirect followed
12728        // by a URL-fragment tail" footgun) routes through
12729        // `FonteCaminhoShellRedirection` not
12730        // `FonteCaminhoShellComment`. The input/output redirection
12731        // metachar carries the more self-locating `byte` payload,
12732        // so the prior arm wins on every probe-as-both value.
12733        let d = dep_with_fonte(DepSource::Path {
12734            caminho: "../caixa-teia>log#pin".into(),
12735        });
12736        let err = d.validate().unwrap_err();
12737        assert!(
12738            matches!(
12739                err,
12740                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
12741            ),
12742            "got {err:?}",
12743        );
12744    }
12745
12746    #[test]
12747    fn fonte_caminho_backslash_fires_before_shell_comment() {
12748        // Cascade pin on the upstream backslash arm: a value
12749        // carrying both `\` and `#` (`"..\caixa-teia#pin"` — the
12750        // canonical "I pasted a Windows-shell path followed by a
12751        // URL-fragment tail" footgun) routes through
12752        // `FonteCaminhoBackslash` not `FonteCaminhoShellComment`.
12753        // The cross-host-OS-separator divergence is the load-
12754        // bearing axis on every probe-as-both value.
12755        let d = dep_with_fonte(DepSource::Path {
12756            caminho: "..\\caixa-teia#pin".into(),
12757        });
12758        let err = d.validate().unwrap_err();
12759        assert!(
12760            matches!(err, DepError::FonteCaminhoBackslash { .. }),
12761            "got {err:?}",
12762        );
12763    }
12764
12765    #[test]
12766    fn fonte_caminho_control_char_fires_before_shell_comment() {
12767        // Cascade pin on the embedded-control-byte arm: a value
12768        // carrying both a control byte and `#` (`"../foo\n#pin"` —
12769        // the canonical paste-from-multiline-doc footgun where a
12770        // newline landed mid-caminho between the path and an
12771        // annotation) routes through `FonteCaminhoControlChar` not
12772        // `FonteCaminhoShellComment`. The POSIX-syscall-rejected-
12773        // byte diagnostic is the load-bearing axis on every value
12774        // that probes positive for both — mirrors the cascade
12775        // discipline on every prior arm.
12776        let d = dep_with_fonte(DepSource::Path {
12777            caminho: "../foo\n#pin".into(),
12778        });
12779        let err = d.validate().unwrap_err();
12780        assert!(
12781            matches!(err, DepError::FonteCaminhoControlChar { .. }),
12782            "got {err:?}",
12783        );
12784    }
12785
12786    #[test]
12787    fn fonte_caminho_absolute_fires_before_shell_comment() {
12788        // Cascade pin on the load-bearing leading-byte arm: a
12789        // leading `/` value with embedded `#` (`"/etc/foo#pin"`)
12790        // routes through `FonteCaminhoAbsolute` not
12791        // `FonteCaminhoShellComment` — the host-layout-leak
12792        // diagnostic is the load-bearing axis, the fragment byte is
12793        // the secondary observation. Same precedence logic as every
12794        // prior leading-byte arm.
12795        let d = dep_with_fonte(DepSource::Path {
12796            caminho: "/etc/foo#pin".into(),
12797        });
12798        let err = d.validate().unwrap_err();
12799        assert!(
12800            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
12801            "got {err:?}",
12802        );
12803    }
12804
12805    #[test]
12806    fn fonte_caminho_var_expansion_fires_before_shell_comment() {
12807        // Cascade pin on the upstream leading-`$` var-expansion
12808        // arm: a value carrying both a leading `$` and a `#`
12809        // (`"$DIR/foo#pin"` — the canonical "I pasted a `$DIR`
12810        // shell-variable at the head of a sibling-workspace path
12811        // followed by a URL-fragment tail" footgun) routes through
12812        // `FonteCaminhoVarExpansion` not `FonteCaminhoShellComment`.
12813        // The leading-byte shell-variable-expansion is the more
12814        // self-locating diagnostic on values that probe as both.
12815        let d = dep_with_fonte(DepSource::Path {
12816            caminho: "$DIR/foo#pin".into(),
12817        });
12818        let err = d.validate().unwrap_err();
12819        assert!(
12820            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
12821            "got {err:?}",
12822        );
12823    }
12824
12825    #[test]
12826    fn fonte_caminho_shell_comment_fires_before_trailing_slash() {
12827        // Cascade pin on the immediate-successor arm: a value
12828        // carrying both `#` and a trailing `/`
12829        // (`"../caixa-teia#pin/"` — the canonical "I tab-completed
12830        // a URL-fragment-carrying path" footgun) routes through
12831        // `FonteCaminhoShellComment` not
12832        // `FonteCaminhoTrailingSlash`. The embedded fragment /
12833        // comment-lead byte is the more semantic-locating axis (an
12834        // author who removes the `#pin` fragment typically also
12835        // drops the trailing separator since both are paste-from-
12836        // URL / paste-from-shell-tab-completion artifacts).
12837        let d = dep_with_fonte(DepSource::Path {
12838            caminho: "../caixa-teia#pin/".into(),
12839        });
12840        let err = d.validate().unwrap_err();
12841        assert!(
12842            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. },),
12843            "got {err:?}",
12844        );
12845    }
12846
12847    #[test]
12848    fn fonte_caminho_shell_comment_diagnostic_carries_offending_dep_caminho_and_byte() {
12849        // Diagnostic-shape pin (peer with
12850        // `fonte_caminho_shell_quote_grouping_diagnostic_carries_offending_dep_caminho_and_byte`
12851        // on the immediate-predecessor arm): the error's Display
12852        // surfaces the offending `:nome`, the offending `:caminho`
12853        // verbatim, the offending byte's hex / character form, and
12854        // names the shell-comment / URL-fragment-identifier /
12855        // YAML-comment cross-config-DSL footgun explicitly so a
12856        // `feira lint` run can render the diagnostic without
12857        // re-parsing.
12858        let d = dep_with_fonte(DepSource::Path {
12859            caminho: "../caixa-teia#readme".into(),
12860        });
12861        let rendered = d.validate().unwrap_err().to_string();
12862        assert!(
12863            rendered.contains("caixa-teia"),
12864            "diagnostic must name the offending dep: {rendered}",
12865        );
12866        assert!(
12867            rendered.contains("../caixa-teia#readme"),
12868            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
12869        );
12870        assert!(
12871            rendered.contains("0x23"),
12872            "diagnostic must surface the offending byte hex: {rendered:?}",
12873        );
12874        assert!(
12875            rendered.contains("shell-comment") || rendered.contains("comment-lead"),
12876            "diagnostic must name the shell-comment footgun: {rendered:?}",
12877        );
12878        assert!(
12879            rendered.contains("fragment") || rendered.contains("URL-fragment"),
12880            "diagnostic must reference the URL-fragment-identifier vocabulary: \
12881             {rendered:?}",
12882        );
12883    }
12884
12885    #[test]
12886    fn validate_rejects_path_fonte_with_caminho_carrying_url_percent_encoded_space() {
12887        // The canonical paste-from-browser-address-bar percent-
12888        // encoded-space footgun: an author copies `../caixa%20teia`
12889        // out of a URL-encoded README hyperlink / browser address
12890        // bar / percent-encoded permalink expecting `%20` to decode
12891        // to a literal space at the filesystem layer. POSIX
12892        // `std::path::Path` treats `%` as a literal path-component
12893        // byte, so `Path::join` looks for a literal
12894        // `./../caixa%20teia` subdirectory. `Path::is_absolute`
12895        // returns false on `..`, `%` is neither a leading-byte
12896        // sentinel nor a control byte nor `\` nor `<` / `>` nor
12897        // `|` nor `;` nor `&` nor backtick nor `*` / `?` nor `(` /
12898        // `)` nor `{` / `}` nor `[` / `]` nor `'` / `"` nor `#`,
12899        // and the value's last byte isn't `/` — so the value
12900        // silently passed every prior arm. The new arm moves the
12901        // rejection to validate time and names the offending dep +
12902        // caminho + byte verbatim.
12903        let d = dep_with_fonte(DepSource::Path {
12904            caminho: "../caixa%20teia".into(),
12905        });
12906        let err = d.validate().unwrap_err();
12907        let DepError::FonteCaminhoUrlPercentEncoding {
12908            nome,
12909            caminho,
12910            byte,
12911        } = err
12912        else {
12913            panic!("expected FonteCaminhoUrlPercentEncoding, got {err:?}");
12914        };
12915        assert_eq!(nome, "caixa-teia");
12916        assert_eq!(caminho, "../caixa%20teia");
12917        assert_eq!(byte, b'%');
12918    }
12919
12920    #[test]
12921    fn validate_rejects_path_fonte_with_caminho_carrying_url_percent_encoded_slash() {
12922        // The over-encoded path-separator shape (`"../caixa%2Fteia"`
12923        // intending the `%2F` as the URL encoding of `/`) locks a
12924        // `path:../caixa%2Fteia` BLAKE3 closure that diverges from
12925        // the byte-identical `path:../caixa/teia` form. Pinned
12926        // separately from the space-encoded shape so the gate's
12927        // coverage extends past the single canonical `%20` example
12928        // to any two-hex-digit percent-encoded sequence.
12929        let d = dep_with_fonte(DepSource::Path {
12930            caminho: "../caixa%2Fteia".into(),
12931        });
12932        let err = d.validate().unwrap_err();
12933        assert!(
12934            matches!(
12935                err,
12936                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
12937            ),
12938            "got {err:?}",
12939        );
12940    }
12941
12942    #[test]
12943    fn validate_rejects_path_fonte_with_caminho_carrying_lone_percent() {
12944        // The lone-`%` malformed-escape shape (`"../caixa-teia%foo"`
12945        // where `%` isn't followed by two hex digits) — every
12946        // WHATWG-conformant URL parser rejects the value at parse
12947        // time per RFC 3986 §2.1, but the byte would silently ride
12948        // into the lacre before the resolver subprocess crosses the
12949        // URL-parser boundary. Pinned separately from the well-
12950        // formed `%HH` shapes so the gate covers every percent-
12951        // occurrence, not only strictly-conformant escapes.
12952        let d = dep_with_fonte(DepSource::Path {
12953            caminho: "../caixa-teia%foo".into(),
12954        });
12955        let err = d.validate().unwrap_err();
12956        assert!(
12957            matches!(
12958                err,
12959                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
12960            ),
12961            "got {err:?}",
12962        );
12963    }
12964
12965    #[test]
12966    fn validate_rejects_path_fonte_with_caminho_carrying_leading_yaml_directive() {
12967        // The YAML-directive-lead paste shape (`"%YAML/../caixa-teia"`
12968        // — the canonical paste-from-top-of-doc YAML directive
12969        // block cross-idiom leak per YAML 1.2 §6.8.1). Pinned
12970        // separately from embedded shapes so the gate covers the
12971        // leading-position `%` too, not only mid-value occurrences.
12972        let d = dep_with_fonte(DepSource::Path {
12973            caminho: "%YAML/../caixa-teia".into(),
12974        });
12975        let err = d.validate().unwrap_err();
12976        assert!(
12977            matches!(
12978                err,
12979                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
12980            ),
12981            "got {err:?}",
12982        );
12983    }
12984
12985    #[test]
12986    fn validate_rejects_path_fonte_with_caminho_carrying_printf_format_specifier() {
12987        // The printf-format-specifier paste shape
12988        // (`"../caixa-%s-teia"` — the canonical paste-from-shell-
12989        // diagnostic-one-liner `printf "path=%s\n" ...` idiom, CWE-
12990        // 134 format-string-injection vector). Pinned separately
12991        // from the URL-encoding shapes so the gate's rationale
12992        // extends past the RFC 3986 axis to the C / POSIX printf
12993        // format-directive-lead axis.
12994        let d = dep_with_fonte(DepSource::Path {
12995            caminho: "../caixa-%s-teia".into(),
12996        });
12997        let err = d.validate().unwrap_err();
12998        assert!(
12999            matches!(
13000                err,
13001                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
13002            ),
13003            "got {err:?}",
13004        );
13005    }
13006
13007    #[test]
13008    fn validate_accepts_path_fonte_with_caminho_carrying_no_percent() {
13009        // The positive-control pin: the gate targets only `%`,
13010        // never adjacent printable ASCII or POSIX-valid bytes. The
13011        // canonical relative POSIX path (`"../caixa-teia"`) and a
13012        // nested deeply-pathed variant with adjacent printable
13013        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
13014        // to validate cleanly so the gate doesn't widen to a "no
13015        // printable punctuation anywhere" sweep that would defeat
13016        // the entire path-fonte author surface. Peer with
13017        // `validate_accepts_path_fonte_with_caminho_carrying_no_shell_comment`
13018        // on the immediate-predecessor arm.
13019        let d = dep_with_fonte(DepSource::Path {
13020            caminho: "../caixa-teia/sub-dir.v2".into(),
13021        });
13022        d.validate().unwrap();
13023    }
13024
13025    #[test]
13026    fn fonte_caminho_shell_comment_fires_before_url_percent_encoding() {
13027        // Cascade pin on the immediate-predecessor arm: a value
13028        // carrying both `#` and `%` (`"../caixa-teia#pin%20"` — the
13029        // canonical "I pasted a URL-fragment permalink followed by a
13030        // percent-encoded space tail" footgun) routes through
13031        // `FonteCaminhoShellComment` not
13032        // `FonteCaminhoUrlPercentEncoding`. The URL-fragment-
13033        // identifier is the load-bearing downstream-truncation edit
13034        // on every probe-as-both value; same cascade discipline
13035        // every prior `:caminho` arm establishes.
13036        let d = dep_with_fonte(DepSource::Path {
13037            caminho: "../caixa-teia#pin%20".into(),
13038        });
13039        let err = d.validate().unwrap_err();
13040        assert!(
13041            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
13042            "got {err:?}",
13043        );
13044    }
13045
13046    #[test]
13047    fn fonte_caminho_shell_quote_grouping_fires_before_url_percent_encoding() {
13048        // Cascade pin on the upstream shell-quote-grouping arm: a
13049        // value carrying both `'` and `%` (`"../'x'%20teia"` — the
13050        // canonical "I pasted a strong-quoted literal followed by
13051        // a percent-encoded space" footgun) routes through
13052        // `FonteCaminhoShellQuoteGrouping` not
13053        // `FonteCaminhoUrlPercentEncoding`. The shell-string-
13054        // literal-delimiter is the load-bearing root-cause edit on
13055        // every probe-as-both value.
13056        let d = dep_with_fonte(DepSource::Path {
13057            caminho: "../'x'%20teia".into(),
13058        });
13059        let err = d.validate().unwrap_err();
13060        assert!(
13061            matches!(
13062                err,
13063                DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
13064            ),
13065            "got {err:?}",
13066        );
13067    }
13068
13069    #[test]
13070    fn fonte_caminho_backslash_fires_before_url_percent_encoding() {
13071        // Cascade pin on the upstream backslash arm: a value
13072        // carrying both `\` and `%` (`"..\\caixa%20teia"` — the
13073        // canonical "I pasted a Windows-shell path followed by a
13074        // percent-encoded space" footgun) routes through
13075        // `FonteCaminhoBackslash` not
13076        // `FonteCaminhoUrlPercentEncoding`. The cross-host-OS-
13077        // separator divergence is the load-bearing root-cause edit
13078        // on every probe-as-both value.
13079        let d = dep_with_fonte(DepSource::Path {
13080            caminho: "..\\caixa%20teia".into(),
13081        });
13082        let err = d.validate().unwrap_err();
13083        assert!(
13084            matches!(err, DepError::FonteCaminhoBackslash { .. }),
13085            "got {err:?}",
13086        );
13087    }
13088
13089    #[test]
13090    fn fonte_caminho_control_char_fires_before_url_percent_encoding() {
13091        // Cascade pin on the upstream control-char arm: a value
13092        // carrying both a NUL byte and `%` (`"../caixa\0%20teia"` —
13093        // the canonical "I pasted a paste-from-binary-blob path
13094        // followed by a percent-encoded space" footgun) routes
13095        // through `FonteCaminhoControlChar` not
13096        // `FonteCaminhoUrlPercentEncoding`. The POSIX-syscall-
13097        // rejected byte is the load-bearing root-cause edit on
13098        // every probe-as-both value.
13099        let d = dep_with_fonte(DepSource::Path {
13100            caminho: "../caixa\0%20teia".into(),
13101        });
13102        let err = d.validate().unwrap_err();
13103        assert!(
13104            matches!(err, DepError::FonteCaminhoControlChar { byte: 0x00, .. },),
13105            "got {err:?}",
13106        );
13107    }
13108
13109    #[test]
13110    fn fonte_caminho_absolute_fires_before_url_percent_encoding() {
13111        // Cascade pin on the upstream absolute-path arm: a value
13112        // that's both absolute and carries `%` (`"/etc/passwd%20"`
13113        // — the canonical "I pasted an absolute path with a
13114        // percent-encoded space tail" footgun) routes through
13115        // `FonteCaminhoAbsolute` not
13116        // `FonteCaminhoUrlPercentEncoding`. The host-layout-leak is
13117        // the load-bearing root-cause edit on every probe-as-both
13118        // value.
13119        let d = dep_with_fonte(DepSource::Path {
13120            caminho: "/etc/passwd%20".into(),
13121        });
13122        let err = d.validate().unwrap_err();
13123        assert!(
13124            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
13125            "got {err:?}",
13126        );
13127    }
13128
13129    #[test]
13130    fn fonte_caminho_var_expansion_fires_before_url_percent_encoding() {
13131        // Cascade pin on the upstream var-expansion arm: a value
13132        // starting with `$` and carrying `%` (`"$HOME/caixa%20teia"`
13133        // — the canonical "I pasted a `$HOME`-rooted path with a
13134        // percent-encoded space" footgun) routes through
13135        // `FonteCaminhoVarExpansion` not
13136        // `FonteCaminhoUrlPercentEncoding`. The shell-variable-
13137        // expansion is the load-bearing root-cause edit on every
13138        // probe-as-both value.
13139        let d = dep_with_fonte(DepSource::Path {
13140            caminho: "$HOME/caixa%20teia".into(),
13141        });
13142        let err = d.validate().unwrap_err();
13143        assert!(
13144            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
13145            "got {err:?}",
13146        );
13147    }
13148
13149    #[test]
13150    fn fonte_caminho_url_percent_encoding_fires_before_trailing_slash() {
13151        // Cascade pin on the immediate-successor arm: a value
13152        // carrying both `%` and a trailing `/`
13153        // (`"../caixa%20teia/"` — the canonical "I tab-completed a
13154        // percent-encoded-space-carrying path" footgun) routes
13155        // through `FonteCaminhoUrlPercentEncoding` not
13156        // `FonteCaminhoTrailingSlash`. The embedded percent-
13157        // encoding-escape byte is the more semantic-locating axis
13158        // (an author who decodes the `%20` to a literal space is
13159        // likely to also tab-strip the trailing separator since
13160        // both are paste-from-URL / paste-from-shell-tab-completion
13161        // artifacts).
13162        let d = dep_with_fonte(DepSource::Path {
13163            caminho: "../caixa%20teia/".into(),
13164        });
13165        let err = d.validate().unwrap_err();
13166        assert!(
13167            matches!(
13168                err,
13169                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
13170            ),
13171            "got {err:?}",
13172        );
13173    }
13174
13175    #[test]
13176    fn fonte_caminho_url_percent_encoding_diagnostic_carries_offending_dep_caminho_and_byte() {
13177        // Diagnostic-shape pin (peer with
13178        // `fonte_caminho_shell_comment_diagnostic_carries_offending_dep_caminho_and_byte`
13179        // on the immediate-predecessor arm): the error's Display
13180        // surfaces the offending `:nome`, the offending `:caminho`
13181        // verbatim, the offending byte's hex / character form, and
13182        // names the URL-percent-encoding-escape / printf-format-
13183        // specifier footgun explicitly so a `feira lint` run can
13184        // render the diagnostic without re-parsing.
13185        let d = dep_with_fonte(DepSource::Path {
13186            caminho: "../caixa%20teia".into(),
13187        });
13188        let rendered = d.validate().unwrap_err().to_string();
13189        assert!(
13190            rendered.contains("caixa-teia"),
13191            "diagnostic must name the offending dep: {rendered}",
13192        );
13193        assert!(
13194            rendered.contains("../caixa%20teia"),
13195            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
13196        );
13197        assert!(
13198            rendered.contains("0x25"),
13199            "diagnostic must surface the offending byte hex: {rendered:?}",
13200        );
13201        assert!(
13202            rendered.contains("percent-encoding") || rendered.contains("percent-encoded"),
13203            "diagnostic must name the URL-percent-encoding-escape footgun: {rendered:?}",
13204        );
13205        assert!(
13206            rendered.contains("printf") || rendered.contains("format-specifier"),
13207            "diagnostic must reference the printf-format-specifier vocabulary: \
13208             {rendered:?}",
13209        );
13210    }
13211
13212    #[test]
13213    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_var_expansion() {
13214        // The canonical embedded-`$` shell-variable-expansion paste
13215        // shape (`"../foo$HOME/bar"` — an author copies a partially-
13216        // substituted shell one-liner where the leading segment is a
13217        // literal `../foo` while the mid segment carries the un-
13218        // substituted `$HOME` template). The leading-`$` position is
13219        // already gated by the f4efe9c leading-byte arm which routes
13220        // through `FonteCaminhoVarExpansion`; this arm closes the
13221        // last positional gap on `$` — every position on the axis is
13222        // structurally rejected.
13223        let d = dep_with_fonte(DepSource::Path {
13224            caminho: "../foo$HOME/bar".into(),
13225        });
13226        let err = d.validate().unwrap_err();
13227        let DepError::FonteCaminhoShellVariableExpansion {
13228            nome,
13229            caminho,
13230            byte,
13231        } = err
13232        else {
13233            panic!("expected FonteCaminhoShellVariableExpansion, got {err:?}");
13234        };
13235        assert_eq!(nome, "caixa-teia");
13236        assert_eq!(caminho, "../foo$HOME/bar");
13237        assert_eq!(byte, b'$');
13238    }
13239
13240    #[test]
13241    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_braced_var_expansion() {
13242        // The symmetric braced-CI-manifest paste shape
13243        // (`"../foo${WORKSPACE}/bar"` — the canonical paste-from-
13244        // GitHub-Actions-workflow / paste-from-`.gitlab-ci.yml`
13245        // footgun). Pinned separately from the bare-`$VAR` shape so
13246        // the gate covers both POSIX shell §2.6 Parameter Expansion
13247        // syntactic forms, not only the unbraced variant. The
13248        // embedded `{` byte in `${...}` is also caught by the 598b770
13249        // shell-brace-expansion arm but that arm fires earlier in
13250        // the cascade — the `$` arm's coverage extends to `${...}`
13251        // structurally, so the diagnostic asserted here is the
13252        // brace-expansion one (which is a valid outcome; the point
13253        // of the pin is that the value never survives validation).
13254        let d = dep_with_fonte(DepSource::Path {
13255            caminho: "../foo${WORKSPACE}/bar".into(),
13256        });
13257        let err = d.validate().unwrap_err();
13258        assert!(
13259            matches!(
13260                err,
13261                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. }
13262                    | DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
13263            ),
13264            "got {err:?}",
13265        );
13266    }
13267
13268    #[test]
13269    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_command_substitution() {
13270        // The paste-from-shell-prompt command-substitution idiom
13271        // (`"../foo$(whoami)/bar"`). Pinned separately from the bare-
13272        // `$VAR` shape so the gate's rationale extends to POSIX shell
13273        // §2.6.3 Command Substitution (the modern `$(<cmd>)` form; the
13274        // legacy `` `<cmd>` `` form is already closed by the c370458
13275        // backtick arm). The embedded `(` byte in `$(...)` is also
13276        // caught structurally by the 0633c91 shell-subshell-grouping
13277        // arm which fires earlier in the cascade — the diagnostic
13278        // asserted here is either outcome, since both structurally
13279        // reject the value; the point of the pin is that the value
13280        // never survives validation.
13281        let d = dep_with_fonte(DepSource::Path {
13282            caminho: "../foo$(whoami)/bar".into(),
13283        });
13284        let err = d.validate().unwrap_err();
13285        assert!(
13286            matches!(
13287                err,
13288                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. }
13289                    | DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
13290            ),
13291            "got {err:?}",
13292        );
13293    }
13294
13295    #[test]
13296    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_positional_parameter() {
13297        // The paste-from-`Makefile` / paste-from-SQL-migration bare-
13298        // `$1` positional-parameter shape (`"../foo$1/bar"` — a Make
13299        // automatic-variable `$1` or a PostgreSQL bind-parameter `$1`
13300        // idiom copied into a caminho template). None of the prior
13301        // shell-metachar arms cover this shape (`1` is a bare digit;
13302        // no `(` / `{` / letter follows the `$`), so the arm is the
13303        // sole gate on the shape.
13304        let d = dep_with_fonte(DepSource::Path {
13305            caminho: "../foo$1/bar".into(),
13306        });
13307        let err = d.validate().unwrap_err();
13308        assert!(
13309            matches!(
13310                err,
13311                DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
13312            ),
13313            "got {err:?}",
13314        );
13315    }
13316
13317    #[test]
13318    fn validate_accepts_path_fonte_with_caminho_carrying_no_dollar() {
13319        // The positive-control pin (peer with
13320        // `validate_accepts_path_fonte_with_caminho_carrying_no_percent`
13321        // on the immediate-predecessor arm): the gate targets only
13322        // `$`, never adjacent printable ASCII or POSIX-valid bytes.
13323        // A relative POSIX path carrying dashes / dots / slashes /
13324        // digits (`"../caixa-teia/sub-dir.v2"`) must continue to
13325        // validate cleanly so the gate doesn't widen to a "no
13326        // printable punctuation anywhere" sweep that would defeat
13327        // the entire path-fonte author surface.
13328        let d = dep_with_fonte(DepSource::Path {
13329            caminho: "../caixa-teia/sub-dir.v2".into(),
13330        });
13331        d.validate().unwrap();
13332    }
13333
13334    #[test]
13335    fn fonte_caminho_var_expansion_fires_before_shell_variable_expansion() {
13336        // Cascade pin on the leading-`$` sibling arm at line 540: a
13337        // value starting with `$` and carrying an embedded `$` too
13338        // (`"$HOME/foo$WORKSPACE/bar"` — the canonical "I pasted a
13339        // fully-templated CI path with two un-substituted variables")
13340        // routes through `FonteCaminhoVarExpansion` not
13341        // `FonteCaminhoShellVariableExpansion`. The leading-byte
13342        // host-layout-leak is the load-bearing self-locating axis
13343        // (the leading position dominates the semantic-locating
13344        // rationale on every probe-as-both value); the embedded
13345        // arm's positional-agnostic sweep catches only values whose
13346        // leading byte doesn't route through the earlier leading-
13347        // byte arms.
13348        let d = dep_with_fonte(DepSource::Path {
13349            caminho: "$HOME/foo$WORKSPACE/bar".into(),
13350        });
13351        let err = d.validate().unwrap_err();
13352        assert!(
13353            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
13354            "got {err:?}",
13355        );
13356    }
13357
13358    #[test]
13359    fn fonte_caminho_url_percent_encoding_fires_before_shell_variable_expansion() {
13360        // Cascade pin on the immediate-predecessor arm: a value
13361        // carrying both `%` and embedded `$` (`"../foo%20$HOME/bar"`
13362        // — the canonical "I pasted a percent-encoded space adjacent
13363        // to a `$HOME` template") routes through
13364        // `FonteCaminhoUrlPercentEncoding` not
13365        // `FonteCaminhoShellVariableExpansion`. The URL-percent-
13366        // encoding-escape byte is the more semantic-locating axis
13367        // (the paste-from-browser-address-bar shape is the load-
13368        // bearing self-locating edit); same cascade discipline every
13369        // prior `:caminho` arm establishes.
13370        let d = dep_with_fonte(DepSource::Path {
13371            caminho: "../foo%20$HOME/bar".into(),
13372        });
13373        let err = d.validate().unwrap_err();
13374        assert!(
13375            matches!(
13376                err,
13377                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
13378            ),
13379            "got {err:?}",
13380        );
13381    }
13382
13383    #[test]
13384    fn fonte_caminho_shell_variable_expansion_fires_before_trailing_slash() {
13385        // Cascade pin on the immediate-successor arm: a value
13386        // carrying both embedded `$` and a trailing `/`
13387        // (`"../foo$HOME/bar/"` — the canonical "I tab-completed a
13388        // `$HOME`-template-carrying path") routes through
13389        // `FonteCaminhoShellVariableExpansion` not
13390        // `FonteCaminhoTrailingSlash`. The embedded shell-variable-
13391        // expansion byte is the more semantic-locating axis on
13392        // probe-as-both values (an author who substitutes the
13393        // `$HOME` template with a literal value is likely to also
13394        // tab-strip the trailing separator).
13395        let d = dep_with_fonte(DepSource::Path {
13396            caminho: "../foo$HOME/bar/".into(),
13397        });
13398        let err = d.validate().unwrap_err();
13399        assert!(
13400            matches!(
13401                err,
13402                DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
13403            ),
13404            "got {err:?}",
13405        );
13406    }
13407
13408    #[test]
13409    fn fonte_caminho_shell_variable_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
13410        // Diagnostic-shape pin (peer with
13411        // `fonte_caminho_url_percent_encoding_diagnostic_carries_offending_dep_caminho_and_byte`
13412        // on the immediate-predecessor arm): the error's Display
13413        // surfaces the offending `:nome`, the offending `:caminho`
13414        // verbatim, the offending byte's hex / character form, and
13415        // names the shell-variable-expansion / command-substitution
13416        // footgun explicitly so a `feira lint` run can render the
13417        // diagnostic without re-parsing.
13418        let d = dep_with_fonte(DepSource::Path {
13419            caminho: "../foo$HOME/bar".into(),
13420        });
13421        let rendered = d.validate().unwrap_err().to_string();
13422        assert!(
13423            rendered.contains("caixa-teia"),
13424            "diagnostic must name the offending dep: {rendered}",
13425        );
13426        assert!(
13427            rendered.contains("../foo$HOME/bar"),
13428            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
13429        );
13430        assert!(
13431            rendered.contains("0x24"),
13432            "diagnostic must surface the offending byte hex: {rendered:?}",
13433        );
13434        assert!(
13435            rendered.contains("variable-expansion") || rendered.contains("variable expansion"),
13436            "diagnostic must name the shell-variable-expansion footgun: {rendered:?}",
13437        );
13438        assert!(
13439            rendered.contains("command-substitution") || rendered.contains("command substitution"),
13440            "diagnostic must reference the command-substitution vocabulary: {rendered:?}",
13441        );
13442    }
13443
13444    #[test]
13445    fn validate_rejects_path_fonte_with_caminho_carrying_shell_history_expansion() {
13446        // The fail-before-pass-after pin for the canonical paste-from-
13447        // shell-history footgun on `:caminho`. An author copies a `cd
13448        // ../caixa-teia && !sudo make install` one-liner from a quick-
13449        // start README, intending the trailing `!sudo` as a shell-
13450        // history-expansion reference but the typed slot is itself a
13451        // byte-level string parser, not a shell context, so the byte
13452        // rides into the value verbatim. Until this arm landed the `!`
13453        // byte silently passed every prior `:caminho` cascade arm
13454        // (`!` isn't `\` / `<` / `>` / `|` / `;` / `&` / backtick /
13455        // `*` / `?` / `(` / `)` / `{` / `}` / `[` / `]` / `'` / `"` /
13456        // `#` / `%` / `$`); bash with the default `histexpand` mode
13457        // rewrites `!command` to the most recent history entry
13458        // beginning with `command`, the canonical RCE-class injection
13459        // vector when the byte rides into a shell argument executed
13460        // under `bash -i` (the operator-notebook interactive shell).
13461        let d = dep_with_fonte(DepSource::Path {
13462            caminho: "../caixa-teia!sudo".into(),
13463        });
13464        let err = d.validate().unwrap_err();
13465        let DepError::FonteCaminhoShellHistoryExpansion {
13466            nome,
13467            caminho,
13468            byte,
13469        } = err
13470        else {
13471            panic!("expected FonteCaminhoShellHistoryExpansion, got {err:?}");
13472        };
13473        assert_eq!(nome, "caixa-teia");
13474        assert_eq!(caminho, "../caixa-teia!sudo");
13475        assert_eq!(byte, b'!');
13476    }
13477
13478    #[test]
13479    fn validate_rejects_path_fonte_with_caminho_carrying_double_bang_history_reference() {
13480        // The symmetric `!!` repeat-prior-command paste idiom (peer with
13481        // `validate_rejects_git_fonte_with_repo_carrying_double_bang_history_reference`
13482        // on `is_git_repo_url`). Pinned separately from the wrapped
13483        // `!command` shape so a future diagnostic-surface change that
13484        // only checked the leading or paired-bang position surfaces
13485        // here — the per-byte arm fires anywhere `!` appears in the
13486        // value, including at consecutive positions in the middle.
13487        let d = dep_with_fonte(DepSource::Path {
13488            caminho: "../foo!!/bar".into(),
13489        });
13490        let err = d.validate().unwrap_err();
13491        assert!(
13492            matches!(
13493                err,
13494                DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
13495            ),
13496            "got {err:?}",
13497        );
13498    }
13499
13500    #[test]
13501    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_enthusiasm_bang() {
13502        // The English-typography enthusiasm-form paste-from-prose
13503        // idiom: an author writes `:caminho "../caixa-teia!"`
13504        // expecting the substrate to coerce it to a kebab-case slug.
13505        // Pinned separately from the `!<word>` shell-history shape so
13506        // the gate's rationale extends to the paste-from-prose surface
13507        // (the same rationale the peer `is_git_repo_url` bang arm at
13508        // 7d53c68 covers). None of the prior shell-metachar arms cover
13509        // this shape (no `!<word>` reference and no `!!` repeat), so
13510        // the arm is the sole gate on the shape.
13511        let d = dep_with_fonte(DepSource::Path {
13512            caminho: "../caixa-teia!".into(),
13513        });
13514        let err = d.validate().unwrap_err();
13515        assert!(
13516            matches!(
13517                err,
13518                DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
13519            ),
13520            "got {err:?}",
13521        );
13522    }
13523
13524    #[test]
13525    fn validate_accepts_path_fonte_with_caminho_carrying_no_bang() {
13526        // The positive-control pin (peer with
13527        // `validate_accepts_path_fonte_with_caminho_carrying_no_dollar`
13528        // on the immediate-predecessor arm): the gate targets only
13529        // `!`, never adjacent printable ASCII or POSIX-valid bytes.
13530        // A relative POSIX path carrying dashes / dots / slashes /
13531        // digits (`"../caixa-teia/sub-dir.v2"`) must continue to
13532        // validate cleanly so the gate doesn't widen to a "no
13533        // printable punctuation anywhere" sweep that would defeat
13534        // the entire path-fonte author surface.
13535        let d = dep_with_fonte(DepSource::Path {
13536            caminho: "../caixa-teia/sub-dir.v2".into(),
13537        });
13538        d.validate().unwrap();
13539    }
13540
13541    #[test]
13542    fn fonte_caminho_shell_variable_expansion_fires_before_shell_history_expansion() {
13543        // Cascade pin on the immediate-predecessor arm: a value
13544        // carrying both embedded `$` and `!` (`"../foo$HOME/bar!sudo"`
13545        // — the canonical "I pasted a `$HOME`-templated path adjacent
13546        // to a trailing `!sudo` history-expansion") routes through
13547        // `FonteCaminhoShellVariableExpansion` not
13548        // `FonteCaminhoShellHistoryExpansion`. The shell-variable-
13549        // expansion byte is the more semantic-locating axis on
13550        // probe-as-both values (the paste-from-CI-manifest-with-`$VAR`-
13551        // template shape is the load-bearing self-locating edit);
13552        // same cascade discipline every prior `:caminho` arm
13553        // establishes.
13554        let d = dep_with_fonte(DepSource::Path {
13555            caminho: "../foo$HOME/bar!sudo".into(),
13556        });
13557        let err = d.validate().unwrap_err();
13558        assert!(
13559            matches!(
13560                err,
13561                DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
13562            ),
13563            "got {err:?}",
13564        );
13565    }
13566
13567    #[test]
13568    fn fonte_caminho_shell_history_expansion_fires_before_trailing_slash() {
13569        // Cascade pin on the immediate-successor arm: a value carrying
13570        // both embedded `!` and a trailing `/` (`"../caixa-teia!sudo/"`
13571        // — the canonical "I tab-completed a `!sudo`-carrying path")
13572        // routes through `FonteCaminhoShellHistoryExpansion` not
13573        // `FonteCaminhoTrailingSlash`. The embedded shell-history-
13574        // expansion byte is the more semantic-locating axis on probe-
13575        // as-both values (an author who removes the `!sudo` history
13576        // reference is likely to also tab-strip the trailing separator).
13577        let d = dep_with_fonte(DepSource::Path {
13578            caminho: "../caixa-teia!sudo/".into(),
13579        });
13580        let err = d.validate().unwrap_err();
13581        assert!(
13582            matches!(
13583                err,
13584                DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
13585            ),
13586            "got {err:?}",
13587        );
13588    }
13589
13590    #[test]
13591    fn fonte_caminho_shell_history_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
13592        // Diagnostic-shape pin (peer with
13593        // `fonte_caminho_shell_variable_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
13594        // on the immediate-predecessor arm): the error's Display
13595        // surfaces the offending `:nome`, the offending `:caminho`
13596        // verbatim, the offending byte's hex / character form, and
13597        // names the shell-history-expansion / bang-operator footgun
13598        // explicitly so a `feira lint` run can render the diagnostic
13599        // without re-parsing.
13600        let d = dep_with_fonte(DepSource::Path {
13601            caminho: "../caixa-teia!sudo".into(),
13602        });
13603        let rendered = d.validate().unwrap_err().to_string();
13604        assert!(
13605            rendered.contains("caixa-teia"),
13606            "diagnostic must name the offending dep: {rendered}",
13607        );
13608        assert!(
13609            rendered.contains("../caixa-teia!sudo"),
13610            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
13611        );
13612        assert!(
13613            rendered.contains("0x21"),
13614            "diagnostic must surface the offending byte hex: {rendered:?}",
13615        );
13616        assert!(
13617            rendered.contains("history-expansion") || rendered.contains("history expansion"),
13618            "diagnostic must name the shell-history-expansion footgun: {rendered:?}",
13619        );
13620        assert!(
13621            rendered.contains("bang"),
13622            "diagnostic must reference the bang-operator vocabulary: {rendered:?}",
13623        );
13624    }
13625
13626    #[test]
13627    fn validate_rejects_path_fonte_with_caminho_carrying_shell_history_substitution() {
13628        // The fail-before-pass-after pin for the canonical paste-from-
13629        // shell-history-quick-substitution footgun on `:caminho`. An
13630        // author copies a `git clone <bad-url>` line from their terminal,
13631        // corrects it via bash's `^bad^good` quick-substitution history
13632        // operator (bash reference §9.3, `set -o histexpand` mode's
13633        // default for interactive sessions), and pastes the trailing
13634        // `^bad^good` substitution fragment into a `:caminho` value
13635        // without trimming the leading `git clone` prefix — the byte
13636        // rides into the manifest verbatim. Until this arm landed the
13637        // `^` byte silently passed every prior `:caminho` cascade arm
13638        // (`^` isn't `\` / `<` / `>` / `|` / `;` / `&` / backtick / `*`
13639        // / `?` / `(` / `)` / `{` / `}` / `[` / `]` / `'` / `"` / `#` /
13640        // `%` / `$` / `!`); bash with the default `histexpand` mode
13641        // rewrites the prior command's `bad` string to `good` and re-
13642        // executes it, the paired-operator half of the `set -o
13643        // histexpand` feature the peer `!` arm already closes the prefix
13644        // half of. The peer `is_git_repo_url` axis rejects the byte at
13645        // 49e142f under the same shell-history-substitution / RFC-3986-
13646        // unwise banner.
13647        let d = dep_with_fonte(DepSource::Path {
13648            caminho: "../foo^bad^good".into(),
13649        });
13650        let err = d.validate().unwrap_err();
13651        let DepError::FonteCaminhoShellHistorySubstitution {
13652            nome,
13653            caminho,
13654            byte,
13655        } = err
13656        else {
13657            panic!("expected FonteCaminhoShellHistorySubstitution, got {err:?}");
13658        };
13659        assert_eq!(nome, "caixa-teia");
13660        assert_eq!(caminho, "../foo^bad^good");
13661        assert_eq!(byte, b'^');
13662    }
13663
13664    #[test]
13665    fn validate_rejects_path_fonte_with_caminho_carrying_regex_negation_anchor() {
13666        // The symmetric paste-from-doc-grep-pipeline footgun (peer with
13667        // `validate_rejects_git_fonte_with_repo_carrying_caret_regex_anchor`
13668        // on `is_git_repo_url`). An author copies a `grep '^archived'`
13669        // regex-anchor / negation idiom from a doc snippet and the byte
13670        // rides in verbatim. Pinned separately from the `^old^new^`
13671        // quick-substitution shape so a future diagnostic-surface change
13672        // that only checked the paired-caret history-substitution
13673        // position surfaces here — the per-byte arm fires anywhere `^`
13674        // appears in the value, including at a solitary leading-of-
13675        // segment position.
13676        let d = dep_with_fonte(DepSource::Path {
13677            caminho: "../foo/^archived".into(),
13678        });
13679        let err = d.validate().unwrap_err();
13680        assert!(
13681            matches!(
13682                err,
13683                DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
13684            ),
13685            "got {err:?}",
13686        );
13687    }
13688
13689    #[test]
13690    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_history_substitution_open() {
13691        // The trailing-`^` history-substitution-open shape — an author
13692        // starts typing a `^bad^good` quick-substitution but pastes only
13693        // the leading `^` sentinel before context-switching (a bash-
13694        // reference §9.3 valid histexpand prefix on its own — even a
13695        // solitary `^` on the prior command's whole re-execution shape).
13696        // Pinned separately from the `^old^new^` full-form and the leading-
13697        // of-segment `^archived` regex-anchor shape so the gate's
13698        // rationale extends to the paste-from-shell-history-with-only-
13699        // the-first-byte-selected surface. None of the prior shell-
13700        // metachar arms cover this shape.
13701        let d = dep_with_fonte(DepSource::Path {
13702            caminho: "../caixa-teia^".into(),
13703        });
13704        let err = d.validate().unwrap_err();
13705        assert!(
13706            matches!(
13707                err,
13708                DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
13709            ),
13710            "got {err:?}",
13711        );
13712    }
13713
13714    #[test]
13715    fn validate_accepts_path_fonte_with_caminho_carrying_no_caret() {
13716        // The positive-control pin (peer with
13717        // `validate_accepts_path_fonte_with_caminho_carrying_no_bang`
13718        // on the immediate-predecessor arm): the gate targets only
13719        // `^`, never adjacent printable ASCII or POSIX-valid bytes.
13720        // A relative POSIX path carrying dashes / dots / slashes /
13721        // digits / underscore (`"../caixa-teia/sub_v2.rc"`) must
13722        // continue to validate cleanly so the gate doesn't widen to
13723        // a "no printable punctuation anywhere" sweep that would
13724        // defeat the entire path-fonte author surface.
13725        let d = dep_with_fonte(DepSource::Path {
13726            caminho: "../caixa-teia/sub_v2.rc".into(),
13727        });
13728        d.validate().unwrap();
13729    }
13730
13731    #[test]
13732    fn fonte_caminho_shell_history_expansion_fires_before_shell_history_substitution() {
13733        // Cascade pin on the immediate-predecessor arm: a value carrying
13734        // both embedded `!` and `^` (`"../foo!sudo^bad^good"` — the
13735        // canonical "I pasted a `!sudo` history-reference next to a
13736        // `^bad^good` quick-substitution") routes through
13737        // `FonteCaminhoShellHistoryExpansion` not
13738        // `FonteCaminhoShellHistorySubstitution`. The `!` prefix form is
13739        // the more semantic-locating axis on probe-as-both values (an
13740        // author who removes the `!sudo` reference is likely to also
13741        // strip the paired `^` substitution fragment); same cascade
13742        // discipline every prior `:caminho` arm establishes.
13743        let d = dep_with_fonte(DepSource::Path {
13744            caminho: "../foo!sudo^bad^good".into(),
13745        });
13746        let err = d.validate().unwrap_err();
13747        assert!(
13748            matches!(
13749                err,
13750                DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
13751            ),
13752            "got {err:?}",
13753        );
13754    }
13755
13756    #[test]
13757    fn fonte_caminho_shell_history_substitution_fires_before_trailing_slash() {
13758        // Cascade pin on the immediate-successor arm: a value carrying
13759        // both embedded `^` and a trailing `/` (`"../foo^bad^good/"` —
13760        // the canonical "I tab-completed a `^bad^good`-carrying path")
13761        // routes through `FonteCaminhoShellHistorySubstitution` not
13762        // `FonteCaminhoTrailingSlash`. The embedded shell-history-
13763        // substitution byte is the more semantic-locating axis on probe-
13764        // as-both values (an author who removes the `^bad^good`
13765        // substitution fragment is likely to also tab-strip the trailing
13766        // separator).
13767        let d = dep_with_fonte(DepSource::Path {
13768            caminho: "../foo^bad^good/".into(),
13769        });
13770        let err = d.validate().unwrap_err();
13771        assert!(
13772            matches!(
13773                err,
13774                DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
13775            ),
13776            "got {err:?}",
13777        );
13778    }
13779
13780    #[test]
13781    fn fonte_caminho_shell_history_substitution_diagnostic_carries_offending_dep_caminho_and_byte()
13782    {
13783        // Diagnostic-shape pin (peer with
13784        // `fonte_caminho_shell_history_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
13785        // on the immediate-predecessor arm): the error's Display
13786        // surfaces the offending `:nome`, the offending `:caminho`
13787        // verbatim, the offending byte's hex form, and names the
13788        // shell-history-substitution / RFC-3986-'unwise' / regex-
13789        // negation footgun explicitly so a `feira lint` run can render
13790        // the diagnostic without re-parsing.
13791        let d = dep_with_fonte(DepSource::Path {
13792            caminho: "../foo^bad^good".into(),
13793        });
13794        let rendered = d.validate().unwrap_err().to_string();
13795        assert!(
13796            rendered.contains("caixa-teia"),
13797            "diagnostic must name the offending dep: {rendered}",
13798        );
13799        assert!(
13800            rendered.contains("../foo^bad^good"),
13801            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
13802        );
13803        assert!(
13804            rendered.contains("0x5e") || rendered.contains("0x5E"),
13805            "diagnostic must surface the offending byte hex: {rendered:?}",
13806        );
13807        assert!(
13808            rendered.contains("history-substitution") || rendered.contains("history substitution"),
13809            "diagnostic must name the shell-history-substitution footgun: {rendered:?}",
13810        );
13811        assert!(
13812            rendered.contains("unwise"),
13813            "diagnostic must reference the RFC-3986 'unwise' set vocabulary: {rendered:?}",
13814        );
13815    }
13816
13817    #[test]
13818    fn fonte_repo_empty_fires_before_pin_missing() {
13819        // Order pin: empty `:repo` is the more self-locating diagnostic
13820        // (every git source needs a repo; the pin discussion is
13821        // secondary), so it fires before the pin-missing arm even when
13822        // both are violated. Mirrors the
13823        // `nome_empty_takes_precedence_over_versao_invalid` ordering
13824        // discipline on the per-entry layer.
13825        let d = dep_with_fonte(DepSource::Git {
13826            repo: String::new(),
13827            tag: None,
13828            rev: None,
13829            branch: None,
13830        });
13831        let err = d.validate().unwrap_err();
13832        assert!(
13833            matches!(err, DepError::FonteRepoEmpty { .. }),
13834            "got {err:?}"
13835        );
13836    }
13837
13838    #[test]
13839    fn fonte_pin_missing_fires_before_pin_empty() {
13840        // Order pin: a fully-None pin set is structurally distinct from
13841        // a Some(empty) pin — the first surfaces as FontePinMissing
13842        // (no axis chosen), the second as FontePinEmpty (axis chosen
13843        // but value blank). Pin the disjoint relationship so a future
13844        // unification collapses to one variant only as a structural
13845        // decision.
13846        let d = dep_with_fonte(DepSource::Git {
13847            repo: "github:pleme-io/caixa-teia".into(),
13848            tag: None,
13849            rev: None,
13850            branch: None,
13851        });
13852        assert!(matches!(
13853            d.validate().unwrap_err(),
13854            DepError::FontePinMissing { .. }
13855        ));
13856    }
13857
13858    #[test]
13859    fn nome_empty_takes_precedence_over_fonte_invalid() {
13860        // Order pin: a per-entry diagnostic without a non-empty :nome
13861        // can't be self-locating, so :nome "" fires first even when
13862        // :fonte is also malformed. Mirrors
13863        // `nome_empty_takes_precedence_over_versao_invalid` on the
13864        // adjacent axis.
13865        let mut d = dep_with_fonte(DepSource::Git {
13866            repo: String::new(),
13867            tag: None,
13868            rev: None,
13869            branch: None,
13870        });
13871        d.nome = String::new();
13872        assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
13873    }
13874
13875    #[test]
13876    fn versao_invalid_takes_precedence_over_fonte_invalid() {
13877        // Order pin: the :versao parse-side diagnostic is narrower than
13878        // the :fonte shape diagnostic — a malformed :versao always names
13879        // the parser's reason, which is more actionable than the
13880        // :fonte gate's "the pins are wrong" wording. Pin the ordering
13881        // so a re-ordering surfaces here.
13882        let mut d = dep_with_fonte(DepSource::Git {
13883            repo: String::new(),
13884            tag: None,
13885            rev: None,
13886            branch: None,
13887        });
13888        d.versao = "v0.1".into();
13889        let err = d.validate().unwrap_err();
13890        assert!(
13891            matches!(err, DepError::VersaoInvalid { ref nome, .. } if nome == "caixa-teia"),
13892            "got {err:?}"
13893        );
13894    }
13895
13896    #[test]
13897    fn fonte_invalid_diagnostic_carries_offending_nome() {
13898        // The diagnostic-shape pin: every :fonte error variant names
13899        // the offending dep's :nome verbatim, so the author can grep
13900        // caixa.lisp for the `:nome "<n>"` block and fix it in one
13901        // edit. Cover all seven variants so a future variant addition
13902        // forces a parallel diagnostic-shape decision.
13903        for (case, fonte) in [
13904            (
13905                "repo-empty",
13906                DepSource::Git {
13907                    repo: String::new(),
13908                    tag: Some("v1".into()),
13909                    rev: None,
13910                    branch: None,
13911                },
13912            ),
13913            (
13914                "repo-shape",
13915                DepSource::Git {
13916                    repo: "github:p/x ".into(),
13917                    tag: Some("v1".into()),
13918                    rev: None,
13919                    branch: None,
13920                },
13921            ),
13922            (
13923                "pin-missing",
13924                DepSource::Git {
13925                    repo: "github:p/x".into(),
13926                    tag: None,
13927                    rev: None,
13928                    branch: None,
13929                },
13930            ),
13931            (
13932                "pin-ambiguous",
13933                DepSource::Git {
13934                    repo: "github:p/x".into(),
13935                    tag: Some("v1".into()),
13936                    rev: None,
13937                    branch: Some("main".into()),
13938                },
13939            ),
13940            (
13941                "pin-empty",
13942                DepSource::Git {
13943                    repo: "github:p/x".into(),
13944                    tag: Some(String::new()),
13945                    rev: None,
13946                    branch: None,
13947                },
13948            ),
13949            (
13950                "caminho-empty",
13951                DepSource::Path {
13952                    caminho: String::new(),
13953                },
13954            ),
13955            (
13956                "caminho-absolute",
13957                DepSource::Path {
13958                    caminho: "/home/me/work/caixa-teia".into(),
13959                },
13960            ),
13961        ] {
13962            let d = dep_with_fonte(fonte);
13963            let msg = d
13964                .validate()
13965                .expect_err(&format!("{case}: expected fonte error"))
13966                .to_string();
13967            assert!(
13968                msg.contains("\"caixa-teia\""),
13969                "{case}: diagnostic must quote the offending :nome verbatim, got {msg:?}"
13970            );
13971        }
13972    }
13973
13974    // -- :tag / :branch value-shape gate ----------------------------------
13975
13976    #[test]
13977    fn validate_rejects_git_fonte_with_tag_carrying_trailing_space() {
13978        // The canonical paste-from-doc footgun on `:tag` — author
13979        // copies `"v0.1.0 "` (trailing space) out of a release-notes
13980        // paragraph. Until this gate landed the empty-pin arm passed
13981        // (the string isn't empty), the resolver issued
13982        // `git fetch <remote> tag 'v0.1.0 '`, and the failure
13983        // surfaced at clone time with a quoting-confused git error
13984        // far from the source caixa.lisp. The new gate moves the
13985        // check to caixa-build time and names the offending dep +
13986        // pin + value verbatim.
13987        let d = dep_with_fonte(DepSource::Git {
13988            repo: "github:pleme-io/caixa-teia".into(),
13989            tag: Some("v0.1.0 ".into()),
13990            rev: None,
13991            branch: None,
13992        });
13993        let err = d.validate().unwrap_err();
13994        let DepError::FontePinShape {
13995            nome,
13996            pin,
13997            value,
13998            reason,
13999        } = err
14000        else {
14001            panic!("expected FontePinShape, got other variant");
14002        };
14003        assert_eq!(nome, "caixa-teia");
14004        assert_eq!(pin, ":tag");
14005        assert_eq!(value, "v0.1.0 ");
14006        assert!(
14007            reason.contains("whitespace"),
14008            "reason must surface the whitespace arm, got {reason:?}"
14009        );
14010    }
14011
14012    #[test]
14013    fn validate_rejects_git_fonte_with_tag_carrying_lock_suffix() {
14014        // The `.lock` suffix is git's atomic-rename guard for
14015        // in-flight ref updates — a refname ending in `.lock` is
14016        // unwritable on disk. Pinned separately from the whitespace
14017        // arm so a future relaxation that admits one but not the
14018        // other surfaces here.
14019        let d = dep_with_fonte(DepSource::Git {
14020            repo: "github:pleme-io/caixa-teia".into(),
14021            tag: Some("v0.1.0.lock".into()),
14022            rev: None,
14023            branch: None,
14024        });
14025        let err = d.validate().unwrap_err();
14026        let DepError::FontePinShape {
14027            pin, value, reason, ..
14028        } = err
14029        else {
14030            panic!("expected FontePinShape, got other variant");
14031        };
14032        assert_eq!(pin, ":tag");
14033        assert_eq!(value, "v0.1.0.lock");
14034        assert!(
14035            reason.contains(".lock"),
14036            "reason must surface the .lock arm, got {reason:?}"
14037        );
14038    }
14039
14040    #[test]
14041    fn validate_rejects_git_fonte_with_branch_carrying_embedded_space() {
14042        // The canonical "branch name with spaces" footgun (`feature
14043        // foo`, `release branch`) — git's refname parser rejects raw
14044        // whitespace, and the failure surfaces at `git checkout
14045        // 'feature foo'` time with a quoting-confused error far from
14046        // the source caixa.lisp. Pinned on the `:branch` axis so the
14047        // gate-applies-to-both-:tag-and-:branch contract is a build-
14048        // error to relax.
14049        let d = dep_with_fonte(DepSource::Git {
14050            repo: "github:pleme-io/caixa-teia".into(),
14051            tag: None,
14052            rev: None,
14053            branch: Some("feature/foo bar".into()),
14054        });
14055        let err = d.validate().unwrap_err();
14056        let DepError::FontePinShape {
14057            pin, value, reason, ..
14058        } = err
14059        else {
14060            panic!("expected FontePinShape, got other variant");
14061        };
14062        assert_eq!(pin, ":branch");
14063        assert_eq!(value, "feature/foo bar");
14064        assert!(
14065            reason.contains("whitespace"),
14066            "reason must surface the whitespace arm, got {reason:?}"
14067        );
14068    }
14069
14070    #[test]
14071    fn validate_rejects_git_fonte_with_branch_carrying_qualified_prefix() {
14072        // The `refs/heads/main` shape — the canonical "I copied the
14073        // fully-qualified ref out of `git show-ref` instead of the
14074        // leaf" footgun. The caixa-resolver prepends `refs/heads/`
14075        // at clone time, so this resolves to a literal ref named
14076        // `refs/heads/refs/heads/main` on disk; the silent double-
14077        // prefix is the load-bearing reason to gate at validate.
14078        // The diagnostic must enumerate the leaf the author probably
14079        // meant (`"main"`) so the fix is one edit.
14080        let d = dep_with_fonte(DepSource::Git {
14081            repo: "github:pleme-io/caixa-teia".into(),
14082            tag: None,
14083            rev: None,
14084            branch: Some("refs/heads/main".into()),
14085        });
14086        let err = d.validate().unwrap_err();
14087        let DepError::FontePinShape {
14088            pin, value, reason, ..
14089        } = err
14090        else {
14091            panic!("expected FontePinShape, got other variant");
14092        };
14093        assert_eq!(pin, ":branch");
14094        assert_eq!(value, "refs/heads/main");
14095        assert!(
14096            reason.contains("fully-qualified"),
14097            "reason must surface the qualified-prefix arm, got {reason:?}"
14098        );
14099        assert!(
14100            reason.contains("\"main\""),
14101            "reason must quote the leaf the author probably meant, got {reason:?}"
14102        );
14103    }
14104
14105    #[test]
14106    fn validate_rejects_git_fonte_with_tag_carrying_qualified_prefix() {
14107        // Sibling arm of the qualified-prefix gate on the `:tag`
14108        // axis (`refs/tags/v0.1.0` — same `git show-ref` output-leak
14109        // footgun). Pinned separately so a future relaxation that
14110        // only catches the `:branch` arm surfaces here.
14111        let d = dep_with_fonte(DepSource::Git {
14112            repo: "github:pleme-io/caixa-teia".into(),
14113            tag: Some("refs/tags/v0.1.0".into()),
14114            rev: None,
14115            branch: None,
14116        });
14117        let err = d.validate().unwrap_err();
14118        let DepError::FontePinShape {
14119            pin, value, reason, ..
14120        } = err
14121        else {
14122            panic!("expected FontePinShape, got other variant");
14123        };
14124        assert_eq!(pin, ":tag");
14125        assert_eq!(value, "refs/tags/v0.1.0");
14126        assert!(
14127            reason.contains("fully-qualified"),
14128            "reason must surface the qualified-prefix arm, got {reason:?}"
14129        );
14130        assert!(
14131            reason.contains("\"v0.1.0\""),
14132            "reason must quote the leaf the author probably meant, got {reason:?}"
14133        );
14134    }
14135
14136    #[test]
14137    fn validate_rejects_git_fonte_with_branch_named_at() {
14138        // The bare `@` is git's alias for `HEAD`; a `:branch "@"` is
14139        // unsourceable. Pinned so a future relaxation that admits
14140        // any single-character refname surfaces here.
14141        let d = dep_with_fonte(DepSource::Git {
14142            repo: "github:pleme-io/caixa-teia".into(),
14143            tag: None,
14144            rev: None,
14145            branch: Some("@".into()),
14146        });
14147        let err = d.validate().unwrap_err();
14148        let DepError::FontePinShape { pin, value, .. } = err else {
14149            panic!("expected FontePinShape, got other variant");
14150        };
14151        assert_eq!(pin, ":branch");
14152        assert_eq!(value, "@");
14153    }
14154
14155    #[test]
14156    fn validate_rejects_git_fonte_with_tag_carrying_double_dot() {
14157        // Git's `<rev1>..<rev2>` range grammar reserves `..` —
14158        // a `:tag "../escape"` (path-traversal-shaped slug) silently
14159        // passes parse and surfaces as a refname-parse error or, on
14160        // older git, a literal `../escape` checkout that escapes the
14161        // refs/ directory tree. Pinned separately from the
14162        // qualified-prefix arm so a future relaxation that catches
14163        // one but not the other surfaces here.
14164        let d = dep_with_fonte(DepSource::Git {
14165            repo: "github:pleme-io/caixa-teia".into(),
14166            tag: Some("../escape".into()),
14167            rev: None,
14168            branch: None,
14169        });
14170        let err = d.validate().unwrap_err();
14171        let DepError::FontePinShape { pin, value, .. } = err else {
14172            panic!("expected FontePinShape, got other variant");
14173        };
14174        assert_eq!(pin, ":tag");
14175        assert_eq!(value, "../escape");
14176    }
14177
14178    #[test]
14179    fn validate_accepts_git_fonte_with_hierarchical_branch() {
14180        // The positive-control pin: hierarchical refnames with one or
14181        // more `/` separators (the `feature/foo` / `user/jdoe/feat`
14182        // canonical idiom) round-trip through the gate. Pinned
14183        // separately from the leaf-`"main"` positive control so a
14184        // future tightening that rejects all multi-component refnames
14185        // surfaces here.
14186        let d = dep_with_fonte(DepSource::Git {
14187            repo: "github:pleme-io/caixa-teia".into(),
14188            tag: None,
14189            rev: None,
14190            branch: Some("feature/checkout-rewrite".into()),
14191        });
14192        d.validate().unwrap();
14193    }
14194
14195    #[test]
14196    fn validate_accepts_git_fonte_with_prerelease_tag() {
14197        // The positive-control pin: semver pre-release shape
14198        // (`v0.1.0-alpha.1`) — the in-component dot is allowed
14199        // (only consecutive `..` and trailing `.` are rejected), the
14200        // mid-component hyphen is allowed. Pinned separately from
14201        // the bare-`"v0.1.0"` positive control so a future tightening
14202        // that rejects pre-release tags surfaces here.
14203        let d = dep_with_fonte(DepSource::Git {
14204            repo: "github:pleme-io/caixa-teia".into(),
14205            tag: Some("v0.1.0-alpha.1".into()),
14206            rev: None,
14207            branch: None,
14208        });
14209        d.validate().unwrap();
14210    }
14211
14212    #[test]
14213    fn validate_rejects_git_fonte_with_rev_carrying_refname_unfriendly_value() {
14214        // The `:rev` axis is routed through `crate::render::is_git_oid`
14215        // (a SHA's character set is `[0-9a-f]`, not a refname's), so a
14216        // value with refname-shape punctuation (here, a `:` mid-string
14217        // — would be a refname violation under `is_git_ref_name` too)
14218        // is rejected at the OID-shape gate. The two predicates
14219        // partition the `:fonte` pin axes structurally: an `:rev` value
14220        // that's a valid refname (`:rev "main"`, `:rev "v0.1.0"`) is
14221        // *still* rejected here because every refname character outside
14222        // `[0-9a-f]` fails the OID gate. Same shape as
14223        // `fonte_pin_shape_diagnostic_carries_offending_nome_pin_value`
14224        // on the refname-shaped axes — the diagnostic names the
14225        // offending dep + pin + value verbatim. The flip-from-accept
14226        // case the prior `:tag`/`:branch` gate left as a "future axis"
14227        // (e70d213) — now landed.
14228        let d = dep_with_fonte(DepSource::Git {
14229            repo: "github:pleme-io/caixa-teia".into(),
14230            tag: None,
14231            rev: Some("c0ffee:notarefname".into()),
14232            branch: None,
14233        });
14234        let err = d.validate().unwrap_err();
14235        let DepError::FontePinShape {
14236            nome,
14237            pin,
14238            value,
14239            reason,
14240        } = err
14241        else {
14242            panic!("expected FontePinShape, got other variant");
14243        };
14244        assert_eq!(nome, "caixa-teia");
14245        assert_eq!(pin, ":rev");
14246        assert_eq!(value, "c0ffee:notarefname");
14247        assert!(
14248            !reason.is_empty(),
14249            "FontePinShape `reason` must carry the predicate's wording verbatim"
14250        );
14251    }
14252
14253    #[test]
14254    fn validate_accepts_git_fonte_with_rev_full_sha1() {
14255        // The positive-control pin on the SHA-1 OID width: exactly 40
14256        // lowercase hex characters — the canonical `git rev-parse HEAD`
14257        // emission on a SHA-1-hashed repository (the default on every
14258        // pre-2.42 git and the canonical pleme-io substrate hash).
14259        // Pinned separately from the SHA-256 positive control so a
14260        // future tightening that only admits one width surfaces here.
14261        let d = dep_with_fonte(DepSource::Git {
14262            repo: "github:pleme-io/caixa-teia".into(),
14263            tag: None,
14264            rev: Some("0123456789abcdef0123456789abcdef01234567".into()),
14265            branch: None,
14266        });
14267        d.validate().unwrap();
14268    }
14269
14270    #[test]
14271    fn validate_accepts_git_fonte_with_rev_full_sha256() {
14272        // The positive-control pin on the SHA-256 OID width: exactly
14273        // 64 lowercase hex characters — `git`'s
14274        // `extensions.objectFormat = sha256` emission (GA since Git
14275        // 2.42 / Oct 2023). The substrate admits either canonical
14276        // width so an `:rev` authored against a SHA-256-hashed
14277        // upstream round-trips through the gate without per-repo
14278        // configuration. Pinned separately from the SHA-1 positive
14279        // control so a future tightening that drops one width surfaces
14280        // here as a structural decision.
14281        let d = dep_with_fonte(DepSource::Git {
14282            repo: "github:pleme-io/caixa-teia".into(),
14283            tag: None,
14284            rev: Some("0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef".into()),
14285            branch: None,
14286        });
14287        d.validate().unwrap();
14288    }
14289
14290    #[test]
14291    fn validate_rejects_git_fonte_with_rev_abbreviated_prefix() {
14292        // The canonical `git log --short` / `git rev-parse --short HEAD`
14293        // paste-from-release-notes footgun: a 7-char prefix (git's
14294        // default `core.abbrev`) silently passes string emptiness
14295        // checks and resolves to one commit today, but becomes ambiguous
14296        // tomorrow as the repo grows. Until this gate landed the empty-
14297        // pin arm passed (the string isn't empty) and the resolver
14298        // accepted the prefix through git's separate prefix-lookup pass
14299        // — defeating the reproducibility contract `:rev` carries vs.
14300        // `:tag` / `:branch`. The new gate moves the check to caixa-
14301        // build time and names the offending dep + pin + value verbatim.
14302        let d = dep_with_fonte(DepSource::Git {
14303            repo: "github:pleme-io/caixa-teia".into(),
14304            tag: None,
14305            rev: Some("c0ffee0".into()),
14306            branch: None,
14307        });
14308        let err = d.validate().unwrap_err();
14309        let DepError::FontePinShape {
14310            pin, value, reason, ..
14311        } = err
14312        else {
14313            panic!("expected FontePinShape, got other variant");
14314        };
14315        assert_eq!(pin, ":rev");
14316        assert_eq!(value, "c0ffee0");
14317        assert!(
14318            reason.contains("abbreviated") || reason.contains("ambiguous"),
14319            "reason must surface the abbreviation arm, got {reason:?}"
14320        );
14321    }
14322
14323    #[test]
14324    fn validate_rejects_git_fonte_with_rev_uppercase_hex() {
14325        // The canonical "I pasted the SHA in uppercase" footgun: `git
14326        // porcelain` emits OIDs lowercase exclusively, so an uppercase-
14327        // bearing `:rev` round-trips inconsistently across the
14328        // resolver's `git fetch <remote> <:rev>` ↔ `git rev-parse HEAD`
14329        // equality-check pipeline and fails the lacre's content-
14330        // addressing probe with a confusing case-only diff. Pinned
14331        // separately from the non-hex arm so a future relaxation that
14332        // admits one but not the other surfaces here.
14333        let d = dep_with_fonte(DepSource::Git {
14334            repo: "github:pleme-io/caixa-teia".into(),
14335            tag: None,
14336            rev: Some("DEADBEEFCAFEBABE0123456789ABCDEF01234567".into()),
14337            branch: None,
14338        });
14339        let err = d.validate().unwrap_err();
14340        let DepError::FontePinShape {
14341            pin, value, reason, ..
14342        } = err
14343        else {
14344            panic!("expected FontePinShape, got other variant");
14345        };
14346        assert_eq!(pin, ":rev");
14347        assert_eq!(value, "DEADBEEFCAFEBABE0123456789ABCDEF01234567");
14348        assert!(
14349            reason.contains("uppercase"),
14350            "reason must surface the uppercase arm, got {reason:?}"
14351        );
14352    }
14353
14354    #[test]
14355    fn validate_rejects_git_fonte_with_rev_refname_value() {
14356        // The cross-axis mis-slot footgun: `:rev "main"` — the author
14357        // conflated `:rev` (hex commit ID, immutable) and `:branch`
14358        // (mutable ref pointing at whatever HEAD is today). Until this
14359        // gate landed the resolver silently dispatched on the value
14360        // shape ("`main` doesn't look like a SHA, fall back to
14361        // refname"), defeating the `:rev` reproducibility contract.
14362        // The new gate rejects every non-hex value on the `:rev` axis,
14363        // so the `:rev`/`:branch` boundary is structurally enforced —
14364        // a refname in the `:rev` slot is a build error, not a
14365        // resolver-time silent reinterpretation.
14366        let d = dep_with_fonte(DepSource::Git {
14367            repo: "github:pleme-io/caixa-teia".into(),
14368            tag: None,
14369            rev: Some("main".into()),
14370            branch: None,
14371        });
14372        let err = d.validate().unwrap_err();
14373        let DepError::FontePinShape {
14374            pin, value, reason, ..
14375        } = err
14376        else {
14377            panic!("expected FontePinShape, got other variant");
14378        };
14379        assert_eq!(pin, ":rev");
14380        assert_eq!(value, "main");
14381        // 4 chars `main` fails the length arm before the character arm,
14382        // so the diagnostic surfaces the abbreviation wording (same
14383        // path the `c0ffee0` 7-char fixture lands on); the structural
14384        // assertion is just that the `:rev "main"` value is rejected.
14385        assert!(
14386            !reason.is_empty(),
14387            "FontePinShape reason must be non-empty for refname-shaped :rev"
14388        );
14389    }
14390
14391    #[test]
14392    fn validate_rejects_git_fonte_with_rev_tag_shaped_value() {
14393        // Sibling cross-axis mis-slot: `:rev "v0.1.0"` — the author
14394        // conflated `:rev` and `:tag`. Pinned separately from the
14395        // `:rev "main"` (`:branch` mis-slot) arm so a future relaxation
14396        // that catches one but not the other surfaces here. The
14397        // length arm fires first (6 chars ≠ 40 ≠ 64); the structural
14398        // assertion is just that the cross-axis mis-slot is a build
14399        // error, regardless of which sub-arm surfaces the diagnostic
14400        // (`is_git_oid` rejects at the first violation; longer
14401        // tag-shape values would hit the non-hex arm instead).
14402        let d = dep_with_fonte(DepSource::Git {
14403            repo: "github:pleme-io/caixa-teia".into(),
14404            tag: None,
14405            rev: Some("v0.1.0".into()),
14406            branch: None,
14407        });
14408        let err = d.validate().unwrap_err();
14409        let DepError::FontePinShape {
14410            pin, value, reason, ..
14411        } = err
14412        else {
14413            panic!("expected FontePinShape, got other variant");
14414        };
14415        assert_eq!(pin, ":rev");
14416        assert_eq!(value, "v0.1.0");
14417        assert!(
14418            !reason.is_empty(),
14419            "FontePinShape reason must be non-empty for tag-shaped :rev"
14420        );
14421    }
14422
14423    #[test]
14424    fn validate_rejects_git_fonte_with_rev_too_long() {
14425        // Boundary case on the upper end: 41 hex chars — one past the
14426        // SHA-1 width, well below the SHA-256 width. Pin so a future
14427        // relaxation that admits "long enough to be a SHA" without
14428        // matching either canonical width surfaces here. The diagnostic
14429        // names the offending length verbatim so the author's grep
14430        // target is unambiguous (either trim one char or paste the
14431        // full SHA-256).
14432        let too_long: String = "0".repeat(41);
14433        let d = dep_with_fonte(DepSource::Git {
14434            repo: "github:pleme-io/caixa-teia".into(),
14435            tag: None,
14436            rev: Some(too_long.clone()),
14437            branch: None,
14438        });
14439        let err = d.validate().unwrap_err();
14440        let DepError::FontePinShape {
14441            pin, value, reason, ..
14442        } = err
14443        else {
14444            panic!("expected FontePinShape, got other variant");
14445        };
14446        assert_eq!(pin, ":rev");
14447        assert_eq!(value, too_long);
14448        assert!(
14449            reason.contains("41"),
14450            "reason must surface the offending length verbatim, got {reason:?}"
14451        );
14452    }
14453
14454    #[test]
14455    fn validate_rejects_git_fonte_with_rev_carrying_whitespace() {
14456        // The canonical paste-from-doc footgun on `:rev` — author
14457        // copies `"deadbeefcafe…0123 "` (trailing space) out of a
14458        // commit-message paragraph. Until this gate landed the empty-
14459        // pin arm passed (the string isn't empty), the resolver issued
14460        // `git fetch <remote> 'deadbeef… '` and the failure surfaced at
14461        // clone time with a quoting-confused git error far from the
14462        // source caixa.lisp. The new gate moves the check to caixa-
14463        // build time. Length is 41 (40 hex + space) so the length arm
14464        // fires first — pinned separately from the pure-length arm to
14465        // ensure the diagnostic surfaces *some* parser wording, not
14466        // silently pass through.
14467        let with_space = "0123456789abcdef0123456789abcdef01234567 ".to_string();
14468        let d = dep_with_fonte(DepSource::Git {
14469            repo: "github:pleme-io/caixa-teia".into(),
14470            tag: None,
14471            rev: Some(with_space.clone()),
14472            branch: None,
14473        });
14474        let err = d.validate().unwrap_err();
14475        let DepError::FontePinShape {
14476            pin, value, reason, ..
14477        } = err
14478        else {
14479            panic!("expected FontePinShape, got other variant");
14480        };
14481        assert_eq!(pin, ":rev");
14482        assert_eq!(value, with_space);
14483        assert!(
14484            !reason.is_empty(),
14485            "FontePinShape reason must be non-empty for whitespace-bearing :rev"
14486        );
14487    }
14488
14489    #[test]
14490    fn fonte_pin_shape_diagnostic_carries_offending_nome_pin_value_for_rev() {
14491        // Diagnostic-shape pin on the `:rev` axis: every FontePinShape
14492        // variant on this axis names the offending dep's `:nome` + the
14493        // `:rev` axis + the offending value verbatim, so the author's
14494        // grep target is the literal `:rev "<value>"` block in
14495        // caixa.lisp. Sibling of the `fonte_pin_shape_diagnostic_
14496        // carries_offending_nome_pin_value` test on the refname-shaped
14497        // (`:tag` / `:branch`) axes.
14498        let d = dep_with_fonte(DepSource::Git {
14499            repo: "github:p/x".into(),
14500            tag: None,
14501            rev: Some("not-a-sha".into()),
14502            branch: None,
14503        });
14504        let msg = d
14505            .validate()
14506            .expect_err(":rev: expected FontePinShape")
14507            .to_string();
14508        assert!(
14509            msg.contains("\"caixa-teia\""),
14510            ":rev: diagnostic must quote the offending :nome verbatim, got {msg:?}"
14511        );
14512        assert!(
14513            msg.contains(":rev"),
14514            ":rev: diagnostic must name the offending pin axis, got {msg:?}"
14515        );
14516        assert!(
14517            msg.contains("not-a-sha"),
14518            ":rev: diagnostic must quote the offending value verbatim, got {msg:?}"
14519        );
14520    }
14521
14522    #[test]
14523    fn fonte_pin_empty_fires_before_pin_shape() {
14524        // Order pin: a `Some("")` `:tag` is the more self-locating
14525        // diagnostic (the author chose an axis but left it blank;
14526        // grep is unambiguous), so it fires before the shape gate
14527        // even when both arms would match. Pinned so a future
14528        // reordering surfaces here. Mirrors the
14529        // `fonte_repo_empty_fires_before_pin_missing` ordering
14530        // discipline on the peer per-axis arms.
14531        let d = dep_with_fonte(DepSource::Git {
14532            repo: "github:pleme-io/caixa-teia".into(),
14533            tag: Some(String::new()),
14534            rev: None,
14535            branch: None,
14536        });
14537        assert!(matches!(
14538            d.validate().unwrap_err(),
14539            DepError::FontePinEmpty { ref pin, .. } if pin == ":tag"
14540        ));
14541    }
14542
14543    #[test]
14544    fn fonte_pin_shape_fires_after_repo_empty() {
14545        // Order pin: `:repo ""` is the more self-locating axis
14546        // (every git source needs a repo; the per-pin shape gate is
14547        // secondary), so the repo-empty arm fires before the
14548        // per-pin shape arm even when both are violated. Pinned so
14549        // a future reordering surfaces here. Mirrors
14550        // `fonte_repo_empty_fires_before_pin_missing` on the
14551        // adjacent axis pair.
14552        let d = dep_with_fonte(DepSource::Git {
14553            repo: String::new(),
14554            tag: Some("v0.1.0 ".into()),
14555            rev: None,
14556            branch: None,
14557        });
14558        assert!(matches!(
14559            d.validate().unwrap_err(),
14560            DepError::FonteRepoEmpty { .. }
14561        ));
14562    }
14563
14564    #[test]
14565    fn fonte_pin_shape_diagnostic_carries_offending_nome_pin_value() {
14566        // Diagnostic-shape pin across both refname-shaped axes
14567        // (`:tag` + `:branch`): every `FontePinShape` variant names
14568        // the offending dep's `:nome` + the offending pin axis + the
14569        // offending value verbatim, so the author's grep target is
14570        // unambiguous (the literal `:tag "<value>"` / `:branch
14571        // "<value>"` lands in caixa.lisp with quotes). Cover both
14572        // pin axes so a future variant addition forces a parallel
14573        // diagnostic-shape decision.
14574        for (pin_label, fonte) in [
14575            (
14576                ":tag",
14577                DepSource::Git {
14578                    repo: "github:p/x".into(),
14579                    tag: Some("v0.1.0~1".into()),
14580                    rev: None,
14581                    branch: None,
14582                },
14583            ),
14584            (
14585                ":branch",
14586                DepSource::Git {
14587                    repo: "github:p/x".into(),
14588                    tag: None,
14589                    rev: None,
14590                    branch: Some("feature/foo*".into()),
14591                },
14592            ),
14593        ] {
14594            let d = dep_with_fonte(fonte);
14595            let msg = d
14596                .validate()
14597                .expect_err(&format!("{pin_label}: expected FontePinShape"))
14598                .to_string();
14599            assert!(
14600                msg.contains("\"caixa-teia\""),
14601                "{pin_label}: diagnostic must quote the offending :nome verbatim, got {msg:?}"
14602            );
14603            assert!(
14604                msg.contains(pin_label),
14605                "{pin_label}: diagnostic must name the offending pin axis, got {msg:?}"
14606            );
14607        }
14608    }
14609
14610    #[test]
14611    fn git_source_json_round_trip() {
14612        let src = DepSource::Git {
14613            repo: "github:pleme-io/caixa-teia".into(),
14614            tag: Some("v0.1.0".into()),
14615            rev: None,
14616            branch: None,
14617        };
14618        let s = serde_json::to_string(&src).unwrap();
14619        assert!(s.contains(&format!(
14620            r#""{tipo}":"{git}""#,
14621            tipo = crate::render::DEP_SOURCE_KEY_TIPO,
14622            git = crate::render::DEP_SOURCE_TIPO_GIT,
14623        )));
14624        assert!(s.contains(r#""repo":"github:pleme-io/caixa-teia""#));
14625        assert!(s.contains(r#""tag":"v0.1.0""#));
14626        assert!(!s.contains("rev"));
14627        assert!(!s.contains("branch"));
14628        let round: DepSource = serde_json::from_str(&s).unwrap();
14629        assert_eq!(round, src);
14630    }
14631
14632    // ── DEP_SOURCE_{KEY_TIPO,TIPO_GIT,TIPO_PATH} drift-detection ────────
14633    //
14634    // The `#[serde(tag = "tipo", rename_all = "lowercase")]` derive
14635    // attribute on [`DepSource`] pins three load-bearing byte-sequences
14636    // that flow into every serialized `Dep.fonte` block: the outer
14637    // discriminator-key `"tipo"` the `tag = "tipo"` attribute names, and
14638    // the two admitted variant-tag values `"git"` / `"path"` the
14639    // `rename_all = "lowercase"` attribute pins as the discriminator's
14640    // closed-set arms. The three pin tests below round-trip a
14641    // fully-populated variant of each arm through
14642    // [`serde_json::to_value`] and assert each canonical byte-sequence
14643    // appears at its axis — pins a hypothetical future
14644    // `tag = "type"` / `tag = "source_type"` typo, a `rename_all`
14645    // rebrand (`"UPPERCASE"` / `"snake_case"` / `"kebab-case"`), or a
14646    // Rust-side variant rename (`Git` → `Repository`, `Path` → `Local`)
14647    // at build time rather than at fetch time when the resolver's
14648    // `Dep.fonte` dispatch silently fails to match on the drifted
14649    // discriminator. Same "serialize-and-check" discipline the peer
14650    // `M2_LIMITS_KEY_*`, `M2_BEHAVIOR_KEY_ON_*`, `SUPERVISOR_KEY_*`,
14651    // and `MEMBRO_KEY_*` drift-detection pins carry — extended here
14652    // to the last `#[serde(tag = ..., rename_all = ...)]` discriminator
14653    // family in caixa-core lacking a lifted peer.
14654
14655    #[test]
14656    fn dep_source_git_serde_keys_match_lifted_dep_source_key_consts() {
14657        // Fail-before-pass-after: a future `tag = "type"` at the derive
14658        // attribute would serialize under `"type":"git"`, and this test
14659        // would trip because `"tipo"` no longer appears at the emitted
14660        // discriminator key. A future `rename_all = "kebab-case"` /
14661        // `"snake_case"` (both no-ops on `Git` since it lacks internal
14662        // word boundaries) is caught by the sibling
14663        // `dep_source_path_serde_keys_match_lifted_dep_source_key_consts`
14664        // pin below (Path has no internal boundary either but the pair
14665        // catches any per-arm inconsistency). A future variant rename
14666        // `Git` → `Repository` would emit `"tipo":"repository"` and
14667        // trip this pin.
14668        let src = DepSource::Git {
14669            repo: "github:pleme-io/caixa-teia".into(),
14670            tag: Some("v0.1.0".into()),
14671            rev: None,
14672            branch: None,
14673        };
14674        let json = serde_json::to_value(&src).unwrap();
14675        let obj = json.as_object().expect("Git serializes as a JSON object");
14676        assert_eq!(
14677            obj.get(crate::render::DEP_SOURCE_KEY_TIPO)
14678                .and_then(serde_json::Value::as_str),
14679            Some(crate::render::DEP_SOURCE_TIPO_GIT),
14680            "DepSource::Git must serialize the tipo discriminator at DEP_SOURCE_KEY_TIPO \
14681             with value DEP_SOURCE_TIPO_GIT — attribute drift or variant rename \
14682             detected in {json}"
14683        );
14684    }
14685
14686    #[test]
14687    fn dep_source_path_serde_keys_match_lifted_dep_source_key_consts() {
14688        // Fail-before-pass-after: a future variant rename `Path` →
14689        // `Local` / `Filesystem` would emit `"tipo":"local"` and trip
14690        // this pin. A per-consumer disambiguation as the `defcaixa`
14691        // macro stabilizes ("caminho" → "path" for English-uniformity)
14692        // is scoped to the inner field key, not the discriminator; this
14693        // pin is orthogonal to that and catches only the outer
14694        // discriminator drift.
14695        let src = DepSource::Path {
14696            caminho: "../caixa-teia".into(),
14697        };
14698        let json = serde_json::to_value(&src).unwrap();
14699        let obj = json.as_object().expect("Path serializes as a JSON object");
14700        assert_eq!(
14701            obj.get(crate::render::DEP_SOURCE_KEY_TIPO)
14702                .and_then(serde_json::Value::as_str),
14703            Some(crate::render::DEP_SOURCE_TIPO_PATH),
14704            "DepSource::Path must serialize the tipo discriminator at DEP_SOURCE_KEY_TIPO \
14705             with value DEP_SOURCE_TIPO_PATH — attribute drift or variant rename \
14706             detected in {json}"
14707        );
14708    }
14709
14710    #[test]
14711    fn dep_source_key_consts_are_pairwise_distinct() {
14712        // Cross-axis collapse detector: a hypothetical future edit that
14713        // accidentally set two of the three consts to the same byte
14714        // (`DEP_SOURCE_TIPO_GIT = "path"` typo matching a peer arm) would
14715        // pass every per-arm serialize pin above but silently collapse
14716        // the discriminator's closed-set arms onto one another; this pin
14717        // catches the collapse at build time.
14718        assert_ne!(
14719            crate::render::DEP_SOURCE_KEY_TIPO,
14720            crate::render::DEP_SOURCE_TIPO_GIT,
14721        );
14722        assert_ne!(
14723            crate::render::DEP_SOURCE_KEY_TIPO,
14724            crate::render::DEP_SOURCE_TIPO_PATH,
14725        );
14726        assert_ne!(
14727            crate::render::DEP_SOURCE_TIPO_GIT,
14728            crate::render::DEP_SOURCE_TIPO_PATH,
14729        );
14730    }
14731
14732    #[test]
14733    fn dep_source_tipo_variant_consts_are_ascii_lowercase_shape() {
14734        // Shape pin against `rename_all` drift: the two variant-tag
14735        // consts must be ASCII-lowercase-only to match the
14736        // `rename_all = "lowercase"` attribute the derive uses; a future
14737        // rebrand to `"UPPERCASE"` / `"PascalCase"` at the attribute
14738        // would emit `"GIT"` / `"Git"` instead and trip this pin.
14739        for (label, s) in [
14740            ("DEP_SOURCE_TIPO_GIT", crate::render::DEP_SOURCE_TIPO_GIT),
14741            ("DEP_SOURCE_TIPO_PATH", crate::render::DEP_SOURCE_TIPO_PATH),
14742        ] {
14743            assert!(!s.is_empty(), "{label} must not be empty");
14744            assert!(
14745                s.bytes().all(|b| b.is_ascii_lowercase()),
14746                "{label} must be ASCII-lowercase-only (matching \
14747                 rename_all = \"lowercase\"), got {s:?}",
14748            );
14749        }
14750    }
14751
14752    // ── per-entry :caracteristicas set-not-multiset gate ────────────
14753    //
14754    // Every Vec-keyed-by-name authoring surface on the typed Caixa
14755    // surface that identifies its entries by a name field now uniformly
14756    // closes the set-not-multiset discipline at build time (cite
14757    // `validate_caracteristicas`'s peer-axis enumeration). The
14758    // `:caracteristicas` axis is per-`Dep`: the feature-toggle slot is
14759    // set-shaped (a feature is either enabled or not — there is no
14760    // `feature × 2` semantic), so two entries naming the same feature
14761    // are a redundant declaration the caixa-resolver's lacre pipeline
14762    // would silently dedup at resolve time. The empty-feature arm
14763    // closes the parallel "operationally-meaningless value" axis on
14764    // the same slot. Same linear-walk + `HashSet` + first-collision
14765    // shape every peer set gate uses; same empty-first cascade every
14766    // peer per-entry shape + duplicate gate uses (the empty-feature
14767    // axis is the more-actionable defect since two `""` entries would
14768    // both report `caracteristica: ""` under a duplicate-first
14769    // ordering, with no way to distinguish the offending site).
14770
14771    fn dep_with_features(features: &[&str]) -> Dep {
14772        Dep {
14773            nome: "caixa-teia".into(),
14774            versao: "^0.1".into(),
14775            fonte: None,
14776            opcional: false,
14777            caracteristicas: features.iter().map(|s| (*s).into()).collect(),
14778        }
14779    }
14780
14781    #[test]
14782    fn validate_rejects_empty_caracteristica() {
14783        // Fail-before-pass-after pin: every pre-gate codebase accepted
14784        // `(:caracteristicas (""))` cleanly (the `Vec<String>` field
14785        // imposed no per-entry shape contract), the dep validated, and
14786        // the empty feature would have reached the future caixa-resolver
14787        // lacre pipeline as a no-op feature enable — silently dropping
14788        // the author's intent far from the source `caixa.lisp`. The new
14789        // gate surfaces the structural defect at the typed-validate
14790        // surface with a self-locating diagnostic naming the offending
14791        // dep's `:nome`.
14792        let d = dep_with_features(&[""]);
14793        assert!(
14794            matches!(d.validate().unwrap_err(), DepError::CaracteristicaEmpty { ref nome } if nome == "caixa-teia"),
14795            "expected CaracteristicaEmpty, got {:?}",
14796            d.validate(),
14797        );
14798    }
14799
14800    #[test]
14801    fn validate_rejects_duplicate_caracteristica() {
14802        // Fail-before-pass-after pin on the set-not-multiset arm: the
14803        // feature-toggle slot is set-shaped, so `(:caracteristicas
14804        // ("http" "http"))` is a redundant declaration the lacre
14805        // pipeline dedupes silently at resolve time. The diagnostic
14806        // names the offending dep + the colliding feature verbatim so
14807        // the author can grep their caixa.lisp for `:caracteristicas`
14808        // and fix it in one edit. First-collision determinism is
14809        // pinned separately below.
14810        let d = dep_with_features(&["http", "http"]);
14811        assert!(
14812            matches!(
14813                d.validate().unwrap_err(),
14814                DepError::CaracteristicaDuplicate { ref nome, ref caracteristica }
14815                    if nome == "caixa-teia" && caracteristica == "http"
14816            ),
14817            "expected CaracteristicaDuplicate, got {:?}",
14818            d.validate(),
14819        );
14820    }
14821
14822    #[test]
14823    fn validate_accepts_distinct_caracteristicas() {
14824        // The canonical authoring shape — every feature distinct — must
14825        // remain a clean pass (positive control sweep). Covers the
14826        // canonical kebab-case feature names a target caixa typically
14827        // declares.
14828        dep_with_features(&["http", "json", "tls"])
14829            .validate()
14830            .unwrap();
14831    }
14832
14833    #[test]
14834    fn validate_accepts_single_caracteristica() {
14835        // Single-element list is the minimum non-empty shape; passes
14836        // the gate as the identity of the duplicate check (no second
14837        // entry to collide with).
14838        dep_with_features(&["http"]).validate().unwrap();
14839    }
14840
14841    #[test]
14842    fn validate_accepts_empty_caracteristicas_list() {
14843        // The bare-dep authoring shape (`Dep::simple` / `Dep::git`)
14844        // produces `caracteristicas: Vec::new()`; the empty list is
14845        // the gate's empty-set identity and passes vacuously. Pin
14846        // this so a future tightening that requires ≥1 feature
14847        // surfaces here as a test failure rather than a silent
14848        // contract narrowing.
14849        Dep::simple("caixa-teia", "^0.1").validate().unwrap();
14850        assert!(dep_with_features(&[]).validate().is_ok());
14851    }
14852
14853    #[test]
14854    fn validate_caracteristica_empty_fires_before_duplicate() {
14855        // Empty-first cascade: an entry with an empty feature *and*
14856        // duplicate entries surfaces the empty diagnostic first. The
14857        // empty-feature axis is the more-actionable defect since
14858        // `caracteristica: ""` is unambiguous; under duplicate-first
14859        // ordering the diagnostic could report the empty string from
14860        // either of two empty entries with no way to distinguish.
14861        // Mirrors the peer empty-before-duplicate ordering
14862        // discipline every per-entry shape + duplicate gate establishes
14863        // (`SupervisorSpec::validate`'s `EmptyChildName` arm before
14864        // `DuplicateChildCaixa`, `validate_membros`'s
14865        // `MembroCaixaEmpty` arm before `MembroDuplicate`).
14866        let d = dep_with_features(&["", "http", "http"]);
14867        assert!(matches!(
14868            d.validate().unwrap_err(),
14869            DepError::CaracteristicaEmpty { .. }
14870        ));
14871    }
14872
14873    #[test]
14874    fn validate_caracteristica_duplicate_first_collision_determinism() {
14875        // Three matching entries: the second occurrence surfaces the
14876        // diagnostic (the second is the first *collision* — the first
14877        // entry is the establishing one, not a duplicate). Mirrors
14878        // every peer first-collision posture
14879        // (`SupervisorError::DuplicateChildCaixa` reports the second
14880        // collision, `AplicacaoError::MembroDuplicate` reports the
14881        // second, `DepError::DuplicateNome` reports the second).
14882        // Pinning this so a future shortcut that flips to last-
14883        // collision (or non-deterministic) surfaces here.
14884        let d = dep_with_features(&["http", "http", "http"]);
14885        assert!(matches!(
14886            d.validate().unwrap_err(),
14887            DepError::CaracteristicaDuplicate { ref caracteristica, .. } if caracteristica == "http"
14888        ));
14889    }
14890
14891    #[test]
14892    fn validate_per_entry_shape_fires_before_caracteristicas() {
14893        // Per-entry shape precedence: a dep with a malformed `:nome`
14894        // (uppercase) AND duplicate `:caracteristicas` surfaces the
14895        // narrower `NomeInvalid` diagnostic first, not the set-gate
14896        // diagnostic. The `:nome` is the self-locating axis (every
14897        // diagnostic from the caracteristicas gate quotes the
14898        // offending dep's `:nome` to anchor the grep target —
14899        // surfacing the malformed name first keeps that anchor
14900        // valid). Same precedence shape every peer per-entry-shape
14901        // arm establishes against its peer set-gate
14902        // (`validate_deps_per_entry_validate_fires_before_duplicate_in_deps`
14903        // on the cross-entry `:nome` axis).
14904        let d = Dep {
14905            nome: "Caixa-Teia".into(), // uppercase — DNS-1123 violation
14906            versao: "^0.1".into(),
14907            fonte: None,
14908            opcional: false,
14909            caracteristicas: vec!["http".into(), "http".into()],
14910        };
14911        assert!(matches!(
14912            d.validate().unwrap_err(),
14913            DepError::NomeInvalid { .. }
14914        ));
14915    }
14916
14917    // ── per-entry :caracteristicas value-shape gate ──────────────────
14918    //
14919    // Until this gate landed `:caracteristicas` only refused the empty
14920    // string and cross-entry duplicates: a non-empty distinct but
14921    // structurally invalid feature name silently passed validate and the
14922    // failure surfaced at `cargo metadata` time as Cargo's
14923    // `restricted_names::validate_feature_name` parser rejection, far from
14924    // the source `caixa.lisp` with no field naming which `:deps` entry's
14925    // `:caracteristicas` carried the typo. The lifted predicate makes the
14926    // Cargo-feature-name-grammar intersection-floor a substrate-level
14927    // invariant at validate time. Same trajectory as the eight peer
14928    // value-shape predicates each typed surface downstream of a structured
14929    // grammar already follows.
14930
14931    #[test]
14932    fn validate_rejects_caracteristica_with_leading_plus() {
14933        // Fail-before-pass-after pin on the canonical Cargo
14934        // `+<feature>` activation-form-in-feature-name-slot footgun.
14935        // Cargo's `[dependencies.<dep>.features]` list grammar accepts
14936        // `+optional-feature` as an enablement of a previously-disabled
14937        // feature; pasting that activation form into `:caracteristicas`
14938        // (which names the feature itself) silently passed pre-gate and
14939        // failed at `cargo metadata` parse time.
14940        let d = dep_with_features(&["+http"]);
14941        let err = d.validate().unwrap_err();
14942        assert!(
14943            matches!(
14944                err,
14945                DepError::CaracteristicaInvalid { ref nome, ref caracteristica, .. }
14946                    if nome == "caixa-teia" && caracteristica == "+http"
14947            ),
14948            "expected CaracteristicaInvalid, got {err:?}"
14949        );
14950    }
14951
14952    #[test]
14953    fn validate_rejects_caracteristica_with_leading_hyphen() {
14954        // Fail-before-pass-after pin on the leading-hyphen footgun. `-`
14955        // is a legitimate continuation character (kebab-case feature
14956        // names like `runtime-tokio` pass) but Cargo rejects it at the
14957        // start; the structural defect — and its CLI-argument-injection
14958        // adjacency at any downstream Cargo subprocess invocation — is
14959        // closed at validate time, not at `cargo metadata` time.
14960        let d = dep_with_features(&["-json"]);
14961        let err = d.validate().unwrap_err();
14962        assert!(
14963            matches!(
14964                err,
14965                DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "-json"
14966            ),
14967            "expected CaracteristicaInvalid, got {err:?}"
14968        );
14969    }
14970
14971    #[test]
14972    fn validate_rejects_caracteristica_with_leading_dot() {
14973        // Fail-before-pass-after pin on the leading-dot footgun. `.` is
14974        // a legitimate continuation character (version-suffix shapes
14975        // like `feat.v2` pass) but the leading-dot form is the
14976        // canonical dotted-version-suffix-as-feature-name confusion.
14977        let d = dep_with_features(&[".feat"]);
14978        let err = d.validate().unwrap_err();
14979        assert!(matches!(
14980            err,
14981            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == ".feat"
14982        ));
14983    }
14984
14985    #[test]
14986    fn validate_rejects_caracteristica_with_whitespace() {
14987        // Fail-before-pass-after pin on the embedded-whitespace footgun:
14988        // a feature name with a space inside is structurally a multi-
14989        // token blob (the canonical paste-from-doc footgun, or an
14990        // accidental `"http server"` where the author meant
14991        // `"http-server"`).
14992        let d = dep_with_features(&["http feature"]);
14993        let err = d.validate().unwrap_err();
14994        assert!(matches!(
14995            err,
14996            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http feature"
14997        ));
14998    }
14999
15000    #[test]
15001    fn validate_rejects_caracteristica_with_comma() {
15002        // Fail-before-pass-after pin on the embedded-comma footgun:
15003        // the list-separator-belongs-to-the-list-grammar
15004        // miscomprehension where the author writes
15005        // `:caracteristicas ("http,json")` intending two features but
15006        // the `Vec<String>` field consumes the bare token as one entry.
15007        let d = dep_with_features(&["http,json"]);
15008        let err = d.validate().unwrap_err();
15009        assert!(matches!(
15010            err,
15011            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http,json"
15012        ));
15013    }
15014
15015    #[test]
15016    fn validate_rejects_caracteristica_with_slash() {
15017        // Fail-before-pass-after pin on the embedded-slash footgun:
15018        // Cargo's `dep/feat` namespaced-dep syntax applies inside
15019        // `[dependencies.<dep>.features]` list entries that already
15020        // name the parent dep (so the syntax says "enable feature
15021        // `feat` on a transitive dep `dep`"); `:caracteristicas` is
15022        // per-dep already (a sibling slot on the `Dep` itself), so the
15023        // segment separator within an entry must be `-`, `_`, `+`,
15024        // or `.`. The diagnostic remediation points at the canonical
15025        // Cargo namespaced-dep discipline.
15026        let d = dep_with_features(&["http/json"]);
15027        let err = d.validate().unwrap_err();
15028        assert!(matches!(
15029            err,
15030            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http/json"
15031        ));
15032    }
15033
15034    #[test]
15035    fn validate_rejects_caracteristica_with_non_ascii() {
15036        // Fail-before-pass-after pin on the un-percent-encoded non-ASCII
15037        // byte footgun: NFC-vs-NFD normalization across filesystems
15038        // silently rewrites the feature-key, breaking the lacre's
15039        // content-addressing invariant. Pinned at a canonical
15040        // smart-quote-paste shape (`café`) where the raw `é` byte is the
15041        // documented APFS round-trip break.
15042        let d = dep_with_features(&["caf\u{e9}"]);
15043        let err = d.validate().unwrap_err();
15044        assert!(matches!(
15045            err,
15046            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "caf\u{e9}"
15047        ));
15048    }
15049
15050    #[test]
15051    fn validate_rejects_caracteristica_with_control_character() {
15052        // Fail-before-pass-after pin on the embedded-control-character
15053        // footgun: a CR/LF or any 0x00..0x1F / 0x7F byte landing in a
15054        // feature name is the canonical paste-from-multiline-doc
15055        // footgun the predicate's reason wording specifically calls out.
15056        let d = dep_with_features(&["http\njson"]);
15057        let err = d.validate().unwrap_err();
15058        assert!(matches!(err, DepError::CaracteristicaInvalid { .. }));
15059    }
15060
15061    #[test]
15062    fn validate_accepts_canonical_caracteristicas_shapes() {
15063        // Positive control sweep: every canonical Cargo feature name
15064        // shape the pleme-io ecosystem uses must still pass. Mirrors
15065        // the substrate-side `cargo_feature_name_accepts_canonical_forms`
15066        // sweep — drift between either landing site and the predicate's
15067        // accepted set is a build error visible at this pair of tests,
15068        // not a per-renderer "this passed validate but failed at
15069        // cargo metadata time" surprise on the next acceptance.
15070        for s in [
15071            "http",
15072            "json",
15073            "derive",
15074            "serde_json",
15075            "runtime-tokio",
15076            "tokio.full",
15077            "v0.1",
15078            "http+json",
15079            "_internal",
15080            "__private",
15081            "default",
15082            "rt-multi-thread",
15083            "feat.v2",
15084        ] {
15085            let d = dep_with_features(&[s]);
15086            d.validate().unwrap_or_else(|e| {
15087                panic!("canonical Cargo feature name {s:?} must pass validate: {e:?}")
15088            });
15089        }
15090    }
15091
15092    #[test]
15093    fn validate_caracteristica_empty_fires_before_invalid() {
15094        // Cascade precedence pin: an entry list with both an empty
15095        // feature AND an invalid-shape feature surfaces the
15096        // `CaracteristicaEmpty` arm first (the empty value carries no
15097        // self-locating data — `caracteristica: ""` is the diagnostic
15098        // with no way to anchor a grep target — so closing the empty
15099        // axis first preserves the per-entry-shape diagnostic's
15100        // self-locating discipline). Same empty-first cascade every
15101        // peer per-entry shape gate establishes
15102        // (`SupervisorSpec::validate`'s `EmptyChildName` before
15103        // `ChildCaixaInvalid`, `validate_membros`'s `MembroCaixaEmpty`
15104        // before `MembroCaixaInvalid`).
15105        let d = dep_with_features(&["", "+http"]);
15106        assert!(matches!(
15107            d.validate().unwrap_err(),
15108            DepError::CaracteristicaEmpty { .. }
15109        ));
15110    }
15111
15112    #[test]
15113    fn validate_caracteristica_invalid_fires_before_duplicate() {
15114        // Per-entry-shape precedence pin: an entry list with the same
15115        // invalid feature shape declared twice surfaces the
15116        // `CaracteristicaInvalid` diagnostic on the first entry, not
15117        // the `CaracteristicaDuplicate` on the second collision. The
15118        // per-entry shape gate fires before the cross-entry set gate
15119        // — same precedence shape every peer two-arm-plus-set gate
15120        // establishes (`SupervisorSpec::validate`'s
15121        // `ChildCaixaInvalid` before `DuplicateChildCaixa`,
15122        // `validate_membros`'s `MembroCaixaInvalid` before
15123        // `MembroDuplicate`, `Dep::validate`'s `NomeInvalid` before
15124        // cross-list `DuplicateNome`).
15125        let d = dep_with_features(&["+http", "+http"]);
15126        assert!(matches!(
15127            d.validate().unwrap_err(),
15128            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "+http"
15129        ));
15130    }
15131
15132    #[test]
15133    fn validate_rejects_caracteristica_at_65_byte_boundary() {
15134        // Boundary pin on the 64-byte cap — both the boundary-accepting
15135        // case and the boundary-exceeding case in one place, so a
15136        // future cap shift surfaces both arms simultaneously, mirroring
15137        // the peer `cargo_feature_name_rejects_at_65_byte_boundary`
15138        // predicate-level pin at the dep-axis landing site.
15139        let max_ok = "a".repeat(64);
15140        dep_with_features(&[&max_ok])
15141            .validate()
15142            .unwrap_or_else(|e| panic!("64-byte feature name must pass: {e:?}"));
15143        let too_long = "a".repeat(65);
15144        let d = dep_with_features(&[&too_long]);
15145        assert!(matches!(
15146            d.validate().unwrap_err(),
15147            DepError::CaracteristicaInvalid { .. }
15148        ));
15149    }
15150
15151    // ── self-dep cross-slot gate ─────────────────────────────────────
15152
15153    #[test]
15154    fn validate_no_self_dep_rejects_self_in_deps() {
15155        // A caixa whose `:deps` lists its own `:nome` is a one-node
15156        // cycle in the lacre closure's dep-graph traversal — rejected,
15157        // naming the parent and the offending list tag.
15158        let deps = vec![
15159            Dep::simple("caixa-teia", "^0.1"),
15160            Dep::simple("orquestra", "^0.1"),
15161        ];
15162        let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
15163        assert!(
15164            matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS),
15165            "got {err:?}"
15166        );
15167    }
15168
15169    #[test]
15170    fn validate_no_self_dep_rejects_self_in_deps_dev() {
15171        // Same gate on the `:deps-dev` axis — neither dep list is a
15172        // second-class citizen on the self-edge invariant.
15173        let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
15174        let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
15175        assert!(
15176            matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
15177            "got {err:?}"
15178        );
15179    }
15180
15181    #[test]
15182    fn validate_no_self_dep_deps_fires_before_deps_dev() {
15183        // Walk order pin: a caixa that self-references on both lists
15184        // surfaces the `:deps` arm first — the load-bearing axis the
15185        // lacre closure resolves at every build. Mirrors the canonical
15186        // [`Caixa::validate_deps`] cascade (`:deps` → `:deps-dev`).
15187        let deps = vec![Dep::simple("orquestra", "^0.1")];
15188        let deps_dev = vec![Dep::simple("orquestra", "^0.2")];
15189        let err = validate_no_self_dep(&deps, &deps_dev, "orquestra").unwrap_err();
15190        assert!(
15191            matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS),
15192            "got {err:?}"
15193        );
15194    }
15195
15196    #[test]
15197    fn validate_no_self_dep_accepts_distinct_names() {
15198        // Positive control: every dep names a distinct caixa. The
15199        // canonical author surface — peer of
15200        // [`validate_no_self_supervision_accepts_distinct_children`].
15201        let deps = vec![
15202            Dep::simple("caixa-teia", "^0.1"),
15203            Dep::simple("caixa-arch", "^0.1"),
15204        ];
15205        let deps_dev = vec![Dep::simple("caixa-test", "^0.1")];
15206        validate_no_self_dep(&deps, &deps_dev, "orquestra").unwrap();
15207    }
15208
15209    #[test]
15210    fn validate_no_self_dep_empty_lists_pass() {
15211        // A caixa with no declared deps has nothing to self-reference —
15212        // the gate is vacuously satisfied. Peer of
15213        // [`validate_no_self_supervision_empty_children_is_ok`].
15214        validate_no_self_dep(&[], &[], "orquestra").unwrap();
15215    }
15216
15217    #[test]
15218    fn validate_no_self_dep_diagnostic_carries_offending_list_and_nome() {
15219        // Diagnostic-shape pin (peer with
15220        // [`validate_no_self_supervision`]'s diagnostic): the error's
15221        // Display surfaces both the offending list tag and the
15222        // parent's `:nome` verbatim, so the author can grep their
15223        // caixa.lisp for the offending block in one edit. Names
15224        // `:bibliotecas` / `:exe` / `:servicos` as the corrective
15225        // surface — every legitimate "I want to use code from this
15226        // caixa" intent routes through one of those three slots.
15227        let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
15228        let rendered = validate_no_self_dep(&[], &deps_dev, "orquestra")
15229            .unwrap_err()
15230            .to_string();
15231        assert!(
15232            rendered.contains(crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
15233            "diagnostic must name the offending list tag: {rendered}",
15234        );
15235        assert!(
15236            rendered.contains("orquestra"),
15237            "diagnostic must quote the parent caixa name: {rendered}",
15238        );
15239        assert!(
15240            rendered.contains(":bibliotecas"),
15241            "diagnostic must point at the corrective code-surface slot: {rendered}",
15242        );
15243    }
15244
15245    #[test]
15246    fn validate_no_self_dep_accepts_coincidental_substring_match() {
15247        // Identity is exact-string equality, not substring — a dep
15248        // named `"orquestra-helper"` is a distinct caixa even when the
15249        // parent is `"orquestra"`. Pin the exact-match discipline so a
15250        // future relaxation that uses `contains` surfaces here, peer
15251        // with the supervision-tree and Aplicacao-membership gates
15252        // which all use exact-string equality on the typed identity.
15253        let deps = vec![Dep::simple("orquestra-helper", "^0.1")];
15254        validate_no_self_dep(&deps, &[], "orquestra").unwrap();
15255    }
15256
15257    // ── drift-detection: DEP_AUTHOR_KEY_{DEPS,DEPS_DEV} pin ─────────────
15258
15259    #[test]
15260    fn dep_author_key_consts_pin_canonical_kebab_case_labels() {
15261        // Scalar-value pin: the two author-facing kebab-case labels the
15262        // `(defcaixa … :deps ((…)) :deps-dev ((…)))` surface admits on
15263        // the two-list dep-graph slot axis, one arm per typed slot.
15264        // Mirrors the peer scalar-value pin the sibling
15265        // [`crate::M2_AUTHOR_KEY_LIMITS`] /
15266        // [`crate::M2_AUTHOR_KEY_BEHAVIOR`] /
15267        // [`crate::M2_AUTHOR_KEY_UPGRADE_FROM`] (f49c8b0) M2 top-level
15268        // author-labels, [`crate::M3_AUTHOR_KEY_MEMBROS`] etc.
15269        // (882f498) M3 top-level author-labels, and
15270        // [`crate::SUPERVISOR_AUTHOR_KEY_ESTRATEGIA`] etc. (be40492)
15271        // Supervisor top-level author-labels carry, so every kind-scoped
15272        // typed-slot-family axis routes through one canonical per-arm
15273        // declaration.
15274        //
15275        // A future rebrand (`:deps` → `:dependencies` matching Cargo's
15276        // verbatim key, `:deps-dev` → `:dev-dependencies` matching the
15277        // same, `:deps` / `:deps-dev` → `:runtime-deps` / `:dev-deps`
15278        // for symmetry) lands as an edit to exactly one const, and
15279        // every consumer that reaches for the label picks it up at
15280        // build time rather than at runtime as a downstream mismatch on
15281        // a `DepError::DuplicateNome { list: … }` diagnostic far from
15282        // the rename's commit.
15283        assert_eq!(crate::render::DEP_AUTHOR_KEY_DEPS, ":deps");
15284        assert_eq!(crate::render::DEP_AUTHOR_KEY_DEPS_DEV, ":deps-dev");
15285    }
15286
15287    #[test]
15288    fn dep_author_key_consts_are_pairwise_distinct() {
15289        // Distinct-labels pin: the two `:deps` / `:deps-dev` labels
15290        // must not collapse onto one byte-string. A future copy-paste
15291        // slip that renamed both consts to the same value (or a rebrand
15292        // that dropped the `-dev` suffix from one but not the other)
15293        // would leave every `DepError::DuplicateNome { list: … }`
15294        // diagnostic naming an unattributable list — the linter would
15295        // route the author to the wrong caixa.lisp block, or the
15296        // cross-list precedence gate
15297        // (`validate_deps_duplicate_in_deps_fires_before_duplicate_in_deps_dev`)
15298        // would surface a `:deps`-tagged diagnostic on a `:deps-dev`
15299        // duplicate. Peer of the sibling
15300        // `m2_author_key_consts_are_pairwise_distinct`-shape gates the
15301        // other top-level kind-scoped slot-family axes carry
15302        // (implicitly held by their different byte-values today).
15303        assert_ne!(
15304            crate::render::DEP_AUTHOR_KEY_DEPS,
15305            crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
15306            "DEP_AUTHOR_KEY_{{DEPS,DEPS_DEV}} consts must be pairwise-distinct \
15307             so a `DepError::DuplicateNome {{ list: … }}` diagnostic \
15308             self-locates the offending block in the author's caixa.lisp",
15309        );
15310    }
15311
15312    #[test]
15313    fn validate_no_self_dep_routes_through_lifted_dep_author_key_consts() {
15314        // Production-through-const pin: the two per-arm list tags
15315        // [`validate_no_self_dep`] threads onto the `list:` field of a
15316        // returned [`DepError::DepIsSelf`] route through the lifted
15317        // [`crate::DEP_AUTHOR_KEY_DEPS`] /
15318        // [`crate::DEP_AUTHOR_KEY_DEPS_DEV`] consts. A future drift at
15319        // the walker (a rename that reaches one arm but not the const,
15320        // or vice versa) surfaces here at build time rather than at
15321        // runtime as a `feira lint` diagnostic naming the wrong list
15322        // tag. Mirror of the peer
15323        // [`crate::Caixa::declared_servico_slots`] production tagger
15324        // pin (f49c8b0) on the sibling M2 top-level slot axis, extended
15325        // onto the two-list dep-graph gate.
15326        let deps = vec![Dep::simple("orquestra", "^0.1")];
15327        let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
15328        let DepError::DepIsSelf { list, .. } = err else {
15329            panic!("expected DepIsSelf from :deps walk");
15330        };
15331        assert_eq!(list, crate::render::DEP_AUTHOR_KEY_DEPS);
15332
15333        let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
15334        let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
15335        let DepError::DepIsSelf { list, .. } = err else {
15336            panic!("expected DepIsSelf from :deps-dev walk");
15337        };
15338        assert_eq!(list, crate::render::DEP_AUTHOR_KEY_DEPS_DEV);
15339    }
15340
15341    // ── Dep::nome accessor pins ───────────────────────────────────────
15342    //
15343    // Three coherence pins on the lifted `Dep::nome` accessor: byte-equal
15344    // projection over the plain-shorthand / explicit-git / explicit-path
15345    // fixture triad the [`Dep`] docstring lists (so the accessor's
15346    // accept-set is exercised across every author-surface `:fonte`
15347    // shape); by-borrow pointer identity so the projection stays
15348    // zero-copy at every consumer site; and validate-composition through
15349    // the [`validate_no_self_dep`] cross-slot gate reading its
15350    // parent-name equality check through the lifted accessor rather than
15351    // the raw field.
15352
15353    #[test]
15354    fn dep_nome_returns_declared_nome_across_fonte_shapes() {
15355        // Plain-shorthand form (`:fonte None`).
15356        assert_eq!(Dep::simple("caixa-teia", "^0.1").nome(), "caixa-teia");
15357        // Explicit git-source form with a tag pin — same accessor path.
15358        assert_eq!(
15359            Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0").nome(),
15360            "caixa-teia",
15361        );
15362        // Explicit path-source form.
15363        assert_eq!(
15364            Dep {
15365                nome: "caixa-teia".to_string(),
15366                versao: "0.1.0".to_string(),
15367                fonte: Some(DepSource::Path {
15368                    caminho: "../caixa-teia".to_string(),
15369                }),
15370                opcional: false,
15371                caracteristicas: Vec::new(),
15372            }
15373            .nome(),
15374            "caixa-teia",
15375        );
15376        // The empty-string `:nome` sentinel (which [`Dep::validate`]
15377        // refuses through the [`DepError::NomeEmpty`] arm) still round-
15378        // trips as an empty `&str` through the accessor — the accessor is
15379        // a projection, not a gate; the gate is [`Dep::validate`].
15380        assert_eq!(Dep::simple("", "^0.1").nome(), "");
15381    }
15382
15383    #[test]
15384    fn dep_nome_is_by_borrow_pointer_identity() {
15385        // Zero-copy pin: the accessor must borrow into the field's own
15386        // storage, not clone. If a future rewrite regresses to
15387        // `self.nome.clone().leak()` or an owned-buffer shape, the two
15388        // pointers diverge and this pin fails at build time.
15389        let d = Dep::simple("caixa-teia", "^0.1");
15390        assert!(std::ptr::eq(d.nome().as_ptr(), d.nome.as_ptr()));
15391    }
15392
15393    // ── Dep::versao_requirement accessor pins ─────────────────────────
15394    //
15395    // Three coherence pins on the lifted `Dep::versao_requirement`
15396    // accessor: byte-equal projection over the plain-shorthand /
15397    // explicit-git / explicit-path fixture triad the [`Dep`] docstring
15398    // lists plus the empty-sentinel that round-trips as `""` (the accessor
15399    // is a projection, not a gate; the gate is [`Dep::validate`]); by-
15400    // borrow pointer identity so the projection stays zero-copy at every
15401    // consumer site; and validate-composition through the
15402    // [`crate::render::require_valid_versao_requirement`] cascade reading
15403    // its requirement-shape check through the lifted accessor rather than
15404    // the raw field.
15405    #[test]
15406    fn dep_versao_requirement_returns_declared_versao_across_fonte_shapes() {
15407        // Plain-shorthand form (`:fonte None`).
15408        assert_eq!(
15409            Dep::simple("caixa-teia", "^0.1").versao_requirement(),
15410            "^0.1",
15411        );
15412        // Explicit git-source form with a tag pin — same accessor path.
15413        assert_eq!(
15414            Dep::git(
15415                "caixa-teia",
15416                "~0.1.2",
15417                "github:pleme-io/caixa-teia",
15418                "v0.1.0"
15419            )
15420            .versao_requirement(),
15421            "~0.1.2",
15422        );
15423        // Explicit path-source form.
15424        assert_eq!(
15425            Dep {
15426                nome: "caixa-teia".to_string(),
15427                versao: "0.1.0".to_string(),
15428                fonte: Some(DepSource::Path {
15429                    caminho: "../caixa-teia".to_string(),
15430                }),
15431                opcional: false,
15432                caracteristicas: Vec::new(),
15433            }
15434            .versao_requirement(),
15435            "0.1.0",
15436        );
15437        // The wildcard requirement (`"*"`) — the shorthand
15438        // `parse_requirement` accepts as `VersionReq::STAR` — round-trips
15439        // verbatim through the accessor as `"*"`, same byte-shape the
15440        // author wrote.
15441        assert_eq!(Dep::simple("caixa-teia", "*").versao_requirement(), "*");
15442        // The empty-string `:versao` sentinel (which [`Dep::validate`]
15443        // refuses through the [`DepError::VersaoEmpty`] arm) still round-
15444        // trips as an empty `&str` through the accessor — the accessor is
15445        // a projection, not a gate; the gate is [`Dep::validate`]. Peer
15446        // of the sibling [`Dep::nome`] empty-sentinel round-trip pin.
15447        assert_eq!(Dep::simple("caixa-teia", "").versao_requirement(), "");
15448    }
15449
15450    #[test]
15451    fn dep_versao_requirement_is_by_borrow_pointer_identity() {
15452        // Zero-copy pin: the accessor must borrow into the field's own
15453        // storage, not clone. If a future rewrite regresses to
15454        // `self.versao.clone().leak()` or an owned-buffer shape, the two
15455        // pointers diverge and this pin fails at build time. Peer of the
15456        // sibling [`Dep::nome`] pointer-identity pin — same by-borrow
15457        // discipline extended onto the requirement-carrying axis.
15458        let d = Dep::simple("caixa-teia", "^0.1");
15459        assert!(std::ptr::eq(
15460            d.versao_requirement().as_ptr(),
15461            d.versao.as_ptr(),
15462        ));
15463    }
15464
15465    #[test]
15466    fn dep_validate_reads_requirement_through_accessor() {
15467        // Composition pin: the [`Dep::validate`]
15468        // [`crate::render::require_valid_versao_requirement`] cascade
15469        // consumes the requirement string through the lifted accessor —
15470        // both the requirement-gate input and the
15471        // [`DepError::VersaoInvalid`] error-body carrier route through
15472        // `self.versao_requirement()`. A valid requirement passes
15473        // (positive control); a malformed-but-non-empty requirement fails
15474        // and the diagnostic quotes the offending byte-string verbatim
15475        // (same shape the accessor projects), so a future regression that
15476        // detoured the requirement carrier through a different byte-
15477        // string (say the parsed `VersionReq`'s `Display`, or a
15478        // normalized rewrite) would surface here at build time. The
15479        // empty-`:versao` arm fires the [`DepError::VersaoEmpty`] variant
15480        // ahead of the parse arm, pinning the empty-first cascade the
15481        // accessor's `""` sentinel round-trip acknowledges.
15482        Dep::simple("caixa-teia", "^0.1").validate().unwrap();
15483        let err = Dep::simple("caixa-teia", "v0.1").validate().unwrap_err();
15484        assert!(
15485            matches!(
15486                &err,
15487                DepError::VersaoInvalid {
15488                    nome,
15489                    versao,
15490                    ..
15491                } if nome == "caixa-teia" && versao == "v0.1",
15492            ),
15493            "expected VersaoInvalid quoting the accessor-projected requirement, got {err:?}",
15494        );
15495        let err = Dep::simple("caixa-teia", "").validate().unwrap_err();
15496        assert!(
15497            matches!(
15498                &err,
15499                DepError::VersaoEmpty { nome } if nome == "caixa-teia",
15500            ),
15501            "expected VersaoEmpty from the empty-first arm, got {err:?}",
15502        );
15503    }
15504
15505    // ── Dep::fonte accessor pins ──────────────────────────────────────
15506    //
15507    // Three coherence pins on the lifted `Dep::fonte` accessor: byte-
15508    // equal projection over the plain-shorthand (`:fonte None`) /
15509    // explicit-git-tag / explicit-path fixture triad the [`Dep`]
15510    // docstring lists (so the accessor's accept-set is exercised across
15511    // every author-surface `:fonte` shape and both `DepSource` variants);
15512    // pointer identity so the borrowed reference points into the field's
15513    // own `Option<DepSource>` storage (not a cloned side-buffer); and
15514    // validate-composition through the [`Dep::validate`] gate reading
15515    // its per-`:fonte` [`DepSource::validate`] delegation through the
15516    // lifted accessor rather than the raw `if let Some(ref fonte) =
15517    // self.fonte` bracket.
15518
15519    #[test]
15520    fn dep_fonte_returns_declared_source_across_shapes() {
15521        // Plain-shorthand form — `:fonte` omitted, accessor projects
15522        // the `None` partition the resolver-side default-fill treats
15523        // as "resolve through `github:<default-org>/<nome>`".
15524        assert!(Dep::simple("caixa-teia", "^0.1").fonte().is_none());
15525        // Explicit git-source form with a tag pin — same accessor path.
15526        let git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
15527        match git.fonte() {
15528            Some(DepSource::Git {
15529                repo,
15530                tag,
15531                rev,
15532                branch,
15533            }) => {
15534                assert_eq!(repo, "github:pleme-io/caixa-teia");
15535                assert_eq!(tag.as_deref(), Some("v0.1.0"));
15536                assert!(rev.is_none());
15537                assert!(branch.is_none());
15538            }
15539            other => panic!("expected explicit git :fonte, got {other:?}"),
15540        }
15541        // Explicit path-source form — the dev-only local-filesystem
15542        // arm the [`Dep`] docstring's third fixture carries.
15543        let path = Dep {
15544            nome: "caixa-teia".to_string(),
15545            versao: "0.1.0".to_string(),
15546            fonte: Some(DepSource::Path {
15547                caminho: "../caixa-teia".to_string(),
15548            }),
15549            opcional: false,
15550            caracteristicas: Vec::new(),
15551        };
15552        match path.fonte() {
15553            Some(DepSource::Path { caminho }) => {
15554                assert_eq!(caminho, "../caixa-teia");
15555            }
15556            other => panic!("expected explicit path :fonte, got {other:?}"),
15557        }
15558    }
15559
15560    #[test]
15561    fn dep_fonte_is_by_borrow_pointer_identity() {
15562        // Zero-copy pin: the accessor must borrow into the field's own
15563        // `Option<DepSource>` storage, not clone into a side buffer. If
15564        // a future rewrite regresses to `self.fonte.clone()` or an
15565        // owned-buffer shape, the two pointers diverge and this pin
15566        // fails at build time. Peer of the sibling per-`Dep` [`Dep::nome`]
15567        // (eba2cde) / [`Dep::versao_requirement`] (05529b1) pointer-
15568        // identity pins — same by-borrow discipline extended onto the
15569        // outer-`Dep` `Option<&Composite>` composite-reference axis.
15570        let d = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
15571        let accessed = d.fonte().expect("git :fonte present") as *const DepSource;
15572        let raw = d.fonte.as_ref().expect("git :fonte present") as *const DepSource;
15573        assert!(std::ptr::eq(accessed, raw));
15574    }
15575
15576    #[test]
15577    fn dep_validate_reads_fonte_through_accessor() {
15578        // Composition pin: [`Dep::validate`]'s per-`:fonte`
15579        // [`DepSource::validate`] delegation consumes the typed slot
15580        // through the lifted accessor — an author-omitted `:fonte`
15581        // still passes the outer gate (positive control), an explicit
15582        // well-formed git source with exactly one pin passes, and a
15583        // malformed git source (empty `:repo`) surfaces the
15584        // [`DepError::FonteRepoEmpty`] variant quoting the offending
15585        // dep's `:nome` verbatim so a future regression that detoured
15586        // the `:fonte` delegation through a different path (say a
15587        // per-scope override projector) would surface here at build
15588        // time. Peer of the sibling
15589        // `dep_validate_reads_requirement_through_accessor` composition
15590        // pin on the `:versao` axis.
15591        // Positive control 1: no `:fonte` at all.
15592        Dep::simple("caixa-teia", "^0.1").validate().unwrap();
15593        // Positive control 2: well-formed git source.
15594        Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0")
15595            .validate()
15596            .unwrap();
15597        // Negative control: empty `:repo` — the accessor still returns
15598        // `Some(&DepSource::Git { repo: "", … })` and the delegated
15599        // `DepSource::validate` gate raises the typed carrier.
15600        let bad = Dep {
15601            nome: "caixa-teia".to_string(),
15602            versao: "^0.1".to_string(),
15603            fonte: Some(DepSource::Git {
15604                repo: String::new(),
15605                tag: Some("v0.1.0".to_string()),
15606                rev: None,
15607                branch: None,
15608            }),
15609            opcional: false,
15610            caracteristicas: Vec::new(),
15611        };
15612        let err = bad.validate().unwrap_err();
15613        assert!(
15614            matches!(
15615                &err,
15616                DepError::FonteRepoEmpty { nome } if nome == "caixa-teia",
15617            ),
15618            "expected FonteRepoEmpty from the accessor-routed :fonte gate, got {err:?}",
15619        );
15620    }
15621
15622    #[test]
15623    fn validate_no_self_dep_reads_parent_equality_through_accessor() {
15624        // Composition pin: the cross-slot [`validate_no_self_dep`] gate
15625        // rejects a `:deps` entry whose `:nome` equals the parent caixa's
15626        // own `:nome` through the lifted accessor rather than the raw
15627        // field. Fails-before-passes-after: with the accessor lifted the
15628        // gate reads its equality check through `dep.nome() ==
15629        // parent_nome` on both the `:deps` and `:deps-dev` traversals, so
15630        // the diagnostic still names the offending list tag as expected.
15631        let deps = vec![Dep::simple("orquestra", "^0.1")];
15632        let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
15633        assert!(matches!(
15634            err,
15635            DepError::DepIsSelf {
15636                ref nome,
15637                list,
15638            } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS,
15639        ));
15640        let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
15641        let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
15642        assert!(matches!(
15643            err,
15644            DepError::DepIsSelf {
15645                ref nome,
15646                list,
15647            } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
15648        ));
15649        // A non-matching `:nome` passes through the accessor gate.
15650        let deps = vec![Dep::simple("caixa-teia", "^0.1")];
15651        validate_no_self_dep(&deps, &[], "orquestra").unwrap();
15652    }
15653
15654    // ── Dep::caracteristicas accessor pins ────────────────────────────
15655    //
15656    // Three coherence pins on the lifted `Dep::caracteristicas` accessor:
15657    // byte-equal projection over the default-empty / single-entry /
15658    // multi-entry fixture triad (so the accessor's accept-set is
15659    // exercised across every author-surface `:caracteristicas` shape,
15660    // matching the peer sibling family's fixture-triad discipline); by-
15661    // borrow pointer identity so the projection stays zero-copy at every
15662    // consumer site; and validate-composition through the
15663    // [`Dep::validate_caracteristicas`] gate reading its per-entry
15664    // linear walk through the lifted accessor rather than the raw
15665    // `for c in &self.caracteristicas` bracket.
15666
15667    #[test]
15668    fn dep_caracteristicas_returns_declared_features_across_shapes() {
15669        // Default-empty form — the [`Dep::simple`] constructor's
15670        // `Vec::new()` fill; the accessor projects the empty slice
15671        // verbatim (no `None` collapse).
15672        assert!(
15673            Dep::simple("caixa-teia", "^0.1")
15674                .caracteristicas()
15675                .is_empty(),
15676        );
15677        // Single-entry form — the canonical Cargo-shaped one-feature
15678        // enable ([`crate::render::is_cargo_feature_name`] accepts the
15679        // `"http"` byte-string as a valid feature name).
15680        let one = Dep {
15681            nome: "caixa-teia".to_string(),
15682            versao: "^0.1".to_string(),
15683            fonte: None,
15684            opcional: false,
15685            caracteristicas: vec!["http".to_string()],
15686        };
15687        assert_eq!(one.caracteristicas(), &["http".to_string()]);
15688        // Multi-entry form — the substrate's set-shaped multi-feature
15689        // enable, exercising the accessor over a length-two slice with
15690        // no duplicate collapse.
15691        let two = Dep {
15692            nome: "caixa-teia".to_string(),
15693            versao: "^0.1".to_string(),
15694            fonte: None,
15695            opcional: false,
15696            caracteristicas: vec!["http".to_string(), "json".to_string()],
15697        };
15698        assert_eq!(
15699            two.caracteristicas(),
15700            &["http".to_string(), "json".to_string()],
15701        );
15702    }
15703
15704    #[test]
15705    fn dep_caracteristicas_is_by_borrow_pointer_identity() {
15706        // Zero-copy pin: the accessor must borrow into the field's own
15707        // `Vec<String>` storage, not clone into a side buffer. If a
15708        // future rewrite regresses to `self.caracteristicas.clone()` or
15709        // an owned-buffer shape, the two pointers diverge and this pin
15710        // fails at build time. Peer of the sibling per-`Dep`
15711        // [`Dep::nome`] (eba2cde) / [`Dep::versao_requirement`] (05529b1)
15712        // / [`Dep::fonte`] (d65d1bf) pointer-identity pins — same by-
15713        // borrow discipline extended onto the outer-`Dep` `&[String]`
15714        // slice-projection axis.
15715        let d = Dep {
15716            nome: "caixa-teia".to_string(),
15717            versao: "^0.1".to_string(),
15718            fonte: None,
15719            opcional: false,
15720            caracteristicas: vec!["http".to_string(), "json".to_string()],
15721        };
15722        assert!(std::ptr::eq(
15723            d.caracteristicas().as_ptr(),
15724            d.caracteristicas.as_ptr(),
15725        ));
15726    }
15727
15728    #[test]
15729    fn dep_validate_reads_caracteristicas_through_accessor() {
15730        // Composition pin: [`Dep::validate_caracteristicas`]'s per-entry
15731        // linear walk consumes the feature-toggle list through the
15732        // lifted accessor — a well-formed `:caracteristicas` set passes
15733        // (positive control), an empty-string entry surfaces the
15734        // [`DepError::CaracteristicaEmpty`] variant quoting the offending
15735        // `Dep::nome`, and a within-list duplicate surfaces the
15736        // [`DepError::CaracteristicaDuplicate`] variant so a future
15737        // regression that detoured the walk through a different byte-
15738        // string list (say a per-scope override projector) would surface
15739        // here at build time. Peer of the sibling
15740        // `dep_validate_reads_fonte_through_accessor` /
15741        // `dep_validate_reads_requirement_through_accessor` composition
15742        // pins on the `:fonte` / `:versao` axes.
15743        // Positive control: two distinct well-formed feature names pass.
15744        Dep {
15745            nome: "caixa-teia".to_string(),
15746            versao: "^0.1".to_string(),
15747            fonte: None,
15748            opcional: false,
15749            caracteristicas: vec!["http".to_string(), "json".to_string()],
15750        }
15751        .validate()
15752        .unwrap();
15753        // Negative control 1: empty-string feature-name entry — the
15754        // accessor still returns `&[""]` and the walk raises the typed
15755        // empty-first carrier.
15756        let err = Dep {
15757            nome: "caixa-teia".to_string(),
15758            versao: "^0.1".to_string(),
15759            fonte: None,
15760            opcional: false,
15761            caracteristicas: vec![String::new()],
15762        }
15763        .validate()
15764        .unwrap_err();
15765        assert!(
15766            matches!(
15767                &err,
15768                DepError::CaracteristicaEmpty { nome } if nome == "caixa-teia",
15769            ),
15770            "expected CaracteristicaEmpty from the accessor-routed walk, got {err:?}",
15771        );
15772        // Negative control 2: within-list duplicate — the accessor's
15773        // slice view carries both entries, and the walk's dedup arm
15774        // raises the typed duplicate carrier quoting the offending
15775        // feature name verbatim.
15776        let err = Dep {
15777            nome: "caixa-teia".to_string(),
15778            versao: "^0.1".to_string(),
15779            fonte: None,
15780            opcional: false,
15781            caracteristicas: vec!["http".to_string(), "http".to_string()],
15782        }
15783        .validate()
15784        .unwrap_err();
15785        assert!(
15786            matches!(
15787                &err,
15788                DepError::CaracteristicaDuplicate {
15789                    nome,
15790                    caracteristica,
15791                } if nome == "caixa-teia" && caracteristica == "http",
15792            ),
15793            "expected CaracteristicaDuplicate from the accessor-routed dedup, got {err:?}",
15794        );
15795    }
15796
15797    // ── Dep::opcional accessor pins ───────────────────────────────────
15798    //
15799    // Two coherence pins on the lifted `Dep::opcional` accessor: byte-
15800    // equal projection over the default-`false` / explicit-`true`
15801    // fixture pair across the plain-shorthand (`:fonte None`) / explicit-
15802    // git-tag / explicit-path fixture triad the [`Dep`] docstring lists,
15803    // exercising the accessor's accept-set over every author-surface
15804    // `:fonte` shape × every author-surface `:opcional` shape; and by-
15805    // `Copy` idempotency so the projection stays value-return (no
15806    // silent detour to a fresh `&bool` borrow that would introduce a
15807    // lifetime on the return type the plain-`Copy`-scalar axis's `bool`
15808    // shape elides). No composition pin — `:opcional` does not
15809    // participate in [`Dep::validate`] (an opcional dep with any bool
15810    // value is validate-accepted; the missing-source arm is a resolver-
15811    // side runtime dispatch, not a build-time refusal), so the axis
15812    // reduces to the value-shape + `Copy` pin pair the peer
15813    // [`crate::Caixa::max_restarts`] / [`crate::Caixa::estrategia`]
15814    // outer-`Option<Copy>` accessor pins already carry.
15815
15816    #[test]
15817    fn dep_opcional_returns_declared_opcional_across_fonte_shapes() {
15818        // Default-`false` form via the [`Dep::simple`] constructor —
15819        // the accessor projects the `false` bit the default-fill sets.
15820        assert!(!Dep::simple("caixa-teia", "^0.1").opcional());
15821        // Default-`false` form via the [`Dep::git`] constructor — same
15822        // default fill; the accessor projects `false` regardless of the
15823        // `:fonte` arm.
15824        assert!(!Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0").opcional(),);
15825        // Explicit-`true` form × plain-shorthand `:fonte` — the
15826        // canonical author-surface "this dep may be missing" shape.
15827        let plain_true = Dep {
15828            nome: "caixa-teia".to_string(),
15829            versao: "^0.1".to_string(),
15830            fonte: None,
15831            opcional: true,
15832            caracteristicas: Vec::new(),
15833        };
15834        assert!(plain_true.opcional());
15835        // Explicit-`true` form × explicit git-source — the accessor
15836        // projects the bit verbatim regardless of the `:fonte` arm.
15837        let git_true = Dep {
15838            nome: "caixa-teia".to_string(),
15839            versao: "^0.1".to_string(),
15840            fonte: Some(DepSource::Git {
15841                repo: "github:pleme-io/caixa-teia".to_string(),
15842                tag: Some("v0.1.0".to_string()),
15843                rev: None,
15844                branch: None,
15845            }),
15846            opcional: true,
15847            caracteristicas: Vec::new(),
15848        };
15849        assert!(git_true.opcional());
15850        // Explicit-`true` form × explicit path-source — the dev-only
15851        // local-filesystem arm the [`Dep`] docstring's third fixture
15852        // carries.
15853        let path_true = Dep {
15854            nome: "caixa-teia".to_string(),
15855            versao: "0.1.0".to_string(),
15856            fonte: Some(DepSource::Path {
15857                caminho: "../caixa-teia".to_string(),
15858            }),
15859            opcional: true,
15860            caracteristicas: Vec::new(),
15861        };
15862        assert!(path_true.opcional());
15863    }
15864
15865    #[test]
15866    fn dep_opcional_projects_bool_by_copy() {
15867        // The by-`Copy` pin: [`Dep::opcional`] returns `bool` by value
15868        // (`bool: Copy`) — the accessor does not borrow `&self` past
15869        // the call (no lifetime on the return type), and calling the
15870        // accessor twice on the same [`Dep`] must yield discriminant-
15871        // equal values (idempotent, no side effects on `&self`). Peer
15872        // of the sibling outer-`Caixa` `Option<Copy>` by-`Copy`
15873        // `max_restarts_projects_option_by_copy` (eba5211) /
15874        // `estrategia_projects_option_by_copy` (ed04d3c) pins on the
15875        // outer-`Caixa` altitude — extended here to the outer-`Dep`
15876        // altitude's plain-`Copy` `bool` axis. The `Copy` discipline
15877        // replaces the pointer-equality claim the sibling per-`Dep`
15878        // by-borrow pins (`dep_nome_is_by_borrow_pointer_identity`
15879        // eba2cde, `dep_versao_requirement_is_by_borrow_pointer_identity`
15880        // 05529b1, `dep_fonte_is_by_borrow_pointer_identity` d65d1bf,
15881        // `dep_caracteristicas_is_by_borrow_pointer_identity` 9197944)
15882        // carry (a fresh `Copy` of a `Copy` discriminant is definitionally
15883        // the same discriminant, so the axis reduces to discriminant
15884        // equality).
15885        //
15886        // Pins against a future silent detour that returned a fresh
15887        // `&bool` reference (which would type-check but silently
15888        // introduce a borrow of `&self` past the call, collapsing the
15889        // load-bearing "no lifetime on the return type" `Copy`
15890        // projection the plain-`Copy`-scalar axis's `bool` shape
15891        // carries) or a stale-read side effect that flipped the outer
15892        // discriminant on successive calls.
15893        for opcional in [false, true] {
15894            let d = Dep {
15895                nome: "caixa-teia".to_string(),
15896                versao: "^0.1".to_string(),
15897                fonte: None,
15898                opcional,
15899                caracteristicas: Vec::new(),
15900            };
15901            let first = d.opcional();
15902            let second = d.opcional();
15903            assert_eq!(
15904                first, second,
15905                "Dep::opcional must be idempotent — two successive calls \
15906                 on the same &self must return the same bool",
15907            );
15908            assert_eq!(
15909                first, opcional,
15910                "Dep::opcional must return :opcional verbatim by Copy — \
15911                 got {first}, expected {opcional}",
15912            );
15913            assert_eq!(
15914                d.opcional(),
15915                d.opcional,
15916                "Dep::opcional accessor and self.opcional field access \
15917                 must byte-equal — a bit-flip drift would silently split \
15918                 the paired resolver-side drop-vs-error dispatch from \
15919                 the storage-side default-fill the [`Dep::simple`] / \
15920                 [`Dep::git`] constructor pair carries",
15921            );
15922        }
15923    }
15924
15925    // ── DepSource::sole_pin — sole-set git-pin accessor ─────────────────
15926
15927    #[test]
15928    fn sole_pin_returns_none_for_path_source() {
15929        // A path source carries no git-ref, so `sole_pin()` returns
15930        // `None` structurally — the sibling arm every git-fetching
15931        // consumer partitions off before reaching for a git-ref. Pins
15932        // the Path-arm branch of the accessor against a future silent
15933        // detour that treats a `Self::Path` as an unpinned-git source
15934        // and returns the wrong "no pin" signal (e.g. the empty string,
15935        // or a hard-coded `Some("HEAD")` matching the caixa-crd
15936        // path-arm `git_ref` fill).
15937        let s = DepSource::Path {
15938            caminho: "../local-caixa".to_string(),
15939        };
15940        assert_eq!(s.sole_pin(), None);
15941    }
15942
15943    #[test]
15944    fn sole_pin_returns_none_for_unpinned_git_source() {
15945        // The [`DepSource::default_github`] shorthand shape carries no
15946        // pin — every `tag`/`rev`/`branch` is `None`, and `sole_pin()`
15947        // returns `None`. This is the shape caixa-resolver's `fetch_dep`
15948        // materializes when the author omits `:fonte` entirely, then
15949        // hands to `fetch_git` which raises `ResolveError::MissingPin`
15950        // on the `None` arm — the accessor's return matches the arm
15951        // the resolver's diagnostic keys off.
15952        let s = DepSource::default_github("pleme-io", "caixa-teia");
15953        assert_eq!(s.sole_pin(), None);
15954    }
15955
15956    #[test]
15957    fn sole_pin_returns_rev_when_only_rev_is_set() {
15958        let s = DepSource::Git {
15959            repo: "github:o/x".into(),
15960            tag: None,
15961            rev: Some("deadbeefcafebabe1234567890abcdef12345678".into()),
15962            branch: None,
15963        };
15964        assert_eq!(
15965            s.sole_pin(),
15966            Some("deadbeefcafebabe1234567890abcdef12345678")
15967        );
15968    }
15969
15970    #[test]
15971    fn sole_pin_returns_tag_when_only_tag_is_set() {
15972        let s = DepSource::Git {
15973            repo: "github:o/x".into(),
15974            tag: Some("v0.1.0".into()),
15975            rev: None,
15976            branch: None,
15977        };
15978        assert_eq!(s.sole_pin(), Some("v0.1.0"));
15979    }
15980
15981    #[test]
15982    fn sole_pin_returns_branch_when_only_branch_is_set() {
15983        let s = DepSource::Git {
15984            repo: "github:o/x".into(),
15985            tag: None,
15986            rev: None,
15987            branch: Some("main".into()),
15988        };
15989        assert_eq!(s.sole_pin(), Some("main"));
15990    }
15991
15992    #[test]
15993    fn sole_pin_precedence_rev_beats_tag_and_branch() {
15994        // Precedence: rev > tag > branch. Validate() rejects
15995        // multiple-pin shapes, but the accessor's precedence is defined
15996        // for pre-validate consumers (the resolver's `MissingPin`
15997        // diagnostic path, the caixa-crd round-trip's default `"main"`
15998        // fallback) and as defense-in-depth if the gate is ever
15999        // bypassed. Pins the same precedence caixa-resolver's
16000        // `fetch_git` and caixa-crd's `dep_into_ref` already apply
16001        // inline.
16002        let s = DepSource::Git {
16003            repo: "github:o/x".into(),
16004            tag: Some("v1".into()),
16005            rev: Some("deadbeefcafebabe1234567890abcdef12345678".into()),
16006            branch: Some("main".into()),
16007        };
16008        assert_eq!(
16009            s.sole_pin(),
16010            Some("deadbeefcafebabe1234567890abcdef12345678")
16011        );
16012    }
16013
16014    #[test]
16015    fn sole_pin_precedence_tag_beats_branch_when_no_rev() {
16016        let s = DepSource::Git {
16017            repo: "github:o/x".into(),
16018            tag: Some("v1".into()),
16019            rev: None,
16020            branch: Some("main".into()),
16021        };
16022        assert_eq!(s.sole_pin(), Some("v1"));
16023    }
16024
16025    #[test]
16026    fn sole_pin_byte_equals_inline_rev_or_tag_or_branch_cascade() {
16027        // Fail-before-pass-after byte-parity pin: the substrate accessor
16028        // must return byte-identical to the inline
16029        // `rev.as_deref().or(tag.as_deref()).or(branch.as_deref())`
16030        // cascade both caixa-resolver's `fetch_git` and caixa-crd's
16031        // `dep_into_ref` open-coded pre-lift. Trips at caixa-core build
16032        // time if the accessor's precedence silently drifts from the
16033        // consumer-side cascade — the exact drift this lift converges
16034        // to one substrate primitive to close structurally.
16035        //
16036        // Iterates through the 2^3 = 8 combinations of (tag, rev,
16037        // branch) each-either-`None`-or-`Some`, so every arm of the
16038        // precedence cascade lands under the pin. `validate()` refuses
16039        // the 4 multi-pin combinations, but the accessor's return is
16040        // defined on all 8.
16041        let vals = [Some("R".to_string()), None];
16042        for tag in &vals {
16043            for rev in &vals {
16044                for branch in &vals {
16045                    let s = DepSource::Git {
16046                        repo: "github:o/x".into(),
16047                        tag: tag.clone(),
16048                        rev: rev.clone(),
16049                        branch: branch.clone(),
16050                    };
16051                    // The exact inline cascade the two pre-lift
16052                    // consumer sites hand-rolled, byte-for-byte.
16053                    let expected = rev.as_deref().or(tag.as_deref()).or(branch.as_deref());
16054                    assert_eq!(
16055                        s.sole_pin(),
16056                        expected,
16057                        "sole_pin() must byte-equal \
16058                         rev.or(tag).or(branch) for \
16059                         (tag={tag:?}, rev={rev:?}, branch={branch:?}) — \
16060                         a drift would silently split caixa-resolver's \
16061                         fetch_git checkout target from caixa-crd's \
16062                         dep_into_ref git_ref fill",
16063                    );
16064                }
16065            }
16066        }
16067    }
16068
16069    // Fail-before-pass-after pins on the eleven
16070    // [`fonte_caminho_ctors!`]-generated `DepError::fonte_caminho_*`
16071    // constructors folded from the [`DepSource::validate_caminho`]
16072    // wire-up sites. Each pins the generated ctor's output to the
16073    // pre-lift struct-literal on the same `(&str, &str)` fixture, so
16074    // any wrapper-side lowercase / trim / re-order / silent-field-swap
16075    // regression on the two-field `{ nome: nome.to_string(), caminho:
16076    // caminho.to_string() }` construction surfaces here rather than at
16077    // a downstream diagnostic-shape mismatch. Peer of the sibling
16078    // `empty_child_version_ctor_matches_struct_literal_wrap` /
16079    // `contrato_endpoint_empty_ctor_matches_struct_literal_wrap` /
16080    // `entrada_host_invalid_ctor_matches_struct_literal_wrap` /
16081    // `nome_only_ctor_routes_caixa_through_nome_accessor` equivalence
16082    // pins on the peer `SupervisorError` / `AplicacaoError` /
16083    // `LayoutError` / `LimitsError` / `UpgradeError` envelopes.
16084
16085    #[test]
16086    fn fonte_caminho_absolute_ctor_matches_struct_literal_wrap() {
16087        assert_eq!(
16088            DepError::fonte_caminho_absolute("caixa-teia", "/home/me/work/caixa-teia"),
16089            DepError::FonteCaminhoAbsolute {
16090                nome: "caixa-teia".to_string(),
16091                caminho: "/home/me/work/caixa-teia".to_string(),
16092            },
16093            "generated fonte_caminho_absolute ctor must produce byte-equal \
16094             DepError to the open-coded struct-literal wrap on the same \
16095             (&str, &str) fixture",
16096        );
16097    }
16098
16099    #[test]
16100    fn fonte_caminho_tilde_expansion_ctor_matches_struct_literal_wrap() {
16101        assert_eq!(
16102            DepError::fonte_caminho_tilde_expansion("caixa-teia", "~/work/caixa-teia"),
16103            DepError::FonteCaminhoTildeExpansion {
16104                nome: "caixa-teia".to_string(),
16105                caminho: "~/work/caixa-teia".to_string(),
16106            },
16107        );
16108    }
16109
16110    #[test]
16111    fn fonte_caminho_var_expansion_ctor_matches_struct_literal_wrap() {
16112        assert_eq!(
16113            DepError::fonte_caminho_var_expansion("caixa-teia", "$HOME/work/caixa-teia"),
16114            DepError::FonteCaminhoVarExpansion {
16115                nome: "caixa-teia".to_string(),
16116                caminho: "$HOME/work/caixa-teia".to_string(),
16117            },
16118        );
16119    }
16120
16121    #[test]
16122    fn fonte_caminho_leading_whitespace_ctor_matches_struct_literal_wrap() {
16123        assert_eq!(
16124            DepError::fonte_caminho_leading_whitespace("caixa-teia", " ../caixa-teia"),
16125            DepError::FonteCaminhoLeadingWhitespace {
16126                nome: "caixa-teia".to_string(),
16127                caminho: " ../caixa-teia".to_string(),
16128            },
16129        );
16130    }
16131
16132    #[test]
16133    fn fonte_caminho_leading_hyphen_ctor_matches_struct_literal_wrap() {
16134        assert_eq!(
16135            DepError::fonte_caminho_leading_hyphen("caixa-teia", "-rf"),
16136            DepError::FonteCaminhoLeadingHyphen {
16137                nome: "caixa-teia".to_string(),
16138                caminho: "-rf".to_string(),
16139            },
16140        );
16141    }
16142
16143    #[test]
16144    fn fonte_caminho_backslash_ctor_matches_struct_literal_wrap() {
16145        assert_eq!(
16146            DepError::fonte_caminho_backslash("caixa-teia", "..\\caixa-teia"),
16147            DepError::FonteCaminhoBackslash {
16148                nome: "caixa-teia".to_string(),
16149                caminho: "..\\caixa-teia".to_string(),
16150            },
16151        );
16152    }
16153
16154    #[test]
16155    fn fonte_caminho_shell_pipe_ctor_matches_struct_literal_wrap() {
16156        assert_eq!(
16157            DepError::fonte_caminho_shell_pipe("caixa-teia", "../caixa-teia|evil"),
16158            DepError::FonteCaminhoShellPipe {
16159                nome: "caixa-teia".to_string(),
16160                caminho: "../caixa-teia|evil".to_string(),
16161            },
16162        );
16163    }
16164
16165    #[test]
16166    fn fonte_caminho_shell_semicolon_ctor_matches_struct_literal_wrap() {
16167        assert_eq!(
16168            DepError::fonte_caminho_shell_semicolon("caixa-teia", "../caixa-teia;evil"),
16169            DepError::FonteCaminhoShellSemicolon {
16170                nome: "caixa-teia".to_string(),
16171                caminho: "../caixa-teia;evil".to_string(),
16172            },
16173        );
16174    }
16175
16176    #[test]
16177    fn fonte_caminho_shell_background_ctor_matches_struct_literal_wrap() {
16178        assert_eq!(
16179            DepError::fonte_caminho_shell_background("caixa-teia", "../caixa-teia&"),
16180            DepError::FonteCaminhoShellBackground {
16181                nome: "caixa-teia".to_string(),
16182                caminho: "../caixa-teia&".to_string(),
16183            },
16184        );
16185    }
16186
16187    #[test]
16188    fn fonte_caminho_shell_command_substitution_ctor_matches_struct_literal_wrap() {
16189        assert_eq!(
16190            DepError::fonte_caminho_shell_command_substitution(
16191                "caixa-teia",
16192                "../caixa-teia`whoami`",
16193            ),
16194            DepError::FonteCaminhoShellCommandSubstitution {
16195                nome: "caixa-teia".to_string(),
16196                caminho: "../caixa-teia`whoami`".to_string(),
16197            },
16198        );
16199    }
16200
16201    #[test]
16202    fn fonte_caminho_trailing_slash_ctor_matches_struct_literal_wrap() {
16203        assert_eq!(
16204            DepError::fonte_caminho_trailing_slash("caixa-teia", "../caixa-teia/"),
16205            DepError::FonteCaminhoTrailingSlash {
16206                nome: "caixa-teia".to_string(),
16207                caminho: "../caixa-teia/".to_string(),
16208            },
16209        );
16210    }
16211
16212    #[test]
16213    fn fonte_caminho_ctors_route_nome_and_caminho_through_to_string() {
16214        // Cross-axis pin: sweep the two constructor input axes
16215        // (`nome: &str`, `caminho: &str`) through a non-default fixture
16216        // pair against every generated arm in the
16217        // [`fonte_caminho_ctors!`] macro, so any wrapper-side lowercase
16218        // / trim / truncate / re-order on the two-field
16219        // `{ nome, caminho }` construction — or a silent field swap
16220        // between the two axes at codegen time — surfaces here rather
16221        // than at a downstream diagnostic-shape mismatch. Peer of the
16222        // sibling `supervisor_caixa_only_ctors_route_caixa_through_
16223        // to_string` cross-axis routing pin on the peer
16224        // `SupervisorError` envelope, extended here onto the
16225        // `DepError` `{ nome: String, caminho: String }` envelope so
16226        // every substrate-primitive ctor family in caixa-core
16227        // guarantees each `&str`-field construction routes the
16228        // caller's `&str` verbatim through `.to_string()`.
16229        let nome = "sibling-teia";
16230        let caminho = "../workspace/sibling";
16231        let cases: [(DepError, DepError); 11] = [
16232            (
16233                DepError::fonte_caminho_absolute(nome, caminho),
16234                DepError::FonteCaminhoAbsolute {
16235                    nome: nome.to_string(),
16236                    caminho: caminho.to_string(),
16237                },
16238            ),
16239            (
16240                DepError::fonte_caminho_tilde_expansion(nome, caminho),
16241                DepError::FonteCaminhoTildeExpansion {
16242                    nome: nome.to_string(),
16243                    caminho: caminho.to_string(),
16244                },
16245            ),
16246            (
16247                DepError::fonte_caminho_var_expansion(nome, caminho),
16248                DepError::FonteCaminhoVarExpansion {
16249                    nome: nome.to_string(),
16250                    caminho: caminho.to_string(),
16251                },
16252            ),
16253            (
16254                DepError::fonte_caminho_leading_whitespace(nome, caminho),
16255                DepError::FonteCaminhoLeadingWhitespace {
16256                    nome: nome.to_string(),
16257                    caminho: caminho.to_string(),
16258                },
16259            ),
16260            (
16261                DepError::fonte_caminho_leading_hyphen(nome, caminho),
16262                DepError::FonteCaminhoLeadingHyphen {
16263                    nome: nome.to_string(),
16264                    caminho: caminho.to_string(),
16265                },
16266            ),
16267            (
16268                DepError::fonte_caminho_backslash(nome, caminho),
16269                DepError::FonteCaminhoBackslash {
16270                    nome: nome.to_string(),
16271                    caminho: caminho.to_string(),
16272                },
16273            ),
16274            (
16275                DepError::fonte_caminho_shell_pipe(nome, caminho),
16276                DepError::FonteCaminhoShellPipe {
16277                    nome: nome.to_string(),
16278                    caminho: caminho.to_string(),
16279                },
16280            ),
16281            (
16282                DepError::fonte_caminho_shell_semicolon(nome, caminho),
16283                DepError::FonteCaminhoShellSemicolon {
16284                    nome: nome.to_string(),
16285                    caminho: caminho.to_string(),
16286                },
16287            ),
16288            (
16289                DepError::fonte_caminho_shell_background(nome, caminho),
16290                DepError::FonteCaminhoShellBackground {
16291                    nome: nome.to_string(),
16292                    caminho: caminho.to_string(),
16293                },
16294            ),
16295            (
16296                DepError::fonte_caminho_shell_command_substitution(nome, caminho),
16297                DepError::FonteCaminhoShellCommandSubstitution {
16298                    nome: nome.to_string(),
16299                    caminho: caminho.to_string(),
16300                },
16301            ),
16302            (
16303                DepError::fonte_caminho_trailing_slash(nome, caminho),
16304                DepError::FonteCaminhoTrailingSlash {
16305                    nome: nome.to_string(),
16306                    caminho: caminho.to_string(),
16307                },
16308            ),
16309        ];
16310        for (via_ctor, via_struct_literal) in cases {
16311            assert_eq!(
16312                via_ctor, via_struct_literal,
16313                "fonte_caminho_ctors!-generated ctor must route (nome, caminho) \
16314                 through `.to_string()` in declared field order — a field-swap or \
16315                 silent-conversion regression surfaces here rather than at a \
16316                 downstream diagnostic-shape mismatch",
16317            );
16318        }
16319    }
16320
16321    // ── `dep_nome_only_ctors!` — the paired `{ nome: String }` single-slot
16322    //    envelope on `DepError`, sibling of the peer `fonte_caminho_ctors!`
16323    //    (f85f145) on the `{ nome, caminho }` two-slot envelope of the same
16324    //    enum, and of `supervisor_caixa_only_ctors!` (db09650) on the peer
16325    //    `SupervisorError` envelope's `{ caixa: String }` single-slot axis.
16326
16327    #[test]
16328    fn versao_empty_ctor_matches_struct_literal_wrap() {
16329        assert_eq!(
16330            DepError::versao_empty("caixa-teia"),
16331            DepError::VersaoEmpty {
16332                nome: "caixa-teia".to_string(),
16333            },
16334        );
16335    }
16336
16337    #[test]
16338    fn fonte_repo_empty_ctor_matches_struct_literal_wrap() {
16339        assert_eq!(
16340            DepError::fonte_repo_empty("caixa-teia"),
16341            DepError::FonteRepoEmpty {
16342                nome: "caixa-teia".to_string(),
16343            },
16344        );
16345    }
16346
16347    #[test]
16348    fn fonte_pin_missing_ctor_matches_struct_literal_wrap() {
16349        assert_eq!(
16350            DepError::fonte_pin_missing("caixa-teia"),
16351            DepError::FontePinMissing {
16352                nome: "caixa-teia".to_string(),
16353            },
16354        );
16355    }
16356
16357    #[test]
16358    fn fonte_caminho_empty_ctor_matches_struct_literal_wrap() {
16359        assert_eq!(
16360            DepError::fonte_caminho_empty("caixa-teia"),
16361            DepError::FonteCaminhoEmpty {
16362                nome: "caixa-teia".to_string(),
16363            },
16364        );
16365    }
16366
16367    #[test]
16368    fn caracteristica_empty_ctor_matches_struct_literal_wrap() {
16369        assert_eq!(
16370            DepError::caracteristica_empty("caixa-teia"),
16371            DepError::CaracteristicaEmpty {
16372                nome: "caixa-teia".to_string(),
16373            },
16374        );
16375    }
16376
16377    #[test]
16378    fn dep_nome_only_ctors_route_nome_through_to_string() {
16379        // Cross-axis routing pin: sweep the single constructor input
16380        // axis (`nome: &str`) through a non-default fixture against
16381        // every generated arm in the [`dep_nome_only_ctors!`] macro, so
16382        // any wrapper-side lowercase / trim / truncate at codegen time
16383        // — or a silent field re-name away from the canonical `nome`
16384        // axis on any one variant — surfaces here rather than at a
16385        // downstream diagnostic-shape mismatch. Peer of the sibling
16386        // `fonte_caminho_ctors_route_nome_and_caminho_through_
16387        // to_string` cross-axis routing pin on the same envelope's
16388        // two-slot family (f85f145) and of the peer
16389        // `supervisor_caixa_only_ctors_route_caixa_through_to_string`
16390        // pin on the `SupervisorError` single-slot family (db09650).
16391        let nome = "sibling-teia";
16392        let cases: [(DepError, DepError); 5] = [
16393            (
16394                DepError::versao_empty(nome),
16395                DepError::VersaoEmpty {
16396                    nome: nome.to_string(),
16397                },
16398            ),
16399            (
16400                DepError::fonte_repo_empty(nome),
16401                DepError::FonteRepoEmpty {
16402                    nome: nome.to_string(),
16403                },
16404            ),
16405            (
16406                DepError::fonte_pin_missing(nome),
16407                DepError::FontePinMissing {
16408                    nome: nome.to_string(),
16409                },
16410            ),
16411            (
16412                DepError::fonte_caminho_empty(nome),
16413                DepError::FonteCaminhoEmpty {
16414                    nome: nome.to_string(),
16415                },
16416            ),
16417            (
16418                DepError::caracteristica_empty(nome),
16419                DepError::CaracteristicaEmpty {
16420                    nome: nome.to_string(),
16421                },
16422            ),
16423        ];
16424        for (via_ctor, via_struct_literal) in cases {
16425            assert_eq!(
16426                via_ctor, via_struct_literal,
16427                "dep_nome_only_ctors!-generated ctor must route `nome` \
16428                 through `.to_string()` onto the canonical `nome` field \
16429                 — a field-rename or silent-conversion regression surfaces \
16430                 here rather than at a downstream diagnostic-shape mismatch",
16431            );
16432        }
16433    }
16434}
16435
16436#[cfg(test)]
16437mod dep_source_is_variant_tests {
16438    use super::*;
16439
16440    fn all_variants() -> Vec<(DepSource, &'static str)> {
16441        vec![
16442            (
16443                DepSource::Git {
16444                    repo: "github:pleme-io/caixa-teia".into(),
16445                    tag: Some("v0.1.0".into()),
16446                    rev: None,
16447                    branch: None,
16448                },
16449                "Git",
16450            ),
16451            (
16452                DepSource::Path {
16453                    caminho: "../caixa-teia".into(),
16454                },
16455                "Path",
16456            ),
16457        ]
16458    }
16459
16460    fn predicate_row(s: &DepSource) -> [bool; 2] {
16461        [s.is_git(), s.is_path()]
16462    }
16463
16464    // Fail-before-pass-after pin on the [`gen_platform::IsVariant`]
16465    // derive-generated per-arm predicate partition — for every variant
16466    // in `all_variants()`, the observed 2-slot predicate row must equal
16467    // a one-hot row with the `true` at exactly the same index as the
16468    // variant's declaration order. Expected rows are generated live
16469    // from the enumeration rather than transcribed by hand, so a
16470    // copy-paste flip that reroutes one arm through the wrong predicate
16471    // lane trips at the identity-diagonal assertion the way every peer
16472    // sibling [`DepList`] / [`crate::CaixaKind`] / [`crate::CaixaDialeto`]
16473    // / [`crate::supervisor::RestartStrategy`] / [`crate::supervisor::RestartPolicy`]
16474    // / [`crate::upgrade::UpgradeInstruction`] /
16475    // [`crate::aplicacao::PlacementStrategy`] /
16476    // [`crate::aplicacao::RateLimitUnit`] /
16477    // [`crate::aplicacao::WitTarget`] /
16478    // [`crate::render::PathShapeViolation`] partition pin already does.
16479    #[test]
16480    fn dep_source_is_variant_predicates_partition_the_arm_set() {
16481        let variants = all_variants();
16482        for (idx, (variant, name)) in variants.iter().enumerate() {
16483            let observed = predicate_row(variant);
16484            let mut expected = [false; 2];
16485            expected[idx] = true;
16486            assert_eq!(
16487                observed, expected,
16488                "DepSource::{name} at declaration-order slot {idx} must \
16489                 satisfy exactly one is_* predicate (its own); observed \
16490                 row must equal the one-hot expected row — a drift \
16491                 would silently reroute one `:fonte`-arm consumer \
16492                 through the wrong predicate lane"
16493            );
16494        }
16495    }
16496
16497    // Byte-parity pin on the two field-agnostic `matches!` shapes the
16498    // per-arm arm-discriminator predicates replace at any future
16499    // consumer site (a `:fonte`-shape-only lint rule that flags path
16500    // deps outside dev-caixas via `dep.fonte().is_some_and(DepSource::is_path)`,
16501    // a future admission-webhook that rejects `:fonte` shapes outside
16502    // the `is_git()` accept-set, a caixa-lacre indexing pass that
16503    // dispatches on `s.is_git()` without extracting `repo` / `caminho`).
16504    // Refuses a future accidental split between the derived predicate
16505    // and its `matches!` shape — a hand-rolled shadow impl that
16506    // overrides one path, an accidental rebrand that leaves one
16507    // consumer on the raw `matches!` form — on the two load-bearing
16508    // `:fonte`-arm-discriminator axes every downstream substrate
16509    // consumer of the dep-source axis keys off.
16510    #[test]
16511    fn dep_source_is_git_and_is_path_byte_equal_matches_shape() {
16512        for (variant, name) in all_variants() {
16513            let via_matches_git = matches!(variant, DepSource::Git { .. });
16514            let via_predicate_git = variant.is_git();
16515            assert_eq!(
16516                via_predicate_git, via_matches_git,
16517                "DepSource::{name}.is_git() must byte-equal \
16518                 matches!(_, DepSource::Git {{ .. }}) — otherwise a \
16519                 future converged consumer site would silently \
16520                 disagree with its pre-lift shape"
16521            );
16522            let via_matches_path = matches!(variant, DepSource::Path { .. });
16523            let via_predicate_path = variant.is_path();
16524            assert_eq!(
16525                via_predicate_path, via_matches_path,
16526                "DepSource::{name}.is_path() must byte-equal \
16527                 matches!(_, DepSource::Path {{ .. }}) — otherwise a \
16528                 future converged consumer site would silently \
16529                 disagree with its pre-lift shape"
16530            );
16531        }
16532    }
16533
16534    // Cross-pin against every constructor path that materializes a
16535    // [`DepSource`] shape today (the [`DepSource::default_github`]
16536    // resolver-side fallback that materializes an unpinned
16537    // `github:<org>/<nome>` git shorthand, the [`Dep::git`] author-
16538    // surface constructor that materializes a pinned `:tag`-carrying
16539    // `DepSource::Git`, a hand-rolled `DepSource::Path` the dev-mode
16540    // fixture family builds inline). Every constructor's return must
16541    // satisfy the arm-discriminator predicate the constructor's
16542    // variant name matches — a future constructor addition (an
16543    // in-tree registry-fetch pin, a `DepSource::Feira` variant the
16544    // enclosing docstring already names as a trajectory item) surfaces
16545    // as a build-time failure that names the offending drift when its
16546    // return arm doesn't route through the paired predicate.
16547    #[test]
16548    fn dep_source_constructors_route_through_paired_is_variant_predicate() {
16549        let via_default_github = DepSource::default_github("pleme-io", "caixa-teia");
16550        assert!(
16551            via_default_github.is_git(),
16552            "DepSource::default_github must materialize a Git-arm shape — \
16553             a future constructor that routed through a non-Git arm \
16554             (a registry-fetch pin, a `DepSource::Feira` promotion) \
16555             would silently split the resolver's unpinned-shorthand \
16556             materializer from the sole_pin() precedence cascade"
16557        );
16558        assert!(
16559            !via_default_github.is_path(),
16560            "DepSource::default_github must NOT materialize a Path-arm \
16561             shape — the paired negation pin"
16562        );
16563
16564        let via_dep_git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0")
16565            .fonte
16566            .expect("Dep::git materializes a Some(fonte)");
16567        assert!(
16568            via_dep_git.is_git(),
16569            "Dep::git's `:fonte` materialization must land on the Git \
16570             arm — the author-surface pinned-git constructor's return \
16571             must route through the paired predicate"
16572        );
16573        assert!(!via_dep_git.is_path(), "paired negation pin");
16574
16575        let via_path = DepSource::Path {
16576            caminho: "../caixa-teia".into(),
16577        };
16578        assert!(
16579            via_path.is_path(),
16580            "the dev-mode Path-arm materialization must satisfy is_path()"
16581        );
16582        assert!(!via_path.is_git(), "paired negation pin");
16583    }
16584}