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::fonte_caminho_control_char(nome, caminho, b));
861            }
862        }
863        // Reproducibility gate's Windows-path-separator arm. The four
864        // leading-byte arms (`/` / `~` / `$`) and the embedded-
865        // control-byte arm close the host-layout-leaking + paste-from-
866        // multiline-doc shapes; the leading-`\` / embedded-`\` byte is
867        // the orthogonal cross-host-OS-separator shape — same render-
868        // determinism axis, different semantic mechanism. POSIX
869        // [`std::path::Path`] treats `\` (0x5C) as a literal byte
870        // inside a single path component (so `..\caixa-teia` is one
871        // directory named literally `..\caixa-teia`, sibling of `.`
872        // and `..`); Windows [`std::path::Path`] treats `\` as a
873        // primary path separator equal to `/` (so `..\caixa-teia` is
874        // the parent's sibling directory `caixa-teia`). The lacre
875        // pipeline embeds the value verbatim in its per-dep content-
876        // address (`conteudo: format!("path:{caminho}")`, caixa-
877        // resolver/src/resolve.rs:189), so byte-identical caixa.lisp
878        // values resolve to two distinct directories across runner
879        // OSes — the same THEORY.md §V.2 render-determinism contract
880        // the absolute / tilde / var arms protect, here against the
881        // cross-host-OS-separator divergence vector. Even on POSIX-
882        // only resolvers (the canonical pleme-io substrate posture),
883        // a `..\caixa-teia` (the Windows-Explorer "copy as path" /
884        // PowerShell `Get-Location` paste-idiom footgun) silently
885        // passes every prior arm because `Path::is_absolute` returns
886        // false on `..` and `\` is neither a leading-byte sentinel
887        // nor a control byte, then the resolver folds the value
888        // through `Path::new(caminho).join(<file>)` looking for a
889        // literal `./..\caixa-teia` subdirectory and fails at
890        // resolve time with a non-self-locating `No such file or
891        // directory` error far from the source caixa.lisp.
892        //
893        // The peer single-token-shaped axes on the same git-CLI /
894        // path-CLI consumer cluster already reject `\` under the same
895        // Windows-path-leak banner: [`crate::render::is_git_ref_name`]
896        // line 1441 (`"must not contain \\ … the canonical Windows-
897        // path-leak footgun; use / for hierarchical refs"`) gates
898        // `:fonte :tag` / `:fonte :branch` against the same byte,
899        // and [`crate::render::is_gateway_api_http_path`] line 506
900        // includes `\` in the eleven-byte RFC-3986-reserved rejection
901        // set on `:entrada :paths`. Closing the same byte on `:fonte
902        // :caminho` makes the substrate-wide "no Windows path
903        // separator anywhere in a typed string slot" invariant
904        // structurally consistent across every path-shaped typed
905        // surface (the `:caminho` axis was the last typed string
906        // surface still admitting `\`).
907        //
908        // The arm fires AFTER the control-char arm because the
909        // control-char diagnostic is the more self-locating axis on
910        // values that probe as both (`"..\caixa\0teia"` carries both
911        // a `\` and a NUL — NUL is the load-bearing POSIX-syscall-
912        // rejected byte, so `FonteCaminhoControlChar` wins). Same
913        // narrower-diagnostic-first cascade discipline every prior
914        // arm establishes. A pure-`\` value
915        // (`"..\caixa-teia"` with no control bytes) falls through
916        // every prior arm and lands here.
917        for &b in caminho.as_bytes() {
918            if b == b'\\' {
919                return Err(DepError::fonte_caminho_backslash(nome, caminho));
920            }
921        }
922        // Reproducibility gate's shell-redirection arm. The 3a4e1d7 backslash
923        // arm closes the cross-host-OS-separator vector; `<` (`0x3C`) and `>`
924        // (`0x3E`) are the orthogonal shell-redirection sentinels — same
925        // paste-from-shell-prompt footgun class, different syntactic surface.
926        // POSIX `std::path::Path` treats `<` / `>` as literal bytes inside a
927        // single path component (so `../caixa-teia>output` is one directory
928        // named literally `../caixa-teia>output`, sibling of `.` and `..`),
929        // but every interactive shell (bash / zsh / fish / nushell) lexes
930        // `<` / `>` as input / output redirection operators — a `:caminho
931        // "../caixa-teia>build.log"` (the canonical "I pasted a shell
932        // pipeline that wrote build output and forgot to trim the redirect"
933        // footgun) or `:caminho "../<input.lisp"` (the symmetric input-
934        // redirection paste idiom) silently passes every prior arm because
935        // `Path::is_absolute` returns false, `<` / `>` are neither leading-
936        // byte sentinels nor control bytes nor `\`, and the value's last byte
937        // isn't `/`. The resolver folds the value through
938        // `Path::new(caminho).join(<file>)` looking for a literal
939        // `./..\caixa-teia>build.log` subdirectory and fails at resolve time
940        // with a non-self-locating `No such file or directory` error far
941        // from the source caixa.lisp.
942        //
943        // The lacre pipeline embeds the value verbatim in its per-dep
944        // content-address (`conteudo: format!("path:{caminho}")`,
945        // caixa-resolver/src/resolve.rs:189), so a `<` / `>` byte lands in
946        // the BLAKE3 closure and rides downstream as part of the build's
947        // identity. The bytes carry a second class of hazard the prior
948        // separator-shaped arms don't: every typed-string slot whose value
949        // ever flows verbatim into a shell-spawned subprocess (the caixa-
950        // resolver's `git clone` invocation, a future `feira tofu` shell-
951        // out, a future operator-side `nix flake check` spawn) is the
952        // canonical CRLF-at-subprocess-argument / shell-metachar injection
953        // surface that every peer single-token-shaped typed slot already
954        // closes. The peer path-shaped axis `[crate::render::is_gateway_api_http_path]`
955        // (caixa-core/src/render.rs:506) rejects `<` / `>` as part of its
956        // eleven-byte RFC-3986-reserved set on `:entrada :paths`, and the
957        // peer git-ref-shaped axis `[crate::render::is_git_ref_name]` rejects
958        // `<` / `>` on `:fonte :tag` / `:fonte :branch` under the same
959        // shell-metachar-injection banner. The `:caminho` axis was the last
960        // typed string surface still admitting these two bytes; this arm
961        // closes the gap so the substrate-wide "no shell-redirection
962        // metacharacter anywhere in a typed string slot" invariant is now
963        // structurally consistent across every path-shaped typed surface.
964        //
965        // The arm fires AFTER the control-char arm + backslash arm because
966        // both prior arms carry more self-locating diagnostics on values
967        // that probe as both (`"..\foo<bar"` carries both `\` and `<` — the
968        // cross-OS-separator divergence is the load-bearing axis, so the
969        // backslash arm wins; `"../foo\n<bar"` carries both LF and `<` —
970        // the POSIX-syscall-rejected byte is the load-bearing axis, so the
971        // control-char arm wins). The arm fires BEFORE the trailing-`/` arm
972        // because the embedded redirection byte is the more semantic-
973        // locating axis on probe-as-both values (`"../foo</"` ends in `/`
974        // but the load-bearing diagnostic is the embedded `<` shell-
975        // redirection — the trailing `/` is the secondary observation, and
976        // an author who removes the `<` is likely to also tab-strip the
977        // trailing separator).
978        for &b in caminho.as_bytes() {
979            if b == b'<' || b == b'>' {
980                return Err(DepError::fonte_caminho_shell_redirection(nome, caminho, b));
981            }
982        }
983        // Reproducibility gate's shell-pipe arm. The e457141 shell-redirection
984        // arm closes the `<` / `>` input/output redirection sentinels; `|`
985        // (`0x7C`) is the orthogonal shell-pipe sentinel — same paste-from-
986        // shell-prompt footgun class, different syntactic surface. POSIX
987        // `std::path::Path` treats `|` as a literal path-component byte (so
988        // `../caixa-teia|tee` is one directory named literally
989        // `../caixa-teia|tee`, sibling of `.` and `..`), but every interactive
990        // shell (bash / zsh / fish / nushell) lexes `|` as the pipe operator
991        // — a `:caminho "../caixa-teia | grep foo"` (the canonical "I copied a
992        // `ls ../caixa-teia | grep` line out of a shell-history block and
993        // forgot to trim the pipeline tail" footgun) or `:caminho
994        // "../foo||bar"` (the symmetric "I copied a `cmd-a || cmd-b` short-
995        // circuit OR line" idiom) silently passes every prior arm because
996        // `Path::is_absolute` returns false on `..`, `|` is neither a leading-
997        // byte sentinel nor a control byte nor `\` nor `<` / `>`, and the
998        // value's last byte isn't `/`. The resolver folds the value through
999        // `Path::new(caminho).join(<file>)` looking for a literal
1000        // `./../caixa-teia | grep foo` subdirectory and fails at resolve time
1001        // with a non-self-locating `No such file or directory` error far
1002        // from the source caixa.lisp.
1003        //
1004        // The lacre pipeline embeds the value verbatim in its per-dep
1005        // content-address (`conteudo: format!("path:{caminho}")`,
1006        // caixa-resolver/src/resolve.rs:189), so a `|` byte lands in the
1007        // BLAKE3 closure and rides downstream as part of the build's identity
1008        // into every shell-spawned subprocess (the caixa-resolver's `git
1009        // clone` invocation, a future `feira tofu` shell-out, a future
1010        // operator-side `nix flake check` spawn) as the canonical CRLF-at-
1011        // subprocess-argument / shell-metachar injection surface every peer
1012        // single-token-shaped typed slot already closes. The peer path-shaped
1013        // axis [`crate::render::is_gateway_api_http_path`]
1014        // (caixa-core/src/render.rs:506) rejects `|` as part of its eleven-
1015        // byte RFC-3986-reserved set on `:entrada :paths`. The `:caminho`
1016        // axis was the last typed path-string surface still admitting this
1017        // byte; this arm closes the gap so the substrate-wide "no shell-
1018        // composition metacharacter anywhere in a typed string slot that
1019        // flows verbatim into a shell-spawned subprocess" invariant extends
1020        // from shell-redirection (`<` / `>`) to shell-pipe (`|`) on the
1021        // `:caminho` axis.
1022        //
1023        // The arm fires AFTER the shell-redirection arm because the prior
1024        // arm's two-byte `byte: u8` payload is the more self-locating axis on
1025        // values that probe as both (`"../caixa-teia<input|tee"` carries both
1026        // `<` and `|` — the input-redirection-paste idiom is the load-bearing
1027        // root-cause edit, so `FonteCaminhoShellRedirection` wins; same
1028        // cascade discipline every prior `:caminho` arm establishes). The arm
1029        // fires BEFORE the trailing-`/` arm because the embedded pipe byte is
1030        // the more semantic-locating axis on probe-as-both values
1031        // (`"../foo|tee/"` ends in `/` but the load-bearing diagnostic is the
1032        // embedded `|` shell-pipe — the trailing `/` is the secondary
1033        // observation, and an author who removes the `|` is likely to also
1034        // tab-strip the trailing separator).
1035        for &b in caminho.as_bytes() {
1036            if b == b'|' {
1037                return Err(DepError::fonte_caminho_shell_pipe(nome, caminho));
1038            }
1039        }
1040        // Reproducibility gate's shell-command-separator arm. The 124106f
1041        // shell-pipe arm closes the `|` byte; `;` (`0x3B`) is the orthogonal
1042        // shell-command-separator sentinel — same paste-from-shell-prompt
1043        // footgun class, different syntactic surface. POSIX `std::path::Path`
1044        // treats `;` as a literal path-component byte (so
1045        // `../caixa-teia;rm -rf /` is one directory named literally
1046        // `../caixa-teia;rm -rf /`, sibling of `.` and `..`), but every
1047        // interactive shell (bash / zsh / fish / nushell) lexes `;` as the
1048        // sequential-command terminator that fires the next command
1049        // regardless of the prior command's exit status — a `:caminho
1050        // "../caixa-teia; rm -rf build"` (the canonical "I pasted a shell
1051        // one-liner that chained a cleanup tail after the directory name"
1052        // footgun) or `:caminho "../foo;;bar"` (the symmetric "I copied a
1053        // POSIX `case` arm's `;;` terminator into the middle of a path"
1054        // idiom) silently passes every prior arm because `Path::is_absolute`
1055        // returns false on `..`, `;` is neither a leading-byte sentinel nor a
1056        // control byte nor `\` nor `<` / `>` nor `|`, and the value's last
1057        // byte isn't `/`. The resolver folds the value through
1058        // `Path::new(caminho).join(<file>)` looking for a literal
1059        // `./../caixa-teia; rm -rf build` subdirectory and fails at resolve
1060        // time with a non-self-locating `No such file or directory` error far
1061        // from the source caixa.lisp.
1062        //
1063        // The lacre pipeline embeds the value verbatim in its per-dep
1064        // content-address (`conteudo: format!("path:{caminho}")`,
1065        // caixa-resolver/src/resolve.rs:189), so a `;` byte lands in the
1066        // BLAKE3 closure and rides downstream as part of the build's identity
1067        // into every shell-spawned subprocess (the caixa-resolver's `git
1068        // clone` invocation, a future `feira tofu` shell-out, a future
1069        // operator-side `nix flake check` spawn) as the canonical
1070        // shell-metachar injection surface every peer single-token-shaped
1071        // typed slot already closes. The peer path-shaped axis
1072        // [`crate::render::is_gateway_api_http_path`]
1073        // (caixa-core/src/render.rs:506) rejects `;` as part of its eleven-
1074        // byte RFC-3986-reserved set on `:entrada :paths`. The `:caminho`
1075        // axis was the last typed path-string surface still admitting this
1076        // byte; this arm closes the gap so the substrate-wide "no shell-
1077        // composition metacharacter anywhere in a typed string slot that
1078        // flows verbatim into a shell-spawned subprocess" invariant extends
1079        // from shell-pipe (`|`) to shell-command-separator (`;`) on the
1080        // `:caminho` axis.
1081        //
1082        // The arm fires AFTER the shell-pipe arm because the prior arm's
1083        // canonical-cmd-a-|-cmd-b shape is the more common shell-history
1084        // paste idiom on values that probe as both (`"../caixa-teia | tee;
1085        // rm"` carries both `|` and `;` — the pipeline-tail paste is the
1086        // load-bearing root-cause edit, so `FonteCaminhoShellPipe` wins; same
1087        // cascade discipline every prior `:caminho` arm establishes). The arm
1088        // fires BEFORE the trailing-`/` arm because the embedded
1089        // command-separator byte is the more semantic-locating axis on
1090        // probe-as-both values (`"../foo;rm/"` ends in `/` but the
1091        // load-bearing diagnostic is the embedded `;` shell-command-
1092        // separator — the trailing `/` is the secondary observation, and an
1093        // author who removes the `;` is likely to also tab-strip the trailing
1094        // separator).
1095        for &b in caminho.as_bytes() {
1096            if b == b';' {
1097                return Err(DepError::fonte_caminho_shell_semicolon(nome, caminho));
1098            }
1099        }
1100        // Reproducibility gate's shell-background / logical-AND arm. The
1101        // 05c358e shell-command-separator arm closes the `;` byte; `&`
1102        // (`0x26`) is the orthogonal shell-background / list-AND sentinel
1103        // — same paste-from-shell-prompt footgun class, different
1104        // syntactic surface. POSIX `std::path::Path` treats `&` as a
1105        // literal path-component byte (so `../caixa-teia & sleep 1` is
1106        // one directory named literally `../caixa-teia & sleep 1`,
1107        // sibling of `.` and `..`), but every interactive shell
1108        // (bash / zsh / fish / nushell) lexes `&` two ways:
1109        //
1110        //   - Single `&` as the background-task terminator that detaches
1111        //     the prior command into the background and returns control
1112        //     to the prompt immediately (the canonical `cmd &` idiom
1113        //     every long-running pipeline uses);
1114        //   - Double `&&` as the logical-AND list operator that fires
1115        //     the next command only if the prior command succeeded (the
1116        //     canonical `make && make install` idiom every build script
1117        //     carries).
1118        //
1119        // A `:caminho "../caixa-teia & sleep 1"` (the canonical "I
1120        // pasted a `cd path & sleep 1` background-launch into the
1121        // `:caminho` slot" footgun) or `:caminho "../caixa-teia && make"`
1122        // (the symmetric "I copied a `cd path && make` build chain"
1123        // idiom) silently passes every prior arm because
1124        // `Path::is_absolute` returns false on `..`, `&` is neither a
1125        // leading-byte sentinel nor a control byte nor `\` nor
1126        // `<` / `>` nor `|` nor `;`, and the value's last byte isn't `/`.
1127        // The resolver folds the value through
1128        // `Path::new(caminho).join(<file>)` looking for a literal
1129        // `./../caixa-teia & sleep 1` subdirectory and fails at resolve
1130        // time with a non-self-locating `No such file or directory`
1131        // error far from the source caixa.lisp.
1132        //
1133        // The lacre pipeline embeds the value verbatim in its per-dep
1134        // content-address (`conteudo: format!("path:{caminho}")`,
1135        // caixa-resolver/src/resolve.rs:189), so an `&` byte lands in
1136        // the BLAKE3 closure and rides downstream as part of the build's
1137        // identity into every shell-spawned subprocess (the
1138        // caixa-resolver's `git clone` invocation, a future `feira tofu`
1139        // shell-out, a future operator-side `nix flake check` spawn) as
1140        // the canonical shell-metachar injection surface every peer
1141        // single-token-shaped typed slot already closes. The peer
1142        // path-shaped axis [`crate::render::is_gateway_api_http_path`]
1143        // (caixa-core/src/render.rs:506) rejects `&` as part of its
1144        // eleven-byte RFC-3986-reserved set on `:entrada :paths`. The
1145        // `:caminho` axis was the last typed path-string surface still
1146        // admitting this byte; this arm closes the gap so the
1147        // substrate-wide "no shell-composition metacharacter anywhere
1148        // in a typed string slot that flows verbatim into a
1149        // shell-spawned subprocess" invariant extends from
1150        // shell-command-separator (`;`) to shell-background /
1151        // logical-AND (`&`) on the `:caminho` axis.
1152        //
1153        // The arm fires AFTER the shell-command-separator arm because
1154        // the prior arm's `cmd-a; cmd-b` shape is the more common
1155        // shell-history paste idiom on values that probe as both
1156        // (`"../caixa-teia; rm & sleep"` carries both `;` and `&` — the
1157        // command-separator-tail paste is the load-bearing root-cause
1158        // edit, so `FonteCaminhoShellSemicolon` wins; same cascade
1159        // discipline every prior `:caminho` arm establishes). The arm
1160        // fires BEFORE the trailing-`/` arm because the embedded
1161        // background / list-AND byte is the more semantic-locating axis
1162        // on probe-as-both values (`"../foo&bar/"` ends in `/` but the
1163        // load-bearing diagnostic is the embedded `&` shell-background
1164        // / logical-AND metachar — the trailing `/` is the secondary
1165        // observation, and an author who removes the `&` is likely to
1166        // also tab-strip the trailing separator).
1167        for &b in caminho.as_bytes() {
1168            if b == b'&' {
1169                return Err(DepError::fonte_caminho_shell_background(nome, caminho));
1170            }
1171        }
1172        // Reproducibility gate's shell-command-substitution arm. The
1173        // e12e4f3 shell-background / logical-AND arm closes the `&`
1174        // byte; the backtick (`0x60`) is the orthogonal POSIX legacy
1175        // command-substitution sentinel — every POSIX shell (sh /
1176        // bash / zsh / dash / ksh / fish / nushell) lexes the byte as
1177        // the canonical legacy wrapper that runs the enclosed command
1178        // and substitutes its standard-output verbatim into the
1179        // surrounding word (a `whoami` wrapped in backticks expands
1180        // to the current user's name; a `cat /etc/passwd` wrapped in
1181        // backticks expands to the file's contents — the canonical
1182        // CWE-78 shell-command-injection vector every shell-side
1183        // hardening guide enumerates first). POSIX
1184        // `std::path::Path` treats backtick as a literal path-
1185        // component byte (so `../caixa-teia/<backtick>whoami<backtick>`
1186        // is one directory named literally that, sibling of `.` and
1187        // `..`).
1188        //
1189        // A `:caminho "../caixa-teia/<backtick>whoami<backtick>"` (the
1190        // canonical "I pasted a shell one-liner carrying a backticked
1191        // `whoami` command-substitution expansion into the `:caminho`
1192        // slot" footgun) or `:caminho "<backtick>pwd<backtick>/caixa-
1193        // teia"` (the symmetric "I copied a `<backtick>pwd<backtick>/
1194        // path` working-directory expansion") silently passes every
1195        // prior arm because `Path::is_absolute` returns false on
1196        // `..`, the backtick byte is neither a leading-byte sentinel
1197        // (the f4efe9c `FonteCaminhoVarExpansion` arm catches the
1198        // modern `$()` form at leading position only; backtick is
1199        // the orthogonal legacy form) nor a control byte nor `\` nor
1200        // `<` / `>` nor `|` nor `;` nor `&`, and the value's last
1201        // byte isn't `/`. The resolver folds the value through
1202        // `Path::new(caminho).join(<file>)` looking for a literal
1203        // subdirectory whose name embeds the backticked token and
1204        // fails at resolve time with a non-self-locating `No such
1205        // file or directory` error far from the source caixa.lisp.
1206        //
1207        // The lacre pipeline embeds the value verbatim in its per-
1208        // dep content-address (`conteudo: format!("path:{caminho}")`,
1209        // caixa-resolver/src/resolve.rs:189), so a backtick byte
1210        // lands in the BLAKE3 closure and rides downstream as part
1211        // of the build's identity into every shell-spawned
1212        // subprocess (the caixa-resolver's `git clone` invocation, a
1213        // future `feira tofu` shell-out, a future operator-side
1214        // `nix flake check` spawn) as the canonical shell-metachar
1215        // injection surface every peer single-token-shaped typed
1216        // slot already closes. The peer path-shaped axis
1217        // [`crate::render::is_gateway_api_http_path`]
1218        // (caixa-core/src/render.rs:506) rejects backtick as part of
1219        // its eleven-byte RFC-3986-reserved set on `:entrada
1220        // :paths`. The `:caminho` axis was the last typed path-
1221        // string surface still admitting this byte; this arm closes
1222        // the gap so the substrate-wide "no shell-composition
1223        // metacharacter anywhere in a typed string slot that flows
1224        // verbatim into a shell-spawned subprocess" invariant
1225        // extends from shell-background / logical-AND (`&`) to
1226        // shell-command-substitution (backtick) on the `:caminho`
1227        // axis.
1228        //
1229        // The arm fires AFTER the shell-background arm because the
1230        // prior arm's `cmd & sleep` shape is the more common shell-
1231        // history paste idiom on values that probe as both (a
1232        // `"../caixa-teia & <backtick>whoami<backtick>"` carries
1233        // both `&` and a backtick — the background-launch tail is
1234        // the load-bearing root-cause edit, so
1235        // `FonteCaminhoShellBackground` wins; same cascade
1236        // discipline every prior `:caminho` arm establishes). The
1237        // arm fires BEFORE the trailing-`/` arm because the
1238        // embedded command-substitution byte is the more semantic-
1239        // locating axis on probe-as-both values (a
1240        // `"../<backtick>whoami<backtick>/"` ends in `/` but the
1241        // load-bearing diagnostic is the embedded backtick shell-
1242        // command-substitution metachar — the trailing `/` is the
1243        // secondary observation, and an author who removes the
1244        // backtick is likely to also tab-strip the trailing
1245        // separator).
1246        for &b in caminho.as_bytes() {
1247            if b == b'`' {
1248                return Err(DepError::fonte_caminho_shell_command_substitution(
1249                    nome, caminho,
1250                ));
1251            }
1252        }
1253        // Reproducibility gate's shell-glob arm. The c4d62b3 shell-command-
1254        // substitution arm closes the backtick byte; `*` (`0x2A`) and `?`
1255        // (`0x3F`) are the orthogonal POSIX glob-expansion sentinels — same
1256        // paste-from-shell-prompt footgun class, different syntactic surface.
1257        // Every POSIX shell (sh / bash / zsh / dash / ksh / fish / nushell)
1258        // lexes `*` and `?` as pathname-expansion wildcards: `*` matches any
1259        // sequence of characters in a path component (including the empty
1260        // sequence), `?` matches exactly one character. POSIX
1261        // `std::path::Path` treats both bytes as literal path-component bytes
1262        // (so `../caixa-teia/*.lisp` is one directory named literally
1263        // `../caixa-teia/*.lisp`, sibling of `.` and `..`).
1264        //
1265        // A `:caminho "../caixa-teia/*"` (the canonical "I pasted a
1266        // `ls ../caixa-teia/*` shell-listing one-liner into the `:caminho`
1267        // slot" footgun) or `:caminho "../foo?"` (the symmetric "I copied a
1268        // `rm foo?` single-char-wildcard removal idiom") silently passes
1269        // every prior arm because `Path::is_absolute` returns false on `..`,
1270        // `*` / `?` are neither leading-byte sentinels nor control bytes nor
1271        // `\` nor `<` / `>` nor `|` nor `;` nor `&` nor backtick, and the
1272        // value's last byte isn't `/`. The resolver folds the value through
1273        // `Path::new(caminho).join(<file>)` looking for a literal
1274        // `./../caixa-teia/*` subdirectory and fails at resolve time with a
1275        // non-self-locating `No such file or directory` error far from the
1276        // source caixa.lisp.
1277        //
1278        // The lacre pipeline embeds the value verbatim in its per-dep
1279        // content-address (`conteudo: format!("path:{caminho}")`,
1280        // caixa-resolver/src/resolve.rs:189), so a `*` or `?` byte lands in
1281        // the BLAKE3 closure and rides downstream as part of the build's
1282        // identity into every shell-spawned subprocess (the caixa-resolver's
1283        // `git clone` invocation, a future `feira tofu` shell-out, a future
1284        // operator-side `nix flake check` spawn) as the canonical
1285        // shell-metachar / pathname-expansion surface every peer
1286        // single-token-shaped typed slot already closes. The peer path-shaped
1287        // axis [`crate::render::is_gateway_api_http_path`]
1288        // (caixa-core/src/render.rs:506) rejects `*` and `?` as part of its
1289        // eleven-byte RFC-3986-reserved set on `:entrada :paths`. The
1290        // `:caminho` axis was the last typed path-string surface still
1291        // admitting these two bytes; this arm closes the gap so the
1292        // substrate-wide "no shell-composition / glob-expansion
1293        // metacharacter anywhere in a typed string slot that flows verbatim
1294        // into a shell-spawned subprocess" invariant extends from
1295        // shell-command-substitution (backtick) to glob-expansion
1296        // (`*` / `?`) on the `:caminho` axis.
1297        //
1298        // The arm fires AFTER the backtick arm because the prior arm's
1299        // CWE-78 shell-command-injection vector is the load-bearing
1300        // diagnostic on values that probe as both (a `"../`whoami`/*"`
1301        // carries both backtick and `*` — the command-substitution paste
1302        // is the load-bearing root-cause edit, so
1303        // `FonteCaminhoShellCommandSubstitution` wins; same cascade
1304        // discipline every prior `:caminho` arm establishes). The arm
1305        // fires BEFORE the trailing-`/` arm because the embedded glob
1306        // byte is the more semantic-locating axis on probe-as-both values
1307        // (`"../foo*/"` ends in `/` but the load-bearing diagnostic is the
1308        // embedded `*` glob metachar — the trailing `/` is the secondary
1309        // observation, and an author who removes the `*` is likely to
1310        // also tab-strip the trailing separator).
1311        for &b in caminho.as_bytes() {
1312            if b == b'*' || b == b'?' {
1313                return Err(DepError::fonte_caminho_shell_glob(nome, caminho, b));
1314            }
1315        }
1316        // Reproducibility gate's shell-subshell-grouping arm. The cf9034b
1317        // shell-glob arm closes the `*` / `?` pathname-expansion sentinels;
1318        // `(` (`0x28`) and `)` (`0x29`) are the orthogonal POSIX subshell-
1319        // grouping sentinels — same paste-from-shell-prompt footgun class,
1320        // different syntactic surface. Every POSIX shell (sh / bash / zsh /
1321        // dash / ksh / fish / nushell) lexes the parenthesis pair as the
1322        // subshell-grouping operator: `(<cmd>)` runs `<cmd>` in a child
1323        // shell with a fresh environment scope (the canonical sandboxing
1324        // idiom every shell-history `(cd <path> && <cmd>)` one-liner uses
1325        // to scope a `cd` to one subshell without disturbing the parent's
1326        // working directory), and `$(<cmd>)` is the modern Bourne
1327        // command-substitution shape the upstream f4efe9c
1328        // `FonteCaminhoVarExpansion` arm closes the leading `$` byte of —
1329        // the closing `)` byte completes that substitution shape and must
1330        // be refused on the same axis (peer with the
1331        // [`crate::render::is_git_repo_url`] 3b99147 arm that closes the
1332        // same byte-pair on the sibling `:fonte :repo` axis under the
1333        // same shell-subshell-grouping + RFC-3986-sub-delims banner).
1334        // POSIX `std::path::Path` treats both bytes as literal path-
1335        // component bytes (so `../caixa-teia/(date)` is one directory
1336        // named literally `../caixa-teia/(date)`, sibling of `.` and
1337        // `..`).
1338        //
1339        // A `:caminho "../caixa-teia/$(date)/build"` (the canonical "I
1340        // pasted a `cd ../caixa-teia/$(date)/build` shell-history one-
1341        // liner whose modern command-substitution expansion lands the
1342        // current date as a subdirectory name" footgun) or `:caminho
1343        // "../(cd foo && pwd)/caixa-teia"` (the symmetric "I copied a
1344        // `(cd foo && pwd)` subshell-grouping working-directory probe
1345        // idiom") silently passes every prior arm because
1346        // `Path::is_absolute` returns false on `..`, `(` / `)` are
1347        // neither leading-byte sentinels nor control bytes nor `\` nor
1348        // `<` / `>` nor `|` nor `;` nor `&` nor backtick nor `*` / `?`,
1349        // and the value's last byte isn't `/`. The resolver folds the
1350        // value through `Path::new(caminho).join(<file>)` looking for a
1351        // literal `./../caixa-teia/$(date)/build` subdirectory and fails
1352        // at resolve time with a non-self-locating `No such file or
1353        // directory` error far from the source caixa.lisp.
1354        //
1355        // The lacre pipeline embeds the value verbatim in its per-dep
1356        // content-address (`conteudo: format!("path:{caminho}")`,
1357        // caixa-resolver/src/resolve.rs:189), so a `(` or `)` byte lands
1358        // in the BLAKE3 closure and rides downstream as part of the
1359        // build's identity into every shell-spawned subprocess (the
1360        // caixa-resolver's `git clone` invocation, a future `feira tofu`
1361        // shell-out, a future operator-side `nix flake check` spawn) as
1362        // the canonical shell-metachar / subshell-grouping surface every
1363        // peer single-token-shaped typed slot already closes. The peer
1364        // git-source axis [`crate::render::is_git_repo_url`] (3b99147)
1365        // rejects the same byte pair on `:fonte :repo` under the same
1366        // shell-subshell-grouping / RFC-3986-sub-delims banner. The
1367        // `:caminho` axis was the last typed path-string surface still
1368        // admitting these two bytes;
1369        // this arm closes the gap so the substrate-wide "no shell-
1370        // composition metacharacter anywhere in a typed string slot that
1371        // flows verbatim into a shell-spawned subprocess" invariant
1372        // extends from shell-glob (`*` / `?`) to shell-subshell-grouping
1373        // (`(` / `)`) on the `:caminho` axis. Together with the f4efe9c
1374        // leading-`$` arm, the typed `:caminho` accepted set now
1375        // structurally excludes the entire modern Bourne
1376        // command-substitution surface — leading `$` closes the
1377        // leading byte of every `$(<cmd>)` shape, this arm closes the
1378        // trailing `)` boundary.
1379        //
1380        // The arm fires AFTER the shell-glob arm because the prior arm's
1381        // `*` / `?` pathname-expansion shape is the more common shell-
1382        // history paste idiom on values that probe as both
1383        // (`"../caixa-teia/*(date)"` carries both `*` and `(` — the
1384        // glob-paste-tail is the load-bearing root-cause edit, so
1385        // `FonteCaminhoShellGlob` wins; same cascade discipline every
1386        // prior `:caminho` arm establishes). The arm fires BEFORE the
1387        // trailing-`/` arm because the embedded subshell-grouping byte
1388        // is the more semantic-locating axis on probe-as-both values
1389        // (`"../foo(date)/"` ends in `/` but the load-bearing diagnostic
1390        // is the embedded `(` shell-subshell-grouping metachar — the
1391        // trailing `/` is the secondary observation, and an author who
1392        // removes the `(` is likely to also tab-strip the trailing
1393        // separator).
1394        for &b in caminho.as_bytes() {
1395            if b == b'(' || b == b')' {
1396                return Err(DepError::fonte_caminho_shell_subshell_grouping(
1397                    nome, caminho, b,
1398                ));
1399            }
1400        }
1401        // Reproducibility gate's shell-brace-expansion arm. The 0633c91
1402        // shell-subshell-grouping arm closes `(` / `)`; `{` (`0x7b`) and
1403        // `}` (`0x7d`) are the orthogonal shell-brace-expansion /
1404        // URI-Template-placeholder byte pair — same paste-from-shell-
1405        // prompt + paste-from-templated-doc footgun class, different
1406        // syntactic surface. Every POSIX-derived shell that implements
1407        // brace expansion (bash / zsh / ksh / fish; the canonical
1408        // `mkdir -p ../{caixa-teia,caixa-helm,caixa-flux}` /
1409        // `cp file{,.bak}` idiom every shell-history block carries)
1410        // expands `{a,b,c}` to the cross-product of its comma-separated
1411        // members and `{1..10}` to the integer range; RFC 6570 reserves
1412        // the matched pair for URI Template placeholders (the canonical
1413        // `https://{host}/{org}/{repo}` substitution shape every
1414        // OpenAPI / Swagger / Postman / GitHub Octokit client /
1415        // Helm chart-URL fragment / Mustache `{{org}}` doubled-brace
1416        // form carries), and Tera / Jinja2 / Handlebars / Go html/template
1417        // every IaC tool (Helm, Kustomize, Terraform's `${var}` cousin
1418        // shape) emit. POSIX `std::path::Path` treats both bytes as
1419        // literal path-component bytes (so `../{caixa-teia,caixa-helm}`
1420        // is one directory named literally `../{caixa-teia,caixa-helm}`,
1421        // sibling of `.` and `..`).
1422        //
1423        // A `:caminho "../{caixa-teia,caixa-helm}/build"` (the canonical
1424        // "I pasted a `cd ../{caixa-teia,caixa-helm}` shell brace-
1425        // expansion one-liner that fans across two siblings" footgun)
1426        // or `:caminho "../{{org}}/caixa-teia"` (the symmetric "I copied
1427        // a `{{org}}` Mustache / Helm template placeholder out of a
1428        // README quick-start and forgot to substitute") silently passes
1429        // every prior arm because `Path::is_absolute` returns false on
1430        // `..`, `{` / `}` are neither leading-byte sentinels nor control
1431        // bytes nor `\` nor `<` / `>` nor `|` nor `;` nor `&` nor
1432        // backtick nor `*` / `?` nor `(` / `)`, and the value's last
1433        // byte isn't `/`. The resolver folds the value through
1434        // `Path::new(caminho).join(<file>)` looking for a literal
1435        // `./../{caixa-teia,caixa-helm}/build` subdirectory and fails
1436        // at resolve time with a non-self-locating `No such file or
1437        // directory` error far from the source caixa.lisp.
1438        //
1439        // The lacre pipeline embeds the value verbatim in its per-dep
1440        // content-address (`conteudo: format!("path:{caminho}")`,
1441        // caixa-resolver/src/resolve.rs:189), so a `{` or `}` byte
1442        // lands in the BLAKE3 closure and rides downstream as part of
1443        // the build's identity into every shell-spawned subprocess
1444        // (the caixa-resolver's `git clone` invocation, a future
1445        // `feira tofu` shell-out, a future operator-side `nix flake
1446        // check` spawn) as the canonical shell-metachar / brace-
1447        // expansion surface every peer single-token-shaped typed
1448        // slot already closes. The peer git-source axis
1449        // [`crate::render::is_git_repo_url`] (42d8f9d — the URI Template
1450        // placeholder arm) rejects the same byte pair on `:fonte :repo`
1451        // under the same RFC-3986-'delims' / RFC-6570-URI-Template /
1452        // shell-brace-expansion banner. The `:caminho` axis was the last
1453        // typed path-string surface still admitting these two bytes;
1454        // this arm closes the gap so the substrate-wide "no shell-
1455        // composition metacharacter anywhere in a typed string slot
1456        // that flows verbatim into a shell-spawned subprocess"
1457        // invariant extends from shell-subshell-grouping (`(` / `)`)
1458        // to shell-brace-expansion (`{` / `}`) on the `:caminho` axis,
1459        // and the typed `:caminho` accepted set now also structurally
1460        // excludes the URI Template / templating-engine placeholder
1461        // surface that would silently round-trip through any
1462        // downstream IaC templating-engine layer.
1463        //
1464        // The arm fires AFTER the shell-subshell-grouping arm because
1465        // the prior arm's `(` / `)` shape is the more semantic-locating
1466        // axis on values that probe as both (`"../{cd foo}(date)"`
1467        // carries both `{` and `(` — the parenthesis-pair is the
1468        // load-bearing modern-Bourne-command-substitution surface the
1469        // prior arm closes; same cascade discipline every prior
1470        // `:caminho` arm establishes). The arm fires BEFORE the
1471        // trailing-`/` arm because the embedded brace-expansion byte
1472        // is the more semantic-locating axis on probe-as-both values
1473        // (`"../{caixa-teia,caixa-helm}/"` ends in `/` but the
1474        // load-bearing diagnostic is the embedded `{` brace-expansion
1475        // metachar — the trailing `/` is the secondary observation,
1476        // and an author who removes the `{` is likely to also tab-
1477        // strip the trailing separator).
1478        for &b in caminho.as_bytes() {
1479            if b == b'{' || b == b'}' {
1480                return Err(DepError::fonte_caminho_shell_brace_expansion(
1481                    nome, caminho, b,
1482                ));
1483            }
1484        }
1485        // Reproducibility gate's shell-bracket-expansion arm. The 598b770
1486        // shell-brace-expansion arm closes `{` / `}`; `[` (`0x5b`) and
1487        // `]` (`0x5d`) are the orthogonal POSIX glob-character-class /
1488        // shell-`test`-builtin byte pair — same paste-from-shell-prompt
1489        // footgun class, different syntactic surface. Every POSIX shell
1490        // (sh / bash / zsh / dash / ksh / fish / nushell) lexes the
1491        // bracket pair as the glob character-class operator: `[abc]`
1492        // matches one of `a`, `b`, `c`; `[a-z]` matches any lowercase
1493        // ASCII letter; `[^x]` negates (the canonical
1494        // `ls *.[ch]` C-source-file glob and the `cd ../[a-z]*`
1495        // lowercase-sibling glob every shell-history block carries —
1496        // the orthogonal axis to the cf9034b `*` / `?` shell-glob arm
1497        // closing the unbounded pathname-expansion sentinels). The
1498        // bracket pair additionally carries the POSIX `test` /
1499        // `[` builtin command (`[ -d ../caixa-teia ] && cd ...` —
1500        // the canonical idiom every shell-script conditional uses) and
1501        // bash's `[[ ... ]]` extended-test grammar. Beyond shell, the
1502        // bracket pair is the TOML inline-array delimiter
1503        // (`features = ["a", "b"]` — the canonical paste-from-Cargo-
1504        // manifest cross-idiom-leak vector), the YAML flow-sequence
1505        // delimiter (`paths: [/a, /b]` — the canonical paste-from-
1506        // values.yaml cross-idiom leak), the JSON array delimiter,
1507        // and the POSIX-ERE / PCRE bracket-expression / character-
1508        // class anchor (the canonical paste-from-regex-doc shape).
1509        // POSIX `std::path::Path` treats both bytes as literal path-
1510        // component bytes (so `../[caixa-teia]` is one directory
1511        // named literally `../[caixa-teia]`, sibling of `.` and
1512        // `..`).
1513        //
1514        // A `:caminho "../caixa-[a-z]/build"` (the canonical "I
1515        // pasted a `cd ../caixa-[a-z]/build` glob-character-class
1516        // one-liner that matches every lowercase-sibling-suffix
1517        // sibling directory" footgun), `:caminho "../[caixa-teia]/
1518        // build"` (the symmetric "I pasted a TOML inline-array /
1519        // YAML flow-sequence shape out of an aligned manifest"
1520        // idiom), or `:caminho "../caixa-[ch]"` (the canonical
1521        // `*.[ch]` C-source character-class paste-from-shell-history
1522        // shape) silently passes every prior arm because
1523        // `Path::is_absolute` returns false on `..`, `[` / `]` are
1524        // neither leading-byte sentinels nor control bytes nor `\`
1525        // nor `<` / `>` nor `|` nor `;` nor `&` nor backtick nor
1526        // `*` / `?` nor `(` / `)` nor `{` / `}`, and the value's
1527        // last byte isn't `/`. The resolver folds the value through
1528        // `Path::new(caminho).join(<file>)` looking for a literal
1529        // `./../caixa-[a-z]/build` subdirectory and fails at resolve
1530        // time with a non-self-locating `No such file or directory`
1531        // error far from the source caixa.lisp.
1532        //
1533        // The lacre pipeline embeds the value verbatim in its per-dep
1534        // content-address (`conteudo: format!("path:{caminho}")`,
1535        // caixa-resolver/src/resolve.rs:189), so a `[` or `]` byte
1536        // lands in the BLAKE3 closure and rides downstream as part of
1537        // the build's identity into every shell-spawned subprocess
1538        // (the caixa-resolver's `git clone` invocation, a future
1539        // `feira tofu` shell-out, a future operator-side `nix flake
1540        // check` spawn) as the canonical shell-metachar / glob-
1541        // character-class / TOML-array surface every peer single-
1542        // token-shaped typed slot already closes. The `:caminho` axis
1543        // was the last typed path-string surface still admitting
1544        // these two bytes; this arm closes the gap so the substrate-
1545        // wide "no shell-composition metacharacter anywhere in a
1546        // typed string slot that flows verbatim into a shell-spawned
1547        // subprocess" invariant extends from shell-brace-expansion
1548        // (`{` / `}`) to shell-bracket-expansion (`[` / `]`) on the
1549        // `:caminho` axis. Together with the cf9034b `*` / `?` arm,
1550        // the typed `:caminho` accepted set now structurally excludes
1551        // the entire POSIX pathname-expansion / glob surface —
1552        // unbounded glob (`*` / `?`) AND bounded character-class
1553        // (`[abc]` / `[a-z]`).
1554        //
1555        // The arm fires AFTER the shell-brace-expansion arm because
1556        // the prior arm's `{` / `}` shape is the more semantic-
1557        // locating axis on values that probe as both
1558        // (`"../{a,b}[ch]"` carries both `{` and `[` — the brace-
1559        // expansion fan is the load-bearing root-cause edit, so
1560        // `FonteCaminhoShellBraceExpansion` wins; same cascade
1561        // discipline every prior `:caminho` arm establishes). The arm
1562        // fires BEFORE the trailing-`/` arm because the embedded
1563        // bracket-expansion byte is the more semantic-locating axis
1564        // on probe-as-both values (`"../[a-z]/"` ends in `/` but the
1565        // load-bearing diagnostic is the embedded `[` glob-character-
1566        // class metachar — the trailing `/` is the secondary
1567        // observation, and an author who removes the `[` is likely
1568        // to also tab-strip the trailing separator).
1569        for &b in caminho.as_bytes() {
1570            if b == b'[' || b == b']' {
1571                return Err(DepError::fonte_caminho_shell_bracket_expansion(
1572                    nome, caminho, b,
1573                ));
1574            }
1575        }
1576        // Reproducibility gate's shell-quote-grouping arm. The 986963b
1577        // shell-bracket-expansion arm closes `[` / `]`; `'` (`0x27`) and
1578        // `"` (`0x22`) are the orthogonal POSIX shell-string-literal
1579        // delimiter pair — same paste-from-shell-prompt footgun class,
1580        // different syntactic surface. Every POSIX shell (sh / bash /
1581        // zsh / dash / ksh / fish / nushell) lexes the pair as the
1582        // string-literal quoting operator: `'…'` is the strong
1583        // (no-expansion) single-quoted string and `"…"` is the weak
1584        // (variable-/command-substitution-preserving) double-quoted
1585        // string — the canonical `cd '../caixa-teia'` shell-history
1586        // idiom every path-with-embedded-whitespace paste block carries,
1587        // and the symmetric `git clone "$REPO"` weak-quoted CI-manifest
1588        // shape. Beyond shell, the two bytes carry the JSON string-literal
1589        // delimiter (`"key": "value"` — the canonical paste-from-JSON-
1590        // config cross-idiom-leak vector), the YAML double-quoted +
1591        // single-quoted flow-scalar delimiters (`path: "../caixa-teia"`
1592        // — the canonical paste-from-values.yaml / paste-from-K8s-YAML-
1593        // manifest cross-idiom leak), the TOML basic + literal string
1594        // delimiters (`path = "../caixa-teia"` — the canonical paste-
1595        // from-Cargo-manifest cross-idiom-leak vector), the tatara-lisp
1596        // string-literal delimiter itself (`(:caminho "../caixa-teia")`
1597        // — the canonical "I copied the entire `:caminho "..."` slot
1598        // rather than just the string body" author-surface footgun),
1599        // and RFC 3986 §2.2's `gen-delims` / `sub-delims` grammar which
1600        // excludes both bytes from the `unreserved / pct-encoded /
1601        // sub-delims / ":" / "@"` `pchar` production. POSIX
1602        // `std::path::Path` treats both bytes as literal path-component
1603        // bytes (so `../"caixa-teia"` is one directory named literally
1604        // `../"caixa-teia"`, sibling of `.` and `..`).
1605        //
1606        // A `:caminho "'../caixa-teia'"` (the canonical "I pasted a
1607        // `cd '../caixa-teia'` shell-history one-liner whose strong-
1608        // quoting preserved the sibling-workspace path verbatim across
1609        // the whitespace paste boundary" footgun), `:caminho
1610        // "\"../caixa-teia\""` (the symmetric weak-quoted paste-from-
1611        // JSON / paste-from-YAML flow-scalar / paste-from-TOML basic-
1612        // string / paste-from-tatara-lisp string-literal cross-idiom-
1613        // leak shape), or `:caminho "../\"caixa-teia\""` (the embedded-
1614        // quote "I pasted a JSON key-value pair fragment into the
1615        // middle of the path" idiom) silently passes every prior arm
1616        // because `Path::is_absolute` returns false on `..` / `'` /
1617        // `"`, `'` / `"` are neither leading-byte sentinels nor
1618        // control bytes nor `\` nor `<` / `>` nor `|` nor `;` nor `&`
1619        // nor backtick nor `*` / `?` nor `(` / `)` nor `{` / `}` nor
1620        // `[` / `]`, and the value's last byte isn't `/`. The resolver
1621        // folds the value through `Path::new(caminho).join(<file>)`
1622        // looking for a literal `./'../caixa-teia'` subdirectory and
1623        // fails at resolve time with a non-self-locating `No such file
1624        // or directory` error far from the source caixa.lisp.
1625        //
1626        // The lacre pipeline embeds the value verbatim in its per-dep
1627        // content-address (`conteudo: format!("path:{caminho}")`,
1628        // caixa-resolver/src/resolve.rs:189), so a `'` or `"` byte
1629        // lands in the BLAKE3 closure and rides downstream as part of
1630        // the build's identity into every shell-spawned subprocess
1631        // (the caixa-resolver's `git clone` invocation, a future
1632        // `feira tofu` shell-out, a future operator-side `nix flake
1633        // check` spawn) as the canonical shell-metachar / string-
1634        // literal-delimiter surface every peer single-token-shaped
1635        // typed slot already closes. The peer `:fonte :repo` axis
1636        // closes both bytes under the same shell-quote-grouping /
1637        // RFC-3986-sub-delims banner (e7a109f `'` shell-single-quote
1638        // + 4267d8b `"` shell-double-quote on `is_git_repo_url`). The
1639        // `:caminho` axis was the last typed path-string surface
1640        // still admitting these two bytes; this arm closes the gap
1641        // so the substrate-wide "no shell-composition metacharacter
1642        // anywhere in a typed string slot that flows verbatim into a
1643        // shell-spawned subprocess" invariant extends from shell-
1644        // bracket-expansion (`[` / `]`) to shell-quote-grouping (`'`
1645        // / `"`) on the `:caminho` axis. Together with the peer
1646        // JSON / YAML / TOML string-literal delimiters closing at
1647        // this arm and the 598b770 `{` / `}` brace-expansion arm
1648        // closing the templating-engine-placeholder boundary, the
1649        // typed `:caminho` accepted set now structurally excludes
1650        // the entire cross-config-DSL string-literal / templating
1651        // paste-from-aligned-manifest cross-idiom-leak surface that
1652        // would silently round-trip through any downstream JSON /
1653        // YAML / TOML / HCL / tatara-lisp parsing layer.
1654        //
1655        // The arm fires AFTER the shell-bracket-expansion arm because
1656        // the prior arm's `[` / `]` shape is the more semantic-
1657        // locating axis on values that probe as both (`"../[a-z]'x'"`
1658        // carries both `[` and `'` — the glob-character-class
1659        // expansion is the load-bearing root-cause edit, so
1660        // `FonteCaminhoShellBracketExpansion` wins; same cascade
1661        // discipline every prior `:caminho` arm establishes). The arm
1662        // fires BEFORE the trailing-`/` arm because the embedded
1663        // quote-grouping byte is the more semantic-locating axis on
1664        // probe-as-both values (`"../'caixa-teia'/"` ends in `/` but
1665        // the load-bearing diagnostic is the embedded `'` shell-
1666        // string-literal metachar — the trailing `/` is the secondary
1667        // observation, and an author who removes the `'` is likely to
1668        // also tab-strip the trailing separator).
1669        for &b in caminho.as_bytes() {
1670            if b == b'\'' || b == b'"' {
1671                return Err(DepError::fonte_caminho_shell_quote_grouping(
1672                    nome, caminho, b,
1673                ));
1674            }
1675        }
1676        // Reproducibility gate's shell-comment / URL-fragment / YAML-comment arm.
1677        // The d14cbc5 shell-quote-grouping arm closes `'` / `"`; `#` (`0x23`) is
1678        // the orthogonal "byte at which four distinct downstream parsers all
1679        // truncate the value at the first occurrence" surface, and no prior arm
1680        // has covered it on the `:caminho` axis. Every POSIX shell (sh / bash /
1681        // zsh / dash / ksh / fish / nushell) lexes an unquoted `#` at the head
1682        // of a word (or after unquoted whitespace) as the comment-lead: from
1683        // that byte to the end of the physical line is a comment discarded
1684        // before command parsing (`cd ../caixa-teia  # legacy sibling` — the
1685        // canonical paste-from-shell-history-with-trailing-annotation shape
1686        // every operator-notebook and CI-manifest carries; POSIX.1-2017 §2.3
1687        // Token Recognition step 6). YAML 1.2 §6.6 makes `#` the comment lead
1688        // at any position preceded by whitespace or at line-start (`path:
1689        // ../caixa-teia  # pin` — the canonical paste-from-values.yaml /
1690        // paste-from-K8s-manifest cross-idiom-leak shape). tatara-lisp itself
1691        // treats `;` as the comment-lead but a growing number of consumer
1692        // config-DSL layers (HCL, Terraform, Nix flake attributes, .env
1693        // dotenv-style files, gitconfig / .gitignore, ini / TOML) use `#` as
1694        // the comment-lead too — the pair extends the cross-config-DSL
1695        // paste-idiom surface the d14cbc5 quote-grouping arm and the 598b770
1696        // brace-expansion arm already cover on adjacent axes. RFC 3986 §3.5
1697        // reserves `#` as the URL fragment-identifier delimiter (the canonical
1698        // paste-from-browser-address-bar `github.com/foo/bar#readme` /
1699        // `github.com/foo/bar#L42` permalink shape, and the symmetric
1700        // Nix-flake-ref cross-idiom leak `github:foo/bar#packageName` where
1701        // `#` selects a flake output — the same axis the peer
1702        // [`crate::render::is_git_repo_url`] closes on the `:fonte :repo`
1703        // surface at a68f818 with the same downstream-drops-the-tail
1704        // rationale).
1705        //
1706        // POSIX `std::path::Path` treats `#` as a literal path-component byte,
1707        // so a `:caminho "../caixa-teia # legacy sibling"` (the canonical
1708        // paste-from-shell-history-with-trailing-annotation footgun),
1709        // `:caminho "../caixa-teia  # pin"` (the symmetric YAML flow-scalar
1710        // paste-with-trailing-comment shape), or `:caminho "../caixa-teia
1711        // #readme"` (the URL fragment paste-from-browser-address-bar shape)
1712        // silently passes every prior arm because `Path::is_absolute` returns
1713        // false on `..`, `#` is neither a leading-byte sentinel nor a control
1714        // byte nor `\` nor `<` / `>` nor `|` nor `;` nor `&` nor backtick nor
1715        // `*` / `?` nor `(` / `)` nor `{` / `}` nor `[` / `]` nor `'` / `"`,
1716        // and the value's last byte isn't `/`. The resolver folds the value
1717        // through `Path::new(caminho).join(<file>)` looking for a literal
1718        // subdirectory named `../caixa-teia # legacy sibling` and fails at
1719        // resolve time with a non-self-locating `No such file or directory`
1720        // error far from the source caixa.lisp — while every downstream
1721        // shell / YAML / URL parser silently truncates the value at the `#`
1722        // byte to `../caixa-teia`, so a `feira tofu` shell-out to a
1723        // `cd '{caminho}'` command line and a `nix flake check` invocation on
1724        // an emitted YAML `path:` scalar disagree with the resolver on which
1725        // directory the value names. Two workstations whose downstream
1726        // shell / YAML / URL parsing layers differ in unquoted-`#`
1727        // recognition emit divergent build artifacts for the byte-identical
1728        // caixa.lisp value.
1729        //
1730        // The lacre pipeline embeds the value verbatim in its per-dep
1731        // content-address (`conteudo: format!("path:{caminho}")`,
1732        // caixa-resolver/src/resolve.rs:189), so the byte lands in the BLAKE3
1733        // closure and rides downstream as part of the build's identity into
1734        // every shell-spawned subprocess (the caixa-resolver's `git clone`
1735        // invocation, a future `feira tofu` shell-out, a future operator-side
1736        // `nix flake check` spawn) as the canonical shell-metachar /
1737        // comment-lead / URL-fragment-delimiter surface every peer
1738        // single-token-shaped typed slot already closes. The peer `:fonte
1739        // :repo` axis closes the byte under the URL-fragment-identifier
1740        // banner (a68f818 `#` on `is_git_repo_url`); the `:caminho` axis was
1741        // the last typed path-string surface still admitting the byte. This
1742        // arm closes the gap so the substrate-wide "no shell-composition
1743        // metacharacter / comment-lead / URL-fragment-delimiter anywhere in a
1744        // typed string slot that flows verbatim into a shell-spawned
1745        // subprocess or downstream YAML / URL parser" invariant extends from
1746        // shell-quote-grouping (`'` / `"`) to shell-comment / URL-fragment
1747        // (`#`) on the `:caminho` axis. Together with the peer JSON / YAML /
1748        // TOML string-literal delimiters the d14cbc5 quote-grouping arm
1749        // closes and the 598b770 `{` / `}` brace-expansion arm closes on the
1750        // templating-engine-placeholder boundary, the typed `:caminho`
1751        // accepted set now structurally excludes the entire
1752        // paste-with-trailing-annotation / paste-from-URL-permalink /
1753        // paste-from-YAML-comment cross-idiom-leak surface that would
1754        // silently round-trip through any downstream shell / YAML / URL /
1755        // dotenv / gitconfig / HCL parsing layer to a different value than
1756        // the resolver's `Path::join` sees.
1757        //
1758        // The arm fires AFTER the shell-quote-grouping arm because the prior
1759        // arm's `'` / `"` shape is the more semantic-locating axis on values
1760        // that probe as both (`"../'x'#pin"` carries both `'` and `#` — the
1761        // shell-string-literal-delimiter is the load-bearing root-cause edit,
1762        // so `FonteCaminhoShellQuoteGrouping` wins; same cascade discipline
1763        // every prior `:caminho` arm establishes). The arm fires BEFORE the
1764        // trailing-`/` arm because the embedded comment-lead / fragment-
1765        // delimiter byte is the more semantic-locating axis on probe-as-both
1766        // values (`"../caixa-teia#pin/"` ends in `/` but the load-bearing
1767        // diagnostic is the embedded `#` — the trailing `/` is the secondary
1768        // observation, and an author who removes the `#pin` fragment is
1769        // likely to also tab-strip the trailing separator).
1770        for &b in caminho.as_bytes() {
1771            if b == b'#' {
1772                return Err(DepError::fonte_caminho_shell_comment(nome, caminho, b));
1773            }
1774        }
1775        // Reproducibility gate's URL-percent-encoding-escape arm. The 6622063
1776        // shell-comment arm closes the `#` URL-fragment-identifier byte; `%`
1777        // (`0x25`) is the orthogonal RFC 3986 §2.1 URL percent-encoding-escape
1778        // byte — the mandatory encoding mechanism for every byte outside the
1779        // `unreserved` alphanumeric / `-` / `.` / `_` / `~` set, and `%`
1780        // itself must be percent-encoded as `%25` to appear literally inside
1781        // a URL value. The byte carries three distinct render-determinism
1782        // hazards on the `:caminho` axis, no prior arm has covered it, and
1783        // the peer `:fonte :repo` axis (a323db8 `%` on `is_git_repo_url`)
1784        // already closes the same byte under the same URL-percent-encoding
1785        // banner — the `:caminho` axis was the last typed path-string surface
1786        // still admitting the byte.
1787        //
1788        // First, the paste-from-browser-address-bar percent-encoded-space
1789        // footgun: an author copies `../caixa%20teia` out of a URL-encoded
1790        // README hyperlink / a browser address bar / a percent-encoded
1791        // permalink expecting `%20` to decode to a literal space at the
1792        // filesystem layer. POSIX `std::path::Path` treats the byte as a
1793        // literal path-component byte, so `Path::join` looks for a literal
1794        // `./../caixa%20teia` subdirectory and fails at resolve time with a
1795        // non-self-locating `No such file or directory` error far from the
1796        // source caixa.lisp — while the author's mental model was
1797        // `../caixa teia`, the decoded shape. Two authors whose only
1798        // difference is percent-encoding presence resolve to two distinct
1799        // BLAKE3 closures (`path:../caixa%20teia` vs `path:../caixa teia`)
1800        // for what they intended as the byte-identical sibling-workspace
1801        // dep. The lacre pipeline embeds the value verbatim in its per-dep
1802        // content-address (`conteudo: format!("path:{caminho}")`,
1803        // caixa-resolver/src/resolve.rs:189), so the divergence rides
1804        // downstream into the BLAKE3 closure and locks the substrate's
1805        // "the lacre is the build's identity" contract (CAIXA-SDLC §III.2)
1806        // to the wrong encoding — the same THEORY.md §V.2 render-
1807        // determinism vector every prior `:caminho` arm protects.
1808        //
1809        // Second, the printf-format-specifier lead footgun: `%` is the C /
1810        // POSIX printf format-directive lead-in (`%s`, `%d`, `%02x`, the
1811        // canonical `printf "path=%s\n" ../caixa-teia` invocation every
1812        // shell-diagnostic one-liner carries) and the printf builtin is
1813        // wired into every POSIX shell (bash / zsh / dash / ksh / busybox
1814        // ash) as the format-string lead. A `:caminho "../caixa-%s-teia"`
1815        // value flowing into any future `feira` verb that shells out with a
1816        // printf-formatted path template silently gets reinterpreted as a
1817        // format-directive rather than a literal byte — the canonical
1818        // CWE-134 format-string-injection vector.
1819        //
1820        // Third, the bash-job-control-specifier lead footgun: bash / zsh /
1821        // ksh reserve `%N` at word-start as the job-control specifier —
1822        // `%1` names "job 1", `%%` names "the current job", `%foo` names
1823        // "the most recent job whose command started with `foo`". A future
1824        // `feira` verb that invokes `kill %1` on a caminho-scoped
1825        // subprocess would silently redirect the signal to a wrong target.
1826        //
1827        // Beyond the three shell-side hazards, `%` is a first-class parser
1828        // byte in three cross-config-DSL layers the substrate's paste-idiom
1829        // surface routinely crosses: YAML 1.2 §6.8.1 lexes `%` at
1830        // line-start as the directive lead (`%YAML 1.2` / `%TAG` — a
1831        // `:caminho "%YAML/1.2/../caixa-teia"` paste from a top-of-doc
1832        // YAML directive block silently trips the YAML directive parser on
1833        // any downstream emitted YAML manifest); Prometheus / Grafana
1834        // template syntax uses `%(var)s` as the substitution lead; and Nix
1835        // interpolation uses `${var}` (not `%`) but Envsubst /
1836        // Kubernetes / OpenShift template layers use `%VAR%` as the
1837        // Windows-shell env-var-reference lead — the paste-from-`.bat` /
1838        // paste-from-PowerShell-`%env:PATH%` cross-idiom leak.
1839        //
1840        // The three malformed-`%HH` classes documented on the peer
1841        // `is_git_repo_url` `%` arm (a323db8) apply here too:
1842        //
1843        //   - The lone-`%` malformed-escape shape (`"../caixa-teia%foo"`
1844        //     where `%` isn't followed by two hex digits) — every WHATWG-
1845        //     conformant URL parser rejects the value at parse time per
1846        //     RFC 3986 §2.1, but the byte rides into the lacre before
1847        //     the resolver subprocess crosses the URL-parser boundary.
1848        //   - The over-encoded path-separator shape (`"../caixa%2Fteia"`
1849        //     intending the `%2F` as the URL encoding of `/`) locks a
1850        //     `path:../caixa%2Fteia` BLAKE3 closure that diverges from
1851        //     the byte-identical `path:../caixa/teia` form.
1852        //   - The double-encoded shape (`"../caixa%2520teia"` — the `%25`
1853        //     already itself an encoded `%`, so the intent was likely a
1854        //     literal `%20` that survived one round-trip through a
1855        //     URL-encoder that shouldn't have run) locks a triply-
1856        //     divergent closure across the encoded / once-decoded /
1857        //     twice-decoded chain.
1858        //
1859        // POSIX `std::path::Path` treats the byte as a literal path-
1860        // component byte, so a `:caminho "../caixa%20teia"` (the canonical
1861        // paste-from-browser-address-bar percent-encoded-space footgun),
1862        // `:caminho "%YAML/../caixa-teia"` (the symmetric paste-from-YAML-
1863        // directive-block cross-idiom leak), or `:caminho
1864        // "../caixa-%s-teia"` (the printf-format-specifier paste-from-
1865        // shell-diagnostic-one-liner shape) silently passes every prior arm
1866        // because `Path::is_absolute` returns false on `..`, `%` is neither
1867        // a leading-byte sentinel nor a control byte nor `\` nor `<` / `>`
1868        // nor `|` nor `;` nor `&` nor backtick nor `*` / `?` nor `(` / `)`
1869        // nor `{` / `}` nor `[` / `]` nor `'` / `"` nor `#`, and the
1870        // value's last byte isn't `/`. The resolver folds the value through
1871        // `Path::new(caminho).join(<file>)` looking for a literal
1872        // subdirectory named `../caixa%20teia` and fails at resolve time
1873        // with a non-self-locating `No such file or directory` error far
1874        // from the source caixa.lisp — while every downstream URL parser /
1875        // shell printf builtin / YAML directive parser silently
1876        // reinterprets the byte to a different value than the resolver's
1877        // `Path::join` sees. Two workstations whose downstream URL / shell
1878        // / YAML layers differ in `%HH` recognition emit divergent build
1879        // artifacts for the byte-identical caixa.lisp value.
1880        //
1881        // The lacre pipeline embeds the value verbatim in its per-dep
1882        // content-address (`conteudo: format!("path:{caminho}")`, caixa-
1883        // resolver/src/resolve.rs:189), so the byte lands in the BLAKE3
1884        // closure and rides into every shell-spawned subprocess (the
1885        // resolver's `git clone`, a future `feira tofu` shell-out, a
1886        // future operator-side `nix flake check` spawn) as the canonical
1887        // URL-percent-encoding-escape / printf-format-specifier / bash-
1888        // job-control-specifier surface every peer single-token-shaped
1889        // typed slot already closes. This arm closes the gap so the
1890        // substrate-wide "no URL-percent-encoding-escape / printf-format-
1891        // specifier / job-control-specifier / YAML-directive-lead byte
1892        // anywhere in a typed string slot that flows verbatim into a
1893        // shell-spawned subprocess or downstream URL / printf / YAML
1894        // parser" invariant extends from shell-comment / URL-fragment
1895        // (`#` — 6622063) to URL-percent-encoding-escape (`%`) on the
1896        // `:caminho` axis.
1897        //
1898        // The arm fires AFTER the shell-comment arm because the prior
1899        // arm's `#` shape is the more semantic-locating axis on values
1900        // that probe as both (`"../caixa%20teia#pin"` carries both `%`
1901        // and `#` — the URL-fragment-identifier is the load-bearing
1902        // downstream-truncation edit, so `FonteCaminhoShellComment` wins;
1903        // same cascade discipline every prior `:caminho` arm establishes).
1904        // The arm fires BEFORE the trailing-`/` arm because the embedded
1905        // percent-encoding-escape byte is the more semantic-locating axis
1906        // on probe-as-both values (`"../caixa%20teia/"` ends in `/` but
1907        // the load-bearing diagnostic is the embedded `%` percent-
1908        // encoding-escape — the trailing `/` is the secondary observation,
1909        // and an author who decodes the `%20` to a literal space is
1910        // likely to also tab-strip the trailing separator).
1911        for &b in caminho.as_bytes() {
1912            if b == b'%' {
1913                return Err(DepError::fonte_caminho_url_percent_encoding(
1914                    nome, caminho, b,
1915                ));
1916            }
1917        }
1918        // Reproducibility gate's embedded-`$` shell-variable-expansion /
1919        // command-substitution / arithmetic-expansion arm. The f4efe9c
1920        // leading-`$` arm at line 540 routes `caminho.starts_with('$')`
1921        // through `FonteCaminhoVarExpansion` under the leading-byte-
1922        // sentinel host-layout-leak banner (peer with the b94fd83
1923        // absolute / a5c248e tilde leading-byte arms), but the arm
1924        // fires only at position 0 — a `:caminho "../foo$HOME/bar"`
1925        // (embedded `$HOME` in a nested path segment — the canonical
1926        // paste-from-`ls ../foo$HOME/bar`-shell-one-liner footgun where
1927        // an author copies a partially-substituted shell one-liner and
1928        // the leading segment is a literal `../foo` while the mid
1929        // segment carries the un-substituted `$HOME` template), a
1930        // `:caminho "../foo${WORKSPACE}/bar"` (the symmetric braced-CI-
1931        // manifest paste-from-`.gitlab-ci.yml` / paste-from-GitHub-
1932        // Actions-workflow shape), a `:caminho "../foo$(whoami)/bar"`
1933        // (the paste-from-shell-prompt command-substitution idiom), or
1934        // a `:caminho "../foo$((1+2))/bar"` (the arithmetic-expansion
1935        // idiom) silently passes every prior arm because
1936        // `Path::is_absolute` returns false on `..`, `$` is neither a
1937        // leading-byte sentinel (the f4efe9c arm fires only at position
1938        // 0) nor a control byte nor `\` nor `<` / `>` nor `|` nor `;`
1939        // nor `&` nor backtick nor `*` / `?` nor `(` / `)` nor `{` /
1940        // `}` nor `[` / `]` nor `'` / `"` nor `#` nor `%`, and the
1941        // value's last byte isn't `/`. Note that `$(...)` command-
1942        // substitution and `$((...))` arithmetic-expansion each carry
1943        // an embedded `(` byte that the 0633c91 shell-subshell-grouping
1944        // arm catches structurally at the earlier `(` position — but
1945        // an author who reaches for the sh-brace-substitution
1946        // `${VAR}` or the bare `$VAR` shape carries only the `$` byte,
1947        // which no prior arm covers. This arm closes the last
1948        // positional gap on the `$` byte on the `:caminho` axis so
1949        // every position — leading (`FonteCaminhoVarExpansion`) and
1950        // embedded (`FonteCaminhoShellVariableExpansion`) — is
1951        // structurally rejected.
1952        //
1953        // Every POSIX shell (sh / bash / zsh / dash / ksh / busybox
1954        // ash / fish / nushell) lexes `$` as the variable-expansion /
1955        // command-substitution / arithmetic-expansion operator per
1956        // POSIX.1-2017 §2.6 (Word Expansions): `$<name>` (Parameter
1957        // Expansion) expands a named variable, `${<name>}` (Parameter
1958        // Expansion braced form) does the same with an explicit token
1959        // boundary, `$(<cmd>)` (Command Substitution modern form,
1960        // `` `<cmd>` `` legacy form which the c370458 backtick arm
1961        // already closes) runs a subshell and substitutes its stdout,
1962        // and `$((<expr>))` (Arithmetic Expansion) evaluates an
1963        // arithmetic expression. Every form is a host-layout /
1964        // environment-state / shell-subprocess-side-effect leak when
1965        // the byte lands in a value the resolver passes to a shell-
1966        // spawned subprocess. Beyond the POSIX shell layer, `$` is
1967        // the Nix `${var}` string-interpolation lead (the paste-from-
1968        // `flake.nix` / paste-from-`.nix`-attribute cross-idiom leak
1969        // where an author copies `"${pkgs.hello}/bin/hello"` out of a
1970        // nix expression), the Make `$(var)` / `$@` / `$<` automatic-
1971        // variable lead (the paste-from-`Makefile` shape), the
1972        // JavaScript / TypeScript template-literal `${expr}` interp
1973        // lead (the paste-from-JS-template-string idiom in a
1974        // multi-lang-monorepo where a `path` attribute gets copied out
1975        // of a `package.json` script or a Vite config), the envsubst /
1976        // Kubernetes / OpenShift template `${VAR}` interp lead (the
1977        // paste-from-Helm-values / paste-from-K8s-manifest cross-idiom
1978        // leak), the PHP variable lead (`$_GET`, `$_ENV` — the paste-
1979        // from-`.php`-config footgun), the Perl scalar-variable lead
1980        // (`$foo`), the SASS / SCSS variable lead (`$primary-color`),
1981        // and the SQL bind-parameter lead in PostgreSQL / SQLite
1982        // (`$1`, `$2` — the paste-from-`.sql`-migration idiom). The
1983        // cross-idiom paste-footgun surface is broader than any single
1984        // shell layer — `$` is a first-class parser byte in nearly
1985        // every config / templating / build-system DSL the substrate's
1986        // paste-idiom surface routinely crosses. The peer `:fonte
1987        // :repo` axis closes the byte under the shell-variable-
1988        // expansion / URL-sub-delim banner (b9d187c `$` on
1989        // `is_git_repo_url`), the peer `:fonte :tag` / `:fonte :branch`
1990        // axes close `$` as part of `is_git_ref_name`'s printable-
1991        // ASCII-restricted grammar (`git check-ref-format` rejects the
1992        // byte outright), and the peer `:entrada :paths` axis closes
1993        // `$` via `is_gateway_api_http_path`'s eleven-byte RFC-3986-
1994        // reserved set. The `:caminho` axis was the last typed path-
1995        // string surface still admitting `$` at positions other than 0.
1996        //
1997        // POSIX `std::path::Path` treats `$` as a literal path-
1998        // component byte, so `:caminho "../foo$HOME/bar"` silently
1999        // routes through `Path::new(caminho).join(<file>)` looking for
2000        // a literal `./{caminho}` subdirectory that fails at resolve
2001        // time with a non-self-locating `No such file or directory`
2002        // error far from the source caixa.lisp. But every downstream
2003        // shell / envsubst / Nix / Make / K8s-template parser silently
2004        // reinterprets the byte to a different value than the
2005        // resolver's `Path::join` sees — so a `feira tofu` shell-out
2006        // to a `cd '{caminho}'` command line, a `nix flake check`
2007        // invocation on an emitted YAML `path:` scalar folded through
2008        // envsubst, or a `helm template` invocation with a
2009        // `values.yaml` `path: {caminho}` embedded in a `{{`-quoted
2010        // template all disagree with the resolver on which directory
2011        // the value names. Two workstations whose downstream shell /
2012        // envsubst / Nix / Make / K8s-template parsing layers differ
2013        // in `$VAR` recognition (or, worse, expand the byte against
2014        // divergent environments — Alice's `$HOME=/home/alice`, Bob's
2015        // `$HOME=/home/bob`) emit divergent build artifacts for the
2016        // byte-identical caixa.lisp value. Even in the case where the
2017        // resolver strictly does NOT expand `$VAR` (the current
2018        // implementation) the divergence still bites at the lacre-
2019        // identity axis: the lacre pipeline embeds the value verbatim
2020        // in its per-dep content-address (`conteudo:
2021        // format!("path:{caminho}")`, caixa-resolver/src/resolve.rs:189),
2022        // so `path:../foo$HOME/bar` locks a BLAKE3 closure distinct
2023        // from the byte-identical-semantic `path:../foo/home/alice/bar`
2024        // one author would have produced by substituting the literal
2025        // value at author time, defeating the THEORY.md §V.2 render-
2026        // determinism contract on the same axis every prior `:caminho`
2027        // arm protects.
2028        //
2029        // Beyond the render-determinism / host-layout-leak vectors,
2030        // `$` at any position in a value flowing verbatim into a
2031        // shell-spawned subprocess is the canonical CWE-78 shell-
2032        // command-injection surface every peer single-token-shaped
2033        // typed slot already closes. A `:caminho "../foo$(whoami)/bar"`
2034        // that rides into a future `feira tofu` shell-out as `cd
2035        // '../foo$(whoami)/bar'` gets substituted by the shell at
2036        // subprocess-argument-expansion time even inside single quotes
2037        // in fewer positions than one might expect (the substitution
2038        // fires only outside single-quoting per POSIX §2.2.2, but
2039        // eval-style wrappers and `sh -c` layers that route the value
2040        // through re-parsing round-trip the substitution — the same
2041        // vector the c370458 backtick arm closes at the sibling
2042        // command-substitution-legacy-form surface). Every future
2043        // `feira` verb that shells out with a `caminho`-formatted
2044        // subprocess argument silently inherits this substitution
2045        // vector unless the typed slot's accepted set structurally
2046        // excludes the byte.
2047        //
2048        // Frontier inspiration: OTP's `gen_server` return-value grammar
2049        // rejects mid-tuple shell-metachar bytes by construction —
2050        // `{noreply, State}` never carries a raw `$` because the
2051        // Erlang term type system has no notion of "string that gets
2052        // shelled out"; caixa's typed slots inherit the same
2053        // structural discipline (types-are-theorems, the compounding
2054        // mandate's leverage-point-1) by refusing values that would
2055        // silently reinterpret at any downstream layer. Peer with
2056        // Unison's content-addressed code (no ambient environment —
2057        // every reference is a hash, no `$VAR` substitution possible)
2058        // and Pony's capabilities (a path capability that carries a
2059        // `$` would be ill-typed at the reference layer).
2060        //
2061        // The arm fires AFTER the URL-percent-encoding-escape arm (the
2062        // e3558fa `%` arm) because a value carrying both `%` and `$`
2063        // (`"../foo%20$HOME/bar"` — the canonical "I pasted a percent-
2064        // encoded space next to a `$HOME` template") surfaces the
2065        // narrower URL-encoding diagnostic first — the paste-from-
2066        // browser-address-bar shape is the load-bearing self-locating
2067        // edit on every probe-as-both value; same cascade discipline
2068        // every prior `:caminho` arm establishes (a323db8 %  before
2069        // this arm, this arm before trailing-`/`). The arm fires
2070        // BEFORE the trailing-`/` arm because the embedded shell-
2071        // variable-expansion byte is the more semantic-locating axis
2072        // on probe-as-both values (`"../foo$HOME/bar/"` ends in `/`
2073        // but the load-bearing diagnostic is the embedded `$` — the
2074        // trailing `/` is the secondary observation, and an author
2075        // who substitutes the `$HOME` template with a literal value is
2076        // likely to also tab-strip the trailing separator).
2077        for &b in caminho.as_bytes() {
2078            if b == b'$' {
2079                return Err(DepError::fonte_caminho_shell_variable_expansion(
2080                    nome, caminho, b,
2081                ));
2082            }
2083        }
2084        // Reproducibility gate's shell-history-expansion / RFC-3986-sub-delims
2085        // arm. The immediate-predecessor `$` embedded arm closes the shell-
2086        // variable-expansion / command-substitution byte; `!` (`0x21`) is the
2087        // orthogonal POSIX shell-history-expansion sentinel every interactive
2088        // shell with history enabled (bash / ksh / zsh's `bashcompat` /
2089        // csh / tcsh) lexes as the history-expansion prefix: `!command`
2090        // re-runs the most recent history entry beginning with `command`,
2091        // `!!` re-runs the prior command verbatim, `!$` substitutes the
2092        // last word of the prior command, `!:N` substitutes the Nth word,
2093        // `^old^new` rewrites the prior command's `old` to `new` (the
2094        // canonical set of `set -o histexpand` operators bash's default
2095        // interactive session enables). Beyond the shell-history layer,
2096        // RFC 3986 §2.2 lists `!` in the `sub-delims` set (the URL grammar
2097        // admits the byte inside a path segment, but every WHATWG-conformant
2098        // special-scheme URL parser percent-encodes it inside a query
2099        // component via the 'special-query percent-encode set' the peer
2100        // `is_git_repo_url` `*` / `(` / `)` / `'` arms close on); the byte
2101        // is also the C / C++ / Rust / JavaScript / Python bang-operator
2102        // (logical-negation prefix — the paste-from-source-code idiom where
2103        // an author copies `!path.exists()` out of a Rust snippet and the
2104        // trailing punctuation crosses the string-literal boundary); the
2105        // canonical English-typography emphasis / exclamation mark (the
2106        // paste-from-prose enthusiasm-form idiom where an author writes
2107        // `:caminho "../caixa-teia!"` expecting the substrate to coerce it
2108        // to a kebab-case slug); and the Nix flake-ref import-attribute
2109        // `import ./foo.nix { … }` sibling operator surface.
2110        //
2111        // POSIX `std::path::Path` treats `!` as a literal path-component
2112        // byte, so a `:caminho "../caixa-teia!sudo"` (the canonical paste-
2113        // from-shell-history footgun where the author copies a `cd
2114        // ../caixa-teia && !sudo make install` one-liner from a quick-
2115        // start README and the trailing `!sudo` rides in verbatim as a
2116        // history-expansion reference), a `:caminho "../foo!!/bar"` (the
2117        // `!!` repeat-prior-command paste idiom), a `:caminho
2118        // "../caixa-teia!"` (the English-typography enthusiasm-form
2119        // paste-from-prose footgun), or a `:caminho "../foo!$"` (the
2120        // last-word-substitution shape) silently pass every prior arm
2121        // because `Path::is_absolute` returns false on `..`, `!` is neither
2122        // a leading-byte sentinel nor a control byte nor `\` nor `<` / `>`
2123        // nor `|` nor `;` nor `&` nor backtick nor `*` / `?` nor `(` / `)`
2124        // nor `{` / `}` nor `[` / `]` nor `'` / `"` nor `#` nor `%` nor `$`,
2125        // and the value's last byte isn't `/`. The resolver folds the value
2126        // through `Path::new(caminho).join(<file>)` looking for a literal
2127        // `./../caixa-teia!sudo` subdirectory and fails at resolve time
2128        // with a non-self-locating `No such file or directory` error far
2129        // from the source caixa.lisp — while every downstream interactive
2130        // shell with `set -o histexpand` reinterprets the byte as the
2131        // history-expansion prefix, and the failure mode forks per
2132        // consumer: a `feira tofu` shell-out to a `cd '{caminho}'` command
2133        // line executed under `bash -i` (the operator-notebook interactive
2134        // shell) substitutes the `!sudo` reference to the most recent
2135        // history entry starting with `sudo`, silently invoking whatever
2136        // privileged command that entry named.
2137        //
2138        // The lacre pipeline embeds the value verbatim in its per-dep
2139        // content-address (`conteudo: format!("path:{caminho}")`,
2140        // caixa-resolver/src/resolve.rs:189), so the byte lands in the
2141        // BLAKE3 closure and rides into every shell-spawned subprocess
2142        // (the resolver's `git clone`, a future `feira tofu` shell-out,
2143        // a future operator-side `nix flake check` spawn) as the
2144        // canonical shell-history-expansion / RFC-3986-sub-delims surface
2145        // every peer single-token-shaped typed slot already closes. The
2146        // peer `:fonte :repo` axis closes the byte under the same shell-
2147        // history-expansion / RFC-3986-sub-delims banner (7d53c68 `!` on
2148        // `is_git_repo_url`); the `:caminho` axis was the last typed
2149        // path-string surface still admitting the byte. This arm closes
2150        // the gap so the substrate-wide "no shell-composition
2151        // metacharacter / history-expansion sentinel anywhere in a typed
2152        // string slot that flows verbatim into a shell-spawned subprocess"
2153        // invariant extends from shell-variable-expansion (`$`) to shell-
2154        // history-expansion (`!`) on the `:caminho` axis. Together with
2155        // the peer c370458 backtick command-substitution-legacy-form arm
2156        // and the b9d187c-`$`-embedded-variable-expansion arm on the
2157        // sibling `:repo` axis, the typed `:caminho` accepted set now
2158        // structurally excludes every byte the POSIX shell §2.6 Word
2159        // Expansions section, §2.3 Token Recognition step 6, and every
2160        // history-expansion / brace-expansion / pathname-expansion /
2161        // parameter-expansion / command-substitution / arithmetic-
2162        // expansion operator lexes as a first-class parser byte.
2163        //
2164        // Frontier inspiration: Unison's content-addressed code (no
2165        // ambient environment — every reference is a hash, no `!<num>`
2166        // history-index substitution possible; the caixa substrate's
2167        // lacre discipline arrives at the same guarantee by refusing
2168        // bytes at manifest-parse time that would reinterpret against
2169        // ambient shell history state); Pony's capabilities (a path
2170        // capability that carries a `!` would be ill-typed at the
2171        // reference layer).
2172        //
2173        // The arm fires AFTER the shell-variable-expansion arm because a
2174        // value carrying both `$` and `!` (`"../foo$HOME/bar!sudo"` — the
2175        // canonical "I pasted a `$HOME`-templated path adjacent to a
2176        // trailing `!sudo` history-expansion") surfaces the narrower
2177        // shell-variable-expansion diagnostic first — the paste-from-CI-
2178        // manifest-with-`$VAR`-template shape is the load-bearing self-
2179        // locating edit on every probe-as-both value; same cascade
2180        // discipline every prior `:caminho` arm establishes. The arm
2181        // fires BEFORE the trailing-`/` arm because the embedded shell-
2182        // history-expansion byte is the more semantic-locating axis on
2183        // probe-as-both values (`"../foo!sudo/"` ends in `/` but the
2184        // load-bearing diagnostic is the embedded `!` — the trailing `/`
2185        // is the secondary observation, and an author who removes the
2186        // `!sudo` history reference is likely to also tab-strip the
2187        // trailing separator).
2188        for &b in caminho.as_bytes() {
2189            if b == b'!' {
2190                return Err(DepError::fonte_caminho_shell_history_expansion(
2191                    nome, caminho, b,
2192                ));
2193            }
2194        }
2195        // Reproducibility gate's shell-history-substitution / RFC-3986-unwise
2196        // / regex-anchor arm. The immediate-predecessor `!` arm closes the
2197        // POSIX `!command` / `!!` / `!$` history-expansion prefix; `^`
2198        // (`0x5E`) is the paired-operator half of the same bash-reference
2199        // §9.3 histexpand feature — the `^old^new^` "quick substitution"
2200        // form (POSIX bash rewrites the prior command's `old` string to
2201        // `new` and re-executes it, the canonical typo-correction one-
2202        // liner idiom `git clone <bad-url>` → `^bad^good` that pastes the
2203        // trailing substitution fragment verbatim into a `:caminho` value
2204        // when the author trims only the leading `git clone` prefix). The
2205        // peer `:fonte :repo` axis closes the byte under the same
2206        // shell-history-substitution / RFC-3986-unwise banner (49e142f `^`
2207        // on `is_git_repo_url`); the `:caminho` axis was the last typed
2208        // path-string surface still admitting the byte after 6a04767
2209        // landed the `!` arm.
2210        //
2211        // Beyond bash history-substitution, `^` carries five distinct
2212        // downstream-reinterpretation surfaces the typed slot's accepted
2213        // set must structurally exclude:
2214        //
2215        // 1. **RFC 3986 §2 'unwise' set** — the four-byte cross-transport
2216        //    layer set (`{`, `}`, `|`, `\`) plus `^` every URL parser is
2217        //    required to percent-encode-or-refuse at the wire boundary.
2218        //    The WHATWG URL spec's 'fragment percent-encode set' maps
2219        //    `^` → `%5E` at the query / fragment component transition;
2220        //    libcurl silently percent-encodes the byte on the wire, so a
2221        //    `:caminho "../foo^bar"` value the resolver's `Path::join`
2222        //    sees as a literal `./../foo^bar` subdirectory diverges from
2223        //    the byte-transformed `%5E` shape any downstream `feira tofu`
2224        //    curl-invocation or artifact-registry-fetch would emit — the
2225        //    canonical wire-boundary divergence vector the peer
2226        //    `{`, `}`, `|`, `\` `:caminho` arms already close (
2227        //    `FonteCaminhoShellBraceExpansion` at 598b770,
2228        //    `FonteCaminhoShellPipe` at the pipe arm,
2229        //    `FonteCaminhoBackslash` at the backslash arm).
2230        // 2. **Regex character-class negation prefix `[^abc]`** — the
2231        //    canonical paste-from-doc-regex-pipeline footgun where an
2232        //    author copies a `grep '[^abc]'` idiom from a docs quick-
2233        //    listing and the character-class negation byte rides in
2234        //    verbatim.
2235        // 3. **Bitwise XOR operator** in C / C++ / Rust / Python /
2236        //    JavaScript / Nix / Go — the paste-from-source-code idiom
2237        //    where an author copies an `x ^ y`-shaped expression out of
2238        //    a source snippet and the operator crosses the string-
2239        //    literal boundary.
2240        // 4. **Windows `cmd.exe` escape metacharacter** — the byte
2241        //    escapes the next character in a `cmd.exe` batch context (a
2242        //    peer of the backslash arm's Windows-separator-leak vector).
2243        //    A `:caminho "..^&whoami"` cross-platform paste-from-batch-
2244        //    file footgun reinterprets at every `cmd.exe`-spawned
2245        //    subprocess (the resolver's future Windows-runner shell-out,
2246        //    the operator's WinRM path, a future PowerShell-embedded
2247        //    invocation).
2248        // 5. **LaTeX / Markdown / BibTeX superscript operator** — the
2249        //    paste-from-typeset-doc footgun where a mathematical
2250        //    superscript notation (`x^2` / `M^T`) leaks from prose.
2251        //
2252        // POSIX `std::path::Path` treats `^` as a literal path-component
2253        // byte, so `:caminho "../foo^bar/baz"` (embedded quick-
2254        // substitution), `:caminho "../foo^"` (trailing history-
2255        // substitution-open shape), `:caminho "../[^a-z]/foo"` (regex-
2256        // negation-prefix paste from a grep pipeline; note the `[` / `]`
2257        // arm at 986963b fires first on this shape), or `:caminho
2258        // "../x^y"` (XOR-expression paste-from-source) all silently pass
2259        // every prior arm (`^` isn't `\` / `<` / `>` / `|` / `;` / `&` /
2260        // backtick / `*` / `?` / `(` / `)` / `{` / `}` / `[` / `]` / `'`
2261        // / `"` / `#` / `%` / `$` / `!`) and route through
2262        // `Path::new(caminho).join(<file>)` looking for a literal
2263        // `./{caminho}` subdirectory that fails at resolve time with a
2264        // non-self-locating `No such file or directory` error far from
2265        // the source caixa.lisp — while every downstream shell / curl /
2266        // regex / `cmd.exe` layer reinterprets the byte to its own
2267        // semantic.
2268        //
2269        // The lacre pipeline embeds the value verbatim in its per-dep
2270        // content-address (`conteudo: format!("path:{caminho}")`,
2271        // caixa-resolver/src/resolve.rs:189), so the byte lands in the
2272        // BLAKE3 closure and rides into every shell-spawned subprocess
2273        // (the resolver's `git clone`, a future `feira tofu` shell-out,
2274        // a future operator-side `nix flake check` spawn) as the
2275        // canonical shell-history-substitution / RFC-3986-unwise /
2276        // regex-negation surface every peer single-token-shaped typed
2277        // slot already closes. This arm together with the immediate-
2278        // predecessor `!` arm (6a04767) closes the full `set -o
2279        // histexpand` operator surface on the `:caminho` axis — the
2280        // `!command` / `!!` / `!$` prefix form via `!`, the `^old^new^`
2281        // quick-substitution form via `^` — so the substrate-wide "no
2282        // shell-history operator anywhere in a typed string slot that
2283        // flows verbatim into a shell-spawned subprocess" invariant
2284        // extends from the `!` prefix half to the `^` quick-substitution
2285        // half. Every peer bash-history operator now fails at manifest-
2286        // parse time with a self-locating diagnostic naming the offending
2287        // caixa.lisp rather than at resolve-time as a `Path::join`-
2288        // derived `No such file or directory` (harmless but non-self-
2289        // locating) or worse riding into a downstream `bash -i` context
2290        // that reinterprets the byte-pair against ambient history state.
2291        //
2292        // Frontier inspiration: bash reference §9.3 HISTORY EXPANSION
2293        // "Quick substitution. Repeat the previous command, replacing
2294        // string1 with string2." + RFC 3986 §2 'unwise' set
2295        // ("characters that gateways and other transport agents are
2296        // known to sometimes modify") + Pony's capabilities (a path
2297        // capability that carries a `^` would be ill-typed at the
2298        // reference layer, matching the same structural discipline the
2299        // sibling `!` history-expansion arm inherits from Unison's
2300        // content-addressed no-ambient-history discipline).
2301        //
2302        // The arm fires AFTER the shell-history-expansion `!` arm because
2303        // a value carrying both `!` and `^` (`"../foo!sudo^bad^good"` —
2304        // the canonical "I pasted a `!sudo` history-reference next to a
2305        // `^bad^good` quick-substitution") surfaces the narrower prefix-
2306        // form `!` diagnostic first — the `!` form is the load-bearing
2307        // self-locating edit on every probe-as-both value (an author who
2308        // removes the `!sudo` reference is likely to also strip the
2309        // paired `^` substitution fragment); same cascade discipline
2310        // every prior `:caminho` arm establishes. The arm fires BEFORE
2311        // the trailing-`/` arm because the embedded shell-history-
2312        // substitution byte is the more semantic-locating axis on
2313        // probe-as-both values (`"../foo^bar/"` ends in `/` but the
2314        // load-bearing diagnostic is the embedded `^` — the trailing `/`
2315        // is the secondary observation, and an author who removes the
2316        // `^bar` substitution fragment is likely to also tab-strip the
2317        // trailing separator).
2318        for &b in caminho.as_bytes() {
2319            if b == b'^' {
2320                return Err(DepError::fonte_caminho_shell_history_substitution(
2321                    nome, caminho, b,
2322                ));
2323            }
2324        }
2325        // Reproducibility gate's trailing-`/` arm. The b94fd83 absolute arm
2326        // closes the leading-`/` host-layout-leak; the embedded-control-byte
2327        // arm closes any byte-in-the-`0x00..=0x1F` / `0x7F` range; the
2328        // backslash arm closes the cross-host-OS-separator vector. The
2329        // trailing-`/` is the orthogonal shell-tab-completion-on-a-directory
2330        // footgun — `Path::join("../caixa-teia")` and
2331        // `Path::join("../caixa-teia/")` resolve to the same directory
2332        // (POSIX path-component-walk treats trailing `/` as a no-op for
2333        // directory targets, which `:caminho` always names — the sibling-
2334        // workspace dep root is structurally a directory). The lacre
2335        // pipeline embeds the value verbatim in its per-dep content-address
2336        // (`conteudo: format!("path:{caminho}")`,
2337        // caixa-resolver/src/resolve.rs:189), so byte-identical caixa
2338        // semantic-meaning yields two distinct BLAKE3 closures depending on
2339        // whether the author shell-tab-completed the path (every interactive
2340        // shell appends `/` on tab-completing a directory, idiomatic in
2341        // bash / zsh / fish / nushell), pasted from `pwd` (which on most
2342        // shells emits without trailing `/`, but `realpath -e -m` on a
2343        // directory with trailing `/` preserves it), or copied a Cargo
2344        // `path = "../caixa-teia/"` entry from cross-substrate documentation
2345        // (Cargo accepts both shapes and folds them the same way). Two
2346        // workstations whose authors differ only in tab-completion habits
2347        // emit byte-divergent lacres for the byte-identical-semantic caixa,
2348        // and the substrate's "the lacre is the build's identity" contract
2349        // (CAIXA-SDLC §III.2) silently breaks far from the source caixa.lisp.
2350        //
2351        // Same THEORY.md §V.2 render-determinism axis every prior `:caminho`
2352        // arm protects, here against the trailing-separator divergence
2353        // vector: every typed slot's accepted set excludes byte-divergent
2354        // values that round-trip to the same downstream semantic. The peer
2355        // path-shaped axes already reject trailing separators on the same
2356        // contract: [`crate::render::is_gateway_api_http_path`] gates
2357        // `:entrada :paths` against any non-canonical normalization, and
2358        // [`crate::render::is_sandboxed_relative_path`] gates the M2 typed
2359        // path-slots (`:behavior :on-*`, `:upgrade-from :state-change
2360        // :script`, `:bibliotecas`, `:exe`, `:servicos`) against shapes
2361        // whose canonical form would re-introduce determinism divergence.
2362        //
2363        // The arm fires last in the cascade because every prior arm carries
2364        // a more self-locating diagnostic on values that probe as both
2365        // (e.g. `:caminho "../foo/\0/"` ends in `/` but the load-bearing
2366        // diagnostic is the NUL byte's POSIX-syscall-rejection — the
2367        // control-char arm wins; `:caminho "/etc/passwd/"` ends in `/` but
2368        // the load-bearing diagnostic is the absolute host-layout-leak —
2369        // the absolute arm wins; `:caminho "..\caixa-teia/"` ends in `/`
2370        // but the load-bearing diagnostic is the Windows-separator cross-
2371        // OS divergence — the backslash arm wins). The arm covers every
2372        // shape where the last byte is `/` regardless of length, including
2373        // the degenerate single-`/` (which the absolute arm catches first)
2374        // and the consecutive-`//` (where every prior arm passes on the
2375        // bytes other than the trailing `/`).
2376        if caminho.as_bytes().last() == Some(&b'/') {
2377            return Err(DepError::fonte_caminho_trailing_slash(nome, caminho));
2378        }
2379        Ok(())
2380    }
2381}
2382
2383impl Dep {
2384    /// Substrate-canonical per-`:deps` / `:deps-dev` entry `:nome` scalar
2385    /// accessor every consumer of the dep-graph identity axis keys off —
2386    /// returns the author-declared `:nome` byte-string verbatim as a
2387    /// `&str`, borrowed from the typed slot's own [`String`] storage.
2388    ///
2389    /// The `:deps :nome` / `:deps-dev :nome` slot carries the DNS-1123
2390    /// label that names the target caixa (validated by [`Self::validate`]
2391    /// through the shared [`crate::render::is_dns_1123_label`] predicate,
2392    /// same accept-set the peer caixa-identifier axes carry — top-level
2393    /// [`crate::Caixa::nome`], per-`:membros` [`crate::Membro::nome`],
2394    /// per-`:children` [`crate::supervisor::ChildSpec::nome`]). Every
2395    /// downstream consumer that fans on the dep's name-identity keys off
2396    /// this scalar: the [`crate::Caixa::validate_deps`] per-list
2397    /// [`crate::render::insert_first_seen`] dedup key + the paired
2398    /// [`DepError::DuplicateNome`] carrier the walk raises on collision,
2399    /// the cross-list [`validate_no_self_dep`] parent-name equality gate
2400    /// on both `:deps` and `:deps-dev` traversals, the `caixa-resolver`
2401    /// pipeline's `HashSet<String>` seen-set the closure walker gates
2402    /// requeueing off (`caixa-resolver/src/resolve.rs:55`), the resolver's
2403    /// per-transitive-target requeue path (`resolve.rs:63,66`), the
2404    /// [`crate::DepSource::default_github`]-shaped resolver-side shorthand
2405    /// fill-in that folds `:nome` into the fetched-git-URL (`resolve.rs:147`),
2406    /// every `caixa-resolver` `ResolveError::MissingPath` /
2407    /// `ResolveError::MissingPin` carrier that names the offending dep
2408    /// (`resolve.rs:177,206`), each resolved
2409    /// `caixa-lacre::LacreEntry` `nome:` field the closure hash keys off
2410    /// (`resolve.rs:108,113`), and the peer `feira lock` stub-resolver's
2411    /// `LacreEntry` emitter (`caixa-feira/src/cmd/lock.rs:59,61,64`).
2412    ///
2413    /// Prior to this lift the `.nome` byte-string was read inline at every
2414    /// production site — the [`crate::Caixa::validate_deps`] paired
2415    /// `dep.nome.as_str()` / `dep.nome.clone()` accesses on both `:deps`
2416    /// and `:deps-dev` traversals, the [`validate_no_self_dep`] pair of
2417    /// parent-equality checks, and every caixa-resolver / caixa-feira
2418    /// site enumerated above — open-coded field-accesses that expressed
2419    /// no compile-time link back to the typed slot. A future extension of
2420    /// the `:deps :nome` axis to a richer author surface (a per-scope
2421    /// alias table the resolver folds through the `~/.config/caixa/config.yaml`
2422    /// entry the [`crate::dep::Dep`] docstring already acknowledges, a
2423    /// namespace-qualified rewrite the future M4 lacre-federation layer
2424    /// applies per-cluster, a promotion of the plain [`String`] byte-string
2425    /// to a richer scoped-identifier newtype once cross-registry federation
2426    /// lands) would have had to be threaded through every open-coded copy
2427    /// in lockstep or two consumers would silently disagree on which caixa
2428    /// a given dep resolves to — the [`crate::Caixa::validate_deps`] dedup
2429    /// set treating the name as `"caixa-teia"` while the caixa-resolver
2430    /// closure walker treated it as `"tenant-a/caixa-teia"` would silently
2431    /// split the [`DepError::DuplicateNome`] refusal from the resolver's
2432    /// requeue-suppression seen-set, one build-time diagnostic
2433    /// disagreeing with the run-time closure the substrate's lacre
2434    /// pipeline actually materializes. Lifting the resolution rule to a
2435    /// typed method on the substrate primitive means every downstream
2436    /// consumer of the caixa's per-`:deps` identity surface reaches for
2437    /// exactly one typed dispatch — the resolver's accept-set migrates as
2438    /// a unit on any future axis addition.
2439    ///
2440    /// First accessor on the outer `Dep` type — opens the outer-`Dep`
2441    /// `&str`-return required-scalar projection pattern the sibling
2442    /// per-`Dep` `:versao` future lift folds on. Peer of the sibling
2443    /// per-`:membros` [`crate::Membro::nome`] (4a32abf) /
2444    /// per-`:children` [`crate::supervisor::ChildSpec::nome`] (dfb4a81)
2445    /// / top-level [`crate::Caixa::nome`] (e6b7d97) caixa-identity scalar
2446    /// accessors — same "one typed dispatch on the substrate primitive,
2447    /// thin projections at each consumer" discipline extended onto the
2448    /// third named-caixa-referencing axis (`:deps` / `:deps-dev`), the
2449    /// remaining unlifted caixa-name-referencing accessor family in the
2450    /// substrate. Named `nome()` to match the tatara-lisp author-surface
2451    /// term the field's docstring already reaches for ("Caixa name — must
2452    /// match the target caixa's `:nome`") and the peer caixa-identity
2453    /// accessor family the substrate already carries.
2454    #[must_use]
2455    pub const fn nome(&self) -> &str {
2456        self.nome.as_str()
2457    }
2458
2459    /// Substrate-canonical per-`:deps` / `:deps-dev` entry `:versao`
2460    /// Cargo-shaped semver-requirement scalar accessor every consumer of
2461    /// the dep-graph version-pin axis keys off — returns the author-
2462    /// declared `:versao` requirement byte-string verbatim as a `&str`,
2463    /// borrowed from the typed slot's own [`String`] storage.
2464    ///
2465    /// The `:deps :versao` / `:deps-dev :versao` slot carries the
2466    /// Cargo-shaped semver requirement string (`"^0.1"`, `"~0.1.2"`,
2467    /// `"0.1.0"`, `"*"`) the shared [`crate::version::parse_requirement`]
2468    /// entry-point consumes — same accept-set the peer requirement-
2469    /// carrying axes carry (per-`:membros`
2470    /// [`crate::Membro::versao_requirement`], per-`:children`
2471    /// [`crate::supervisor::ChildSpec::versao_requirement`]), validated
2472    /// through the shared
2473    /// [`crate::render::require_valid_versao_requirement`] cascade in
2474    /// [`Self::validate`]. Every downstream consumer that fans on the
2475    /// dep's version-pin keys off this scalar: the [`Self::validate`]
2476    /// `require_valid_versao_requirement` gate + the paired
2477    /// [`DepError::VersaoInvalid`] carrier the cascade raises on
2478    /// requirement-shape rejection, the `feira lock` stub-resolver's
2479    /// `format!("{}@{}", dep.nome(), dep.versao_requirement())`
2480    /// `conteudo` hash-input interpolation and the paired
2481    /// `LacreEntry.versao:` `String`-carry fill (`caixa-feira/src/cmd/lock.rs`),
2482    /// and the peer `feira lock` end-to-end fixture in `caixa-feira/tests/feira_e2e.rs`.
2483    ///
2484    /// Prior to this lift the `.versao` byte-string was read inline at
2485    /// every production site — the [`Self::validate`] paired
2486    /// `&self.versao` requirement-gate reference and `self.versao.clone()`
2487    /// error-body carrier, the `caixa-feira/src/cmd/lock.rs` paired
2488    /// `format!("{}@{}", dep.nome(), dep.versao)` `conteudo` interpolation
2489    /// and `versao: dep.versao.clone()` `LacreEntry` fill, and the
2490    /// `caixa-feira/tests/feira_e2e.rs` end-to-end fixture's pair of the
2491    /// same shapes — open-coded field-accesses that expressed no
2492    /// compile-time link back to the typed slot. A future extension of
2493    /// the `:deps :versao` axis to a richer author surface (a per-scope
2494    /// version-lock overlay the resolver folds through the
2495    /// `~/.config/caixa/config.yaml` entry the [`crate::dep::Dep`]
2496    /// docstring already acknowledges, a per-cluster canary-version
2497    /// overlay per MESH-COMPOSITION §III.2, a promotion of the plain
2498    /// [`String`] requirement to a richer parsed-`VersionReq` newtype
2499    /// once cross-registry federation lands) would have had to be
2500    /// threaded through every open-coded copy in lockstep or two
2501    /// consumers would silently disagree on which release constraint a
2502    /// given dep resolves to — the [`Self::validate`] requirement-gate
2503    /// call reading `"^0.1"` while the `feira lock` stub-resolver's
2504    /// `conteudo` hash-input read `"tenant-a-pin/^0.1"` would silently
2505    /// split the [`DepError::VersaoInvalid`] refusal from the lacre's
2506    /// content-addressed hash the substrate's fetch pipeline actually
2507    /// materializes, one build-time diagnostic disagreeing with the
2508    /// run-time closure. Lifting the resolution rule to a typed method
2509    /// on the substrate primitive means every downstream consumer of
2510    /// the caixa's per-`:deps` version-pin surface reaches for exactly
2511    /// one typed dispatch — the resolver's accept-set migrates as a
2512    /// unit on any future axis addition.
2513    ///
2514    /// Second accessor on the outer `Dep` type — folds on the outer-
2515    /// `Dep` `&str`-return required-scalar projection pattern the
2516    /// sibling per-`Dep` [`Self::nome`] (eba2cde) accessor opened. Peer
2517    /// of the per-`:membros` [`crate::Membro::versao_requirement`]
2518    /// (a40b0e3) / per-`:children`
2519    /// [`crate::supervisor::ChildSpec::versao_requirement`] (7844f4e
2520    /// family) member/child version-pin accessors — the three
2521    /// requirement-carrying axes (`Dep::versao_requirement` on the
2522    /// per-caixa dep-graph edge, `Membro::versao_requirement` on the M3
2523    /// Aplicacao side, `ChildSpec::versao_requirement` on the M2
2524    /// Supervisor side) now share one accessor discipline for the
2525    /// shared substrate concept "another caixa referenced by a
2526    /// Cargo-shaped semver requirement". The pair
2527    /// `(nome(), versao_requirement())` jointly projects the
2528    /// `(nome, versao)` field pair every dep-graph consumer that fans
2529    /// on per-dep identity + version pin keys off. Named
2530    /// `versao_requirement()` rather than `versao()` because the field's
2531    /// storage-side `.versao` label is already the author-surface term
2532    /// (`:versao`); the accessor's name carries the semantic role — the
2533    /// semver *requirement* string the shared
2534    /// [`crate::version::parse_requirement`] entry-point consumes — so a
2535    /// raw field access and a typed dispatch read differently at every
2536    /// consumer site. Matches the peer
2537    /// [`crate::Membro::versao_requirement`] /
2538    /// [`crate::supervisor::ChildSpec::versao_requirement`] naming
2539    /// discipline verbatim.
2540    #[must_use]
2541    pub const fn versao_requirement(&self) -> &str {
2542        self.versao.as_str()
2543    }
2544
2545    /// Substrate-canonical per-`:deps` / `:deps-dev` entry `:fonte`
2546    /// Zig-store-model per-dep source-tuple optional-composite-reference
2547    /// accessor every consumer of the dep-graph fetch-source axis keys
2548    /// off — returns the author-declared `:fonte` typed [`DepSource`]
2549    /// verbatim as an `Option<&DepSource>` borrowed from the typed slot's
2550    /// own `Option<DepSource>` storage, with `None` naming the "author
2551    /// omitted `:fonte`" shorthand every resolver-side default-fill
2552    /// (`caixa-feira/src/cmd/lock.rs`'s stub, `caixa-resolver/src/resolve.rs`'s
2553    /// canonical fetcher, per the [`DepSource::default_github`] fallback
2554    /// the [`Dep::fonte`] field docstring already documents) treats as
2555    /// the "resolve through the configured default host / org
2556    /// (`github:<default-org>/<nome>`)" partition.
2557    ///
2558    /// The `:deps :fonte` / `:deps-dev :fonte` slot carries the two-
2559    /// arm typed [`DepSource`] the `Zig-style git-only store model` the
2560    /// enclosing [`Dep`] docstring names — `DepSource::Git { repo, tag,
2561    /// rev, branch }` for the git-clone arm every published caixa
2562    /// resolves through, `DepSource::Path { caminho }` for the dev-only
2563    /// local-filesystem arm every unpublishable in-tree checkout
2564    /// resolves through. Every downstream consumer that fans on the
2565    /// dep's fetch-source keys off this accessor: [`Self::validate`]'s
2566    /// per-`:fonte` [`DepSource::validate`] delegation (which raises
2567    /// the empty-`:repo` / missing-pin / multiple-pin / empty-`:caminho`
2568    /// diagnostics through the [`DepError::Fonte*`] carrier family
2569    /// naming the offending `Dep::nome`), the caixa-crd conversion
2570    /// crate's `dep_into_ref` two-arm projection into the `CaixaSource`
2571    /// `{repo, git_ref}` pair the K8s-CR side consumes
2572    /// (`caixa-crd/src/conversion.rs`), and — through the paired
2573    /// resolver-side default-fill's `Option::unwrap_or_else` — every
2574    /// `caixa-feira` / `caixa-resolver` fetch site that requires a
2575    /// concrete `DepSource` at run time.
2576    ///
2577    /// Prior to this lift the `.fonte` typed slot was read inline at
2578    /// every production site — the [`Self::validate`]
2579    /// `if let Some(ref fonte) = self.fonte` bracket the per-`:fonte`
2580    /// gate delegates through, the caixa-crd `dep_into_ref`
2581    /// `d.fonte.as_ref().and_then(...)` two-arm `CaixaSource` projector,
2582    /// the resolver-side `caixa-feira/src/cmd/lock.rs` / `caixa-resolver/src/resolve.rs`
2583    /// `dep.fonte.clone().unwrap_or_else(...)` default-fill pair — open-
2584    /// coded field-accesses that expressed no compile-time link back to
2585    /// the typed slot. A future extension of the `:deps :fonte` axis
2586    /// to a richer author surface (a per-scope source-override table
2587    /// the resolver folds through the `~/.config/caixa/config.yaml`
2588    /// entry the [`Dep`] docstring already acknowledges, a per-org
2589    /// mirror-fallback list the future M4 lacre-federation resolver
2590    /// consults ahead of the `default_github` fallback, a promotion of
2591    /// the plain `Option<DepSource>` to a richer
2592    /// `{primary, mirrors, integrity}` triple once cross-registry
2593    /// federation lands, a per-dep `sri:sha256-…` integrity slot the
2594    /// M4 lacre gate binds against ahead of the git-fetch) would have
2595    /// had to be threaded through every open-coded copy in lockstep or
2596    /// two consumers would silently disagree on which fetch source a
2597    /// given dep resolves to — the [`Self::validate`] per-`:fonte`
2598    /// gate reading the author-declared source while the caixa-crd
2599    /// projector read a per-scope-override-resolved source would
2600    /// silently split the build-time refusal from the CR the
2601    /// substrate's admission pipeline actually materializes, one
2602    /// build-time diagnostic disagreeing with the run-time closure.
2603    /// Lifting the resolution rule to a typed method on the substrate
2604    /// primitive means every downstream consumer of the caixa's per-
2605    /// `:deps` fetch-source surface reaches for exactly one typed
2606    /// dispatch — the resolver's accept-set migrates as a unit on any
2607    /// future axis addition.
2608    ///
2609    /// First outer-`Dep` `Option<&Composite>`-return composite-reference
2610    /// accessor — opens the outer-`Dep` `Option<&Composite>` composite-
2611    /// reference projection pattern the sibling per-`Dep` `:opcional`
2612    /// (`Option<Copy>` — the plain-bool axis) / `:caracteristicas`
2613    /// (`&[String]` — the feature-flag list) future outer scalar / slice
2614    /// lifts fold on. Peer of the outer-top-level [`crate::Caixa`]
2615    /// `Option<&Composite>` composite-reference sub-family the
2616    /// [`crate::Caixa::limits`] (b2bd9d7) / [`crate::Caixa::behavior`]
2617    /// (35d8b52) / [`crate::Caixa::politicas`] (5d23d29) /
2618    /// [`crate::Caixa::placement`] (4fb8074) / [`crate::Caixa::entrada`]
2619    /// (e4128e4) accessors already close on the outer [`crate::Caixa`]
2620    /// altitude, and of the outer M3 mesh-slot [`crate::AplicacaoSpec`]
2621    /// altitude the sibling [`crate::AplicacaoSpec::entrada`] (d32111c)
2622    /// accessor already carries — extends that "one typed dispatch on
2623    /// the substrate primitive, thin projections at each consumer"
2624    /// discipline onto the third outer typed-slot altitude that carries
2625    /// an `Option<Composite>` axis (`Dep`, the outer per-dep-list-entry
2626    /// slot). Returns `Option<&DepSource>` (not the owning composite by
2627    /// copy or clone) because every downstream consumer of the fonte
2628    /// composite treats it as a read-only per-arm dispatch source — the
2629    /// reference-view is the narrowest borrow that supports every
2630    /// present + roadmapped consumer (per-arm match projection at the
2631    /// caixa-crd `CaixaSource` two-arm emitter, presence-probe early
2632    /// return on the "author-omitted `:fonte` ⇒ resolver-side
2633    /// `default_github` fill applies" partition every resolver
2634    /// consults, `.cloned()`-on-demand for the two resolver-side
2635    /// default-fill call sites that require an owned `DepSource` for
2636    /// `Option::unwrap_or_else`) without cloning the composite through
2637    /// every consumer's fast path. The `Option` half of the return-type
2638    /// preserves the load-bearing "author-omitted `:fonte` ⇒ resolver-
2639    /// side default applies" partition (not a default composite the
2640    /// downstream must reject on emptiness) — the accessor projects the
2641    /// raw `Option<DepSource>` slot's presence bit through the
2642    /// reference-return unchanged. Named `fonte()` to match the storage
2643    /// field's name verbatim and the tatara-lisp author-surface term
2644    /// (`:fonte`) the field's own docstring already carries.
2645    ///
2646    /// Declared `pub const fn` — the body projects through
2647    /// `Option::<DepSource>::as_ref`, const-stable since Rust 1.83 and
2648    /// well within the workspace MSRV, so every downstream `const`-
2649    /// context consumer of the per-`Dep` `:fonte` composite-reference
2650    /// accessor reaches through the same typed dispatch on the
2651    /// substrate primitive at const-eval time as at runtime. The
2652    /// paired [`dep_outer_accessor_family_is_const_fn`][pin] pin
2653    /// (a `const fn <name>_via_const_fn(d: &Dep) -> …` wrapper family
2654    /// that forwards through each lifted accessor) locks the posture
2655    /// load-bearing at caixa-core build time — any future accidental
2656    /// downgrade to non-`const` fails the wrapper with E0015
2657    /// (`cannot call non-const method`), strictly stronger than a
2658    /// runtime `assert!` and side-stepping the destructor-in-const
2659    /// restriction the `Dep` fixture's `String` / `Option<DepSource>`
2660    /// / `Vec<String>` carriers rule out. Peer of the sibling per-
2661    /// `WitContract` pre-projection accessor family's `const`-eval-
2662    /// surface pass (279823b) and of the outer-`Caixa` slice-return
2663    /// accessor family's parallel pass (231a968) — same "one canonical
2664    /// dispatch per axis, `const`-eval posture pinned at the substrate
2665    /// primitive, thin projections at each consumer" discipline
2666    /// extended onto the outer per-dep-list-entry [`Dep`] altitude.
2667    ///
2668    /// [pin]: tests::dep_outer_accessor_family_is_const_fn
2669    #[must_use]
2670    pub const fn fonte(&self) -> Option<&DepSource> {
2671        self.fonte.as_ref()
2672    }
2673
2674    /// Substrate-canonical per-`:deps` / `:deps-dev` entry
2675    /// `:caracteristicas` Cargo-shaped feature-toggle-set slice accessor
2676    /// every consumer of the dep-graph feature-flag axis keys off —
2677    /// returns the author-declared `:caracteristicas` feature-name list
2678    /// verbatim as a `&[String]` slice-view over the same backing buffer
2679    /// the raw `self.caracteristicas.as_slice()` field access borrows
2680    /// from. Empty-list-carrying (`:caracteristicas` is a default-empty
2681    /// axis every `Dep` supplies with `Vec::new()` when the author omits
2682    /// the slot; the [`crate::Caixa::from_lisp`] derive folds an omitted
2683    /// `:caracteristicas` through `#[serde(default)]` to `Vec::new()`,
2684    /// so a `Dep` past parse definitionally carries a `Vec<String>` slot
2685    /// — possibly empty — and the returned `&[String]` degenerates to
2686    /// an empty slice on that arm without any silent `None` collapse).
2687    ///
2688    /// The `:deps :caracteristicas` / `:deps-dev :caracteristicas` slot
2689    /// carries the set-shaped feature-toggle list the substrate walks
2690    /// through the [`Self::validate_caracteristicas`] per-entry shape +
2691    /// duplicate cascade — same Cargo `[dependencies.<dep>.features]`
2692    /// accept-set (per-entry Cargo-feature-name grammar via the shared
2693    /// [`crate::render::is_cargo_feature_name`] predicate, cross-entry
2694    /// uniqueness via the shared [`crate::render::insert_first_seen`]
2695    /// walk, empty-first / value-shape-second / duplicate-third
2696    /// precedence via the peer per-axis two-arm cascade discipline every
2697    /// substrate-blessed Vec-keyed-by-name slot already follows).
2698    /// Every downstream consumer that fans on the dep's feature-toggle
2699    /// keys off this accessor: [`Self::validate_caracteristicas`]'s
2700    /// per-entry linear walk that gates each feature-name byte-string
2701    /// through the empty / value-shape / duplicate arms (raising the
2702    /// [`DepError::CaracteristicaEmpty`] / [`DepError::CaracteristicaInvalid`]
2703    /// / [`DepError::CaracteristicaDuplicate`] carrier family naming the
2704    /// offending `Dep::nome`), and every future
2705    /// per-`Caixa`-manifest / caixa-resolver / caixa-crd feature-toggle-
2706    /// facing consumer the CAIXA-SDLC §I roadmap acknowledges (the
2707    /// future caixa-resolver per-dep feature-projection walk that folds
2708    /// the toggle set into the resolved [`crate::Caixa`]'s activated
2709    /// [`crate::render::CARGO_FEATURE_NAME_MAX_LEN`]-bounded feature
2710    /// closure ahead of the lacre hash, the future caixa-crd per-`spec.deps`
2711    /// features slice the K8s-CR admission gate consumes, the future
2712    /// per-cluster feature-overlay the M4 lacre-federation resolver
2713    /// composes ahead of the substrate-wide feature-name accept-set).
2714    ///
2715    /// Prior to this lift the `.caracteristicas` byte-string list was
2716    /// read inline at the [`Self::validate_caracteristicas`] `for c in
2717    /// &self.caracteristicas` walk — the only in-crate consumer of the
2718    /// raw field beyond the per-`Dep` constructor pair
2719    /// ([`Self::simple`] / [`Self::git`]) and the paired serde
2720    /// round-trip / per-test fixture-mutation paths — an open-coded
2721    /// field-access that expressed no compile-time link back to the
2722    /// typed slot. A future extension of the `:caracteristicas` axis to
2723    /// a richer author surface (a per-scope feature-overlay the resolver
2724    /// folds through the `~/.config/caixa/config.yaml` entry the
2725    /// [`Dep`] docstring already acknowledges, a per-cluster feature-
2726    /// activation overlay the future M4 lacre-federation layer applies
2727    /// per-CR, a promotion of the plain `Vec<String>` byte-string list
2728    /// to a richer parsed-feature-set newtype once the Cargo-shaped
2729    /// namespaced-dep `dep/feat` syntax the value-shape gate's
2730    /// docstring anticipates lands) would have had to be threaded
2731    /// through every open-coded copy in lockstep or two consumers
2732    /// would silently disagree on which feature closure a given dep
2733    /// activates — the [`Self::validate_caracteristicas`] gate walking
2734    /// the author-declared list while a downstream caixa-resolver
2735    /// consumer walked a per-scope-override-resolved list would
2736    /// silently split the build-time refusal from the lacre closure
2737    /// the substrate's fetch pipeline actually materializes, one
2738    /// build-time diagnostic disagreeing with the run-time closure.
2739    /// Lifting the resolution rule to a typed method on the substrate
2740    /// primitive means every downstream consumer of the caixa's per-
2741    /// `:deps` feature-toggle surface reaches for exactly one typed
2742    /// dispatch — the resolver's accept-set migrates as a unit on any
2743    /// future axis addition.
2744    ///
2745    /// First outer-`Dep` `&[T]`-return slice accessor — opens the
2746    /// outer-`Dep` `&[String]` slice projection pattern the sibling
2747    /// per-`Dep` `:opcional` (`bool` — the plain-`Copy`-scalar axis)
2748    /// future outer scalar lift folds on and closes the outer-`Dep`
2749    /// slot-family the sibling [`Self::nome`] (eba2cde) /
2750    /// [`Self::versao_requirement`] (05529b1) / [`Self::fonte`] (d65d1bf)
2751    /// accessors already open, leaving the `:opcional` `Copy`-scalar arm
2752    /// as the sole remaining unlifted outer-`Dep` slot. Peer of the
2753    /// outer top-level [`crate::Caixa`] `&[String]`-return foreign-code-
2754    /// slot sub-family ([`crate::Caixa::bibliotecas`] 8a36c23,
2755    /// [`crate::Caixa::exe`] 65d9527, [`crate::Caixa::servicos`]
2756    /// 611f78b) and the outer top-level [`crate::Caixa`] universal-axis
2757    /// text-tag family ([`crate::Caixa::autores`] b5d813f,
2758    /// [`crate::Caixa::etiquetas`] 78c7d3c) that already carry the
2759    /// `&[String]` slice-projection discipline on the outer-`Caixa`
2760    /// altitude — extends the "one typed dispatch on the substrate
2761    /// primitive, thin projections at each consumer" discipline onto the
2762    /// outer per-dep-list-entry [`Dep`] altitude's set-shaped byte-
2763    /// string list slot. Returns `&[String]` (not `&Vec<String>`)
2764    /// because every downstream consumer of the feature-toggle list
2765    /// treats it as a read-only sequence — the slice-view is the
2766    /// narrowest borrow that supports every present + roadmapped
2767    /// consumer (`.iter()`, `.len()`, `.is_empty()`) without leaking
2768    /// the backing `Vec`'s grow/push/reserve surface no consumer of
2769    /// the typed view reaches for (the storage-side `Vec` remains
2770    /// reachable through the `pub caracteristicas` field for the
2771    /// mutation-carrying serde round-trip and per-test fixture-mutation
2772    /// paths). Named `caracteristicas()` to match the storage field's
2773    /// name verbatim and the tatara-lisp author-surface term
2774    /// (`:caracteristicas`) the field's own docstring already carries.
2775    ///
2776    /// Declared `pub const fn` — the body projects through
2777    /// `Vec::<String>::as_slice`, const-stable since Rust 1.83 and
2778    /// well within the workspace MSRV, so every downstream `const`-
2779    /// context consumer of the per-`Dep` `:caracteristicas` slice-
2780    /// accessor reaches through the same typed dispatch on the
2781    /// substrate primitive at const-eval time as at runtime. Pinned
2782    /// load-bearing by the paired
2783    /// [`dep_outer_accessor_family_is_const_fn`][pin] wrapper family
2784    /// alongside its sibling [`Self::fonte`] — see [`Self::fonte`] for
2785    /// the full pin-shape rationale.
2786    ///
2787    /// [pin]: tests::dep_outer_accessor_family_is_const_fn
2788    #[must_use]
2789    pub const fn caracteristicas(&self) -> &[String] {
2790        self.caracteristicas.as_slice()
2791    }
2792
2793    /// Substrate-canonical per-`:deps` / `:deps-dev` entry `:opcional`
2794    /// missing-source-tolerance flag scalar accessor every consumer of
2795    /// the dep-graph opt-in-fetch axis keys off — returns the author-
2796    /// declared `:opcional` `bool` verbatim, `Copy`-projected from the
2797    /// typed slot's own `bool` storage (no borrow of `&self` past the
2798    /// call; the `Copy`-return arm matches the peer
2799    /// [`crate::Caixa::max_restarts`] (eba5211) `Option<u32>` `Copy`-
2800    /// projected sibling discipline the outer flat-spread family
2801    /// already carries). Default-`false` (`#[serde(default,
2802    /// skip_serializing_if = "is_false")]` on the storage slot, so a
2803    /// `Dep` past parse definitionally carries a `bool` — `false` when
2804    /// the author omits `:opcional` — and the returned value degenerates
2805    /// to `false` on that arm without any silent `None` collapse).
2806    ///
2807    /// The `:deps :opcional` / `:deps-dev :opcional` slot carries the
2808    /// per-entry "if this dep's `:fonte` cannot be resolved, treat the
2809    /// missing-source arm as a soft-fail rather than a build refusal"
2810    /// bit — the same Cargo-shaped `[dependencies.<dep>.optional = true]`
2811    /// accept-set (an opcional dep whose `:fonte` fails to resolve is
2812    /// dropped from the resolved dep-graph rather than tripping the
2813    /// build-refusal edge that a mandatory `:opcional false` entry
2814    /// would). Every downstream consumer that fans on the dep's
2815    /// missing-source-tolerance keys off this accessor: the future
2816    /// caixa-resolver's per-`:fonte` resolve-fail arm (drop-vs-error
2817    /// dispatch on the opcional bit ahead of the lacre closure
2818    /// materialization), the future caixa-crd per-`spec.deps`
2819    /// `optional` boolean the K8s-CR admission gate consumes on the
2820    /// per-dep partition, and the future feira / caixa-resolver /
2821    /// caixa-crd feature-projection walk that folds the opcional bit
2822    /// into the resolved feature-closure the future M4 lacre-federation
2823    /// layer emits.
2824    ///
2825    /// Prior to this lift the `.opcional` `bool` slot was read inline
2826    /// at the sole in-crate consumer site — the tests-module
2827    /// `registry_dep_is_minimal` fixture's `assert!(!d.opcional)` gate
2828    /// pinning the [`Self::simple`] constructor's default-`false` fill
2829    /// (the only in-crate read of the raw field beyond the per-`Dep`
2830    /// constructor pair [`Self::simple`] / [`Self::git`] and the paired
2831    /// serde round-trip / per-test fixture-mutation paths) — an open-
2832    /// coded field-access that expressed no compile-time link back to
2833    /// the typed slot. A future extension of the `:opcional` axis to a
2834    /// richer author surface (a per-scope opcional-override the resolver
2835    /// folds through the `~/.config/caixa/config.yaml` entry the [`Dep`]
2836    /// docstring already acknowledges, a per-cluster opcional-override
2837    /// the future M4 lacre-federation layer applies per-CR, a promotion
2838    /// of the plain `bool` to a richer `OpcionalPolicy { drop, warn,
2839    /// error }` tri-state once the CAIXA-SDLC §II opcional-policy
2840    /// roadmap lands) would have had to be threaded through every open-
2841    /// coded copy in lockstep or two consumers would silently disagree
2842    /// on which missing-source arm a given dep resolves to — the
2843    /// [`Self::simple`] constructor's default-`false` fill reading
2844    /// verbatim while a downstream caixa-resolver consumer read a per-
2845    /// scope-override-resolved bit would silently split the build-time
2846    /// arm from the lacre closure the substrate's fetch pipeline
2847    /// actually materializes, one build-time diagnostic disagreeing
2848    /// with the run-time closure. Lifting the resolution rule to a
2849    /// typed method on the substrate primitive means every downstream
2850    /// consumer of the caixa's per-`:deps` opcional-tolerance surface
2851    /// reaches for exactly one typed dispatch — the resolver's accept-
2852    /// set migrates as a unit on any future axis addition.
2853    ///
2854    /// Fifth and final outer-`Dep` accessor — closes the outer-`Dep`
2855    /// slot-family the sibling per-`Dep` [`Self::nome`] (eba2cde) /
2856    /// [`Self::versao_requirement`] (05529b1) / [`Self::fonte`] (d65d1bf)
2857    /// / [`Self::caracteristicas`] (9197944) accessors opened, so every
2858    /// outer-`Dep` slot (`:nome`, `:versao`, `:fonte`, `:opcional`,
2859    /// `:caracteristicas`) now routes through exactly one typed
2860    /// dispatch on the substrate primitive. First outer-`Dep`
2861    /// `bool`-return / plain-`Copy`-scalar accessor — opens the
2862    /// outer-`Dep` `Copy`-scalar projection pattern that folds on the
2863    /// peer outer-top-level [`crate::Caixa`] `Option<Copy>`
2864    /// flat-spread sub-family ([`crate::Caixa::max_restarts`] eba5211,
2865    /// [`crate::Caixa::estrategia`] ed04d3c) the outer-`Caixa` altitude
2866    /// already carries — extends the "one typed dispatch on the
2867    /// substrate primitive, thin projections at each consumer"
2868    /// discipline onto the outer per-dep-list-entry [`Dep`] altitude's
2869    /// bool-shaped missing-source-tolerance slot. Returns `bool` by
2870    /// `Copy` (not by `&bool` reference) because `bool` is `Copy` and
2871    /// every downstream consumer treats it as a plain discriminant
2872    /// value — the by-value return is the narrowest return-shape that
2873    /// supports every present + roadmapped consumer (`.then(…)` early
2874    /// return on the resolver-side drop-vs-error partition, direct
2875    /// bool composition with a per-scope-override projector, plain
2876    /// `if dep.opcional() { … }` early return at every future admission
2877    /// gate) without leaking the storage field's `bool`-in-`&self`
2878    /// lifetime the by-value return elides. Marked `pub const fn` so
2879    /// the accessor is `const`-callable — same discipline the peer
2880    /// [`crate::Caixa::max_restarts`] `Option<u32>` `Copy`-return
2881    /// accessor carries. Named `opcional()` to match the storage
2882    /// field's name verbatim and the tatara-lisp author-surface term
2883    /// (`:opcional`) the field's own docstring already carries.
2884    #[must_use]
2885    pub const fn opcional(&self) -> bool {
2886        self.opcional
2887    }
2888
2889    /// Build a minimal registry-sourced dep.
2890    #[must_use]
2891    pub fn simple(nome: impl Into<String>, versao: impl Into<String>) -> Self {
2892        Self {
2893            nome: nome.into(),
2894            versao: versao.into(),
2895            fonte: None,
2896            opcional: false,
2897            caracteristicas: Vec::new(),
2898        }
2899    }
2900
2901    /// Build a Git-sourced dep (tag-based).
2902    #[must_use]
2903    pub fn git(
2904        nome: impl Into<String>,
2905        versao: impl Into<String>,
2906        repo: impl Into<String>,
2907        tag: impl Into<String>,
2908    ) -> Self {
2909        Self {
2910            nome: nome.into(),
2911            versao: versao.into(),
2912            fonte: Some(DepSource::Git {
2913                repo: repo.into(),
2914                tag: Some(tag.into()),
2915                rev: None,
2916                branch: None,
2917            }),
2918            opcional: false,
2919            caracteristicas: Vec::new(),
2920        }
2921    }
2922
2923    /// Reject dependency entries whose `:nome` or `:versao` are empty,
2924    /// whose `:nome` is non-empty but not a valid DNS-1123 label,
2925    /// or whose `:versao` is non-empty but not a valid Cargo-shaped
2926    /// semver requirement.
2927    ///
2928    /// The author surface for `:deps :versao` (and `:deps-dev :versao`)
2929    /// is the same Cargo-shaped requirement string `:membros :versao`
2930    /// (validated at [`crate::AplicacaoSpec::validate`] since 9888b13)
2931    /// and `:children :versao` (validated at
2932    /// [`crate::SupervisorSpec::validate`] since b38ff3a) carry — and
2933    /// the lacre pipeline resolves all three axes through the same
2934    /// [`crate::parse_requirement`] entry-point. Until 2420c44 landed
2935    /// `:deps :versao` was the last `:versao` axis untyped past
2936    /// `Caixa::from_lisp`: a malformed-but-non-empty requirement
2937    /// (`"^bad-version"`, `"^^0.1"`, the canonical git-tag-shape-
2938    /// leaking-into-:versao `"v0.1"` typo, the accidental
2939    /// `"not-a-req"`) silently passed parse and the `semver::Error`
2940    /// surfaced at lacre-resolve time, far from the source
2941    /// caixa.lisp, with no field naming which `:deps` entry carried
2942    /// the typo. The diagnostic [`DepError::VersaoInvalid`] carries
2943    /// the offending entry's `:nome` + the offending `:versao`
2944    /// verbatim + the parser's own wording in `reason`, so the
2945    /// author's grep target is unambiguous.
2946    ///
2947    /// The author surface for `:deps :nome` is the same DNS-1123 label
2948    /// the peer caixa-identifier axes carry — top-level Caixa `:nome`
2949    /// (validated at [`crate::Caixa::validate_nome`] since 6c992f8),
2950    /// `:membros :caixa` (validated at
2951    /// [`crate::AplicacaoSpec::validate_membros`] since 3f9d7a0),
2952    /// `:children :caixa` (validated at
2953    /// [`crate::SupervisorSpec::validate`] since 31bfa43). A `:deps
2954    /// :nome` value flows verbatim through the lacre pipeline as the
2955    /// target caixa's `:nome` (which the gate at the *target* side now
2956    /// rejects if non-DNS-1123) and lands as the rendered caixa's
2957    /// `lareira-<nome>` Helm chart name segment, the per-dep
2958    /// `LABEL_PROGRAM` label value, and the `caixa-resolver`'s
2959    /// `~/.cache/caixa/<org>/<nome>` checkout-directory leaf. Until
2960    /// this gate landed `:deps :nome` was the fourth and last
2961    /// DNS-1123-shaped caixa-identifier axis still untyped past
2962    /// `Caixa::from_lisp`: a syntactically wrong dep name (`"Caixa-
2963    /// Teia"` uppercase — the canonical "I copied the README header"
2964    /// typo; `"caixa_teia"` underscore — the Go module / Python
2965    /// identifier leak; `"caixa-teia."` trailing dot — the FQDN
2966    /// confusion; `"-caixa-teia"` leading hyphen; a 64-byte slug)
2967    /// silently passed parse and surfaced at lacre-resolve time when
2968    /// the resolved target caixa's `:nome` failed *its* DNS-1123 gate
2969    /// — far from the source `:deps` entry, with a diagnostic naming
2970    /// the *target's* `:nome` rather than the dep entry that referenced
2971    /// it. Mirroring the 3f9d7a0 / 31bfa43 / 6c992f8 trajectory through
2972    /// the lifted [`crate::render::is_dns_1123_label`] predicate (the
2973    /// "before its third occurrence" PRIME DIRECTIVE boundary, THEORY.md
2974    /// §I.3.5): every `Dep::nome` past validate is DNS-1123-label-shaped,
2975    /// so every downstream consumer (caixa-resolver's lacre fetch,
2976    /// caixa-helm's `lareira-<nome>` chart name, the future M4 per-dep
2977    /// fan-out emitter) reaches for the name knowing the value is
2978    /// apiserver-valid without re-validating.
2979    ///
2980    /// Empty checks fire first (narrower diagnostic), parse last —
2981    /// same ordering discipline as
2982    /// [`crate::AplicacaoSpec::validate_membros`] and
2983    /// [`crate::SupervisorSpec::validate`]. `parse_requirement("")`
2984    /// returns `Ok(VersionReq::STAR)`, so the empty-`:versao` arm is
2985    /// structurally necessary even with the parse arm in place. The
2986    /// `:nome` shape gate runs after the `:nome` empty gate and before
2987    /// the `:versao` checks so a one-entry caixa.lisp with both wrong
2988    /// sees the name-side diagnostic first (the name is the
2989    /// self-locating axis — without it, the parse diagnostic can't
2990    /// quote `:nome "<bad>"`).
2991    pub fn validate(&self) -> Result<(), DepError> {
2992        if self.nome.is_empty() {
2993            return Err(DepError::NomeEmpty);
2994        }
2995        if let Err(reason) = crate::render::is_dns_1123_label(&self.nome) {
2996            return Err(DepError::NomeInvalid {
2997                nome: self.nome.clone(),
2998                reason,
2999            });
3000        }
3001        // Delegate the empty-first + `parse_requirement` cascade to the
3002        // shared [`crate::render::require_valid_versao_requirement`]
3003        // helper — same two-arm shape the peer
3004        // [`crate::AplicacaoSpec::validate_membros`] on `:membros
3005        // :versao` and [`crate::SupervisorSpec::validate`] on `:children
3006        // :versao` route through, so drift between the three axes'
3007        // accepted requirement sets is structurally impossible and the
3008        // parse-side no-op the empty-first arm closes (semver's empty
3009        // parse yields an implicit `*`) lives in exactly one predicate.
3010        crate::render::require_valid_versao_requirement(
3011            self.versao_requirement(),
3012            || DepError::versao_empty(&self.nome),
3013            |reason| DepError::VersaoInvalid {
3014                nome: self.nome.clone(),
3015                versao: self.versao_requirement().to_string(),
3016                reason,
3017            },
3018        )?;
3019        if let Some(fonte) = self.fonte() {
3020            fonte.validate(&self.nome)?;
3021        }
3022        self.validate_caracteristicas()?;
3023        Ok(())
3024    }
3025
3026    /// Reject per-entry `:caracteristicas` (feature-flag) values that
3027    /// are operationally meaningless. The `:caracteristicas` slot is
3028    /// a set of feature toggles to enable on the target caixa — same
3029    /// shape as Cargo's `[dependencies.<dep>.features]` list — and
3030    /// two structural footguns close here:
3031    ///
3032    ///   - empty-string entry (`(:caracteristicas (""))`): the future
3033    ///     caixa-resolver lacre pipeline would consume the empty
3034    ///     identifier as a no-op feature enable, silently dropping the
3035    ///     author's intent far from the source `caixa.lisp`;
3036    ///   - duplicate entry within one dep (`(:caracteristicas ("http"
3037    ///     "http"))`): the feature-toggle slot is set-shaped (enabling
3038    ///     a feature twice has no additional semantic — there is no
3039    ///     `feature × 2`), so two entries naming the same feature are
3040    ///     a silent miscount, the same set-not-multiset distinction
3041    ///     every peer Vec-keyed-by-name axis already closes
3042    ///     ([`crate::SupervisorError::DuplicateChildCaixa`] on
3043    ///     `:children :caixa`, [`crate::AplicacaoError::MembroDuplicate`]
3044    ///     on `:membros :caixa`, [`crate::AplicacaoError::ContratoDuplicate`]
3045    ///     on `:contratos`, [`crate::AplicacaoError::PlacementClusterDuplicate`]
3046    ///     on `:placement :clusters`, [`crate::AplicacaoError::EntradaPathDuplicate`]
3047    ///     on `:entrada :paths`, [`crate::UpgradeError::DuplicateFrom`]
3048    ///     on `:upgrade-from :from`, [`crate::UpgradeError::DuplicateLoadModule`]
3049    ///     / [`crate::UpgradeError::DuplicateStateChange`] /
3050    ///     [`crate::UpgradeError::DuplicateCleanup`] on the within-
3051    ///     entry `:upgrade-from` axes, and [`DepError::DuplicateNome`]
3052    ///     on the cross-entry `:deps`/`:deps-dev` `:nome` axis the
3053    ///     immediate-predecessor 359fba5 closed).
3054    ///
3055    /// Same linear-walk + `HashSet` + first-collision diagnostic shape
3056    /// every peer set-not-multiset gate uses; the empty arm fires
3057    /// before the duplicate arm so an entry with both an empty feature
3058    /// *and* a duplicate of some later feature surfaces the empty-
3059    /// shape diagnostic first (the empty-feature axis is the
3060    /// more-actionable defect since the missing-name renders the
3061    /// duplicate-key arm ambiguous: two `""` entries would both report
3062    /// `caracteristica: ""` with no way to distinguish the offending
3063    /// site). Empty-first cascade discipline mirrors every peer per-
3064    /// entry shape + duplicate gate
3065    /// (`SupervisorSpec::validate`'s `EmptyChildName` before
3066    /// `DuplicateChildCaixa`; `validate_membros`'s `MembroCaixaEmpty`
3067    /// before `MembroDuplicate`).
3068    ///
3069    /// The per-entry value-shape gate (Cargo-feature-name grammar via
3070    /// the lifted [`crate::render::is_cargo_feature_name`] predicate)
3071    /// fires between the empty arm and the duplicate arm — the
3072    /// canonical per-entry-shape-before-cross-entry-uniqueness
3073    /// precedence every peer two-arm + value-shape gate establishes
3074    /// ([`crate::SupervisorSpec::validate`]'s `EmptyChildName` →
3075    /// `ChildCaixaInvalid` → `DuplicateChildCaixa`,
3076    /// [`crate::AplicacaoSpec::validate_membros`]'s `MembroCaixaEmpty`
3077    /// → `MembroCaixaInvalid` → `MembroDuplicate`, [`Dep::validate`]'s
3078    /// `NomeEmpty` → `NomeInvalid` → cross-list `DuplicateNome`).
3079    /// Until the value-shape arm landed `:caracteristicas` accepted
3080    /// every non-empty distinct string — a structurally invalid
3081    /// feature name (`"http feature"` whitespace, `"+http"` the
3082    /// canonical paste-from-`+optional-feature` doc activation-form
3083    /// footgun, `"-flag"` leading hyphen, `".feat"` leading dot,
3084    /// `"http/json"` Cargo's `dep/feat` namespaced-dep syntax that
3085    /// only applies inside list-grammar contexts, `"http,json"`
3086    /// list-separator-belongs-to-the-list-grammar miscomprehension,
3087    /// `"café"` un-percent-encoded non-ASCII silently round-tripping
3088    /// inconsistently across NFC/NFD normalization, the 65-byte
3089    /// paste-from-binary slug) silently passed validate and the
3090    /// failure surfaced at `cargo metadata` time as the
3091    /// `restricted_names::validate_feature_name` parser's rejection,
3092    /// far from the source `caixa.lisp`, with no field naming which
3093    /// `:deps` entry's `:caracteristicas` carried the typo. The
3094    /// lifted predicate makes the Cargo-feature-name-grammar
3095    /// intersection-floor a substrate-level invariant at validate
3096    /// time — same trajectory as the eight peer
3097    /// [`crate::render`] value-shape predicates each typed surface
3098    /// downstream of a structured grammar already follows
3099    /// ([`is_dns_1123_label`](crate::render::is_dns_1123_label),
3100    /// [`is_gateway_api_http_path`](crate::render::is_gateway_api_http_path),
3101    /// [`is_wit_world_ref`](crate::render::is_wit_world_ref),
3102    /// [`is_nats_subject`](crate::render::is_nats_subject),
3103    /// [`is_wasi_keyvalue_slot`](crate::render::is_wasi_keyvalue_slot),
3104    /// [`is_git_ref_name`](crate::render::is_git_ref_name),
3105    /// [`is_git_oid`](crate::render::is_git_oid),
3106    /// [`is_git_repo_url`](crate::render::is_git_repo_url)).
3107    fn validate_caracteristicas(&self) -> Result<(), DepError> {
3108        let mut seen = std::collections::HashSet::new();
3109        for c in self.caracteristicas() {
3110            if c.is_empty() {
3111                return Err(DepError::caracteristica_empty(&self.nome));
3112            }
3113            if let Err(reason) = crate::render::is_cargo_feature_name(c) {
3114                return Err(DepError::CaracteristicaInvalid {
3115                    nome: self.nome.clone(),
3116                    caracteristica: c.clone(),
3117                    reason,
3118                });
3119            }
3120            crate::render::insert_first_seen(&mut seen, c.as_str(), || {
3121                DepError::CaracteristicaDuplicate {
3122                    nome: self.nome.clone(),
3123                    caracteristica: c.clone(),
3124                }
3125            })?;
3126        }
3127        Ok(())
3128    }
3129}
3130
3131/// Cross-slot coherence gate on the dep-graph axis: no `:deps` or
3132/// `:deps-dev` entry may name the caixa's own `:nome`.
3133///
3134/// A caixa that lists itself as a dep is a degenerate self-edge in the
3135/// lacre closure's dep-graph — the closure is a DAG rooted at the
3136/// caixa's `:nome`, and the caixa-resolver's lacre pipeline traverses
3137/// every `:deps` / `:deps-dev` entry's target by name. A self-dep
3138/// hands the resolver a node that is its own parent: a one-node cycle
3139/// it either rejects mid-traversal far from the source `caixa.lisp`
3140/// (the resolver detecting infinite recursion on the closure walk) or,
3141/// worse, recurses on until it exhausts its stack. Because every
3142/// `:nome` is a globally-unique substrate identity (DNS-1123 label +
3143/// lacre closure root), a dep entry whose `:nome` equals the caixa's
3144/// own `:nome` *is* the caixa itself, not a coincidentally-named peer.
3145///
3146/// Lives outside [`Caixa::validate_deps`] because the dep-list view
3147/// carries the entries but not the parent `:nome`; mirrors the
3148/// cross-slot self-edge gates [`crate::supervisor::validate_no_self_supervision`]
3149/// (ad4abf1) on the `:children :caixa` axis and
3150/// [`crate::aplicacao::validate_no_self_membership`] on the
3151/// `:membros :caixa` axis — the same "an edge from a graph node to
3152/// itself is structurally not a tree/graph edge" discipline, here on
3153/// the third typed-name-graph axis (the dep closure; the supervision
3154/// tree and the Aplicacao membership set were the prior two).
3155///
3156/// Walks `:deps` first then `:deps-dev` so the diagnostic for a caixa
3157/// that self-references on both axes surfaces the `:deps` arm first —
3158/// the load-bearing axis the lacre closure resolves at every build,
3159/// peer with the canonical [`Caixa::validate_deps`] walk order
3160/// (`:deps` → `:deps-dev`).
3161///
3162/// Carries the offending list tag (`":deps"` or `":deps-dev"`)
3163/// verbatim into the diagnostic so the author can grep their
3164/// `caixa.lisp` for the offending block in one edit — same
3165/// `list: &'static str` shape [`DepError::DuplicateNome`] (359fba5)
3166/// uses on the cross-list duplicate-name axis.
3167///
3168/// `Code paths` (`:bibliotecas` / `:exe` / `:servicos`) are the
3169/// substrate-blessed shape for referencing the caixa's *own* code, so
3170/// the diagnostic names them as the corrective surface — every
3171/// legitimate "I want to use code from this caixa" authoring intent
3172/// routes through one of those three slots, not a self-dep.
3173pub fn validate_no_self_dep(
3174    deps: &[Dep],
3175    deps_dev: &[Dep],
3176    parent_nome: &str,
3177) -> Result<(), DepError> {
3178    for dep in deps {
3179        if dep.nome() == parent_nome {
3180            return Err(DepError::DepIsSelf {
3181                nome: parent_nome.to_string(),
3182                list: crate::render::DEP_AUTHOR_KEY_DEPS,
3183            });
3184        }
3185    }
3186    for dep in deps_dev {
3187        if dep.nome() == parent_nome {
3188            return Err(DepError::DepIsSelf {
3189                nome: parent_nome.to_string(),
3190                list: crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
3191            });
3192        }
3193    }
3194    Ok(())
3195}
3196
3197/// Closed-set typed enum for the two dep-list author-surface axes every
3198/// top-level [`crate::Caixa`] carries — the runtime-closure `:deps` slot
3199/// (`Prod`) and the dev-only-closure `:deps-dev` slot (`Dev`). Every
3200/// substrate consumer that dispatches on "which of the two dep-lists"
3201/// (the `feira add` mutation head, the future per-cluster dev-closure-
3202/// audit overlay the M4 CR materializer resolves per-CR, the future
3203/// `caixa app graph` per-list dep summary, every future
3204/// `Caixa::push_dep` / `Caixa::deps_by_list` typed-method dispatch a
3205/// caller reaches for) reads through this enum rather than through a
3206/// bare `&'static str` — the closed-set is expressed at the type layer,
3207/// so a future third dep-list axis (a `:deps-build` build-only closure
3208/// once the substrate grows cross-artifact heterogeneous dep-graphs,
3209/// per CAIXA-SDLC §I) is one variant plus one arm per method and the
3210/// compiler enforces exhaustiveness on every consumer's `match` arms.
3211///
3212/// The wire byte-string [`Self::as_str`] returns is the same author-
3213/// surface tag the sibling [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3214/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] constants carry — the
3215/// [`DepError::DuplicateNome`] / [`DepError::DepIsSelf`] `list:
3216/// &'static str` payload family the substrate already emits routes
3217/// through the same source of truth (an author reading a
3218/// [`DepError::DuplicateNome`] refusal can grep their `caixa.lisp`
3219/// for the offending `:deps` / `:deps-dev` block in one edit whether
3220/// the diagnostic came from a `Caixa::validate_deps` walk or a
3221/// `Caixa::push_dep` mutation).
3222///
3223/// Same "closed-set typed-enum discriminator with canonical
3224/// projections per axis" discipline the sibling closed-set typed enums
3225/// on the caixa typed surface carry
3226/// ([`crate::aplicacao::PlacementStrategy`] cc8f749,
3227/// [`crate::aplicacao::RateLimitUnit`] 6bce03d,
3228/// [`crate::supervisor::RestartStrategy`],
3229/// [`crate::supervisor::RestartPolicy`],
3230/// [`crate::upgrade::UpgradeInstruction`], [`crate::CaixaKind`])
3231/// — extended onto the outer-`Caixa` two-list dep-graph axis, the
3232/// substrate's last unlifted closed-set-shaped `&'static str`-carrying
3233/// axis on the top-level manifest surface.
3234#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, gen_platform::IsVariant)]
3235pub enum DepList {
3236    /// Runtime-closure `:deps` axis — the load-bearing dep-list the
3237    /// lacre closure resolves at every build. Wire-format
3238    /// [`crate::render::DEP_AUTHOR_KEY_DEPS`].
3239    Prod,
3240    /// Dev-only-closure `:deps-dev` axis — Cargo's `[dev-dependencies]`
3241    /// table's dev-time-only visibility contract per CAIXA-SDLC §I.
3242    /// Wire-format [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`].
3243    Dev,
3244}
3245
3246impl DepList {
3247    /// Exhaustive iteration surface for every consumer that reads the
3248    /// full closed-set (the future M4 admission webhook's per-list
3249    /// summary rejection body, any future round-trip pin harness). A
3250    /// future variant addition extends this slice as a single edit and
3251    /// every consumer picks up the new entry by construction — the
3252    /// compiler-checked exhaustiveness on the sibling method `match`
3253    /// arms is the build-time guarantee that no arm forgets to grow.
3254    pub const ALL: &'static [Self] = &[Self::Prod, Self::Dev];
3255
3256    /// Canonical author-surface tag every substrate consumer that
3257    /// names the offending dep-list in a diagnostic reaches for —
3258    /// [`crate::render::DEP_AUTHOR_KEY_DEPS`] for [`Self::Prod`] and
3259    /// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] for [`Self::Dev`],
3260    /// the same `&'static str` payload the sibling
3261    /// [`DepError::DuplicateNome`] and [`DepError::DepIsSelf`] variants
3262    /// already carry. Routing every dep-list diagnostic through the
3263    /// closed-set enum's `as_str` closes the last `&'static str`-shape
3264    /// literal-carry axis on the two-list dep-graph surface — a
3265    /// future kebab-case rebrand (`":deps"` → `":packages"`) or a
3266    /// wire-format promotion (a distinct diagnostic form for the
3267    /// `Dev` arm) reaches every consumer through one edit on the
3268    /// canonical constant, not a coordinated rewrite across the
3269    /// substrate's dep-graph consumers.
3270    #[must_use]
3271    pub const fn as_str(self) -> &'static str {
3272        match self {
3273            Self::Prod => crate::render::DEP_AUTHOR_KEY_DEPS,
3274            Self::Dev => crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
3275        }
3276    }
3277
3278    /// Substrate-canonical reverse projection on the two-list dep-graph
3279    /// axis — parses the author-surface wire tag back to the typed
3280    /// variant, or `None` when `s` is outside the closed-set arm-string
3281    /// set [`Self::as_str`] emits. Dispatches on the same lifted
3282    /// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3283    /// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] constants the
3284    /// [`Self::as_str`] emitter walks, so the parse and emit halves of
3285    /// the round-trip migrate through one caixa-core edit on any future
3286    /// list-axis addition.
3287    ///
3288    /// Prior to this lift the substrate carried only the forward
3289    /// `Self → &str` projection on the two-list dep-graph axis (the
3290    /// [`Self::as_str`] emitter, the [`std::fmt::Display`] impl routed
3291    /// through it, the two [`DepError::DuplicateNome`] /
3292    /// [`DepError::DepIsSelf`] variants that carry the wire tag verbatim
3293    /// as a `&'static str` `list:` field). Every future consumer that
3294    /// wanted to promote the wire tag back to the typed enum (a future
3295    /// `feira dep --list <deps|deps-dev>` CLI arg-parse that binds the
3296    /// wire form into the typed enum before dispatching to
3297    /// [`crate::Caixa::deps_of`] / [`crate::Caixa::push_dep`], the M4
3298    /// `mesh.pleme.io/v1alpha1/Caixa` CR materializer's admission-time
3299    /// wire re-parse of the per-list diagnostic body, a future
3300    /// [`DepError`] widening that promotes the two `list: &'static str`
3301    /// fields to a typed `list: DepList` carry so downstream consumers
3302    /// dispatch on the enum rather than string-comparing the wire
3303    /// scalar) would have had to re-inline a two-arm `match s { ":deps"
3304    /// => …, ":deps-dev" => …, _ => … }` cascade that expressed no
3305    /// compile-time link back to the typed [`DepList`] enum. A future
3306    /// variant addition (a `:build-dep` or `:test-dep` third list once
3307    /// the substrate grows Cargo-style split-graphs, a `:tool-dep` for
3308    /// build-time-only tooling per the peer Cargo `[build-dependencies]`
3309    /// / `[target.<cfg>.dev-dependencies]` future admission surface)
3310    /// would silently split the wire byte-string the emitter walks from
3311    /// the parser's arm-set — the round-trip would carry the new list
3312    /// through the forward projection but land on the fallback silently
3313    /// at every non-updated reverse parser, far from the arm-addition
3314    /// commit that caused the drift. Lifting the resolver to a typed
3315    /// method on the substrate primitive closes the drift footgun by
3316    /// construction: the parser's accept-set is the same set the
3317    /// [`Self::as_str`] emitter walks (routed through the same lifted
3318    /// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3319    /// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] consts), so both halves
3320    /// of the round-trip migrate through one caixa-core edit on any
3321    /// future list-axis addition.
3322    ///
3323    /// Same closed-set-reverse-projection discipline the sibling
3324    /// [`crate::CaixaKind::from_wire`] (2aa6d23) /
3325    /// [`crate::supervisor::RestartStrategy::from_wire`] (4eec29c) /
3326    /// [`crate::supervisor::RestartPolicy::from_wire`] (dd32ccf) /
3327    /// [`crate::aplicacao::PlacementStrategy::from_wire`] (18c7342) /
3328    /// [`crate::aplicacao::RateLimitUnit::from_suffix`] typed enums
3329    /// carry on the peer wire-side `str → Self` axes — extended onto
3330    /// the two-list dep-graph closed-set axis, the sixth substrate-side
3331    /// closed-set typed enum on the caixa surface to converge on the
3332    /// two-way `str ↔ Self` round-trip. Method-named `from_wire` (not
3333    /// `from_str`) to match the peer shapes verbatim and side-step the
3334    /// derived [`std::str::FromStr`] impls the sibling
3335    /// [`gen_platform::FromStrKind`]-carrying axes install on their
3336    /// kebab-case dispatcher-catalog identity. Returns `Option<Self>`
3337    /// (rather than `Result<Self, _>`) to match the peer shapes: the
3338    /// caller picks the diagnostic form appropriate for its use site —
3339    /// a future `feira dep --list …` arg-parse that surfaces
3340    /// `unknown list: <arg>` at the CLI builds one on top by iterating
3341    /// [`Self::ALL`], while the future M4 admission-webhook's rejection
3342    /// path folds `None` onto its per-CR structured refusal body.
3343    #[must_use]
3344    pub fn from_wire(s: &str) -> Option<Self> {
3345        match s {
3346            crate::render::DEP_AUTHOR_KEY_DEPS => Some(Self::Prod),
3347            crate::render::DEP_AUTHOR_KEY_DEPS_DEV => Some(Self::Dev),
3348            _ => None,
3349        }
3350    }
3351}
3352
3353/// Route [`std::fmt::Display`] through [`DepList::as_str`], so every
3354/// consumer that formats the axis as user-facing text (a future
3355/// `feira app graph` per-list summary, a future M4 admission-webhook
3356/// rejection body naming the offending list, this crate's own
3357/// [`DepError`] `#[error(...)]` templates when they widen to carry a
3358/// typed [`DepList`]) lands on the same author-surface tag the
3359/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3360/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] constants carry. Same
3361/// as-str-through-Display convergence discipline the sibling
3362/// [`crate::aplicacao::PlacementStrategy`],
3363/// [`crate::aplicacao::RateLimitUnit`],
3364/// [`crate::supervisor::RestartStrategy`],
3365/// [`crate::supervisor::RestartPolicy`], and [`crate::CaixaKind`]
3366/// closed-set typed enums carry.
3367impl std::fmt::Display for DepList {
3368    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3369        f.write_str(self.as_str())
3370    }
3371}
3372
3373/// Errors raised by [`Dep::validate`].
3374///
3375/// Mirrors the per-axis error families the other `:versao`-carrying
3376/// typed surfaces expose
3377/// ([`crate::AplicacaoError::MembroVersaoEmpty`] /
3378/// [`crate::AplicacaoError::MembroVersaoInvalid`],
3379/// [`crate::SupervisorError::EmptyChildVersion`] /
3380/// [`crate::SupervisorError::ChildVersaoInvalid`]) so a future top-
3381/// level `CaixaError` (M4) sums these without reshaping the diagnostic.
3382#[derive(Debug, Error, PartialEq, Eq)]
3383pub enum DepError {
3384    #[error(
3385        ":deps entry has empty :nome (every dep must name a target caixa; \
3386         omit the entry instead of carrying an empty name)"
3387    )]
3388    NomeEmpty,
3389    #[error(
3390        ":deps entry :nome {nome:?} is not a valid DNS-1123 label: {reason} \
3391         (the value flows verbatim as the target caixa's `:nome`, the rendered \
3392         `lareira-<nome>` Helm chart name segment, the `LABEL_PROGRAM` label \
3393         value, and the resolver's checkout-directory leaf — each apiserver-side \
3394         schema rejects non-DNS-1123 names at admission time; use a lowercase \
3395         RFC 1123 label like `\"caixa-teia\"` or `\"pleme-mesh\"`, 1..=63 bytes, \
3396         pattern `^[a-z0-9]([-a-z0-9]*[a-z0-9])?$`)"
3397    )]
3398    NomeInvalid { nome: String, reason: String },
3399    #[error(
3400        ":deps entry {nome:?} has empty :versao (every dep must pin a semver \
3401         constraint that resolves through the lacre pipeline)"
3402    )]
3403    VersaoEmpty { nome: String },
3404    #[error(
3405        ":deps entry {nome:?} :versao {versao:?} is not a valid semver \
3406         requirement: {reason} (use Cargo-shaped forms like `\"^0.1\"`, \
3407         `\"~0.1.2\"`, `\"0.1.0\"`, or `\"*\"` — the same shape `:membros :versao` \
3408         and `:children :versao` carry; the lacre pipeline resolves all three \
3409         through the same parser)"
3410    )]
3411    VersaoInvalid {
3412        nome: String,
3413        versao: String,
3414        reason: String,
3415    },
3416    #[error(
3417        ":deps entry {nome:?} :fonte (:tipo git …) has empty :repo \
3418         (every git source must name a repo — use a `github:org/repo` \
3419         shorthand, an `https://…` URL, or an ssh-git URL; omit the \
3420         entire :fonte block to fall back to the default-host resolver \
3421         convention)"
3422    )]
3423    FonteRepoEmpty { nome: String },
3424    #[error(
3425        ":deps entry {nome:?} :fonte (:tipo git …) :repo {repo:?} has \
3426         invalid value-shape: {reason} (the value flows verbatim into the \
3427         caixa-resolver's `git clone <repo>` subprocess invocation; every \
3428         documented form carries a `:` separator and no whitespace / \
3429         control / non-ASCII bytes — use a `github:org/repo` shorthand, \
3430         an `https://host/path` / `ssh://[user@]host/path` / \
3431         `git://host/path` / `file:///path` URL, or the `git@host:path` \
3432         scp-style SSH form)"
3433    )]
3434    FonteRepoShape {
3435        nome: String,
3436        repo: String,
3437        reason: String,
3438    },
3439    #[error(
3440        ":deps entry {nome:?} :fonte (:tipo git …) has no pin set \
3441         (set exactly one of :tag, :rev, or :branch so the resolver \
3442         can pick a reproducible commit; omit the entire :fonte block \
3443         to fall back to the default-host resolver convention, which \
3444         resolves the latest tag matching :versao)"
3445    )]
3446    FontePinMissing { nome: String },
3447    #[error(
3448        ":deps entry {nome:?} :fonte (:tipo git …) has multiple pins \
3449         set ({pins}); exactly one of :tag, :rev, or :branch must be \
3450         set so the resolver's checkout target is unambiguous (the \
3451         resolver's silent precedence is :rev > :tag > :branch — if \
3452         you intended one specifically, drop the others)"
3453    )]
3454    FontePinAmbiguous { nome: String, pins: String },
3455    #[error(
3456        ":deps entry {nome:?} :fonte (:tipo git …) has empty {pin} \
3457         (a set pin must name a non-empty git ref; drop the {pin} key \
3458         entirely to fall through to another pin axis)"
3459    )]
3460    FontePinEmpty { nome: String, pin: String },
3461    #[error(
3462        ":deps entry {nome:?} :fonte (:tipo git …) {pin} {value:?} has invalid \
3463         value-shape: {reason} (the git porcelain enforces the same shape at \
3464         `git fetch` / `git checkout` time on every pin; use a leaf refname \
3465         like `\"v0.1.0\"` for `:tag` or `\"main\"` / `\"feature/foo\"` for \
3466         `:branch`, or a full 40/64 lowercase-hex commit OID for `:rev` — \
3467         drop any `refs/heads/` or `refs/tags/` prefix the caixa-resolver \
3468         prepends at clone time, and avoid abbreviated SHAs which are \
3469         ambiguous across repository history)"
3470    )]
3471    FontePinShape {
3472        nome: String,
3473        pin: String,
3474        value: String,
3475        reason: String,
3476    },
3477    #[error(
3478        ":deps entry {nome:?} :fonte (:tipo path …) has empty :caminho \
3479         (every path source must name a non-empty filesystem path; \
3480         omit the entire :fonte block to fall back to the default-host \
3481         resolver convention)"
3482    )]
3483    FonteCaminhoEmpty { nome: String },
3484    #[error(
3485        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} is \
3486         absolute (the lacre pipeline embeds the value verbatim in its \
3487         per-dep content-address `path:{caminho}` at \
3488         caixa-resolver/src/resolve.rs:189, so an absolute path makes the \
3489         BLAKE3 closure differ across machines — defeating the \
3490         reproducibility contract that's load-bearing for CSE; express \
3491         the path relative to the caixa.lisp location, e.g. \
3492         \"../caixa-teia\" for a sibling workspace dep)"
3493    )]
3494    FonteCaminhoAbsolute { nome: String, caminho: String },
3495    #[error(
3496        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
3497         with `~` (the leading-tilde is a shell-expansion convention, not a \
3498         POSIX path component — `Path::is_absolute` returns false on it, so \
3499         the b94fd83 absolute-path gate doesn't catch it, but the lacre \
3500         pipeline embeds the value verbatim in its per-dep content-address \
3501         `path:{caminho}` at caixa-resolver/src/resolve.rs:189 and the \
3502         caixa-resolver folds it through `Path::join` without `~`-expansion, \
3503         so the build looks for a literal `./{caminho}` subdirectory and \
3504         fails at resolve time far from the source caixa.lisp; even worse, a \
3505         future caixa-resolver pass that *does* expand `~` would silently \
3506         re-open the host-layout-leak the b94fd83 absolute gate closes — \
3507         Alice's `~` resolves to `/home/alice`, Bob's to `/home/bob`, two CI \
3508         runners with different `$HOME` layouts resolve to two distinct paths \
3509         for the byte-identical caixa, defeating the THEORY.md §V.2 render-\
3510         determinism contract; express the path relative to the caixa.lisp \
3511         location, e.g. \"../caixa-teia\" for a sibling workspace dep, or \
3512         spell out the full relative path explicitly if a workstation-rooted \
3513         dep is genuinely intended)"
3514    )]
3515    FonteCaminhoTildeExpansion { nome: String, caminho: String },
3516    #[error(
3517        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
3518         with `$` (the leading-`$` is a shell-variable-expansion convention, \
3519         not a POSIX path component — `Path::is_absolute` returns false on it \
3520         and the a5c248e tilde gate doesn't catch it, but the lacre pipeline \
3521         embeds the value verbatim in its per-dep content-address \
3522         `path:{caminho}` at caixa-resolver/src/resolve.rs:189 and the \
3523         caixa-resolver folds it through `Path::join` without `$`-expansion, \
3524         so the build looks for a literal `./{caminho}` subdirectory and \
3525         fails at resolve time far from the source caixa.lisp; even worse, a \
3526         future caixa-resolver pass that *does* expand `$VAR` (the canonical \
3527         shell-convention idiom that CI's `${{WORKSPACE}}` paste-idiom \
3528         invites) would silently re-open the host-layout-leak the b94fd83 \
3529         absolute gate closes — Alice's `$HOME` resolves to `/home/alice`, \
3530         Bob's to `/home/bob`, two CI runners with different `${{WORKSPACE}}` \
3531         layouts resolve to two distinct paths for the byte-identical caixa, \
3532         defeating the THEORY.md §V.2 render-determinism contract; express \
3533         the path relative to the caixa.lisp location, e.g. \"../caixa-teia\" \
3534         for a sibling workspace dep, or spell out the full relative path \
3535         explicitly if a workstation-rooted dep is genuinely intended)"
3536    )]
3537    FonteCaminhoVarExpansion { nome: String, caminho: String },
3538    #[error(
3539        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
3540         with a space (the leading ASCII space `0x20` is the orthogonal \
3541         paste-from-aligned-doc footgun that silently passes \
3542         `Path::is_absolute` and every prior leading-byte arm — \
3543         `\" ../caixa-teia\"` resolves via `Path::join` to a literal \
3544         `./ ../caixa-teia` subdirectory the resolver fails to find at \
3545         resolve time with a non-self-locating `No such file or directory` \
3546         error far from the source caixa.lisp; the lacre pipeline embeds \
3547         the value verbatim in its per-dep content-address `path:{caminho}` \
3548         at caixa-resolver/src/resolve.rs:189, so byte-divergent / \
3549         semantic-identical caixa values (` ../caixa-teia` vs \
3550         `../caixa-teia`) yield two distinct BLAKE3 closures across two \
3551         workstations whose authors differ only in paste-from-aligned- \
3552         caixa.lisp-doc whitespace habits — the most insidious failure \
3553         mode the typed slot can carry (no error surfaces; the divergence \
3554         is invisible until two machines compare lacres), defeating the \
3555         THEORY.md §V.2 render-determinism contract. The canonical \
3556         paste-from-aligned-`:deps`-block footgun (every `:fonte` form in \
3557         a multi-entry `:deps` block sits at the same column — an author \
3558         selecting `\"<sp><sp><sp>../caixa-teia\"` and pasting it from \
3559         the rendered alignment into a fresh entry preserves the leading \
3560         whitespace verbatim); peer `:fonte :repo` axis already rejects \
3561         leading whitespace via `is_git_repo_url`, `:fonte :tag` / \
3562         `:fonte :branch` via `is_git_ref_name`, `:descricao` via \
3563         `is_chart_description_shape`, `:licenca` via \
3564         `is_spdx_expression_shape`. Drop the leading space; express the \
3565         path as a bare relative single-token like \"../caixa-teia\")"
3566    )]
3567    FonteCaminhoLeadingWhitespace { nome: String, caminho: String },
3568    #[error(
3569        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
3570         with `-` (the canonical CLI-argument-injection footgun on the \
3571         `:caminho` axis — the lacre pipeline embeds the value verbatim in \
3572         its per-dep content-address `path:{caminho}` at \
3573         caixa-resolver/src/resolve.rs:189 and the caixa-resolver folds it \
3574         through `Path::join` looking for a literal `./{caminho}` \
3575         subdirectory. Every downstream subprocess that consumes the resolved \
3576         path — `git -C {caminho} <verb>`, `terraform -chdir={caminho}`, \
3577         `nix build --path {caminho}`, `find {caminho}`, `stat {caminho}`, \
3578         `cp -r {caminho} …`, `rm -rf {caminho}` — reinterprets a leading-`-` \
3579         value as a CLI flag rather than a positional path when the invocation \
3580         does not carry a `--` argument-list terminator between the flag block \
3581         and the path (the common case at every porcelain entry point). The \
3582         canonical footguns: `:caminho \"-rf\"` (bare short-flag paste), \
3583         `:caminho \"-C\"` (`git -C -C` config-injection paste), \
3584         `:caminho \"--upload-pack=cat /etc/passwd\"` (the canonical long-flag \
3585         CLI-arg-injection vector at every git porcelain entry point that \
3586         consumes a path or URL argument, peer with is_git_repo_url's \
3587         leading-`-` arm on the sibling `:fonte :repo` axis), \
3588         `:caminho \"--config=…\"` (`git -c foo=bar` config-override paste). \
3589         POSIX `std::path::Path` treats a leading `-` as a literal filename \
3590         byte so the resolver folds `\"-rf\"` through `Path::join` and looks \
3591         for a literal `./-rf` subdirectory that fails at resolve time with a \
3592         non-self-locating `No such file or directory` error far from the \
3593         source caixa.lisp — but on any downstream shell-out without `--` the \
3594         reinterpretation is silent and the failure mode is arbitrary-\
3595         argument-injection. Peer arms: `is_git_repo_url` (render.rs:2037) \
3596         rejects leading `-` on `:fonte :repo` for `git clone <repo>` CLI-\
3597         arg-injection; `is_git_ref_name` (render.rs:1381, 5a28454) rejects \
3598         leading `-` on `:fonte :tag` / `:branch` for `git checkout <ref>` \
3599         CLI-arg-injection; `is_dns_1123_label` rejects leading `-` on every \
3600         DNS-1123-shaped axis (top-level Caixa `:nome`, `:membros :caixa`, \
3601         `:children :caixa`, `:deps :nome`, cluster names); \
3602         `is_cargo_feature_name` rejects leading `-` on `:caracteristicas`; \
3603         the feira `init` / `add <nome>` positional gate (868c191) rejects \
3604         leading `-` on the CLI positional itself. Express the path as a bare \
3605         relative single-token like \"../caixa-teia\" — the sibling-workspace \
3606         directory name carries no leading-hyphen semantic, and `./` / `../` \
3607         prefixes structurally partition the leading-byte set to safe values.)"
3608    )]
3609    FonteCaminhoLeadingHyphen { nome: String, caminho: String },
3610    #[error(
3611        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains \
3612         ASCII control byte 0x{byte:02x} (POSIX paths reject NUL `0x00` outright — \
3613         every `std::fs` syscall routes the path through `CString::new` which \
3614         fails with `NulError` at resolve time; the lacre pipeline embeds the \
3615         value verbatim in its per-dep content-address `path:{caminho}` at \
3616         caixa-resolver/src/resolve.rs:189 so a control byte anywhere in the \
3617         value lands in the BLAKE3 closure and breaks the THEORY.md §V.2 render-\
3618         determinism contract — the canonical paste-from-multiline-doc \
3619         (`\\n`/`\\r`), paste-from-aligned-table (`\\t`), or paste-from-binary-\
3620         blob (`0x00`-DEL) footgun every peer single-token-shaped axis \
3621         (`:fonte :repo`, `:fonte :tag`/`:branch`, the Helm chart-string axes) \
3622         already gates against. Express the path as a relative single-line ASCII \
3623         string, e.g. \"../caixa-teia\" for a sibling workspace dep)"
3624    )]
3625    FonteCaminhoControlChar {
3626        nome: String,
3627        caminho: String,
3628        byte: u8,
3629    },
3630    #[error(
3631        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains `\\` \
3632         (POSIX `std::path::Path` treats `\\` as a literal byte inside a single path \
3633         component, so `..\\caixa-teia` is one directory named literally `..\\caixa-teia` — \
3634         not the parent's sibling — and the caixa-resolver folds the value through \
3635         `Path::join` looking for a literal `./{caminho}` subdirectory that fails at \
3636         resolve time with a non-self-locating `No such file or directory` error far \
3637         from the source caixa.lisp; Windows `std::path::Path` treats `\\` as a \
3638         primary path separator equal to `/`, so byte-identical caixa.lisp values \
3639         resolve to two distinct directories across runner OSes — the lacre pipeline \
3640         embeds the value verbatim in its per-dep content-address `path:{caminho}` at \
3641         caixa-resolver/src/resolve.rs:189, defeating the THEORY.md §V.2 render-\
3642         determinism contract via the cross-host-OS-separator divergence vector. The \
3643         canonical Windows-Explorer `Copy as path` / PowerShell `Get-Location` \
3644         paste-idiom footgun; peer `:fonte :tag` / `:fonte :branch` axis already \
3645         rejects `\\` via `is_git_ref_name` for the same Windows-path-leak reason, \
3646         and `:entrada :paths` rejects `\\` via `is_gateway_api_http_path`'s eleven-\
3647         byte RFC-3986-reserved set. Express the path with `/` as the separator, e.g. \
3648         \"../caixa-teia\" for a sibling workspace dep)"
3649    )]
3650    FonteCaminhoBackslash { nome: String, caminho: String },
3651    #[error(
3652        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3653         redirection metacharacter 0x{byte:02x} `{ch}` (every interactive shell — bash / \
3654         zsh / fish / nushell — lexes `<` and `>` as input / output redirection \
3655         operators, so `:caminho \"../caixa-teia>build.log\"` is the canonical \
3656         paste-from-shell-pipeline footgun where an author copies a `command > log` \
3657         tail without trimming the redirect; POSIX `std::path::Path` treats both bytes \
3658         as literal path-component bytes, so the resolver folds the value through \
3659         `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
3660         subdirectory and fails at resolve time with a non-self-locating `No such \
3661         file or directory` error far from the source caixa.lisp. The lacre pipeline \
3662         embeds the value verbatim in its per-dep content-address `path:{caminho}` at \
3663         caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure \
3664         and rides into every shell-spawned subprocess (the resolver's `git clone`, a \
3665         future `feira tofu` shell-out, a future operator-side `nix` spawn) as the \
3666         canonical CRLF-at-subprocess-argument / shell-metachar injection surface every \
3667         peer single-token-shaped typed slot already closes. The peer `:fonte :tag` / \
3668         `:fonte :branch` axis already rejects `<` / `>` via `is_git_ref_name`, and \
3669         `:entrada :paths` rejects them via `is_gateway_api_http_path`'s eleven-byte \
3670         RFC-3986-reserved set. Express the path as a bare relative single-token like \
3671         \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
3672         redirection semantic.",
3673        ch = *byte as char
3674    )]
3675    FonteCaminhoShellRedirection {
3676        nome: String,
3677        caminho: String,
3678        byte: u8,
3679    },
3680    #[error(
3681        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-pipe \
3682         metacharacter `|` (every interactive shell — bash / zsh / fish / nushell — lexes \
3683         `|` as the pipe operator that wires one command's stdout to the next command's \
3684         stdin, so `:caminho \"../caixa-teia | grep foo\"` is the canonical paste-from-\
3685         shell-history footgun where an author copies a `ls ../caixa-teia | grep` line \
3686         without trimming the pipeline tail, and `:caminho \"../foo||bar\"` is the \
3687         symmetric `cmd-a || cmd-b` short-circuit-OR paste shape; POSIX `std::path::Path` \
3688         treats `|` as a literal path-component byte, so the resolver folds the value \
3689         through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
3690         subdirectory and fails at resolve time with a non-self-locating `No such file or \
3691         directory` error far from the source caixa.lisp. The lacre pipeline embeds the \
3692         value verbatim in its per-dep content-address `path:{caminho}` at caixa-resolver/\
3693         src/resolve.rs:189, so the byte lands in the BLAKE3 closure and rides into every \
3694         shell-spawned subprocess (the resolver's `git clone`, a future `feira tofu` \
3695         shell-out, a future operator-side `nix` spawn) as the canonical CRLF-at-\
3696         subprocess-argument / shell-metachar injection surface every peer single-token-\
3697         shaped typed slot already closes. The peer `:entrada :paths` axis rejects `|` \
3698         via `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the \
3699         path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
3700         workspace directory name carries no shell-pipe semantic."
3701    )]
3702    FonteCaminhoShellPipe { nome: String, caminho: String },
3703    #[error(
3704        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3705         command-separator metacharacter `;` (every interactive shell — bash / zsh / fish \
3706         / nushell — lexes `;` as the sequential-command terminator that fires the next \
3707         command regardless of the prior command's exit status, so `:caminho \
3708         \"../caixa-teia; rm -rf build\"` is the canonical paste-from-shell-one-liner \
3709         footgun where an author copies a `cd path; do-thing` chain without trimming \
3710         the cleanup tail, and `:caminho \"../foo;;bar\"` is the symmetric POSIX `case` \
3711         arm `;;` terminator paste shape; POSIX `std::path::Path` treats `;` as a \
3712         literal path-component byte, so the resolver folds the value through \
3713         `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
3714         subdirectory and fails at resolve time with a non-self-locating `No such file \
3715         or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
3716         the value verbatim in its per-dep content-address `path:{caminho}` at \
3717         caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
3718         rides into every shell-spawned subprocess (the resolver's `git clone`, a \
3719         future `feira tofu` shell-out, a future operator-side `nix` spawn) as the \
3720         canonical shell-metachar injection surface every peer single-token-shaped \
3721         typed slot already closes. The peer `:entrada :paths` axis rejects `;` via \
3722         `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the \
3723         path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
3724         workspace directory name carries no shell-command-separator semantic."
3725    )]
3726    FonteCaminhoShellSemicolon { nome: String, caminho: String },
3727    #[error(
3728        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3729         background / list-AND metacharacter `&` (every interactive shell — bash / zsh \
3730         / fish / nushell — lexes `&` two ways: single `&` as the background-task \
3731         terminator detaching the prior command and returning control immediately to \
3732         the prompt, double `&&` as the logical-AND list operator firing the next \
3733         command only if the prior succeeded; POSIX `std::path::Path` treats it as a \
3734         literal byte. The canonical paste-from-shell-prompt footgun is a `cd path & \
3735         sleep 1` background-launch one-liner or a `cd path && make install` build-\
3736         chain idiom selected whole into the `:caminho` slot — the prior `;` arm at \
3737         05c358e closed the sequential-command-separator vector, this arm closes the \
3738         orthogonal background-task / logical-AND vector on the same paste-from-shell-\
3739         prompt class. The lacre pipeline embeds the value verbatim in its per-dep \
3740         content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the \
3741         byte lands in the BLAKE3 closure and rides into every shell-spawned \
3742         subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a \
3743         future operator-side `nix` spawn) as the canonical shell-metachar injection \
3744         surface every peer single-token-shaped typed slot already closes. The peer \
3745         `:entrada :paths` axis rejects `&` via `is_gateway_api_http_path`'s eleven-\
3746         byte RFC-3986-reserved set. Express the path as a bare relative single-token \
3747         like \"../caixa-teia\" — the sibling-workspace directory name carries no \
3748         shell-background / logical-AND semantic."
3749    )]
3750    FonteCaminhoShellBackground { nome: String, caminho: String },
3751    #[error(
3752        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3753         command-substitution metacharacter `` ` `` (every POSIX shell — sh / bash / zsh / \
3754         dash / ksh / fish / nushell — lexes the byte as the legacy command-substitution \
3755         wrapper that runs the enclosed command and substitutes its standard-output \
3756         verbatim into the surrounding word, so a backticked `whoami` expands to the \
3757         current user's name and a backticked `cat /etc/passwd` expands to the file's \
3758         contents — the canonical CWE-78 shell-command-injection vector; POSIX \
3759         `std::path::Path` treats the byte as a literal path-component byte. The canonical \
3760         paste-from-shell-prompt footgun is a `cd ../path/<backtick>whoami<backtick>` legacy substitution \
3761         one-liner or a `cd <backtick>pwd<backtick>/path` working-directory expansion idiom selected whole \
3762         into the `:caminho` slot — the prior `&` arm at e12e4f3 closed the shell-\
3763         background / logical-AND vector, this arm closes the orthogonal command-\
3764         substitution vector on the same paste-from-shell-prompt class (the modern `$()` \
3765         form is gated at leading position by the f4efe9c `FonteCaminhoVarExpansion` arm; \
3766         the legacy backtick form is the orthogonal axis). The lacre pipeline embeds the \
3767         value verbatim in its per-dep content-address `path:{caminho}` at \
3768         caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
3769         rides into every shell-spawned subprocess (the resolver's `git clone`, a future \
3770         `feira tofu` shell-out, a future operator-side `nix` spawn) as the canonical \
3771         shell-metachar injection surface every peer single-token-shaped typed slot \
3772         already closes. The peer `:entrada :paths` axis rejects the byte via \
3773         `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the path \
3774         as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
3775         directory name carries no shell-command-substitution semantic."
3776    )]
3777    FonteCaminhoShellCommandSubstitution { nome: String, caminho: String },
3778    #[error(
3779        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3780         glob / pathname-expansion metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — \
3781         sh / bash / zsh / dash / ksh / fish / nushell — lexes `*` and `?` as pathname-\
3782         expansion wildcards: `*` matches any sequence of characters in a path component \
3783         and `?` matches exactly one character, so a `:caminho \"../caixa-teia/*\"` is the \
3784         canonical paste-from-shell-listing footgun where an author copies a \
3785         `ls ../caixa-teia/*` listing without trimming the wildcard, and `:caminho \
3786         \"../foo?\"` is the symmetric single-char-wildcard paste shape; POSIX \
3787         `std::path::Path` treats both bytes as literal path-component bytes, so the \
3788         resolver folds the value through `Path::new(caminho).join(<file>)` looking for \
3789         a literal `./{caminho}` subdirectory and fails at resolve time with a non-self-\
3790         locating `No such file or directory` error far from the source caixa.lisp. The \
3791         lacre pipeline embeds the value verbatim in its per-dep content-address \
3792         `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in the \
3793         BLAKE3 closure and rides into every shell-spawned subprocess (the resolver's \
3794         `git clone`, a future `feira tofu` shell-out, a future operator-side `nix` \
3795         spawn) as the canonical shell-metachar / glob-expansion surface every peer \
3796         single-token-shaped typed slot already closes. The peer `:entrada :paths` axis \
3797         rejects `*` and `?` via `is_gateway_api_http_path`'s eleven-byte RFC-3986-\
3798         reserved set. Express the path as a bare relative single-token like \
3799         \"../caixa-teia\" — the sibling-workspace directory name carries no shell-glob \
3800         / pathname-expansion semantic.",
3801        ch = *byte as char
3802    )]
3803    FonteCaminhoShellGlob {
3804        nome: String,
3805        caminho: String,
3806        byte: u8,
3807    },
3808    #[error(
3809        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3810         subshell-grouping metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / \
3811         zsh / dash / ksh / fish / nushell — lexes `(` and `)` as the subshell-grouping \
3812         operator: `(<cmd>)` runs `<cmd>` in a child shell with a fresh environment scope \
3813         (the canonical `(cd <path> && <cmd>)` shell-history one-liner scopes a `cd` to one \
3814         subshell without disturbing the parent's working directory), and `$(<cmd>)` is the \
3815         modern Bourne command-substitution shape the leading-`$` `FonteCaminhoVarExpansion` \
3816         arm closes the leading byte of — together the two arms now structurally exclude the \
3817         entire `$(<cmd>)` substitution surface from the typed `:caminho` accepted set. \
3818         POSIX `std::path::Path` treats the byte as a literal path-component byte, so a \
3819         `:caminho \"../caixa-teia/$(date)/build\"` (the canonical paste-from-shell-history \
3820         modern-command-substitution footgun) or `:caminho \"../(cd foo && pwd)/caixa-teia\"` \
3821         (the symmetric subshell-grouping working-directory-probe paste idiom) silently passes \
3822         every prior arm and the resolver folds the value through `Path::new(caminho).join(\
3823         <file>)` looking for a literal subdirectory and fails at resolve time with a non-\
3824         self-locating `No such file or directory` error far from the source caixa.lisp. The \
3825         lacre pipeline embeds the value verbatim in its per-dep content-address `path:\
3826         {caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 \
3827         closure and rides into every shell-spawned subprocess (the resolver's `git clone`, a \
3828         future `feira tofu` shell-out, a future operator-side `nix` spawn) as the canonical \
3829         shell-metachar / subshell-grouping surface every peer single-token-shaped typed slot \
3830         already closes. The peer `:fonte :repo` axis (3b99147) closes the same byte under the \
3831         same shell-subshell-grouping / RFC-3986-sub-delims banner on `is_git_repo_url`, \
3832         together with the leading-`$` `FonteCaminhoVarExpansion` arm closing the leading byte \
3833         of every `$(<cmd>)` shape. Express the path as a bare relative single-token \
3834         like \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
3835         subshell-grouping semantic.",
3836        ch = *byte as char
3837    )]
3838    FonteCaminhoShellSubshellGrouping {
3839        nome: String,
3840        caminho: String,
3841        byte: u8,
3842    },
3843    #[error(
3844        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3845         brace-expansion / URI-Template placeholder metacharacter 0x{byte:02x} `{ch}` \
3846         (every POSIX-derived brace-expanding shell — bash / zsh / ksh / fish — lexes `{{` / \
3847         `}}` as the brace-expansion operator: `{{a,b,c}}` expands to the cross-product of \
3848         comma-separated members and `{{1..10}}` expands to the integer range — the \
3849         canonical `mkdir -p ../{{caixa-teia,caixa-helm,caixa-flux}}` / `cp file{{,.bak}}` \
3850         idiom every shell-history block carries; RFC 6570 reserves the matched pair for \
3851         URI Template placeholders (the canonical `https://{{host}}/{{org}}/{{repo}}` \
3852         substitution shape every OpenAPI / Swagger / Postman / GitHub Octokit client \
3853         library / Helm chart-URL fragment carries) and the Mustache / Handlebars / \
3854         Tera / Jinja2 / Go html/template doubled-brace substitution form every IaC \
3855         templating engine (Helm, Kustomize, Terraform's `${{var}}` cousin) emits. POSIX \
3856         `std::path::Path` treats the byte as a literal path-component byte, so a \
3857         `:caminho \"../{{caixa-teia,caixa-helm}}/build\"` (the canonical paste-from-\
3858         shell-history brace-expansion fan-across-siblings footgun) or `:caminho \"../{{{{org}}}}/\
3859         caixa-teia\"` (the symmetric paste-from-templated-doc URI-Template placeholder \
3860         idiom every README quick-start / OpenAPI spec / Helm chart `home:` field carries) \
3861         silently passes every prior arm and the resolver folds the value through \
3862         `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
3863         resolve time with a non-self-locating `No such file or directory` error far from \
3864         the source caixa.lisp. The lacre pipeline embeds the value verbatim in its \
3865         per-dep content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, \
3866         so the byte lands in the BLAKE3 closure and rides into every shell-spawned \
3867         subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a \
3868         future operator-side `nix` spawn) as the canonical shell-metachar / brace-\
3869         expansion / URI-Template-placeholder surface every peer single-token-shaped \
3870         typed slot already closes. The peer `:fonte :repo` axis (42d8f9d) closes the \
3871         same byte pair on `is_git_repo_url` under the same RFC-3986-'delims' / \
3872         RFC-6570-URI-Template / shell-brace-expansion banner. Express the path as a \
3873         bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
3874         directory name carries no shell-brace-expansion / URI-Template-placeholder \
3875         semantic; if two siblings actually need pinning, author two separate `:deps` \
3876         entries rather than one brace-expanded `:caminho` value.",
3877        ch = *byte as char
3878    )]
3879    FonteCaminhoShellBraceExpansion {
3880        nome: String,
3881        caminho: String,
3882        byte: u8,
3883    },
3884    #[error(
3885        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3886         bracket-expansion / POSIX glob-character-class / shell-`test`-builtin metacharacter \
3887         0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / nushell \
3888         — lexes the bracket pair as the glob character-class operator: `[abc]` matches one of \
3889         `a` / `b` / `c`, `[a-z]` matches any lowercase ASCII letter, `[^x]` negates — the \
3890         canonical `ls *.[ch]` C-source-file glob and `cd ../caixa-[a-z]*` lowercase-sibling \
3891         glob every shell-history block carries; the bracket pair additionally carries the \
3892         POSIX `test` / `[` builtin command (`[ -d ../caixa-teia ] && cd ...` every shell-\
3893         script conditional uses) and bash's `[[ ... ]]` extended-test grammar; beyond shell \
3894         the pair is the TOML inline-array delimiter (`features = [\"a\", \"b\"]` — the \
3895         canonical paste-from-Cargo-manifest cross-idiom-leak vector), the YAML flow-sequence \
3896         delimiter (`paths: [/a, /b]` — the canonical paste-from-values.yaml cross-idiom \
3897         leak), the JSON array delimiter, and the POSIX-ERE / PCRE bracket-expression anchor. \
3898         POSIX `std::path::Path` treats the byte as a literal path-component byte, so a \
3899         `:caminho \"../caixa-[a-z]/build\"` (the canonical paste-from-shell-history glob-\
3900         character-class fan-across-siblings footgun) or `:caminho \"../[caixa-teia]/build\"` \
3901         (the symmetric paste-from-TOML-array / paste-from-YAML-flow-sequence cross-idiom \
3902         leak) silently passes every prior arm and the resolver folds the value through \
3903         `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
3904         resolve time with a non-self-locating `No such file or directory` error far from \
3905         the source caixa.lisp. The lacre pipeline embeds the value verbatim in its per-dep \
3906         content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte \
3907         lands in the BLAKE3 closure and rides into every shell-spawned subprocess (the \
3908         resolver's `git clone`, a future `feira tofu` shell-out, a future operator-side \
3909         `nix` spawn) as the canonical shell-metachar / glob-character-class / TOML-array \
3910         surface every peer single-token-shaped typed slot already closes. Express the path \
3911         as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
3912         directory name carries no shell-bracket-expansion / glob-character-class / array-\
3913         literal semantic; if a family of sibling caixas actually needs pinning, author \
3914         separate `:deps` entries rather than one character-class-expanded `:caminho` value.",
3915        ch = *byte as char
3916    )]
3917    FonteCaminhoShellBracketExpansion {
3918        nome: String,
3919        caminho: String,
3920        byte: u8,
3921    },
3922    #[error(
3923        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3924         quote-grouping / cross-config-DSL string-literal-delimiter metacharacter \
3925         0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / \
3926         nushell — lexes `'` as the strong string-literal delimiter (`'…'` — no expansion) \
3927         and `\"` as the weak string-literal delimiter (`\"…\"` — variable- / command-\
3928         substitution-preserving); the canonical `cd '../caixa-teia'` shell-history idiom \
3929         every path-with-embedded-whitespace paste block carries and the symmetric \
3930         `git clone \"$REPO\"` weak-quoted CI-manifest shape both leak the pair verbatim. \
3931         Beyond shell the pair is the JSON string-literal delimiter (`\"key\": \"value\"` — \
3932         the canonical paste-from-JSON-config cross-idiom-leak vector), the YAML double- \
3933         and single-quoted flow-scalar delimiter (`path: \"../caixa-teia\"` — the canonical \
3934         paste-from-values.yaml / paste-from-K8s-YAML-manifest cross-idiom leak), the TOML \
3935         basic and literal string delimiter (`path = \"../caixa-teia\"` — the canonical \
3936         paste-from-Cargo-manifest cross-idiom leak), the tatara-lisp string-literal \
3937         delimiter itself (`(:caminho \"../caixa-teia\")` — the canonical \"I copied the \
3938         entire `:caminho \"...\"` slot rather than just the string body\" author-surface \
3939         footgun), and RFC 3986 §2.2's `gen-delims` / `sub-delims` grammar which excludes \
3940         both bytes from the `pchar = unreserved / pct-encoded / sub-delims / \":\" / \"@\"` \
3941         production. POSIX `std::path::Path` treats the byte as a literal path-component \
3942         byte, so a `:caminho \"'../caixa-teia'\"` (the canonical paste-from-shell-history \
3943         strong-quoted sibling-workspace path footgun) or `:caminho \"\\\"../caixa-teia\\\"\"` \
3944         (the symmetric weak-quoted paste-from-JSON / paste-from-YAML flow-scalar / paste-\
3945         from-TOML basic-string / paste-from-tatara-lisp string-literal cross-idiom-leak \
3946         shape) silently passes every prior arm and the resolver folds the value through \
3947         `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
3948         resolve time with a non-self-locating `No such file or directory` error far from \
3949         the source caixa.lisp. The lacre pipeline embeds the value verbatim in its per-dep \
3950         content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte \
3951         lands in the BLAKE3 closure and rides into every shell-spawned subprocess (the \
3952         resolver's `git clone`, a future `feira tofu` shell-out, a future operator-side \
3953         `nix` spawn) as the canonical shell-metachar / string-literal-delimiter surface \
3954         every peer single-token-shaped typed slot already closes. The peer `:fonte :repo` \
3955         axis closes both bytes under the same shell-quote-grouping / RFC-3986-sub-delims \
3956         banner (e7a109f `'` shell-single-quote + 4267d8b `\"` shell-double-quote on \
3957         `is_git_repo_url`). Express the path as a bare relative single-token like \
3958         \"../caixa-teia\" — the sibling-workspace directory name carries no shell-quote-\
3959         grouping / string-literal-delimiter semantic; strip the outer quote pair from the \
3960         paste (the tatara-lisp `:caminho \"...\"` slot already carries the string-literal \
3961         quoting on the outer syntactic layer, so an inner quote pair would nest and \
3962         desugar to a broken layer).",
3963        ch = *byte as char
3964    )]
3965    FonteCaminhoShellQuoteGrouping {
3966        nome: String,
3967        caminho: String,
3968        byte: u8,
3969    },
3970    #[error(
3971        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3972         comment / URL-fragment-identifier / YAML-comment cross-config-DSL metacharacter \
3973         0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / \
3974         nushell — lexes an unquoted `#` at the head of a word or after unquoted \
3975         whitespace as the comment-lead per POSIX.1-2017 §2.3 Token Recognition step 6, \
3976         discarding the byte and everything after it to the end of the physical line \
3977         before command parsing (`cd ../caixa-teia  # legacy sibling` — the canonical \
3978         paste-from-shell-history-with-trailing-annotation shape every operator-notebook \
3979         and CI-manifest carries); YAML 1.2 §6.6 makes `#` the comment-lead at any \
3980         position preceded by whitespace or at line-start (`path: ../caixa-teia  # pin` \
3981         — the canonical paste-from-values.yaml / paste-from-K8s-manifest cross-idiom-\
3982         leak); RFC 3986 §3.5 reserves `#` as the URL fragment-identifier delimiter (the \
3983         canonical paste-from-browser-address-bar `github.com/foo/bar#readme` / \
3984         `github.com/foo/bar#L42` permalink shape, and the symmetric Nix-flake-ref \
3985         cross-idiom leak `github:foo/bar#packageName` where `#` selects a flake \
3986         output); the same cross-config-DSL surface extends to HCL / Terraform / Nix \
3987         flake attributes / dotenv `.env` / gitconfig / .gitignore / ini / TOML where \
3988         `#` is likewise the comment-lead. POSIX `std::path::Path` treats the byte as a \
3989         literal path-component byte, so a `:caminho \"../caixa-teia # legacy sibling\"` \
3990         (the canonical paste-from-shell-history-with-trailing-annotation footgun), \
3991         `:caminho \"../caixa-teia  # pin\"` (the symmetric YAML flow-scalar paste-with-\
3992         trailing-comment shape), or `:caminho \"../caixa-teia#readme\"` (the URL \
3993         fragment paste-from-browser-address-bar shape) silently passes every prior arm \
3994         and the resolver folds the value through `Path::new(caminho).join(<file>)` \
3995         looking for a literal subdirectory named `../caixa-teia # legacy sibling` and \
3996         fails at resolve time with a non-self-locating `No such file or directory` \
3997         error far from the source caixa.lisp — while every downstream shell / YAML / \
3998         URL parser silently truncates the value at the `#` byte to `../caixa-teia`, so \
3999         a `feira tofu` shell-out and a `nix flake check` on an emitted YAML `path:` \
4000         scalar disagree with the resolver on which directory the value names. The \
4001         lacre pipeline embeds the value verbatim in its per-dep content-address \
4002         `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in \
4003         the BLAKE3 closure and rides into every shell-spawned subprocess (the \
4004         resolver's `git clone`, a future `feira tofu` shell-out, a future operator-\
4005         side `nix` spawn) as the canonical shell-metachar / comment-lead / URL-\
4006         fragment-delimiter surface every peer single-token-shaped typed slot already \
4007         closes. The peer `:fonte :repo` axis closes the byte under the same URL-\
4008         fragment-identifier banner (a68f818 `#` on `is_git_repo_url`). Express the \
4009         path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
4010         workspace directory name carries no shell-comment / URL-fragment / YAML-\
4011         comment semantic; move any trailing annotation to a tatara-lisp `;`-comment \
4012         on the surrounding form (`;; legacy sibling` above the `(:caminho ...)` slot) \
4013         and drop any `#fragment` tail entirely (fragment identifiers select \
4014         renderings, not directories, and `:caminho` names a directory).",
4015        ch = *byte as char
4016    )]
4017    FonteCaminhoShellComment {
4018        nome: String,
4019        caminho: String,
4020        byte: u8,
4021    },
4022    #[error(
4023        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains URL-\
4024         percent-encoding-escape / printf-format-specifier / bash-job-control-specifier \
4025         / YAML-directive-lead metacharacter 0x{byte:02x} `{ch}` (RFC 3986 §2.1 reserves \
4026         `%` as the URL percent-encoding-escape — `%HH` is the mandatory encoding \
4027         mechanism for every byte outside the `unreserved` alphanumeric / `-` / `.` / \
4028         `_` / `~` set, and `%` itself must be percent-encoded as `%25` to appear \
4029         literally inside a URL value. The canonical paste-from-browser-address-bar \
4030         percent-encoded-space footgun (an author copies `../caixa%20teia` out of a URL-\
4031         encoded README hyperlink / browser address bar / percent-encoded permalink \
4032         expecting `%20` to decode to a literal space at the filesystem layer) locks two \
4033         distinct BLAKE3 closures (`path:../caixa%20teia` vs `path:../caixa teia`) for \
4034         what the author intended as the byte-identical sibling-workspace dep. POSIX \
4035         `std::path::Path` treats the byte as a literal path-component byte, so \
4036         `Path::join` looks for a literal `./{caminho}` subdirectory and fails at \
4037         resolve time with a non-self-locating `No such file or directory` error far \
4038         from the source caixa.lisp — while every downstream URL parser / shell printf \
4039         builtin / YAML directive parser silently reinterprets the byte to a different \
4040         value than the resolver's `Path::join` sees. Beyond the URL-encoding hazard, \
4041         `%` is the C / POSIX printf format-directive lead-in (`%s`, `%d`, `%02x` — \
4042         wired into every POSIX shell's `printf` builtin, the canonical CWE-134 format-\
4043         string-injection vector); the bash / zsh / ksh job-control-specifier lead-in \
4044         (`%1` names \"job 1\", `%%` names \"the current job\", `%foo` names \"the most \
4045         recent job whose command started with `foo`\" — a future `kill %1` invocation \
4046         silently redirects the signal to a wrong target); the YAML 1.2 §6.8.1 \
4047         directive lead-in (`%YAML 1.2` / `%TAG` — the paste-from-top-of-doc YAML \
4048         directive block cross-idiom leak); and the Windows-shell env-var-reference \
4049         lead-in (`%PATH%` — the paste-from-`.bat` / paste-from-PowerShell-`%env:PATH%` \
4050         cross-idiom leak). The lacre pipeline embeds the value verbatim in its per-dep \
4051         content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the \
4052         byte lands in the BLAKE3 closure and rides into every shell-spawned subprocess \
4053         (the resolver's `git clone`, a future `feira tofu` shell-out, a future \
4054         operator-side `nix` spawn) as the canonical URL-percent-encoding-escape / \
4055         printf-format-specifier / job-control-specifier surface every peer single-\
4056         token-shaped typed slot already closes. The peer `:fonte :repo` axis closes \
4057         the byte under the same URL-percent-encoding-escape banner (a323db8 `%` on \
4058         `is_git_repo_url`). Express the path as a bare relative single-token like \
4059         \"../caixa-teia\" — the sibling-workspace directory name carries no URL-\
4060         percent-encoding-escape / format-specifier / job-control semantic; substitute \
4061         any `%20` percent-encoded-space with a literal space then reject the whole \
4062         value at the leading-whitespace / embedded-`?` arm on the same axis (a caixa \
4063         directory name never carries an embedded space in practice); drop any \
4064         `%2F`-encoded path separator in favor of a literal `/`; and drop any leading \
4065         `%YAML` / `%PATH%` cross-idiom-leak prefix entirely.",
4066        ch = *byte as char
4067    )]
4068    FonteCaminhoUrlPercentEncoding {
4069        nome: String,
4070        caminho: String,
4071        byte: u8,
4072    },
4073    #[error(
4074        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4075         variable-expansion / command-substitution / arithmetic-expansion / cross-config-\
4076         DSL-interpolation metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — sh / \
4077         bash / zsh / dash / ksh / busybox ash / fish / nushell — lexes `$` per \
4078         POSIX.1-2017 §2.6 as the variable-expansion `$<name>` / braced-form `${{<name>}}` \
4079         / command-substitution `$(<cmd>)` / arithmetic-expansion `$((<expr>))` operator; \
4080         Nix uses `${{var}}` as the string-interpolation lead, Make uses `$(var)` / `$@` \
4081         / `$<` for variables and automatic-variables, JavaScript / TypeScript template \
4082         literals use `${{expr}}` for interpolation, envsubst / Kubernetes / OpenShift \
4083         templates use `${{VAR}}` for env-var-reference, PHP uses `$_GET` / `$_ENV` for \
4084         superglobals, Perl uses `$foo` for scalars, SASS / SCSS uses `$primary-color` \
4085         for variables, and PostgreSQL / SQLite use `$1` / `$2` for bind parameters — \
4086         the byte is a first-class parser byte in nearly every config / templating / \
4087         build-system DSL the substrate's paste-idiom surface routinely crosses. POSIX \
4088         `std::path::Path` treats the byte as a literal path-component byte, so the \
4089         canonical paste-from-shell-one-liner `:caminho \"../foo$HOME/bar\"` / paste-\
4090         from-CI-manifest `:caminho \"../foo${{WORKSPACE}}/bar\"` / paste-from-shell-\
4091         prompt `:caminho \"../foo$(whoami)/bar\"` footguns silently pass every prior \
4092         cascade arm (`$` isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / \
4093         `?` / `(` / `)` / `{{` / `}}` / `[` / `]` / `'` / `\"` / `#` / `%`) and route \
4094         through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
4095         subdirectory that fails at resolve time with a non-self-locating `No such file \
4096         or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
4097         the value verbatim in its per-dep content-address `path:{caminho}` at \
4098         caixa-resolver/src/resolve.rs:189, so byte-identical caixa.lisp values differing \
4099         only in whether the author substituted `$HOME` / `${{WORKSPACE}}` at author \
4100         time lock to two distinct BLAKE3 closures across two workstations whose \
4101         downstream envsubst / Nix / Make / K8s-template layers differ in `$VAR` \
4102         recognition — defeating the THEORY.md §V.2 render-determinism contract on the \
4103         same axis every prior `:caminho` arm protects. Beyond the determinism vector, \
4104         `$` at any position in a value flowing verbatim into a shell-spawned subprocess \
4105         is the canonical CWE-78 shell-command-injection surface every peer single-\
4106         token-shaped typed slot already closes: peer `:fonte :repo` axis rejects `$` \
4107         under the shell-variable-expansion / URL-sub-delim banner via `is_git_repo_url` \
4108         (b9d187c), peer `:fonte :tag` / `:fonte :branch` axes reject `$` as part of \
4109         `is_git_ref_name`'s printable-ASCII-restricted grammar (`git check-ref-format` \
4110         rejects the byte outright), and peer `:entrada :paths` axis rejects `$` via \
4111         `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. The leading-`$` \
4112         position on the same axis routes through `FonteCaminhoVarExpansion` at the \
4113         f4efe9c leading-byte arm; this arm closes the last positional gap on the byte \
4114         so every position — leading and embedded — is structurally rejected. Substitute \
4115         the `$VAR` / `${{VAR}}` / `$(cmd)` template with the literal value at author \
4116         time, or express the path as a bare relative single-token like \
4117         \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
4118         variable-expansion / command-substitution / arithmetic-expansion semantic.",
4119        ch = *byte as char
4120    )]
4121    FonteCaminhoShellVariableExpansion {
4122        nome: String,
4123        caminho: String,
4124        byte: u8,
4125    },
4126    #[error(
4127        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4128         history-expansion / RFC-3986-sub-delims / bang-operator metacharacter 0x{byte:02x} \
4129         `{ch}` (every interactive POSIX shell with history enabled — bash / ksh / zsh's \
4130         `bashcompat` / csh / tcsh — lexes `!` as the history-expansion prefix per bash \
4131         reference §9.3: `!command` re-runs the most recent history entry beginning with \
4132         `command`, `!!` re-runs the prior command verbatim, `!$` substitutes the last \
4133         word of the prior command, `!:N` substitutes the Nth word of the prior command, \
4134         and the substitution fires at every history-expansion-enabled shell context — \
4135         `set -o histexpand` is bash's default for interactive sessions and the layer \
4136         every `feira tofu` / `git clone` / `nix flake check` subprocess-argument \
4137         invocation crosses when spawned under `bash -i`. Beyond shell history, RFC 3986 \
4138         §2.2 lists `!` in the `sub-delims` set (the URL grammar admits the byte inside \
4139         a path segment, but every WHATWG-conformant special-scheme URL parser percent-\
4140         encodes it inside a query component via the 'special-query percent-encode set' \
4141         the peer `is_git_repo_url` `*` / `(` / `)` / `'` arms close on); the byte is \
4142         also the C / C++ / Rust / JavaScript / Python bang-operator (logical-negation \
4143         prefix — the paste-from-source-code idiom where an author copies \
4144         `!path.exists()` out of a Rust snippet and the trailing punctuation crosses \
4145         the string-literal boundary); the canonical English-typography emphasis / \
4146         exclamation mark (the paste-from-prose enthusiasm-form idiom where an author \
4147         writes `:caminho \"../caixa-teia!\"` expecting the substrate to coerce it to a \
4148         kebab-case slug); and the Nix flake-ref attribute-selection operator surface. \
4149         POSIX `std::path::Path` treats `!` as a literal path-component byte, so the \
4150         canonical paste-from-shell-history footgun `:caminho \"../caixa-teia!sudo\"` \
4151         (an author copies a `cd ../caixa-teia && !sudo make install` one-liner from a \
4152         quick-start README and the trailing `!sudo` rides in verbatim as a history-\
4153         expansion reference), the symmetric `:caminho \"../foo!!/bar\"` (the `!!` \
4154         repeat-prior-command paste idiom), the English-typography `:caminho \
4155         \"../caixa-teia!\"` (paste-from-prose enthusiasm-form), and the last-word-\
4156         substitution `:caminho \"../foo!$\"` shape silently pass every prior cascade \
4157         arm (`!` isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / `?` / `(` \
4158         / `)` / `{{` / `}}` / `[` / `]` / `'` / `\"` / `#` / `%` / `$`) and route \
4159         through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
4160         subdirectory that fails at resolve time with a non-self-locating `No such file \
4161         or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
4162         the value verbatim in its per-dep content-address `path:{caminho}` at \
4163         caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
4164         rides into every shell-spawned subprocess (the resolver's `git clone`, a \
4165         future `feira tofu` shell-out, a future operator-side `nix flake check` spawn) \
4166         as the canonical shell-history-expansion / RFC-3986-sub-delims surface every \
4167         peer single-token-shaped typed slot already closes. The peer `:fonte :repo` \
4168         axis closes the byte under the same shell-history-expansion / RFC-3986-sub-\
4169         delims banner (7d53c68 `!` on `is_git_repo_url`). Express the path as a bare \
4170         relative single-token like \"../caixa-teia\" — the sibling-workspace directory \
4171         name carries no shell-history-expansion / bang-operator semantic; drop any \
4172         `!sudo` / `!!` / `!$` history-expansion trailing paste-from-shell-history \
4173         idiom; and drop any trailing English-typography exclamation mark that pasted \
4174         from prose.",
4175        ch = *byte as char
4176    )]
4177    FonteCaminhoShellHistoryExpansion {
4178        nome: String,
4179        caminho: String,
4180        byte: u8,
4181    },
4182    #[error(
4183        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4184         history-substitution / RFC-3986-'unwise' / regex-negation metacharacter 0x{byte:02x} \
4185         `{ch}` (POSIX bash's `set -o histexpand` mode — the default for every interactive \
4186         session and every `bash -i` subprocess-argument context `feira tofu` / `git clone` / \
4187         `nix flake check` cross — lexes `^old^new^` per bash reference §9.3 as the 'quick \
4188         substitution' history operator that rewrites the prior command's `old` string to \
4189         `new` and re-executes it verbatim, the canonical typo-correction one-liner idiom \
4190         (`git clone <bad-url>` → `^bad^good` typo-fix-and-rerun the paste-from-shell-\
4191         history author trims only the leading `git clone` prefix from). RFC 3986 §2 lists \
4192         `^` in the 'unwise' set every URL parser is required to percent-encode-or-refuse at \
4193         the wire boundary, and the WHATWG URL spec's 'fragment percent-encode set' maps \
4194         `^` → `%5E` at the query / fragment component transition, so `Path::join` on the \
4195         literal value diverges from every downstream `feira tofu` curl-invocation / \
4196         artifact-registry-fetch that percent-encodes the byte before the wire. `^` is also \
4197         the regex character-class negation prefix (`[^abc]`), the bitwise XOR operator in \
4198         C / C++ / Rust / Python / JavaScript / Nix / Go, the Windows `cmd.exe` escape \
4199         metacharacter, and the LaTeX / Markdown / BibTeX superscript operator. POSIX \
4200         `std::path::Path` treats `^` as a literal path-component byte, so \
4201         `:caminho \"../foo^bar/baz\"` (embedded quick-substitution), `:caminho \
4202         \"../foo^\"` (trailing history-substitution-open shape), or `:caminho \"../x^y\"` \
4203         (XOR-expression paste-from-source) silently pass every prior cascade arm (`^` \
4204         isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / `?` / `(` / `)` / `{{` \
4205         / `}}` / `[` / `]` / `'` / `\"` / `#` / `%` / `$` / `!`) and route through \
4206         `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` subdirectory \
4207         that fails at resolve time with a non-self-locating `No such file or directory` \
4208         error far from the source caixa.lisp. The lacre pipeline embeds the value verbatim \
4209         in its per-dep content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, \
4210         so the byte lands in the BLAKE3 closure and rides into every shell-spawned \
4211         subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a future \
4212         operator-side `nix flake check` spawn) as the canonical shell-history-substitution \
4213         / RFC-3986-unwise surface every peer single-token-shaped typed slot already closes. \
4214         The peer `:fonte :repo` axis closes the byte under the same shell-history-\
4215         substitution / RFC-3986-unwise banner (49e142f `^` on `is_git_repo_url`). Together \
4216         with the immediate-predecessor `!` arm (6a04767) this arm closes the full `set -o \
4217         histexpand` operator surface on the `:caminho` axis — the `!command` / `!!` / `!$` \
4218         prefix form via `!`, the `^old^new^` quick-substitution form via `^`. Express the \
4219         path as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
4220         directory name carries no shell-history-substitution / regex-negation / XOR-operator \
4221         semantic; drop any `^old^new` history-substitution paste-from-shell-history idiom; \
4222         drop any trailing `^` history-substitution-open fragment.",
4223        ch = *byte as char
4224    )]
4225    FonteCaminhoShellHistorySubstitution {
4226        nome: String,
4227        caminho: String,
4228        byte: u8,
4229    },
4230    #[error(
4231        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} has a trailing \
4232         `/` (the resolver's `Path::join` resolves `\"../caixa-teia\"` and \
4233         `\"../caixa-teia/\"` to the same directory, but the lacre pipeline embeds the \
4234         value verbatim in its per-dep content-address `path:{caminho}` at \
4235         caixa-resolver/src/resolve.rs:189, so two authors whose only difference is \
4236         shell tab-completion emit byte-divergent BLAKE3 closures for the same caixa — \
4237         defeating the THEORY.md §V.2 render-determinism contract via the trailing-\
4238         separator vector (the canonical paste-from-shell-tab-completion + paste-from-\
4239         `pwd`-with-`/`-suffix footgun, and the canonical Cargo-style `path = \
4240         \"../caixa-teia/\"` paste-from-Cargo-manifest cross-idiom leak). Drop the \
4241         trailing `/`; every `:caminho` value names a sibling-workspace directory \
4242         already, so the trailing separator carries no information. Use \
4243         `\"../caixa-teia\"` rather than `\"../caixa-teia/\"`)"
4244    )]
4245    FonteCaminhoTrailingSlash { nome: String, caminho: String },
4246    #[error(
4247        "{list} carries duplicate entry :nome {nome:?} — every dep list keys its \
4248         entries by caixa name (Cargo's [dependencies] / [dev-dependencies] tables \
4249         apply the same set-not-multiset discipline; one package per table), and \
4250         two entries naming the same caixa carry two version constraints / source \
4251         pins / feature sets for one identity. The caixa-resolver's lacre pipeline \
4252         consumes the list as a `HashMap`-keyed-by-`:nome` lookup: the second entry \
4253         silently overwrites the first at the resolver-side `concrete_versao` step, \
4254         and the dropped entry's pin / features never reach the closure — far from \
4255         the source caixa.lisp, with no field naming which `:deps` entry was the \
4256         silent loser. If two version constraints are genuinely needed (the rare \
4257         multi-version closure case the lacre pipeline doesn't yet support), the \
4258         author surface is two distinct caixa names (e.g. a `caixa-teia-v01` / \
4259         `caixa-teia-v02` aliased pair); within one list, one entry per caixa name."
4260    )]
4261    DuplicateNome { nome: String, list: &'static str },
4262    #[error(
4263        ":deps entry {nome:?} has empty :caracteristicas entry — every feature flag must \
4264         name a non-empty identifier on the target caixa (Cargo's [dependencies.<dep>.features] \
4265         applies the same per-entry non-empty discipline). An empty feature flag reaches the \
4266         caixa-resolver's lacre pipeline as a no-op feature enable, silently dropping the \
4267         author's intent far from the source caixa.lisp; drop the empty entry, or replace it \
4268         with the canonical kebab-case feature name the target caixa declares."
4269    )]
4270    CaracteristicaEmpty { nome: String },
4271    #[error(
4272        ":deps entry {nome:?} :caracteristicas entry {caracteristica:?} is not a valid Cargo \
4273         feature name: {reason} (the value flows verbatim into Cargo's \
4274         [dependencies.<dep>.features] list and Cargo's `restricted_names::validate_feature_name` \
4275         parser enforces the same shape at `cargo metadata` time; use a single-token \
4276         identifier like `\"http\"`, `\"derive\"`, or `\"runtime-tokio\"` — kebab-case ASCII \
4277         alphanumeric with `-`, `_`, `+`, or `.` as continuation characters, starting with \
4278         an ASCII alphanumeric or `_`)"
4279    )]
4280    CaracteristicaInvalid {
4281        nome: String,
4282        caracteristica: String,
4283        reason: String,
4284    },
4285    #[error(
4286        ":deps entry {nome:?} :caracteristicas carries duplicate feature {caracteristica:?} — \
4287         every feature-flag list keys its entries by name (Cargo's \
4288         [dependencies.<dep>.features] applies the same set-not-multiset discipline; one entry \
4289         per feature per dep), and two entries naming the same feature are a redundant \
4290         set-membership declaration for one identity (the feature-toggle slot is set-shaped; \
4291         enabling a feature twice has no additional semantic). The caixa-resolver's lacre \
4292         pipeline consumes the list as a set-shaped feature toggle — the resolver enables the \
4293         feature once regardless of declaration count, so the duplicate's pin / position never \
4294         reaches the closure with no field naming the silent loser. One entry per feature per \
4295         dep; if two distinct features are intended, name each verbatim."
4296    )]
4297    CaracteristicaDuplicate {
4298        nome: String,
4299        caracteristica: String,
4300    },
4301    #[error(
4302        "{list} entry :nome {nome:?} names the caixa itself — a caixa cannot depend \
4303         on itself (the lacre closure's dep-graph traversal is rooted at the caixa's \
4304         :nome, and a self-dep would be a one-node cycle the caixa-resolver either \
4305         rejects mid-traversal far from the source caixa.lisp or recurses on until \
4306         it exhausts its stack). Every :nome is globally-unique substrate identity, \
4307         so a :deps / :deps-dev entry whose :nome equals the parent caixa's :nome \
4308         *is* the parent itself, not a coincidentally-named peer. Drop the \
4309         self-referential dep entry — to reference code from this caixa, use \
4310         :bibliotecas / :exe / :servicos (the substrate-blessed shape for \
4311         referencing the caixa's own code surface) instead."
4312    )]
4313    DepIsSelf { nome: String, list: &'static str },
4314}
4315
4316// Fold the eleven `DepError::FonteCaminho<Variant> { nome: nome.to_string(),
4317// caminho: caminho.to_string() }` two-slot struct-variant wire-up sites at
4318// [`DepSource::validate_caminho`] onto one substrate primitive per typed
4319// variant — the paired `{ nome: String, caminho: String }` two-slot family
4320// on [`DepError`], sibling of the peer
4321// [`crate::supervisor::supervisor_caixa_only_ctors!`] (db09650, 3 variants
4322// on `{ caixa: String }`) on the `SupervisorError` envelope, the peer
4323// [`crate::aplicacao::contrato_empty_pair_ctors!`] (8580068, 4 variants on
4324// `{ de, para }`), [`crate::aplicacao::aplicacao_field_reason_ctors!`]
4325// (981060b, 7 variants on `{ <field>: String, reason: String }`),
4326// [`crate::aplicacao::contrato_target_ctors!`] (14b81d5, 2 variants on
4327// `{ de, para, wit, expected }`), and
4328// [`crate::aplicacao::contrato_pair_value_reason_ctors!`] (14e13f1, 3
4329// variants on `{ de, para, <field>: String, reason: String }`) on the
4330// `AplicacaoError` envelopes, the peer
4331// [`crate::layout::layout_violation_ctors!`] (131ca0d, 16 variants on
4332// `{ caixa, issue }`), [`crate::layout::layout_slot_kind_ctors!`]
4333// (0419438, 4 variants on `{ caixa, kind, slots }`),
4334// [`crate::LayoutError::missing_entry`] (1b09f9d, one variant on
4335// `{ kind, path }`), and [`crate::layout::layout_nome_only_ctors!`]
4336// (3fe3dd7, 6 variants on `<Variant>(String)`) on the `LayoutError`
4337// envelopes, the peer three [`crate::limits::limits_codec_value_*_ctors!`]
4338// codec-family macros (81c856c, 12 wire-ups) on the `LimitsError`
4339// envelope, and the peer [`crate::upgrade::upgrade_from_script_ctors!`]
4340// (8e67041, 3 variants on `{ from: String, script: PathBuf }`) on the
4341// `UpgradeError` envelope. First fold family on this `DepError` envelope.
4342//
4343// Each of the eleven wire-up sites on this shape (the leading-byte cascade
4344// closing the seven `FonteCaminho{Absolute, TildeExpansion, VarExpansion,
4345// LeadingWhitespace, LeadingHyphen}` arms; the orthogonal single-metachar
4346// cascade closing `FonteCaminhoBackslash` on `\`; the shell-lexer-metachar
4347// cascade closing `FonteCaminhoShell{Pipe, Semicolon, Background,
4348// CommandSubstitution}` on the four single-byte shell operators; and the
4349// trailing-`/` reproducibility arm closing `FonteCaminhoTrailingSlash`)
4350// opened the identical `DepError::FonteCaminho<Variant> { nome:
4351// nome.to_string(), caminho: caminho.to_string() }` four-line
4352// struct-literal against the same `(nome: &str, caminho: &str)` local pair
4353// — the exact "same block re-inlined at every consumer" shape the PRIME
4354// DIRECTIVE names as a bug, on the same altitude the peer `LayoutError` /
4355// `AplicacaoError` / `SupervisorError` / `LimitsError` / `UpgradeError`
4356// families each closed on their sibling envelopes. The eleven variants
4357// share one `{ nome: String, caminho: String }` shape, so the fold routes
4358// each wire-up site through one dispatch per typed variant.
4359//
4360// The macro below generates one `#[must_use]` inherent constructor per
4361// variant of shape `fn <ctor>(nome: &str, caminho: &str) -> Self`, so every
4362// wire-up site collapses onto one dispatch:
4363// `DepError::<ctor>(nome, caminho)`, byte-equal to the pre-lift
4364// struct-literal on the same `(&str, &str)` fixture. The uniform two-field
4365// construction (`nome.to_string()` / `caminho.to_string()`) is spelled
4366// once — inside the macro — rather than at every wire-up site.
4367//
4368// The twelve `FonteCaminho<Variant> { nome, caminho, byte }` three-field
4369// shapes at the per-byte-classification arms — the
4370// `FonteCaminho{ControlChar,ShellRedirection,ShellGlob,
4371// ShellSubshellGrouping,ShellBraceExpansion,ShellBracketExpansion,
4372// ShellQuoteGrouping,ShellComment,UrlPercentEncoding,
4373// ShellVariableExpansion,ShellHistoryExpansion,ShellHistorySubstitution}`
4374// cluster — carry an additional `byte: u8` naming the offending byte and
4375// so would break the uniform-two-field routing this macro promises. They
4376// instead fold onto the sibling three-field envelope through
4377// [`fonte_caminho_byte_ctors!`] (this-commit-lift, 12 variants on the
4378// `{ nome, caminho, byte }` shape), whose sole additional axis over this
4379// two-slot family is the `byte: u8` classification the arms carry. The
4380// remaining `FonteCaminhoEmpty` one-field `{ nome }` shape at the empty-
4381// first arm folds instead onto the peer [`dep_nome_only_ctors!`]
4382// (792aa92, 5 variants on `{ nome: String }`) sibling family of this
4383// envelope.
4384//
4385// Every future consumer that wants to construct one of these eleven
4386// variants outside the current in-crate [`DepSource::validate_caminho`]
4387// wire-up sites (a deferred `caixa-resolver` per-`:caminho` re-validator
4388// at lacre-resolve time re-checking the same value-shape axes the resolver
4389// consumes, a future `feira validate --deps` per-caixa admission verb
4390// re-checking the `:fonte :caminho` axis, a per-lacre overlay resolver
4391// rejecting a `:caminho` value against a cluster-local snapshot) now
4392// reaches each variant through one call rather than re-inlining the
4393// four-line struct-literal in lockstep with the eleven in-crate wire-up
4394// sites.
4395macro_rules! fonte_caminho_ctors {
4396    ($($ctor:ident => $variant:ident),* $(,)?) => {
4397        impl DepError {
4398            $(
4399                #[doc = concat!(
4400                    "Construct a [`DepError::",
4401                    stringify!($variant),
4402                    "`] naming the offending `:deps :nome` + `:fonte ",
4403                    "(:tipo path …) :caminho` pair. Folds the uniform ",
4404                    "`Self::",
4405                    stringify!($variant),
4406                    " { nome: nome.to_string(), caminho: caminho.to_string() }` ",
4407                    "two-slot struct-literal onto one substrate primitive so ",
4408                    "every [`DepSource::validate_caminho`] wire-up on this ",
4409                    "variant reads through one dispatch rather than the ",
4410                    "pre-lift four-line open-coded block."
4411                )]
4412                #[must_use]
4413                pub fn $ctor(nome: &str, caminho: &str) -> Self {
4414                    Self::$variant {
4415                        nome: nome.to_string(),
4416                        caminho: caminho.to_string(),
4417                    }
4418                }
4419            )*
4420        }
4421    };
4422}
4423
4424fonte_caminho_ctors! {
4425    fonte_caminho_absolute => FonteCaminhoAbsolute,
4426    fonte_caminho_tilde_expansion => FonteCaminhoTildeExpansion,
4427    fonte_caminho_var_expansion => FonteCaminhoVarExpansion,
4428    fonte_caminho_leading_whitespace => FonteCaminhoLeadingWhitespace,
4429    fonte_caminho_leading_hyphen => FonteCaminhoLeadingHyphen,
4430    fonte_caminho_backslash => FonteCaminhoBackslash,
4431    fonte_caminho_shell_pipe => FonteCaminhoShellPipe,
4432    fonte_caminho_shell_semicolon => FonteCaminhoShellSemicolon,
4433    fonte_caminho_shell_background => FonteCaminhoShellBackground,
4434    fonte_caminho_shell_command_substitution => FonteCaminhoShellCommandSubstitution,
4435    fonte_caminho_trailing_slash => FonteCaminhoTrailingSlash,
4436}
4437
4438// Fold the twelve `DepError::FonteCaminho<Variant> { nome: nome.to_string(),
4439// caminho: caminho.to_string(), byte: b }` three-slot struct-variant wire-up
4440// sites at [`DepSource::validate_caminho`] onto one substrate primitive per
4441// typed variant — the paired `{ nome: String, caminho: String, byte: u8 }`
4442// three-slot family on [`DepError`], strict sibling of the peer
4443// [`fonte_caminho_ctors!`] (f85f145, 11 variants on the two-slot
4444// `{ nome: String, caminho: String }` envelope) of this envelope. Extends
4445// that fold onto the `byte`-classifying arms whose additional `byte: u8`
4446// axis broke its uniform-two-field routing — the exact "future compounding
4447// work" the pre-lift `fonte_caminho_ctors!` prose named as deferred, closed
4448// here. Third fold family on this `DepError` envelope, sibling of the peer
4449// two-slot [`fonte_caminho_ctors!`] and one-slot [`dep_nome_only_ctors!`]
4450// (792aa92, 5 variants on the `{ nome: String }` envelope) families on the
4451// same enum.
4452//
4453// Each of the twelve wire-up sites on this shape (the control-byte arm
4454// closing `FonteCaminhoControlChar` on the sub-`0x20` / `0x7F` cluster; the
4455// shell-lexer-metachar cascade closing `FonteCaminhoShellRedirection` on
4456// `< >`, `FonteCaminhoShellGlob` on `* ?`, `FonteCaminhoShellSubshellGrouping`
4457// on `( )`, `FonteCaminhoShellBraceExpansion` on `{ }`,
4458// `FonteCaminhoShellBracketExpansion` on `[ ]`, and
4459// `FonteCaminhoShellQuoteGrouping` on `' "`; the single-metachar arms
4460// closing `FonteCaminhoShellComment` on `#`, `FonteCaminhoUrlPercentEncoding`
4461// on `%`, `FonteCaminhoShellVariableExpansion` on `$`,
4462// `FonteCaminhoShellHistoryExpansion` on `!`, and
4463// `FonteCaminhoShellHistorySubstitution` on `^`) opened the identical
4464// `DepError::FonteCaminho<Variant> { nome: nome.to_string(),
4465// caminho: caminho.to_string(), byte: b }` five-line struct-literal against
4466// the same `(nome: &str, caminho: &str, b: u8)` local triple — the exact
4467// "same block re-inlined at every consumer" shape the PRIME DIRECTIVE names
4468// as a bug, on the same altitude the peer two-slot `fonte_caminho_ctors!`
4469// closed on the sibling two-field envelope of this same enum. The twelve
4470// variants share one `{ nome: String, caminho: String, byte: u8 }` shape, so
4471// the fold routes each wire-up site through one dispatch per typed variant.
4472//
4473// The macro below generates one `#[must_use]` inherent constructor per
4474// variant of shape `fn <ctor>(nome: &str, caminho: &str, byte: u8) -> Self`,
4475// so every wire-up site collapses onto one dispatch:
4476// `DepError::<ctor>(nome, caminho, b)`, byte-equal to the pre-lift
4477// struct-literal on the same `(&str, &str, u8)` fixture. The uniform
4478// three-field construction (`nome.to_string()` / `caminho.to_string()` /
4479// `byte`) is spelled once — inside the macro — rather than at every wire-up
4480// site.
4481//
4482// Every future consumer that wants to construct one of these twelve
4483// variants outside the current in-crate [`DepSource::validate_caminho`]
4484// wire-up sites (a deferred `caixa-resolver` per-`:caminho` re-validator
4485// at lacre-resolve time re-checking the same value-shape axes the resolver
4486// consumes, a future `feira validate --deps` per-caixa admission verb
4487// re-checking the `:fonte :caminho` axis against the shell-metachar
4488// classification bytes this cluster catches, a per-lacre overlay resolver
4489// rejecting a `:caminho` value against a cluster-local snapshot) now
4490// reaches each variant through one call rather than re-inlining the
4491// five-line struct-literal in lockstep with the twelve in-crate wire-up
4492// sites.
4493macro_rules! fonte_caminho_byte_ctors {
4494    ($($ctor:ident => $variant:ident),* $(,)?) => {
4495        impl DepError {
4496            $(
4497                #[doc = concat!(
4498                    "Construct a [`DepError::",
4499                    stringify!($variant),
4500                    "`] naming the offending `:deps :nome` + `:fonte ",
4501                    "(:tipo path …) :caminho` pair + the offending `byte: u8` ",
4502                    "classification. Folds the uniform `Self::",
4503                    stringify!($variant),
4504                    " { nome: nome.to_string(), caminho: caminho.to_string(), ",
4505                    "byte }` three-slot struct-literal onto one substrate ",
4506                    "primitive so every [`DepSource::validate_caminho`] wire-up ",
4507                    "on this variant reads through one dispatch rather than ",
4508                    "the pre-lift five-line open-coded block."
4509                )]
4510                #[must_use]
4511                pub fn $ctor(nome: &str, caminho: &str, byte: u8) -> Self {
4512                    Self::$variant {
4513                        nome: nome.to_string(),
4514                        caminho: caminho.to_string(),
4515                        byte,
4516                    }
4517                }
4518            )*
4519        }
4520    };
4521}
4522
4523fonte_caminho_byte_ctors! {
4524    fonte_caminho_control_char => FonteCaminhoControlChar,
4525    fonte_caminho_shell_redirection => FonteCaminhoShellRedirection,
4526    fonte_caminho_shell_glob => FonteCaminhoShellGlob,
4527    fonte_caminho_shell_subshell_grouping => FonteCaminhoShellSubshellGrouping,
4528    fonte_caminho_shell_brace_expansion => FonteCaminhoShellBraceExpansion,
4529    fonte_caminho_shell_bracket_expansion => FonteCaminhoShellBracketExpansion,
4530    fonte_caminho_shell_quote_grouping => FonteCaminhoShellQuoteGrouping,
4531    fonte_caminho_shell_comment => FonteCaminhoShellComment,
4532    fonte_caminho_url_percent_encoding => FonteCaminhoUrlPercentEncoding,
4533    fonte_caminho_shell_variable_expansion => FonteCaminhoShellVariableExpansion,
4534    fonte_caminho_shell_history_expansion => FonteCaminhoShellHistoryExpansion,
4535    fonte_caminho_shell_history_substitution => FonteCaminhoShellHistorySubstitution,
4536}
4537
4538// Fold the five `DepError::<Variant> { nome: <owner>.clone_or_to_string() }`
4539// single-slot struct-variant wire-up sites scattered across
4540// [`Dep::validate`] / [`Dep::validate_caracteristicas`] /
4541// [`DepSource::validate`] / [`DepSource::validate_caminho`] onto one
4542// substrate primitive per typed variant — the paired `{ nome: String }`
4543// single-slot family on [`DepError`], sibling of the peer
4544// [`fonte_caminho_ctors!`] (f85f145, 11 variants on
4545// `{ nome: String, caminho: String }`) on the sibling two-slot envelope of
4546// the same enum, and of the peer
4547// [`crate::supervisor::supervisor_caixa_only_ctors!`] (db09650, 3 variants
4548// on `{ caixa: String }`) on the `SupervisorError` envelope's single-slot
4549// axis. Second fold family on this `DepError` envelope, and the first on
4550// the single-`{ nome }` shape.
4551//
4552// The five wire-up sites this fold closes each opened the identical
4553// `DepError::<Variant> { nome: <owner>.to_string_or_clone() }` three-line
4554// struct-literal against the same `nome: &str` (or `self.nome: &String`)
4555// local — the exact "same block re-inlined at every consumer" shape the
4556// PRIME DIRECTIVE names as a bug. The five variants share one
4557// `{ nome: String }` shape, so the fold routes each wire-up site through
4558// one dispatch per typed variant.
4559//
4560// The macro below generates one `#[must_use]` inherent constructor per
4561// variant of shape `fn <ctor>(nome: &str) -> Self`, so every wire-up site
4562// collapses onto one dispatch: `DepError::<ctor>(nome)`, byte-equal to the
4563// pre-lift struct-literal on the same `&str` fixture. The uniform
4564// one-field construction (`nome.to_string()`) is spelled once — inside
4565// the macro — rather than at every wire-up site. Callers that hold a
4566// `String` (`self.nome`) pass `&self.nome`, which auto-derefs to `&str`
4567// and lets the macro-owned `.to_string()` produce the fresh owning copy
4568// the enum variant needs; the semantics collapse onto the same
4569// `.clone()`-equivalent one this fold replaces at every site.
4570//
4571// The sibling `NomeEmpty` unit-variant (`enum DepError { NomeEmpty, … }`)
4572// on the same envelope stays on its pre-lift open-coded wire-up shape —
4573// it carries no `nome` field (the offending `:nome` value *is* the empty
4574// string this variant catches) so the uniform `fn(nome: &str) -> Self`
4575// signature this macro promises does not apply. Every future consumer
4576// that wants to construct one of these five variants outside the current
4577// in-crate wire-up sites (a deferred `caixa-resolver` per-`:versao` /
4578// `:caracteristicas` / `:fonte :repo` / `:fonte :pin` / `:fonte :caminho`
4579// re-validator at lacre-resolve time, a future `feira validate --deps`
4580// per-caixa admission verb, a per-lacre overlay resolver rejecting one of
4581// these empty-value shapes against a cluster-local snapshot) now reaches
4582// each variant through one call rather than re-inlining the three-line
4583// struct-literal in lockstep with the five in-crate wire-up sites.
4584macro_rules! dep_nome_only_ctors {
4585    ($($ctor:ident => $variant:ident),* $(,)?) => {
4586        impl DepError {
4587            $(
4588                #[doc = concat!(
4589                    "Construct a [`DepError::",
4590                    stringify!($variant),
4591                    "`] naming the offending `:deps :nome`. Folds the ",
4592                    "uniform `Self::",
4593                    stringify!($variant),
4594                    " { nome: nome.to_string() }` one-field ",
4595                    "struct-literal onto one substrate primitive so every ",
4596                    "in-crate wire-up on this variant reads through one ",
4597                    "dispatch rather than the pre-lift three-line ",
4598                    "open-coded block."
4599                )]
4600                #[must_use]
4601                pub fn $ctor(nome: &str) -> Self {
4602                    Self::$variant { nome: nome.to_string() }
4603                }
4604            )*
4605        }
4606    };
4607}
4608
4609dep_nome_only_ctors! {
4610    versao_empty => VersaoEmpty,
4611    fonte_repo_empty => FonteRepoEmpty,
4612    fonte_pin_missing => FontePinMissing,
4613    fonte_caminho_empty => FonteCaminhoEmpty,
4614    caracteristica_empty => CaracteristicaEmpty,
4615}
4616
4617#[allow(clippy::trivially_copy_pass_by_ref)]
4618fn is_false(b: &bool) -> bool {
4619    !*b
4620}
4621
4622#[cfg(test)]
4623mod tests {
4624    use super::*;
4625
4626    #[test]
4627    fn registry_dep_is_minimal() {
4628        let d = Dep::simple("caixa-teia", "^0.1");
4629        assert_eq!(d.nome, "caixa-teia");
4630        assert_eq!(d.versao, "^0.1");
4631        assert!(d.fonte.is_none());
4632        assert!(!d.opcional());
4633        assert!(d.caracteristicas().is_empty());
4634    }
4635
4636    #[test]
4637    fn dep_string_scalar_accessor_pair_is_const_fn() {
4638        // Fail-before-pass-after pin on [`Dep::nome`] +
4639        // [`Dep::versao_requirement`]'s `const`-eval-surface posture.
4640        // Each accessor projects the per-`:deps` / per-`:deps-dev`
4641        // entry's [`String`] storage through the `pub const fn`
4642        // [`String::as_str`] (const-stable since Rust 1.87, well
4643        // within the workspace MSRV) — any future accidental
4644        // downgrade to non-`const` fails the corresponding
4645        // `<name>_via_const_fn` wrapper at caixa-core build time with
4646        // E0015 (`cannot call non-const method`), strictly stronger
4647        // than a runtime `assert!`. Sibling of the peer
4648        // per-M2/M3/universal-axis `String → &str` scalar-accessor
4649        // family pins on the sibling `const`-eval-surface passes
4650        // ([`crate::Caixa::nome`] / [`crate::Caixa::versao`] at the
4651        // top-level manifest, [`crate::CaixaVersion::as_str`] at the
4652        // typed-newtype wrapper, [`crate::aplicacao::Membro::nome`] /
4653        // [`crate::aplicacao::Membro::versao_requirement`] at the M3
4654        // membership axis, [`crate::aplicacao::Entrada::hostname`] /
4655        // [`crate::aplicacao::Entrada::destination`] at the M3
4656        // ingress axis, [`crate::supervisor::ChildSpec::nome`] /
4657        // [`crate::supervisor::ChildSpec::versao_requirement`] at the
4658        // M2 supervisor-tree axis,
4659        // [`crate::upgrade::UpgradeFromEntry::prior_versao`] at the
4660        // M2 upgrade axis, and the per-`:contratos`
4661        // [`crate::aplicacao::WitContract::source`] /
4662        // [`crate::aplicacao::WitContract::destination`] /
4663        // [`crate::aplicacao::WitContract::world_ref`] trio the
4664        // sibling pin at 279823b already anchors).
4665        const fn nome_via_const_fn(d: &Dep) -> &str {
4666            d.nome()
4667        }
4668        const fn versao_via_const_fn(d: &Dep) -> &str {
4669            d.versao_requirement()
4670        }
4671        for (nome, versao) in [
4672            ("caixa-teia", "^0.1"),
4673            ("caixa-mesh", "~0.2.3"),
4674            ("caixa-helm", "*"),
4675        ] {
4676            let d = Dep::simple(nome, versao);
4677            assert_eq!(nome_via_const_fn(&d), d.nome());
4678            assert_eq!(versao_via_const_fn(&d), d.versao_requirement());
4679            assert_eq!(d.nome(), nome);
4680            assert_eq!(d.versao_requirement(), versao);
4681        }
4682    }
4683
4684    #[test]
4685    fn dep_outer_accessor_family_is_const_fn() {
4686        // Fail-before-pass-after pin on [`Dep::fonte`] +
4687        // [`Dep::caracteristicas`]'s `const`-eval-surface posture.
4688        // Each accessor projects the per-`:deps` / per-`:deps-dev`
4689        // entry's composite / list storage through a `pub const fn`
4690        // stdlib method (`Option::<DepSource>::as_ref` /
4691        // `Vec::<String>::as_slice`, both const-stable since Rust
4692        // 1.83, well within the workspace MSRV). Any future
4693        // accidental downgrade to non-`const` fails the corresponding
4694        // `<name>_via_const_fn` wrapper at caixa-core build time with
4695        // E0015 (`cannot call non-const method`), strictly stronger
4696        // than a runtime `assert!` and side-stepping the destructor-
4697        // in-const restriction the `Dep` fixture's `String` /
4698        // `Option<DepSource>` / `Vec<String>` carriers rule out on the
4699        // direct-`const _: () = assert!(...)` residence.
4700        //
4701        // Peer of the sibling per-`Dep` scalar-accessor pair pin
4702        // [`dep_string_scalar_accessor_pair_is_const_fn`] on the same
4703        // outer per-dep-list-entry [`Dep`] altitude — this pin extends
4704        // the `const`-eval-surface discipline onto the composite-
4705        // reference and slice-return arms of the outer-`Dep` accessor
4706        // family, closing the four-slot outer surface (`:nome` +
4707        // `:versao` + `:fonte` + `:caracteristicas`) on the `const`-fn
4708        // posture. The `:opcional` `bool` arm already carries the
4709        // posture through [`Dep::opcional`]'s prior `pub const fn`
4710        // declaration, so this pin lands the last two unlifted
4711        // outer-`Dep` accessors and closes the family.
4712        const fn fonte_via_const_fn(d: &Dep) -> Option<&DepSource> {
4713            d.fonte()
4714        }
4715        const fn caracteristicas_via_const_fn(d: &Dep) -> &[String] {
4716            d.caracteristicas()
4717        }
4718        // `Dep::simple` — no `:fonte`, empty `:caracteristicas`.
4719        let empty = Dep::simple("caixa-teia", "^0.1");
4720        assert!(fonte_via_const_fn(&empty).is_none());
4721        assert_eq!(fonte_via_const_fn(&empty), empty.fonte());
4722        assert!(caracteristicas_via_const_fn(&empty).is_empty());
4723        assert_eq!(
4724            caracteristicas_via_const_fn(&empty),
4725            empty.caracteristicas()
4726        );
4727        // `Dep::git` — `:fonte` is `Some(Git{…})`, `:caracteristicas`
4728        // still empty.
4729        let git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
4730        assert!(fonte_via_const_fn(&git).is_some());
4731        assert_eq!(fonte_via_const_fn(&git), git.fonte());
4732        assert_eq!(caracteristicas_via_const_fn(&git), git.caracteristicas());
4733        // Populated `:caracteristicas` — exercise the non-empty
4734        // slice-view arm to pin the accessor's borrow shape against
4735        // both a `Vec::new()` empty backing buffer and a populated one.
4736        let mut with_features = Dep::simple("caixa-teia", "^0.1");
4737        with_features.caracteristicas = vec!["feat-a".into(), "feat-b".into()];
4738        assert_eq!(caracteristicas_via_const_fn(&with_features).len(), 2);
4739        assert_eq!(
4740            caracteristicas_via_const_fn(&with_features),
4741            with_features.caracteristicas()
4742        );
4743    }
4744
4745    #[test]
4746    fn git_dep_carries_tag() {
4747        let d = Dep::git("t", "*", "github:o/r", "v1");
4748        match d.fonte {
4749            Some(DepSource::Git {
4750                ref repo, ref tag, ..
4751            }) => {
4752                assert_eq!(repo, "github:o/r");
4753                assert_eq!(tag.as_deref(), Some("v1"));
4754            }
4755            _ => panic!("expected Git source"),
4756        }
4757    }
4758
4759    #[test]
4760    fn validate_accepts_simple_dep() {
4761        Dep::simple("caixa-teia", "^0.1").validate().unwrap();
4762    }
4763
4764    #[test]
4765    fn validate_rejects_empty_nome() {
4766        // The fail-before-pass-after pin for `:nome ""`: the empty-name
4767        // arm fires first so the per-entry parse-side diagnostic doesn't
4768        // emit a useless `nome: ""` reference.
4769        let mut d = Dep::simple("placeholder", "^0.1");
4770        d.nome = String::new();
4771        assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
4772    }
4773
4774    #[test]
4775    fn validate_rejects_empty_versao() {
4776        // `parse_requirement("")` returns `Ok(VersionReq::STAR)` (the
4777        // semver crate accepts the empty string as a wildcard match),
4778        // so the empty-`:versao` arm is structurally necessary even
4779        // with the parse arm in place — mirrors `MembroVersaoEmpty` /
4780        // `EmptyChildVersion` ordering on the other two `:versao` axes.
4781        let mut d = Dep::simple("caixa-teia", "ignored");
4782        d.versao = String::new();
4783        let err = d.validate().unwrap_err();
4784        assert!(
4785            matches!(err, DepError::VersaoEmpty { ref nome } if nome == "caixa-teia"),
4786            "got {err:?}"
4787        );
4788    }
4789
4790    // ── value-shape: DNS-1123 label on :deps :nome ────────────────────────
4791
4792    #[test]
4793    fn validate_rejects_nome_with_uppercase() {
4794        // The fail-before-pass-after pin: a non-empty but uppercase
4795        // `:nome` silently passed `validate()` on every pre-gate
4796        // codebase because the prior shape only refused the empty
4797        // string. The DNS-1123 violation surfaced far downstream at
4798        // lacre-resolve time when the *target* caixa's `:nome` failed
4799        // its own gate — far from the `:deps` entry, with a diagnostic
4800        // naming the target rather than the dep entry that referenced
4801        // it. Same fail-before-pass-after fixture pinned for
4802        // `:membros :caixa` (3f9d7a0), `:children :caixa` (31bfa43),
4803        // and Caixa `:nome` (6c992f8).
4804        let d = Dep::simple("Caixa-Teia", "^0.1");
4805        let err = d.validate().unwrap_err();
4806        assert!(
4807            matches!(
4808                err,
4809                DepError::NomeInvalid { ref nome, ref reason }
4810                    if nome == "Caixa-Teia" && reason.contains("uppercase")
4811            ),
4812            "got {err:?}"
4813        );
4814    }
4815
4816    #[test]
4817    fn validate_rejects_nome_with_underscore() {
4818        // RFC 1123 allows `[a-z0-9-]` only; underscore is the canonical
4819        // "I'm thinking of Go module names / Python identifiers" leak.
4820        // Same fixture pinned for the peer caixa-identifier axes.
4821        let d = Dep::simple("caixa_teia", "^0.1");
4822        let err = d.validate().unwrap_err();
4823        assert!(
4824            matches!(
4825                err,
4826                DepError::NomeInvalid { ref nome, ref reason }
4827                    if nome == "caixa_teia" && reason.contains('_')
4828            ),
4829            "got {err:?}"
4830        );
4831    }
4832
4833    #[test]
4834    fn validate_rejects_nome_with_dot() {
4835        // A `:deps :nome` is a single DNS-1123 *label*, not a
4836        // subdomain — dots are rejected. The `"caixa.teia"` shape is
4837        // the canonical "I confused the dep name with the FQDN /
4838        // namespace" footgun, distinct from the legitimate
4839        // `:fonte :repo "github:org/caixa-teia"` axis.
4840        let d = Dep::simple("caixa.teia", "^0.1");
4841        let err = d.validate().unwrap_err();
4842        assert!(
4843            matches!(
4844                err,
4845                DepError::NomeInvalid { ref nome, ref reason }
4846                    if nome == "caixa.teia" && reason.contains('.')
4847            ),
4848            "got {err:?}"
4849        );
4850    }
4851
4852    #[test]
4853    fn validate_rejects_nome_with_leading_hyphen() {
4854        // RFC 1123 requires alphanumeric at both label boundaries.
4855        // Pinned in parity with the peer DNS-1123 fixtures.
4856        let d = Dep::simple("-caixa-teia", "^0.1");
4857        let err = d.validate().unwrap_err();
4858        assert!(
4859            matches!(
4860                err,
4861                DepError::NomeInvalid { ref nome, ref reason }
4862                    if nome == "-caixa-teia" && reason.contains("alphanumeric")
4863            ),
4864            "got {err:?}"
4865        );
4866    }
4867
4868    #[test]
4869    fn validate_rejects_nome_with_trailing_hyphen() {
4870        let d = Dep::simple("caixa-teia-", "^0.1");
4871        let err = d.validate().unwrap_err();
4872        assert!(
4873            matches!(
4874                err,
4875                DepError::NomeInvalid { ref nome, ref reason }
4876                    if nome == "caixa-teia-" && reason.contains("alphanumeric")
4877            ),
4878            "got {err:?}"
4879        );
4880    }
4881
4882    #[test]
4883    fn validate_rejects_nome_with_slash() {
4884        // The canonical "I copied the GitHub repo path into `:nome`
4885        // instead of `:fonte :repo`" typo. A `/` in the name leaks the
4886        // lacre-side `:repositorio` shape (`pleme-io/caixa-teia`) into
4887        // the local-name slot. Same fixture pinned for `:membros
4888        // :caixa` (3f9d7a0).
4889        let d = Dep::simple("pleme-io/caixa-teia", "^0.1");
4890        let err = d.validate().unwrap_err();
4891        assert!(
4892            matches!(
4893                err,
4894                DepError::NomeInvalid { ref nome, ref reason }
4895                    if nome == "pleme-io/caixa-teia" && reason.contains('/')
4896            ),
4897            "got {err:?}"
4898        );
4899    }
4900
4901    #[test]
4902    fn validate_rejects_nome_too_long() {
4903        // 64-byte label — one over the RFC 1035 / RFC 1123 label cap.
4904        // Built from a valid character set so the length-bound
4905        // diagnostic surfaces before any per-character check (the
4906        // order pin parallel to the per-character predicates inside
4907        // [`crate::render::is_dns_1123_label`]).
4908        let long = "a".repeat(64);
4909        let d = Dep::simple(&long, "^0.1");
4910        let err = d.validate().unwrap_err();
4911        assert!(
4912            matches!(
4913                err,
4914                DepError::NomeInvalid { ref nome, ref reason }
4915                    if nome.len() == 64 && reason.contains("max length of 63")
4916            ),
4917            "got {err:?}"
4918        );
4919    }
4920
4921    #[test]
4922    fn validate_accepts_canonical_nome_labels() {
4923        // Positive-control sweep — every form the K8s apiserver
4924        // accepts as a DNS-1123 label must round-trip through
4925        // validate. Covers a hyphen-bearing label, a numeric-suffix
4926        // label, a leading-digit label, a single-character label, and
4927        // a 63-byte (exactly the cap) label — the same fixture set
4928        // the peer `:membros :caixa` / `:children :caixa` positive
4929        // controls pin.
4930        for nome in [
4931            "caixa-teia",
4932            "caixa-resolver2",
4933            "2nd-tier-cache",
4934            "x",
4935            "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0",
4936        ] {
4937            Dep::simple(nome, "^0.1")
4938                .validate()
4939                .unwrap_or_else(|e| panic!("canonical label {nome:?} must validate, got {e:?}"));
4940        }
4941    }
4942
4943    #[test]
4944    fn nome_empty_takes_precedence_over_nome_invalid() {
4945        // Ordering pin: `NomeEmpty` is the more self-locating
4946        // diagnostic on `""` and must lead — `is_dns_1123_label` is
4947        // only reached after the empty-check fires at the call site.
4948        // Mirrors `membro_caixa_empty_takes_precedence_over_invalid`
4949        // (3f9d7a0) on the peer caixa-identifier axis.
4950        let mut d = Dep::simple("placeholder", "^0.1");
4951        d.nome = String::new();
4952        assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
4953    }
4954
4955    #[test]
4956    fn nome_invalid_fires_before_versao_empty() {
4957        // Ordering pin: a malformed `:nome` fires before any `:versao`
4958        // axis check on the *same* entry — the per-entry shape gates
4959        // run top-to-bottom (nome empty → nome shape → versao empty →
4960        // versao parse → fonte shape), so a one-entry caixa.lisp with
4961        // both wrong sees the name-side diagnostic first (the name is
4962        // the self-locating axis — without a valid name, the parse
4963        // diagnostic can't quote `:nome "<bad>"`). Same ordering
4964        // discipline as `membro_caixa_invalid_fires_before_versao_check`
4965        // (3f9d7a0).
4966        let mut d = Dep::simple("Caixa-Teia", "^0.1");
4967        d.versao = String::new();
4968        let err = d.validate().unwrap_err();
4969        assert!(
4970            matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
4971            "got {err:?}"
4972        );
4973    }
4974
4975    #[test]
4976    fn nome_invalid_fires_before_versao_invalid() {
4977        // Ordering pin: a malformed `:nome` fires before the `:versao`
4978        // parse-side check on the *same* entry. Pin separately from
4979        // the empty-versao ordering so a future re-ordering surfaces
4980        // here, parallel to the b0c8389 / c4213a4 trajectory.
4981        let d = Dep::simple("Caixa-Teia", "^^0.1");
4982        let err = d.validate().unwrap_err();
4983        assert!(
4984            matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
4985            "got {err:?}"
4986        );
4987    }
4988
4989    #[test]
4990    fn nome_invalid_fires_before_fonte_invalid() {
4991        // Ordering pin: a malformed `:nome` fires before the `:fonte`
4992        // shape check on the *same* entry. The `:fonte` diagnostic
4993        // names the offending dep's `:nome` verbatim (via
4994        // `DepSource::validate(&self.nome)`), so a non-self-locating
4995        // name would taint the downstream diagnostic too — the gate
4996        // ordering keeps both diagnostics individually self-locating.
4997        let mut d = Dep::simple("Caixa-Teia", "^0.1");
4998        d.fonte = Some(DepSource::Git {
4999            repo: String::new(),
5000            tag: None,
5001            rev: None,
5002            branch: None,
5003        });
5004        let err = d.validate().unwrap_err();
5005        assert!(
5006            matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
5007            "got {err:?}"
5008        );
5009    }
5010
5011    #[test]
5012    fn nome_invalid_diagnostic_carries_offending_name() {
5013        // The diagnostic-shape pin: the error names the offending
5014        // `:nome` value verbatim so the author can grep their
5015        // caixa.lisp without re-running the build, and carries a
5016        // non-empty `reason` from `is_dns_1123_label` so the
5017        // predicate's own wording flows through to the diagnostic.
5018        // Same shape as `MembroCaixaInvalid` (3f9d7a0),
5019        // `ChildCaixaInvalid` (31bfa43), `ManifestError::NomeInvalid`
5020        // (6c992f8) — the four DNS-1123 caixa-identifier axes now
5021        // share a structurally-equivalent diagnostic family.
5022        let d = Dep::simple("Caixa_Teia", "^0.1");
5023        let err = d.validate().unwrap_err();
5024        let DepError::NomeInvalid { nome, reason } = err else {
5025            panic!("expected NomeInvalid, got other variant");
5026        };
5027        assert_eq!(nome, "Caixa_Teia");
5028        assert!(
5029            !reason.is_empty(),
5030            "NomeInvalid `reason` must carry the predicate's wording verbatim"
5031        );
5032    }
5033
5034    #[test]
5035    fn validate_rejects_invalid_versao_requirement() {
5036        // The fail-before-pass-after pin: a non-empty but malformed
5037        // requirement (`"^bad-version"`) silently passed every pre-gate
5038        // codebase because `:deps :versao` wasn't validated. The parse
5039        // failure surfaced far downstream at lacre-resolve time with a
5040        // `semver::Error` that didn't name which `:deps` entry carried
5041        // the typo. The new gate moves the check to caixa-build time
5042        // at the source caixa.lisp.
5043        let d = Dep::simple("caixa-teia", "^bad-version");
5044        let err = d.validate().unwrap_err();
5045        assert!(
5046            matches!(
5047                err,
5048                DepError::VersaoInvalid { ref nome, ref versao, .. }
5049                    if nome == "caixa-teia" && versao == "^bad-version"
5050            ),
5051            "got {err:?}"
5052        );
5053    }
5054
5055    #[test]
5056    fn validate_rejects_versao_with_double_caret_typo() {
5057        // `"^^0.1"` is the canonical doubled-caret typo — looks like a
5058        // Cargo-shaped requirement on first glance but fails the parser
5059        // because semver doesn't accept stacked operators. Pin this
5060        // adjacent-shape footgun explicitly so a future relaxation that
5061        // accepts "looks-canonical-but-isn't" forms surfaces here, in
5062        // parity with the `:membros` / `:children` fixtures.
5063        let d = Dep::simple("caixa-teia", "^^0.1");
5064        let err = d.validate().unwrap_err();
5065        assert!(
5066            matches!(
5067                err,
5068                DepError::VersaoInvalid { ref nome, ref versao, .. }
5069                    if nome == "caixa-teia" && versao == "^^0.1"
5070            ),
5071            "got {err:?}"
5072        );
5073    }
5074
5075    #[test]
5076    fn validate_rejects_versao_with_v_prefixed_tag() {
5077        // `"v0.1"` is the canonical "git-tag-shape leaking into the
5078        // semver requirement slot" typo — an author copies the
5079        // publish-side git-tag string verbatim into `:versao`, but
5080        // Cargo's semver parser rejects the leading `v`. Same fixture
5081        // pinned for `:membros :versao` (9888b13) and `:children
5082        // :versao` (b38ff3a). (Bare `x`-glob shorthands like `^0.1.x`
5083        // are *accepted* by the semver crate as an `*` wildcard on the
5084        // patch axis — they're a Cargo-side valid shape, not a typo.)
5085        let d = Dep::simple("caixa-teia", "v0.1");
5086        let err = d.validate().unwrap_err();
5087        assert!(
5088            matches!(
5089                err,
5090                DepError::VersaoInvalid { ref nome, ref versao, .. }
5091                    if nome == "caixa-teia" && versao == "v0.1"
5092            ),
5093            "got {err:?}"
5094        );
5095    }
5096
5097    #[test]
5098    fn validate_accepts_canonical_versao_forms() {
5099        // The five Cargo-shaped requirement forms `:membros :versao`
5100        // and `:children :versao` already accept via
5101        // `crate::parse_requirement` must pass the deps gate without
5102        // re-validating at the resolver layer. Pin every leg so a
5103        // future tightening of the canonical set surfaces here as a
5104        // test failure.
5105        for form in [
5106            "^0.1",      // caret — minor-range pin (the most common shape)
5107            "~0.1.2",    // tilde — patch-range pin
5108            "0.1.0",     // exact — single-version pin
5109            "*",         // wildcard — explicitly any-version
5110            ">=0.1, <2", // multi-range — comma-separated comparators
5111        ] {
5112            Dep::simple("caixa-teia", form)
5113                .validate()
5114                .unwrap_or_else(|e| panic!("canonical form {form:?} must validate, got {e:?}"));
5115        }
5116    }
5117
5118    #[test]
5119    fn versao_empty_takes_precedence_over_invalid() {
5120        // Order pin: the existing `VersaoEmpty` diagnostic (which
5121        // doesn't try to parse) fires before the new `VersaoInvalid`
5122        // parse-side diagnostic, so an empty `:versao` keeps its
5123        // narrower error message — `parse_requirement("")` would
5124        // otherwise return `Ok(STAR)` and silently pass, but the empty
5125        // arm catches it first.
5126        let mut d = Dep::simple("caixa-teia", "ignored");
5127        d.versao = String::new();
5128        let err = d.validate().unwrap_err();
5129        assert!(
5130            matches!(err, DepError::VersaoEmpty { ref nome } if nome == "caixa-teia"),
5131            "got {err:?}"
5132        );
5133    }
5134
5135    #[test]
5136    fn nome_empty_takes_precedence_over_versao_invalid() {
5137        // Order pin: even when `:versao` is malformed and would raise
5138        // its own diagnostic, `:nome ""` fires first because the
5139        // per-entry parse diagnostic needs a non-empty name to be
5140        // self-locating. Mirrors the
5141        // `membros_validation_runs_before_contratos_membership_check`
5142        // ordering on the typed-graph layer.
5143        let mut d = Dep::simple("placeholder", "^bad");
5144        d.nome = String::new();
5145        let err = d.validate().unwrap_err();
5146        assert_eq!(err, DepError::NomeEmpty);
5147    }
5148
5149    #[test]
5150    fn versao_invalid_diagnostic_carries_offending_versao() {
5151        // The diagnostic-shape pin: the error names the offending
5152        // `:versao` value verbatim so the author can grep their
5153        // caixa.lisp without re-running the build, and carries a
5154        // non-empty `reason` from `semver::VersionReq::parse` so the
5155        // parser's own wording flows through to the diagnostic.
5156        let d = Dep::simple("caixa-teia", "not-a-req");
5157        let err = d.validate().unwrap_err();
5158        let DepError::VersaoInvalid {
5159            nome,
5160            versao,
5161            reason,
5162        } = err
5163        else {
5164            panic!("expected VersaoInvalid, got other variant");
5165        };
5166        assert_eq!(nome, "caixa-teia");
5167        assert_eq!(versao, "not-a-req");
5168        assert!(
5169            !reason.is_empty(),
5170            "VersaoInvalid `reason` must carry the parser's wording verbatim"
5171        );
5172    }
5173
5174    // -- :fonte value-shape gate ------------------------------------------
5175
5176    fn dep_with_fonte(fonte: DepSource) -> Dep {
5177        let mut d = Dep::simple("caixa-teia", "^0.1");
5178        d.fonte = Some(fonte);
5179        d
5180    }
5181
5182    #[test]
5183    fn validate_accepts_git_fonte_with_tag() {
5184        // The positive-control pin on the canonical git source — exactly
5185        // one of :tag/:rev/:branch set, non-empty :repo. Mirrors the
5186        // shape every existing caixa-resolver integration test uses.
5187        let d = dep_with_fonte(DepSource::Git {
5188            repo: "github:pleme-io/caixa-teia".into(),
5189            tag: Some("v0.1.0".into()),
5190            rev: None,
5191            branch: None,
5192        });
5193        d.validate().unwrap();
5194    }
5195
5196    #[test]
5197    fn validate_accepts_git_fonte_with_rev() {
5198        // Each of the three pin axes is independently a valid single-pin
5199        // shape; pin the :rev arm so a future relaxation that only
5200        // accepts :tag surfaces here. The value is a full 40-hex SHA-1
5201        // OID — the canonical `git rev-parse HEAD` emission shape the
5202        // `crate::render::is_git_oid` value-shape gate now requires;
5203        // abbreviated OIDs are ambiguous across repo history and
5204        // rejected at this gate (pinned separately by
5205        // `validate_rejects_git_fonte_with_rev_abbreviated_prefix`).
5206        let d = dep_with_fonte(DepSource::Git {
5207            repo: "github:pleme-io/caixa-teia".into(),
5208            tag: None,
5209            rev: Some("c0ffee0123abcdef0123456789abcdef01234567".into()),
5210            branch: None,
5211        });
5212        d.validate().unwrap();
5213    }
5214
5215    #[test]
5216    fn validate_accepts_git_fonte_with_branch() {
5217        // The :branch arm is the third valid single-pin shape — pinned
5218        // separately so the gate-accepts-all-three-pin-axes contract is
5219        // a build-error to relax.
5220        let d = dep_with_fonte(DepSource::Git {
5221            repo: "github:pleme-io/caixa-teia".into(),
5222            tag: None,
5223            rev: None,
5224            branch: Some("main".into()),
5225        });
5226        d.validate().unwrap();
5227    }
5228
5229    #[test]
5230    fn validate_accepts_path_fonte() {
5231        // The positive-control pin on the path source — non-empty
5232        // :caminho, no pin axes (paths have no commit identity). Pinned
5233        // so a future "paths must also pin a rev" tightening surfaces
5234        // here as a structural decision, not a silent break.
5235        let d = dep_with_fonte(DepSource::Path {
5236            caminho: "../caixa-teia".into(),
5237        });
5238        d.validate().unwrap();
5239    }
5240
5241    #[test]
5242    fn validate_rejects_git_fonte_with_empty_repo() {
5243        // The fail-before-pass-after pin for `(:tipo git :repo "" :tag
5244        // "v1")`: the empty-repo shape silently passed every pre-gate
5245        // codebase because `:fonte` wasn't validated. The git-clone
5246        // failure surfaced far downstream at lacre-resolve time with no
5247        // field naming which `:deps` entry carried the typo. The new
5248        // gate moves the check to caixa-build time at the source
5249        // caixa.lisp.
5250        let d = dep_with_fonte(DepSource::Git {
5251            repo: String::new(),
5252            tag: Some("v0.1.0".into()),
5253            rev: None,
5254            branch: None,
5255        });
5256        let err = d.validate().unwrap_err();
5257        assert!(
5258            matches!(err, DepError::FonteRepoEmpty { ref nome } if nome == "caixa-teia"),
5259            "got {err:?}"
5260        );
5261    }
5262
5263    // -- :repo value-shape gate -------------------------------------------
5264    //
5265    // The `:fonte (:tipo git :repo …)` value flows verbatim into the
5266    // caixa-resolver's `git clone <repo>` subprocess. The pre-gate
5267    // codebase admitted any non-empty string; the new
5268    // [`crate::render::is_git_repo_url`] predicate gates the git-porcelain
5269    // URL intersection-floor at validate time, peer with the three pin
5270    // axes (`:tag` + `:branch` via `is_git_ref_name`, `:rev` via
5271    // `is_git_oid`). Every test in this section is a fail-before /
5272    // pass-after pin on a specific authoring footgun.
5273
5274    #[test]
5275    fn validate_rejects_git_fonte_with_repo_carrying_trailing_space() {
5276        // The canonical paste-from-doc footgun on `:repo` — an author
5277        // copies `"github:pleme-io/caixa-teia "` (trailing space) out of
5278        // a doc paragraph. Until this gate landed the empty-repo arm
5279        // passed (the string isn't empty), the resolver issued
5280        // `git clone 'github:pleme-io/caixa-teia '`, and the failure
5281        // surfaced at clone time with a quoting-confused error far from
5282        // the source caixa.lisp. Same paste-from-doc footgun the
5283        // `:tag "v0.1.0 "` gate (e70d213) closes on the peer refname
5284        // axis — now closed on the `:repo` URL axis too.
5285        let d = dep_with_fonte(DepSource::Git {
5286            repo: "github:pleme-io/caixa-teia ".into(),
5287            tag: Some("v0.1.0".into()),
5288            rev: None,
5289            branch: None,
5290        });
5291        let err = d.validate().unwrap_err();
5292        let DepError::FonteRepoShape { nome, repo, reason } = err else {
5293            panic!("expected FonteRepoShape, got other variant");
5294        };
5295        assert_eq!(nome, "caixa-teia");
5296        assert_eq!(repo, "github:pleme-io/caixa-teia ");
5297        assert!(
5298            reason.contains("whitespace"),
5299            "reason must surface the whitespace arm, got {reason:?}"
5300        );
5301    }
5302
5303    #[test]
5304    fn validate_rejects_git_fonte_with_repo_starting_with_dash() {
5305        // The canonical CLI-argument-injection footgun at the `git clone`
5306        // subprocess boundary — `:repo "-upload-pack=evil"` makes git's
5307        // argv parser read the value as a CLI flag, escaping the
5308        // subprocess argument boundary. The `--` separator workaround
5309        // does not fix the typed slot's accepted set; the gate rejects
5310        // the shape upstream at validate time so the resolver never
5311        // invokes a `git clone -…` subprocess.
5312        let d = dep_with_fonte(DepSource::Git {
5313            repo: "-upload-pack=evil".into(),
5314            tag: Some("v0.1.0".into()),
5315            rev: None,
5316            branch: None,
5317        });
5318        let err = d.validate().unwrap_err();
5319        let DepError::FonteRepoShape { repo, reason, .. } = err else {
5320            panic!("expected FonteRepoShape, got other variant");
5321        };
5322        assert_eq!(repo, "-upload-pack=evil");
5323        assert!(
5324            reason.contains("must not start with `-`"),
5325            "reason must surface the leading-`-` arm, got {reason:?}"
5326        );
5327    }
5328
5329    #[test]
5330    fn validate_rejects_git_fonte_with_repo_carrying_embedded_newline() {
5331        // The canonical paste-from-multiline-doc footgun — a `:repo`
5332        // string with an embedded `\n` silently breaks git's URL parser
5333        // and is a class of CRLF-injection at the subprocess-argument
5334        // boundary. Caught by the control-char arm (0x0A < 0x20).
5335        let d = dep_with_fonte(DepSource::Git {
5336            repo: "github:pleme-io/caixa-teia\nrm -rf /".into(),
5337            tag: Some("v0.1.0".into()),
5338            rev: None,
5339            branch: None,
5340        });
5341        let err = d.validate().unwrap_err();
5342        let DepError::FonteRepoShape { reason, .. } = err else {
5343            panic!("expected FonteRepoShape, got other variant");
5344        };
5345        assert!(
5346            reason.contains("control character"),
5347            "reason must surface the control-char arm, got {reason:?}"
5348        );
5349    }
5350
5351    #[test]
5352    fn validate_rejects_git_fonte_with_repo_carrying_tab() {
5353        // Tab is the sibling whitespace footgun (the canonical
5354        // copy-from-aligned-table paste); pinned separately from the
5355        // space arm so a future relaxation that only catches one
5356        // surfaces here.
5357        let d = dep_with_fonte(DepSource::Git {
5358            repo: "github:pleme-io/caixa-teia\t".into(),
5359            tag: Some("v0.1.0".into()),
5360            rev: None,
5361            branch: None,
5362        });
5363        let err = d.validate().unwrap_err();
5364        assert!(
5365            matches!(
5366                err,
5367                DepError::FonteRepoShape { ref reason, .. }
5368                    if reason.contains("whitespace")
5369            ),
5370            "got {err:?}"
5371        );
5372    }
5373
5374    #[test]
5375    fn validate_rejects_git_fonte_with_repo_carrying_non_ascii() {
5376        // IDN hosts must be pre-encoded as Punycode (`xn--…`) — raw
5377        // non-ASCII silently breaks at git's URL parser and round-trips
5378        // inconsistently across NFC/NFD normalization on APFS /
5379        // case-folding filesystems. Same intersection-floor
5380        // [`is_git_ref_name`] enforces on the refname axes.
5381        let d = dep_with_fonte(DepSource::Git {
5382            repo: "https://github.com/pleme-io/café".into(),
5383            tag: Some("v0.1.0".into()),
5384            rev: None,
5385            branch: None,
5386        });
5387        let err = d.validate().unwrap_err();
5388        assert!(
5389            matches!(
5390                err,
5391                DepError::FonteRepoShape { ref reason, .. }
5392                    if reason.contains("non-ASCII")
5393            ),
5394            "got {err:?}"
5395        );
5396    }
5397
5398    #[test]
5399    fn validate_rejects_git_fonte_with_repo_carrying_fragment_anchor() {
5400        // The fail-before-pass-after pin for the canonical paste-from-
5401        // browser-address-bar footgun on `:repo`: an author copies a
5402        // GitHub permalink to a README anchor / line-permalink and
5403        // forgets to trim the `#fragment` tail. Until this arm landed
5404        // `:repo "https://github.com/pleme-io/caixa-teia#readme"`
5405        // silently passed every prior arm (no whitespace, no control
5406        // chars, no non-ASCII, contains a `:`, doesn't start with `-`
5407        // or `:`), libcurl's URL parser stripped the `#readme` tail
5408        // before opening the HTTPS transport, and the lacre embedded
5409        // the value verbatim in its per-dep BLAKE3 closure — two
5410        // authors whose values differ only in their fragment anchor
5411        // (`#readme` vs `#L42`) resolve to the byte-identical upstream
5412        // `git clone` but lock to two distinct lacres, defeating the
5413        // THEORY.md §V.2 render-determinism contract. Same value-shape
5414        // axis-floor every peer typed surface enforces; peer `:fonte
5415        // :tag` / `:fonte :branch` already reject the byte-class through
5416        // `is_git_ref_name`'s alphabet (refs are leaf identifiers, no
5417        // URL grammar admitted) and `:entrada :paths` rejects `#` as
5418        // part of `is_gateway_api_http_path`'s RFC-3986-reserved set.
5419        let d = dep_with_fonte(DepSource::Git {
5420            repo: "https://github.com/pleme-io/caixa-teia#readme".into(),
5421            tag: Some("v0.1.0".into()),
5422            rev: None,
5423            branch: None,
5424        });
5425        let err = d.validate().unwrap_err();
5426        let DepError::FonteRepoShape { nome, repo, reason } = err else {
5427            panic!("expected FonteRepoShape, got other variant");
5428        };
5429        assert_eq!(nome, "caixa-teia");
5430        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia#readme");
5431        assert!(
5432            reason.contains("must not contain `#`"),
5433            "reason must surface the fragment-`#` arm, got {reason:?}"
5434        );
5435        assert!(
5436            reason.contains("fragment"),
5437            "reason must name the URL fragment grammar, got {reason:?}"
5438        );
5439    }
5440
5441    #[test]
5442    fn validate_rejects_git_fonte_with_repo_carrying_flake_ref_fragment() {
5443        // The symmetric paste-from-Nix-flake-ref footgun — an author
5444        // confuses the Nix flake-reference idiom (`github:foo/
5445        // bar#packageName`, where `#packageName` selects a flake
5446        // output) with the bare git `:repo` shape. The pleme-io
5447        // substrate authors compose flakes downstream of caixa
5448        // (caixa-flake renders a flake.nix), so the cross-idiom leak
5449        // is the canonical near-miss: the author writes the
5450        // flake-ref shape into a git `:repo` slot. Pinned separately
5451        // from the HTTPS-anchor arm so a future relaxation that
5452        // narrows to one URL scheme surfaces here.
5453        let d = dep_with_fonte(DepSource::Git {
5454            repo: "github:pleme-io/caixa-teia#caixa-teia".into(),
5455            tag: Some("v0.1.0".into()),
5456            rev: None,
5457            branch: None,
5458        });
5459        let err = d.validate().unwrap_err();
5460        let DepError::FonteRepoShape { reason, .. } = err else {
5461            panic!("expected FonteRepoShape, got other variant");
5462        };
5463        assert!(
5464            reason.contains("must not contain `#`"),
5465            "reason must surface the fragment-`#` arm, got {reason:?}"
5466        );
5467        assert!(
5468            reason.contains("Nix flake"),
5469            "reason must name the Nix-flake-ref cross-idiom footgun, got {reason:?}"
5470        );
5471    }
5472
5473    #[test]
5474    fn validate_rejects_git_fonte_with_repo_carrying_query_string() {
5475        // The fail-before-pass-after pin for the canonical paste-from-
5476        // browser-address-bar footgun on `:repo` (peer with the
5477        // a68f818 fragment-`#` arm on the same axis). An author
5478        // copies a GitHub tab deep-link out of the address bar and
5479        // forgets to trim the `?tab=…` query tail. Until this arm
5480        // landed `:repo "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file"`
5481        // silently passed every prior arm (no whitespace, no control
5482        // chars, no non-ASCII, no `#` fragment, contains a `:`,
5483        // doesn't start with `-` or `:`); GitHub silently ignored
5484        // the `?query` tail and served the same repo regardless;
5485        // the lacre embedded the value verbatim in its per-dep
5486        // BLAKE3 closure — two authors whose values differ only in
5487        // their query tail (`?tab=readme-ov-file` vs `?ref=main` vs
5488        // `?utm_source=twitter`) resolve to the byte-identical
5489        // upstream `git clone` but lock to two distinct lacres,
5490        // defeating the THEORY.md §V.2 render-determinism contract
5491        // on the same axis the `#` fragment arm closes. Same value-
5492        // shape axis-floor every peer typed surface enforces; peer
5493        // `:fonte :tag` / `:fonte :branch` already reject the byte-
5494        // class through `is_git_ref_name`'s alphabet (refspec glob
5495        // wildcards, caixa-core/src/render.rs:1426) and `:entrada
5496        // :paths` rejects `?` as the query separator in
5497        // `is_gateway_api_http_path` (caixa-core/src/render.rs:473).
5498        let d = dep_with_fonte(DepSource::Git {
5499            repo: "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file".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 { nome, repo, reason } = err else {
5506            panic!("expected FonteRepoShape, got other variant");
5507        };
5508        assert_eq!(nome, "caixa-teia");
5509        assert_eq!(
5510            repo,
5511            "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file"
5512        );
5513        assert!(
5514            reason.contains("must not contain `?`"),
5515            "reason must surface the query-`?` arm, got {reason:?}"
5516        );
5517        assert!(
5518            reason.contains("query"),
5519            "reason must name the URL query grammar, got {reason:?}"
5520        );
5521    }
5522
5523    #[test]
5524    fn validate_rejects_git_fonte_with_repo_carrying_utm_tracker() {
5525        // The symmetric paste-from-social-share footgun — an author
5526        // copies a repo URL out of a Slack unfurl / Twitter share /
5527        // newsletter link / Discord embed and forgets to trim the
5528        // `?utm_source=…` / `?utm_medium=…` / `?utm_campaign=…`
5529        // campaign-tracker tail. Every major social-share / unfurl /
5530        // newsletter platform appends these UTM parameters; the
5531        // canonical near-miss on the `:repo` axis. Pinned separately
5532        // from the GitHub-tab-deep-link arm so a future relaxation
5533        // that narrows to one query-parameter class surfaces here.
5534        let d = dep_with_fonte(DepSource::Git {
5535            repo: "https://github.com/pleme-io/caixa-teia?utm_source=twitter&utm_campaign=launch"
5536                .into(),
5537            tag: Some("v0.1.0".into()),
5538            rev: None,
5539            branch: None,
5540        });
5541        let err = d.validate().unwrap_err();
5542        let DepError::FonteRepoShape { reason, .. } = err else {
5543            panic!("expected FonteRepoShape, got other variant");
5544        };
5545        assert!(
5546            reason.contains("must not contain `?`"),
5547            "reason must surface the query-`?` arm, got {reason:?}"
5548        );
5549        assert!(
5550            reason.contains("campaign-tracker"),
5551            "reason must name the campaign-tracker paste footgun, got {reason:?}"
5552        );
5553    }
5554
5555    #[test]
5556    fn fonte_repo_fragment_fires_before_query_when_fragment_first() {
5557        // Cascade pin: the fragment-`#` arm and the query-`?` arm are
5558        // both per-byte arms inside the same `for &b in s.as_bytes()`
5559        // loop, so the byte that appears first in the value's byte
5560        // order wins. A `:repo "https://github.com/p/x#readme?ref=main"`
5561        // (fragment before query — unusual URL-grammar but value-
5562        // disjoint at byte level) carries both `#` and `?`; the `#`
5563        // byte appears first, so the fragment-`#` arm fires, surfacing
5564        // the more self-locating diagnostic on the byte the author
5565        // pasted earliest in the URL. Mirrors the peer cascade
5566        // discipline `fonte_repo_control_char_fires_before_fragment`
5567        // pins on the prior `:repo` byte-class arm.
5568        let d = dep_with_fonte(DepSource::Git {
5569            repo: "https://github.com/pleme-io/caixa-teia#readme?ref=main".into(),
5570            tag: Some("v0.1.0".into()),
5571            rev: None,
5572            branch: None,
5573        });
5574        let err = d.validate().unwrap_err();
5575        let DepError::FonteRepoShape { reason, .. } = err else {
5576            panic!("expected FonteRepoShape, got other variant");
5577        };
5578        assert!(
5579            reason.contains("must not contain `#`"),
5580            "reason must surface the fragment-`#` arm (fires before query-`?` when \
5581             `#` byte appears first in value), got {reason:?}"
5582        );
5583    }
5584
5585    #[test]
5586    fn fonte_repo_control_char_fires_before_fragment() {
5587        // Cascade pin: the control-char arm structurally precedes the
5588        // fragment-`#` arm. A value like `"github:p/x\n#readme"` probes
5589        // positive on both arms (contains LF and `#`), but the narrower
5590        // POSIX-syscall-rejected / CRLF-injection-class diagnostic
5591        // (`control character`) wins so the author sees the more
5592        // self-locating arm first. Mirrors the peer cascade discipline
5593        // every prior `:repo` byte-class arm establishes.
5594        let d = dep_with_fonte(DepSource::Git {
5595            repo: "github:pleme-io/caixa-teia\n#readme".into(),
5596            tag: Some("v0.1.0".into()),
5597            rev: None,
5598            branch: None,
5599        });
5600        let err = d.validate().unwrap_err();
5601        let DepError::FonteRepoShape { reason, .. } = err else {
5602            panic!("expected FonteRepoShape, got other variant");
5603        };
5604        assert!(
5605            reason.contains("control character"),
5606            "reason must surface the control-char arm, got {reason:?}"
5607        );
5608    }
5609
5610    #[test]
5611    fn validate_rejects_git_fonte_with_repo_carrying_embedded_backslash() {
5612        // The fail-before-pass-after pin for the canonical Windows-
5613        // file-path-confusion footgun on `:repo` (peer with the 3a4e1d7
5614        // backslash arm on the sibling `:caminho` path-fonte axis).
5615        // An author pastes a Windows Explorer address-bar / PowerShell
5616        // `Get-Location` output into a `file://` URL slot, producing
5617        // `file:///C:\Users\me\caixa-teia`. Until this arm landed the
5618        // value silently passed every prior arm (no whitespace, no
5619        // control chars, no non-ASCII, no `#`, no `?`, doesn't start
5620        // with `-` or `:`); libcurl's URL parser silently translates
5621        // `\` → `/` on some platforms and refuses it on others, so
5622        // the byte rides verbatim into the lacre's per-dep content-
5623        // address but is silently rewritten / rejected at the wire —
5624        // two authors whose `:repo` values differ only in backslash-
5625        // vs-forward-slash (`file:///C:\path` vs `file:///C:/path`)
5626        // resolve to the byte-identical local clone but lock to two
5627        // distinct BLAKE3 closures, defeating the THEORY.md §V.2
5628        // render-determinism contract on the same axis the `#`
5629        // fragment and `?` query arms close. Same value-shape axis-
5630        // floor every peer typed surface enforces; the `:caminho`
5631        // 3a4e1d7 arm closes the same byte on the path-fonte axis.
5632        let d = dep_with_fonte(DepSource::Git {
5633            repo: "file:///C:\\Users\\me\\caixa-teia".into(),
5634            tag: Some("v0.1.0".into()),
5635            rev: None,
5636            branch: None,
5637        });
5638        let err = d.validate().unwrap_err();
5639        let DepError::FonteRepoShape { nome, repo, reason } = err else {
5640            panic!("expected FonteRepoShape, got other variant");
5641        };
5642        assert_eq!(nome, "caixa-teia");
5643        assert_eq!(repo, "file:///C:\\Users\\me\\caixa-teia");
5644        assert!(
5645            reason.contains("must not contain `\\`"),
5646            "reason must surface the backslash-`\\` arm, got {reason:?}"
5647        );
5648        assert!(
5649            reason.contains("Windows"),
5650            "reason must name the Windows-path-confusion footgun, got {reason:?}"
5651        );
5652    }
5653
5654    #[test]
5655    fn validate_rejects_git_fonte_with_repo_carrying_mangled_https_backslashes() {
5656        // The symmetric Win32-shell-mangled-slashes footgun — an author
5657        // copies `https://github.com/foo/bar` into a Win32 shell that
5658        // rewrites every `/` to `\` (the canonical `cmd.exe` path-
5659        // separator-coercion bug), pastes the result into a `:repo`
5660        // slot, and produces `https:\\github.com\foo\bar`. Pinned
5661        // separately from the `file://` Explorer-paste arm so a future
5662        // relaxation that narrows to one URL scheme surfaces here.
5663        let d = dep_with_fonte(DepSource::Git {
5664            repo: "https:\\\\github.com\\pleme-io\\caixa-teia".into(),
5665            tag: Some("v0.1.0".into()),
5666            rev: None,
5667            branch: None,
5668        });
5669        let err = d.validate().unwrap_err();
5670        let DepError::FonteRepoShape { reason, .. } = err else {
5671            panic!("expected FonteRepoShape, got other variant");
5672        };
5673        assert!(
5674            reason.contains("must not contain `\\`"),
5675            "reason must surface the backslash-`\\` arm, got {reason:?}"
5676        );
5677        assert!(
5678            reason.contains("path separator") || reason.contains("path-segment separator"),
5679            "reason must name the URL path-segment separator grammar, got {reason:?}"
5680        );
5681    }
5682
5683    #[test]
5684    fn fonte_repo_fragment_fires_before_backslash_when_fragment_first() {
5685        // Cascade pin: the fragment-`#` arm and the backslash-`\` arm
5686        // are both per-byte arms inside the same `for &b in s.as_bytes()`
5687        // loop, so the byte that appears first in the value's byte order
5688        // wins. A `:repo "https://github.com/p/x#readme\\foo"` carries
5689        // both `#` and `\`; the `#` byte appears first, so the fragment-
5690        // `#` arm fires, surfacing the more self-locating diagnostic on
5691        // the byte the author pasted earliest in the URL. Mirrors the
5692        // peer cascade discipline `fonte_repo_fragment_fires_before_query_when_fragment_first`
5693        // pins on the prior `:repo` byte-class arm.
5694        let d = dep_with_fonte(DepSource::Git {
5695            repo: "https://github.com/pleme-io/caixa-teia#readme\\foo".into(),
5696            tag: Some("v0.1.0".into()),
5697            rev: None,
5698            branch: None,
5699        });
5700        let err = d.validate().unwrap_err();
5701        let DepError::FonteRepoShape { reason, .. } = err else {
5702            panic!("expected FonteRepoShape, got other variant");
5703        };
5704        assert!(
5705            reason.contains("must not contain `#`"),
5706            "reason must surface the fragment-`#` arm (fires before backslash-`\\` when \
5707             `#` byte appears first in value), got {reason:?}"
5708        );
5709    }
5710
5711    #[test]
5712    fn validate_rejects_git_fonte_with_repo_carrying_uri_template_placeholder() {
5713        // The fail-before-pass-after pin for the canonical URI Template
5714        // (RFC 6570) placeholder footgun on `:repo`. An author copies a
5715        // README quick-start snippet / OpenAPI `servers:` URL / Helm
5716        // chart `home:` template that carries unresolved
5717        // `{org}` / `{repo}` placeholders and pastes the raw template
5718        // into the `:repo` slot, expecting the substrate to resolve the
5719        // placeholder downstream. Until this arm landed the value
5720        // silently passed every prior arm (no whitespace, no control
5721        // chars, no non-ASCII, no `#`, no `?`, no `\`, doesn't start
5722        // with `-` or `:`); libcurl percent-encodes `{` / `}` to `%7B`
5723        // / `%7D` on the wire, so the byte rides verbatim into the
5724        // lacre's per-dep content-address but round-trips inconsistently
5725        // between the lacre's per-dep content-address and the
5726        // resolver's `git clone <repo>` invocation, defeating the
5727        // THEORY.md §V.2 render-determinism contract on the same axis
5728        // the `#` fragment, `?` query, and `\` backslash arms close;
5729        // every git porcelain entry-point additionally fetches a
5730        // nonexistent literal-`{placeholder}`-named path far from the
5731        // source caixa.lisp.
5732        let d = dep_with_fonte(DepSource::Git {
5733            repo: "https://github.com/{org}/caixa-teia".into(),
5734            tag: Some("v0.1.0".into()),
5735            rev: None,
5736            branch: None,
5737        });
5738        let err = d.validate().unwrap_err();
5739        let DepError::FonteRepoShape { nome, repo, reason } = err else {
5740            panic!("expected FonteRepoShape, got other variant");
5741        };
5742        assert_eq!(nome, "caixa-teia");
5743        assert_eq!(repo, "https://github.com/{org}/caixa-teia");
5744        assert!(
5745            reason.contains("must not contain `{`"),
5746            "reason must surface the open-brace `{{` arm, got {reason:?}"
5747        );
5748        assert!(
5749            reason.contains("URI Template") || reason.contains("RFC 6570"),
5750            "reason must name the RFC 6570 URI Template grammar, got {reason:?}"
5751        );
5752    }
5753
5754    #[test]
5755    fn validate_rejects_git_fonte_with_repo_carrying_handlebars_doubled_brace() {
5756        // The symmetric Mustache / Handlebars doubled-brace
5757        // substitution-form footgun every CI / IaC templating engine
5758        // (Argo Workflows, Jinja2, Liquid, Vue / Angular interpolation,
5759        // GitHub Actions `${{ … }}` even though Actions uses `${{`) /
5760        // chart README quick-start snippet emits. Pinned separately
5761        // from the single-`{` `{org}` arm so a future relaxation that
5762        // narrows to one substitution-form surfaces here.
5763        let d = dep_with_fonte(DepSource::Git {
5764            repo: "https://github.com/{{org}}/caixa-teia".into(),
5765            tag: Some("v0.1.0".into()),
5766            rev: None,
5767            branch: None,
5768        });
5769        let err = d.validate().unwrap_err();
5770        let DepError::FonteRepoShape { reason, .. } = err else {
5771            panic!("expected FonteRepoShape, got other variant");
5772        };
5773        assert!(
5774            reason.contains("must not contain `{`"),
5775            "reason must surface the open-brace `{{` arm, got {reason:?}"
5776        );
5777    }
5778
5779    #[test]
5780    fn validate_rejects_git_fonte_with_repo_carrying_closing_brace_only() {
5781        // Asymmetric `}`-only shape — covers the closing-brace-by-
5782        // itself footgun (an author truncated `{org}/{repo}` mid-edit
5783        // and left a trailing `}` from the prior template fragment,
5784        // or pasted a value that included a closing brace from a
5785        // surrounding shell context). Pinned to ensure the predicate
5786        // refuses each brace independently rather than only when both
5787        // appear — a future regression that ANDs the two byte tests
5788        // surfaces here.
5789        let d = dep_with_fonte(DepSource::Git {
5790            repo: "https://github.com/pleme-io/caixa-teia}".into(),
5791            tag: Some("v0.1.0".into()),
5792            rev: None,
5793            branch: None,
5794        });
5795        let err = d.validate().unwrap_err();
5796        let DepError::FonteRepoShape { reason, .. } = err else {
5797            panic!("expected FonteRepoShape, got other variant");
5798        };
5799        assert!(
5800            reason.contains("must not contain `}`"),
5801            "reason must surface the close-brace `}}` arm, got {reason:?}"
5802        );
5803    }
5804
5805    #[test]
5806    fn fonte_repo_fragment_fires_before_template_placeholder_when_fragment_first() {
5807        // Cascade pin: the fragment-`#` arm and the template-`{` /
5808        // `}` arm are both per-byte arms inside the same
5809        // `for &b in s.as_bytes()` loop, so the byte that appears
5810        // first in the value's byte order wins. A `:repo
5811        // "https://github.com/p/x#readme{org}"` carries both `#` and
5812        // `{`; the `#` byte appears first, so the fragment-`#` arm
5813        // fires, surfacing the more self-locating diagnostic on the
5814        // byte the author pasted earliest in the URL. Mirrors the
5815        // peer cascade discipline `fonte_repo_fragment_fires_before_backslash_when_fragment_first`
5816        // pins on the prior `:repo` byte-class arm.
5817        let d = dep_with_fonte(DepSource::Git {
5818            repo: "https://github.com/pleme-io/caixa-teia#readme{org}".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 fragment-`#` arm (fires before template-`{{` when \
5830             `#` byte appears first in value), got {reason:?}"
5831        );
5832    }
5833
5834    #[test]
5835    fn validate_rejects_git_fonte_with_repo_carrying_output_redirection() {
5836        // The fail-before-pass-after pin for the canonical
5837        // shell-output-redirection footgun on `:repo`: an author
5838        // pastes a shell-pipeline tail (`git clone <repo> > build.log`
5839        // / `… >output.txt`) into the `:repo` slot without trimming
5840        // the redirect. Until this arm landed the value silently
5841        // passed every prior arm (no whitespace, no control chars,
5842        // no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, doesn't
5843        // start with `-` or `:`); RFC 3986 §2 lists `<` / `>` in the
5844        // 'delims' / 'unwise' set and the WHATWG URL spec's fragment
5845        // percent-encode set maps `>` → `%3E` on the wire, so the
5846        // byte rides verbatim into the lacre's per-dep BLAKE3 closure
5847        // but is silently rewritten or rejected at libcurl's URL-
5848        // parser layer — two authors whose values differ only in
5849        // their redirect tail (`>build.log` vs nothing) resolve to
5850        // the byte-identical upstream `git clone` but lock to two
5851        // distinct lacres, defeating the THEORY.md §V.2 render-
5852        // determinism contract. Peer with the `:caminho` axis's
5853        // `FonteCaminhoShellRedirection` arm (e457141) on the sibling
5854        // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
5855        // byte RFC-3986-reserved set on `:entrada :paths`.
5856        let d = dep_with_fonte(DepSource::Git {
5857            repo: "https://github.com/pleme-io/caixa-teia>build.log".into(),
5858            tag: Some("v0.1.0".into()),
5859            rev: None,
5860            branch: None,
5861        });
5862        let err = d.validate().unwrap_err();
5863        let DepError::FonteRepoShape { nome, repo, reason } = err else {
5864            panic!("expected FonteRepoShape, got other variant");
5865        };
5866        assert_eq!(nome, "caixa-teia");
5867        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia>build.log");
5868        assert!(
5869            reason.contains("must not contain `>`"),
5870            "reason must surface the output-redirection `>` arm, got {reason:?}"
5871        );
5872        assert!(
5873            reason.contains("redirection") || reason.contains("'delims'"),
5874            "reason must name the shell-redirection / RFC-3986-unwise rationale, got {reason:?}"
5875        );
5876    }
5877
5878    #[test]
5879    fn validate_rejects_git_fonte_with_repo_carrying_input_redirection() {
5880        // The symmetric shell-input-redirection footgun — an author
5881        // pastes a shell-pipeline head (`git clone <input.url` /
5882        // `cat <README.md`) into the `:repo` slot. Pinned separately
5883        // from the `>`-output arm so a future relaxation that only
5884        // catches one of the two redirect bytes surfaces here. Peer
5885        // with the `:caminho` axis's `FonteCaminhoShellRedirection`
5886        // arm which closes both `<` and `>` under the same banner.
5887        let d = dep_with_fonte(DepSource::Git {
5888            repo: "https://github.com/pleme-io/caixa-teia<input.url".into(),
5889            tag: Some("v0.1.0".into()),
5890            rev: None,
5891            branch: None,
5892        });
5893        let err = d.validate().unwrap_err();
5894        let DepError::FonteRepoShape { reason, .. } = err else {
5895            panic!("expected FonteRepoShape, got other variant");
5896        };
5897        assert!(
5898            reason.contains("must not contain `<`"),
5899            "reason must surface the input-redirection `<` arm, got {reason:?}"
5900        );
5901        assert!(
5902            reason.contains("RFC 3986") || reason.contains("'unwise'"),
5903            "reason must name the RFC 3986 'unwise' grammar, got {reason:?}"
5904        );
5905    }
5906
5907    #[test]
5908    fn validate_rejects_git_fonte_with_repo_carrying_backtick_command_substitution() {
5909        // The fail-before-pass-after pin for the canonical
5910        // paste-from-shell-prompt-with-backticked-substitution footgun
5911        // on `:repo` (peer with the c4d62b3 backtick arm on the sibling
5912        // `:caminho` path-fonte axis). An author pastes a URL whose
5913        // segment carries a backticked command-substitution wrapper
5914        // (`` `whoami` ``, `` `git config user.name` ``, `` `pwd` ``)
5915        // from a doc / README quick-start snippet that expected the
5916        // substrate to substitute the value downstream. Until this arm
5917        // landed the value silently passed every prior arm (no
5918        // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
5919        // no `\`, no `{`/`}`, no `<`/`>`, doesn't start with `-` or
5920        // `:`); RFC 3986 §2 lists the backtick byte in the 'delims' /
5921        // 'unwise' set and the WHATWG URL spec's fragment percent-
5922        // encode set maps `` ` `` → `%60` on the wire, so the byte
5923        // rides verbatim into the lacre's per-dep BLAKE3 closure but
5924        // is silently rewritten or rejected at libcurl's URL-parser
5925        // layer — two authors whose values differ only in their
5926        // backtick wrapper (`` `whoami` `` vs nothing) resolve to the
5927        // byte-identical upstream `git clone` but lock to two distinct
5928        // lacres, defeating the THEORY.md §V.2 render-determinism
5929        // contract. Peer with the `:caminho` axis's
5930        // `FonteCaminhoShellCommandSubstitution` arm (c4d62b3) on the
5931        // sibling path-fonte axis, and `is_gateway_api_http_path`'s
5932        // eleven-byte RFC-3986-reserved set on `:entrada :paths`.
5933        let d = dep_with_fonte(DepSource::Git {
5934            repo: "https://github.com/pleme-io/`whoami`/caixa-teia".into(),
5935            tag: Some("v0.1.0".into()),
5936            rev: None,
5937            branch: None,
5938        });
5939        let err = d.validate().unwrap_err();
5940        let DepError::FonteRepoShape { nome, repo, reason } = err else {
5941            panic!("expected FonteRepoShape, got other variant");
5942        };
5943        assert_eq!(nome, "caixa-teia");
5944        assert_eq!(repo, "https://github.com/pleme-io/`whoami`/caixa-teia");
5945        assert!(
5946            reason.contains("must not contain `` ` ``"),
5947            "reason must surface the backtick command-substitution arm, got {reason:?}"
5948        );
5949        assert!(
5950            reason.contains("command-substitution") || reason.contains("'unwise'"),
5951            "reason must name the shell-command-substitution / RFC-3986-unwise rationale, \
5952             got {reason:?}"
5953        );
5954    }
5955
5956    #[test]
5957    fn fonte_repo_fragment_fires_before_backtick_when_fragment_first() {
5958        // Cascade pin: the fragment-`#` arm and the backtick command-
5959        // substitution arm are both per-byte arms inside the same
5960        // `for &b in s.as_bytes()` loop, so the byte that appears first
5961        // in the value's byte order wins. A `:repo
5962        // "https://github.com/p/x#readme/`whoami`"` carries both `#`
5963        // and backtick; the `#` byte appears first, so the fragment-
5964        // `#` arm fires, surfacing the more self-locating diagnostic
5965        // on the byte the author pasted earliest in the URL. Mirrors
5966        // the peer cascade discipline
5967        // `fonte_repo_fragment_fires_before_shell_redirection_when_fragment_first`
5968        // pins on the prior `:repo` byte-class arm.
5969        let d = dep_with_fonte(DepSource::Git {
5970            repo: "https://github.com/pleme-io/caixa-teia#readme/`whoami`".into(),
5971            tag: Some("v0.1.0".into()),
5972            rev: None,
5973            branch: None,
5974        });
5975        let err = d.validate().unwrap_err();
5976        let DepError::FonteRepoShape { reason, .. } = err else {
5977            panic!("expected FonteRepoShape, got other variant");
5978        };
5979        assert!(
5980            reason.contains("must not contain `#`"),
5981            "reason must surface the fragment-`#` arm (fires before backtick when `#` byte \
5982             appears first in value), got {reason:?}"
5983        );
5984    }
5985
5986    #[test]
5987    fn fonte_repo_shell_redirection_fires_before_backtick_when_redirection_first() {
5988        // Cascade pin: the shell-redirection `<` / `>` arm and the
5989        // backtick command-substitution arm are both per-byte arms
5990        // inside the same `for &b in s.as_bytes()` loop, so the byte
5991        // that appears first in the value's byte order wins. A `:repo
5992        // "https://github.com/p/x>build.log/`whoami`"` carries both
5993        // `>` and backtick; the `>` byte appears first, so the
5994        // shell-redirection arm fires, surfacing the more self-
5995        // locating diagnostic on the byte the author pasted earliest
5996        // in the URL. Pins the natural-order cascade so a future
5997        // reorder of the per-byte arms surfaces here.
5998        let d = dep_with_fonte(DepSource::Git {
5999            repo: "https://github.com/pleme-io/caixa-teia>build.log/`whoami`".into(),
6000            tag: Some("v0.1.0".into()),
6001            rev: None,
6002            branch: None,
6003        });
6004        let err = d.validate().unwrap_err();
6005        let DepError::FonteRepoShape { reason, .. } = err else {
6006            panic!("expected FonteRepoShape, got other variant");
6007        };
6008        assert!(
6009            reason.contains("must not contain `>`"),
6010            "reason must surface the shell-redirection `>` arm (fires before backtick when \
6011             `>` byte appears first in value), got {reason:?}"
6012        );
6013    }
6014
6015    #[test]
6016    fn fonte_repo_fragment_fires_before_shell_redirection_when_fragment_first() {
6017        // Cascade pin: the fragment-`#` arm and the shell-redirection
6018        // `<` / `>` arm are both per-byte arms inside the same
6019        // `for &b in s.as_bytes()` loop, so the byte that appears
6020        // first in the value's byte order wins. A `:repo
6021        // "https://github.com/p/x#readme>build.log"` carries both
6022        // `#` and `>`; the `#` byte appears first, so the fragment-
6023        // `#` arm fires, surfacing the more self-locating diagnostic
6024        // on the byte the author pasted earliest in the URL. Mirrors
6025        // the peer cascade discipline
6026        // `fonte_repo_fragment_fires_before_template_placeholder_when_fragment_first`
6027        // pins on the prior `:repo` byte-class arm.
6028        let d = dep_with_fonte(DepSource::Git {
6029            repo: "https://github.com/pleme-io/caixa-teia#readme>build.log".into(),
6030            tag: Some("v0.1.0".into()),
6031            rev: None,
6032            branch: None,
6033        });
6034        let err = d.validate().unwrap_err();
6035        let DepError::FonteRepoShape { reason, .. } = err else {
6036            panic!("expected FonteRepoShape, got other variant");
6037        };
6038        assert!(
6039            reason.contains("must not contain `#`"),
6040            "reason must surface the fragment-`#` arm (fires before shell-redirection `>` when \
6041             `#` byte appears first in value), got {reason:?}"
6042        );
6043    }
6044
6045    #[test]
6046    fn validate_rejects_git_fonte_with_repo_carrying_shell_pipe() {
6047        // The fail-before-pass-after pin for the canonical
6048        // paste-from-shell-prompt-with-piped-pipeline footgun on
6049        // `:repo` (peer with the 124106f pipe arm on the sibling
6050        // `:caminho` path-fonte axis). An author pastes a shell
6051        // pipeline (`git clone <url> | tee build.log`,
6052        // `git ls-remote <url> | head`) into the `:repo` slot,
6053        // forgetting to trim the `| <consumer>` tail. Until this arm
6054        // landed the value silently passed every prior arm (no
6055        // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
6056        // no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, doesn't start
6057        // with `-` or `:`); RFC 3986 §2 lists the pipe byte in the
6058        // 'unwise' set and the WHATWG URL spec's fragment percent-
6059        // encode set maps `|` → `%7C` on the wire, so the byte rides
6060        // verbatim into the lacre's per-dep BLAKE3 closure but is
6061        // silently rewritten or rejected at libcurl's URL-parser
6062        // layer — two authors whose values differ only in their pipe
6063        // tail (`|tee build.log` vs nothing) resolve to the byte-
6064        // identical upstream `git clone` but lock to two distinct
6065        // lacres, defeating the THEORY.md §V.2 render-determinism
6066        // contract. Peer with the `:caminho` axis's
6067        // `FonteCaminhoShellPipe` arm (124106f) on the sibling path-
6068        // fonte axis, and `is_gateway_api_http_path`'s eleven-byte
6069        // RFC-3986-reserved set on `:entrada :paths`.
6070        let d = dep_with_fonte(DepSource::Git {
6071            repo: "https://github.com/pleme-io/caixa-teia|tee build.log".into(),
6072            tag: Some("v0.1.0".into()),
6073            rev: None,
6074            branch: None,
6075        });
6076        let err = d.validate().unwrap_err();
6077        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6078            panic!("expected FonteRepoShape, got other variant");
6079        };
6080        assert_eq!(nome, "caixa-teia");
6081        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia|tee build.log");
6082        assert!(
6083            reason.contains("must not contain `|`"),
6084            "reason must surface the shell-pipe arm, got {reason:?}"
6085        );
6086        assert!(
6087            reason.contains("pipe") || reason.contains("'unwise'"),
6088            "reason must name the shell-pipe / RFC-3986-unwise rationale, got {reason:?}"
6089        );
6090    }
6091
6092    #[test]
6093    fn fonte_repo_fragment_fires_before_pipe_when_fragment_first() {
6094        // Cascade pin: the fragment-`#` arm and the pipe arm are both
6095        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
6096        // so the byte that appears first in the value's byte order
6097        // wins. A `:repo "https://github.com/p/x#readme|tee"` carries
6098        // both `#` and `|`; the `#` byte appears first, so the
6099        // fragment-`#` arm fires, surfacing the more self-locating
6100        // diagnostic on the byte the author pasted earliest in the
6101        // URL. Mirrors the peer cascade discipline
6102        // `fonte_repo_fragment_fires_before_backtick_when_fragment_first`
6103        // pins on the prior `:repo` byte-class arm.
6104        let d = dep_with_fonte(DepSource::Git {
6105            repo: "https://github.com/pleme-io/caixa-teia#readme|tee".into(),
6106            tag: Some("v0.1.0".into()),
6107            rev: None,
6108            branch: None,
6109        });
6110        let err = d.validate().unwrap_err();
6111        let DepError::FonteRepoShape { reason, .. } = err else {
6112            panic!("expected FonteRepoShape, got other variant");
6113        };
6114        assert!(
6115            reason.contains("must not contain `#`"),
6116            "reason must surface the fragment-`#` arm (fires before pipe when `#` byte \
6117             appears first in value), got {reason:?}"
6118        );
6119    }
6120
6121    #[test]
6122    fn fonte_repo_backtick_fires_before_pipe_when_backtick_first() {
6123        // Cascade pin: the backtick arm and the pipe arm are both per-
6124        // byte arms inside the same `for &b in s.as_bytes()` loop, so
6125        // the byte that appears first in the value's byte order wins.
6126        // A `:repo "https://github.com/p/x/`whoami`|tee"` carries both
6127        // `` ` `` and `|`; the backtick byte appears first, so the
6128        // backtick arm fires, surfacing the more self-locating
6129        // diagnostic on the byte the author pasted earliest in the
6130        // URL. Pins the natural-order cascade so a future reorder of
6131        // the per-byte arms surfaces here.
6132        let d = dep_with_fonte(DepSource::Git {
6133            repo: "https://github.com/pleme-io/caixa-teia/`whoami`|tee".into(),
6134            tag: Some("v0.1.0".into()),
6135            rev: None,
6136            branch: None,
6137        });
6138        let err = d.validate().unwrap_err();
6139        let DepError::FonteRepoShape { reason, .. } = err else {
6140            panic!("expected FonteRepoShape, got other variant");
6141        };
6142        assert!(
6143            reason.contains("must not contain `` ` ``"),
6144            "reason must surface the backtick arm (fires before pipe when `` ` `` byte \
6145             appears first in value), got {reason:?}"
6146        );
6147    }
6148
6149    #[test]
6150    fn validate_rejects_git_fonte_with_repo_carrying_shell_command_separator() {
6151        // The fail-before-pass-after pin for the canonical
6152        // paste-from-shell-prompt-with-sequential-command-tail footgun
6153        // on `:repo` (peer with the 05c358e `;` arm on the sibling
6154        // `:caminho` path-fonte axis). An author pastes a shell
6155        // one-liner that chained a cleanup tail after the URL
6156        // (`git clone <url>; rm -rf build`, `git ls-remote <url>;
6157        // echo done`) into the `:repo` slot, forgetting to trim the
6158        // `; <cmd>` tail. Until this arm landed the value silently
6159        // passed every prior `is_git_repo_url` arm (no whitespace, no
6160        // control chars, no non-ASCII, no `#`, no `?`, no `\`, no
6161        // `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, doesn't start with
6162        // `-` or `:`); RFC 3986 §2 lists `;` in the 'sub-delims' /
6163        // reserved set and the WHATWG URL spec's fragment percent-
6164        // encode set maps `;` → `%3B` on the wire, so the byte rides
6165        // verbatim into the lacre's per-dep BLAKE3 closure but is
6166        // silently rewritten at libcurl's URL-parser layer — two
6167        // authors whose values differ only in their sequential-command
6168        // tail (`; rm -rf build` vs nothing) resolve to the byte-
6169        // identical upstream `git clone` but lock to two distinct
6170        // lacres, defeating the THEORY.md §V.2 render-determinism
6171        // contract. Peer with the `:caminho` axis's
6172        // `FonteCaminhoShellSemicolon` arm (05c358e) on the sibling
6173        // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
6174        // byte RFC-3986-reserved set on `:entrada :paths`.
6175        let d = dep_with_fonte(DepSource::Git {
6176            repo: "https://github.com/pleme-io/caixa-teia; rm -rf build".into(),
6177            tag: Some("v0.1.0".into()),
6178            rev: None,
6179            branch: None,
6180        });
6181        let err = d.validate().unwrap_err();
6182        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6183            panic!("expected FonteRepoShape, got other variant");
6184        };
6185        assert_eq!(nome, "caixa-teia");
6186        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia; rm -rf build");
6187        assert!(
6188            reason.contains("must not contain `;`"),
6189            "reason must surface the shell-command-separator arm, got {reason:?}"
6190        );
6191        assert!(
6192            reason.contains("sequential-command") || reason.contains("'sub-delims'"),
6193            "reason must name the shell-command-separator / RFC-3986-sub-delims \
6194             rationale, got {reason:?}"
6195        );
6196    }
6197
6198    #[test]
6199    fn fonte_repo_fragment_fires_before_semicolon_when_fragment_first() {
6200        // Cascade pin: the fragment-`#` arm and the semicolon arm are
6201        // both per-byte arms inside the same `for &b in s.as_bytes()`
6202        // loop, so the byte that appears first in the value's byte
6203        // order wins. A `:repo "https://github.com/p/x#readme; rm"`
6204        // carries both `#` and `;`; the `#` byte appears first, so the
6205        // fragment-`#` arm fires, surfacing the more self-locating
6206        // diagnostic on the byte the author pasted earliest in the URL.
6207        // Mirrors the peer cascade discipline
6208        // `fonte_repo_fragment_fires_before_pipe_when_fragment_first`
6209        // pins on the prior `:repo` byte-class arm.
6210        let d = dep_with_fonte(DepSource::Git {
6211            repo: "https://github.com/pleme-io/caixa-teia#readme; rm".into(),
6212            tag: Some("v0.1.0".into()),
6213            rev: None,
6214            branch: None,
6215        });
6216        let err = d.validate().unwrap_err();
6217        let DepError::FonteRepoShape { reason, .. } = err else {
6218            panic!("expected FonteRepoShape, got other variant");
6219        };
6220        assert!(
6221            reason.contains("must not contain `#`"),
6222            "reason must surface the fragment-`#` arm (fires before semicolon when `#` \
6223             byte appears first in value), got {reason:?}"
6224        );
6225    }
6226
6227    #[test]
6228    fn fonte_repo_pipe_fires_before_semicolon_when_pipe_first() {
6229        // Cascade pin: the pipe arm and the semicolon arm are both
6230        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
6231        // so the byte that appears first in the value's byte order
6232        // wins. A `:repo "https://github.com/p/x|tee; rm"` carries
6233        // both `|` and `;`; the `|` byte appears first, so the
6234        // pipe arm fires, surfacing the more self-locating diagnostic
6235        // on the byte the author pasted earliest in the URL. Pins the
6236        // natural-order cascade so a future reorder of the per-byte
6237        // arms surfaces here.
6238        let d = dep_with_fonte(DepSource::Git {
6239            repo: "https://github.com/pleme-io/caixa-teia|tee; rm".into(),
6240            tag: Some("v0.1.0".into()),
6241            rev: None,
6242            branch: None,
6243        });
6244        let err = d.validate().unwrap_err();
6245        let DepError::FonteRepoShape { reason, .. } = err else {
6246            panic!("expected FonteRepoShape, got other variant");
6247        };
6248        assert!(
6249            reason.contains("must not contain `|`"),
6250            "reason must surface the pipe arm (fires before semicolon when `|` byte \
6251             appears first in value), got {reason:?}"
6252        );
6253    }
6254
6255    #[test]
6256    fn validate_rejects_git_fonte_with_repo_carrying_shell_background() {
6257        // The fail-before-pass-after pin for the canonical
6258        // paste-from-shell-prompt-with-background-launch-tail footgun
6259        // on `:repo` (peer with the e12e4f3 `&` arm on the sibling
6260        // `:caminho` path-fonte axis). An author pastes a shell one-
6261        // liner that detached the clone into the background
6262        // (`git clone <url> & sleep 1`, `git clone <url> && cd …`)
6263        // into the `:repo` slot, forgetting to trim the `& <cmd>` /
6264        // `&& <cmd>` tail. Until this arm landed the value silently
6265        // passed every prior `is_git_repo_url` arm (no whitespace,
6266        // no control chars, no non-ASCII, no `#`, no `?`, no `\`,
6267        // no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no `;`,
6268        // doesn't start with `-` or `:`); RFC 3986 §2 lists `&` in
6269        // the 'sub-delims' / reserved set and the WHATWG URL spec's
6270        // fragment percent-encode set maps `&` → `%26` on the wire,
6271        // so the byte rides verbatim into the lacre's per-dep
6272        // BLAKE3 closure but is silently rewritten at libcurl's
6273        // URL-parser layer — two authors whose values differ only
6274        // in their background-launch tail (`& sleep 1` vs nothing)
6275        // resolve to the byte-identical upstream `git clone` but
6276        // lock to two distinct lacres, defeating the THEORY.md
6277        // §V.2 render-determinism contract. Peer with the
6278        // `:caminho` axis's `FonteCaminhoShellBackground` arm
6279        // (e12e4f3) on the sibling path-fonte axis, and
6280        // `is_gateway_api_http_path`'s eleven-byte RFC-3986-
6281        // reserved set on `:entrada :paths`.
6282        let d = dep_with_fonte(DepSource::Git {
6283            repo: "https://github.com/pleme-io/caixa-teia&sleep".into(),
6284            tag: Some("v0.1.0".into()),
6285            rev: None,
6286            branch: None,
6287        });
6288        let err = d.validate().unwrap_err();
6289        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6290            panic!("expected FonteRepoShape, got other variant");
6291        };
6292        assert_eq!(nome, "caixa-teia");
6293        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia&sleep");
6294        assert!(
6295            reason.contains("must not contain `&`"),
6296            "reason must surface the shell-background / logical-AND arm, got {reason:?}"
6297        );
6298        assert!(
6299            reason.contains("background-task") || reason.contains("'sub-delims'"),
6300            "reason must name the shell-background / RFC-3986-sub-delims rationale, \
6301             got {reason:?}"
6302        );
6303    }
6304
6305    #[test]
6306    fn validate_rejects_git_fonte_with_repo_carrying_logical_and() {
6307        // The fail-before-pass-after pin for the symmetric `&&`
6308        // logical-AND build-chain paste footgun: an author pastes
6309        // a `git clone <url> && cd <repo>` build-chain one-liner
6310        // and forgets to trim the `&& <cmd>` tail. The `&&` shape
6311        // is the same `&` byte twice in a row; the per-byte arm
6312        // fires on the first `&` it sees. Pinned separately from
6313        // the single-`&` background-launch shape so a future
6314        // diagnostic-surface change that special-cased the
6315        // doubled-byte form surfaces here.
6316        let d = dep_with_fonte(DepSource::Git {
6317            repo: "github:pleme-io/caixa-teia&&echo".into(),
6318            tag: Some("v0.1.0".into()),
6319            rev: None,
6320            branch: None,
6321        });
6322        let err = d.validate().unwrap_err();
6323        let DepError::FonteRepoShape { reason, .. } = err else {
6324            panic!("expected FonteRepoShape, got other variant");
6325        };
6326        assert!(
6327            reason.contains("must not contain `&`"),
6328            "reason must surface the shell-background / logical-AND arm on the doubled-`&&` \
6329             shape too, got {reason:?}"
6330        );
6331    }
6332
6333    #[test]
6334    fn fonte_repo_fragment_fires_before_background_when_fragment_first() {
6335        // Cascade pin: the fragment-`#` arm and the background-`&`
6336        // arm are both per-byte arms inside the same `for &b in
6337        // s.as_bytes()` loop, so the byte that appears first in the
6338        // value's byte order wins. A `:repo
6339        // "https://github.com/p/x#readme & sleep"` carries both `#`
6340        // and `&`; the `#` byte appears first, so the fragment-`#`
6341        // arm fires, surfacing the more self-locating diagnostic on
6342        // the byte the author pasted earliest in the URL. Mirrors
6343        // the peer cascade discipline
6344        // `fonte_repo_fragment_fires_before_semicolon_when_fragment_first`
6345        // on the prior `:repo` byte-class arm.
6346        let d = dep_with_fonte(DepSource::Git {
6347            repo: "https://github.com/pleme-io/caixa-teia#readme&sleep".into(),
6348            tag: Some("v0.1.0".into()),
6349            rev: None,
6350            branch: None,
6351        });
6352        let err = d.validate().unwrap_err();
6353        let DepError::FonteRepoShape { reason, .. } = err else {
6354            panic!("expected FonteRepoShape, got other variant");
6355        };
6356        assert!(
6357            reason.contains("must not contain `#`"),
6358            "reason must surface the fragment-`#` arm (fires before background-`&` when `#` \
6359             byte appears first in value), got {reason:?}"
6360        );
6361    }
6362
6363    #[test]
6364    fn fonte_repo_semicolon_fires_before_background_when_semicolon_first() {
6365        // Cascade pin: the semicolon arm and the background-`&` arm
6366        // are both per-byte arms inside the same `for &b in
6367        // s.as_bytes()` loop, so the byte that appears first in the
6368        // value's byte order wins. A `:repo
6369        // "https://github.com/p/x; rm & sleep"` carries both `;` and
6370        // `&`; the `;` byte appears first, so the semicolon arm
6371        // fires, surfacing the more self-locating diagnostic on the
6372        // byte the author pasted earliest in the URL. Pins the
6373        // natural-order cascade so a future reorder of the per-byte
6374        // arms surfaces here.
6375        let d = dep_with_fonte(DepSource::Git {
6376            repo: "https://github.com/pleme-io/caixa-teia;rm&sleep".into(),
6377            tag: Some("v0.1.0".into()),
6378            rev: None,
6379            branch: None,
6380        });
6381        let err = d.validate().unwrap_err();
6382        let DepError::FonteRepoShape { reason, .. } = err else {
6383            panic!("expected FonteRepoShape, got other variant");
6384        };
6385        assert!(
6386            reason.contains("must not contain `;`"),
6387            "reason must surface the semicolon arm (fires before background-`&` when `;` \
6388             byte appears first in value), got {reason:?}"
6389        );
6390    }
6391
6392    #[test]
6393    fn validate_rejects_git_fonte_with_repo_carrying_shell_variable_expansion() {
6394        // The fail-before-pass-after pin for the canonical
6395        // paste-from-shell-prompt-with-unsubstituted-variable footgun
6396        // on `:repo` (peer with the f4efe9c `$` arm on the sibling
6397        // `:caminho` path-fonte axis). An author pastes a shell one-
6398        // liner that referenced an environment variable
6399        // (`git clone https://github.com/$ORG/x`, `git clone
6400        // github:$USER/repo`) into the `:repo` slot, forgetting to
6401        // substitute the literal value at author time. Until this arm
6402        // landed the value silently passed every prior
6403        // `is_git_repo_url` arm (no whitespace, no control chars, no
6404        // non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no `<`/`>`,
6405        // no `` ` ``, no `|`, no `;`, no `&`, doesn't start with `-`
6406        // or `:`); RFC 3986 §2 lists `$` in the 'sub-delims' /
6407        // reserved set and the WHATWG URL spec's fragment percent-
6408        // encode set maps `$` → `%24` on the wire, so the byte rides
6409        // verbatim into the lacre's per-dep BLAKE3 closure but is
6410        // silently rewritten at libcurl's URL-parser layer — two
6411        // authors whose values differ only in their `$VAR` /
6412        // `${VAR}` / `$(cmd)` expansion tail resolve to the byte-
6413        // identical upstream `git clone` but lock to two distinct
6414        // lacres, defeating the THEORY.md §V.2 render-determinism
6415        // contract. Beyond determinism, the value is a structural
6416        // host-layout leak: two authors with the same `:repo` slot
6417        // but different `$ORG` / `$HOME` / `$WORKSPACE` resolve
6418        // different upstreams. Peer with the `:caminho` axis's
6419        // `FonteCaminhoVarExpansion` arm (f4efe9c) on the sibling
6420        // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
6421        // byte RFC-3986-reserved set on `:entrada :paths`.
6422        let d = dep_with_fonte(DepSource::Git {
6423            repo: "https://github.com/$ORG/caixa-teia".into(),
6424            tag: Some("v0.1.0".into()),
6425            rev: None,
6426            branch: None,
6427        });
6428        let err = d.validate().unwrap_err();
6429        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6430            panic!("expected FonteRepoShape, got other variant");
6431        };
6432        assert_eq!(nome, "caixa-teia");
6433        assert_eq!(repo, "https://github.com/$ORG/caixa-teia");
6434        assert!(
6435            reason.contains("must not contain `$`"),
6436            "reason must surface the shell-variable-expansion arm, got {reason:?}"
6437        );
6438        assert!(
6439            reason.contains("variable-expansion") || reason.contains("'sub-delims'"),
6440            "reason must name the shell-variable-expansion / RFC-3986-sub-delims \
6441             rationale, got {reason:?}"
6442        );
6443    }
6444
6445    #[test]
6446    fn validate_rejects_git_fonte_with_repo_carrying_braced_variable_expansion() {
6447        // The fail-before-pass-after pin for the symmetric POSIX-
6448        // shell braced `${VAR}` expansion paste footgun: an author
6449        // pastes a CI-manifest line `git clone
6450        // https://github.com/${WORKSPACE}/x` (the canonical GitHub
6451        // Actions / GitLab CI / Drone shape) and forgets to
6452        // substitute the literal value. The `${...}` shape is the
6453        // same `$` byte at the leading position of the expansion;
6454        // the per-byte arm fires on the `$`. Pinned separately from
6455        // the bare-`$VAR` shape so a future diagnostic-surface
6456        // change that special-cased the braced form surfaces here.
6457        let d = dep_with_fonte(DepSource::Git {
6458            repo: "https://github.com/${WORKSPACE}/caixa-teia".into(),
6459            tag: Some("v0.1.0".into()),
6460            rev: None,
6461            branch: None,
6462        });
6463        let err = d.validate().unwrap_err();
6464        let DepError::FonteRepoShape { reason, .. } = err else {
6465            panic!("expected FonteRepoShape, got other variant");
6466        };
6467        assert!(
6468            reason.contains("must not contain `$`"),
6469            "reason must surface the shell-variable-expansion arm on the braced `${{...}}` \
6470             shape too, got {reason:?}"
6471        );
6472    }
6473
6474    #[test]
6475    fn fonte_repo_fragment_fires_before_var_expansion_when_fragment_first() {
6476        // Cascade pin: the fragment-`#` arm and the var-expansion-`$`
6477        // arm are both per-byte arms inside the same `for &b in
6478        // s.as_bytes()` loop, so the byte that appears first in the
6479        // value's byte order wins. A `:repo
6480        // "https://github.com/p/x#readme$HOME"` carries both `#` and
6481        // `$`; the `#` byte appears first, so the fragment-`#` arm
6482        // fires, surfacing the more self-locating diagnostic on the
6483        // byte the author pasted earliest in the URL. Mirrors the
6484        // peer cascade discipline
6485        // `fonte_repo_fragment_fires_before_background_when_fragment_first`
6486        // on the prior `:repo` byte-class arm.
6487        let d = dep_with_fonte(DepSource::Git {
6488            repo: "https://github.com/pleme-io/caixa-teia#readme$HOME".into(),
6489            tag: Some("v0.1.0".into()),
6490            rev: None,
6491            branch: None,
6492        });
6493        let err = d.validate().unwrap_err();
6494        let DepError::FonteRepoShape { reason, .. } = err else {
6495            panic!("expected FonteRepoShape, got other variant");
6496        };
6497        assert!(
6498            reason.contains("must not contain `#`"),
6499            "reason must surface the fragment-`#` arm (fires before var-expansion-`$` when \
6500             `#` byte appears first in value), got {reason:?}"
6501        );
6502    }
6503
6504    #[test]
6505    fn fonte_repo_background_fires_before_var_expansion_when_background_first() {
6506        // Cascade pin: the background-`&` arm and the
6507        // var-expansion-`$` arm are both per-byte arms inside the
6508        // same `for &b in s.as_bytes()` loop, so the byte that
6509        // appears first in the value's byte order wins. A `:repo
6510        // "https://github.com/p/x&sleep$HOME"` carries both `&` and
6511        // `$`; the `&` byte appears first, so the background arm
6512        // fires, surfacing the more self-locating diagnostic on the
6513        // byte the author pasted earliest in the URL. Pins the
6514        // natural-order cascade so a future reorder of the per-byte
6515        // arms surfaces here — `$` is the most recent byte-class arm,
6516        // so the cascade-pin sweep extends to cover every immediately
6517        // prior byte arm (`#`, `&`) firing first when ordered ahead
6518        // of `$` in the value.
6519        let d = dep_with_fonte(DepSource::Git {
6520            repo: "https://github.com/pleme-io/caixa-teia&sleep$HOME".into(),
6521            tag: Some("v0.1.0".into()),
6522            rev: None,
6523            branch: None,
6524        });
6525        let err = d.validate().unwrap_err();
6526        let DepError::FonteRepoShape { reason, .. } = err else {
6527            panic!("expected FonteRepoShape, got other variant");
6528        };
6529        assert!(
6530            reason.contains("must not contain `&`"),
6531            "reason must surface the background-`&` arm (fires before var-expansion-`$` when \
6532             `&` byte appears first in value), got {reason:?}"
6533        );
6534    }
6535
6536    #[test]
6537    fn validate_rejects_git_fonte_with_repo_carrying_shell_glob_wildcard() {
6538        // The fail-before-pass-after pin for the canonical
6539        // paste-from-shell-prompt glob footgun on `:repo` (peer with
6540        // the cf9034b `*` / `?` arm on the sibling `:caminho`
6541        // path-fonte axis). An author pastes a shell one-liner that
6542        // referenced a glob expansion (`ls
6543        // github.com/pleme-io/caixa-*`, `git clone
6544        // github:pleme-io/caixa-*`) into the `:repo` slot, forgetting
6545        // to substitute the literal repo name. Until this arm landed
6546        // the `*` byte silently passed every prior `is_git_repo_url`
6547        // arm (no whitespace, no control chars, no non-ASCII, no `#`,
6548        // no `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`,
6549        // no `;`, no `&`, no `$`, doesn't start with `-` or `:`); RFC
6550        // 3986 §2 lists `*` in the 'sub-delims' / reserved set and
6551        // the WHATWG URL spec's special-query percent-encode set maps
6552        // `*` → `%2A` on the wire, so the byte rides verbatim into
6553        // the lacre's per-dep BLAKE3 closure but is silently
6554        // rewritten at libcurl's URL-parser layer — two authors
6555        // whose values differ only in their asterisk presence
6556        // resolve to the byte-identical upstream `git clone` but
6557        // lock to two distinct lacres, defeating the THEORY.md §V.2
6558        // render-determinism contract. Peer with the `:caminho`
6559        // axis's `FonteCaminhoShellGlob` arm (cf9034b) on the
6560        // sibling path-fonte axis, and the `is_git_ref_name`
6561        // refspec-wildcard cascade on the `:fonte :tag` / `:branch`
6562        // axes.
6563        let d = dep_with_fonte(DepSource::Git {
6564            repo: "https://github.com/pleme-io/caixa-*".into(),
6565            tag: Some("v0.1.0".into()),
6566            rev: None,
6567            branch: None,
6568        });
6569        let err = d.validate().unwrap_err();
6570        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6571            panic!("expected FonteRepoShape, got other variant");
6572        };
6573        assert_eq!(nome, "caixa-teia");
6574        assert_eq!(repo, "https://github.com/pleme-io/caixa-*");
6575        assert!(
6576            reason.contains("must not contain `*`"),
6577            "reason must surface the shell-glob arm, got {reason:?}"
6578        );
6579        assert!(
6580            reason.contains("pathname-expansion") || reason.contains("'sub-delims'"),
6581            "reason must name the shell-glob / pathname-expansion / \
6582             RFC-3986-sub-delims rationale, got {reason:?}"
6583        );
6584    }
6585
6586    #[test]
6587    fn validate_rejects_git_fonte_with_repo_carrying_recursive_shell_glob() {
6588        // The fail-before-pass-after pin for the symmetric bash
6589        // `globstar` recursive-glob paste footgun: an author pastes
6590        // a `ls github.com/pleme-io/**/x` (the canonical
6591        // `globstar`-shopt-enabled recursive-listing tail) into the
6592        // `:repo` slot. The `**` shape is two `*` bytes adjacent;
6593        // the per-byte arm fires on the first `*`. Pinned
6594        // separately from the single-`*` shape so a future
6595        // diagnostic-surface change that special-cased the
6596        // double-`*` form surfaces here.
6597        let d = dep_with_fonte(DepSource::Git {
6598            repo: "https://github.com/pleme-io/**/caixa-teia".into(),
6599            tag: Some("v0.1.0".into()),
6600            rev: None,
6601            branch: None,
6602        });
6603        let err = d.validate().unwrap_err();
6604        let DepError::FonteRepoShape { reason, .. } = err else {
6605            panic!("expected FonteRepoShape, got other variant");
6606        };
6607        assert!(
6608            reason.contains("must not contain `*`"),
6609            "reason must surface the shell-glob arm on the `**` recursive-glob shape too, \
6610             got {reason:?}"
6611        );
6612    }
6613
6614    #[test]
6615    fn fonte_repo_fragment_fires_before_glob_when_fragment_first() {
6616        // Cascade pin: the fragment-`#` arm and the glob-`*` arm are
6617        // both per-byte arms inside the same `for &b in s.as_bytes()`
6618        // loop, so the byte that appears first in the value's byte
6619        // order wins. A `:repo
6620        // "https://github.com/p/x#readme*tail"` carries both `#` and
6621        // `*`; the `#` byte appears first, so the fragment-`#` arm
6622        // fires, surfacing the more self-locating diagnostic on the
6623        // byte the author pasted earliest in the URL. Mirrors the
6624        // peer cascade discipline
6625        // `fonte_repo_fragment_fires_before_var_expansion_when_fragment_first`
6626        // on the prior `:repo` byte-class arm.
6627        let d = dep_with_fonte(DepSource::Git {
6628            repo: "https://github.com/pleme-io/caixa-teia#readme*tail".into(),
6629            tag: Some("v0.1.0".into()),
6630            rev: None,
6631            branch: None,
6632        });
6633        let err = d.validate().unwrap_err();
6634        let DepError::FonteRepoShape { reason, .. } = err else {
6635            panic!("expected FonteRepoShape, got other variant");
6636        };
6637        assert!(
6638            reason.contains("must not contain `#`"),
6639            "reason must surface the fragment-`#` arm (fires before glob-`*` when `#` byte \
6640             appears first in value), got {reason:?}"
6641        );
6642    }
6643
6644    #[test]
6645    fn fonte_repo_var_expansion_fires_before_glob_when_var_expansion_first() {
6646        // Cascade pin: the var-expansion-`$` arm and the glob-`*`
6647        // arm are both per-byte arms inside the same `for &b in
6648        // s.as_bytes()` loop, so the byte that appears first in the
6649        // value's byte order wins. A `:repo
6650        // "https://github.com/p/$ORG-*"` carries both `$` and `*`;
6651        // the `$` byte appears first, so the var-expansion arm
6652        // fires, surfacing the more self-locating diagnostic on the
6653        // byte the author pasted earliest in the URL. Pins the
6654        // natural-order cascade so a future reorder of the per-byte
6655        // arms surfaces here — `*` is the most recent byte-class
6656        // arm, so the cascade-pin sweep extends to cover the
6657        // immediately prior `$` byte arm firing first when ordered
6658        // ahead of `*` in the value.
6659        let d = dep_with_fonte(DepSource::Git {
6660            repo: "https://github.com/pleme-io/$ORG-caixa-*".into(),
6661            tag: Some("v0.1.0".into()),
6662            rev: None,
6663            branch: None,
6664        });
6665        let err = d.validate().unwrap_err();
6666        let DepError::FonteRepoShape { reason, .. } = err else {
6667            panic!("expected FonteRepoShape, got other variant");
6668        };
6669        assert!(
6670            reason.contains("must not contain `$`"),
6671            "reason must surface the var-expansion-`$` arm (fires before glob-`*` when `$` \
6672             byte appears first in value), got {reason:?}"
6673        );
6674    }
6675
6676    #[test]
6677    fn validate_rejects_git_fonte_with_repo_carrying_subshell_open_paren() {
6678        // The fail-before-pass-after pin for the canonical paste-from-
6679        // shell-prompt subshell-grouping footgun on `:repo`. An author
6680        // pastes a doc / README snippet carrying a regex-alternation
6681        // grouping shape (`https://github.com/(foo|bar)/repo`) or a
6682        // dynamic-config-substitution wrapper (`$(<cmd>)`) into the
6683        // `:repo` slot, forgetting to substitute one literal org name.
6684        // Until this arm landed the `(` byte silently passed every
6685        // prior `is_git_repo_url` arm (no whitespace, no control
6686        // chars, no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no
6687        // `<`/`>`, no `` ` ``, no `|`, no `;`, no `&`, no `$`, no
6688        // `*`, doesn't start with `-` or `:`); RFC 3986 §2 lists `(`
6689        // / `)` in the 'sub-delims' / reserved set, and the WHATWG
6690        // URL spec's special-query percent-encode set maps `(` →
6691        // `%28` and `)` → `%29` on the wire, so the byte rides
6692        // verbatim into the lacre's per-dep BLAKE3 closure but is
6693        // silently rewritten at libcurl's URL-parser layer —
6694        // defeating the THEORY.md §V.2 render-determinism contract on
6695        // the same axis the prior twelve byte-class arms close.
6696        let d = dep_with_fonte(DepSource::Git {
6697            repo: "https://github.com/(foo|bar)/caixa-teia".into(),
6698            tag: Some("v0.1.0".into()),
6699            rev: None,
6700            branch: None,
6701        });
6702        let err = d.validate().unwrap_err();
6703        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6704            panic!("expected FonteRepoShape, got other variant");
6705        };
6706        assert_eq!(nome, "caixa-teia");
6707        assert_eq!(repo, "https://github.com/(foo|bar)/caixa-teia");
6708        assert!(
6709            reason.contains("must not contain `(`"),
6710            "reason must surface the subshell-open-paren arm, got {reason:?}"
6711        );
6712        assert!(
6713            reason.contains("subshell-grouping") || reason.contains("'sub-delims'"),
6714            "reason must name the shell-subshell-grouping / RFC-3986-sub-delims rationale, \
6715             got {reason:?}"
6716        );
6717    }
6718
6719    #[test]
6720    fn validate_rejects_git_fonte_with_repo_carrying_subshell_close_paren() {
6721        // The symmetric arm pin on the closing `)` byte: an author
6722        // pastes a `$(date)` command-substitution wrapper or a
6723        // regex-alternation `(foo|bar)` tail into the `:repo` slot.
6724        // Pinned separately from the opening `(` shape so a future
6725        // diagnostic-surface change that only checked one boundary
6726        // surfaces here. The `(` byte appears earlier in the
6727        // canonical regex / subshell wrapper so the per-byte loop
6728        // fires on `(` first; this test exercises a `:repo` value
6729        // carrying only the closing `)` byte (no opening paren) so
6730        // the `)` arm fires directly — pinning the byte-class arm
6731        // independent of order.
6732        let d = dep_with_fonte(DepSource::Git {
6733            repo: "github:pleme-io/caixa-teia)tail".into(),
6734            tag: Some("v0.1.0".into()),
6735            rev: None,
6736            branch: None,
6737        });
6738        let err = d.validate().unwrap_err();
6739        let DepError::FonteRepoShape { reason, .. } = err else {
6740            panic!("expected FonteRepoShape, got other variant");
6741        };
6742        assert!(
6743            reason.contains("must not contain `)`"),
6744            "reason must surface the subshell-close-paren arm on the bare `)` shape, \
6745             got {reason:?}"
6746        );
6747    }
6748
6749    #[test]
6750    fn fonte_repo_fragment_fires_before_subshell_when_fragment_first() {
6751        // Cascade pin: the fragment-`#` arm and the subshell-`(` arm
6752        // are both per-byte arms inside the same `for &b in
6753        // s.as_bytes()` loop, so the byte that appears first in the
6754        // value's byte order wins. A `:repo
6755        // "https://github.com/p/x#readme(tail)"` carries both `#` and
6756        // `(`; the `#` byte appears first, so the fragment-`#` arm
6757        // fires, surfacing the more self-locating diagnostic on the
6758        // byte the author pasted earliest in the URL. Mirrors the
6759        // peer cascade discipline
6760        // `fonte_repo_fragment_fires_before_glob_when_fragment_first`
6761        // on the prior `:repo` byte-class arm.
6762        let d = dep_with_fonte(DepSource::Git {
6763            repo: "https://github.com/pleme-io/caixa-teia#readme(tail)".into(),
6764            tag: Some("v0.1.0".into()),
6765            rev: None,
6766            branch: None,
6767        });
6768        let err = d.validate().unwrap_err();
6769        let DepError::FonteRepoShape { reason, .. } = err else {
6770            panic!("expected FonteRepoShape, got other variant");
6771        };
6772        assert!(
6773            reason.contains("must not contain `#`"),
6774            "reason must surface the fragment-`#` arm (fires before subshell-`(` when `#` \
6775             byte appears first in value), got {reason:?}"
6776        );
6777    }
6778
6779    #[test]
6780    fn fonte_repo_glob_fires_before_subshell_when_glob_first() {
6781        // Cascade pin: the glob-`*` arm (the immediate-predecessor
6782        // byte-class arm, 3902a9a) and the subshell-`(` arm are both
6783        // per-byte arms inside the same `for &b in s.as_bytes()`
6784        // loop, so the byte that appears first in the value's byte
6785        // order wins. A `:repo
6786        // "https://github.com/p/x-*-(date)"` carries both `*` and
6787        // `(`; the `*` byte appears first, so the glob arm fires,
6788        // surfacing the more self-locating diagnostic on the byte
6789        // the author pasted earliest in the URL. Pins the natural-
6790        // order cascade so a future reorder of the per-byte arms
6791        // surfaces here — `(` is the most recent byte-class arm,
6792        // so the cascade-pin sweep extends to cover the immediately
6793        // prior `*` byte arm firing first when ordered ahead of `(`
6794        // in the value.
6795        let d = dep_with_fonte(DepSource::Git {
6796            repo: "https://github.com/pleme-io/caixa-teia-*-(date)".into(),
6797            tag: Some("v0.1.0".into()),
6798            rev: None,
6799            branch: None,
6800        });
6801        let err = d.validate().unwrap_err();
6802        let DepError::FonteRepoShape { reason, .. } = err else {
6803            panic!("expected FonteRepoShape, got other variant");
6804        };
6805        assert!(
6806            reason.contains("must not contain `*`"),
6807            "reason must surface the glob-`*` arm (fires before subshell-`(` when `*` byte \
6808             appears first in value), got {reason:?}"
6809        );
6810    }
6811
6812    #[test]
6813    fn validate_rejects_git_fonte_with_repo_carrying_shell_double_quote() {
6814        // The fail-before-pass-after pin for the canonical paste-from-
6815        // doc-shell-quoting footgun on `:repo`. An author copies a
6816        // README quick-start snippet (`$ git clone "https://github.com/
6817        // foo/bar"`) and keeps the surrounding double-quote bytes when
6818        // pasting into the `:repo` slot — the doc wraps the URL in
6819        // double quotes so the shell doesn't re-lex metachars inside,
6820        // but the typed slot is itself a byte-level string parser, not
6821        // a shell context, so the quote bytes ride into the value
6822        // verbatim. Until this arm landed the `"` byte silently passed
6823        // every prior `is_git_repo_url` arm (no whitespace, no control
6824        // chars, no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no
6825        // `<`/`>`, no `` ` ``, no `|`, no `;`, no `&`, no `$`, no `*`,
6826        // no `(`/`)`, doesn't start with `-` or `:`); RFC 3986 §2 lists
6827        // `"` in the strict four-byte 'delims' subset (with `<`, `>`,
6828        // `` ` ``) every URL parser is required to refuse or percent-
6829        // encode, and the WHATWG URL spec's 'C0 control percent-encode
6830        // set' maps `"` → `%22` on the wire, so the byte rides verbatim
6831        // into the lacre's per-dep BLAKE3 closure but is silently
6832        // rewritten at libcurl's URL-parser layer, defeating the
6833        // THEORY.md §V.2 render-determinism contract.
6834        let d = dep_with_fonte(DepSource::Git {
6835            repo: "\"https://github.com/pleme-io/caixa-teia\"".into(),
6836            tag: Some("v0.1.0".into()),
6837            rev: None,
6838            branch: None,
6839        });
6840        let err = d.validate().unwrap_err();
6841        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6842            panic!("expected FonteRepoShape, got other variant");
6843        };
6844        assert_eq!(nome, "caixa-teia");
6845        assert_eq!(repo, "\"https://github.com/pleme-io/caixa-teia\"");
6846        assert!(
6847            reason.contains("must not contain `\"`"),
6848            "reason must surface the shell-double-quote arm, got {reason:?}"
6849        );
6850        assert!(
6851            reason.contains("double-quote") || reason.contains("'delims'"),
6852            "reason must name the shell-double-quote / RFC-3986-delims rationale, \
6853             got {reason:?}"
6854        );
6855    }
6856
6857    #[test]
6858    fn validate_rejects_git_fonte_with_repo_carrying_stray_trailing_double_quote() {
6859        // The symmetric stray-quote tail pin: an author pastes only a
6860        // closing `"` from a shell-history line like `git clone
6861        // "https://github.com/foo/bar" && cd …` (the trim went too
6862        // far in one direction but not the other) into the `:repo`
6863        // slot. Pinned separately from the wrapped-quote shape so a
6864        // future diagnostic-surface change that only checked one
6865        // boundary (only leading, only trailing, only paired) surfaces
6866        // here — the per-byte arm fires anywhere `"` appears.
6867        let d = dep_with_fonte(DepSource::Git {
6868            repo: "github:pleme-io/caixa-teia\"".into(),
6869            tag: Some("v0.1.0".into()),
6870            rev: None,
6871            branch: None,
6872        });
6873        let err = d.validate().unwrap_err();
6874        let DepError::FonteRepoShape { reason, .. } = err else {
6875            panic!("expected FonteRepoShape, got other variant");
6876        };
6877        assert!(
6878            reason.contains("must not contain `\"`"),
6879            "reason must surface the shell-double-quote arm on the trailing-`\"` shape, \
6880             got {reason:?}"
6881        );
6882    }
6883
6884    #[test]
6885    fn fonte_repo_fragment_fires_before_double_quote_when_fragment_first() {
6886        // Cascade pin: the fragment-`#` arm and the double-quote arm
6887        // are both per-byte arms inside the same `for &b in
6888        // s.as_bytes()` loop, so the byte that appears first in the
6889        // value's byte order wins. A `:repo
6890        // "https://github.com/p/x#readme\"tail"` carries both `#` and
6891        // `"`; the `#` byte appears first, so the fragment-`#` arm
6892        // fires, surfacing the more self-locating diagnostic on the
6893        // byte the author pasted earliest in the URL.
6894        let d = dep_with_fonte(DepSource::Git {
6895            repo: "https://github.com/pleme-io/caixa-teia#readme\"tail".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 { reason, .. } = err else {
6902            panic!("expected FonteRepoShape, got other variant");
6903        };
6904        assert!(
6905            reason.contains("must not contain `#`"),
6906            "reason must surface the fragment-`#` arm (fires before double-quote when `#` \
6907             byte appears first in value), got {reason:?}"
6908        );
6909    }
6910
6911    #[test]
6912    fn fonte_repo_subshell_fires_before_double_quote_when_subshell_first() {
6913        // Cascade pin: the subshell-`(` arm (the immediate-predecessor
6914        // byte-class arm, 3b99147) and the double-quote arm are both
6915        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
6916        // so the byte that appears first in the value's byte order
6917        // wins. A `:repo "github:p/x(date)\"tail"` carries both `(`
6918        // and `"`; the `(` byte appears first, so the subshell arm
6919        // fires, surfacing the more self-locating diagnostic on the
6920        // byte the author pasted earliest in the URL. Pins the natural-
6921        // order cascade so a future reorder of the per-byte arms
6922        // surfaces here — `"` is the most recent byte-class arm, so
6923        // the cascade-pin sweep extends to cover the immediately prior
6924        // `(` byte arm firing first when ordered ahead of `"` in the
6925        // value.
6926        let d = dep_with_fonte(DepSource::Git {
6927            repo: "github:pleme-io/caixa-teia(date)\"tail".into(),
6928            tag: Some("v0.1.0".into()),
6929            rev: None,
6930            branch: None,
6931        });
6932        let err = d.validate().unwrap_err();
6933        let DepError::FonteRepoShape { reason, .. } = err else {
6934            panic!("expected FonteRepoShape, got other variant");
6935        };
6936        assert!(
6937            reason.contains("must not contain `(`"),
6938            "reason must surface the subshell-`(` arm (fires before double-quote when `(` \
6939             byte appears first in value), got {reason:?}"
6940        );
6941    }
6942
6943    #[test]
6944    fn validate_rejects_git_fonte_with_repo_carrying_shell_single_quote() {
6945        // The fail-before-pass-after pin for the canonical paste-from-
6946        // doc-strong-quoting footgun on `:repo`. An author copies a
6947        // security-conscious README quick-start snippet (`$ git clone
6948        // 'https://github.com/foo/bar'`) and keeps the surrounding
6949        // single-quote bytes when pasting into the `:repo` slot — the
6950        // doc strong-quotes the URL so the shell suppresses every form
6951        // of expansion on the bytes inside (no `$`, no backtick, no
6952        // glob, no word-splitting), but the typed slot is itself a
6953        // byte-level string parser, not a shell context, so the quote
6954        // bytes ride into the value verbatim. Until this arm landed the
6955        // `'` byte silently passed every prior `is_git_repo_url` arm
6956        // (no whitespace, no control chars, no non-ASCII, no `#`, no
6957        // `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no
6958        // `;`, no `&`, no `$`, no `*`, no `(`/`)`, no `"`, doesn't start
6959        // with `-` or `:`); RFC 3986 §2.2 lists `'` in the 'sub-delims'
6960        // set, peer with the `\"` 'delims' double-quote arm and the
6961        // partner ASCII shell-string-delimiter byte every byte-level
6962        // string parser sharing a value-shape with a shell argument
6963        // must refuse on a URL-shaped slot.
6964        let d = dep_with_fonte(DepSource::Git {
6965            repo: "'https://github.com/pleme-io/caixa-teia'".into(),
6966            tag: Some("v0.1.0".into()),
6967            rev: None,
6968            branch: None,
6969        });
6970        let err = d.validate().unwrap_err();
6971        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6972            panic!("expected FonteRepoShape, got other variant");
6973        };
6974        assert_eq!(nome, "caixa-teia");
6975        assert_eq!(repo, "'https://github.com/pleme-io/caixa-teia'");
6976        assert!(
6977            reason.contains("must not contain `'`"),
6978            "reason must surface the shell-single-quote arm, got {reason:?}"
6979        );
6980        assert!(
6981            reason.contains("single-quote") || reason.contains("strong-quote"),
6982            "reason must name the shell-single-quote / strong-quote rationale, \
6983             got {reason:?}"
6984        );
6985    }
6986
6987    #[test]
6988    fn validate_rejects_git_fonte_with_repo_carrying_english_apostrophe() {
6989        // The symmetric English-typography pin: an author writes
6990        // `:repo "github:p/repo's-fork"` (the possessive-form paste-
6991        // from-prose idiom every README / commit-message / chat-thread
6992        // reference to a repo carries) expecting the substrate to
6993        // coerce it to a kebab-case slug — but the byte rides into the
6994        // lacre verbatim. Pinned separately from the wrapped-quote
6995        // shape so a future diagnostic-surface change that only checked
6996        // the boundary positions (only leading, only trailing, only
6997        // paired) surfaces here — the per-byte arm fires anywhere `'`
6998        // appears in the value.
6999        let d = dep_with_fonte(DepSource::Git {
7000            repo: "github:pleme-io/repo's-fork".into(),
7001            tag: Some("v0.1.0".into()),
7002            rev: None,
7003            branch: None,
7004        });
7005        let err = d.validate().unwrap_err();
7006        let DepError::FonteRepoShape { reason, .. } = err else {
7007            panic!("expected FonteRepoShape, got other variant");
7008        };
7009        assert!(
7010            reason.contains("must not contain `'`"),
7011            "reason must surface the shell-single-quote arm on the mid-string \
7012             apostrophe shape, got {reason:?}"
7013        );
7014    }
7015
7016    #[test]
7017    fn fonte_repo_fragment_fires_before_single_quote_when_fragment_first() {
7018        // Cascade pin: the fragment-`#` arm and the single-quote arm
7019        // are both per-byte arms inside the same `for &b in
7020        // s.as_bytes()` loop, so the byte that appears first in the
7021        // value's byte order wins. A `:repo
7022        // "https://github.com/p/x#readme'tail"` carries both `#` and
7023        // `'`; the `#` byte appears first, so the fragment-`#` arm
7024        // fires, surfacing the more self-locating diagnostic on the
7025        // byte the author pasted earliest in the URL.
7026        let d = dep_with_fonte(DepSource::Git {
7027            repo: "https://github.com/pleme-io/caixa-teia#readme'tail".into(),
7028            tag: Some("v0.1.0".into()),
7029            rev: None,
7030            branch: None,
7031        });
7032        let err = d.validate().unwrap_err();
7033        let DepError::FonteRepoShape { reason, .. } = err else {
7034            panic!("expected FonteRepoShape, got other variant");
7035        };
7036        assert!(
7037            reason.contains("must not contain `#`"),
7038            "reason must surface the fragment-`#` arm (fires before single-quote when `#` \
7039             byte appears first in value), got {reason:?}"
7040        );
7041    }
7042
7043    #[test]
7044    fn fonte_repo_double_quote_fires_before_single_quote_when_double_quote_first() {
7045        // Cascade pin: the double-quote-`"` arm (the immediate-predecessor
7046        // byte-class arm, 4267d8b) and the single-quote arm are both
7047        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
7048        // so the byte that appears first in the value's byte order
7049        // wins. A `:repo "github:p/x\"mid'tail"` carries both `"` and
7050        // `'`; the `"` byte appears first, so the double-quote arm
7051        // fires, surfacing the more self-locating diagnostic on the
7052        // byte the author pasted earliest in the URL. Pins the natural-
7053        // order cascade so a future reorder of the per-byte arms
7054        // surfaces here — `'` is the most recent byte-class arm, so
7055        // the cascade-pin sweep extends to cover the immediately prior
7056        // `"` byte arm firing first when ordered ahead of `'` in the
7057        // value.
7058        let d = dep_with_fonte(DepSource::Git {
7059            repo: "github:pleme-io/caixa-teia\"mid'tail".into(),
7060            tag: Some("v0.1.0".into()),
7061            rev: None,
7062            branch: None,
7063        });
7064        let err = d.validate().unwrap_err();
7065        let DepError::FonteRepoShape { reason, .. } = err else {
7066            panic!("expected FonteRepoShape, got other variant");
7067        };
7068        assert!(
7069            reason.contains("must not contain `\"`"),
7070            "reason must surface the double-quote arm (fires before single-quote when `\"` \
7071             byte appears first in value), got {reason:?}"
7072        );
7073    }
7074
7075    #[test]
7076    fn validate_rejects_git_fonte_with_repo_carrying_shell_history_expansion() {
7077        // The fail-before-pass-after pin for the canonical paste-from-
7078        // shell-history footgun on `:repo`. An author copies a `git
7079        // clone <url>!sudo make install` one-liner from a README's
7080        // quick-start snippet, intending the trailing `!sudo` as a
7081        // shell-history-expansion reference but the typed slot is itself
7082        // a byte-level string parser, not a shell context, so the byte
7083        // rides into the value verbatim. Until this arm landed the `!`
7084        // byte silently passed every prior `is_git_repo_url` arm (no
7085        // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
7086        // no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no `;`,
7087        // no `&`, no `$`, no `*`, no `(`/`)`, no `"`, no `'`, doesn't
7088        // start with `-` or `:`); bash with the default `histexpand`
7089        // mode rewrites `!command` to the most recent history entry
7090        // beginning with `command`, the canonical RCE-class injection
7091        // vector when the byte rides into a shell argument.
7092        let d = dep_with_fonte(DepSource::Git {
7093            repo: "https://github.com/pleme-io/caixa-teia!sudo".into(),
7094            tag: Some("v0.1.0".into()),
7095            rev: None,
7096            branch: None,
7097        });
7098        let err = d.validate().unwrap_err();
7099        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7100            panic!("expected FonteRepoShape, got other variant");
7101        };
7102        assert_eq!(nome, "caixa-teia");
7103        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia!sudo");
7104        assert!(
7105            reason.contains("must not contain `!`"),
7106            "reason must surface the shell-history-expansion arm, got {reason:?}"
7107        );
7108        assert!(
7109            reason.contains("history-expansion") || reason.contains("bang"),
7110            "reason must name the shell-history-expansion / bang rationale, got {reason:?}"
7111        );
7112    }
7113
7114    #[test]
7115    fn validate_rejects_git_fonte_with_repo_carrying_double_bang_history_reference() {
7116        // The symmetric `!!` repeat-prior-command pin: an author paste-
7117        // trims a `git clone <url>` retry idiom from shell history that
7118        // expands to the previous command via `!!`. Pinned separately
7119        // from the wrapped `!command` shape so a future diagnostic-
7120        // surface change that only checked the leading or paired-bang
7121        // position surfaces here — the per-byte arm fires anywhere `!`
7122        // appears in the value.
7123        let d = dep_with_fonte(DepSource::Git {
7124            repo: "github:pleme-io/caixa-teia!!".into(),
7125            tag: Some("v0.1.0".into()),
7126            rev: None,
7127            branch: None,
7128        });
7129        let err = d.validate().unwrap_err();
7130        let DepError::FonteRepoShape { reason, .. } = err else {
7131            panic!("expected FonteRepoShape, got other variant");
7132        };
7133        assert!(
7134            reason.contains("must not contain `!`"),
7135            "reason must surface the shell-history-expansion arm on the trailing-`!!` shape, \
7136             got {reason:?}"
7137        );
7138    }
7139
7140    #[test]
7141    fn fonte_repo_fragment_fires_before_bang_when_fragment_first() {
7142        // Cascade pin: the fragment-`#` arm and the bang arm are both
7143        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
7144        // so the byte that appears first in the value's byte order
7145        // wins. A `:repo "https://github.com/p/x#readme!tail"` carries
7146        // both `#` and `!`; the `#` byte appears first, so the
7147        // fragment-`#` arm fires, surfacing the more self-locating
7148        // diagnostic on the byte the author pasted earliest in the URL.
7149        let d = dep_with_fonte(DepSource::Git {
7150            repo: "https://github.com/pleme-io/caixa-teia#readme!tail".into(),
7151            tag: Some("v0.1.0".into()),
7152            rev: None,
7153            branch: None,
7154        });
7155        let err = d.validate().unwrap_err();
7156        let DepError::FonteRepoShape { reason, .. } = err else {
7157            panic!("expected FonteRepoShape, got other variant");
7158        };
7159        assert!(
7160            reason.contains("must not contain `#`"),
7161            "reason must surface the fragment-`#` arm (fires before bang when `#` byte \
7162             appears first in value), got {reason:?}"
7163        );
7164    }
7165
7166    #[test]
7167    fn fonte_repo_single_quote_fires_before_bang_when_single_quote_first() {
7168        // Cascade pin: the single-quote-`'` arm (the immediate-predecessor
7169        // byte-class arm, e7a109f) and the bang arm are both per-byte
7170        // arms inside the same `for &b in s.as_bytes()` loop, so the
7171        // byte that appears first in the value's byte order wins. A
7172        // `:repo "github:p/x'mid!tail"` carries both `'` and `!`; the
7173        // `'` byte appears first, so the single-quote arm fires,
7174        // surfacing the more self-locating diagnostic on the byte the
7175        // author pasted earliest in the URL. Pins the natural-order
7176        // cascade so a future reorder of the per-byte arms surfaces
7177        // here — `!` is the most recent byte-class arm, so the
7178        // cascade-pin sweep extends to cover the immediately prior `'`
7179        // byte arm firing first when ordered ahead of `!` in the value.
7180        let d = dep_with_fonte(DepSource::Git {
7181            repo: "github:pleme-io/caixa-teia'mid!tail".into(),
7182            tag: Some("v0.1.0".into()),
7183            rev: None,
7184            branch: None,
7185        });
7186        let err = d.validate().unwrap_err();
7187        let DepError::FonteRepoShape { reason, .. } = err else {
7188            panic!("expected FonteRepoShape, got other variant");
7189        };
7190        assert!(
7191            reason.contains("must not contain `'`"),
7192            "reason must surface the single-quote arm (fires before bang when `'` byte \
7193             appears first in value), got {reason:?}"
7194        );
7195    }
7196
7197    #[test]
7198    fn validate_rejects_git_fonte_with_repo_carrying_list_separator_comma() {
7199        // The fail-before-pass-after pin for the canonical
7200        // list-separator-belongs-to-list-grammar footgun on `:repo`.
7201        // An author copies a `git clone <a>, <b>, <c>` paste-from-CSV
7202        // one-liner from a multi-repo bootstrap doc, intending the
7203        // comma to separate multiple repo entries but the typed
7204        // `:repo` slot names *one* repo (the list-separator belongs
7205        // to the `:deps` list grammar, not to the value). Until this
7206        // arm landed the `,` byte silently passed every prior
7207        // `is_git_repo_url` arm (no whitespace, no control chars, no
7208        // non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no `<`/`>`,
7209        // no `` ` ``, no `|`, no `;`, no `&`, no `$`, no `*`, no
7210        // `(`/`)`, no `"`, no `'`, no `!`, doesn't start with `-` or
7211        // `:`); the byte rode into the lacre's per-dep content-
7212        // address and the resolver's `git clone <repo>` subprocess
7213        // invocation, where no host's repo registry resolved the
7214        // comma-bearing slug.
7215        let d = dep_with_fonte(DepSource::Git {
7216            repo: "github:pleme-io/caixa-teia,github:pleme-io/caixa-feira".into(),
7217            tag: Some("v0.1.0".into()),
7218            rev: None,
7219            branch: None,
7220        });
7221        let err = d.validate().unwrap_err();
7222        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7223            panic!("expected FonteRepoShape, got other variant");
7224        };
7225        assert_eq!(nome, "caixa-teia");
7226        assert_eq!(
7227            repo,
7228            "github:pleme-io/caixa-teia,github:pleme-io/caixa-feira"
7229        );
7230        assert!(
7231            reason.contains("must not contain `,`"),
7232            "reason must surface the list-separator-comma arm, got {reason:?}"
7233        );
7234        assert!(
7235            reason.contains("list-separator") || reason.contains("sub-delims"),
7236            "reason must name the list-separator / RFC-3986-sub-delims rationale, \
7237             got {reason:?}"
7238        );
7239    }
7240
7241    #[test]
7242    fn validate_rejects_git_fonte_with_repo_carrying_trailing_comma() {
7243        // The symmetric trailing-`,` paste-from-prose pin: an author
7244        // writes `:repo "github:pleme-io/caixa-feira,"` (the trailing
7245        // comma every README-prose list-of-projects sentence carries,
7246        // mistakenly retained when the slug is pasted mid-sentence)
7247        // expecting the substrate to coerce it to a kebab-case slug.
7248        // Pinned separately from the wrapped mid-token shape so a
7249        // future diagnostic-surface change that only checked the
7250        // leading or paired-comma position surfaces here — the
7251        // per-byte arm fires anywhere `,` appears in the value.
7252        let d = dep_with_fonte(DepSource::Git {
7253            repo: "github:pleme-io/caixa-feira,".into(),
7254            tag: Some("v0.1.0".into()),
7255            rev: None,
7256            branch: None,
7257        });
7258        let err = d.validate().unwrap_err();
7259        let DepError::FonteRepoShape { reason, .. } = err else {
7260            panic!("expected FonteRepoShape, got other variant");
7261        };
7262        assert!(
7263            reason.contains("must not contain `,`"),
7264            "reason must surface the list-separator-comma arm on the trailing-`,` shape, \
7265             got {reason:?}"
7266        );
7267    }
7268
7269    #[test]
7270    fn fonte_repo_fragment_fires_before_comma_when_fragment_first() {
7271        // Cascade pin: the fragment-`#` arm and the comma arm are
7272        // both per-byte arms inside the same `for &b in s.as_bytes()`
7273        // loop, so the byte that appears first in the value's byte
7274        // order wins. A `:repo "https://github.com/p/x#readme,tail"`
7275        // carries both `#` and `,`; the `#` byte appears first, so
7276        // the fragment-`#` arm fires, surfacing the more self-
7277        // locating diagnostic on the byte the author pasted earliest
7278        // in the URL.
7279        let d = dep_with_fonte(DepSource::Git {
7280            repo: "https://github.com/pleme-io/caixa-teia#readme,tail".into(),
7281            tag: Some("v0.1.0".into()),
7282            rev: None,
7283            branch: None,
7284        });
7285        let err = d.validate().unwrap_err();
7286        let DepError::FonteRepoShape { reason, .. } = err else {
7287            panic!("expected FonteRepoShape, got other variant");
7288        };
7289        assert!(
7290            reason.contains("must not contain `#`"),
7291            "reason must surface the fragment-`#` arm (fires before comma when `#` byte \
7292             appears first in value), got {reason:?}"
7293        );
7294    }
7295
7296    #[test]
7297    fn fonte_repo_bang_fires_before_comma_when_bang_first() {
7298        // Cascade pin: the bang-`!` arm (the immediate-predecessor
7299        // byte-class arm, 7d53c68) and the comma arm are both
7300        // per-byte arms inside the same `for &b in s.as_bytes()`
7301        // loop, so the byte that appears first in the value's byte
7302        // order wins. A `:repo "github:p/x!mid,tail"` carries both
7303        // `!` and `,`; the `!` byte appears first, so the bang arm
7304        // fires, surfacing the more self-locating diagnostic on the
7305        // byte the author pasted earliest in the URL. Pins the
7306        // natural-order cascade so a future reorder of the per-byte
7307        // arms surfaces here — `,` is the most recent byte-class
7308        // arm, so the cascade-pin sweep extends to cover the
7309        // immediately prior `!` byte arm firing first when ordered
7310        // ahead of `,` in the value.
7311        let d = dep_with_fonte(DepSource::Git {
7312            repo: "github:pleme-io/caixa-teia!mid,tail".into(),
7313            tag: Some("v0.1.0".into()),
7314            rev: None,
7315            branch: None,
7316        });
7317        let err = d.validate().unwrap_err();
7318        let DepError::FonteRepoShape { reason, .. } = err else {
7319            panic!("expected FonteRepoShape, got other variant");
7320        };
7321        assert!(
7322            reason.contains("must not contain `!`"),
7323            "reason must surface the bang arm (fires before comma when `!` byte \
7324             appears first in value), got {reason:?}"
7325        );
7326    }
7327
7328    #[test]
7329    fn validate_rejects_git_fonte_with_repo_carrying_shell_env_var_assignment() {
7330        // The fail-before-pass-after pin for the canonical
7331        // shell-env-var-assignment-belongs-to-shell-grammar footgun
7332        // on `:repo`. An author copies
7333        // `GIT_TERMINAL_PROMPT=0 git clone <url>` (or
7334        // `GIT_SSL_NO_VERIFY=1 git clone <url>`, `HTTPS_PROXY=…
7335        // git clone <url>`, etc. — the canonical
7336        // git-troubleshooting README idiom for a one-shot env-var
7337        // scoped to the `git clone` invocation) from a shell-prompt
7338        // one-liner, intending the `KEY=VALUE` prefix as a shell-
7339        // grammar env-var assignment but the typed `:repo` slot is
7340        // a value parser, not a shell context, so the bytes ride
7341        // into the value verbatim. Until this arm landed the `=`
7342        // byte silently passed every prior `is_git_repo_url` arm
7343        // (no whitespace, no control chars, no non-ASCII, no `#`,
7344        // no `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no
7345        // `|`, no `;`, no `&`, no `$`, no `*`, no `(`/`)`, no `"`,
7346        // no `'`, no `!`, no `,`, doesn't start with `-` or `:`);
7347        // the byte rode into the lacre's per-dep content-address
7348        // and the resolver's `git clone <repo>` subprocess
7349        // invocation, where the upstream host's git porcelain
7350        // fetched a literal `GIT_TERMINAL_PROMPT=0 https://…`-shaped
7351        // path that no host's repo registry resolves.
7352        let d = dep_with_fonte(DepSource::Git {
7353            repo: "GIT_TERMINAL_PROMPT=0 https://github.com/pleme-io/caixa-teia".into(),
7354            tag: Some("v0.1.0".into()),
7355            rev: None,
7356            branch: None,
7357        });
7358        let err = d.validate().unwrap_err();
7359        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7360            panic!("expected FonteRepoShape, got other variant");
7361        };
7362        assert_eq!(nome, "caixa-teia");
7363        assert_eq!(
7364            repo,
7365            "GIT_TERMINAL_PROMPT=0 https://github.com/pleme-io/caixa-teia"
7366        );
7367        // The `=` byte at position 19 of `GIT_TERMINAL_PROMPT=0 …`
7368        // appears before the ` ` byte at position 21, so the `=`
7369        // arm fires (not the whitespace arm) — both arms guard
7370        // the slot, but the per-byte for-loop scans left-to-right
7371        // and the first matching byte wins.
7372        assert!(
7373            reason.contains("must not contain `=`"),
7374            "reason must surface the equals-`=` arm on the env-var-assignment \
7375             paste shape, got {reason:?}"
7376        );
7377        assert!(
7378            reason.contains("env-var-assignment") || reason.contains("KEY=VALUE"),
7379            "reason must name the shell-env-var-assignment rationale, got {reason:?}"
7380        );
7381    }
7382
7383    #[test]
7384    fn validate_rejects_git_fonte_with_repo_carrying_gitconfig_url_key_prefix() {
7385        // The symmetric paste-from-gitconfig pin: an author copies
7386        // `url=https://github.com/p/x` from `git config --get-all
7387        // remote.origin.url` output, a `.gitconfig` `[remote
7388        // "origin"] url = https://…` ini-stanza paste, or a
7389        // `git config remote.origin.url <value>` doc snippet,
7390        // intending the `url=` prefix as the ini-key but the typed
7391        // `:repo` slot is a URL value parser, not a gitconfig
7392        // grammar. With no leading whitespace and no earlier-arm
7393        // bytes in the value, the `=` arm itself fires (rather
7394        // than cascading to the whitespace arm as in the env-var
7395        // paste shape). Pinned separately so a future diagnostic-
7396        // surface change that only checked the whitespace-leading
7397        // shape surfaces here — the per-byte arm fires anywhere
7398        // `=` appears in the value.
7399        let d = dep_with_fonte(DepSource::Git {
7400            repo: "url=https://github.com/pleme-io/caixa-feira".into(),
7401            tag: Some("v0.1.0".into()),
7402            rev: None,
7403            branch: None,
7404        });
7405        let err = d.validate().unwrap_err();
7406        let DepError::FonteRepoShape { reason, .. } = err else {
7407            panic!("expected FonteRepoShape, got other variant");
7408        };
7409        assert!(
7410            reason.contains("must not contain `=`"),
7411            "reason must surface the equals-`=` arm on the `url=…` gitconfig \
7412             paste shape, got {reason:?}"
7413        );
7414        assert!(
7415            reason.contains("key-value-separator") || reason.contains("sub-delims"),
7416            "reason must name the key-value-separator / RFC-3986-sub-delims \
7417             rationale, got {reason:?}"
7418        );
7419    }
7420
7421    #[test]
7422    fn fonte_repo_fragment_fires_before_equals_when_fragment_first() {
7423        // Cascade pin: the fragment-`#` arm and the `=` arm are
7424        // both per-byte arms inside the same `for &b in s.as_bytes()`
7425        // loop, so the byte that appears first in the value's byte
7426        // order wins. A `:repo "https://github.com/p/x#readme=tail"`
7427        // carries both `#` and `=`; the `#` byte appears first, so
7428        // the fragment-`#` arm fires, surfacing the more self-
7429        // locating diagnostic on the byte the author pasted earliest
7430        // in the URL.
7431        let d = dep_with_fonte(DepSource::Git {
7432            repo: "https://github.com/pleme-io/caixa-teia#readme=tail".into(),
7433            tag: Some("v0.1.0".into()),
7434            rev: None,
7435            branch: None,
7436        });
7437        let err = d.validate().unwrap_err();
7438        let DepError::FonteRepoShape { reason, .. } = err else {
7439            panic!("expected FonteRepoShape, got other variant");
7440        };
7441        assert!(
7442            reason.contains("must not contain `#`"),
7443            "reason must surface the fragment-`#` arm (fires before equals when \
7444             `#` byte appears first in value), got {reason:?}"
7445        );
7446    }
7447
7448    #[test]
7449    fn fonte_repo_comma_fires_before_equals_when_comma_first() {
7450        // Cascade pin: the comma-`,` arm (the immediate-predecessor
7451        // byte-class arm, 775b80e) and the `=` arm are both per-byte
7452        // arms inside the same `for &b in s.as_bytes()` loop, so
7453        // the byte that appears first in the value's byte order
7454        // wins. A `:repo "github:p/x,mid=tail"` carries both `,`
7455        // and `=`; the `,` byte appears first, so the comma arm
7456        // fires, surfacing the more self-locating diagnostic on
7457        // the byte the author pasted earliest in the URL. Pins the
7458        // natural-order cascade so a future reorder of the per-byte
7459        // arms surfaces here — `=` is the most recent byte-class
7460        // arm, so the cascade-pin sweep extends to cover the
7461        // immediately prior `,` byte arm firing first when ordered
7462        // ahead of `=` in the value.
7463        let d = dep_with_fonte(DepSource::Git {
7464            repo: "github:pleme-io/caixa-teia,mid=tail".into(),
7465            tag: Some("v0.1.0".into()),
7466            rev: None,
7467            branch: None,
7468        });
7469        let err = d.validate().unwrap_err();
7470        let DepError::FonteRepoShape { reason, .. } = err else {
7471            panic!("expected FonteRepoShape, got other variant");
7472        };
7473        assert!(
7474            reason.contains("must not contain `,`"),
7475            "reason must surface the comma arm (fires before equals when `,` byte \
7476             appears first in value), got {reason:?}"
7477        );
7478    }
7479
7480    #[test]
7481    fn validate_rejects_git_fonte_with_repo_carrying_percent_encoded_space() {
7482        // The fail-before-pass-after pin for the canonical paste-from-
7483        // browser-address-bar percent-encoded-space footgun on `:repo`.
7484        // An author copies `https://github.com/p/x%20test` from a
7485        // browser address bar (or a percent-encoded README hyperlink,
7486        // or a `curl --data-urlencode` shell-pipeline output)
7487        // intending `%20` as the URL encoding of a literal space; the
7488        // typed `:repo` slot already rejects the literal space byte
7489        // (the whitespace arm at the top of `is_git_repo_url`), so an
7490        // author trying to express "I really meant a space" reaches
7491        // for percent-encoding. Until this arm landed the `%` byte
7492        // silently passed every prior `is_git_repo_url` arm and rode
7493        // verbatim into the lacre's per-dep content-address — but
7494        // libcurl re-percent-encodes `%` to `%25` on the wire (since
7495        // `%` is reserved as the escape-sequence lead-in), so the
7496        // wire request becomes `https://github.com/p/x%2520test`, a
7497        // path the lacre's content-address never names. The classic
7498        // render-determinism violation on the encoding-mechanism axis
7499        // itself.
7500        let d = dep_with_fonte(DepSource::Git {
7501            repo: "https://github.com/pleme-io/caixa-teia%20test".into(),
7502            tag: Some("v0.1.0".into()),
7503            rev: None,
7504            branch: None,
7505        });
7506        let err = d.validate().unwrap_err();
7507        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7508            panic!("expected FonteRepoShape, got other variant");
7509        };
7510        assert_eq!(nome, "caixa-teia");
7511        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia%20test");
7512        assert!(
7513            reason.contains("must not contain `%`"),
7514            "reason must surface the percent-`%` arm on the percent-encoded-space \
7515             paste shape, got {reason:?}"
7516        );
7517        assert!(
7518            reason.contains("percent-encoding") || reason.contains("%25"),
7519            "reason must name the percent-encoding / `%25` re-encoding rationale, \
7520             got {reason:?}"
7521        );
7522    }
7523
7524    #[test]
7525    fn validate_rejects_git_fonte_with_repo_carrying_percent_encoded_slash() {
7526        // The symmetric over-encoded-path-separator pin: an author
7527        // writes `:repo "https://github.com/p%2Fx"` intending the
7528        // `%2F` as the URL encoding of `/` (the canonical
7529        // paste-from-OpenAPI-spec / paste-from-percent-encoded-template
7530        // footgun every API client library and OAuth redirect-URI
7531        // documentation surfaces — the `/` is the URL-path-separator
7532        // and some templates percent-encode it to escape interpretation
7533        // as a path separator). The GitHub Smart-HTTP transport
7534        // resolves the URL's path-segment grammar before the
7535        // percent-decoding pass, so the value identifies a different
7536        // resource on the wire than the literal-`/` form the lacre's
7537        // content-address must agree with — two authors whose `:repo`
7538        // values differ only in their `/` vs `%2F` presence lock to
7539        // two distinct BLAKE3 closures for the byte-identical upstream
7540        // `git clone`. Pinned separately so a future diagnostic
7541        // surface that only catches the `%20` shape surfaces here too.
7542        let d = dep_with_fonte(DepSource::Git {
7543            repo: "https://github.com/pleme-io%2Fcaixa-teia".into(),
7544            tag: Some("v0.1.0".into()),
7545            rev: None,
7546            branch: None,
7547        });
7548        let err = d.validate().unwrap_err();
7549        let DepError::FonteRepoShape { reason, .. } = err else {
7550            panic!("expected FonteRepoShape, got other variant");
7551        };
7552        assert!(
7553            reason.contains("must not contain `%`"),
7554            "reason must surface the percent-`%` arm on the over-encoded-path \
7555             shape, got {reason:?}"
7556        );
7557        assert!(
7558            reason.contains("render-determinism") || reason.contains("BLAKE3"),
7559            "reason must name the render-determinism / BLAKE3-closure rationale, \
7560             got {reason:?}"
7561        );
7562    }
7563
7564    #[test]
7565    fn fonte_repo_fragment_fires_before_percent_when_fragment_first() {
7566        // Cascade pin: the fragment-`#` arm and the `%` arm are both
7567        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
7568        // so the byte that appears first in the value's byte order
7569        // wins. A `:repo "https://github.com/p/x#sec%20tail"` carries
7570        // both `#` and `%`; the `#` byte appears first, so the
7571        // fragment-`#` arm fires, surfacing the more self-locating
7572        // diagnostic on the byte the author pasted earliest in the URL.
7573        let d = dep_with_fonte(DepSource::Git {
7574            repo: "https://github.com/pleme-io/caixa-teia#sec%20tail".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 { reason, .. } = err else {
7581            panic!("expected FonteRepoShape, got other variant");
7582        };
7583        assert!(
7584            reason.contains("must not contain `#`"),
7585            "reason must surface the fragment-`#` arm (fires before percent when \
7586             `#` byte appears first in value), got {reason:?}"
7587        );
7588    }
7589
7590    #[test]
7591    fn fonte_repo_equals_fires_before_percent_when_equals_first() {
7592        // Cascade pin: the equals-`=` arm (the immediate-predecessor
7593        // byte-class arm, acf99af) and the `%` arm are both per-byte
7594        // arms inside the same `for &b in s.as_bytes()` loop, so the
7595        // byte that appears first in the value's byte order wins.
7596        // A `:repo "github:p/x=mid%20tail"` carries both `=` and `%`;
7597        // the `=` byte appears first, so the equals arm fires,
7598        // surfacing the more self-locating diagnostic on the byte the
7599        // author pasted earliest in the URL. Pins the natural-order
7600        // cascade so a future reorder of the per-byte arms surfaces
7601        // here — `%` is the most recent byte-class arm, so the
7602        // cascade-pin sweep extends to cover the immediately prior
7603        // `=` byte arm firing first when ordered ahead of `%` in the
7604        // value.
7605        let d = dep_with_fonte(DepSource::Git {
7606            repo: "github:pleme-io/caixa-teia=mid%20tail".into(),
7607            tag: Some("v0.1.0".into()),
7608            rev: None,
7609            branch: None,
7610        });
7611        let err = d.validate().unwrap_err();
7612        let DepError::FonteRepoShape { reason, .. } = err else {
7613            panic!("expected FonteRepoShape, got other variant");
7614        };
7615        assert!(
7616            reason.contains("must not contain `=`"),
7617            "reason must surface the equals arm (fires before percent when `=` byte \
7618             appears first in value), got {reason:?}"
7619        );
7620    }
7621
7622    #[test]
7623    fn validate_rejects_git_fonte_with_repo_carrying_caret_history_substitution() {
7624        // The fail-before-pass-after pin for the canonical paste-from-
7625        // shell-history footgun on `:repo`. An author copies a
7626        // `git clone <url>` line from their terminal followed by a
7627        // bash / ksh / zsh `^typo^fix^` quick-edit-and-rerun shell-
7628        // history shorthand (the `^old^new^` form re-runs the prior
7629        // history entry with the first `old` substituted by `new`,
7630        // bash's default behavior on interactive sessions with
7631        // `set -o histexpand`), forgetting to trim the trailing
7632        // `^...^...` shell-history fragment from the URL value. The
7633        // `^` byte sits in the RFC 3986 §2 'unwise' set (peer with
7634        // `{`, `}`, `|`, `\\` — the strictest of the §2 reserved
7635        // classes), the WHATWG URL spec's 'fragment percent-encode
7636        // set' maps `^` → `%5E` on the wire, so the byte rides
7637        // verbatim into the lacre's per-dep content-address but
7638        // libcurl re-encodes it to `%5E` at `git clone` time — the
7639        // classic render-determinism violation on the same axis the
7640        // peer `%`, `=`, `,`, `!`, `'`, `"`, `(`, `)`, `*`, `$`,
7641        // `&`, `;`, `|`, backtick, `<`, `>`, `{`, `}`, `\\`, `?`,
7642        // `#` arms close.
7643        let d = dep_with_fonte(DepSource::Git {
7644            repo: "https://github.com/pleme-io/caixa-teia^typo^fix".into(),
7645            tag: Some("v0.1.0".into()),
7646            rev: None,
7647            branch: None,
7648        });
7649        let err = d.validate().unwrap_err();
7650        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7651            panic!("expected FonteRepoShape, got other variant");
7652        };
7653        assert_eq!(nome, "caixa-teia");
7654        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia^typo^fix");
7655        assert!(
7656            reason.contains("must not contain `^`"),
7657            "reason must surface the caret-`^` arm on the paste-from-shell-history \
7658             shape, got {reason:?}"
7659        );
7660        assert!(
7661            reason.contains("history-substitution") || reason.contains("%5E"),
7662            "reason must name the shell-history-substitution / `%5E` wire-encoding \
7663             rationale, got {reason:?}"
7664        );
7665    }
7666
7667    #[test]
7668    fn validate_rejects_git_fonte_with_repo_carrying_caret_regex_anchor() {
7669        // The symmetric paste-from-doc-grep-pipeline footgun: an
7670        // author writes `:repo "github:p/^archived"` after copying a
7671        // `grep '^archived'` regex-anchor / negation idiom from a
7672        // doc / README quick-listing snippet, expecting the substrate
7673        // to coerce it to a literal repo name. The byte rides
7674        // verbatim into the lacre's per-dep content-address and
7675        // diverges from the byte-identical literal `archived` form
7676        // every other author authored — the canonical render-
7677        // determinism violation pin on the second footgun shape the
7678        // caret-`^` arm closes.
7679        let d = dep_with_fonte(DepSource::Git {
7680            repo: "github:pleme-io/^archived".into(),
7681            tag: Some("v0.1.0".into()),
7682            rev: None,
7683            branch: None,
7684        });
7685        let err = d.validate().unwrap_err();
7686        let DepError::FonteRepoShape { reason, .. } = err else {
7687            panic!("expected FonteRepoShape, got other variant");
7688        };
7689        assert!(
7690            reason.contains("must not contain `^`"),
7691            "reason must surface the caret-`^` arm on the regex-anchor shape, \
7692             got {reason:?}"
7693        );
7694        assert!(
7695            reason.contains("render-determinism") || reason.contains("BLAKE3"),
7696            "reason must name the render-determinism / BLAKE3-closure rationale, \
7697             got {reason:?}"
7698        );
7699    }
7700
7701    #[test]
7702    fn fonte_repo_percent_fires_before_caret_when_percent_first() {
7703        // Cascade pin: the `%` arm (the immediate-predecessor byte-
7704        // class arm, a323db8) and the `^` arm are both per-byte arms
7705        // inside the same `for &b in s.as_bytes()` loop, so the byte
7706        // that appears first in the value's byte order wins. A
7707        // `:repo "https://github.com/p/x%20mid^tail"` carries both
7708        // `%` and `^`; the `%` byte appears first, so the percent
7709        // arm fires, surfacing the more self-locating diagnostic on
7710        // the byte the author pasted earliest in the URL. Pins the
7711        // natural-order cascade so a future reorder of the per-byte
7712        // arms surfaces here — `^` is the most recent byte-class arm,
7713        // so the cascade-pin sweep extends to cover the immediately
7714        // prior `%` byte arm firing first when ordered ahead of `^`
7715        // in the value.
7716        let d = dep_with_fonte(DepSource::Git {
7717            repo: "https://github.com/pleme-io/caixa-teia%20mid^tail".into(),
7718            tag: Some("v0.1.0".into()),
7719            rev: None,
7720            branch: None,
7721        });
7722        let err = d.validate().unwrap_err();
7723        let DepError::FonteRepoShape { reason, .. } = err else {
7724            panic!("expected FonteRepoShape, got other variant");
7725        };
7726        assert!(
7727            reason.contains("must not contain `%`"),
7728            "reason must surface the percent arm (fires before caret when `%` byte \
7729             appears first in value), got {reason:?}"
7730        );
7731    }
7732
7733    #[test]
7734    fn validate_rejects_git_fonte_with_repo_missing_colon_separator() {
7735        // The "I dropped the scheme" footgun — `:repo "pleme-io/caixa-teia"`
7736        // (no `github:` prefix, no scheme). Every documented form
7737        // carries a `:` (`github:`, `https://`, `ssh://`, `git://`,
7738        // `file://`, or `git@host:path`); a bare `org/repo` is
7739        // ambiguous (`git clone` reads as a relative filesystem path
7740        // rather than the GitHub-shorthand expansion the author
7741        // probably intended) and the gate rejects the shape upstream.
7742        let d = dep_with_fonte(DepSource::Git {
7743            repo: "pleme-io/caixa-teia".into(),
7744            tag: Some("v0.1.0".into()),
7745            rev: None,
7746            branch: None,
7747        });
7748        let err = d.validate().unwrap_err();
7749        let DepError::FonteRepoShape { reason, .. } = err else {
7750            panic!("expected FonteRepoShape, got other variant");
7751        };
7752        assert!(
7753            reason.contains("must contain a `:`"),
7754            "reason must surface the missing-`:` arm, got {reason:?}"
7755        );
7756        assert!(
7757            reason.contains("github:"),
7758            "reason must name the canonical `github:` shorthand prefix, got {reason:?}"
7759        );
7760    }
7761
7762    #[test]
7763    fn validate_rejects_git_fonte_with_repo_leading_colon() {
7764        // The "empty scheme" footgun — `:repo ":foo"` has a zero-length
7765        // scheme that no git porcelain entry-point accepts. Pinned
7766        // separately from the missing-`:` arm because a value with a
7767        // leading `:` does technically contain a `:` separator; the
7768        // shape gate rejects on a dedicated arm so the diagnostic
7769        // names the specific footgun.
7770        let d = dep_with_fonte(DepSource::Git {
7771            repo: ":pleme-io/caixa-teia".into(),
7772            tag: Some("v0.1.0".into()),
7773            rev: None,
7774            branch: None,
7775        });
7776        let err = d.validate().unwrap_err();
7777        let DepError::FonteRepoShape { reason, .. } = err else {
7778            panic!("expected FonteRepoShape, got other variant");
7779        };
7780        assert!(
7781            reason.contains("must not start with `:`"),
7782            "reason must surface the leading-`:` arm, got {reason:?}"
7783        );
7784    }
7785
7786    #[test]
7787    fn validate_rejects_git_fonte_with_repo_too_long() {
7788        // The cap arm — a `:repo` value longer than
7789        // [`crate::render::GIT_REPO_URL_MAX_LEN`] (2048) bytes is
7790        // structurally untenable on every realistic landing site (the
7791        // resolver's `git clone` invocation, the future M4 CR
7792        // materializer's per-dep `repo:` axis); a value of that length
7793        // is almost certainly a paste-from-binary slug.
7794        let too_long = format!(
7795            "github:pleme-io/{}",
7796            "x".repeat(crate::render::GIT_REPO_URL_MAX_LEN)
7797        );
7798        let d = dep_with_fonte(DepSource::Git {
7799            repo: too_long.clone(),
7800            tag: Some("v0.1.0".into()),
7801            rev: None,
7802            branch: None,
7803        });
7804        let err = d.validate().unwrap_err();
7805        let DepError::FonteRepoShape { reason, .. } = err else {
7806            panic!("expected FonteRepoShape, got other variant");
7807        };
7808        assert!(
7809            reason.contains("2048"),
7810            "reason must name the cap, got {reason:?}"
7811        );
7812    }
7813
7814    #[test]
7815    fn validate_accepts_canonical_git_fonte_repo_shapes() {
7816        // The positive-control sweep: every documented author shape on
7817        // the `:fonte :repo` axis ([`crate::DepSource::Git`] doc comment)
7818        // must pass the value-shape gate. Pinned so a future tightening
7819        // (e.g. forbidding `http://` in favor of `https://`-only) surfaces
7820        // here as a structural decision. Each form is exercised with the
7821        // same canonical `:tag` pin so only the `:repo` axis varies.
7822        for repo in [
7823            // The pleme-io registry-shorthand convention — `github:org/repo`.
7824            "github:pleme-io/caixa-teia",
7825            // Other host-aliased shorthands (the resolver's pluggable
7826            // host-prefix table).
7827            "gitlab:pleme-io/caixa-teia",
7828            "codeberg:pleme-io/caixa-teia",
7829            "sourcehut:~pleme-io/caixa-teia",
7830            // Full HTTPS URL with and without `.git` suffix.
7831            "https://github.com/pleme-io/caixa-teia",
7832            "https://github.com/pleme-io/caixa-teia.git",
7833            // HTTP (rare; dev / mirror).
7834            "http://example.com/pleme-io/caixa-teia.git",
7835            // SSH URL.
7836            "ssh://git@github.com/pleme-io/caixa-teia.git",
7837            "ssh://git@git.example.com:2222/pleme-io/caixa-teia.git",
7838            // Scp-style SSH — the canonical `git@host:path` short form.
7839            "git@github.com:pleme-io/caixa-teia.git",
7840            "git@git.example.com:team/private.git",
7841            // Anonymous git protocol.
7842            "git://git.example.com/pleme-io/caixa-teia.git",
7843            // Local file URL (dev path).
7844            "file:///tmp/caixa-teia",
7845        ] {
7846            let d = dep_with_fonte(DepSource::Git {
7847                repo: repo.into(),
7848                tag: Some("v0.1.0".into()),
7849                rev: None,
7850                branch: None,
7851            });
7852            d.validate()
7853                .unwrap_or_else(|e| panic!("canonical repo {repo:?} must validate, got {e:?}"));
7854        }
7855    }
7856
7857    #[test]
7858    fn fonte_repo_empty_takes_precedence_over_shape() {
7859        // Order pin: the existing `FonteRepoEmpty` diagnostic (narrower
7860        // diagnostic; doesn't try to parse the URL shape) fires before
7861        // the new `FonteRepoShape` per-axis gate, so an empty `:repo`
7862        // keeps its narrower error message. Mirrors
7863        // `fonte_repo_empty_fires_before_pin_missing` (already pinned)
7864        // on the ordering layer.
7865        let d = dep_with_fonte(DepSource::Git {
7866            repo: String::new(),
7867            tag: Some("v0.1.0".into()),
7868            rev: None,
7869            branch: None,
7870        });
7871        let err = d.validate().unwrap_err();
7872        assert!(
7873            matches!(err, DepError::FonteRepoEmpty { .. }),
7874            "got {err:?}"
7875        );
7876    }
7877
7878    #[test]
7879    fn fonte_repo_shape_fires_before_pin_missing() {
7880        // Order pin: a malformed `:repo` value on a dep with no pin set
7881        // surfaces the `:repo` shape diagnostic (the more self-locating
7882        // axis — the `:repo` is the load-bearing identity of the source;
7883        // a missing pin is downstream from "do we even know the repo")
7884        // rather than collapsing onto the pin-missing diagnostic. The
7885        // shape gate runs inline before the pin enumeration in
7886        // `DepSource::validate`.
7887        let d = dep_with_fonte(DepSource::Git {
7888            repo: "pleme-io/caixa-teia".into(), // missing `:` separator
7889            tag: None,
7890            rev: None,
7891            branch: None,
7892        });
7893        let err = d.validate().unwrap_err();
7894        assert!(
7895            matches!(err, DepError::FonteRepoShape { .. }),
7896            "got {err:?}"
7897        );
7898    }
7899
7900    #[test]
7901    fn fonte_repo_shape_diagnostic_carries_offending_repo_verbatim() {
7902        // The diagnostic-shape pin: the error names the offending
7903        // `:repo` value verbatim plus a non-empty parser-shaped `reason`
7904        // so the author can grep their caixa.lisp without re-running
7905        // the build. Mirrors the diagnostic-shape sweep on every prior
7906        // value-shape gate (3f9d7a0, 6cbb900, c7d05ec, e70d213, be07fd5).
7907        let d = dep_with_fonte(DepSource::Git {
7908            repo: "pleme-io/caixa-teia".into(),
7909            tag: Some("v0.1.0".into()),
7910            rev: None,
7911            branch: None,
7912        });
7913        let err = d.validate().unwrap_err();
7914        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7915            panic!("expected FonteRepoShape, got other variant");
7916        };
7917        assert_eq!(nome, "caixa-teia");
7918        assert_eq!(repo, "pleme-io/caixa-teia");
7919        assert!(
7920            !reason.is_empty(),
7921            "FonteRepoShape `reason` must carry the predicate's wording verbatim"
7922        );
7923    }
7924
7925    #[test]
7926    fn validate_rejects_git_fonte_with_no_pin() {
7927        // The fail-before-pass-after pin for the canonical
7928        // `(:tipo git :repo "github:pleme-io/x")` shape with no
7929        // :tag/:rev/:branch — until this gate landed the resolver's
7930        // ResolveError::MissingPin surfaced at fetch time, far from the
7931        // source caixa.lisp. The new gate moves the check to validate
7932        // time and names the offending dep.
7933        let d = dep_with_fonte(DepSource::Git {
7934            repo: "github:pleme-io/caixa-teia".into(),
7935            tag: None,
7936            rev: None,
7937            branch: None,
7938        });
7939        let err = d.validate().unwrap_err();
7940        assert!(
7941            matches!(err, DepError::FontePinMissing { ref nome } if nome == "caixa-teia"),
7942            "got {err:?}"
7943        );
7944    }
7945
7946    #[test]
7947    fn validate_rejects_git_fonte_with_ambiguous_tag_and_branch() {
7948        // The canonical "pin drift" footgun: an author writes
7949        // `:tag "v1"` and later adds `:branch "main"` without removing
7950        // the :tag, and the resolver silently picks :tag (precedence
7951        // :rev > :tag > :branch). The :branch was dropped with no
7952        // diagnostic. The gate now rejects multi-pin shapes so the
7953        // author makes the precedence explicit at the source.
7954        let d = dep_with_fonte(DepSource::Git {
7955            repo: "github:pleme-io/caixa-teia".into(),
7956            tag: Some("v0.1.0".into()),
7957            rev: None,
7958            branch: Some("main".into()),
7959        });
7960        let err = d.validate().unwrap_err();
7961        let DepError::FontePinAmbiguous { nome, pins } = err else {
7962            panic!("expected FontePinAmbiguous");
7963        };
7964        assert_eq!(nome, "caixa-teia");
7965        assert!(pins.contains(":tag"));
7966        assert!(pins.contains(":branch"));
7967        assert!(!pins.contains(":rev"));
7968    }
7969
7970    #[test]
7971    fn validate_rejects_git_fonte_with_ambiguous_tag_and_rev() {
7972        // Sibling arm of the pin-drift footgun: :tag + :rev set
7973        // simultaneously. Pinned separately so a future relaxation
7974        // that only catches the (:tag, :branch) pair surfaces here.
7975        let d = dep_with_fonte(DepSource::Git {
7976            repo: "github:pleme-io/caixa-teia".into(),
7977            tag: Some("v0.1.0".into()),
7978            rev: Some("c0ffee".into()),
7979            branch: None,
7980        });
7981        let err = d.validate().unwrap_err();
7982        let DepError::FontePinAmbiguous { nome, pins } = err else {
7983            panic!("expected FontePinAmbiguous");
7984        };
7985        assert_eq!(nome, "caixa-teia");
7986        assert!(pins.contains(":tag"));
7987        assert!(pins.contains(":rev"));
7988    }
7989
7990    #[test]
7991    fn validate_rejects_git_fonte_with_all_three_pins() {
7992        // The maximal ambiguity case — every pin axis set. Pinned so a
7993        // future relaxation that only catches pairs surfaces here. The
7994        // diagnostic must enumerate every offending axis so the author
7995        // sees the full set, not just the first match.
7996        let d = dep_with_fonte(DepSource::Git {
7997            repo: "github:pleme-io/caixa-teia".into(),
7998            tag: Some("v0.1.0".into()),
7999            rev: Some("c0ffee".into()),
8000            branch: Some("main".into()),
8001        });
8002        let err = d.validate().unwrap_err();
8003        let DepError::FontePinAmbiguous { nome, pins } = err else {
8004            panic!("expected FontePinAmbiguous");
8005        };
8006        assert_eq!(nome, "caixa-teia");
8007        assert!(pins.contains(":tag"));
8008        assert!(pins.contains(":rev"));
8009        assert!(pins.contains(":branch"));
8010    }
8011
8012    #[test]
8013    fn validate_rejects_git_fonte_with_empty_tag_pin() {
8014        // The empty-pin arm: exactly one pin axis is `Some(_)`, but its
8015        // inner string is empty. Distinct from FontePinMissing (where
8016        // every axis is None) — pinned separately so a future
8017        // tightening collapsing them surfaces here as a structural
8018        // decision.
8019        let d = dep_with_fonte(DepSource::Git {
8020            repo: "github:pleme-io/caixa-teia".into(),
8021            tag: Some(String::new()),
8022            rev: None,
8023            branch: None,
8024        });
8025        let err = d.validate().unwrap_err();
8026        let DepError::FontePinEmpty { nome, pin } = err else {
8027            panic!("expected FontePinEmpty");
8028        };
8029        assert_eq!(nome, "caixa-teia");
8030        assert_eq!(pin, ":tag");
8031    }
8032
8033    #[test]
8034    fn validate_rejects_git_fonte_with_empty_rev_pin() {
8035        // Sibling arm — the empty-pin diagnostic names which axis
8036        // carries the empty value, so the author's grep target is
8037        // unambiguous.
8038        let d = dep_with_fonte(DepSource::Git {
8039            repo: "github:pleme-io/caixa-teia".into(),
8040            tag: None,
8041            rev: Some(String::new()),
8042            branch: None,
8043        });
8044        let err = d.validate().unwrap_err();
8045        let DepError::FontePinEmpty { nome, pin } = err else {
8046            panic!("expected FontePinEmpty");
8047        };
8048        assert_eq!(nome, "caixa-teia");
8049        assert_eq!(pin, ":rev");
8050    }
8051
8052    #[test]
8053    fn validate_rejects_path_fonte_with_empty_caminho() {
8054        // The fail-before-pass-after pin for `(:tipo path :caminho "")`:
8055        // until this gate landed the resolver's
8056        // ResolveError::MissingPath surfaced with `path: PathBuf("")` at
8057        // fetch time — not actionable. The new gate moves the check to
8058        // validate time and names the offending dep.
8059        let d = dep_with_fonte(DepSource::Path {
8060            caminho: String::new(),
8061        });
8062        let err = d.validate().unwrap_err();
8063        assert!(
8064            matches!(err, DepError::FonteCaminhoEmpty { ref nome } if nome == "caixa-teia"),
8065            "got {err:?}"
8066        );
8067    }
8068
8069    #[test]
8070    fn validate_rejects_path_fonte_with_absolute_caminho() {
8071        // The fail-before-pass-after pin for the absolute-`:caminho`
8072        // shape: `(:tipo path :caminho "/home/me/work/caixa-teia")`.
8073        // Until this gate landed an absolute `:caminho` silently
8074        // passed validate; the lacre pipeline embedded the
8075        // host-specific filesystem path verbatim in its
8076        // content-address (`conteudo: format!("path:{caminho}")`,
8077        // caixa-resolver/src/resolve.rs:189), so the BLAKE3 closure
8078        // differed per machine — the build succeeded but two CI
8079        // runners with different `${HOME}` layouts emitted two
8080        // distinct lacres for the byte-identical caixa, silently
8081        // breaking the THEORY.md §V.2 render-determinism contract
8082        // far from the source caixa.lisp. The new gate moves the
8083        // check to validate time and names the offending dep +
8084        // caminho verbatim.
8085        let d = dep_with_fonte(DepSource::Path {
8086            caminho: "/home/me/work/caixa-teia".into(),
8087        });
8088        let err = d.validate().unwrap_err();
8089        let DepError::FonteCaminhoAbsolute { nome, caminho } = err else {
8090            panic!("expected FonteCaminhoAbsolute, got other variant");
8091        };
8092        assert_eq!(nome, "caixa-teia");
8093        assert_eq!(caminho, "/home/me/work/caixa-teia");
8094    }
8095
8096    #[test]
8097    fn validate_accepts_path_fonte_with_parent_escape_caminho() {
8098        // The canonical sibling-workspace dep form
8099        // (`:caminho "../caixa-teia"`) remains accepted. The
8100        // absolute-path gate above is specifically narrower than the
8101        // shared [`crate::render::is_sandboxed_relative_path`]
8102        // predicate (which additionally forbids `..` traversal): a
8103        // local-path dep's canonical author surface is the in-tree
8104        // sibling-workspace path, so a full sandboxed-relative-path
8105        // lift would structurally reject every legitimate path-fonte
8106        // dep. Pinned so a future tightening to the full predicate
8107        // surfaces here as a structural decision, not a silent break.
8108        let d = dep_with_fonte(DepSource::Path {
8109            caminho: "../caixa-teia".into(),
8110        });
8111        d.validate().unwrap();
8112    }
8113
8114    #[test]
8115    fn validate_accepts_path_fonte_with_deeply_nested_relative_caminho() {
8116        // A multi-segment relative `:caminho`
8117        // (`"vendor/forks/caixa-teia"`) remains accepted — the
8118        // absolute-path gate brackets the host-layout-leaking shape
8119        // at the leading-`/` boundary only; every relative shape past
8120        // the empty arm continues to pass. Pinned alongside the
8121        // `..`-traversal positive control so a future tightening
8122        // surfaces the full set of legitimate relative forms here
8123        // rather than at a downstream consumer.
8124        let d = dep_with_fonte(DepSource::Path {
8125            caminho: "vendor/forks/caixa-teia".into(),
8126        });
8127        d.validate().unwrap();
8128    }
8129
8130    #[test]
8131    fn validate_rejects_path_fonte_with_tilde_prefix_caminho() {
8132        // The fail-before-pass-after pin for the tilde-expansion
8133        // `:caminho` shape: `(:tipo path :caminho "~/work/caixa-teia")`.
8134        // Until this gate landed the b94fd83 absolute arm let `~/foo`
8135        // through (`Path::is_absolute` returns false on a leading `~`
8136        // — the tilde is a shell-expansion convention, not a POSIX
8137        // path component), so the lacre embedded the value verbatim
8138        // and the resolver folded it through `Path::join` without
8139        // expansion, looking for a literal `./~/work/caixa-teia`
8140        // subdirectory and failing at resolve time with a
8141        // `No such file or directory` error far from the source
8142        // caixa.lisp. The new gate moves the check to validate time
8143        // and names the offending dep + caminho verbatim.
8144        let d = dep_with_fonte(DepSource::Path {
8145            caminho: "~/work/caixa-teia".into(),
8146        });
8147        let err = d.validate().unwrap_err();
8148        let DepError::FonteCaminhoTildeExpansion { nome, caminho } = err else {
8149            panic!("expected FonteCaminhoTildeExpansion, got {err:?}");
8150        };
8151        assert_eq!(nome, "caixa-teia");
8152        assert_eq!(caminho, "~/work/caixa-teia");
8153    }
8154
8155    #[test]
8156    fn validate_rejects_path_fonte_with_bare_tilde_caminho() {
8157        // The bare `~` form (canonical "I meant `$HOME` and forgot
8158        // the rest"): both the leading-tilde arm catches it and the
8159        // canonical-user-tilde shell idiom (`~alice/dev/caixa-teia`)
8160        // sweeps through the same arm. Pinned both to ensure the
8161        // gate doesn't narrow to `~/` only.
8162        for s in ["~", "~alice/dev/caixa-teia", "~/", "~root/work"] {
8163            let d = dep_with_fonte(DepSource::Path { caminho: s.into() });
8164            let err = d.validate().unwrap_err();
8165            assert!(
8166                matches!(err, DepError::FonteCaminhoTildeExpansion { .. }),
8167                "{s:?} → {err:?}",
8168            );
8169        }
8170    }
8171
8172    #[test]
8173    fn validate_accepts_path_fonte_with_mid_path_tilde_caminho() {
8174        // The leading-`~` is the canonical shell-expansion footgun —
8175        // a tilde mid-path (`"../foo~bar/caixa-teia"` — the canonical
8176        // backup-file-suffix idiom) is a legitimate POSIX path byte
8177        // with no shell-expansion semantic at the leading position.
8178        // Pinned so the gate doesn't widen to a full no-tilde-anywhere
8179        // sweep that would break every legitimate-shape backup-file
8180        // path.
8181        let d = dep_with_fonte(DepSource::Path {
8182            caminho: "../foo~bar/caixa-teia".into(),
8183        });
8184        d.validate().unwrap();
8185    }
8186
8187    #[test]
8188    fn fonte_caminho_empty_fires_before_tilde_expansion() {
8189        // Cascade pin: the empty arm structurally precedes the
8190        // tilde arm (the bytes `""` and `"~"` don't overlap), but the
8191        // pin establishes the precedence at the diagnostic-shape
8192        // level should a future codec round-trip ever produce a
8193        // probe-as-both value. Mirrors the peer
8194        // `fonte_repo_empty_fires_before_pin_missing` cascade
8195        // discipline.
8196        let d = dep_with_fonte(DepSource::Path {
8197            caminho: String::new(),
8198        });
8199        let err = d.validate().unwrap_err();
8200        assert!(
8201            matches!(err, DepError::FonteCaminhoEmpty { .. }),
8202            "got {err:?}",
8203        );
8204    }
8205
8206    #[test]
8207    fn fonte_caminho_tilde_diagnostic_carries_offending_dep_and_caminho() {
8208        // Diagnostic-shape pin (peer with
8209        // `validate_rejects_path_fonte_with_absolute_caminho`'s
8210        // payload assertion): the error's Display surfaces both the
8211        // offending `:nome` and the offending `:caminho` verbatim
8212        // so a `feira lint` run can render the diagnostic without
8213        // re-parsing.
8214        let d = dep_with_fonte(DepSource::Path {
8215            caminho: "~alice/dev/caixa-teia".into(),
8216        });
8217        let rendered = d.validate().unwrap_err().to_string();
8218        assert!(
8219            rendered.contains("caixa-teia"),
8220            "diagnostic must name the offending dep: {rendered}",
8221        );
8222        assert!(
8223            rendered.contains("~alice/dev/caixa-teia"),
8224            "diagnostic must quote the offending caminho: {rendered}",
8225        );
8226        assert!(
8227            rendered.contains('~'),
8228            "diagnostic must reference the tilde footgun: {rendered}",
8229        );
8230    }
8231
8232    #[test]
8233    fn validate_rejects_path_fonte_with_dollar_prefix_caminho() {
8234        // The fail-before-pass-after pin for the shell-variable-
8235        // expansion `:caminho` shape: `(:tipo path :caminho
8236        // "$HOME/work/caixa-teia")`. Until this gate landed the
8237        // b94fd83 absolute arm + the a5c248e tilde arm both let
8238        // `$HOME/foo` through (`Path::is_absolute` returns false on
8239        // a leading `$` — the `$` is a shell convention, not a POSIX
8240        // path component; `starts_with('~')` returns false too), so
8241        // the lacre embedded the value verbatim and the resolver
8242        // folded it through `Path::join` without `$`-expansion,
8243        // looking for a literal `./$HOME/work/caixa-teia`
8244        // subdirectory and failing at resolve time with a
8245        // `No such file or directory` error far from the source
8246        // caixa.lisp. The new gate moves the check to validate time
8247        // and names the offending dep + caminho verbatim.
8248        let d = dep_with_fonte(DepSource::Path {
8249            caminho: "$HOME/work/caixa-teia".into(),
8250        });
8251        let err = d.validate().unwrap_err();
8252        let DepError::FonteCaminhoVarExpansion { nome, caminho } = err else {
8253            panic!("expected FonteCaminhoVarExpansion, got {err:?}");
8254        };
8255        assert_eq!(nome, "caixa-teia");
8256        assert_eq!(caminho, "$HOME/work/caixa-teia");
8257    }
8258
8259    #[test]
8260    fn validate_rejects_path_fonte_with_dollar_brace_prefix_caminho() {
8261        // Sweep over every leading-`$` shape: the `${VAR}`-braced
8262        // form (canonical "paste-from-CI-manifest" footgun every
8263        // GitHub Actions / GitLab CI / Drone manifest carries on
8264        // `${WORKSPACE}`), the XDG idiom (`$XDG_CONFIG_HOME/caixa`,
8265        // canonical "I'm referencing a per-user config dir"),
8266        // and the bare `$` (canonical "I meant `$HOME` and forgot
8267        // the rest"). All shapes route through the same gate's
8268        // byte check. Pinned so the gate doesn't narrow to a
8269        // single shape (e.g. `$HOME/` only).
8270        for s in [
8271            "${HOME}/work/caixa-teia",
8272            "${WORKSPACE}/caixa-teia",
8273            "$XDG_CONFIG_HOME/caixa",
8274            "$",
8275        ] {
8276            let d = dep_with_fonte(DepSource::Path { caminho: s.into() });
8277            let err = d.validate().unwrap_err();
8278            assert!(
8279                matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
8280                "{s:?} → {err:?}",
8281            );
8282        }
8283    }
8284
8285    #[test]
8286    fn validate_rejects_path_fonte_with_mid_path_dollar_caminho() {
8287        // The `$` byte is the canonical shell-variable-expansion /
8288        // command-substitution / arithmetic-expansion sentinel and
8289        // is rejected at *every* position on the `:caminho` axis: the
8290        // leading arm surfaces `FonteCaminhoVarExpansion`, the
8291        // embedded arm surfaces `FonteCaminhoShellVariableExpansion`
8292        // (6620f39). Pinned so a future arm doesn't narrow the gate
8293        // back to the leading position and re-open the paste-from-
8294        // shell-one-liner `"../foo$HOME/bar"` / paste-from-CI-
8295        // manifest `"../foo${WORKSPACE}/bar"` / paste-from-shell-
8296        // prompt `"../foo$(whoami)/bar"` cross-idiom-leak surface on
8297        // the lacre content-address (`path:{caminho}`,
8298        // caixa-resolver/src/resolve.rs:189).
8299        let d = dep_with_fonte(DepSource::Path {
8300            caminho: "../foo$bar/caixa-teia".into(),
8301        });
8302        let err = d.validate().unwrap_err();
8303        assert!(
8304            matches!(
8305                err,
8306                DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
8307            ),
8308            "got {err:?}",
8309        );
8310    }
8311
8312    #[test]
8313    fn fonte_caminho_tilde_fires_before_var_expansion() {
8314        // Cascade pin: the tilde arm structurally precedes the var
8315        // arm (the bytes `~` and `$` don't overlap at the leading
8316        // position), but the pin establishes the precedence at the
8317        // diagnostic-shape level should a future codec round-trip
8318        // ever produce a probe-as-both value. Mirrors the peer
8319        // `fonte_caminho_empty_fires_before_tilde_expansion` cascade
8320        // discipline on the immediate-predecessor arm.
8321        let d = dep_with_fonte(DepSource::Path {
8322            caminho: "~/work/caixa-teia".into(),
8323        });
8324        let err = d.validate().unwrap_err();
8325        assert!(
8326            matches!(err, DepError::FonteCaminhoTildeExpansion { .. }),
8327            "got {err:?}",
8328        );
8329    }
8330
8331    #[test]
8332    fn fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho() {
8333        // Diagnostic-shape pin (peer with
8334        // `fonte_caminho_tilde_diagnostic_carries_offending_dep_and_caminho`'s
8335        // payload assertion on the immediate-predecessor arm): the
8336        // error's Display surfaces both the offending `:nome` and
8337        // the offending `:caminho` verbatim plus the `$` footgun
8338        // character itself so a `feira lint` run can render the
8339        // diagnostic without re-parsing.
8340        let d = dep_with_fonte(DepSource::Path {
8341            caminho: "${WORKSPACE}/caixa-teia".into(),
8342        });
8343        let rendered = d.validate().unwrap_err().to_string();
8344        assert!(
8345            rendered.contains("caixa-teia"),
8346            "diagnostic must name the offending dep: {rendered}",
8347        );
8348        assert!(
8349            rendered.contains("${WORKSPACE}/caixa-teia"),
8350            "diagnostic must quote the offending caminho: {rendered}",
8351        );
8352        assert!(
8353            rendered.contains('$'),
8354            "diagnostic must reference the dollar footgun: {rendered}",
8355        );
8356    }
8357
8358    #[test]
8359    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_nul() {
8360        // The fail-before-pass-after pin for the load-bearing NUL byte:
8361        // POSIX paths cannot contain `0x00` (every `std::fs` syscall
8362        // routes the path through `CString::new` which fails with
8363        // `NulError`); until this gate landed a `:caminho
8364        // "../caixa\0teia"` silently passed validate, the lacre
8365        // pipeline embedded the value verbatim, and the failure
8366        // surfaced at the resolver's `Path::join` → `CString::new`
8367        // boundary with a non-self-locating `NulError` far from the
8368        // source caixa.lisp. The new gate moves the check to validate
8369        // time and names the offending dep + caminho + offending byte
8370        // verbatim.
8371        let d = dep_with_fonte(DepSource::Path {
8372            caminho: "../caixa\0teia".into(),
8373        });
8374        let err = d.validate().unwrap_err();
8375        let DepError::FonteCaminhoControlChar {
8376            nome,
8377            caminho,
8378            byte,
8379        } = err
8380        else {
8381            panic!("expected FonteCaminhoControlChar, got {err:?}");
8382        };
8383        assert_eq!(nome, "caixa-teia");
8384        assert_eq!(caminho, "../caixa\0teia");
8385        assert_eq!(byte, 0x00);
8386    }
8387
8388    #[test]
8389    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_newline() {
8390        // The canonical paste-from-multiline-doc footgun on `:caminho`
8391        // — author copies `"../caixa-teia\n"` (trailing newline) out
8392        // of a multi-line code-fence or, worse, a `:caminho
8393        // "../caixa-teia\nrm -rf /"` value (CRLF-at-subprocess-argument
8394        // injection sibling on the path axis the `is_git_repo_url`
8395        // control-char arm already closes on `:repo`). Pinned
8396        // separately from the NUL arm so a future relaxation that
8397        // catches one but not the other surfaces here.
8398        let d = dep_with_fonte(DepSource::Path {
8399            caminho: "../caixa-teia\n".into(),
8400        });
8401        let err = d.validate().unwrap_err();
8402        let DepError::FonteCaminhoControlChar { byte, .. } = err else {
8403            panic!("expected FonteCaminhoControlChar, got {err:?}");
8404        };
8405        assert_eq!(byte, 0x0A);
8406    }
8407
8408    #[test]
8409    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_carriage_return() {
8410        // The CRLF sibling of the LF arm — Windows-line-ending
8411        // paste-from-multiline-doc on a `\r\n`-terminated buffer
8412        // leaves a stray `\r` mid-string after the LF strip. Pinned
8413        // separately from the LF arm so a future relaxation that
8414        // only catches LF surfaces here.
8415        let d = dep_with_fonte(DepSource::Path {
8416            caminho: "../caixa-teia\r".into(),
8417        });
8418        let err = d.validate().unwrap_err();
8419        let DepError::FonteCaminhoControlChar { byte, .. } = err else {
8420            panic!("expected FonteCaminhoControlChar, got {err:?}");
8421        };
8422        assert_eq!(byte, 0x0D);
8423    }
8424
8425    #[test]
8426    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_tab() {
8427        // The canonical paste-from-aligned-table footgun — a `\t`
8428        // mid-`:caminho` is invisible in most editors but rides
8429        // through the lacre's content-address verbatim, so two
8430        // paste-from-distinct-tables (one editor strips tabs, one
8431        // preserves them) yield divergent lacres for the byte-
8432        // identical-looking caixa. Pinned separately from the
8433        // whitespace-shaped LF/CR arms so a future relaxation that
8434        // narrows to line-terminator-only surfaces here.
8435        let d = dep_with_fonte(DepSource::Path {
8436            caminho: "../caixa\tteia".into(),
8437        });
8438        let err = d.validate().unwrap_err();
8439        let DepError::FonteCaminhoControlChar { byte, .. } = err else {
8440            panic!("expected FonteCaminhoControlChar, got {err:?}");
8441        };
8442        assert_eq!(byte, 0x09);
8443    }
8444
8445    #[test]
8446    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_del() {
8447        // The DEL byte (`0x7F`) closes the upper-end paste-from-
8448        // binary-blob footgun — the gate's contract is `b < 0x20 ||
8449        // b == 0x7F`, matching the `is_git_repo_url` /
8450        // `is_git_ref_name` predicates' control-char arms. Pinned
8451        // separately from the lower-range arms so a future narrowing
8452        // to `< 0x20` only surfaces here.
8453        let d = dep_with_fonte(DepSource::Path {
8454            caminho: "../caixa\x7fteia".into(),
8455        });
8456        let err = d.validate().unwrap_err();
8457        let DepError::FonteCaminhoControlChar { byte, .. } = err else {
8458            panic!("expected FonteCaminhoControlChar, got {err:?}");
8459        };
8460        assert_eq!(byte, 0x7F);
8461    }
8462
8463    #[test]
8464    fn validate_accepts_path_fonte_with_caminho_carrying_high_bit_utf8() {
8465        // The control-byte arm targets `0x00..=0x1F` + `0x7F` only —
8466        // high-bit / non-ASCII UTF-8 bytes are not gated. POSIX paths
8467        // are opaque byte sequences and UTF-8 multi-byte sequences
8468        // are a legitimate filename shape (the `café-teia/foo` idiom).
8469        // Pinned so the gate doesn't widen to a full ASCII-only sweep
8470        // that would break every legitimate-shape UTF-8 path.
8471        let d = dep_with_fonte(DepSource::Path {
8472            caminho: "../café-teia/foo".into(),
8473        });
8474        d.validate().unwrap();
8475    }
8476
8477    #[test]
8478    fn fonte_caminho_var_fires_before_control_char() {
8479        // Cascade pin: the var-expansion arm structurally precedes the
8480        // control-char arm. A value like `"$\n"` probes positive on
8481        // both arms (`starts_with('$')` and contains LF), but the
8482        // narrower leading-byte diagnostic (`FonteCaminhoVarExpansion`)
8483        // wins so the author sees the more self-locating shell-
8484        // expansion arm first. Mirrors the
8485        // `fonte_caminho_tilde_fires_before_var_expansion` cascade
8486        // discipline on the immediate-predecessor arm.
8487        let d = dep_with_fonte(DepSource::Path {
8488            caminho: "$HOME\n".into(),
8489        });
8490        let err = d.validate().unwrap_err();
8491        assert!(
8492            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
8493            "got {err:?}",
8494        );
8495    }
8496
8497    #[test]
8498    fn validate_rejects_path_fonte_with_leading_space_caminho() {
8499        // The fail-before-pass-after pin for the leading ASCII space
8500        // `:caminho` shape: `(:tipo path :caminho " ../caixa-teia")`.
8501        // Until this gate landed the b94fd83 absolute arm + the a5c248e
8502        // tilde arm + the f4efe9c var arm + the d624c8d control-byte arm
8503        // all let `" ../caixa-teia"` through: `Path::is_absolute` returns
8504        // false on a leading space (the leading byte is `0x20`, not `0x2F`),
8505        // `starts_with('~')` / `starts_with('$')` return false, and `0x20`
8506        // is not in the `0x00..=0x1F` plus `0x7F` control-byte set (the
8507        // four ASCII whitespace bytes `0x09` tab, `0x0A` LF, `0x0D` CR
8508        // are caught, but the most common whitespace `0x20` space is
8509        // not). The lacre embedded the value verbatim and the resolver
8510        // folded it through `Path::join` looking for a literal `./ ../
8511        // caixa-teia` subdirectory and failing at resolve time with a
8512        // non-self-locating `No such file or directory` error far from
8513        // the source caixa.lisp. The new gate moves the check to
8514        // validate time and names the offending dep + caminho verbatim.
8515        let d = dep_with_fonte(DepSource::Path {
8516            caminho: " ../caixa-teia".into(),
8517        });
8518        let err = d.validate().unwrap_err();
8519        let DepError::FonteCaminhoLeadingWhitespace { nome, caminho } = err else {
8520            panic!("expected FonteCaminhoLeadingWhitespace, got {err:?}");
8521        };
8522        assert_eq!(nome, "caixa-teia");
8523        assert_eq!(caminho, " ../caixa-teia");
8524    }
8525
8526    #[test]
8527    fn validate_rejects_path_fonte_with_multiple_leading_spaces_caminho() {
8528        // The aligned-doc paste footgun sweep: more than one leading
8529        // space (`"   ../caixa-teia"` — the canonical "I selected the
8530        // aligned column from a four-`:fonte`-entry `:deps` block"
8531        // paste) routes through the same gate's `starts_with(' ')`
8532        // byte check. Pinned so the gate doesn't narrow to a
8533        // single-space prefix.
8534        let d = dep_with_fonte(DepSource::Path {
8535            caminho: "   ../caixa-teia".into(),
8536        });
8537        let err = d.validate().unwrap_err();
8538        assert!(
8539            matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
8540            "got {err:?}",
8541        );
8542    }
8543
8544    #[test]
8545    fn validate_accepts_path_fonte_with_mid_path_space_caminho() {
8546        // The leading-space is the canonical paste-from-aligned-doc
8547        // footgun — a space mid-path (`"../my dir/caixa-teia"` — the
8548        // canonical "I have a directory with a space in its name"
8549        // idiom; ASCII `0x20` is a valid POSIX filename byte) is a
8550        // legitimate path with no whitespace-leak semantic at the
8551        // non-leading position. Pinned so the gate doesn't widen to a
8552        // full no-space-anywhere sweep that would break every
8553        // legitimate-shape space-in-filename path.
8554        let d = dep_with_fonte(DepSource::Path {
8555            caminho: "../my dir/caixa-teia".into(),
8556        });
8557        d.validate().unwrap();
8558    }
8559
8560    #[test]
8561    fn fonte_caminho_var_fires_before_leading_whitespace() {
8562        // Cascade pin: the var-expansion arm structurally precedes the
8563        // leading-whitespace arm. A value like `"$ "` would probe positive
8564        // on var (`starts_with('$')`) but the leading-byte arms walk
8565        // left-to-right so the var arm fires on the leading `$` before
8566        // the leading-whitespace arm probes. Mirrors the
8567        // `fonte_caminho_tilde_fires_before_var_expansion` cascade
8568        // discipline on the immediate-predecessor arms.
8569        let d = dep_with_fonte(DepSource::Path {
8570            caminho: "$VAR".into(),
8571        });
8572        let err = d.validate().unwrap_err();
8573        assert!(
8574            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
8575            "got {err:?}",
8576        );
8577    }
8578
8579    #[test]
8580    fn fonte_caminho_leading_whitespace_fires_before_control_char() {
8581        // Cascade pin: the leading-whitespace arm structurally precedes
8582        // the control-char arm. A value like `" ../foo\n"` probes
8583        // positive on both (starts with space AND contains LF), but
8584        // the narrower leading-byte diagnostic
8585        // (`FonteCaminhoLeadingWhitespace`) wins so the author sees the
8586        // more self-locating paste-from-aligned-doc arm first. Mirrors
8587        // the `fonte_caminho_var_fires_before_control_char` cascade
8588        // discipline on the immediate-predecessor arm.
8589        let d = dep_with_fonte(DepSource::Path {
8590            caminho: " ../foo\n".into(),
8591        });
8592        let err = d.validate().unwrap_err();
8593        assert!(
8594            matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
8595            "got {err:?}",
8596        );
8597    }
8598
8599    #[test]
8600    fn fonte_caminho_leading_whitespace_diagnostic_carries_offending_dep_and_caminho() {
8601        // Diagnostic-shape pin (peer with
8602        // `fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho`'s
8603        // payload assertion on the immediate-predecessor arm): the
8604        // error's Display surfaces both the offending `:nome` and the
8605        // offending `:caminho` verbatim, so a `feira lint` run can
8606        // render the diagnostic without re-parsing and the author can
8607        // grep their caixa.lisp for `:caminho "<value>"` and fix it in
8608        // one edit.
8609        let d = dep_with_fonte(DepSource::Path {
8610            caminho: " ../caixa-teia".into(),
8611        });
8612        let rendered = d.validate().unwrap_err().to_string();
8613        assert!(
8614            rendered.contains("caixa-teia"),
8615            "diagnostic must name the offending dep: {rendered}",
8616        );
8617        assert!(
8618            rendered.contains(" ../caixa-teia"),
8619            "diagnostic must quote the offending caminho: {rendered}",
8620        );
8621        assert!(
8622            rendered.contains("space"),
8623            "diagnostic must name the space footgun: {rendered}",
8624        );
8625    }
8626
8627    #[test]
8628    fn fonte_caminho_absolute_fires_before_control_char() {
8629        // Cascade pin on the sibling leading-byte arm: a leading `/`
8630        // value with embedded control byte (`"/etc/passwd\n"`) routes
8631        // through `FonteCaminhoAbsolute` not `FonteCaminhoControlChar`
8632        // — the host-layout-leak diagnostic is the load-bearing axis,
8633        // the control byte is the secondary observation. Same precedence
8634        // logic on every prior leading-byte arm.
8635        let d = dep_with_fonte(DepSource::Path {
8636            caminho: "/etc/passwd\n".into(),
8637        });
8638        let err = d.validate().unwrap_err();
8639        assert!(
8640            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
8641            "got {err:?}",
8642        );
8643    }
8644
8645    #[test]
8646    fn validate_rejects_path_fonte_with_leading_hyphen_caminho() {
8647        // The fail-before-pass-after pin for the leading-`-` CLI-arg-
8648        // injection `:caminho` shape sweep. Until this gate landed
8649        // every prior leading-byte arm passed a leading-`-` value
8650        // through: `Path::is_absolute` returns false on `-` (the
8651        // leading byte is `0x2D`, not `0x2F`), `starts_with('~')` /
8652        // `starts_with('$')` / `starts_with(' ')` all return false,
8653        // and `0x2D` sits outside the control-byte set. The lacre
8654        // embedded the value verbatim and the resolver folded it
8655        // through `Path::join` looking for a literal `./-rf` /
8656        // `./-C` / `./--upload-pack=…` subdirectory; the failure at
8657        // `Path::join` time is non-self-locating but harmless, while
8658        // the failure at every downstream `git -C {caminho}` /
8659        // `terraform -chdir={caminho}` / `find {caminho}` shell-out
8660        // is arbitrary-CLI-arg-injection because none of those
8661        // porcelains carry a `--` argument-list terminator between
8662        // the flag block and the path argument. The new arm moves the
8663        // rejection to `Caixa::from_lisp` boundary time and names
8664        // the offending dep + caminho verbatim.
8665        //
8666        // Sweep spans the canonical CLI-arg-injection shapes matching
8667        // the peer sweep on the sibling `is_git_ref_name` /
8668        // `is_git_repo_url` axes: short-flag `-rf` (the `rm -rf` /
8669        // `find -rf` reinterpretation vector), `-C` (the `git -C`
8670        // change-directory-config-injection paste), long-flag
8671        // `--upload-pack=cat /etc/passwd` (the canonical
8672        // arbitrary-command-execution vector on every git porcelain
8673        // entry point), git-config-injection `--config=core.merge=ours`,
8674        // and the degenerate single-byte `-` value.
8675        for caminho in [
8676            "-rf",
8677            "-C",
8678            "--upload-pack=cat /etc/passwd",
8679            "--config=core.merge=ours",
8680            "-",
8681        ] {
8682            let d = dep_with_fonte(DepSource::Path {
8683                caminho: caminho.into(),
8684            });
8685            let err = d.validate().unwrap_err();
8686            let DepError::FonteCaminhoLeadingHyphen { nome, caminho: got } = err else {
8687                panic!("expected FonteCaminhoLeadingHyphen for {caminho:?}, got {err:?}");
8688            };
8689            assert_eq!(nome, "caixa-teia");
8690            assert_eq!(got, caminho);
8691        }
8692    }
8693
8694    #[test]
8695    fn validate_accepts_path_fonte_with_mid_path_hyphen_caminho() {
8696        // The leading-`-` is the canonical CLI-arg-injection footgun
8697        // — a `-` anywhere else in the path (`"../caixa-teia"` — the
8698        // canonical kebab-separator-between-alphanumeric-segments
8699        // shape every DNS-1123-shaped caixa name carries; `"../-hidden"`
8700        // — a mid-path segment starting with `-`, still a legitimate
8701        // POSIX filename byte at that non-leading position because the
8702        // subprocess reads the whole `{caminho}` value as one positional
8703        // argument, so only the very first byte of the composite path
8704        // string is at the CLI-arg-injection boundary) is a legitimate
8705        // path with no CLI-flag-reinterpretation semantic at the non-
8706        // leading position of the top-level value. Pinned so the gate
8707        // doesn't widen to a full no-`-`-anywhere sweep that would
8708        // break every legitimate-shape kebab-in-filename path (i.e.
8709        // essentially every sibling-workspace caixa dep).
8710        for caminho in [
8711            "../caixa-teia",
8712            "../caixa-teia/-hidden",
8713            "./my-lib",
8714            "../foo-bar/baz",
8715        ] {
8716            let d = dep_with_fonte(DepSource::Path {
8717                caminho: caminho.into(),
8718            });
8719            d.validate()
8720                .unwrap_or_else(|e| panic!("mid-path `-` caminho {caminho:?} must pass: {e:?}"));
8721        }
8722    }
8723
8724    #[test]
8725    fn fonte_caminho_leading_whitespace_fires_before_leading_hyphen() {
8726        // Cascade pin: the leading-whitespace arm structurally precedes
8727        // the leading-hyphen arm. A value like `" -rf"` probes positive
8728        // on both (leading space AND, one byte in, a `-` — though the
8729        // leading-hyphen arm probes only the very first byte so it
8730        // wouldn't fire on this value; the pin instead documents the
8731        // arm order on the more common "leading space then a hyphen"
8732        // paste-from-aligned-doc paste-flag-shell-one-liner idiom).
8733        // The narrower leading-space diagnostic (the paste-from-aligned-
8734        // doc footgun) wins so the author sees the more self-locating
8735        // whitespace arm first. Mirrors the
8736        // `fonte_caminho_var_fires_before_leading_whitespace` cascade
8737        // discipline on the immediate-predecessor arm.
8738        let d = dep_with_fonte(DepSource::Path {
8739            caminho: " -rf".into(),
8740        });
8741        let err = d.validate().unwrap_err();
8742        assert!(
8743            matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
8744            "got {err:?}",
8745        );
8746    }
8747
8748    #[test]
8749    fn fonte_caminho_leading_hyphen_fires_before_control_char() {
8750        // Cascade pin: the leading-hyphen arm structurally precedes
8751        // the control-char arm. A value like `"-rf\n"` probes positive
8752        // on both (starts with `-` AND contains LF), but the narrower
8753        // leading-byte diagnostic (`FonteCaminhoLeadingHyphen`) wins so
8754        // the author sees the more self-locating CLI-arg-injection arm
8755        // first. Mirrors the
8756        // `fonte_caminho_leading_whitespace_fires_before_control_char`
8757        // cascade discipline on the immediate-predecessor arm.
8758        let d = dep_with_fonte(DepSource::Path {
8759            caminho: "-rf\n".into(),
8760        });
8761        let err = d.validate().unwrap_err();
8762        assert!(
8763            matches!(err, DepError::FonteCaminhoLeadingHyphen { .. }),
8764            "got {err:?}",
8765        );
8766    }
8767
8768    #[test]
8769    fn fonte_caminho_leading_hyphen_diagnostic_carries_offending_dep_and_caminho() {
8770        // Diagnostic-shape pin (peer with
8771        // `fonte_caminho_leading_whitespace_diagnostic_carries_offending_dep_and_caminho`'s
8772        // payload assertion on the immediate-predecessor arm): the
8773        // error's Display surfaces both the offending `:nome` and the
8774        // offending `:caminho` verbatim plus the CLI-argument-injection
8775        // vocabulary, so a `feira lint` run can render the diagnostic
8776        // without re-parsing and the author can grep their caixa.lisp
8777        // for `:caminho "<value>"` and fix it in one edit.
8778        let d = dep_with_fonte(DepSource::Path {
8779            caminho: "--upload-pack=cat /etc/passwd".into(),
8780        });
8781        let rendered = d.validate().unwrap_err().to_string();
8782        assert!(
8783            rendered.contains("caixa-teia"),
8784            "diagnostic must name the offending dep: {rendered}",
8785        );
8786        assert!(
8787            rendered.contains("--upload-pack=cat /etc/passwd"),
8788            "diagnostic must quote the offending caminho: {rendered}",
8789        );
8790        assert!(
8791            rendered.contains("CLI-argument-injection"),
8792            "diagnostic must name the CLI-argument-injection vector: {rendered}",
8793        );
8794        assert!(
8795            rendered.contains("`-`"),
8796            "diagnostic must name the offending byte: {rendered}",
8797        );
8798    }
8799
8800    #[test]
8801    fn fonte_caminho_control_diagnostic_carries_offending_dep_caminho_byte() {
8802        // Diagnostic-shape pin (peer with
8803        // `fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho`'s
8804        // payload assertion on the immediate-predecessor arm): the
8805        // error's Display surfaces the offending `:nome`, the
8806        // offending `:caminho` verbatim, and the offending byte in
8807        // hex form (`0x09` for tab) so a `feira lint` run can render
8808        // the diagnostic without re-parsing.
8809        let d = dep_with_fonte(DepSource::Path {
8810            caminho: "../caixa\tteia".into(),
8811        });
8812        let rendered = d.validate().unwrap_err().to_string();
8813        assert!(
8814            rendered.contains("caixa-teia"),
8815            "diagnostic must name the offending dep: {rendered}",
8816        );
8817        assert!(
8818            rendered.contains("../caixa\tteia"),
8819            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
8820        );
8821        assert!(
8822            rendered.contains("0x09"),
8823            "diagnostic must name the offending byte in hex: {rendered:?}",
8824        );
8825    }
8826
8827    #[test]
8828    fn validate_rejects_path_fonte_with_caminho_carrying_backslash() {
8829        // The fail-before-pass-after pin for the canonical Windows-
8830        // path-separator paste footgun: an author who pastes a path
8831        // from Windows-Explorer's `Copy as path`, PowerShell's
8832        // `Get-Location`, or any CMD/Cygwin/MSYS shell prompt
8833        // produces `..\caixa-teia`-shape values that silently passed
8834        // every prior arm (`Path::is_absolute("..\\caixa-teia")` is
8835        // false; `\` is neither a leading-byte sentinel nor a
8836        // control byte). On POSIX resolvers the value rides through
8837        // `Path::join` as a literal directory name and fails at
8838        // resolve time with `No such file or directory`; on Windows
8839        // resolvers the value resolves to the parent's sibling — two
8840        // distinct directories for the byte-identical caixa.lisp.
8841        // The new arm moves the rejection to validate time and names
8842        // the offending dep + caminho verbatim.
8843        let d = dep_with_fonte(DepSource::Path {
8844            caminho: "..\\caixa-teia".into(),
8845        });
8846        let err = d.validate().unwrap_err();
8847        let DepError::FonteCaminhoBackslash { nome, caminho } = err else {
8848            panic!("expected FonteCaminhoBackslash, got {err:?}");
8849        };
8850        assert_eq!(nome, "caixa-teia");
8851        assert_eq!(caminho, "..\\caixa-teia");
8852    }
8853
8854    #[test]
8855    fn validate_rejects_path_fonte_with_caminho_carrying_windows_drive_letter() {
8856        // The Windows drive-letter paste shape (`C:\work\caixa-teia`
8857        // out of Explorer / `cd`-and-`pwd`-on-Windows). On POSIX
8858        // hosts `Path::is_absolute("C:\\work\\caixa-teia")` returns
8859        // false (POSIX absolute paths start with `/`, drive letters
8860        // are not a POSIX concept), so the b94fd83 absolute arm
8861        // doesn't fire; the value contains `\` bytes that this arm
8862        // now catches with the more self-locating Windows-path-
8863        // separator diagnostic. Pinned separately from the bare
8864        // `..\caixa-teia` shape so a future arm that targets only
8865        // leading-`..\` doesn't regress the drive-letter coverage.
8866        let d = dep_with_fonte(DepSource::Path {
8867            caminho: "C:\\work\\caixa-teia".into(),
8868        });
8869        let err = d.validate().unwrap_err();
8870        assert!(
8871            matches!(err, DepError::FonteCaminhoBackslash { .. }),
8872            "got {err:?}",
8873        );
8874    }
8875
8876    #[test]
8877    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_backslash() {
8878        // The trailing-`\` shape (`..\caixa-teia\` — the canonical
8879        // PowerShell tab-completion-on-a-directory append). Pinned
8880        // separately from the embedded-`\` shape so the gate's
8881        // contract is "any `\` anywhere", not "any `\` not at end".
8882        let d = dep_with_fonte(DepSource::Path {
8883            caminho: "..\\caixa-teia\\".into(),
8884        });
8885        let err = d.validate().unwrap_err();
8886        assert!(
8887            matches!(err, DepError::FonteCaminhoBackslash { .. }),
8888            "got {err:?}",
8889        );
8890    }
8891
8892    #[test]
8893    fn validate_accepts_path_fonte_with_caminho_carrying_legitimate_forward_slash() {
8894        // The positive-control pin: the gate targets `\` only,
8895        // never `/`. The canonical relative POSIX path
8896        // (`../caixa-teia/foo/bar`) must continue to validate cleanly
8897        // so legitimate nested-directory deps aren't broken. Pinned
8898        // so the gate doesn't accidentally widen to a "no path
8899        // separators at all" sweep.
8900        let d = dep_with_fonte(DepSource::Path {
8901            caminho: "../caixa-teia/foo/bar".into(),
8902        });
8903        d.validate().unwrap();
8904    }
8905
8906    #[test]
8907    fn fonte_caminho_control_char_fires_before_backslash() {
8908        // Cascade pin: the control-char arm structurally precedes the
8909        // backslash arm. A value like `"..\caixa\0teia"` probes
8910        // positive on both (`\` byte + NUL byte), but the control-
8911        // char diagnostic wins so the author sees the more self-
8912        // locating POSIX-syscall-rejected-byte diagnostic first
8913        // (NUL outright breaks `CString::new` at every `std::fs`
8914        // syscall boundary; the `\` divergence is the cross-OS-
8915        // separator axis). Mirrors the
8916        // `fonte_caminho_var_fires_before_control_char` cascade
8917        // discipline on the immediate-predecessor arm.
8918        let d = dep_with_fonte(DepSource::Path {
8919            caminho: "..\\caixa\0teia".into(),
8920        });
8921        let err = d.validate().unwrap_err();
8922        assert!(
8923            matches!(err, DepError::FonteCaminhoControlChar { .. }),
8924            "got {err:?}",
8925        );
8926    }
8927
8928    #[test]
8929    fn fonte_caminho_absolute_fires_before_backslash() {
8930        // Cascade pin on the load-bearing leading-byte arm: a leading
8931        // `/` value with embedded `\` (`/etc/passwd\foo`) routes
8932        // through `FonteCaminhoAbsolute` not `FonteCaminhoBackslash`
8933        // — the host-layout-leak diagnostic is the load-bearing
8934        // axis, the `\` byte is the secondary observation. Same
8935        // precedence logic as every prior leading-byte arm.
8936        let d = dep_with_fonte(DepSource::Path {
8937            caminho: "/etc/passwd\\foo".into(),
8938        });
8939        let err = d.validate().unwrap_err();
8940        assert!(
8941            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
8942            "got {err:?}",
8943        );
8944    }
8945
8946    #[test]
8947    fn fonte_caminho_var_fires_before_backslash() {
8948        // Cascade pin on the var-expansion arm: a leading-`$` value
8949        // with embedded `\` (`$WORKSPACE\caixa-teia` — the canonical
8950        // PowerShell-env-var paste-from-CI-manifest footgun) routes
8951        // through `FonteCaminhoVarExpansion` not `FonteCaminhoBackslash`.
8952        // The shell-expansion diagnostic is the more self-locating
8953        // axis since both the leading `$` and the embedded `\`
8954        // are Windows-shell artifacts but the `$` is the root-cause
8955        // surface (an author who removes the `$` is likely to leave
8956        // the `\` too).
8957        let d = dep_with_fonte(DepSource::Path {
8958            caminho: "$WORKSPACE\\caixa-teia".into(),
8959        });
8960        let err = d.validate().unwrap_err();
8961        assert!(
8962            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
8963            "got {err:?}",
8964        );
8965    }
8966
8967    #[test]
8968    fn fonte_caminho_backslash_diagnostic_carries_offending_dep_and_caminho() {
8969        // Diagnostic-shape pin (peer with the prior
8970        // `fonte_caminho_*_diagnostic_carries_*` payload assertions
8971        // on every preceding arm): the error's Display surfaces the
8972        // offending `:nome` and the offending `:caminho` verbatim
8973        // so a `feira lint` run can render the diagnostic without
8974        // re-parsing.
8975        let d = dep_with_fonte(DepSource::Path {
8976            caminho: "..\\caixa-teia".into(),
8977        });
8978        let rendered = d.validate().unwrap_err().to_string();
8979        assert!(
8980            rendered.contains("caixa-teia"),
8981            "diagnostic must name the offending dep: {rendered}",
8982        );
8983        assert!(
8984            rendered.contains("..\\caixa-teia"),
8985            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
8986        );
8987        assert!(
8988            rendered.contains('\\'),
8989            "diagnostic must reference the backslash footgun: {rendered:?}",
8990        );
8991    }
8992
8993    #[test]
8994    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_slash() {
8995        // The fail-before-pass-after pin for the canonical trailing-`/`
8996        // paste footgun: an author who shell-tab-completes a sibling
8997        // directory (every interactive shell — bash/zsh/fish/nushell —
8998        // appends `/` on tab-completing a directory) produces
8999        // `"../caixa-teia/"`-shape values that silently passed every
9000        // prior arm (the leading byte is `.`, no control bytes, no
9001        // backslash). `Path::join` resolves both shapes to the same
9002        // directory at the resolver, but the lacre embeds the value
9003        // verbatim and the BLAKE3 closures diverge across two
9004        // workstations whose authors differ only in tab-completion
9005        // habits.
9006        let d = dep_with_fonte(DepSource::Path {
9007            caminho: "../caixa-teia/".into(),
9008        });
9009        let err = d.validate().unwrap_err();
9010        let DepError::FonteCaminhoTrailingSlash { nome, caminho } = err else {
9011            panic!("expected FonteCaminhoTrailingSlash, got {err:?}");
9012        };
9013        assert_eq!(nome, "caixa-teia");
9014        assert_eq!(caminho, "../caixa-teia/");
9015    }
9016
9017    #[test]
9018    fn validate_rejects_path_fonte_with_caminho_carrying_bare_dot_slash() {
9019        // The `"./"` shape (the canonical "I meant the caixa.lisp's own
9020        // directory and tab-completed it" footgun). Pinned separately
9021        // from the canonical `"../caixa-teia/"` shape so the gate's
9022        // contract is "any trailing `/`", not "trailing `/` after a leaf
9023        // name".
9024        let d = dep_with_fonte(DepSource::Path {
9025            caminho: "./".into(),
9026        });
9027        let err = d.validate().unwrap_err();
9028        assert!(
9029            matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
9030            "got {err:?}",
9031        );
9032    }
9033
9034    #[test]
9035    fn validate_rejects_path_fonte_with_caminho_carrying_consecutive_trailing_slashes() {
9036        // The `"foo//"` shape (the canonical "I pasted from a CI manifest
9037        // that double-templated `${VAR}/` over an already-`/`-suffixed
9038        // path" footgun). The gate fires on the last byte being `/`
9039        // regardless of how many `/` precede it; the arm contract is
9040        // "the value ends with `/`", structurally.
9041        let d = dep_with_fonte(DepSource::Path {
9042            caminho: "../caixa-teia//".into(),
9043        });
9044        let err = d.validate().unwrap_err();
9045        assert!(
9046            matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
9047            "got {err:?}",
9048        );
9049    }
9050
9051    #[test]
9052    fn validate_rejects_path_fonte_with_caminho_carrying_dotdot_trailing_slash() {
9053        // The `"../"` shape (the canonical "I want the parent" tab-
9054        // completion footgun on a bare `..` path). Pinned separately so
9055        // the gate doesn't accidentally narrow to "trailing `/` only on
9056        // multi-segment paths".
9057        let d = dep_with_fonte(DepSource::Path {
9058            caminho: "../".into(),
9059        });
9060        let err = d.validate().unwrap_err();
9061        assert!(
9062            matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
9063            "got {err:?}",
9064        );
9065    }
9066
9067    #[test]
9068    fn validate_accepts_path_fonte_with_caminho_carrying_internal_slashes() {
9069        // The positive-control pin: the gate targets the trailing byte
9070        // only, never internal `/` separators. The canonical nested
9071        // relative POSIX path (`"../caixa-teia/foo/bar"`) must continue
9072        // to validate cleanly so legitimate deeply-nested deps aren't
9073        // broken. Pinned so the gate doesn't accidentally widen to a
9074        // "no `/` separators anywhere" sweep that would defeat the
9075        // entire path-fonte author surface.
9076        let d = dep_with_fonte(DepSource::Path {
9077            caminho: "../caixa-teia/foo/bar".into(),
9078        });
9079        d.validate().unwrap();
9080    }
9081
9082    #[test]
9083    fn validate_accepts_path_fonte_with_caminho_carrying_bare_dot() {
9084        // The positive-control pin on the degenerate single-`.` shape
9085        // (the canonical "the caixa.lisp's own directory" idiom). The
9086        // gate fires on the trailing byte being `/`, not on the path
9087        // being short, so `"."` (one byte, not `/`) must continue to
9088        // validate cleanly.
9089        let d = dep_with_fonte(DepSource::Path {
9090            caminho: ".".into(),
9091        });
9092        d.validate().unwrap();
9093    }
9094
9095    #[test]
9096    fn fonte_caminho_control_char_fires_before_trailing_slash() {
9097        // Cascade pin: the control-char arm structurally precedes the
9098        // trailing-slash arm. A value like `"../foo\n/"` ends in `/`
9099        // but the embedded LF (`0x0A`) is the load-bearing diagnostic
9100        // (control bytes are the paste-from-multiline-doc footgun the
9101        // d624c8d arm already closes). Mirrors the
9102        // `fonte_caminho_control_char_fires_before_backslash` cascade
9103        // discipline on the immediate-predecessor arm.
9104        let d = dep_with_fonte(DepSource::Path {
9105            caminho: "../foo\n/".into(),
9106        });
9107        let err = d.validate().unwrap_err();
9108        assert!(
9109            matches!(err, DepError::FonteCaminhoControlChar { .. }),
9110            "got {err:?}",
9111        );
9112    }
9113
9114    #[test]
9115    fn fonte_caminho_backslash_fires_before_trailing_slash() {
9116        // Cascade pin on the backslash arm: a value like `"..\foo/"`
9117        // ends in `/` but the embedded `\` is the load-bearing
9118        // diagnostic (the cross-host-OS-separator divergence vector
9119        // the 3a4e1d7 arm closes). Same precedence logic as the prior
9120        // narrower-diagnostic-first cascade.
9121        let d = dep_with_fonte(DepSource::Path {
9122            caminho: "..\\caixa-teia/".into(),
9123        });
9124        let err = d.validate().unwrap_err();
9125        assert!(
9126            matches!(err, DepError::FonteCaminhoBackslash { .. }),
9127            "got {err:?}",
9128        );
9129    }
9130
9131    #[test]
9132    fn fonte_caminho_absolute_fires_before_trailing_slash() {
9133        // Cascade pin on the load-bearing leading-byte arm: a leading
9134        // `/` value with a trailing `/` (`"/etc/passwd/"`) routes
9135        // through `FonteCaminhoAbsolute` not `FonteCaminhoTrailingSlash`
9136        // — the host-layout-leak diagnostic is the load-bearing axis,
9137        // the trailing `/` is the secondary observation. Same
9138        // precedence logic as every prior leading-byte arm.
9139        let d = dep_with_fonte(DepSource::Path {
9140            caminho: "/etc/passwd/".into(),
9141        });
9142        let err = d.validate().unwrap_err();
9143        assert!(
9144            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
9145            "got {err:?}",
9146        );
9147    }
9148
9149    #[test]
9150    fn fonte_caminho_trailing_slash_diagnostic_carries_offending_dep_and_caminho() {
9151        // Diagnostic-shape pin (peer with the prior
9152        // `fonte_caminho_*_diagnostic_carries_*` payload assertions on
9153        // every preceding arm): the error's Display surfaces the
9154        // offending `:nome` and the offending `:caminho` verbatim so a
9155        // `feira lint` run can render the diagnostic without re-parsing.
9156        let d = dep_with_fonte(DepSource::Path {
9157            caminho: "../caixa-teia/".into(),
9158        });
9159        let rendered = d.validate().unwrap_err().to_string();
9160        assert!(
9161            rendered.contains("caixa-teia"),
9162            "diagnostic must name the offending dep: {rendered}",
9163        );
9164        assert!(
9165            rendered.contains("../caixa-teia/"),
9166            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
9167        );
9168        assert!(
9169            rendered.contains("trailing"),
9170            "diagnostic must reference the trailing-slash footgun: {rendered:?}",
9171        );
9172    }
9173
9174    // -- :caminho shell-redirection metacharacter arm -----------------------
9175
9176    #[test]
9177    fn validate_rejects_path_fonte_with_caminho_carrying_gt_redirection() {
9178        // The fail-before-pass-after pin for the canonical output-redirection
9179        // paste footgun: an author copies a shell pipeline tail
9180        // (`"../caixa-teia>build.log"` — the canonical "I selected the whole
9181        // line including the `> build.log` redirect" idiom) and silently
9182        // passed every prior arm (`Path::is_absolute` false on `..`, no
9183        // control bytes, no backslash, doesn't end in `/`). The lacre
9184        // embedded the value verbatim, the resolver folded it through
9185        // `Path::join` looking for a literal `./../caixa-teia>build.log`
9186        // subdirectory, and the failure surfaced at resolve time with a
9187        // non-self-locating `No such file or directory` error. The new arm
9188        // moves the rejection to validate time and names the offending dep
9189        // + caminho + byte verbatim.
9190        let d = dep_with_fonte(DepSource::Path {
9191            caminho: "../caixa-teia>build.log".into(),
9192        });
9193        let err = d.validate().unwrap_err();
9194        let DepError::FonteCaminhoShellRedirection {
9195            nome,
9196            caminho,
9197            byte,
9198        } = err
9199        else {
9200            panic!("expected FonteCaminhoShellRedirection, got {err:?}");
9201        };
9202        assert_eq!(nome, "caixa-teia");
9203        assert_eq!(caminho, "../caixa-teia>build.log");
9204        assert_eq!(byte, b'>');
9205    }
9206
9207    #[test]
9208    fn validate_rejects_path_fonte_with_caminho_carrying_lt_redirection() {
9209        // The symmetric input-redirection paste shape
9210        // (`"../caixa-teia<input.lisp"` — the canonical "I copied a
9211        // `command < input.lisp` line from a tatara-lisp REPL log"
9212        // idiom). Pinned separately from the `>` shape so the gate's
9213        // contract is "any `<` or `>` anywhere", not single-byte coverage.
9214        let d = dep_with_fonte(DepSource::Path {
9215            caminho: "../caixa-teia<input.lisp".into(),
9216        });
9217        let err = d.validate().unwrap_err();
9218        let DepError::FonteCaminhoShellRedirection { byte, .. } = err else {
9219            panic!("expected FonteCaminhoShellRedirection, got {err:?}");
9220        };
9221        assert_eq!(byte, b'<');
9222    }
9223
9224    #[test]
9225    fn validate_rejects_path_fonte_with_caminho_carrying_leading_gt_redirection() {
9226        // Leading-position `>` shape (`">../caixa-teia"` — the degenerate
9227        // "I forgot the source side of the redirect" idiom). Pinned
9228        // separately from the embedded-byte shapes so the gate covers
9229        // every position, not only mid-path.
9230        let d = dep_with_fonte(DepSource::Path {
9231            caminho: ">../caixa-teia".into(),
9232        });
9233        let err = d.validate().unwrap_err();
9234        assert!(
9235            matches!(
9236                err,
9237                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
9238            ),
9239            "got {err:?}",
9240        );
9241    }
9242
9243    #[test]
9244    fn validate_rejects_path_fonte_with_caminho_carrying_double_gt_append() {
9245        // The bash append-redirection shape (`"../caixa-teia>>build.log"` —
9246        // the canonical "I copied a `>>` append redirect" idiom). The arm
9247        // fires on the first `>` encountered; pinned so a future arm that
9248        // tries to distinguish `>` from `>>` doesn't break the broader
9249        // contract.
9250        let d = dep_with_fonte(DepSource::Path {
9251            caminho: "../caixa-teia>>build.log".into(),
9252        });
9253        let err = d.validate().unwrap_err();
9254        assert!(
9255            matches!(
9256                err,
9257                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
9258            ),
9259            "got {err:?}",
9260        );
9261    }
9262
9263    #[test]
9264    fn validate_accepts_path_fonte_with_caminho_carrying_no_redirection() {
9265        // The positive-control pin: the gate targets only `<` / `>`,
9266        // never adjacent printable ASCII or POSIX-valid bytes. The
9267        // canonical relative POSIX path (`"../caixa-teia"`) and a
9268        // nested deeply-pathed variant (`"../caixa-teia/foo/bar"`) must
9269        // continue to validate cleanly so the gate doesn't widen to a
9270        // "no printable punctuation anywhere" sweep that would defeat
9271        // the entire path-fonte author surface.
9272        let d = dep_with_fonte(DepSource::Path {
9273            caminho: "../caixa-teia/foo/bar".into(),
9274        });
9275        d.validate().unwrap();
9276    }
9277
9278    #[test]
9279    fn fonte_caminho_backslash_fires_before_shell_redirection() {
9280        // Cascade pin on the immediate-predecessor arm: a value carrying
9281        // both `\` and `<` / `>` (`"..\caixa-teia>build.log"` — the
9282        // canonical "I pasted a Windows-shell command with output
9283        // redirect" footgun) routes through `FonteCaminhoBackslash` not
9284        // `FonteCaminhoShellRedirection`. The cross-host-OS-separator
9285        // divergence is the load-bearing axis (an author who removes
9286        // the `\` is the root-cause edit; the `>` falls away in the
9287        // same edit since it's downstream of the Windows-shell
9288        // convention).
9289        let d = dep_with_fonte(DepSource::Path {
9290            caminho: "..\\caixa-teia>build.log".into(),
9291        });
9292        let err = d.validate().unwrap_err();
9293        assert!(
9294            matches!(err, DepError::FonteCaminhoBackslash { .. }),
9295            "got {err:?}",
9296        );
9297    }
9298
9299    #[test]
9300    fn fonte_caminho_control_char_fires_before_shell_redirection() {
9301        // Cascade pin on the embedded-control-byte arm: a value carrying
9302        // both a control byte and `<` / `>` (`"../foo\n>bar"` — the
9303        // canonical paste-from-multiline-doc footgun where a newline
9304        // landed mid-caminho) routes through `FonteCaminhoControlChar`
9305        // not `FonteCaminhoShellRedirection`. The POSIX-syscall-
9306        // rejected-byte / NUL-`CString::new`-fail diagnostic is the
9307        // load-bearing axis on every value that probes positive for
9308        // both — mirrors the cascade discipline on every prior arm.
9309        let d = dep_with_fonte(DepSource::Path {
9310            caminho: "../foo\n>bar".into(),
9311        });
9312        let err = d.validate().unwrap_err();
9313        assert!(
9314            matches!(err, DepError::FonteCaminhoControlChar { .. }),
9315            "got {err:?}",
9316        );
9317    }
9318
9319    #[test]
9320    fn fonte_caminho_absolute_fires_before_shell_redirection() {
9321        // Cascade pin on the load-bearing leading-byte arm: a leading
9322        // `/` value with embedded `<` / `>` (`"/etc/passwd>out"`)
9323        // routes through `FonteCaminhoAbsolute` not
9324        // `FonteCaminhoShellRedirection` — the host-layout-leak
9325        // diagnostic is the load-bearing axis, the `>` byte is the
9326        // secondary observation. Same precedence logic as every prior
9327        // leading-byte arm.
9328        let d = dep_with_fonte(DepSource::Path {
9329            caminho: "/etc/passwd>out".into(),
9330        });
9331        let err = d.validate().unwrap_err();
9332        assert!(
9333            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
9334            "got {err:?}",
9335        );
9336    }
9337
9338    #[test]
9339    fn fonte_caminho_shell_redirection_fires_before_trailing_slash() {
9340        // Cascade pin on the immediate-successor arm: a value carrying
9341        // both `<` / `>` and a trailing `/` (`"../foo></"` — the
9342        // canonical "I tab-completed a path that already had a
9343        // redirect" footgun) routes through `FonteCaminhoShellRedirection`
9344        // not `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
9345        // the more semantic-locating axis (an author who removes the
9346        // `<` / `>` typically also drops the trailing separator since
9347        // both are paste-from-shell artifacts).
9348        let d = dep_with_fonte(DepSource::Path {
9349            caminho: "../foo></".into(),
9350        });
9351        let err = d.validate().unwrap_err();
9352        assert!(
9353            matches!(
9354                err,
9355                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
9356            ),
9357            "got {err:?}",
9358        );
9359    }
9360
9361    #[test]
9362    fn fonte_caminho_shell_redirection_diagnostic_carries_offending_dep_caminho_byte() {
9363        // Diagnostic-shape pin (peer with
9364        // `fonte_caminho_control_diagnostic_carries_offending_dep_caminho_byte`'s
9365        // payload assertion on the closest peer arm that also carries a
9366        // `byte` field): the error's Display surfaces the offending
9367        // `:nome`, the offending `:caminho` verbatim, and the offending
9368        // byte in hex (`0x3c` for `<`, `0x3e` for `>`) so a `feira lint`
9369        // run can render the diagnostic without re-parsing.
9370        let d = dep_with_fonte(DepSource::Path {
9371            caminho: "../caixa-teia>build.log".into(),
9372        });
9373        let rendered = d.validate().unwrap_err().to_string();
9374        assert!(
9375            rendered.contains("caixa-teia"),
9376            "diagnostic must name the offending dep: {rendered}",
9377        );
9378        assert!(
9379            rendered.contains("../caixa-teia>build.log"),
9380            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
9381        );
9382        assert!(
9383            rendered.contains("0x3e"),
9384            "diagnostic must name the offending byte in hex: {rendered:?}",
9385        );
9386        assert!(
9387            rendered.contains("redirection"),
9388            "diagnostic must name the shell-redirection footgun: {rendered:?}",
9389        );
9390    }
9391
9392    // -- :caminho shell-pipe metacharacter arm ----------------------------
9393
9394    #[test]
9395    fn validate_rejects_path_fonte_with_caminho_carrying_pipe() {
9396        // The fail-before-pass-after pin for the canonical shell-pipe
9397        // paste footgun: an author copies a shell-history line
9398        // (`"../caixa-teia | grep foo"` — the canonical "I selected
9399        // the whole `ls dir | grep` line out of zsh history") and
9400        // silently passed every prior arm (`Path::is_absolute` false
9401        // on `..`, no control bytes, no backslash, no `<` / `>`,
9402        // doesn't end in `/`). The lacre embedded the value verbatim,
9403        // the resolver folded it through `Path::join` looking for a
9404        // literal `./../caixa-teia | grep foo` subdirectory, and the
9405        // failure surfaced at resolve time with a non-self-locating
9406        // `No such file or directory` error. The new arm moves the
9407        // rejection to validate time and names the offending dep +
9408        // caminho verbatim.
9409        let d = dep_with_fonte(DepSource::Path {
9410            caminho: "../caixa-teia | grep foo".into(),
9411        });
9412        let err = d.validate().unwrap_err();
9413        let DepError::FonteCaminhoShellPipe { nome, caminho } = err else {
9414            panic!("expected FonteCaminhoShellPipe, got {err:?}");
9415        };
9416        assert_eq!(nome, "caixa-teia");
9417        assert_eq!(caminho, "../caixa-teia | grep foo");
9418    }
9419
9420    #[test]
9421    fn validate_rejects_path_fonte_with_caminho_carrying_leading_pipe() {
9422        // Leading-position `|` shape (`"|../caixa-teia"` — the
9423        // degenerate "I forgot the source side of the pipe" idiom).
9424        // Pinned separately from the embedded-byte shape so the gate
9425        // covers every position, not only mid-path.
9426        let d = dep_with_fonte(DepSource::Path {
9427            caminho: "|../caixa-teia".into(),
9428        });
9429        let err = d.validate().unwrap_err();
9430        assert!(
9431            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
9432            "got {err:?}",
9433        );
9434    }
9435
9436    #[test]
9437    fn validate_rejects_path_fonte_with_caminho_carrying_double_pipe_or() {
9438        // The bash short-circuit-OR shape (`"../caixa-teia||fallback"`
9439        // — the canonical "I copied a `cmd-a || cmd-b` fallback line"
9440        // idiom). The arm fires on the first `|` encountered; pinned
9441        // so a future arm that tries to distinguish `|` from `||`
9442        // doesn't break the broader contract.
9443        let d = dep_with_fonte(DepSource::Path {
9444            caminho: "../caixa-teia||fallback".into(),
9445        });
9446        let err = d.validate().unwrap_err();
9447        assert!(
9448            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
9449            "got {err:?}",
9450        );
9451    }
9452
9453    #[test]
9454    fn validate_accepts_path_fonte_with_caminho_carrying_no_pipe() {
9455        // The positive-control pin: the gate targets only `|`, never
9456        // adjacent printable ASCII or POSIX-valid bytes. The canonical
9457        // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
9458        // pathed variant with adjacent printable punctuation
9459        // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
9460        // cleanly so the gate doesn't widen to a "no printable
9461        // punctuation anywhere" sweep that would defeat the entire
9462        // path-fonte author surface.
9463        let d = dep_with_fonte(DepSource::Path {
9464            caminho: "../caixa-teia/sub-dir.v2".into(),
9465        });
9466        d.validate().unwrap();
9467    }
9468
9469    #[test]
9470    fn fonte_caminho_shell_redirection_fires_before_shell_pipe() {
9471        // Cascade pin on the immediate-predecessor arm: a value carrying
9472        // both `<` / `>` and `|` (`"../caixa-teia<input|tee"` — the
9473        // canonical "I pasted a `cmd < input | tee` pipeline tail"
9474        // footgun) routes through `FonteCaminhoShellRedirection` not
9475        // `FonteCaminhoShellPipe`. The input/output redirection
9476        // metachar carries the more self-locating `byte: u8` payload
9477        // (it names which of `<` or `>` triggered), so the prior arm
9478        // wins on every probe-as-both value — same cascade discipline
9479        // every prior `:caminho` arm establishes.
9480        let d = dep_with_fonte(DepSource::Path {
9481            caminho: "../caixa-teia<input|tee".into(),
9482        });
9483        let err = d.validate().unwrap_err();
9484        assert!(
9485            matches!(
9486                err,
9487                DepError::FonteCaminhoShellRedirection { byte: b'<', .. }
9488            ),
9489            "got {err:?}",
9490        );
9491    }
9492
9493    #[test]
9494    fn fonte_caminho_backslash_fires_before_shell_pipe() {
9495        // Cascade pin on the upstream backslash arm: a value carrying
9496        // both `\` and `|` (`"..\caixa-teia|tee"` — the canonical
9497        // "I pasted a Windows-shell command with pipe to tee"
9498        // footgun) routes through `FonteCaminhoBackslash` not
9499        // `FonteCaminhoShellPipe`. The cross-host-OS-separator
9500        // divergence is the load-bearing axis on every probe-as-both
9501        // value (an author who removes the `\` is the root-cause edit;
9502        // the `|` falls away in the same edit since it's downstream of
9503        // the Windows-shell convention).
9504        let d = dep_with_fonte(DepSource::Path {
9505            caminho: "..\\caixa-teia|tee".into(),
9506        });
9507        let err = d.validate().unwrap_err();
9508        assert!(
9509            matches!(err, DepError::FonteCaminhoBackslash { .. }),
9510            "got {err:?}",
9511        );
9512    }
9513
9514    #[test]
9515    fn fonte_caminho_control_char_fires_before_shell_pipe() {
9516        // Cascade pin on the embedded-control-byte arm: a value
9517        // carrying both a control byte and `|` (`"../foo\n|bar"` —
9518        // the canonical paste-from-multiline-doc footgun where a
9519        // newline landed mid-caminho) routes through
9520        // `FonteCaminhoControlChar` not `FonteCaminhoShellPipe`. The
9521        // POSIX-syscall-rejected-byte / NUL-`CString::new`-fail
9522        // diagnostic is the load-bearing axis on every value that
9523        // probes positive for both — mirrors the cascade discipline
9524        // on every prior arm.
9525        let d = dep_with_fonte(DepSource::Path {
9526            caminho: "../foo\n|bar".into(),
9527        });
9528        let err = d.validate().unwrap_err();
9529        assert!(
9530            matches!(err, DepError::FonteCaminhoControlChar { .. }),
9531            "got {err:?}",
9532        );
9533    }
9534
9535    #[test]
9536    fn fonte_caminho_absolute_fires_before_shell_pipe() {
9537        // Cascade pin on the load-bearing leading-byte arm: a leading
9538        // `/` value with embedded `|` (`"/etc/passwd|tee"`) routes
9539        // through `FonteCaminhoAbsolute` not `FonteCaminhoShellPipe`
9540        // — the host-layout-leak diagnostic is the load-bearing axis,
9541        // the `|` byte is the secondary observation. Same precedence
9542        // logic as every prior leading-byte arm.
9543        let d = dep_with_fonte(DepSource::Path {
9544            caminho: "/etc/passwd|tee".into(),
9545        });
9546        let err = d.validate().unwrap_err();
9547        assert!(
9548            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
9549            "got {err:?}",
9550        );
9551    }
9552
9553    #[test]
9554    fn fonte_caminho_shell_pipe_fires_before_trailing_slash() {
9555        // Cascade pin on the immediate-successor arm: a value carrying
9556        // both `|` and a trailing `/` (`"../foo|tee/"` — the canonical
9557        // "I tab-completed a path that already had a pipeline tail"
9558        // footgun) routes through `FonteCaminhoShellPipe` not
9559        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
9560        // the more semantic-locating axis (an author who removes the
9561        // `|` typically also drops the trailing separator since both
9562        // are paste-from-shell artifacts).
9563        let d = dep_with_fonte(DepSource::Path {
9564            caminho: "../foo|tee/".into(),
9565        });
9566        let err = d.validate().unwrap_err();
9567        assert!(
9568            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
9569            "got {err:?}",
9570        );
9571    }
9572
9573    #[test]
9574    fn fonte_caminho_shell_pipe_diagnostic_carries_offending_dep_and_caminho() {
9575        // Diagnostic-shape pin (peer with
9576        // `fonte_caminho_backslash_diagnostic_carries_offending_dep_and_caminho`
9577        // on the closest single-byte peer arm): the error's Display
9578        // surfaces the offending `:nome` and the offending `:caminho`
9579        // verbatim, and names the shell-pipe footgun explicitly so a
9580        // `feira lint` run can render the diagnostic without
9581        // re-parsing.
9582        let d = dep_with_fonte(DepSource::Path {
9583            caminho: "../caixa-teia | grep foo".into(),
9584        });
9585        let rendered = d.validate().unwrap_err().to_string();
9586        assert!(
9587            rendered.contains("caixa-teia"),
9588            "diagnostic must name the offending dep: {rendered}",
9589        );
9590        assert!(
9591            rendered.contains("../caixa-teia | grep foo"),
9592            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
9593        );
9594        assert!(
9595            rendered.contains('|'),
9596            "diagnostic must reference the pipe footgun: {rendered:?}",
9597        );
9598        assert!(
9599            rendered.contains("pipe"),
9600            "diagnostic must name the shell-pipe footgun: {rendered:?}",
9601        );
9602    }
9603
9604    // -- :caminho shell-command-separator metacharacter arm ---------------
9605
9606    #[test]
9607    fn validate_rejects_path_fonte_with_caminho_carrying_semicolon() {
9608        // The fail-before-pass-after pin for the canonical shell-command-
9609        // separator paste footgun: an author copies a shell one-liner
9610        // (`"../caixa-teia; rm -rf build"` — the canonical "I selected the
9611        // whole `cd path; do-thing` chain out of a shell-history block")
9612        // and silently passed every prior arm (`Path::is_absolute` false
9613        // on `..`, no control bytes, no backslash, no `<` / `>`, no `|`,
9614        // doesn't end in `/`). The lacre embedded the value verbatim, the
9615        // resolver folded it through `Path::join` looking for a literal
9616        // `./../caixa-teia; rm -rf build` subdirectory, and the failure
9617        // surfaced at resolve time with a non-self-locating `No such file
9618        // or directory` error. The new arm moves the rejection to validate
9619        // time and names the offending dep + caminho verbatim.
9620        let d = dep_with_fonte(DepSource::Path {
9621            caminho: "../caixa-teia; rm -rf build".into(),
9622        });
9623        let err = d.validate().unwrap_err();
9624        let DepError::FonteCaminhoShellSemicolon { nome, caminho } = err else {
9625            panic!("expected FonteCaminhoShellSemicolon, got {err:?}");
9626        };
9627        assert_eq!(nome, "caixa-teia");
9628        assert_eq!(caminho, "../caixa-teia; rm -rf build");
9629    }
9630
9631    #[test]
9632    fn validate_rejects_path_fonte_with_caminho_carrying_leading_semicolon() {
9633        // Leading-position `;` shape (`";../caixa-teia"` — the degenerate
9634        // "I forgot the prior command side of the separator" idiom).
9635        // Pinned separately from the embedded-byte shape so the gate
9636        // covers every position, not only mid-path.
9637        let d = dep_with_fonte(DepSource::Path {
9638            caminho: ";../caixa-teia".into(),
9639        });
9640        let err = d.validate().unwrap_err();
9641        assert!(
9642            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
9643            "got {err:?}",
9644        );
9645    }
9646
9647    #[test]
9648    fn validate_rejects_path_fonte_with_caminho_carrying_double_semicolon() {
9649        // The POSIX `case` arm `;;` terminator shape
9650        // (`"../caixa-teia;;next"` — the canonical "I copied a `case`
9651        // arm tail" idiom). The arm fires on the first `;` encountered;
9652        // pinned so a future arm that tries to distinguish `;` from `;;`
9653        // doesn't break the broader contract.
9654        let d = dep_with_fonte(DepSource::Path {
9655            caminho: "../caixa-teia;;next".into(),
9656        });
9657        let err = d.validate().unwrap_err();
9658        assert!(
9659            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
9660            "got {err:?}",
9661        );
9662    }
9663
9664    #[test]
9665    fn validate_accepts_path_fonte_with_caminho_carrying_no_semicolon() {
9666        // The positive-control pin: the gate targets only `;`, never
9667        // adjacent printable ASCII or POSIX-valid bytes. The canonical
9668        // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
9669        // pathed variant with adjacent printable punctuation
9670        // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
9671        // cleanly so the gate doesn't widen to a "no printable
9672        // punctuation anywhere" sweep that would defeat the entire
9673        // path-fonte author surface.
9674        let d = dep_with_fonte(DepSource::Path {
9675            caminho: "../caixa-teia/sub-dir.v2".into(),
9676        });
9677        d.validate().unwrap();
9678    }
9679
9680    #[test]
9681    fn fonte_caminho_shell_pipe_fires_before_shell_semicolon() {
9682        // Cascade pin on the immediate-predecessor arm: a value carrying
9683        // both `|` and `;` (`"../caixa-teia | tee; rm"` — the canonical
9684        // "I pasted a `cmd | tee; cleanup` chain" footgun) routes through
9685        // `FonteCaminhoShellPipe` not `FonteCaminhoShellSemicolon`. The
9686        // pipeline-tail paste is the load-bearing root-cause edit on
9687        // every probe-as-both value (an author who removes the `|`
9688        // typically also drops the trailing `; cleanup` since both are
9689        // the same paste-from-shell-history artifact) — same cascade
9690        // discipline every prior `:caminho` arm establishes.
9691        let d = dep_with_fonte(DepSource::Path {
9692            caminho: "../caixa-teia | tee; rm".into(),
9693        });
9694        let err = d.validate().unwrap_err();
9695        assert!(
9696            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
9697            "got {err:?}",
9698        );
9699    }
9700
9701    #[test]
9702    fn fonte_caminho_shell_redirection_fires_before_shell_semicolon() {
9703        // Cascade pin on the upstream shell-redirection arm: a value
9704        // carrying both `<` / `>` and `;` (`"../caixa-teia>log; rm"` —
9705        // the canonical "I pasted a `cmd > log; cleanup` chain"
9706        // footgun) routes through `FonteCaminhoShellRedirection` not
9707        // `FonteCaminhoShellSemicolon`. The input/output redirection
9708        // metachar carries the more self-locating `byte: u8` payload
9709        // (it names which of `<` or `>` triggered), so the prior arm
9710        // wins on every probe-as-both value.
9711        let d = dep_with_fonte(DepSource::Path {
9712            caminho: "../caixa-teia>log; rm".into(),
9713        });
9714        let err = d.validate().unwrap_err();
9715        assert!(
9716            matches!(
9717                err,
9718                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
9719            ),
9720            "got {err:?}",
9721        );
9722    }
9723
9724    #[test]
9725    fn fonte_caminho_backslash_fires_before_shell_semicolon() {
9726        // Cascade pin on the upstream backslash arm: a value carrying
9727        // both `\` and `;` (`"..\caixa-teia;rm"` — the canonical "I
9728        // pasted a Windows-shell `cd ..\path; cleanup` chain") routes
9729        // through `FonteCaminhoBackslash` not `FonteCaminhoShellSemicolon`.
9730        // The cross-host-OS-separator divergence is the load-bearing axis
9731        // on every probe-as-both value (an author who removes the `\` is
9732        // the root-cause edit; the `;` falls away in the same edit since
9733        // it's downstream of the Windows-shell convention).
9734        let d = dep_with_fonte(DepSource::Path {
9735            caminho: "..\\caixa-teia;rm".into(),
9736        });
9737        let err = d.validate().unwrap_err();
9738        assert!(
9739            matches!(err, DepError::FonteCaminhoBackslash { .. }),
9740            "got {err:?}",
9741        );
9742    }
9743
9744    #[test]
9745    fn fonte_caminho_control_char_fires_before_shell_semicolon() {
9746        // Cascade pin on the embedded-control-byte arm: a value carrying
9747        // both a control byte and `;` (`"../foo\n;bar"` — the canonical
9748        // paste-from-multiline-doc footgun where a newline landed mid-
9749        // caminho) routes through `FonteCaminhoControlChar` not
9750        // `FonteCaminhoShellSemicolon`. The POSIX-syscall-rejected-byte
9751        // / NUL-`CString::new`-fail diagnostic is the load-bearing axis
9752        // on every value that probes positive for both — mirrors the
9753        // cascade discipline on every prior arm.
9754        let d = dep_with_fonte(DepSource::Path {
9755            caminho: "../foo\n;bar".into(),
9756        });
9757        let err = d.validate().unwrap_err();
9758        assert!(
9759            matches!(err, DepError::FonteCaminhoControlChar { .. }),
9760            "got {err:?}",
9761        );
9762    }
9763
9764    #[test]
9765    fn fonte_caminho_absolute_fires_before_shell_semicolon() {
9766        // Cascade pin on the load-bearing leading-byte arm: a leading
9767        // `/` value with embedded `;` (`"/etc/passwd;rm"`) routes
9768        // through `FonteCaminhoAbsolute` not `FonteCaminhoShellSemicolon`
9769        // — the host-layout-leak diagnostic is the load-bearing axis,
9770        // the `;` byte is the secondary observation. Same precedence
9771        // logic as every prior leading-byte arm.
9772        let d = dep_with_fonte(DepSource::Path {
9773            caminho: "/etc/passwd;rm".into(),
9774        });
9775        let err = d.validate().unwrap_err();
9776        assert!(
9777            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
9778            "got {err:?}",
9779        );
9780    }
9781
9782    #[test]
9783    fn fonte_caminho_shell_semicolon_fires_before_trailing_slash() {
9784        // Cascade pin on the immediate-successor arm: a value carrying
9785        // both `;` and a trailing `/` (`"../foo;rm/"` — the canonical
9786        // "I tab-completed a path that already had a `; cleanup` tail"
9787        // footgun) routes through `FonteCaminhoShellSemicolon` not
9788        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
9789        // the more semantic-locating axis (an author who removes the
9790        // `;` typically also drops the trailing separator since both
9791        // are paste-from-shell artifacts).
9792        let d = dep_with_fonte(DepSource::Path {
9793            caminho: "../foo;rm/".into(),
9794        });
9795        let err = d.validate().unwrap_err();
9796        assert!(
9797            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
9798            "got {err:?}",
9799        );
9800    }
9801
9802    #[test]
9803    fn fonte_caminho_shell_semicolon_diagnostic_carries_offending_dep_and_caminho() {
9804        // Diagnostic-shape pin (peer with
9805        // `fonte_caminho_shell_pipe_diagnostic_carries_offending_dep_and_caminho`
9806        // on the closest single-byte peer arm): the error's Display
9807        // surfaces the offending `:nome` and the offending `:caminho`
9808        // verbatim, and names the shell-command-separator footgun
9809        // explicitly so a `feira lint` run can render the diagnostic
9810        // without re-parsing.
9811        let d = dep_with_fonte(DepSource::Path {
9812            caminho: "../caixa-teia; rm -rf build".into(),
9813        });
9814        let rendered = d.validate().unwrap_err().to_string();
9815        assert!(
9816            rendered.contains("caixa-teia"),
9817            "diagnostic must name the offending dep: {rendered}",
9818        );
9819        assert!(
9820            rendered.contains("../caixa-teia; rm -rf build"),
9821            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
9822        );
9823        assert!(
9824            rendered.contains(';'),
9825            "diagnostic must reference the semicolon footgun: {rendered:?}",
9826        );
9827        assert!(
9828            rendered.contains("command-separator"),
9829            "diagnostic must name the shell-command-separator footgun: {rendered:?}",
9830        );
9831    }
9832
9833    #[test]
9834    fn validate_rejects_path_fonte_with_caminho_carrying_ampersand() {
9835        // The fail-before-pass-after pin for the canonical shell-
9836        // background-task paste footgun: an author copies a shell one-
9837        // liner (`"../caixa-teia & sleep 1"` — the canonical "I selected
9838        // the whole `cd path & sleep 1` background-launch out of a
9839        // shell-history block") and silently passed every prior arm
9840        // (`Path::is_absolute` false on `..`, no control bytes, no
9841        // backslash, no `<` / `>`, no `|`, no `;`, doesn't end in `/`).
9842        // The lacre embedded the value verbatim, the resolver folded it
9843        // through `Path::join` looking for a literal `./../caixa-teia &
9844        // sleep 1` subdirectory, and the failure surfaced at resolve
9845        // time with a non-self-locating `No such file or directory`
9846        // error. The new arm moves the rejection to validate time and
9847        // names the offending dep + caminho verbatim.
9848        let d = dep_with_fonte(DepSource::Path {
9849            caminho: "../caixa-teia & sleep 1".into(),
9850        });
9851        let err = d.validate().unwrap_err();
9852        let DepError::FonteCaminhoShellBackground { nome, caminho } = err else {
9853            panic!("expected FonteCaminhoShellBackground, got {err:?}");
9854        };
9855        assert_eq!(nome, "caixa-teia");
9856        assert_eq!(caminho, "../caixa-teia & sleep 1");
9857    }
9858
9859    #[test]
9860    fn validate_rejects_path_fonte_with_caminho_carrying_leading_ampersand() {
9861        // Leading-position `&` shape (`"&../caixa-teia"` — the
9862        // degenerate "I forgot the prior command side of the
9863        // background terminator" idiom). Pinned separately from the
9864        // embedded-byte shape so the gate covers every position, not
9865        // only mid-path.
9866        let d = dep_with_fonte(DepSource::Path {
9867            caminho: "&../caixa-teia".into(),
9868        });
9869        let err = d.validate().unwrap_err();
9870        assert!(
9871            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
9872            "got {err:?}",
9873        );
9874    }
9875
9876    #[test]
9877    fn validate_rejects_path_fonte_with_caminho_carrying_double_ampersand() {
9878        // The logical-AND `&&` shape (`"../caixa-teia && make"` — the
9879        // canonical "I copied a `cd path && make` build chain" idiom
9880        // every Makefile / shell-script wraps). The arm fires on the
9881        // first `&` encountered; pinned so a future arm that tries to
9882        // distinguish `&` from `&&` doesn't break the broader contract.
9883        let d = dep_with_fonte(DepSource::Path {
9884            caminho: "../caixa-teia && make".into(),
9885        });
9886        let err = d.validate().unwrap_err();
9887        assert!(
9888            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
9889            "got {err:?}",
9890        );
9891    }
9892
9893    #[test]
9894    fn validate_accepts_path_fonte_with_caminho_carrying_no_ampersand() {
9895        // The positive-control pin: the gate targets only `&`, never
9896        // adjacent printable ASCII or POSIX-valid bytes. The canonical
9897        // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
9898        // pathed variant with adjacent printable punctuation
9899        // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
9900        // cleanly so the gate doesn't widen to a "no printable
9901        // punctuation anywhere" sweep that would defeat the entire
9902        // path-fonte author surface.
9903        let d = dep_with_fonte(DepSource::Path {
9904            caminho: "../caixa-teia/sub-dir.v2".into(),
9905        });
9906        d.validate().unwrap();
9907    }
9908
9909    #[test]
9910    fn fonte_caminho_shell_semicolon_fires_before_shell_background() {
9911        // Cascade pin on the immediate-predecessor arm: a value carrying
9912        // both `;` and `&` (`"../caixa-teia; rm & sleep"` — the
9913        // canonical "I pasted a `cmd; cleanup & sleep` chain" footgun)
9914        // routes through `FonteCaminhoShellSemicolon` not
9915        // `FonteCaminhoShellBackground`. The sequential-command-
9916        // separator paste is the more common shell-history paste idiom
9917        // on every probe-as-both value (an author who removes the `;`
9918        // typically also drops the trailing `& sleep` since both are
9919        // paste-from-shell-history artifacts) — same cascade discipline
9920        // every prior `:caminho` arm establishes.
9921        let d = dep_with_fonte(DepSource::Path {
9922            caminho: "../caixa-teia; rm & sleep".into(),
9923        });
9924        let err = d.validate().unwrap_err();
9925        assert!(
9926            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
9927            "got {err:?}",
9928        );
9929    }
9930
9931    #[test]
9932    fn fonte_caminho_shell_pipe_fires_before_shell_background() {
9933        // Cascade pin on the upstream shell-pipe arm: a value carrying
9934        // both `|` and `&` (`"../caixa-teia | tee & sleep"` — the
9935        // canonical "I pasted a `cmd | tee & sleep` background-pipeline
9936        // chain" footgun) routes through `FonteCaminhoShellPipe` not
9937        // `FonteCaminhoShellBackground`. The pipeline-tail paste is the
9938        // load-bearing root-cause edit on every probe-as-both value.
9939        let d = dep_with_fonte(DepSource::Path {
9940            caminho: "../caixa-teia | tee & sleep".into(),
9941        });
9942        let err = d.validate().unwrap_err();
9943        assert!(
9944            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
9945            "got {err:?}",
9946        );
9947    }
9948
9949    #[test]
9950    fn fonte_caminho_shell_redirection_fires_before_shell_background() {
9951        // Cascade pin on the upstream shell-redirection arm: a value
9952        // carrying both `>` and `&` (`"../caixa-teia>log & sleep"` —
9953        // the canonical "I pasted a `cmd > log & sleep` background-
9954        // redirect chain" footgun) routes through
9955        // `FonteCaminhoShellRedirection` not
9956        // `FonteCaminhoShellBackground`. The input/output redirection
9957        // metachar carries the more self-locating `byte: u8` payload
9958        // (it names which of `<` or `>` triggered), so the prior arm
9959        // wins on every probe-as-both value.
9960        let d = dep_with_fonte(DepSource::Path {
9961            caminho: "../caixa-teia>log & sleep".into(),
9962        });
9963        let err = d.validate().unwrap_err();
9964        assert!(
9965            matches!(
9966                err,
9967                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
9968            ),
9969            "got {err:?}",
9970        );
9971    }
9972
9973    #[test]
9974    fn fonte_caminho_backslash_fires_before_shell_background() {
9975        // Cascade pin on the upstream backslash arm: a value carrying
9976        // both `\` and `&` (`"..\caixa-teia & sleep"` — the canonical
9977        // "I pasted a Windows-shell `cd ..\path & sleep` background-
9978        // launch chain") routes through `FonteCaminhoBackslash` not
9979        // `FonteCaminhoShellBackground`. The cross-host-OS-separator
9980        // divergence is the load-bearing axis on every probe-as-both
9981        // value (an author who removes the `\` is the root-cause edit;
9982        // the `&` falls away in the same edit since it's downstream of
9983        // the Windows-shell convention).
9984        let d = dep_with_fonte(DepSource::Path {
9985            caminho: "..\\caixa-teia & sleep".into(),
9986        });
9987        let err = d.validate().unwrap_err();
9988        assert!(
9989            matches!(err, DepError::FonteCaminhoBackslash { .. }),
9990            "got {err:?}",
9991        );
9992    }
9993
9994    #[test]
9995    fn fonte_caminho_control_char_fires_before_shell_background() {
9996        // Cascade pin on the embedded-control-byte arm: a value
9997        // carrying both a control byte and `&` (`"../foo\n&sleep"` —
9998        // the canonical paste-from-multiline-doc footgun where a
9999        // newline landed mid-caminho) routes through
10000        // `FonteCaminhoControlChar` not `FonteCaminhoShellBackground`.
10001        // The POSIX-syscall-rejected-byte / NUL-`CString::new`-fail
10002        // diagnostic is the load-bearing axis on every value that
10003        // probes positive for both — mirrors the cascade discipline on
10004        // every prior arm.
10005        let d = dep_with_fonte(DepSource::Path {
10006            caminho: "../foo\n&sleep".into(),
10007        });
10008        let err = d.validate().unwrap_err();
10009        assert!(
10010            matches!(err, DepError::FonteCaminhoControlChar { .. }),
10011            "got {err:?}",
10012        );
10013    }
10014
10015    #[test]
10016    fn fonte_caminho_absolute_fires_before_shell_background() {
10017        // Cascade pin on the load-bearing leading-byte arm: a leading
10018        // `/` value with embedded `&` (`"/etc/passwd & sleep"`) routes
10019        // through `FonteCaminhoAbsolute` not
10020        // `FonteCaminhoShellBackground` — the host-layout-leak
10021        // diagnostic is the load-bearing axis, the `&` byte is the
10022        // secondary observation. Same precedence logic as every prior
10023        // leading-byte arm.
10024        let d = dep_with_fonte(DepSource::Path {
10025            caminho: "/etc/passwd & sleep".into(),
10026        });
10027        let err = d.validate().unwrap_err();
10028        assert!(
10029            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10030            "got {err:?}",
10031        );
10032    }
10033
10034    #[test]
10035    fn fonte_caminho_shell_background_fires_before_trailing_slash() {
10036        // Cascade pin on the immediate-successor arm: a value carrying
10037        // both `&` and a trailing `/` (`"../foo&sleep/"` — the
10038        // canonical "I tab-completed a path that already had a `&
10039        // sleep` background-launch tail" footgun) routes through
10040        // `FonteCaminhoShellBackground` not `FonteCaminhoTrailingSlash`.
10041        // The embedded shell-metachar is the more semantic-locating
10042        // axis (an author who removes the `&` typically also drops
10043        // the trailing separator since both are paste-from-shell
10044        // artifacts).
10045        let d = dep_with_fonte(DepSource::Path {
10046            caminho: "../foo&sleep/".into(),
10047        });
10048        let err = d.validate().unwrap_err();
10049        assert!(
10050            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
10051            "got {err:?}",
10052        );
10053    }
10054
10055    #[test]
10056    fn fonte_caminho_shell_background_diagnostic_carries_offending_dep_and_caminho() {
10057        // Diagnostic-shape pin (peer with
10058        // `fonte_caminho_shell_semicolon_diagnostic_carries_offending_dep_and_caminho`
10059        // on the closest single-byte peer arm): the error's Display
10060        // surfaces the offending `:nome` and the offending `:caminho`
10061        // verbatim, and names the shell-background / logical-AND
10062        // footgun explicitly so a `feira lint` run can render the
10063        // diagnostic without re-parsing.
10064        let d = dep_with_fonte(DepSource::Path {
10065            caminho: "../caixa-teia & sleep 1".into(),
10066        });
10067        let rendered = d.validate().unwrap_err().to_string();
10068        assert!(
10069            rendered.contains("caixa-teia"),
10070            "diagnostic must name the offending dep: {rendered}",
10071        );
10072        assert!(
10073            rendered.contains("../caixa-teia & sleep 1"),
10074            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10075        );
10076        assert!(
10077            rendered.contains('&'),
10078            "diagnostic must reference the ampersand footgun: {rendered:?}",
10079        );
10080        assert!(
10081            rendered.contains("background") || rendered.contains("list-AND"),
10082            "diagnostic must name the shell-background / logical-AND footgun: {rendered:?}",
10083        );
10084    }
10085
10086    #[test]
10087    fn validate_rejects_path_fonte_with_caminho_carrying_backtick() {
10088        // The fail-before-pass-after pin for the canonical shell-
10089        // command-substitution paste footgun: an author copies a
10090        // POSIX legacy backticked one-liner (`"../caixa-teia/`whoami`"`
10091        // — the canonical "I pasted a path that included a `pwd`
10092        // / `whoami` / `date` legacy command-substitution expansion
10093        // out of a shell-history block") and silently passed every
10094        // prior arm (`Path::is_absolute` false on `..`, no control
10095        // bytes, no `\`, no `<` / `>`, no `|`, no `;`, no `&`, doesn't
10096        // end in `/`). The lacre embedded the value verbatim, the
10097        // resolver folded it through `Path::join` looking for a
10098        // literal `./../caixa-teia/`whoami`` subdirectory, and the
10099        // failure surfaced at resolve time with a non-self-locating
10100        // `No such file or directory` error. The new arm moves the
10101        // rejection to validate time and names the offending dep +
10102        // caminho verbatim.
10103        let d = dep_with_fonte(DepSource::Path {
10104            caminho: "../caixa-teia/`whoami`".into(),
10105        });
10106        let err = d.validate().unwrap_err();
10107        let DepError::FonteCaminhoShellCommandSubstitution { nome, caminho } = err else {
10108            panic!("expected FonteCaminhoShellCommandSubstitution, got {err:?}");
10109        };
10110        assert_eq!(nome, "caixa-teia");
10111        assert_eq!(caminho, "../caixa-teia/`whoami`");
10112    }
10113
10114    #[test]
10115    fn validate_rejects_path_fonte_with_caminho_carrying_leading_backtick() {
10116        // Leading-position backtick shape (``"`pwd`/caixa-teia"`` —
10117        // the canonical `<backtick>pwd<backtick>/path` working-
10118        // directory expansion shape every shell-side path-composition
10119        // idiom carries). Pinned separately from the embedded-byte
10120        // shape so the gate covers every position, not only mid-path.
10121        let d = dep_with_fonte(DepSource::Path {
10122            caminho: "`pwd`/caixa-teia".into(),
10123        });
10124        let err = d.validate().unwrap_err();
10125        assert!(
10126            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
10127            "got {err:?}",
10128        );
10129    }
10130
10131    #[test]
10132    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_backtick() {
10133        // Trailing-position backtick shape (`"../caixa-teia`"` — the
10134        // degenerate "I selected an unbalanced backtick out of a
10135        // shell-history block" idiom that probes for the cascade's
10136        // last-byte handling). The trailing-`/` arm fires only on
10137        // last-byte `/`; an unbalanced trailing backtick must route
10138        // through this arm regardless of position.
10139        let d = dep_with_fonte(DepSource::Path {
10140            caminho: "../caixa-teia`".into(),
10141        });
10142        let err = d.validate().unwrap_err();
10143        assert!(
10144            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
10145            "got {err:?}",
10146        );
10147    }
10148
10149    #[test]
10150    fn validate_rejects_path_fonte_with_caminho_carrying_balanced_backtick_pair() {
10151        // The canonical balanced-pair shape (``"../<backtick>cat
10152        // /etc/passwd<backtick>"`` — the canonical CWE-78 shell-
10153        // command-injection paste idiom every shell-side hardening
10154        // guide enumerates first). The arm fires on the first
10155        // backtick encountered; pinned so a future arm that tries to
10156        // distinguish the opening from the closing byte doesn't break
10157        // the broader contract.
10158        let d = dep_with_fonte(DepSource::Path {
10159            caminho: "../`cat /etc/passwd`".into(),
10160        });
10161        let err = d.validate().unwrap_err();
10162        assert!(
10163            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
10164            "got {err:?}",
10165        );
10166    }
10167
10168    #[test]
10169    fn validate_accepts_path_fonte_with_caminho_carrying_no_backtick() {
10170        // The positive-control pin: the gate targets only the
10171        // backtick byte, never adjacent printable ASCII or POSIX-
10172        // valid bytes. The canonical relative POSIX path
10173        // (`"../caixa-teia"`) and a nested deeply-pathed variant with
10174        // adjacent printable punctuation
10175        // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
10176        // cleanly so the gate doesn't widen to a "no printable
10177        // punctuation anywhere" sweep that would defeat the entire
10178        // path-fonte author surface.
10179        let d = dep_with_fonte(DepSource::Path {
10180            caminho: "../caixa-teia/sub-dir.v2".into(),
10181        });
10182        d.validate().unwrap();
10183    }
10184
10185    #[test]
10186    fn fonte_caminho_shell_background_fires_before_shell_command_substitution() {
10187        // Cascade pin on the immediate-predecessor arm: a value
10188        // carrying both `&` and a backtick (``"../caixa-teia &
10189        // <backtick>sleep 1<backtick>"`` — the canonical "I pasted a
10190        // `cmd & <backtick>sleep N<backtick>` background-launch +
10191        // command-substitution chain" footgun) routes through
10192        // `FonteCaminhoShellBackground` not
10193        // `FonteCaminhoShellCommandSubstitution`. The background-
10194        // launch tail is the more common shell-history paste idiom
10195        // on every probe-as-both value — same cascade discipline
10196        // every prior `:caminho` arm establishes.
10197        let d = dep_with_fonte(DepSource::Path {
10198            caminho: "../caixa-teia & `sleep 1`".into(),
10199        });
10200        let err = d.validate().unwrap_err();
10201        assert!(
10202            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
10203            "got {err:?}",
10204        );
10205    }
10206
10207    #[test]
10208    fn fonte_caminho_shell_semicolon_fires_before_shell_command_substitution() {
10209        // Cascade pin on the upstream shell-semicolon arm: a value
10210        // carrying both `;` and a backtick (``"../caixa-teia;
10211        // <backtick>whoami<backtick>"`` — the canonical "I pasted a
10212        // `cmd; <backtick>follow-up<backtick>` sequential-chain
10213        // footgun) routes through `FonteCaminhoShellSemicolon` not
10214        // `FonteCaminhoShellCommandSubstitution`. The sequential-
10215        // command-separator paste is the load-bearing root-cause
10216        // edit on every probe-as-both value.
10217        let d = dep_with_fonte(DepSource::Path {
10218            caminho: "../caixa-teia; `whoami`".into(),
10219        });
10220        let err = d.validate().unwrap_err();
10221        assert!(
10222            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
10223            "got {err:?}",
10224        );
10225    }
10226
10227    #[test]
10228    fn fonte_caminho_shell_pipe_fires_before_shell_command_substitution() {
10229        // Cascade pin on the upstream shell-pipe arm: a value
10230        // carrying both `|` and a backtick (``"../caixa-teia |
10231        // <backtick>tee log<backtick>"`` — the canonical pipeline-to-
10232        // command-substitution paste idiom) routes through
10233        // `FonteCaminhoShellPipe` not
10234        // `FonteCaminhoShellCommandSubstitution`. The pipeline-tail
10235        // paste is the load-bearing root-cause edit on every
10236        // probe-as-both value.
10237        let d = dep_with_fonte(DepSource::Path {
10238            caminho: "../caixa-teia | `tee log`".into(),
10239        });
10240        let err = d.validate().unwrap_err();
10241        assert!(
10242            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10243            "got {err:?}",
10244        );
10245    }
10246
10247    #[test]
10248    fn fonte_caminho_shell_redirection_fires_before_shell_command_substitution() {
10249        // Cascade pin on the upstream shell-redirection arm: a value
10250        // carrying both `>` and a backtick (``"../caixa-teia>log
10251        // <backtick>date<backtick>"`` — the canonical "I pasted a
10252        // `cmd > log <backtick>date<backtick>` redirect-plus-
10253        // substitution chain" footgun) routes through
10254        // `FonteCaminhoShellRedirection` not
10255        // `FonteCaminhoShellCommandSubstitution`. The input/output
10256        // redirection metachar carries the more self-locating `byte`
10257        // payload (it names which of `<` or `>` triggered), so the
10258        // prior arm wins on every probe-as-both value.
10259        let d = dep_with_fonte(DepSource::Path {
10260            caminho: "../caixa-teia>log `date`".into(),
10261        });
10262        let err = d.validate().unwrap_err();
10263        assert!(
10264            matches!(
10265                err,
10266                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
10267            ),
10268            "got {err:?}",
10269        );
10270    }
10271
10272    #[test]
10273    fn fonte_caminho_backslash_fires_before_shell_command_substitution() {
10274        // Cascade pin on the upstream backslash arm: a value
10275        // carrying both `\` and a backtick (``"..\caixa-teia
10276        // <backtick>whoami<backtick>"`` — the canonical "I pasted a
10277        // Windows-shell `cd ..\path <backtick>whoami<backtick>`
10278        // chain") routes through `FonteCaminhoBackslash` not
10279        // `FonteCaminhoShellCommandSubstitution`. The cross-host-OS-
10280        // separator divergence is the load-bearing axis on every
10281        // probe-as-both value (an author who removes the `\` is the
10282        // root-cause edit; the backtick falls away in the same edit
10283        // since it's downstream of the Windows-shell convention).
10284        let d = dep_with_fonte(DepSource::Path {
10285            caminho: "..\\caixa-teia `whoami`".into(),
10286        });
10287        let err = d.validate().unwrap_err();
10288        assert!(
10289            matches!(err, DepError::FonteCaminhoBackslash { .. }),
10290            "got {err:?}",
10291        );
10292    }
10293
10294    #[test]
10295    fn fonte_caminho_control_char_fires_before_shell_command_substitution() {
10296        // Cascade pin on the embedded-control-byte arm: a value
10297        // carrying both a control byte and a backtick (`"../foo\n
10298        // `whoami`"` — the canonical paste-from-multiline-doc
10299        // footgun where a newline landed mid-caminho between two
10300        // paste fragments) routes through `FonteCaminhoControlChar`
10301        // not `FonteCaminhoShellCommandSubstitution`. The POSIX-
10302        // syscall-rejected-byte / NUL-`CString::new`-fail diagnostic
10303        // is the load-bearing axis on every value that probes
10304        // positive for both — mirrors the cascade discipline on
10305        // every prior arm.
10306        let d = dep_with_fonte(DepSource::Path {
10307            caminho: "../foo\n`whoami`".into(),
10308        });
10309        let err = d.validate().unwrap_err();
10310        assert!(
10311            matches!(err, DepError::FonteCaminhoControlChar { .. }),
10312            "got {err:?}",
10313        );
10314    }
10315
10316    #[test]
10317    fn fonte_caminho_absolute_fires_before_shell_command_substitution() {
10318        // Cascade pin on the load-bearing leading-byte arm: a
10319        // leading `/` value with embedded backtick (``"/etc/passwd
10320        // <backtick>whoami<backtick>"``) routes through
10321        // `FonteCaminhoAbsolute` not
10322        // `FonteCaminhoShellCommandSubstitution` — the host-layout-
10323        // leak diagnostic is the load-bearing axis, the backtick
10324        // byte is the secondary observation. Same precedence logic
10325        // as every prior leading-byte arm.
10326        let d = dep_with_fonte(DepSource::Path {
10327            caminho: "/etc/passwd `whoami`".into(),
10328        });
10329        let err = d.validate().unwrap_err();
10330        assert!(
10331            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10332            "got {err:?}",
10333        );
10334    }
10335
10336    #[test]
10337    fn fonte_caminho_shell_command_substitution_fires_before_trailing_slash() {
10338        // Cascade pin on the immediate-successor arm: a value
10339        // carrying both a backtick and a trailing `/`
10340        // (``"../`whoami`/"`` — the canonical "I tab-completed a
10341        // path that already had a backticked `whoami` substitution
10342        // tail" footgun) routes through
10343        // `FonteCaminhoShellCommandSubstitution` not
10344        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
10345        // is the more semantic-locating axis (an author who removes
10346        // the backtick typically also drops the trailing separator
10347        // since both are paste-from-shell artifacts).
10348        let d = dep_with_fonte(DepSource::Path {
10349            caminho: "../`whoami`/".into(),
10350        });
10351        let err = d.validate().unwrap_err();
10352        assert!(
10353            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
10354            "got {err:?}",
10355        );
10356    }
10357
10358    #[test]
10359    fn fonte_caminho_shell_command_substitution_diagnostic_carries_offending_dep_and_caminho() {
10360        // Diagnostic-shape pin (peer with
10361        // `fonte_caminho_shell_background_diagnostic_carries_offending_dep_and_caminho`
10362        // on the closest single-byte peer arm): the error's Display
10363        // surfaces the offending `:nome` and the offending `:caminho`
10364        // verbatim, and names the shell-command-substitution footgun
10365        // explicitly so a `feira lint` run can render the diagnostic
10366        // without re-parsing.
10367        let d = dep_with_fonte(DepSource::Path {
10368            caminho: "../caixa-teia/`whoami`".into(),
10369        });
10370        let rendered = d.validate().unwrap_err().to_string();
10371        assert!(
10372            rendered.contains("caixa-teia"),
10373            "diagnostic must name the offending dep: {rendered}",
10374        );
10375        assert!(
10376            rendered.contains("../caixa-teia/`whoami`"),
10377            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10378        );
10379        assert!(
10380            rendered.contains('`'),
10381            "diagnostic must reference the backtick footgun: {rendered:?}",
10382        );
10383        assert!(
10384            rendered.contains("command-substitution"),
10385            "diagnostic must name the shell-command-substitution footgun: {rendered:?}",
10386        );
10387    }
10388
10389    #[test]
10390    fn validate_rejects_path_fonte_with_caminho_carrying_star_glob() {
10391        // The fail-before-pass-after pin for the canonical pathname-
10392        // expansion paste footgun: an author copies an `ls
10393        // ../caixa-teia/*` shell-listing tail into the `:caminho`
10394        // slot and silently passes every prior arm
10395        // (`Path::is_absolute` false on `..`, no control bytes, no
10396        // `\`, no `<` / `>`, no `|`, no `;`, no `&`, no backtick,
10397        // doesn't end in `/`). The lacre embedded the value
10398        // verbatim, the resolver folded it through `Path::join`
10399        // looking for a literal `./../caixa-teia/*` subdirectory,
10400        // and the failure surfaced at resolve time with a non-self-
10401        // locating `No such file or directory` error. The new arm
10402        // moves the rejection to validate time and names the
10403        // offending dep + caminho + byte verbatim.
10404        let d = dep_with_fonte(DepSource::Path {
10405            caminho: "../caixa-teia/*".into(),
10406        });
10407        let err = d.validate().unwrap_err();
10408        let DepError::FonteCaminhoShellGlob {
10409            nome,
10410            caminho,
10411            byte,
10412        } = err
10413        else {
10414            panic!("expected FonteCaminhoShellGlob, got {err:?}");
10415        };
10416        assert_eq!(nome, "caixa-teia");
10417        assert_eq!(caminho, "../caixa-teia/*");
10418        assert_eq!(byte, b'*');
10419    }
10420
10421    #[test]
10422    fn validate_rejects_path_fonte_with_caminho_carrying_question_glob() {
10423        // The symmetric single-char-wildcard paste shape
10424        // (`"../foo?"` — the canonical "I copied a `rm foo?` line
10425        // out of shell history" idiom). Pinned separately from the
10426        // `*` shape so the gate's contract is "any `*` or `?`
10427        // anywhere", not single-byte coverage.
10428        let d = dep_with_fonte(DepSource::Path {
10429            caminho: "../foo?".into(),
10430        });
10431        let err = d.validate().unwrap_err();
10432        let DepError::FonteCaminhoShellGlob { byte, .. } = err else {
10433            panic!("expected FonteCaminhoShellGlob, got {err:?}");
10434        };
10435        assert_eq!(byte, b'?');
10436    }
10437
10438    #[test]
10439    fn validate_rejects_path_fonte_with_caminho_carrying_leading_star_glob() {
10440        // Leading-position `*` shape (`"*/caixa-teia"` — the
10441        // degenerate "I selected only the wildcard prefix out of a
10442        // shell-glob expression" idiom). Pinned separately from the
10443        // embedded-byte shapes so the gate covers every position,
10444        // not only mid-path.
10445        let d = dep_with_fonte(DepSource::Path {
10446            caminho: "*/caixa-teia".into(),
10447        });
10448        let err = d.validate().unwrap_err();
10449        assert!(
10450            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
10451            "got {err:?}",
10452        );
10453    }
10454
10455    #[test]
10456    fn validate_rejects_path_fonte_with_caminho_carrying_double_star_recursive_glob() {
10457        // The bash/zsh `globstar` recursive-glob shape
10458        // (`"../caixa-teia/**/foo"` — the canonical "I copied a
10459        // `find ../caixa-teia/**/foo` recursive expansion" idiom).
10460        // The arm fires on the first `*` encountered; pinned so a
10461        // future arm that tries to distinguish single `*` from
10462        // double `**` doesn't break the broader contract.
10463        let d = dep_with_fonte(DepSource::Path {
10464            caminho: "../caixa-teia/**/foo".into(),
10465        });
10466        let err = d.validate().unwrap_err();
10467        assert!(
10468            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
10469            "got {err:?}",
10470        );
10471    }
10472
10473    #[test]
10474    fn validate_rejects_path_fonte_with_caminho_carrying_dotted_extension_glob() {
10475        // The canonical extension-glob shape (`"../caixa-teia/*.lisp"`
10476        // — the "I selected `*.lisp` to mean every Lisp source file
10477        // in the dep root" footgun the prior arms structurally
10478        // cannot catch since `.` is a POSIX-valid path-component
10479        // byte). Pinned so the gate's contract covers the most
10480        // idiomatic glob-paste shape every author meets first.
10481        let d = dep_with_fonte(DepSource::Path {
10482            caminho: "../caixa-teia/*.lisp".into(),
10483        });
10484        let err = d.validate().unwrap_err();
10485        assert!(
10486            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
10487            "got {err:?}",
10488        );
10489    }
10490
10491    #[test]
10492    fn validate_accepts_path_fonte_with_caminho_carrying_no_glob() {
10493        // The positive-control pin: the gate targets only `*` /
10494        // `?`, never adjacent printable ASCII or POSIX-valid bytes.
10495        // The canonical relative POSIX path (`"../caixa-teia"`) and
10496        // a nested deeply-pathed variant with adjacent printable
10497        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
10498        // to validate cleanly so the gate doesn't widen to a "no
10499        // printable punctuation anywhere" sweep that would defeat
10500        // the entire path-fonte author surface.
10501        let d = dep_with_fonte(DepSource::Path {
10502            caminho: "../caixa-teia/sub-dir.v2".into(),
10503        });
10504        d.validate().unwrap();
10505    }
10506
10507    #[test]
10508    fn fonte_caminho_shell_command_substitution_fires_before_shell_glob() {
10509        // Cascade pin on the immediate-predecessor arm: a value
10510        // carrying both a backtick and `*` (``"../`whoami`/*"`` —
10511        // the canonical "I pasted a `cd <backtick>whoami<backtick>/*`
10512        // command-substitution + glob chain") routes through
10513        // `FonteCaminhoShellCommandSubstitution` not
10514        // `FonteCaminhoShellGlob`. The CWE-78 shell-command-
10515        // injection vector is the load-bearing root-cause edit on
10516        // every probe-as-both value — same cascade discipline every
10517        // prior `:caminho` arm establishes.
10518        let d = dep_with_fonte(DepSource::Path {
10519            caminho: "../`whoami`/*".into(),
10520        });
10521        let err = d.validate().unwrap_err();
10522        assert!(
10523            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
10524            "got {err:?}",
10525        );
10526    }
10527
10528    #[test]
10529    fn fonte_caminho_shell_background_fires_before_shell_glob() {
10530        // Cascade pin on the upstream shell-background arm: a value
10531        // carrying both `&` and `*` (`"../caixa-teia & ls /*"` — the
10532        // canonical "I pasted a `cmd & ls /*` background + glob
10533        // chain" footgun) routes through `FonteCaminhoShellBackground`
10534        // not `FonteCaminhoShellGlob`. The background-launch tail is
10535        // the load-bearing root-cause edit on every probe-as-both
10536        // value.
10537        let d = dep_with_fonte(DepSource::Path {
10538            caminho: "../caixa-teia & ls /*".into(),
10539        });
10540        let err = d.validate().unwrap_err();
10541        assert!(
10542            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
10543            "got {err:?}",
10544        );
10545    }
10546
10547    #[test]
10548    fn fonte_caminho_shell_semicolon_fires_before_shell_glob() {
10549        // Cascade pin on the upstream shell-semicolon arm: a value
10550        // carrying both `;` and `*` (`"../caixa-teia; rm *"` — the
10551        // canonical sequential-cleanup + glob paste idiom) routes
10552        // through `FonteCaminhoShellSemicolon` not
10553        // `FonteCaminhoShellGlob`. The sequential-command-separator
10554        // paste is the load-bearing root-cause edit on every
10555        // probe-as-both value.
10556        let d = dep_with_fonte(DepSource::Path {
10557            caminho: "../caixa-teia; rm *".into(),
10558        });
10559        let err = d.validate().unwrap_err();
10560        assert!(
10561            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
10562            "got {err:?}",
10563        );
10564    }
10565
10566    #[test]
10567    fn fonte_caminho_shell_pipe_fires_before_shell_glob() {
10568        // Cascade pin on the upstream shell-pipe arm: a value
10569        // carrying both `|` and `*` (`"../caixa-teia | ls *"` — the
10570        // canonical pipeline-to-glob paste idiom) routes through
10571        // `FonteCaminhoShellPipe` not `FonteCaminhoShellGlob`. The
10572        // pipeline-tail paste is the load-bearing root-cause edit
10573        // on every probe-as-both value.
10574        let d = dep_with_fonte(DepSource::Path {
10575            caminho: "../caixa-teia | ls *".into(),
10576        });
10577        let err = d.validate().unwrap_err();
10578        assert!(
10579            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10580            "got {err:?}",
10581        );
10582    }
10583
10584    #[test]
10585    fn fonte_caminho_shell_redirection_fires_before_shell_glob() {
10586        // Cascade pin on the upstream shell-redirection arm: a value
10587        // carrying both `>` and `*` (`"../caixa-teia>log *"` — the
10588        // canonical "I pasted a `cmd > log *` redirect-plus-glob
10589        // chain" footgun) routes through
10590        // `FonteCaminhoShellRedirection` not `FonteCaminhoShellGlob`.
10591        // The input/output redirection metachar carries the more
10592        // self-locating `byte` payload (it names which of `<` or `>`
10593        // triggered), so the prior arm wins on every probe-as-both
10594        // value.
10595        let d = dep_with_fonte(DepSource::Path {
10596            caminho: "../caixa-teia>log *".into(),
10597        });
10598        let err = d.validate().unwrap_err();
10599        assert!(
10600            matches!(
10601                err,
10602                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
10603            ),
10604            "got {err:?}",
10605        );
10606    }
10607
10608    #[test]
10609    fn fonte_caminho_backslash_fires_before_shell_glob() {
10610        // Cascade pin on the upstream backslash arm: a value
10611        // carrying both `\` and `*` (`"..\caixa-teia\*"` — the
10612        // canonical "I pasted a Windows-shell `cd ..\path\*` glob
10613        // expression" footgun) routes through
10614        // `FonteCaminhoBackslash` not `FonteCaminhoShellGlob`. The
10615        // cross-host-OS-separator divergence is the load-bearing
10616        // axis on every probe-as-both value (an author who removes
10617        // the `\` is the root-cause edit; the `*` falls away in the
10618        // same edit since it's downstream of the Windows-shell
10619        // convention).
10620        let d = dep_with_fonte(DepSource::Path {
10621            caminho: "..\\caixa-teia\\*".into(),
10622        });
10623        let err = d.validate().unwrap_err();
10624        assert!(
10625            matches!(err, DepError::FonteCaminhoBackslash { .. }),
10626            "got {err:?}",
10627        );
10628    }
10629
10630    #[test]
10631    fn fonte_caminho_control_char_fires_before_shell_glob() {
10632        // Cascade pin on the embedded-control-byte arm: a value
10633        // carrying both a control byte and `*` (`"../foo\n*"` — the
10634        // canonical paste-from-multiline-doc footgun where a
10635        // newline landed mid-caminho between two paste fragments)
10636        // routes through `FonteCaminhoControlChar` not
10637        // `FonteCaminhoShellGlob`. The POSIX-syscall-rejected-byte /
10638        // NUL-`CString::new`-fail diagnostic is the load-bearing
10639        // axis on every value that probes positive for both —
10640        // mirrors the cascade discipline on every prior arm.
10641        let d = dep_with_fonte(DepSource::Path {
10642            caminho: "../foo\n*".into(),
10643        });
10644        let err = d.validate().unwrap_err();
10645        assert!(
10646            matches!(err, DepError::FonteCaminhoControlChar { .. }),
10647            "got {err:?}",
10648        );
10649    }
10650
10651    #[test]
10652    fn fonte_caminho_absolute_fires_before_shell_glob() {
10653        // Cascade pin on the load-bearing leading-byte arm: a
10654        // leading `/` value with embedded `*` (`"/etc/*"`) routes
10655        // through `FonteCaminhoAbsolute` not `FonteCaminhoShellGlob`
10656        // — the host-layout-leak diagnostic is the load-bearing
10657        // axis, the glob byte is the secondary observation. Same
10658        // precedence logic as every prior leading-byte arm.
10659        let d = dep_with_fonte(DepSource::Path {
10660            caminho: "/etc/*".into(),
10661        });
10662        let err = d.validate().unwrap_err();
10663        assert!(
10664            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10665            "got {err:?}",
10666        );
10667    }
10668
10669    #[test]
10670    fn fonte_caminho_shell_glob_fires_before_trailing_slash() {
10671        // Cascade pin on the immediate-successor arm: a value
10672        // carrying both `*` and a trailing `/` (`"../foo*/"` — the
10673        // canonical "I tab-completed a path that already had a
10674        // glob-expansion tail" footgun) routes through
10675        // `FonteCaminhoShellGlob` not `FonteCaminhoTrailingSlash`.
10676        // The embedded shell-metachar is the more semantic-locating
10677        // axis (an author who removes the `*` typically also drops
10678        // the trailing separator since both are paste-from-shell
10679        // artifacts).
10680        let d = dep_with_fonte(DepSource::Path {
10681            caminho: "../foo*/".into(),
10682        });
10683        let err = d.validate().unwrap_err();
10684        assert!(
10685            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
10686            "got {err:?}",
10687        );
10688    }
10689
10690    #[test]
10691    fn fonte_caminho_shell_glob_diagnostic_carries_offending_dep_caminho_and_byte() {
10692        // Diagnostic-shape pin (peer with
10693        // `fonte_caminho_shell_redirection_diagnostic_*` on the
10694        // closest two-byte peer arm): the error's Display surfaces
10695        // the offending `:nome`, the offending `:caminho` verbatim,
10696        // the offending byte's hex / character form, and names the
10697        // shell-glob / pathname-expansion footgun explicitly so a
10698        // `feira lint` run can render the diagnostic without
10699        // re-parsing.
10700        let d = dep_with_fonte(DepSource::Path {
10701            caminho: "../caixa-teia/*.lisp".into(),
10702        });
10703        let rendered = d.validate().unwrap_err().to_string();
10704        assert!(
10705            rendered.contains("caixa-teia"),
10706            "diagnostic must name the offending dep: {rendered}",
10707        );
10708        assert!(
10709            rendered.contains("../caixa-teia/*.lisp"),
10710            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10711        );
10712        assert!(
10713            rendered.contains("0x2a"),
10714            "diagnostic must surface the offending byte hex: {rendered:?}",
10715        );
10716        assert!(
10717            rendered.contains("glob"),
10718            "diagnostic must name the shell-glob footgun: {rendered:?}",
10719        );
10720        assert!(
10721            rendered.contains("pathname-expansion"),
10722            "diagnostic must reference the POSIX pathname-expansion vocabulary: {rendered:?}",
10723        );
10724    }
10725
10726    #[test]
10727    fn validate_rejects_path_fonte_with_caminho_carrying_modern_command_substitution() {
10728        // The fail-before-pass-after pin for the canonical modern-Bourne
10729        // command-substitution paste footgun: an author copies a
10730        // `cd ../caixa-teia/$(date)/build` shell-history one-liner whose
10731        // `$(<cmd>)` expansion would land the current date as a
10732        // subdirectory name and silently passed every prior arm
10733        // (`Path::is_absolute` false on `..`, no control bytes, no `\`,
10734        // no `<` / `>`, no `|`, no `;`, no `&`, no backtick, no `*` /
10735        // `?`, doesn't end in `/`; the leading-`$` f4efe9c
10736        // `FonteCaminhoVarExpansion` arm doesn't fire because the `$`
10737        // sits mid-path). The lacre embedded the value verbatim, the
10738        // resolver folded it through `Path::join` looking for a literal
10739        // `./../caixa-teia/$(date)/build` subdirectory, and the failure
10740        // surfaced at resolve time with a non-self-locating `No such
10741        // file or directory` error. The new arm moves the rejection to
10742        // validate time and names the offending dep + caminho + byte
10743        // verbatim. The arm fires on the first `(` encountered (the
10744        // opening byte of `$(date)`).
10745        let d = dep_with_fonte(DepSource::Path {
10746            caminho: "../caixa-teia/$(date)/build".into(),
10747        });
10748        let err = d.validate().unwrap_err();
10749        let DepError::FonteCaminhoShellSubshellGrouping {
10750            nome,
10751            caminho,
10752            byte,
10753        } = err
10754        else {
10755            panic!("expected FonteCaminhoShellSubshellGrouping, got {err:?}");
10756        };
10757        assert_eq!(nome, "caixa-teia");
10758        assert_eq!(caminho, "../caixa-teia/$(date)/build");
10759        assert_eq!(byte, b'(');
10760    }
10761
10762    #[test]
10763    fn validate_rejects_path_fonte_with_caminho_carrying_close_paren() {
10764        // The symmetric close-paren paste shape (`"../caixa-teia)"` —
10765        // the degenerate "I selected an unbalanced closing paren out of
10766        // a shell-history block" idiom that probes for the cascade's
10767        // last-byte handling on a value carrying only the closing byte).
10768        // Pinned separately from the open-paren shape so the gate's
10769        // contract is "any `(` or `)` anywhere", not single-byte
10770        // coverage. Mirrors the peer `validate_rejects_path_fonte_with_\
10771        // caminho_carrying_question_glob` shape on the immediate-
10772        // predecessor `FonteCaminhoShellGlob` arm.
10773        let d = dep_with_fonte(DepSource::Path {
10774            caminho: "../caixa-teia)".into(),
10775        });
10776        let err = d.validate().unwrap_err();
10777        let DepError::FonteCaminhoShellSubshellGrouping { byte, .. } = err else {
10778            panic!("expected FonteCaminhoShellSubshellGrouping, got {err:?}");
10779        };
10780        assert_eq!(byte, b')');
10781    }
10782
10783    #[test]
10784    fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_paren() {
10785        // Leading-position `(` shape (`"(cd foo)/caixa-teia"` — the
10786        // canonical "I selected a `(cd foo)` subshell-grouping prefix
10787        // out of a `(cd foo) && cmd` shell-history one-liner" idiom).
10788        // Pinned separately from the embedded-byte shape so the gate
10789        // covers every position, not only mid-path.
10790        let d = dep_with_fonte(DepSource::Path {
10791            caminho: "(cd foo)/caixa-teia".into(),
10792        });
10793        let err = d.validate().unwrap_err();
10794        assert!(
10795            matches!(
10796                err,
10797                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
10798            ),
10799            "got {err:?}",
10800        );
10801    }
10802
10803    #[test]
10804    fn validate_rejects_path_fonte_with_caminho_carrying_balanced_subshell_grouping_pair() {
10805        // The canonical balanced-pair shape (`"../(pwd)/caixa-teia"`
10806        // — the canonical "I copied a `(pwd)` working-directory-probe
10807        // subshell-grouping idiom every shell-history block carries"
10808        // footgun). The value carries no other cascade-preceding
10809        // shell metachar (`&` / `;` / `|` / `<` / `>` / backtick /
10810        // `*` / `?`) so the arm fires on the first `(` encountered;
10811        // pinned so a future arm that tries to distinguish the
10812        // opening from the closing byte doesn't break the broader
10813        // contract. Mirrors the peer
10814        // `validate_rejects_path_fonte_with_caminho_carrying_balanced_\
10815        // backtick_pair` shape on the upstream `FonteCaminhoShell\
10816        // CommandSubstitution` arm.
10817        let d = dep_with_fonte(DepSource::Path {
10818            caminho: "../(pwd)/caixa-teia".into(),
10819        });
10820        let err = d.validate().unwrap_err();
10821        assert!(
10822            matches!(
10823                err,
10824                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
10825            ),
10826            "got {err:?}",
10827        );
10828    }
10829
10830    #[test]
10831    fn validate_accepts_path_fonte_with_caminho_carrying_no_subshell_grouping() {
10832        // The positive-control pin: the gate targets only `(` / `)`,
10833        // never adjacent printable ASCII or POSIX-valid bytes. The
10834        // canonical relative POSIX path (`"../caixa-teia"`) and a
10835        // nested deeply-pathed variant with adjacent printable
10836        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue to
10837        // validate cleanly so the gate doesn't widen to a "no printable
10838        // punctuation anywhere" sweep that would defeat the entire
10839        // path-fonte author surface.
10840        let d = dep_with_fonte(DepSource::Path {
10841            caminho: "../caixa-teia/sub-dir.v2".into(),
10842        });
10843        d.validate().unwrap();
10844    }
10845
10846    #[test]
10847    fn fonte_caminho_shell_glob_fires_before_shell_subshell_grouping() {
10848        // Cascade pin on the immediate-predecessor arm: a value
10849        // carrying both `*` and `(` (`"../caixa-teia/*(date)"` — the
10850        // canonical "I pasted a glob expansion followed by a
10851        // subshell-grouping tail" footgun) routes through
10852        // `FonteCaminhoShellGlob` not
10853        // `FonteCaminhoShellSubshellGrouping`. The pathname-expansion
10854        // shape is the more common shell-history paste idiom on every
10855        // probe-as-both value — same cascade discipline every prior
10856        // `:caminho` arm establishes.
10857        let d = dep_with_fonte(DepSource::Path {
10858            caminho: "../caixa-teia/*(date)".into(),
10859        });
10860        let err = d.validate().unwrap_err();
10861        assert!(
10862            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
10863            "got {err:?}",
10864        );
10865    }
10866
10867    #[test]
10868    fn fonte_caminho_shell_command_substitution_fires_before_shell_subshell_grouping() {
10869        // Cascade pin on the upstream shell-command-substitution arm: a
10870        // value carrying both a backtick and `(` (``"../`whoami`/$(date)"``
10871        // — the canonical "I pasted a legacy-backtick + modern-paren
10872        // command-substitution chain" footgun) routes through
10873        // `FonteCaminhoShellCommandSubstitution` not
10874        // `FonteCaminhoShellSubshellGrouping`. The CWE-78 shell-
10875        // command-injection vector is the load-bearing root-cause edit
10876        // on every probe-as-both value.
10877        let d = dep_with_fonte(DepSource::Path {
10878            caminho: "../`whoami`/$(date)".into(),
10879        });
10880        let err = d.validate().unwrap_err();
10881        assert!(
10882            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
10883            "got {err:?}",
10884        );
10885    }
10886
10887    #[test]
10888    fn fonte_caminho_shell_background_fires_before_shell_subshell_grouping() {
10889        // Cascade pin on the upstream shell-background arm: a value
10890        // carrying both `&` and `(` (`"../caixa-teia & (cd foo)"` —
10891        // the canonical "I pasted a `cmd & (cd foo)` background-launch
10892        // + subshell-grouping chain" footgun) routes through
10893        // `FonteCaminhoShellBackground` not
10894        // `FonteCaminhoShellSubshellGrouping`. The background-launch
10895        // tail is the load-bearing root-cause edit on every probe-as-
10896        // both value.
10897        let d = dep_with_fonte(DepSource::Path {
10898            caminho: "../caixa-teia & (cd foo)".into(),
10899        });
10900        let err = d.validate().unwrap_err();
10901        assert!(
10902            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
10903            "got {err:?}",
10904        );
10905    }
10906
10907    #[test]
10908    fn fonte_caminho_shell_semicolon_fires_before_shell_subshell_grouping() {
10909        // Cascade pin on the upstream shell-semicolon arm: a value
10910        // carrying both `;` and `(` (`"../caixa-teia; (cd foo)"` —
10911        // the canonical sequential-cleanup + subshell-grouping paste
10912        // idiom) routes through `FonteCaminhoShellSemicolon` not
10913        // `FonteCaminhoShellSubshellGrouping`. The sequential-command-
10914        // separator paste is the load-bearing root-cause edit on
10915        // every probe-as-both value.
10916        let d = dep_with_fonte(DepSource::Path {
10917            caminho: "../caixa-teia; (cd foo)".into(),
10918        });
10919        let err = d.validate().unwrap_err();
10920        assert!(
10921            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
10922            "got {err:?}",
10923        );
10924    }
10925
10926    #[test]
10927    fn fonte_caminho_shell_pipe_fires_before_shell_subshell_grouping() {
10928        // Cascade pin on the upstream shell-pipe arm: a value carrying
10929        // both `|` and `(` (`"../caixa-teia | (tee log)"` — the
10930        // canonical pipeline-to-subshell-grouping paste idiom) routes
10931        // through `FonteCaminhoShellPipe` not
10932        // `FonteCaminhoShellSubshellGrouping`. The pipeline-tail paste
10933        // is the load-bearing root-cause edit on every probe-as-both
10934        // value.
10935        let d = dep_with_fonte(DepSource::Path {
10936            caminho: "../caixa-teia | (tee log)".into(),
10937        });
10938        let err = d.validate().unwrap_err();
10939        assert!(
10940            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10941            "got {err:?}",
10942        );
10943    }
10944
10945    #[test]
10946    fn fonte_caminho_shell_redirection_fires_before_shell_subshell_grouping() {
10947        // Cascade pin on the upstream shell-redirection arm: a value
10948        // carrying both `>` and `(` (`"../caixa-teia>log (cd foo)"` —
10949        // the canonical "I pasted a `cmd > log (cd foo)` redirect-
10950        // plus-subshell-grouping chain" footgun) routes through
10951        // `FonteCaminhoShellRedirection` not
10952        // `FonteCaminhoShellSubshellGrouping`. The input/output
10953        // redirection metachar carries the more self-locating `byte`
10954        // payload (it names which of `<` or `>` triggered), so the
10955        // prior arm wins on every probe-as-both value.
10956        let d = dep_with_fonte(DepSource::Path {
10957            caminho: "../caixa-teia>log (cd foo)".into(),
10958        });
10959        let err = d.validate().unwrap_err();
10960        assert!(
10961            matches!(
10962                err,
10963                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
10964            ),
10965            "got {err:?}",
10966        );
10967    }
10968
10969    #[test]
10970    fn fonte_caminho_backslash_fires_before_shell_subshell_grouping() {
10971        // Cascade pin on the upstream backslash arm: a value carrying
10972        // both `\` and `(` (`"..\caixa-teia\(cd foo)"` — the canonical
10973        // "I pasted a Windows-shell `cd ..\path\(cmd)` chain") routes
10974        // through `FonteCaminhoBackslash` not
10975        // `FonteCaminhoShellSubshellGrouping`. The cross-host-OS-
10976        // separator divergence is the load-bearing axis on every
10977        // probe-as-both value (an author who removes the `\` is the
10978        // root-cause edit; the `(` falls away in the same edit since
10979        // it's downstream of the Windows-shell convention).
10980        let d = dep_with_fonte(DepSource::Path {
10981            caminho: "..\\caixa-teia\\(cd foo)".into(),
10982        });
10983        let err = d.validate().unwrap_err();
10984        assert!(
10985            matches!(err, DepError::FonteCaminhoBackslash { .. }),
10986            "got {err:?}",
10987        );
10988    }
10989
10990    #[test]
10991    fn fonte_caminho_control_char_fires_before_shell_subshell_grouping() {
10992        // Cascade pin on the embedded-control-byte arm: a value
10993        // carrying both a control byte and `(` (`"../foo\n(cd bar)"` —
10994        // the canonical paste-from-multiline-doc footgun where a
10995        // newline landed mid-caminho between two paste fragments)
10996        // routes through `FonteCaminhoControlChar` not
10997        // `FonteCaminhoShellSubshellGrouping`. The POSIX-syscall-
10998        // rejected-byte / NUL-`CString::new`-fail diagnostic is the
10999        // load-bearing axis on every value that probes positive for
11000        // both — mirrors the cascade discipline on every prior arm.
11001        let d = dep_with_fonte(DepSource::Path {
11002            caminho: "../foo\n(cd bar)".into(),
11003        });
11004        let err = d.validate().unwrap_err();
11005        assert!(
11006            matches!(err, DepError::FonteCaminhoControlChar { .. }),
11007            "got {err:?}",
11008        );
11009    }
11010
11011    #[test]
11012    fn fonte_caminho_absolute_fires_before_shell_subshell_grouping() {
11013        // Cascade pin on the load-bearing leading-byte arm: a leading
11014        // `/` value with embedded `(` (`"/etc/(cd foo)"`) routes
11015        // through `FonteCaminhoAbsolute` not
11016        // `FonteCaminhoShellSubshellGrouping` — the host-layout-leak
11017        // diagnostic is the load-bearing axis, the subshell-grouping
11018        // byte is the secondary observation. Same precedence logic as
11019        // every prior leading-byte arm.
11020        let d = dep_with_fonte(DepSource::Path {
11021            caminho: "/etc/(cd foo)".into(),
11022        });
11023        let err = d.validate().unwrap_err();
11024        assert!(
11025            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11026            "got {err:?}",
11027        );
11028    }
11029
11030    #[test]
11031    fn fonte_caminho_var_expansion_fires_before_shell_subshell_grouping() {
11032        // Cascade pin on the upstream leading-`$` var-expansion arm: a
11033        // value carrying both a leading `$` and a `(` (`"$(date)/\
11034        // caixa-teia"` — the canonical "I pasted a `$(date)` modern-
11035        // command-substitution at the head of a sibling-workspace
11036        // path" footgun) routes through `FonteCaminhoVarExpansion` not
11037        // `FonteCaminhoShellSubshellGrouping`. The leading-byte
11038        // shell-variable-expansion is the more self-locating diagnostic
11039        // on values that probe as both — same load-bearing-leading-
11040        // byte cascade discipline every prior `:caminho` arm
11041        // establishes. Closing both halves of `$(<cmd>)` structurally
11042        // (leading `$` here, trailing `)` on the new arm) excludes the
11043        // entire modern Bourne command-substitution surface from the
11044        // typed `:caminho` accepted set; the cascade preserves the
11045        // narrower leading-byte diagnostic on values that probe both
11046        // halves at the canonical leading position.
11047        let d = dep_with_fonte(DepSource::Path {
11048            caminho: "$(date)/caixa-teia".into(),
11049        });
11050        let err = d.validate().unwrap_err();
11051        assert!(
11052            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
11053            "got {err:?}",
11054        );
11055    }
11056
11057    #[test]
11058    fn fonte_caminho_shell_subshell_grouping_fires_before_trailing_slash() {
11059        // Cascade pin on the immediate-successor arm: a value carrying
11060        // both `(` and a trailing `/` (`"../(cd foo)/"` — the canonical
11061        // "I tab-completed a path that already had a subshell-grouping
11062        // expansion tail" footgun) routes through
11063        // `FonteCaminhoShellSubshellGrouping` not
11064        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
11065        // the more semantic-locating axis (an author who removes the
11066        // `(` typically also drops the trailing separator since both
11067        // are paste-from-shell artifacts).
11068        let d = dep_with_fonte(DepSource::Path {
11069            caminho: "../(cd foo)/".into(),
11070        });
11071        let err = d.validate().unwrap_err();
11072        assert!(
11073            matches!(
11074                err,
11075                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
11076            ),
11077            "got {err:?}",
11078        );
11079    }
11080
11081    #[test]
11082    fn fonte_caminho_shell_subshell_grouping_diagnostic_carries_offending_dep_caminho_and_byte() {
11083        // Diagnostic-shape pin (peer with
11084        // `fonte_caminho_shell_glob_diagnostic_carries_offending_dep_caminho_and_byte`
11085        // on the closest two-byte peer arm): the error's Display
11086        // surfaces the offending `:nome`, the offending `:caminho`
11087        // verbatim, the offending byte's hex / character form, and
11088        // names the shell-subshell-grouping footgun explicitly so a
11089        // `feira lint` run can render the diagnostic without re-
11090        // parsing.
11091        let d = dep_with_fonte(DepSource::Path {
11092            caminho: "../caixa-teia/$(date)/build".into(),
11093        });
11094        let rendered = d.validate().unwrap_err().to_string();
11095        assert!(
11096            rendered.contains("caixa-teia"),
11097            "diagnostic must name the offending dep: {rendered}",
11098        );
11099        assert!(
11100            rendered.contains("../caixa-teia/$(date)/build"),
11101            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11102        );
11103        assert!(
11104            rendered.contains("0x28"),
11105            "diagnostic must surface the offending byte hex: {rendered:?}",
11106        );
11107        assert!(
11108            rendered.contains("subshell-grouping"),
11109            "diagnostic must name the shell-subshell-grouping footgun: {rendered:?}",
11110        );
11111        assert!(
11112            rendered.contains("command-substitution"),
11113            "diagnostic must reference the `$(<cmd>)` command-substitution vocabulary: \
11114             {rendered:?}",
11115        );
11116    }
11117
11118    // ── shell-brace-expansion / URI-Template-placeholder arm ───────────
11119    //
11120    // Peer with the prior `FonteCaminhoShellSubshellGrouping` (`(` /
11121    // `)`) byte-pair arm: the same per-byte cascade with the same
11122    // self-locating `byte: u8` diagnostic on the orthogonal `{` /
11123    // `}` brace-expansion / URI-Template placeholder axis. The peer
11124    // [`crate::render::is_git_repo_url`] (42d8f9d) closes the same
11125    // byte pair on the sibling `:fonte :repo` axis under the same
11126    // banner.
11127
11128    #[test]
11129    fn validate_rejects_path_fonte_with_caminho_carrying_brace_expansion_fan_across_siblings() {
11130        // The fail-before-pass-after pin for the canonical paste-from-
11131        // shell-history brace-expansion footgun: an author copies a
11132        // `cd ../{caixa-teia,caixa-helm}/build` shell-history one-
11133        // liner whose `{a,b}` brace expansion fans across two siblings
11134        // and silently passed every prior arm (`Path::is_absolute`
11135        // false on `..`, no control bytes, no `\`, no `<` / `>`, no
11136        // `|`, no `;`, no `&`, no backtick, no `*` / `?`, no `(` /
11137        // `)`, doesn't end in `/`; the leading-`$` f4efe9c
11138        // `FonteCaminhoVarExpansion` arm doesn't fire because the
11139        // value starts with `..` not `$`). The lacre embedded the
11140        // value verbatim, the resolver folded it through `Path::join`
11141        // looking for a literal `./../{caixa-teia,caixa-helm}/build`
11142        // subdirectory, and the failure surfaced at resolve time with
11143        // a non-self-locating `No such file or directory` error. The
11144        // new arm moves the rejection to validate time and names the
11145        // offending dep + caminho + byte verbatim. The arm fires on
11146        // the first `{` encountered.
11147        let d = dep_with_fonte(DepSource::Path {
11148            caminho: "../{caixa-teia,caixa-helm}/build".into(),
11149        });
11150        let err = d.validate().unwrap_err();
11151        let DepError::FonteCaminhoShellBraceExpansion {
11152            nome,
11153            caminho,
11154            byte,
11155        } = err
11156        else {
11157            panic!("expected FonteCaminhoShellBraceExpansion, got {err:?}");
11158        };
11159        assert_eq!(nome, "caixa-teia");
11160        assert_eq!(caminho, "../{caixa-teia,caixa-helm}/build");
11161        assert_eq!(byte, b'{');
11162    }
11163
11164    #[test]
11165    fn validate_rejects_path_fonte_with_caminho_carrying_close_brace() {
11166        // The symmetric close-brace paste shape (`"../caixa-teia}"` —
11167        // the degenerate "I selected an unbalanced closing brace out
11168        // of a shell-history block" idiom that probes for the
11169        // cascade's last-byte handling on a value carrying only the
11170        // closing byte). Pinned separately from the open-brace shape
11171        // so the gate's contract is "any `{` or `}` anywhere", not
11172        // single-byte coverage. Mirrors the peer
11173        // `validate_rejects_path_fonte_with_caminho_carrying_close_paren`
11174        // shape on the immediate-predecessor `FonteCaminhoShellSubshellGrouping`
11175        // arm.
11176        let d = dep_with_fonte(DepSource::Path {
11177            caminho: "../caixa-teia}".into(),
11178        });
11179        let err = d.validate().unwrap_err();
11180        let DepError::FonteCaminhoShellBraceExpansion { byte, .. } = err else {
11181            panic!("expected FonteCaminhoShellBraceExpansion, got {err:?}");
11182        };
11183        assert_eq!(byte, b'}');
11184    }
11185
11186    #[test]
11187    fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_brace() {
11188        // Leading-position `{` shape (`"{caixa-teia,caixa-helm}/build"`
11189        // — the canonical "I selected a `{a,b}` brace-expansion prefix
11190        // out of a shell-history one-liner" idiom). Pinned separately
11191        // from the embedded-byte shape so the gate covers every
11192        // position, not only mid-path.
11193        let d = dep_with_fonte(DepSource::Path {
11194            caminho: "{caixa-teia,caixa-helm}/build".into(),
11195        });
11196        let err = d.validate().unwrap_err();
11197        assert!(
11198            matches!(
11199                err,
11200                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
11201            ),
11202            "got {err:?}",
11203        );
11204    }
11205
11206    #[test]
11207    fn validate_rejects_path_fonte_with_caminho_carrying_uri_template_placeholder() {
11208        // The canonical URI-Template / Mustache / Helm doubled-brace
11209        // placeholder shape (`"../{{org}}/caixa-teia"` — the canonical
11210        // "I copied a `https://github.com/{{org}}/caixa-teia` README
11211        // quick-start / OpenAPI spec / Helm chart `home:` template
11212        // and forgot to substitute the placeholder" footgun). The arm
11213        // fires on the first `{` encountered; pinned so the gate's
11214        // coverage extends from the bare-brace shell-history shape to
11215        // the doubled-brace URI-Template / templating-engine shape.
11216        // Mirrors the peer 42d8f9d `is_git_repo_url` arm on the
11217        // sibling `:fonte :repo` axis.
11218        let d = dep_with_fonte(DepSource::Path {
11219            caminho: "../{{org}}/caixa-teia".into(),
11220        });
11221        let err = d.validate().unwrap_err();
11222        assert!(
11223            matches!(
11224                err,
11225                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
11226            ),
11227            "got {err:?}",
11228        );
11229    }
11230
11231    #[test]
11232    fn validate_rejects_path_fonte_with_caminho_carrying_brace_range_expansion() {
11233        // The canonical bash brace-range-expansion shape (`"../caixa-
11234        // v{1..10}"` — the `{1..10}` sequence expansion every bash /
11235        // zsh `for i in {1..10}; do …; done` idiom uses, the symmetric
11236        // sequence-range form to the `{a,b,c}` comma-separated form).
11237        // The arm fires on the first `{` encountered; pinned so the
11238        // gate's coverage extends from the comma-separated form to
11239        // the integer-range form.
11240        let d = dep_with_fonte(DepSource::Path {
11241            caminho: "../caixa-v{1..10}".into(),
11242        });
11243        let err = d.validate().unwrap_err();
11244        assert!(
11245            matches!(
11246                err,
11247                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
11248            ),
11249            "got {err:?}",
11250        );
11251    }
11252
11253    #[test]
11254    fn validate_accepts_path_fonte_with_caminho_carrying_no_brace_expansion() {
11255        // The positive-control pin: the gate targets only `{` / `}`,
11256        // never adjacent printable ASCII or POSIX-valid bytes. The
11257        // canonical relative POSIX path (`"../caixa-teia"`) and a
11258        // nested deeply-pathed variant with adjacent printable
11259        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue to
11260        // validate cleanly so the gate doesn't widen to a "no
11261        // printable punctuation anywhere" sweep that would defeat
11262        // the entire path-fonte author surface. Peer with
11263        // `validate_accepts_path_fonte_with_caminho_carrying_no_subshell_grouping`
11264        // on the immediate-predecessor arm.
11265        let d = dep_with_fonte(DepSource::Path {
11266            caminho: "../caixa-teia/sub-dir.v2".into(),
11267        });
11268        d.validate().unwrap();
11269    }
11270
11271    #[test]
11272    fn fonte_caminho_shell_subshell_grouping_fires_before_shell_brace_expansion() {
11273        // Cascade pin on the immediate-predecessor arm: a value
11274        // carrying both `(` and `{` (`"../(cd foo)/{a,b}"` — the
11275        // canonical "I pasted a subshell-grouping followed by a
11276        // brace-expansion tail" footgun) routes through
11277        // `FonteCaminhoShellSubshellGrouping` not
11278        // `FonteCaminhoShellBraceExpansion`. The subshell-grouping
11279        // shape is the more semantic-locating axis on every probe-
11280        // as-both value because it closes both halves of the modern
11281        // Bourne `$(<cmd>)` command-substitution surface — same
11282        // cascade discipline every prior `:caminho` arm establishes.
11283        let d = dep_with_fonte(DepSource::Path {
11284            caminho: "../(cd foo)/{a,b}".into(),
11285        });
11286        let err = d.validate().unwrap_err();
11287        assert!(
11288            matches!(
11289                err,
11290                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
11291            ),
11292            "got {err:?}",
11293        );
11294    }
11295
11296    #[test]
11297    fn fonte_caminho_shell_glob_fires_before_shell_brace_expansion() {
11298        // Cascade pin on the upstream shell-glob arm: a value carrying
11299        // both `*` and `{` (`"../caixa-teia/*{a,b}"` — the canonical
11300        // "I pasted a glob expansion followed by a brace-expansion
11301        // tail" footgun) routes through `FonteCaminhoShellGlob` not
11302        // `FonteCaminhoShellBraceExpansion`. The pathname-expansion
11303        // shape is the load-bearing root-cause edit on every
11304        // probe-as-both value.
11305        let d = dep_with_fonte(DepSource::Path {
11306            caminho: "../caixa-teia/*{a,b}".into(),
11307        });
11308        let err = d.validate().unwrap_err();
11309        assert!(
11310            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
11311            "got {err:?}",
11312        );
11313    }
11314
11315    #[test]
11316    fn fonte_caminho_shell_command_substitution_fires_before_shell_brace_expansion() {
11317        // Cascade pin on the upstream shell-command-substitution arm:
11318        // a value carrying both a backtick and `{` (``"../`whoami`/{a,b}"``
11319        // — the canonical "I pasted a legacy-backtick command-
11320        // substitution followed by a brace-expansion fan-out" footgun)
11321        // routes through `FonteCaminhoShellCommandSubstitution` not
11322        // `FonteCaminhoShellBraceExpansion`. The CWE-78 shell-
11323        // command-injection vector is the load-bearing root-cause
11324        // edit on every probe-as-both value.
11325        let d = dep_with_fonte(DepSource::Path {
11326            caminho: "../`whoami`/{a,b}".into(),
11327        });
11328        let err = d.validate().unwrap_err();
11329        assert!(
11330            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11331            "got {err:?}",
11332        );
11333    }
11334
11335    #[test]
11336    fn fonte_caminho_shell_background_fires_before_shell_brace_expansion() {
11337        // Cascade pin on the upstream shell-background arm: a value
11338        // carrying both `&` and `{` (`"../caixa-teia & {a,b}"` — the
11339        // canonical "I pasted a `cmd & {fork-fan}` background-launch
11340        // + brace-expansion chain" footgun) routes through
11341        // `FonteCaminhoShellBackground` not
11342        // `FonteCaminhoShellBraceExpansion`. The background-launch
11343        // tail is the load-bearing root-cause edit on every
11344        // probe-as-both value.
11345        let d = dep_with_fonte(DepSource::Path {
11346            caminho: "../caixa-teia & {a,b}".into(),
11347        });
11348        let err = d.validate().unwrap_err();
11349        assert!(
11350            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11351            "got {err:?}",
11352        );
11353    }
11354
11355    #[test]
11356    fn fonte_caminho_shell_semicolon_fires_before_shell_brace_expansion() {
11357        // Cascade pin on the upstream shell-semicolon arm: a value
11358        // carrying both `;` and `{` (`"../caixa-teia; {a,b}"` — the
11359        // canonical sequential-cleanup + brace-expansion paste
11360        // idiom) routes through `FonteCaminhoShellSemicolon` not
11361        // `FonteCaminhoShellBraceExpansion`. The sequential-command-
11362        // separator paste is the load-bearing root-cause edit on
11363        // every probe-as-both value.
11364        let d = dep_with_fonte(DepSource::Path {
11365            caminho: "../caixa-teia; {a,b}".into(),
11366        });
11367        let err = d.validate().unwrap_err();
11368        assert!(
11369            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11370            "got {err:?}",
11371        );
11372    }
11373
11374    #[test]
11375    fn fonte_caminho_shell_pipe_fires_before_shell_brace_expansion() {
11376        // Cascade pin on the upstream shell-pipe arm: a value
11377        // carrying both `|` and `{` (`"../caixa-teia | {tee,cat}"`
11378        // — the canonical pipeline-to-brace-expansion paste idiom)
11379        // routes through `FonteCaminhoShellPipe` not
11380        // `FonteCaminhoShellBraceExpansion`. The pipeline-tail paste
11381        // is the load-bearing root-cause edit on every probe-as-
11382        // both value.
11383        let d = dep_with_fonte(DepSource::Path {
11384            caminho: "../caixa-teia | {tee,cat}".into(),
11385        });
11386        let err = d.validate().unwrap_err();
11387        assert!(
11388            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11389            "got {err:?}",
11390        );
11391    }
11392
11393    #[test]
11394    fn fonte_caminho_shell_redirection_fires_before_shell_brace_expansion() {
11395        // Cascade pin on the upstream shell-redirection arm: a value
11396        // carrying both `>` and `{` (`"../caixa-teia>log {a,b}"` —
11397        // the canonical "I pasted a `cmd > log {a,b}` redirect-
11398        // plus-brace-expansion chain" footgun) routes through
11399        // `FonteCaminhoShellRedirection` not
11400        // `FonteCaminhoShellBraceExpansion`. The input/output
11401        // redirection metachar carries the more self-locating
11402        // `byte` payload, so the prior arm wins on every probe-
11403        // as-both value.
11404        let d = dep_with_fonte(DepSource::Path {
11405            caminho: "../caixa-teia>log {a,b}".into(),
11406        });
11407        let err = d.validate().unwrap_err();
11408        assert!(
11409            matches!(
11410                err,
11411                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11412            ),
11413            "got {err:?}",
11414        );
11415    }
11416
11417    #[test]
11418    fn fonte_caminho_backslash_fires_before_shell_brace_expansion() {
11419        // Cascade pin on the upstream backslash arm: a value
11420        // carrying both `\` and `{` (`"..\caixa-teia\{a,b}"` — the
11421        // canonical "I pasted a Windows-shell `cd ..\path\{a,b}`
11422        // chain") routes through `FonteCaminhoBackslash` not
11423        // `FonteCaminhoShellBraceExpansion`. The cross-host-OS-
11424        // separator divergence is the load-bearing axis on every
11425        // probe-as-both value.
11426        let d = dep_with_fonte(DepSource::Path {
11427            caminho: "..\\caixa-teia\\{a,b}".into(),
11428        });
11429        let err = d.validate().unwrap_err();
11430        assert!(
11431            matches!(err, DepError::FonteCaminhoBackslash { .. }),
11432            "got {err:?}",
11433        );
11434    }
11435
11436    #[test]
11437    fn fonte_caminho_control_char_fires_before_shell_brace_expansion() {
11438        // Cascade pin on the embedded-control-byte arm: a value
11439        // carrying both a control byte and `{` (`"../foo\n{a,b}"` —
11440        // the canonical paste-from-multiline-doc footgun where a
11441        // newline landed mid-caminho between two paste fragments)
11442        // routes through `FonteCaminhoControlChar` not
11443        // `FonteCaminhoShellBraceExpansion`. The POSIX-syscall-
11444        // rejected-byte / NUL-`CString::new`-fail diagnostic is the
11445        // load-bearing axis on every value that probes positive for
11446        // both — mirrors the cascade discipline on every prior arm.
11447        let d = dep_with_fonte(DepSource::Path {
11448            caminho: "../foo\n{a,b}".into(),
11449        });
11450        let err = d.validate().unwrap_err();
11451        assert!(
11452            matches!(err, DepError::FonteCaminhoControlChar { .. }),
11453            "got {err:?}",
11454        );
11455    }
11456
11457    #[test]
11458    fn fonte_caminho_absolute_fires_before_shell_brace_expansion() {
11459        // Cascade pin on the load-bearing leading-byte arm: a
11460        // leading `/` value with embedded `{` (`"/etc/{a,b}"`)
11461        // routes through `FonteCaminhoAbsolute` not
11462        // `FonteCaminhoShellBraceExpansion` — the host-layout-leak
11463        // diagnostic is the load-bearing axis, the brace-expansion
11464        // byte is the secondary observation. Same precedence logic
11465        // as every prior leading-byte arm.
11466        let d = dep_with_fonte(DepSource::Path {
11467            caminho: "/etc/{a,b}".into(),
11468        });
11469        let err = d.validate().unwrap_err();
11470        assert!(
11471            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11472            "got {err:?}",
11473        );
11474    }
11475
11476    #[test]
11477    fn fonte_caminho_var_expansion_fires_before_shell_brace_expansion() {
11478        // Cascade pin on the upstream leading-`$` var-expansion
11479        // arm: a value carrying both a leading `$` and a `{`
11480        // (`"${ORG}/caixa-teia"` — the canonical "I pasted a
11481        // `${ORG}` shell-variable + curly-brace expansion at the
11482        // head of a sibling-workspace path" footgun) routes through
11483        // `FonteCaminhoVarExpansion` not
11484        // `FonteCaminhoShellBraceExpansion`. The leading-byte
11485        // shell-variable-expansion is the more self-locating
11486        // diagnostic on values that probe as both — same
11487        // load-bearing-leading-byte cascade discipline every prior
11488        // `:caminho` arm establishes.
11489        let d = dep_with_fonte(DepSource::Path {
11490            caminho: "${ORG}/caixa-teia".into(),
11491        });
11492        let err = d.validate().unwrap_err();
11493        assert!(
11494            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
11495            "got {err:?}",
11496        );
11497    }
11498
11499    #[test]
11500    fn fonte_caminho_shell_brace_expansion_fires_before_trailing_slash() {
11501        // Cascade pin on the immediate-successor arm: a value
11502        // carrying both `{` and a trailing `/`
11503        // (`"../{caixa-teia,caixa-helm}/"` — the canonical "I
11504        // tab-completed a path that already had a brace-expansion
11505        // expansion tail" footgun) routes through
11506        // `FonteCaminhoShellBraceExpansion` not
11507        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
11508        // is the more semantic-locating axis (an author who removes
11509        // the `{` typically also drops the trailing separator since
11510        // both are paste-from-shell artifacts).
11511        let d = dep_with_fonte(DepSource::Path {
11512            caminho: "../{caixa-teia,caixa-helm}/".into(),
11513        });
11514        let err = d.validate().unwrap_err();
11515        assert!(
11516            matches!(
11517                err,
11518                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
11519            ),
11520            "got {err:?}",
11521        );
11522    }
11523
11524    #[test]
11525    fn fonte_caminho_shell_brace_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
11526        // Diagnostic-shape pin (peer with
11527        // `fonte_caminho_shell_subshell_grouping_diagnostic_carries_offending_dep_caminho_and_byte`
11528        // on the closest two-byte peer arm): the error's Display
11529        // surfaces the offending `:nome`, the offending `:caminho`
11530        // verbatim, the offending byte's hex / character form, and
11531        // names the shell-brace-expansion / URI-Template footgun
11532        // explicitly so a `feira lint` run can render the diagnostic
11533        // without re-parsing.
11534        let d = dep_with_fonte(DepSource::Path {
11535            caminho: "../{caixa-teia,caixa-helm}/build".into(),
11536        });
11537        let rendered = d.validate().unwrap_err().to_string();
11538        assert!(
11539            rendered.contains("caixa-teia"),
11540            "diagnostic must name the offending dep: {rendered}",
11541        );
11542        assert!(
11543            rendered.contains("../{caixa-teia,caixa-helm}/build"),
11544            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11545        );
11546        assert!(
11547            rendered.contains("0x7b"),
11548            "diagnostic must surface the offending byte hex: {rendered:?}",
11549        );
11550        assert!(
11551            rendered.contains("brace-expansion"),
11552            "diagnostic must name the shell-brace-expansion footgun: {rendered:?}",
11553        );
11554        assert!(
11555            rendered.contains("URI Template"),
11556            "diagnostic must reference the RFC-6570 URI-Template-placeholder vocabulary: \
11557             {rendered:?}",
11558        );
11559    }
11560
11561    #[test]
11562    fn validate_rejects_path_fonte_with_caminho_carrying_bracket_glob_character_class() {
11563        // The canonical paste-from-shell-history bracket-glob /
11564        // character-class footgun: an author copies a
11565        // `cd ../caixa-[a-z]/build` shell-history one-liner whose
11566        // `[a-z]` POSIX glob character-class matches every lowercase-
11567        // ASCII-suffix sibling caixa directory and silently passed
11568        // every prior arm (`Path::is_absolute` false on `..`, no
11569        // control bytes, no `\`, no `<` / `>`, no `|`, no `;`, no
11570        // `&`, no backtick, no `*` / `?`, no `(` / `)`, no `{` /
11571        // `}`, doesn't end in `/`; the leading-`$` f4efe9c
11572        // `FonteCaminhoVarExpansion` arm doesn't fire because the
11573        // value starts with `..` not `$`). The lacre embedded the
11574        // value verbatim, the resolver folded it through
11575        // `Path::join` looking for a literal `./../caixa-[a-z]/
11576        // build` subdirectory, and the failure surfaced at resolve
11577        // time with a non-self-locating `No such file or directory`
11578        // error. The new arm moves the rejection to validate time
11579        // and names the offending dep + caminho + byte verbatim.
11580        // The arm fires on the first `[` encountered.
11581        let d = dep_with_fonte(DepSource::Path {
11582            caminho: "../caixa-[a-z]/build".into(),
11583        });
11584        let err = d.validate().unwrap_err();
11585        let DepError::FonteCaminhoShellBracketExpansion {
11586            nome,
11587            caminho,
11588            byte,
11589        } = err
11590        else {
11591            panic!("expected FonteCaminhoShellBracketExpansion, got {err:?}");
11592        };
11593        assert_eq!(nome, "caixa-teia");
11594        assert_eq!(caminho, "../caixa-[a-z]/build");
11595        assert_eq!(byte, b'[');
11596    }
11597
11598    #[test]
11599    fn validate_rejects_path_fonte_with_caminho_carrying_close_bracket() {
11600        // The symmetric close-bracket paste shape (`"../caixa-teia]"`
11601        // — the degenerate "I selected an unbalanced closing bracket
11602        // out of a glob character-class block" idiom that probes for
11603        // the cascade's last-byte handling on a value carrying only
11604        // the closing byte). Pinned separately from the open-bracket
11605        // shape so the gate's contract is "any `[` or `]` anywhere",
11606        // not single-byte coverage. Mirrors the peer
11607        // `validate_rejects_path_fonte_with_caminho_carrying_close_brace`
11608        // shape on the immediate-predecessor
11609        // `FonteCaminhoShellBraceExpansion` arm.
11610        let d = dep_with_fonte(DepSource::Path {
11611            caminho: "../caixa-teia]".into(),
11612        });
11613        let err = d.validate().unwrap_err();
11614        let DepError::FonteCaminhoShellBracketExpansion { byte, .. } = err else {
11615            panic!("expected FonteCaminhoShellBracketExpansion, got {err:?}");
11616        };
11617        assert_eq!(byte, b']');
11618    }
11619
11620    #[test]
11621    fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_bracket() {
11622        // Leading-position `[` shape (`"[caixa-teia]/build"` — the
11623        // canonical "I selected a `[caixa-teia]` TOML-table-header /
11624        // glob-character-class prefix out of an aligned config /
11625        // shell-history one-liner" idiom). Pinned separately from
11626        // the embedded-byte shape so the gate covers every position,
11627        // not only mid-path.
11628        let d = dep_with_fonte(DepSource::Path {
11629            caminho: "[caixa-teia]/build".into(),
11630        });
11631        let err = d.validate().unwrap_err();
11632        assert!(
11633            matches!(
11634                err,
11635                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
11636            ),
11637            "got {err:?}",
11638        );
11639    }
11640
11641    #[test]
11642    fn validate_rejects_path_fonte_with_caminho_carrying_toml_inline_array() {
11643        // The canonical TOML inline-array / YAML flow-sequence
11644        // paste shape (`"../[\"a\", \"b\"]/caixa-teia"` — the
11645        // canonical "I copied a `features = [\"a\", \"b\"]` TOML
11646        // inline-array out of a sibling-Cargo manifest" cross-idiom
11647        // leak; the symmetric YAML flow-sequence form `paths: [/a,
11648        // /b]` paste-from-values.yaml shape carries the same
11649        // bracket pair). The arm fires on the first `[` encountered;
11650        // pinned so the gate's coverage extends from the bare-
11651        // bracket glob-character-class shape to the TOML / YAML /
11652        // JSON array-literal shape.
11653        let d = dep_with_fonte(DepSource::Path {
11654            caminho: "../[\"a\", \"b\"]/caixa-teia".into(),
11655        });
11656        let err = d.validate().unwrap_err();
11657        assert!(
11658            matches!(
11659                err,
11660                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
11661            ),
11662            "got {err:?}",
11663        );
11664    }
11665
11666    #[test]
11667    fn validate_rejects_path_fonte_with_caminho_carrying_shell_test_builtin() {
11668        // The canonical POSIX `test` / `[` builtin command paste
11669        // shape (`"../[ -d caixa-teia ]"` — the `[ <expr> ]` shell-
11670        // script conditional every paste-from-shell-script idiom
11671        // carries; bash's `[[ <expr> ]]` extended-test grammar
11672        // would surface the same byte pair). The arm fires on the
11673        // first `[` encountered; pinned so the gate's coverage
11674        // extends from the embedded-glob-character-class shape to
11675        // the leading-`test`-builtin / extended-test form.
11676        let d = dep_with_fonte(DepSource::Path {
11677            caminho: "../[ -d caixa-teia ]".into(),
11678        });
11679        let err = d.validate().unwrap_err();
11680        assert!(
11681            matches!(
11682                err,
11683                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
11684            ),
11685            "got {err:?}",
11686        );
11687    }
11688
11689    #[test]
11690    fn validate_accepts_path_fonte_with_caminho_carrying_no_bracket_expansion() {
11691        // The positive-control pin: the gate targets only `[` /
11692        // `]`, never adjacent printable ASCII or POSIX-valid bytes.
11693        // The canonical relative POSIX path (`"../caixa-teia"`) and
11694        // a nested deeply-pathed variant with adjacent printable
11695        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
11696        // to validate cleanly so the gate doesn't widen to a "no
11697        // printable punctuation anywhere" sweep that would defeat
11698        // the entire path-fonte author surface. Peer with
11699        // `validate_accepts_path_fonte_with_caminho_carrying_no_brace_expansion`
11700        // on the immediate-predecessor arm.
11701        let d = dep_with_fonte(DepSource::Path {
11702            caminho: "../caixa-teia/sub-dir.v2".into(),
11703        });
11704        d.validate().unwrap();
11705    }
11706
11707    #[test]
11708    fn fonte_caminho_shell_brace_expansion_fires_before_shell_bracket_expansion() {
11709        // Cascade pin on the immediate-predecessor arm: a value
11710        // carrying both `{` and `[` (`"../{a,b}[ch]"` — the
11711        // canonical "I pasted a brace-expansion fan followed by a
11712        // glob-character-class tail" footgun) routes through
11713        // `FonteCaminhoShellBraceExpansion` not
11714        // `FonteCaminhoShellBracketExpansion`. The brace-expansion
11715        // fan is the load-bearing root-cause edit on every
11716        // probe-as-both value because the bracket-class tail
11717        // typically rides on a prior brace-expansion expansion;
11718        // same cascade discipline every prior `:caminho` arm
11719        // establishes.
11720        let d = dep_with_fonte(DepSource::Path {
11721            caminho: "../{a,b}[ch]".into(),
11722        });
11723        let err = d.validate().unwrap_err();
11724        assert!(
11725            matches!(
11726                err,
11727                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
11728            ),
11729            "got {err:?}",
11730        );
11731    }
11732
11733    #[test]
11734    fn fonte_caminho_shell_subshell_grouping_fires_before_shell_bracket_expansion() {
11735        // Cascade pin on the upstream shell-subshell-grouping arm:
11736        // a value carrying both `(` and `[` (`"../(cd foo)/[ch]"` —
11737        // the canonical "I pasted a subshell-grouping followed by
11738        // a glob-character-class tail" footgun) routes through
11739        // `FonteCaminhoShellSubshellGrouping` not
11740        // `FonteCaminhoShellBracketExpansion`. The modern Bourne
11741        // `$(<cmd>)` command-substitution boundary is the load-
11742        // bearing axis on every probe-as-both value.
11743        let d = dep_with_fonte(DepSource::Path {
11744            caminho: "../(cd foo)/[ch]".into(),
11745        });
11746        let err = d.validate().unwrap_err();
11747        assert!(
11748            matches!(
11749                err,
11750                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
11751            ),
11752            "got {err:?}",
11753        );
11754    }
11755
11756    #[test]
11757    fn fonte_caminho_shell_glob_fires_before_shell_bracket_expansion() {
11758        // Cascade pin on the upstream shell-glob arm: a value
11759        // carrying both `*` and `[` (`"../caixa-teia/*[ch]"` — the
11760        // canonical "I pasted a `*.[ch]` C-source-file glob whose
11761        // unbounded `*` precedes the bracket character-class"
11762        // footgun) routes through `FonteCaminhoShellGlob` not
11763        // `FonteCaminhoShellBracketExpansion`. The unbounded
11764        // pathname-expansion sentinel is the load-bearing root-
11765        // cause edit on every probe-as-both value — the unbounded
11766        // `*` carries the more aggressive expansion vector than
11767        // the bounded `[ch]` class, so the prior arm wins.
11768        let d = dep_with_fonte(DepSource::Path {
11769            caminho: "../caixa-teia/*[ch]".into(),
11770        });
11771        let err = d.validate().unwrap_err();
11772        assert!(
11773            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
11774            "got {err:?}",
11775        );
11776    }
11777
11778    #[test]
11779    fn fonte_caminho_shell_command_substitution_fires_before_shell_bracket_expansion() {
11780        // Cascade pin on the upstream shell-command-substitution
11781        // arm: a value carrying both a backtick and `[`
11782        // (``"../`whoami`/[ch]"`` — the canonical "I pasted a
11783        // legacy-backtick command-substitution followed by a
11784        // glob-character-class tail" footgun) routes through
11785        // `FonteCaminhoShellCommandSubstitution` not
11786        // `FonteCaminhoShellBracketExpansion`. The CWE-78 shell-
11787        // command-injection vector is the load-bearing root-cause
11788        // edit on every probe-as-both value.
11789        let d = dep_with_fonte(DepSource::Path {
11790            caminho: "../`whoami`/[ch]".into(),
11791        });
11792        let err = d.validate().unwrap_err();
11793        assert!(
11794            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11795            "got {err:?}",
11796        );
11797    }
11798
11799    #[test]
11800    fn fonte_caminho_shell_background_fires_before_shell_bracket_expansion() {
11801        // Cascade pin on the upstream shell-background arm: a
11802        // value carrying both `&` and `[` (`"../caixa-teia & [ch]"`
11803        // — the canonical "I pasted a `cmd & [glob]` background-
11804        // launch + bracket-class chain" footgun) routes through
11805        // `FonteCaminhoShellBackground` not
11806        // `FonteCaminhoShellBracketExpansion`. The background-
11807        // launch tail is the load-bearing root-cause edit on
11808        // every probe-as-both value.
11809        let d = dep_with_fonte(DepSource::Path {
11810            caminho: "../caixa-teia & [ch]".into(),
11811        });
11812        let err = d.validate().unwrap_err();
11813        assert!(
11814            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11815            "got {err:?}",
11816        );
11817    }
11818
11819    #[test]
11820    fn fonte_caminho_shell_semicolon_fires_before_shell_bracket_expansion() {
11821        // Cascade pin on the upstream shell-semicolon arm: a value
11822        // carrying both `;` and `[` (`"../caixa-teia; [ch]"` — the
11823        // canonical sequential-cleanup + bracket-class paste
11824        // idiom) routes through `FonteCaminhoShellSemicolon` not
11825        // `FonteCaminhoShellBracketExpansion`. The sequential-
11826        // command-separator paste is the load-bearing root-cause
11827        // edit on every probe-as-both value.
11828        let d = dep_with_fonte(DepSource::Path {
11829            caminho: "../caixa-teia; [ch]".into(),
11830        });
11831        let err = d.validate().unwrap_err();
11832        assert!(
11833            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11834            "got {err:?}",
11835        );
11836    }
11837
11838    #[test]
11839    fn fonte_caminho_shell_pipe_fires_before_shell_bracket_expansion() {
11840        // Cascade pin on the upstream shell-pipe arm: a value
11841        // carrying both `|` and `[` (`"../caixa-teia | [tee]"` —
11842        // the canonical pipeline-to-bracket-class paste idiom)
11843        // routes through `FonteCaminhoShellPipe` not
11844        // `FonteCaminhoShellBracketExpansion`. The pipeline-tail
11845        // paste is the load-bearing root-cause edit on every
11846        // probe-as-both value.
11847        let d = dep_with_fonte(DepSource::Path {
11848            caminho: "../caixa-teia | [tee]".into(),
11849        });
11850        let err = d.validate().unwrap_err();
11851        assert!(
11852            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11853            "got {err:?}",
11854        );
11855    }
11856
11857    #[test]
11858    fn fonte_caminho_shell_redirection_fires_before_shell_bracket_expansion() {
11859        // Cascade pin on the upstream shell-redirection arm: a
11860        // value carrying both `>` and `[` (`"../caixa-teia>log
11861        // [ch]"` — the canonical "I pasted a `cmd > log [glob]`
11862        // redirect-plus-bracket chain" footgun) routes through
11863        // `FonteCaminhoShellRedirection` not
11864        // `FonteCaminhoShellBracketExpansion`. The input/output
11865        // redirection metachar carries the more self-locating
11866        // `byte` payload, so the prior arm wins on every
11867        // probe-as-both value.
11868        let d = dep_with_fonte(DepSource::Path {
11869            caminho: "../caixa-teia>log [ch]".into(),
11870        });
11871        let err = d.validate().unwrap_err();
11872        assert!(
11873            matches!(
11874                err,
11875                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11876            ),
11877            "got {err:?}",
11878        );
11879    }
11880
11881    #[test]
11882    fn fonte_caminho_backslash_fires_before_shell_bracket_expansion() {
11883        // Cascade pin on the upstream backslash arm: a value
11884        // carrying both `\` and `[` (`"..\caixa-teia\[ch]"` — the
11885        // canonical "I pasted a Windows-shell `cd ..\path\[glob]`
11886        // chain") routes through `FonteCaminhoBackslash` not
11887        // `FonteCaminhoShellBracketExpansion`. The cross-host-OS-
11888        // separator divergence is the load-bearing axis on every
11889        // probe-as-both value.
11890        let d = dep_with_fonte(DepSource::Path {
11891            caminho: "..\\caixa-teia\\[ch]".into(),
11892        });
11893        let err = d.validate().unwrap_err();
11894        assert!(
11895            matches!(err, DepError::FonteCaminhoBackslash { .. }),
11896            "got {err:?}",
11897        );
11898    }
11899
11900    #[test]
11901    fn fonte_caminho_control_char_fires_before_shell_bracket_expansion() {
11902        // Cascade pin on the embedded-control-byte arm: a value
11903        // carrying both a control byte and `[` (`"../foo\n[ch]"` —
11904        // the canonical paste-from-multiline-doc footgun where a
11905        // newline landed mid-caminho between two paste fragments)
11906        // routes through `FonteCaminhoControlChar` not
11907        // `FonteCaminhoShellBracketExpansion`. The POSIX-syscall-
11908        // rejected-byte / NUL-`CString::new`-fail diagnostic is
11909        // the load-bearing axis on every value that probes
11910        // positive for both — mirrors the cascade discipline on
11911        // every prior arm.
11912        let d = dep_with_fonte(DepSource::Path {
11913            caminho: "../foo\n[ch]".into(),
11914        });
11915        let err = d.validate().unwrap_err();
11916        assert!(
11917            matches!(err, DepError::FonteCaminhoControlChar { .. }),
11918            "got {err:?}",
11919        );
11920    }
11921
11922    #[test]
11923    fn fonte_caminho_absolute_fires_before_shell_bracket_expansion() {
11924        // Cascade pin on the load-bearing leading-byte arm: a
11925        // leading `/` value with embedded `[` (`"/etc/[ch]"`)
11926        // routes through `FonteCaminhoAbsolute` not
11927        // `FonteCaminhoShellBracketExpansion` — the host-layout-
11928        // leak diagnostic is the load-bearing axis, the bracket-
11929        // expansion byte is the secondary observation. Same
11930        // precedence logic as every prior leading-byte arm.
11931        let d = dep_with_fonte(DepSource::Path {
11932            caminho: "/etc/[ch]".into(),
11933        });
11934        let err = d.validate().unwrap_err();
11935        assert!(
11936            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11937            "got {err:?}",
11938        );
11939    }
11940
11941    #[test]
11942    fn fonte_caminho_var_expansion_fires_before_shell_bracket_expansion() {
11943        // Cascade pin on the upstream leading-`$` var-expansion
11944        // arm: a value carrying both a leading `$` and a `[`
11945        // (`"$DIR/[ch]"` — the canonical "I pasted a `$DIR` shell-
11946        // variable + bracket-class at the head of a sibling-
11947        // workspace path" footgun) routes through
11948        // `FonteCaminhoVarExpansion` not
11949        // `FonteCaminhoShellBracketExpansion`. The leading-byte
11950        // shell-variable-expansion is the more self-locating
11951        // diagnostic on values that probe as both — same
11952        // load-bearing-leading-byte cascade discipline every
11953        // prior `:caminho` arm establishes.
11954        let d = dep_with_fonte(DepSource::Path {
11955            caminho: "$DIR/[ch]".into(),
11956        });
11957        let err = d.validate().unwrap_err();
11958        assert!(
11959            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
11960            "got {err:?}",
11961        );
11962    }
11963
11964    #[test]
11965    fn fonte_caminho_shell_bracket_expansion_fires_before_trailing_slash() {
11966        // Cascade pin on the immediate-successor arm: a value
11967        // carrying both `[` and a trailing `/` (`"../[a-z]/"` —
11968        // the canonical "I tab-completed a path that already had
11969        // a bracket-glob-character-class expansion tail" footgun)
11970        // routes through `FonteCaminhoShellBracketExpansion` not
11971        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
11972        // is the more semantic-locating axis (an author who
11973        // removes the `[` typically also drops the trailing
11974        // separator since both are paste-from-shell artifacts).
11975        let d = dep_with_fonte(DepSource::Path {
11976            caminho: "../[a-z]/".into(),
11977        });
11978        let err = d.validate().unwrap_err();
11979        assert!(
11980            matches!(
11981                err,
11982                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
11983            ),
11984            "got {err:?}",
11985        );
11986    }
11987
11988    #[test]
11989    fn fonte_caminho_shell_bracket_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
11990        // Diagnostic-shape pin (peer with
11991        // `fonte_caminho_shell_brace_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
11992        // on the closest two-byte peer arm): the error's Display
11993        // surfaces the offending `:nome`, the offending `:caminho`
11994        // verbatim, the offending byte's hex / character form, and
11995        // names the shell-bracket-expansion / glob-character-class
11996        // footgun explicitly so a `feira lint` run can render the
11997        // diagnostic without re-parsing.
11998        let d = dep_with_fonte(DepSource::Path {
11999            caminho: "../caixa-[a-z]/build".into(),
12000        });
12001        let rendered = d.validate().unwrap_err().to_string();
12002        assert!(
12003            rendered.contains("caixa-teia"),
12004            "diagnostic must name the offending dep: {rendered}",
12005        );
12006        assert!(
12007            rendered.contains("../caixa-[a-z]/build"),
12008            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
12009        );
12010        assert!(
12011            rendered.contains("0x5b"),
12012            "diagnostic must surface the offending byte hex: {rendered:?}",
12013        );
12014        assert!(
12015            rendered.contains("bracket-expansion"),
12016            "diagnostic must name the shell-bracket-expansion footgun: {rendered:?}",
12017        );
12018        assert!(
12019            rendered.contains("glob-character-class"),
12020            "diagnostic must reference the POSIX glob-character-class vocabulary: \
12021             {rendered:?}",
12022        );
12023    }
12024
12025    #[test]
12026    fn validate_rejects_path_fonte_with_caminho_carrying_single_quote_grouping() {
12027        // The canonical paste-from-shell-history strong-quoted
12028        // sibling-workspace-path footgun: an author copies a
12029        // `cd '../caixa-teia'` shell-history one-liner whose strong-
12030        // quoting preserved the path across a whitespace paste
12031        // boundary and silently passed every prior arm
12032        // (`Path::is_absolute` false on `'..`, no control bytes, no
12033        // `\`, no `<` / `>`, no `|`, no `;`, no `&`, no backtick, no
12034        // `*` / `?`, no `(` / `)`, no `{` / `}`, no `[` / `]`,
12035        // doesn't end in `/`; the leading-`$` f4efe9c
12036        // `FonteCaminhoVarExpansion` arm doesn't fire because the
12037        // value starts with `'` not `$`). The lacre embedded the
12038        // value verbatim, the resolver folded it through
12039        // `Path::join` looking for a literal `./'../caixa-teia'`
12040        // subdirectory, and the failure surfaced at resolve time
12041        // with a non-self-locating `No such file or directory`
12042        // error. The new arm moves the rejection to validate time
12043        // and names the offending dep + caminho + byte verbatim.
12044        // The arm fires on the first `'` encountered.
12045        let d = dep_with_fonte(DepSource::Path {
12046            caminho: "'../caixa-teia'".into(),
12047        });
12048        let err = d.validate().unwrap_err();
12049        let DepError::FonteCaminhoShellQuoteGrouping {
12050            nome,
12051            caminho,
12052            byte,
12053        } = err
12054        else {
12055            panic!("expected FonteCaminhoShellQuoteGrouping, got {err:?}");
12056        };
12057        assert_eq!(nome, "caixa-teia");
12058        assert_eq!(caminho, "'../caixa-teia'");
12059        assert_eq!(byte, b'\'');
12060    }
12061
12062    #[test]
12063    fn validate_rejects_path_fonte_with_caminho_carrying_double_quote_grouping() {
12064        // The symmetric weak-quoted paste shape (`"\"../caixa-teia\""`
12065        // — the canonical paste-from-JSON-config / paste-from-YAML-
12066        // flow-scalar / paste-from-TOML-basic-string / paste-from-
12067        // tatara-lisp-string-literal cross-idiom leak). Pinned
12068        // separately from the single-quote shape so the gate's
12069        // contract is "any `'` or `\"` anywhere", not single-byte
12070        // coverage. Mirrors the peer
12071        // `validate_rejects_path_fonte_with_caminho_carrying_close_bracket`
12072        // shape on the immediate-predecessor
12073        // `FonteCaminhoShellBracketExpansion` arm.
12074        let d = dep_with_fonte(DepSource::Path {
12075            caminho: "\"../caixa-teia\"".into(),
12076        });
12077        let err = d.validate().unwrap_err();
12078        let DepError::FonteCaminhoShellQuoteGrouping { byte, .. } = err else {
12079            panic!("expected FonteCaminhoShellQuoteGrouping, got {err:?}");
12080        };
12081        assert_eq!(byte, b'"');
12082    }
12083
12084    #[test]
12085    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_double_quote() {
12086        // Embedded-position `"` shape (`"../\"caixa-teia\""` — the
12087        // canonical "I pasted a JSON key-value pair fragment into
12088        // the middle of the path" idiom). Pinned separately from
12089        // the leading-byte shape so the gate covers every position,
12090        // not only leading.
12091        let d = dep_with_fonte(DepSource::Path {
12092            caminho: "../\"caixa-teia\"".into(),
12093        });
12094        let err = d.validate().unwrap_err();
12095        assert!(
12096            matches!(
12097                err,
12098                DepError::FonteCaminhoShellQuoteGrouping { byte: b'"', .. },
12099            ),
12100            "got {err:?}",
12101        );
12102    }
12103
12104    #[test]
12105    fn validate_rejects_path_fonte_with_caminho_carrying_yaml_flow_scalar_paste() {
12106        // The canonical YAML double-quoted flow-scalar cross-idiom
12107        // leak shape (`"path: \"../caixa-teia\""` — the "I copied a
12108        // `path: \"...\"` YAML flow-scalar entry out of an aligned
12109        // values.yaml / K8s manifest and dropped it verbatim into
12110        // the `:caminho` slot including the `path: ` key prefix"
12111        // paste-idiom). The arm fires on the first `"` encountered;
12112        // pinned so the gate's coverage extends from the bare-quote
12113        // paste shape to the aligned-YAML-manifest cross-idiom-leak
12114        // shape.
12115        let d = dep_with_fonte(DepSource::Path {
12116            caminho: "path: \"../caixa-teia\"".into(),
12117        });
12118        let err = d.validate().unwrap_err();
12119        assert!(
12120            matches!(
12121                err,
12122                DepError::FonteCaminhoShellQuoteGrouping { byte: b'"', .. },
12123            ),
12124            "got {err:?}",
12125        );
12126    }
12127
12128    #[test]
12129    fn validate_accepts_path_fonte_with_caminho_carrying_no_quote_grouping() {
12130        // The positive-control pin: the gate targets only `'` /
12131        // `"`, never adjacent printable ASCII or POSIX-valid bytes.
12132        // The canonical relative POSIX path (`"../caixa-teia"`) and
12133        // a nested deeply-pathed variant with adjacent printable
12134        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
12135        // to validate cleanly so the gate doesn't widen to a "no
12136        // printable punctuation anywhere" sweep that would defeat
12137        // the entire path-fonte author surface. Peer with
12138        // `validate_accepts_path_fonte_with_caminho_carrying_no_bracket_expansion`
12139        // on the immediate-predecessor arm.
12140        let d = dep_with_fonte(DepSource::Path {
12141            caminho: "../caixa-teia/sub-dir.v2".into(),
12142        });
12143        d.validate().unwrap();
12144    }
12145
12146    #[test]
12147    fn fonte_caminho_shell_bracket_expansion_fires_before_shell_quote_grouping() {
12148        // Cascade pin on the immediate-predecessor arm: a value
12149        // carrying both `[` and `'` (`"../[a-z]'x'"` — the canonical
12150        // "I pasted a glob-character-class followed by a strong-
12151        // quoted literal tail" footgun) routes through
12152        // `FonteCaminhoShellBracketExpansion` not
12153        // `FonteCaminhoShellQuoteGrouping`. The glob-character-class
12154        // expansion is the load-bearing root-cause edit on every
12155        // probe-as-both value; same cascade discipline every prior
12156        // `:caminho` arm establishes.
12157        let d = dep_with_fonte(DepSource::Path {
12158            caminho: "../[a-z]'x'".into(),
12159        });
12160        let err = d.validate().unwrap_err();
12161        assert!(
12162            matches!(
12163                err,
12164                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
12165            ),
12166            "got {err:?}",
12167        );
12168    }
12169
12170    #[test]
12171    fn fonte_caminho_shell_brace_expansion_fires_before_shell_quote_grouping() {
12172        // Cascade pin on the upstream shell-brace-expansion arm: a
12173        // value carrying both `{` and `'` (`"../{a,b}'x'"` — the
12174        // canonical "I pasted a brace-expansion fan followed by a
12175        // strong-quoted literal tail" footgun) routes through
12176        // `FonteCaminhoShellBraceExpansion` not
12177        // `FonteCaminhoShellQuoteGrouping`. The brace-expansion fan
12178        // is the load-bearing root-cause edit on every probe-as-
12179        // both value.
12180        let d = dep_with_fonte(DepSource::Path {
12181            caminho: "../{a,b}'x'".into(),
12182        });
12183        let err = d.validate().unwrap_err();
12184        assert!(
12185            matches!(
12186                err,
12187                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
12188            ),
12189            "got {err:?}",
12190        );
12191    }
12192
12193    #[test]
12194    fn fonte_caminho_shell_subshell_grouping_fires_before_shell_quote_grouping() {
12195        // Cascade pin on the upstream shell-subshell-grouping arm:
12196        // a value carrying both `(` and `'` (`"../(cd foo)/'x'"` —
12197        // the canonical "I pasted a subshell-grouping followed by
12198        // a strong-quoted literal tail" footgun) routes through
12199        // `FonteCaminhoShellSubshellGrouping` not
12200        // `FonteCaminhoShellQuoteGrouping`. The modern Bourne
12201        // `$(<cmd>)` command-substitution boundary is the load-
12202        // bearing axis on every probe-as-both value.
12203        let d = dep_with_fonte(DepSource::Path {
12204            caminho: "../(cd foo)/'x'".into(),
12205        });
12206        let err = d.validate().unwrap_err();
12207        assert!(
12208            matches!(
12209                err,
12210                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
12211            ),
12212            "got {err:?}",
12213        );
12214    }
12215
12216    #[test]
12217    fn fonte_caminho_shell_glob_fires_before_shell_quote_grouping() {
12218        // Cascade pin on the upstream shell-glob arm: a value
12219        // carrying both `*` and `'` (`"../caixa-teia/*'x'"` — the
12220        // canonical "I pasted a `*` unbounded pathname-expansion
12221        // followed by a strong-quoted literal tail" footgun) routes
12222        // through `FonteCaminhoShellGlob` not
12223        // `FonteCaminhoShellQuoteGrouping`. The unbounded pathname-
12224        // expansion sentinel is the load-bearing root-cause edit
12225        // on every probe-as-both value.
12226        let d = dep_with_fonte(DepSource::Path {
12227            caminho: "../caixa-teia/*'x'".into(),
12228        });
12229        let err = d.validate().unwrap_err();
12230        assert!(
12231            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12232            "got {err:?}",
12233        );
12234    }
12235
12236    #[test]
12237    fn fonte_caminho_shell_command_substitution_fires_before_shell_quote_grouping() {
12238        // Cascade pin on the upstream shell-command-substitution
12239        // arm: a value carrying both a backtick and `'`
12240        // (``"../`whoami`/'x'"`` — the canonical "I pasted a
12241        // legacy-backtick command-substitution followed by a
12242        // strong-quoted literal tail" footgun) routes through
12243        // `FonteCaminhoShellCommandSubstitution` not
12244        // `FonteCaminhoShellQuoteGrouping`. The CWE-78 shell-
12245        // command-injection vector is the load-bearing root-cause
12246        // edit on every probe-as-both value.
12247        let d = dep_with_fonte(DepSource::Path {
12248            caminho: "../`whoami`/'x'".into(),
12249        });
12250        let err = d.validate().unwrap_err();
12251        assert!(
12252            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
12253            "got {err:?}",
12254        );
12255    }
12256
12257    #[test]
12258    fn fonte_caminho_shell_background_fires_before_shell_quote_grouping() {
12259        // Cascade pin on the upstream shell-background arm: a value
12260        // carrying both `&` and `'` (`"../caixa-teia & 'x'"` — the
12261        // canonical "I pasted a `cmd & 'literal'` background-launch
12262        // + quote chain" footgun) routes through
12263        // `FonteCaminhoShellBackground` not
12264        // `FonteCaminhoShellQuoteGrouping`. The background-launch
12265        // tail is the load-bearing root-cause edit on every
12266        // probe-as-both value.
12267        let d = dep_with_fonte(DepSource::Path {
12268            caminho: "../caixa-teia & 'x'".into(),
12269        });
12270        let err = d.validate().unwrap_err();
12271        assert!(
12272            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
12273            "got {err:?}",
12274        );
12275    }
12276
12277    #[test]
12278    fn fonte_caminho_shell_semicolon_fires_before_shell_quote_grouping() {
12279        // Cascade pin on the upstream shell-semicolon arm: a value
12280        // carrying both `;` and `'` (`"../caixa-teia; 'x'"` — the
12281        // canonical sequential-cleanup + quote paste idiom) routes
12282        // through `FonteCaminhoShellSemicolon` not
12283        // `FonteCaminhoShellQuoteGrouping`. The sequential-command-
12284        // separator paste is the load-bearing root-cause edit on
12285        // every probe-as-both value.
12286        let d = dep_with_fonte(DepSource::Path {
12287            caminho: "../caixa-teia; 'x'".into(),
12288        });
12289        let err = d.validate().unwrap_err();
12290        assert!(
12291            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
12292            "got {err:?}",
12293        );
12294    }
12295
12296    #[test]
12297    fn fonte_caminho_shell_pipe_fires_before_shell_quote_grouping() {
12298        // Cascade pin on the upstream shell-pipe arm: a value
12299        // carrying both `|` and `'` (`"../caixa-teia | 'x'"` — the
12300        // canonical pipeline-to-quoted-literal paste idiom) routes
12301        // through `FonteCaminhoShellPipe` not
12302        // `FonteCaminhoShellQuoteGrouping`. The pipeline-tail paste
12303        // is the load-bearing root-cause edit on every probe-as-
12304        // both value.
12305        let d = dep_with_fonte(DepSource::Path {
12306            caminho: "../caixa-teia | 'x'".into(),
12307        });
12308        let err = d.validate().unwrap_err();
12309        assert!(
12310            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
12311            "got {err:?}",
12312        );
12313    }
12314
12315    #[test]
12316    fn fonte_caminho_shell_redirection_fires_before_shell_quote_grouping() {
12317        // Cascade pin on the upstream shell-redirection arm: a
12318        // value carrying both `>` and `'` (`"../caixa-teia>log 'x'"`
12319        // — the canonical "I pasted a `cmd > log 'literal'`
12320        // redirect-plus-quote chain" footgun) routes through
12321        // `FonteCaminhoShellRedirection` not
12322        // `FonteCaminhoShellQuoteGrouping`. The input/output
12323        // redirection metachar carries the more self-locating
12324        // `byte` payload, so the prior arm wins on every probe-as-
12325        // both value.
12326        let d = dep_with_fonte(DepSource::Path {
12327            caminho: "../caixa-teia>log 'x'".into(),
12328        });
12329        let err = d.validate().unwrap_err();
12330        assert!(
12331            matches!(
12332                err,
12333                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
12334            ),
12335            "got {err:?}",
12336        );
12337    }
12338
12339    #[test]
12340    fn fonte_caminho_backslash_fires_before_shell_quote_grouping() {
12341        // Cascade pin on the upstream backslash arm: a value
12342        // carrying both `\` and `'` (`"..\caixa-teia\'x'"` — the
12343        // canonical "I pasted a Windows-shell `cd ..\path\'literal'`
12344        // chain" footgun) routes through `FonteCaminhoBackslash`
12345        // not `FonteCaminhoShellQuoteGrouping`. The cross-host-OS-
12346        // separator divergence is the load-bearing axis on every
12347        // probe-as-both value.
12348        let d = dep_with_fonte(DepSource::Path {
12349            caminho: "..\\caixa-teia\\'x'".into(),
12350        });
12351        let err = d.validate().unwrap_err();
12352        assert!(
12353            matches!(err, DepError::FonteCaminhoBackslash { .. }),
12354            "got {err:?}",
12355        );
12356    }
12357
12358    #[test]
12359    fn fonte_caminho_control_char_fires_before_shell_quote_grouping() {
12360        // Cascade pin on the embedded-control-byte arm: a value
12361        // carrying both a control byte and `'` (`"../foo\n'x'"` —
12362        // the canonical paste-from-multiline-doc footgun where a
12363        // newline landed mid-caminho between two paste fragments)
12364        // routes through `FonteCaminhoControlChar` not
12365        // `FonteCaminhoShellQuoteGrouping`. The POSIX-syscall-
12366        // rejected-byte / NUL-`CString::new`-fail diagnostic is
12367        // the load-bearing axis on every value that probes
12368        // positive for both — mirrors the cascade discipline on
12369        // every prior arm.
12370        let d = dep_with_fonte(DepSource::Path {
12371            caminho: "../foo\n'x'".into(),
12372        });
12373        let err = d.validate().unwrap_err();
12374        assert!(
12375            matches!(err, DepError::FonteCaminhoControlChar { .. }),
12376            "got {err:?}",
12377        );
12378    }
12379
12380    #[test]
12381    fn fonte_caminho_absolute_fires_before_shell_quote_grouping() {
12382        // Cascade pin on the load-bearing leading-byte arm: a
12383        // leading `/` value with embedded `'` (`"/etc/'x'"`) routes
12384        // through `FonteCaminhoAbsolute` not
12385        // `FonteCaminhoShellQuoteGrouping` — the host-layout-leak
12386        // diagnostic is the load-bearing axis, the quote byte is
12387        // the secondary observation. Same precedence logic as every
12388        // prior leading-byte arm.
12389        let d = dep_with_fonte(DepSource::Path {
12390            caminho: "/etc/'x'".into(),
12391        });
12392        let err = d.validate().unwrap_err();
12393        assert!(
12394            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
12395            "got {err:?}",
12396        );
12397    }
12398
12399    #[test]
12400    fn fonte_caminho_var_expansion_fires_before_shell_quote_grouping() {
12401        // Cascade pin on the upstream leading-`$` var-expansion
12402        // arm: a value carrying both a leading `$` and a `'`
12403        // (`"$DIR/'x'"` — the canonical "I pasted a `$DIR` shell-
12404        // variable + quoted literal at the head of a sibling-
12405        // workspace path" footgun) routes through
12406        // `FonteCaminhoVarExpansion` not
12407        // `FonteCaminhoShellQuoteGrouping`. The leading-byte
12408        // shell-variable-expansion is the more self-locating
12409        // diagnostic on values that probe as both — same
12410        // load-bearing-leading-byte cascade discipline every
12411        // prior `:caminho` arm establishes.
12412        let d = dep_with_fonte(DepSource::Path {
12413            caminho: "$DIR/'x'".into(),
12414        });
12415        let err = d.validate().unwrap_err();
12416        assert!(
12417            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
12418            "got {err:?}",
12419        );
12420    }
12421
12422    #[test]
12423    fn fonte_caminho_shell_quote_grouping_fires_before_trailing_slash() {
12424        // Cascade pin on the immediate-successor arm: a value
12425        // carrying both `'` and a trailing `/` (`"../'caixa-teia'/"`
12426        // — the canonical "I tab-completed a path whose strong-
12427        // quoted body already carried the quoting from a shell-
12428        // history paste" footgun) routes through
12429        // `FonteCaminhoShellQuoteGrouping` not
12430        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
12431        // is the more semantic-locating axis (an author who removes
12432        // the `'` typically also drops the trailing separator since
12433        // both are paste-from-shell artifacts).
12434        let d = dep_with_fonte(DepSource::Path {
12435            caminho: "../'caixa-teia'/".into(),
12436        });
12437        let err = d.validate().unwrap_err();
12438        assert!(
12439            matches!(
12440                err,
12441                DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
12442            ),
12443            "got {err:?}",
12444        );
12445    }
12446
12447    #[test]
12448    fn fonte_caminho_shell_quote_grouping_diagnostic_carries_offending_dep_caminho_and_byte() {
12449        // Diagnostic-shape pin (peer with
12450        // `fonte_caminho_shell_bracket_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
12451        // on the closest two-byte peer arm): the error's Display
12452        // surfaces the offending `:nome`, the offending `:caminho`
12453        // verbatim, the offending byte's hex / character form, and
12454        // names the shell-quote-grouping / cross-config-DSL-string-
12455        // literal-delimiter footgun explicitly so a `feira lint`
12456        // run can render the diagnostic without re-parsing.
12457        let d = dep_with_fonte(DepSource::Path {
12458            caminho: "'../caixa-teia'".into(),
12459        });
12460        let rendered = d.validate().unwrap_err().to_string();
12461        assert!(
12462            rendered.contains("caixa-teia"),
12463            "diagnostic must name the offending dep: {rendered}",
12464        );
12465        assert!(
12466            rendered.contains("'../caixa-teia'"),
12467            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
12468        );
12469        assert!(
12470            rendered.contains("0x27"),
12471            "diagnostic must surface the offending byte hex: {rendered:?}",
12472        );
12473        assert!(
12474            rendered.contains("quote-grouping"),
12475            "diagnostic must name the shell-quote-grouping footgun: {rendered:?}",
12476        );
12477        assert!(
12478            rendered.contains("string-literal"),
12479            "diagnostic must reference the cross-config-DSL string-literal-delimiter \
12480             vocabulary: {rendered:?}",
12481        );
12482    }
12483
12484    #[test]
12485    fn validate_rejects_path_fonte_with_caminho_carrying_shell_comment_lead() {
12486        // The canonical paste-from-shell-history-with-trailing-
12487        // annotation footgun: an author pastes a `cd ../caixa-teia
12488        // # legacy sibling` shell-history one-liner whose unquoted `#`
12489        // comment-lead separates the path from an inline annotation.
12490        // The POSIX shell trims the annotation to `../caixa-teia`
12491        // (POSIX.1-2017 §2.3 Token Recognition step 6), but
12492        // `Path::is_absolute` returns false on `..`, `#` is neither
12493        // a leading-byte sentinel nor a control byte nor `\` nor
12494        // `<` / `>` nor `|` nor `;` nor `&` nor backtick nor `*` /
12495        // `?` nor `(` / `)` nor `{` / `}` nor `[` / `]` nor `'` /
12496        // `"`, and the value's last byte isn't `/` — so the value
12497        // silently passed every prior arm. The resolver folded the
12498        // value through `Path::join` looking for a literal
12499        // `./../caixa-teia # legacy sibling` subdirectory and the
12500        // failure surfaced at resolve time with a non-self-locating
12501        // `No such file or directory` error. The new arm moves the
12502        // rejection to validate time and names the offending dep +
12503        // caminho + byte verbatim.
12504        let d = dep_with_fonte(DepSource::Path {
12505            caminho: "../caixa-teia # legacy sibling".into(),
12506        });
12507        let err = d.validate().unwrap_err();
12508        let DepError::FonteCaminhoShellComment {
12509            nome,
12510            caminho,
12511            byte,
12512        } = err
12513        else {
12514            panic!("expected FonteCaminhoShellComment, got {err:?}");
12515        };
12516        assert_eq!(nome, "caixa-teia");
12517        assert_eq!(caminho, "../caixa-teia # legacy sibling");
12518        assert_eq!(byte, b'#');
12519    }
12520
12521    #[test]
12522    fn validate_rejects_path_fonte_with_caminho_carrying_yaml_comment_paste() {
12523        // The symmetric YAML flow-scalar / values.yaml / K8s-manifest
12524        // cross-idiom-leak shape (`"../caixa-teia  # pin"` — the
12525        // canonical "I copied a `path: ../caixa-teia  # pin` YAML
12526        // scalar-plus-comment entry out of an aligned values.yaml and
12527        // dropped it verbatim into the `:caminho` slot" paste-idiom).
12528        // Pinned separately from the shell-history shape so the
12529        // gate's coverage extends from the single-space `#` shape to
12530        // the YAML-canonical double-space `  #` shape. YAML 1.2 §6.6
12531        // requires the `#` to be preceded by whitespace to lex as a
12532        // comment (bare `foo#bar` is a single scalar); the double-
12533        // space paste from an aligned manifest is the canonical
12534        // shape.
12535        let d = dep_with_fonte(DepSource::Path {
12536            caminho: "../caixa-teia  # pin".into(),
12537        });
12538        let err = d.validate().unwrap_err();
12539        assert!(
12540            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
12541            "got {err:?}",
12542        );
12543    }
12544
12545    #[test]
12546    fn validate_rejects_path_fonte_with_caminho_carrying_url_fragment_anchor() {
12547        // The URL-fragment-identifier paste shape
12548        // (`"../caixa-teia#readme"` — the canonical
12549        // paste-from-browser-address-bar permalink shape where the
12550        // browser preserved the `#anchor` tail on the copy). Pinned
12551        // separately from the whitespace-separated shell / YAML
12552        // comment shapes so the gate covers the unpadded RFC 3986
12553        // §3.5 fragment-delimiter position too, not only positions
12554        // preceded by unquoted whitespace. Peer with the immediate-
12555        // sibling `is_git_repo_url` arm on the `:fonte :repo` axis
12556        // (a68f818) which closes the same byte under the same URL-
12557        // fragment-identifier banner.
12558        let d = dep_with_fonte(DepSource::Path {
12559            caminho: "../caixa-teia#readme".into(),
12560        });
12561        let err = d.validate().unwrap_err();
12562        assert!(
12563            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
12564            "got {err:?}",
12565        );
12566    }
12567
12568    #[test]
12569    fn validate_rejects_path_fonte_with_caminho_carrying_leading_shell_comment() {
12570        // Leading-position `#` shape (`"#../caixa-teia"` — the
12571        // "I copied a shell-comment-out entry from a commented-out
12572        // dep row" footgun). Pinned separately from the embedded
12573        // shapes so the gate covers every position, not only
12574        // whitespace-preceded / mid-value.
12575        let d = dep_with_fonte(DepSource::Path {
12576            caminho: "#../caixa-teia".into(),
12577        });
12578        let err = d.validate().unwrap_err();
12579        assert!(
12580            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
12581            "got {err:?}",
12582        );
12583    }
12584
12585    #[test]
12586    fn validate_accepts_path_fonte_with_caminho_carrying_no_shell_comment() {
12587        // The positive-control pin: the gate targets only `#`,
12588        // never adjacent printable ASCII or POSIX-valid bytes. The
12589        // canonical relative POSIX path (`"../caixa-teia"`) and a
12590        // nested deeply-pathed variant with adjacent printable
12591        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
12592        // to validate cleanly so the gate doesn't widen to a "no
12593        // printable punctuation anywhere" sweep that would defeat
12594        // the entire path-fonte author surface. Peer with
12595        // `validate_accepts_path_fonte_with_caminho_carrying_no_quote_grouping`
12596        // on the immediate-predecessor arm.
12597        let d = dep_with_fonte(DepSource::Path {
12598            caminho: "../caixa-teia/sub-dir.v2".into(),
12599        });
12600        d.validate().unwrap();
12601    }
12602
12603    #[test]
12604    fn fonte_caminho_shell_quote_grouping_fires_before_shell_comment() {
12605        // Cascade pin on the immediate-predecessor arm: a value
12606        // carrying both `'` and `#` (`"../'x'#pin"` — the canonical
12607        // "I pasted a strong-quoted literal followed by a URL-
12608        // fragment permalink tail" footgun) routes through
12609        // `FonteCaminhoShellQuoteGrouping` not
12610        // `FonteCaminhoShellComment`. The shell-string-literal-
12611        // delimiter is the load-bearing root-cause edit on every
12612        // probe-as-both value; same cascade discipline every prior
12613        // `:caminho` arm establishes.
12614        let d = dep_with_fonte(DepSource::Path {
12615            caminho: "../'x'#pin".into(),
12616        });
12617        let err = d.validate().unwrap_err();
12618        assert!(
12619            matches!(
12620                err,
12621                DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
12622            ),
12623            "got {err:?}",
12624        );
12625    }
12626
12627    #[test]
12628    fn fonte_caminho_shell_bracket_expansion_fires_before_shell_comment() {
12629        // Cascade pin on the upstream shell-bracket-expansion arm:
12630        // a value carrying both `[` and `#` (`"../[a-z]#pin"` — the
12631        // canonical "I pasted a glob-character-class followed by a
12632        // URL-fragment tail" footgun) routes through
12633        // `FonteCaminhoShellBracketExpansion` not
12634        // `FonteCaminhoShellComment`. The glob-character-class
12635        // expansion is the load-bearing root-cause edit on every
12636        // probe-as-both value.
12637        let d = dep_with_fonte(DepSource::Path {
12638            caminho: "../[a-z]#pin".into(),
12639        });
12640        let err = d.validate().unwrap_err();
12641        assert!(
12642            matches!(
12643                err,
12644                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
12645            ),
12646            "got {err:?}",
12647        );
12648    }
12649
12650    #[test]
12651    fn fonte_caminho_shell_brace_expansion_fires_before_shell_comment() {
12652        // Cascade pin on the upstream shell-brace-expansion arm: a
12653        // value carrying both `{` and `#` (`"../{a,b}#pin"` — the
12654        // canonical "I pasted a brace-expansion fan followed by a
12655        // URL-fragment tail" footgun) routes through
12656        // `FonteCaminhoShellBraceExpansion` not
12657        // `FonteCaminhoShellComment`. The brace-expansion fan is the
12658        // load-bearing root-cause edit on every probe-as-both value.
12659        let d = dep_with_fonte(DepSource::Path {
12660            caminho: "../{a,b}#pin".into(),
12661        });
12662        let err = d.validate().unwrap_err();
12663        assert!(
12664            matches!(
12665                err,
12666                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
12667            ),
12668            "got {err:?}",
12669        );
12670    }
12671
12672    #[test]
12673    fn fonte_caminho_shell_subshell_grouping_fires_before_shell_comment() {
12674        // Cascade pin on the upstream shell-subshell-grouping arm:
12675        // a value carrying both `(` and `#` (`"../(cd foo)#pin"` —
12676        // the canonical "I pasted a subshell-grouping followed by a
12677        // URL-fragment tail" footgun) routes through
12678        // `FonteCaminhoShellSubshellGrouping` not
12679        // `FonteCaminhoShellComment`. The modern Bourne `$(<cmd>)`
12680        // command-substitution boundary is the load-bearing axis on
12681        // every probe-as-both value.
12682        let d = dep_with_fonte(DepSource::Path {
12683            caminho: "../(cd foo)#pin".into(),
12684        });
12685        let err = d.validate().unwrap_err();
12686        assert!(
12687            matches!(
12688                err,
12689                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
12690            ),
12691            "got {err:?}",
12692        );
12693    }
12694
12695    #[test]
12696    fn fonte_caminho_shell_glob_fires_before_shell_comment() {
12697        // Cascade pin on the upstream shell-glob arm: a value
12698        // carrying both `*` and `#` (`"../caixa-teia/*#pin"` — the
12699        // canonical "I pasted a `*` unbounded pathname-expansion
12700        // followed by a URL-fragment tail" footgun) routes through
12701        // `FonteCaminhoShellGlob` not `FonteCaminhoShellComment`.
12702        // The unbounded pathname-expansion sentinel is the load-
12703        // bearing root-cause edit on every probe-as-both value.
12704        let d = dep_with_fonte(DepSource::Path {
12705            caminho: "../caixa-teia/*#pin".into(),
12706        });
12707        let err = d.validate().unwrap_err();
12708        assert!(
12709            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12710            "got {err:?}",
12711        );
12712    }
12713
12714    #[test]
12715    fn fonte_caminho_shell_command_substitution_fires_before_shell_comment() {
12716        // Cascade pin on the upstream shell-command-substitution
12717        // arm: a value carrying both a backtick and `#`
12718        // (``"../`whoami`#pin"`` — the canonical "I pasted a
12719        // legacy-backtick command-substitution followed by a URL-
12720        // fragment tail" footgun) routes through
12721        // `FonteCaminhoShellCommandSubstitution` not
12722        // `FonteCaminhoShellComment`. The CWE-78 shell-command-
12723        // injection vector is the load-bearing root-cause edit on
12724        // every probe-as-both value.
12725        let d = dep_with_fonte(DepSource::Path {
12726            caminho: "../`whoami`#pin".into(),
12727        });
12728        let err = d.validate().unwrap_err();
12729        assert!(
12730            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
12731            "got {err:?}",
12732        );
12733    }
12734
12735    #[test]
12736    fn fonte_caminho_shell_background_fires_before_shell_comment() {
12737        // Cascade pin on the upstream shell-background arm: a value
12738        // carrying both `&` and `#` (`"../caixa-teia&pin#tail"` —
12739        // the canonical "I pasted a `cmd &` background-launch
12740        // followed by a URL-fragment tail" footgun) routes through
12741        // `FonteCaminhoShellBackground` not
12742        // `FonteCaminhoShellComment`. The background-launch tail is
12743        // the load-bearing root-cause edit on every probe-as-both
12744        // value.
12745        let d = dep_with_fonte(DepSource::Path {
12746            caminho: "../caixa-teia&pin#tail".into(),
12747        });
12748        let err = d.validate().unwrap_err();
12749        assert!(
12750            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
12751            "got {err:?}",
12752        );
12753    }
12754
12755    #[test]
12756    fn fonte_caminho_shell_semicolon_fires_before_shell_comment() {
12757        // Cascade pin on the upstream shell-semicolon arm: a value
12758        // carrying both `;` and `#` (`"../caixa-teia;pin#tail"` —
12759        // the canonical sequential-cleanup + URL-fragment paste
12760        // idiom) routes through `FonteCaminhoShellSemicolon` not
12761        // `FonteCaminhoShellComment`. The sequential-command-
12762        // separator paste is the load-bearing root-cause edit on
12763        // every probe-as-both value.
12764        let d = dep_with_fonte(DepSource::Path {
12765            caminho: "../caixa-teia;pin#tail".into(),
12766        });
12767        let err = d.validate().unwrap_err();
12768        assert!(
12769            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
12770            "got {err:?}",
12771        );
12772    }
12773
12774    #[test]
12775    fn fonte_caminho_shell_pipe_fires_before_shell_comment() {
12776        // Cascade pin on the upstream shell-pipe arm: a value
12777        // carrying both `|` and `#` (`"../caixa-teia|pin#tail"` —
12778        // the canonical pipeline-to-URL-fragment paste idiom) routes
12779        // through `FonteCaminhoShellPipe` not
12780        // `FonteCaminhoShellComment`. The pipeline-tail paste is
12781        // the load-bearing root-cause edit on every probe-as-both
12782        // value.
12783        let d = dep_with_fonte(DepSource::Path {
12784            caminho: "../caixa-teia|pin#tail".into(),
12785        });
12786        let err = d.validate().unwrap_err();
12787        assert!(
12788            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
12789            "got {err:?}",
12790        );
12791    }
12792
12793    #[test]
12794    fn fonte_caminho_shell_redirection_fires_before_shell_comment() {
12795        // Cascade pin on the upstream shell-redirection arm: a
12796        // value carrying both `>` and `#` (`"../caixa-teia>log#pin"`
12797        // — the canonical "I pasted a `cmd > log` redirect followed
12798        // by a URL-fragment tail" footgun) routes through
12799        // `FonteCaminhoShellRedirection` not
12800        // `FonteCaminhoShellComment`. The input/output redirection
12801        // metachar carries the more self-locating `byte` payload,
12802        // so the prior arm wins on every probe-as-both value.
12803        let d = dep_with_fonte(DepSource::Path {
12804            caminho: "../caixa-teia>log#pin".into(),
12805        });
12806        let err = d.validate().unwrap_err();
12807        assert!(
12808            matches!(
12809                err,
12810                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
12811            ),
12812            "got {err:?}",
12813        );
12814    }
12815
12816    #[test]
12817    fn fonte_caminho_backslash_fires_before_shell_comment() {
12818        // Cascade pin on the upstream backslash arm: a value
12819        // carrying both `\` and `#` (`"..\caixa-teia#pin"` — the
12820        // canonical "I pasted a Windows-shell path followed by a
12821        // URL-fragment tail" footgun) routes through
12822        // `FonteCaminhoBackslash` not `FonteCaminhoShellComment`.
12823        // The cross-host-OS-separator divergence is the load-
12824        // bearing axis on every probe-as-both value.
12825        let d = dep_with_fonte(DepSource::Path {
12826            caminho: "..\\caixa-teia#pin".into(),
12827        });
12828        let err = d.validate().unwrap_err();
12829        assert!(
12830            matches!(err, DepError::FonteCaminhoBackslash { .. }),
12831            "got {err:?}",
12832        );
12833    }
12834
12835    #[test]
12836    fn fonte_caminho_control_char_fires_before_shell_comment() {
12837        // Cascade pin on the embedded-control-byte arm: a value
12838        // carrying both a control byte and `#` (`"../foo\n#pin"` —
12839        // the canonical paste-from-multiline-doc footgun where a
12840        // newline landed mid-caminho between the path and an
12841        // annotation) routes through `FonteCaminhoControlChar` not
12842        // `FonteCaminhoShellComment`. The POSIX-syscall-rejected-
12843        // byte diagnostic is the load-bearing axis on every value
12844        // that probes positive for both — mirrors the cascade
12845        // discipline on every prior arm.
12846        let d = dep_with_fonte(DepSource::Path {
12847            caminho: "../foo\n#pin".into(),
12848        });
12849        let err = d.validate().unwrap_err();
12850        assert!(
12851            matches!(err, DepError::FonteCaminhoControlChar { .. }),
12852            "got {err:?}",
12853        );
12854    }
12855
12856    #[test]
12857    fn fonte_caminho_absolute_fires_before_shell_comment() {
12858        // Cascade pin on the load-bearing leading-byte arm: a
12859        // leading `/` value with embedded `#` (`"/etc/foo#pin"`)
12860        // routes through `FonteCaminhoAbsolute` not
12861        // `FonteCaminhoShellComment` — the host-layout-leak
12862        // diagnostic is the load-bearing axis, the fragment byte is
12863        // the secondary observation. Same precedence logic as every
12864        // prior leading-byte arm.
12865        let d = dep_with_fonte(DepSource::Path {
12866            caminho: "/etc/foo#pin".into(),
12867        });
12868        let err = d.validate().unwrap_err();
12869        assert!(
12870            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
12871            "got {err:?}",
12872        );
12873    }
12874
12875    #[test]
12876    fn fonte_caminho_var_expansion_fires_before_shell_comment() {
12877        // Cascade pin on the upstream leading-`$` var-expansion
12878        // arm: a value carrying both a leading `$` and a `#`
12879        // (`"$DIR/foo#pin"` — the canonical "I pasted a `$DIR`
12880        // shell-variable at the head of a sibling-workspace path
12881        // followed by a URL-fragment tail" footgun) routes through
12882        // `FonteCaminhoVarExpansion` not `FonteCaminhoShellComment`.
12883        // The leading-byte shell-variable-expansion is the more
12884        // self-locating diagnostic on values that probe as both.
12885        let d = dep_with_fonte(DepSource::Path {
12886            caminho: "$DIR/foo#pin".into(),
12887        });
12888        let err = d.validate().unwrap_err();
12889        assert!(
12890            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
12891            "got {err:?}",
12892        );
12893    }
12894
12895    #[test]
12896    fn fonte_caminho_shell_comment_fires_before_trailing_slash() {
12897        // Cascade pin on the immediate-successor arm: a value
12898        // carrying both `#` and a trailing `/`
12899        // (`"../caixa-teia#pin/"` — the canonical "I tab-completed
12900        // a URL-fragment-carrying path" footgun) routes through
12901        // `FonteCaminhoShellComment` not
12902        // `FonteCaminhoTrailingSlash`. The embedded fragment /
12903        // comment-lead byte is the more semantic-locating axis (an
12904        // author who removes the `#pin` fragment typically also
12905        // drops the trailing separator since both are paste-from-
12906        // URL / paste-from-shell-tab-completion artifacts).
12907        let d = dep_with_fonte(DepSource::Path {
12908            caminho: "../caixa-teia#pin/".into(),
12909        });
12910        let err = d.validate().unwrap_err();
12911        assert!(
12912            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. },),
12913            "got {err:?}",
12914        );
12915    }
12916
12917    #[test]
12918    fn fonte_caminho_shell_comment_diagnostic_carries_offending_dep_caminho_and_byte() {
12919        // Diagnostic-shape pin (peer with
12920        // `fonte_caminho_shell_quote_grouping_diagnostic_carries_offending_dep_caminho_and_byte`
12921        // on the immediate-predecessor arm): the error's Display
12922        // surfaces the offending `:nome`, the offending `:caminho`
12923        // verbatim, the offending byte's hex / character form, and
12924        // names the shell-comment / URL-fragment-identifier /
12925        // YAML-comment cross-config-DSL footgun explicitly so a
12926        // `feira lint` run can render the diagnostic without
12927        // re-parsing.
12928        let d = dep_with_fonte(DepSource::Path {
12929            caminho: "../caixa-teia#readme".into(),
12930        });
12931        let rendered = d.validate().unwrap_err().to_string();
12932        assert!(
12933            rendered.contains("caixa-teia"),
12934            "diagnostic must name the offending dep: {rendered}",
12935        );
12936        assert!(
12937            rendered.contains("../caixa-teia#readme"),
12938            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
12939        );
12940        assert!(
12941            rendered.contains("0x23"),
12942            "diagnostic must surface the offending byte hex: {rendered:?}",
12943        );
12944        assert!(
12945            rendered.contains("shell-comment") || rendered.contains("comment-lead"),
12946            "diagnostic must name the shell-comment footgun: {rendered:?}",
12947        );
12948        assert!(
12949            rendered.contains("fragment") || rendered.contains("URL-fragment"),
12950            "diagnostic must reference the URL-fragment-identifier vocabulary: \
12951             {rendered:?}",
12952        );
12953    }
12954
12955    #[test]
12956    fn validate_rejects_path_fonte_with_caminho_carrying_url_percent_encoded_space() {
12957        // The canonical paste-from-browser-address-bar percent-
12958        // encoded-space footgun: an author copies `../caixa%20teia`
12959        // out of a URL-encoded README hyperlink / browser address
12960        // bar / percent-encoded permalink expecting `%20` to decode
12961        // to a literal space at the filesystem layer. POSIX
12962        // `std::path::Path` treats `%` as a literal path-component
12963        // byte, so `Path::join` looks for a literal
12964        // `./../caixa%20teia` subdirectory. `Path::is_absolute`
12965        // returns false on `..`, `%` is neither a leading-byte
12966        // sentinel nor a control byte nor `\` nor `<` / `>` nor
12967        // `|` nor `;` nor `&` nor backtick nor `*` / `?` nor `(` /
12968        // `)` nor `{` / `}` nor `[` / `]` nor `'` / `"` nor `#`,
12969        // and the value's last byte isn't `/` — so the value
12970        // silently passed every prior arm. The new arm moves the
12971        // rejection to validate time and names the offending dep +
12972        // caminho + byte verbatim.
12973        let d = dep_with_fonte(DepSource::Path {
12974            caminho: "../caixa%20teia".into(),
12975        });
12976        let err = d.validate().unwrap_err();
12977        let DepError::FonteCaminhoUrlPercentEncoding {
12978            nome,
12979            caminho,
12980            byte,
12981        } = err
12982        else {
12983            panic!("expected FonteCaminhoUrlPercentEncoding, got {err:?}");
12984        };
12985        assert_eq!(nome, "caixa-teia");
12986        assert_eq!(caminho, "../caixa%20teia");
12987        assert_eq!(byte, b'%');
12988    }
12989
12990    #[test]
12991    fn validate_rejects_path_fonte_with_caminho_carrying_url_percent_encoded_slash() {
12992        // The over-encoded path-separator shape (`"../caixa%2Fteia"`
12993        // intending the `%2F` as the URL encoding of `/`) locks a
12994        // `path:../caixa%2Fteia` BLAKE3 closure that diverges from
12995        // the byte-identical `path:../caixa/teia` form. Pinned
12996        // separately from the space-encoded shape so the gate's
12997        // coverage extends past the single canonical `%20` example
12998        // to any two-hex-digit percent-encoded sequence.
12999        let d = dep_with_fonte(DepSource::Path {
13000            caminho: "../caixa%2Fteia".into(),
13001        });
13002        let err = d.validate().unwrap_err();
13003        assert!(
13004            matches!(
13005                err,
13006                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
13007            ),
13008            "got {err:?}",
13009        );
13010    }
13011
13012    #[test]
13013    fn validate_rejects_path_fonte_with_caminho_carrying_lone_percent() {
13014        // The lone-`%` malformed-escape shape (`"../caixa-teia%foo"`
13015        // where `%` isn't followed by two hex digits) — every
13016        // WHATWG-conformant URL parser rejects the value at parse
13017        // time per RFC 3986 §2.1, but the byte would silently ride
13018        // into the lacre before the resolver subprocess crosses the
13019        // URL-parser boundary. Pinned separately from the well-
13020        // formed `%HH` shapes so the gate covers every percent-
13021        // occurrence, not only strictly-conformant escapes.
13022        let d = dep_with_fonte(DepSource::Path {
13023            caminho: "../caixa-teia%foo".into(),
13024        });
13025        let err = d.validate().unwrap_err();
13026        assert!(
13027            matches!(
13028                err,
13029                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
13030            ),
13031            "got {err:?}",
13032        );
13033    }
13034
13035    #[test]
13036    fn validate_rejects_path_fonte_with_caminho_carrying_leading_yaml_directive() {
13037        // The YAML-directive-lead paste shape (`"%YAML/../caixa-teia"`
13038        // — the canonical paste-from-top-of-doc YAML directive
13039        // block cross-idiom leak per YAML 1.2 §6.8.1). Pinned
13040        // separately from embedded shapes so the gate covers the
13041        // leading-position `%` too, not only mid-value occurrences.
13042        let d = dep_with_fonte(DepSource::Path {
13043            caminho: "%YAML/../caixa-teia".into(),
13044        });
13045        let err = d.validate().unwrap_err();
13046        assert!(
13047            matches!(
13048                err,
13049                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
13050            ),
13051            "got {err:?}",
13052        );
13053    }
13054
13055    #[test]
13056    fn validate_rejects_path_fonte_with_caminho_carrying_printf_format_specifier() {
13057        // The printf-format-specifier paste shape
13058        // (`"../caixa-%s-teia"` — the canonical paste-from-shell-
13059        // diagnostic-one-liner `printf "path=%s\n" ...` idiom, CWE-
13060        // 134 format-string-injection vector). Pinned separately
13061        // from the URL-encoding shapes so the gate's rationale
13062        // extends past the RFC 3986 axis to the C / POSIX printf
13063        // format-directive-lead axis.
13064        let d = dep_with_fonte(DepSource::Path {
13065            caminho: "../caixa-%s-teia".into(),
13066        });
13067        let err = d.validate().unwrap_err();
13068        assert!(
13069            matches!(
13070                err,
13071                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
13072            ),
13073            "got {err:?}",
13074        );
13075    }
13076
13077    #[test]
13078    fn validate_accepts_path_fonte_with_caminho_carrying_no_percent() {
13079        // The positive-control pin: the gate targets only `%`,
13080        // never adjacent printable ASCII or POSIX-valid bytes. The
13081        // canonical relative POSIX path (`"../caixa-teia"`) and a
13082        // nested deeply-pathed variant with adjacent printable
13083        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
13084        // to validate cleanly so the gate doesn't widen to a "no
13085        // printable punctuation anywhere" sweep that would defeat
13086        // the entire path-fonte author surface. Peer with
13087        // `validate_accepts_path_fonte_with_caminho_carrying_no_shell_comment`
13088        // on the immediate-predecessor arm.
13089        let d = dep_with_fonte(DepSource::Path {
13090            caminho: "../caixa-teia/sub-dir.v2".into(),
13091        });
13092        d.validate().unwrap();
13093    }
13094
13095    #[test]
13096    fn fonte_caminho_shell_comment_fires_before_url_percent_encoding() {
13097        // Cascade pin on the immediate-predecessor arm: a value
13098        // carrying both `#` and `%` (`"../caixa-teia#pin%20"` — the
13099        // canonical "I pasted a URL-fragment permalink followed by a
13100        // percent-encoded space tail" footgun) routes through
13101        // `FonteCaminhoShellComment` not
13102        // `FonteCaminhoUrlPercentEncoding`. The URL-fragment-
13103        // identifier is the load-bearing downstream-truncation edit
13104        // on every probe-as-both value; same cascade discipline
13105        // every prior `:caminho` arm establishes.
13106        let d = dep_with_fonte(DepSource::Path {
13107            caminho: "../caixa-teia#pin%20".into(),
13108        });
13109        let err = d.validate().unwrap_err();
13110        assert!(
13111            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
13112            "got {err:?}",
13113        );
13114    }
13115
13116    #[test]
13117    fn fonte_caminho_shell_quote_grouping_fires_before_url_percent_encoding() {
13118        // Cascade pin on the upstream shell-quote-grouping arm: a
13119        // value carrying both `'` and `%` (`"../'x'%20teia"` — the
13120        // canonical "I pasted a strong-quoted literal followed by
13121        // a percent-encoded space" footgun) routes through
13122        // `FonteCaminhoShellQuoteGrouping` not
13123        // `FonteCaminhoUrlPercentEncoding`. The shell-string-
13124        // literal-delimiter is the load-bearing root-cause edit on
13125        // every probe-as-both value.
13126        let d = dep_with_fonte(DepSource::Path {
13127            caminho: "../'x'%20teia".into(),
13128        });
13129        let err = d.validate().unwrap_err();
13130        assert!(
13131            matches!(
13132                err,
13133                DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
13134            ),
13135            "got {err:?}",
13136        );
13137    }
13138
13139    #[test]
13140    fn fonte_caminho_backslash_fires_before_url_percent_encoding() {
13141        // Cascade pin on the upstream backslash arm: a value
13142        // carrying both `\` and `%` (`"..\\caixa%20teia"` — the
13143        // canonical "I pasted a Windows-shell path followed by a
13144        // percent-encoded space" footgun) routes through
13145        // `FonteCaminhoBackslash` not
13146        // `FonteCaminhoUrlPercentEncoding`. The cross-host-OS-
13147        // separator divergence is the load-bearing root-cause edit
13148        // on every probe-as-both value.
13149        let d = dep_with_fonte(DepSource::Path {
13150            caminho: "..\\caixa%20teia".into(),
13151        });
13152        let err = d.validate().unwrap_err();
13153        assert!(
13154            matches!(err, DepError::FonteCaminhoBackslash { .. }),
13155            "got {err:?}",
13156        );
13157    }
13158
13159    #[test]
13160    fn fonte_caminho_control_char_fires_before_url_percent_encoding() {
13161        // Cascade pin on the upstream control-char arm: a value
13162        // carrying both a NUL byte and `%` (`"../caixa\0%20teia"` —
13163        // the canonical "I pasted a paste-from-binary-blob path
13164        // followed by a percent-encoded space" footgun) routes
13165        // through `FonteCaminhoControlChar` not
13166        // `FonteCaminhoUrlPercentEncoding`. The POSIX-syscall-
13167        // rejected byte is the load-bearing root-cause edit on
13168        // every probe-as-both value.
13169        let d = dep_with_fonte(DepSource::Path {
13170            caminho: "../caixa\0%20teia".into(),
13171        });
13172        let err = d.validate().unwrap_err();
13173        assert!(
13174            matches!(err, DepError::FonteCaminhoControlChar { byte: 0x00, .. },),
13175            "got {err:?}",
13176        );
13177    }
13178
13179    #[test]
13180    fn fonte_caminho_absolute_fires_before_url_percent_encoding() {
13181        // Cascade pin on the upstream absolute-path arm: a value
13182        // that's both absolute and carries `%` (`"/etc/passwd%20"`
13183        // — the canonical "I pasted an absolute path with a
13184        // percent-encoded space tail" footgun) routes through
13185        // `FonteCaminhoAbsolute` not
13186        // `FonteCaminhoUrlPercentEncoding`. The host-layout-leak is
13187        // the load-bearing root-cause edit on every probe-as-both
13188        // value.
13189        let d = dep_with_fonte(DepSource::Path {
13190            caminho: "/etc/passwd%20".into(),
13191        });
13192        let err = d.validate().unwrap_err();
13193        assert!(
13194            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
13195            "got {err:?}",
13196        );
13197    }
13198
13199    #[test]
13200    fn fonte_caminho_var_expansion_fires_before_url_percent_encoding() {
13201        // Cascade pin on the upstream var-expansion arm: a value
13202        // starting with `$` and carrying `%` (`"$HOME/caixa%20teia"`
13203        // — the canonical "I pasted a `$HOME`-rooted path with a
13204        // percent-encoded space" footgun) routes through
13205        // `FonteCaminhoVarExpansion` not
13206        // `FonteCaminhoUrlPercentEncoding`. The shell-variable-
13207        // expansion is the load-bearing root-cause edit on every
13208        // probe-as-both value.
13209        let d = dep_with_fonte(DepSource::Path {
13210            caminho: "$HOME/caixa%20teia".into(),
13211        });
13212        let err = d.validate().unwrap_err();
13213        assert!(
13214            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
13215            "got {err:?}",
13216        );
13217    }
13218
13219    #[test]
13220    fn fonte_caminho_url_percent_encoding_fires_before_trailing_slash() {
13221        // Cascade pin on the immediate-successor arm: a value
13222        // carrying both `%` and a trailing `/`
13223        // (`"../caixa%20teia/"` — the canonical "I tab-completed a
13224        // percent-encoded-space-carrying path" footgun) routes
13225        // through `FonteCaminhoUrlPercentEncoding` not
13226        // `FonteCaminhoTrailingSlash`. The embedded percent-
13227        // encoding-escape byte is the more semantic-locating axis
13228        // (an author who decodes the `%20` to a literal space is
13229        // likely to also tab-strip the trailing separator since
13230        // both are paste-from-URL / paste-from-shell-tab-completion
13231        // artifacts).
13232        let d = dep_with_fonte(DepSource::Path {
13233            caminho: "../caixa%20teia/".into(),
13234        });
13235        let err = d.validate().unwrap_err();
13236        assert!(
13237            matches!(
13238                err,
13239                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
13240            ),
13241            "got {err:?}",
13242        );
13243    }
13244
13245    #[test]
13246    fn fonte_caminho_url_percent_encoding_diagnostic_carries_offending_dep_caminho_and_byte() {
13247        // Diagnostic-shape pin (peer with
13248        // `fonte_caminho_shell_comment_diagnostic_carries_offending_dep_caminho_and_byte`
13249        // on the immediate-predecessor arm): the error's Display
13250        // surfaces the offending `:nome`, the offending `:caminho`
13251        // verbatim, the offending byte's hex / character form, and
13252        // names the URL-percent-encoding-escape / printf-format-
13253        // specifier footgun explicitly so a `feira lint` run can
13254        // render the diagnostic without re-parsing.
13255        let d = dep_with_fonte(DepSource::Path {
13256            caminho: "../caixa%20teia".into(),
13257        });
13258        let rendered = d.validate().unwrap_err().to_string();
13259        assert!(
13260            rendered.contains("caixa-teia"),
13261            "diagnostic must name the offending dep: {rendered}",
13262        );
13263        assert!(
13264            rendered.contains("../caixa%20teia"),
13265            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
13266        );
13267        assert!(
13268            rendered.contains("0x25"),
13269            "diagnostic must surface the offending byte hex: {rendered:?}",
13270        );
13271        assert!(
13272            rendered.contains("percent-encoding") || rendered.contains("percent-encoded"),
13273            "diagnostic must name the URL-percent-encoding-escape footgun: {rendered:?}",
13274        );
13275        assert!(
13276            rendered.contains("printf") || rendered.contains("format-specifier"),
13277            "diagnostic must reference the printf-format-specifier vocabulary: \
13278             {rendered:?}",
13279        );
13280    }
13281
13282    #[test]
13283    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_var_expansion() {
13284        // The canonical embedded-`$` shell-variable-expansion paste
13285        // shape (`"../foo$HOME/bar"` — an author copies a partially-
13286        // substituted shell one-liner where the leading segment is a
13287        // literal `../foo` while the mid segment carries the un-
13288        // substituted `$HOME` template). The leading-`$` position is
13289        // already gated by the f4efe9c leading-byte arm which routes
13290        // through `FonteCaminhoVarExpansion`; this arm closes the
13291        // last positional gap on `$` — every position on the axis is
13292        // structurally rejected.
13293        let d = dep_with_fonte(DepSource::Path {
13294            caminho: "../foo$HOME/bar".into(),
13295        });
13296        let err = d.validate().unwrap_err();
13297        let DepError::FonteCaminhoShellVariableExpansion {
13298            nome,
13299            caminho,
13300            byte,
13301        } = err
13302        else {
13303            panic!("expected FonteCaminhoShellVariableExpansion, got {err:?}");
13304        };
13305        assert_eq!(nome, "caixa-teia");
13306        assert_eq!(caminho, "../foo$HOME/bar");
13307        assert_eq!(byte, b'$');
13308    }
13309
13310    #[test]
13311    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_braced_var_expansion() {
13312        // The symmetric braced-CI-manifest paste shape
13313        // (`"../foo${WORKSPACE}/bar"` — the canonical paste-from-
13314        // GitHub-Actions-workflow / paste-from-`.gitlab-ci.yml`
13315        // footgun). Pinned separately from the bare-`$VAR` shape so
13316        // the gate covers both POSIX shell §2.6 Parameter Expansion
13317        // syntactic forms, not only the unbraced variant. The
13318        // embedded `{` byte in `${...}` is also caught by the 598b770
13319        // shell-brace-expansion arm but that arm fires earlier in
13320        // the cascade — the `$` arm's coverage extends to `${...}`
13321        // structurally, so the diagnostic asserted here is the
13322        // brace-expansion one (which is a valid outcome; the point
13323        // of the pin is that the value never survives validation).
13324        let d = dep_with_fonte(DepSource::Path {
13325            caminho: "../foo${WORKSPACE}/bar".into(),
13326        });
13327        let err = d.validate().unwrap_err();
13328        assert!(
13329            matches!(
13330                err,
13331                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. }
13332                    | DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
13333            ),
13334            "got {err:?}",
13335        );
13336    }
13337
13338    #[test]
13339    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_command_substitution() {
13340        // The paste-from-shell-prompt command-substitution idiom
13341        // (`"../foo$(whoami)/bar"`). Pinned separately from the bare-
13342        // `$VAR` shape so the gate's rationale extends to POSIX shell
13343        // §2.6.3 Command Substitution (the modern `$(<cmd>)` form; the
13344        // legacy `` `<cmd>` `` form is already closed by the c370458
13345        // backtick arm). The embedded `(` byte in `$(...)` is also
13346        // caught structurally by the 0633c91 shell-subshell-grouping
13347        // arm which fires earlier in the cascade — the diagnostic
13348        // asserted here is either outcome, since both structurally
13349        // reject the value; the point of the pin is that the value
13350        // never survives validation.
13351        let d = dep_with_fonte(DepSource::Path {
13352            caminho: "../foo$(whoami)/bar".into(),
13353        });
13354        let err = d.validate().unwrap_err();
13355        assert!(
13356            matches!(
13357                err,
13358                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. }
13359                    | DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
13360            ),
13361            "got {err:?}",
13362        );
13363    }
13364
13365    #[test]
13366    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_positional_parameter() {
13367        // The paste-from-`Makefile` / paste-from-SQL-migration bare-
13368        // `$1` positional-parameter shape (`"../foo$1/bar"` — a Make
13369        // automatic-variable `$1` or a PostgreSQL bind-parameter `$1`
13370        // idiom copied into a caminho template). None of the prior
13371        // shell-metachar arms cover this shape (`1` is a bare digit;
13372        // no `(` / `{` / letter follows the `$`), so the arm is the
13373        // sole gate on the shape.
13374        let d = dep_with_fonte(DepSource::Path {
13375            caminho: "../foo$1/bar".into(),
13376        });
13377        let err = d.validate().unwrap_err();
13378        assert!(
13379            matches!(
13380                err,
13381                DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
13382            ),
13383            "got {err:?}",
13384        );
13385    }
13386
13387    #[test]
13388    fn validate_accepts_path_fonte_with_caminho_carrying_no_dollar() {
13389        // The positive-control pin (peer with
13390        // `validate_accepts_path_fonte_with_caminho_carrying_no_percent`
13391        // on the immediate-predecessor arm): the gate targets only
13392        // `$`, never adjacent printable ASCII or POSIX-valid bytes.
13393        // A relative POSIX path carrying dashes / dots / slashes /
13394        // digits (`"../caixa-teia/sub-dir.v2"`) must continue to
13395        // validate cleanly so the gate doesn't widen to a "no
13396        // printable punctuation anywhere" sweep that would defeat
13397        // the entire path-fonte author surface.
13398        let d = dep_with_fonte(DepSource::Path {
13399            caminho: "../caixa-teia/sub-dir.v2".into(),
13400        });
13401        d.validate().unwrap();
13402    }
13403
13404    #[test]
13405    fn fonte_caminho_var_expansion_fires_before_shell_variable_expansion() {
13406        // Cascade pin on the leading-`$` sibling arm at line 540: a
13407        // value starting with `$` and carrying an embedded `$` too
13408        // (`"$HOME/foo$WORKSPACE/bar"` — the canonical "I pasted a
13409        // fully-templated CI path with two un-substituted variables")
13410        // routes through `FonteCaminhoVarExpansion` not
13411        // `FonteCaminhoShellVariableExpansion`. The leading-byte
13412        // host-layout-leak is the load-bearing self-locating axis
13413        // (the leading position dominates the semantic-locating
13414        // rationale on every probe-as-both value); the embedded
13415        // arm's positional-agnostic sweep catches only values whose
13416        // leading byte doesn't route through the earlier leading-
13417        // byte arms.
13418        let d = dep_with_fonte(DepSource::Path {
13419            caminho: "$HOME/foo$WORKSPACE/bar".into(),
13420        });
13421        let err = d.validate().unwrap_err();
13422        assert!(
13423            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
13424            "got {err:?}",
13425        );
13426    }
13427
13428    #[test]
13429    fn fonte_caminho_url_percent_encoding_fires_before_shell_variable_expansion() {
13430        // Cascade pin on the immediate-predecessor arm: a value
13431        // carrying both `%` and embedded `$` (`"../foo%20$HOME/bar"`
13432        // — the canonical "I pasted a percent-encoded space adjacent
13433        // to a `$HOME` template") routes through
13434        // `FonteCaminhoUrlPercentEncoding` not
13435        // `FonteCaminhoShellVariableExpansion`. The URL-percent-
13436        // encoding-escape byte is the more semantic-locating axis
13437        // (the paste-from-browser-address-bar shape is the load-
13438        // bearing self-locating edit); same cascade discipline every
13439        // prior `:caminho` arm establishes.
13440        let d = dep_with_fonte(DepSource::Path {
13441            caminho: "../foo%20$HOME/bar".into(),
13442        });
13443        let err = d.validate().unwrap_err();
13444        assert!(
13445            matches!(
13446                err,
13447                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
13448            ),
13449            "got {err:?}",
13450        );
13451    }
13452
13453    #[test]
13454    fn fonte_caminho_shell_variable_expansion_fires_before_trailing_slash() {
13455        // Cascade pin on the immediate-successor arm: a value
13456        // carrying both embedded `$` and a trailing `/`
13457        // (`"../foo$HOME/bar/"` — the canonical "I tab-completed a
13458        // `$HOME`-template-carrying path") routes through
13459        // `FonteCaminhoShellVariableExpansion` not
13460        // `FonteCaminhoTrailingSlash`. The embedded shell-variable-
13461        // expansion byte is the more semantic-locating axis on
13462        // probe-as-both values (an author who substitutes the
13463        // `$HOME` template with a literal value is likely to also
13464        // tab-strip the trailing separator).
13465        let d = dep_with_fonte(DepSource::Path {
13466            caminho: "../foo$HOME/bar/".into(),
13467        });
13468        let err = d.validate().unwrap_err();
13469        assert!(
13470            matches!(
13471                err,
13472                DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
13473            ),
13474            "got {err:?}",
13475        );
13476    }
13477
13478    #[test]
13479    fn fonte_caminho_shell_variable_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
13480        // Diagnostic-shape pin (peer with
13481        // `fonte_caminho_url_percent_encoding_diagnostic_carries_offending_dep_caminho_and_byte`
13482        // on the immediate-predecessor arm): the error's Display
13483        // surfaces the offending `:nome`, the offending `:caminho`
13484        // verbatim, the offending byte's hex / character form, and
13485        // names the shell-variable-expansion / command-substitution
13486        // footgun explicitly so a `feira lint` run can render the
13487        // diagnostic without re-parsing.
13488        let d = dep_with_fonte(DepSource::Path {
13489            caminho: "../foo$HOME/bar".into(),
13490        });
13491        let rendered = d.validate().unwrap_err().to_string();
13492        assert!(
13493            rendered.contains("caixa-teia"),
13494            "diagnostic must name the offending dep: {rendered}",
13495        );
13496        assert!(
13497            rendered.contains("../foo$HOME/bar"),
13498            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
13499        );
13500        assert!(
13501            rendered.contains("0x24"),
13502            "diagnostic must surface the offending byte hex: {rendered:?}",
13503        );
13504        assert!(
13505            rendered.contains("variable-expansion") || rendered.contains("variable expansion"),
13506            "diagnostic must name the shell-variable-expansion footgun: {rendered:?}",
13507        );
13508        assert!(
13509            rendered.contains("command-substitution") || rendered.contains("command substitution"),
13510            "diagnostic must reference the command-substitution vocabulary: {rendered:?}",
13511        );
13512    }
13513
13514    #[test]
13515    fn validate_rejects_path_fonte_with_caminho_carrying_shell_history_expansion() {
13516        // The fail-before-pass-after pin for the canonical paste-from-
13517        // shell-history footgun on `:caminho`. An author copies a `cd
13518        // ../caixa-teia && !sudo make install` one-liner from a quick-
13519        // start README, intending the trailing `!sudo` as a shell-
13520        // history-expansion reference but the typed slot is itself a
13521        // byte-level string parser, not a shell context, so the byte
13522        // rides into the value verbatim. Until this arm landed the `!`
13523        // byte silently passed every prior `:caminho` cascade arm
13524        // (`!` isn't `\` / `<` / `>` / `|` / `;` / `&` / backtick /
13525        // `*` / `?` / `(` / `)` / `{` / `}` / `[` / `]` / `'` / `"` /
13526        // `#` / `%` / `$`); bash with the default `histexpand` mode
13527        // rewrites `!command` to the most recent history entry
13528        // beginning with `command`, the canonical RCE-class injection
13529        // vector when the byte rides into a shell argument executed
13530        // under `bash -i` (the operator-notebook interactive shell).
13531        let d = dep_with_fonte(DepSource::Path {
13532            caminho: "../caixa-teia!sudo".into(),
13533        });
13534        let err = d.validate().unwrap_err();
13535        let DepError::FonteCaminhoShellHistoryExpansion {
13536            nome,
13537            caminho,
13538            byte,
13539        } = err
13540        else {
13541            panic!("expected FonteCaminhoShellHistoryExpansion, got {err:?}");
13542        };
13543        assert_eq!(nome, "caixa-teia");
13544        assert_eq!(caminho, "../caixa-teia!sudo");
13545        assert_eq!(byte, b'!');
13546    }
13547
13548    #[test]
13549    fn validate_rejects_path_fonte_with_caminho_carrying_double_bang_history_reference() {
13550        // The symmetric `!!` repeat-prior-command paste idiom (peer with
13551        // `validate_rejects_git_fonte_with_repo_carrying_double_bang_history_reference`
13552        // on `is_git_repo_url`). Pinned separately from the wrapped
13553        // `!command` shape so a future diagnostic-surface change that
13554        // only checked the leading or paired-bang position surfaces
13555        // here — the per-byte arm fires anywhere `!` appears in the
13556        // value, including at consecutive positions in the middle.
13557        let d = dep_with_fonte(DepSource::Path {
13558            caminho: "../foo!!/bar".into(),
13559        });
13560        let err = d.validate().unwrap_err();
13561        assert!(
13562            matches!(
13563                err,
13564                DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
13565            ),
13566            "got {err:?}",
13567        );
13568    }
13569
13570    #[test]
13571    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_enthusiasm_bang() {
13572        // The English-typography enthusiasm-form paste-from-prose
13573        // idiom: an author writes `:caminho "../caixa-teia!"`
13574        // expecting the substrate to coerce it to a kebab-case slug.
13575        // Pinned separately from the `!<word>` shell-history shape so
13576        // the gate's rationale extends to the paste-from-prose surface
13577        // (the same rationale the peer `is_git_repo_url` bang arm at
13578        // 7d53c68 covers). None of the prior shell-metachar arms cover
13579        // this shape (no `!<word>` reference and no `!!` repeat), so
13580        // the arm is the sole gate on the shape.
13581        let d = dep_with_fonte(DepSource::Path {
13582            caminho: "../caixa-teia!".into(),
13583        });
13584        let err = d.validate().unwrap_err();
13585        assert!(
13586            matches!(
13587                err,
13588                DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
13589            ),
13590            "got {err:?}",
13591        );
13592    }
13593
13594    #[test]
13595    fn validate_accepts_path_fonte_with_caminho_carrying_no_bang() {
13596        // The positive-control pin (peer with
13597        // `validate_accepts_path_fonte_with_caminho_carrying_no_dollar`
13598        // on the immediate-predecessor arm): the gate targets only
13599        // `!`, never adjacent printable ASCII or POSIX-valid bytes.
13600        // A relative POSIX path carrying dashes / dots / slashes /
13601        // digits (`"../caixa-teia/sub-dir.v2"`) must continue to
13602        // validate cleanly so the gate doesn't widen to a "no
13603        // printable punctuation anywhere" sweep that would defeat
13604        // the entire path-fonte author surface.
13605        let d = dep_with_fonte(DepSource::Path {
13606            caminho: "../caixa-teia/sub-dir.v2".into(),
13607        });
13608        d.validate().unwrap();
13609    }
13610
13611    #[test]
13612    fn fonte_caminho_shell_variable_expansion_fires_before_shell_history_expansion() {
13613        // Cascade pin on the immediate-predecessor arm: a value
13614        // carrying both embedded `$` and `!` (`"../foo$HOME/bar!sudo"`
13615        // — the canonical "I pasted a `$HOME`-templated path adjacent
13616        // to a trailing `!sudo` history-expansion") routes through
13617        // `FonteCaminhoShellVariableExpansion` not
13618        // `FonteCaminhoShellHistoryExpansion`. The shell-variable-
13619        // expansion byte is the more semantic-locating axis on
13620        // probe-as-both values (the paste-from-CI-manifest-with-`$VAR`-
13621        // template shape is the load-bearing self-locating edit);
13622        // same cascade discipline every prior `:caminho` arm
13623        // establishes.
13624        let d = dep_with_fonte(DepSource::Path {
13625            caminho: "../foo$HOME/bar!sudo".into(),
13626        });
13627        let err = d.validate().unwrap_err();
13628        assert!(
13629            matches!(
13630                err,
13631                DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
13632            ),
13633            "got {err:?}",
13634        );
13635    }
13636
13637    #[test]
13638    fn fonte_caminho_shell_history_expansion_fires_before_trailing_slash() {
13639        // Cascade pin on the immediate-successor arm: a value carrying
13640        // both embedded `!` and a trailing `/` (`"../caixa-teia!sudo/"`
13641        // — the canonical "I tab-completed a `!sudo`-carrying path")
13642        // routes through `FonteCaminhoShellHistoryExpansion` not
13643        // `FonteCaminhoTrailingSlash`. The embedded shell-history-
13644        // expansion byte is the more semantic-locating axis on probe-
13645        // as-both values (an author who removes the `!sudo` history
13646        // reference is likely to also tab-strip the trailing separator).
13647        let d = dep_with_fonte(DepSource::Path {
13648            caminho: "../caixa-teia!sudo/".into(),
13649        });
13650        let err = d.validate().unwrap_err();
13651        assert!(
13652            matches!(
13653                err,
13654                DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
13655            ),
13656            "got {err:?}",
13657        );
13658    }
13659
13660    #[test]
13661    fn fonte_caminho_shell_history_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
13662        // Diagnostic-shape pin (peer with
13663        // `fonte_caminho_shell_variable_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
13664        // on the immediate-predecessor arm): the error's Display
13665        // surfaces the offending `:nome`, the offending `:caminho`
13666        // verbatim, the offending byte's hex / character form, and
13667        // names the shell-history-expansion / bang-operator footgun
13668        // explicitly so a `feira lint` run can render the diagnostic
13669        // without re-parsing.
13670        let d = dep_with_fonte(DepSource::Path {
13671            caminho: "../caixa-teia!sudo".into(),
13672        });
13673        let rendered = d.validate().unwrap_err().to_string();
13674        assert!(
13675            rendered.contains("caixa-teia"),
13676            "diagnostic must name the offending dep: {rendered}",
13677        );
13678        assert!(
13679            rendered.contains("../caixa-teia!sudo"),
13680            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
13681        );
13682        assert!(
13683            rendered.contains("0x21"),
13684            "diagnostic must surface the offending byte hex: {rendered:?}",
13685        );
13686        assert!(
13687            rendered.contains("history-expansion") || rendered.contains("history expansion"),
13688            "diagnostic must name the shell-history-expansion footgun: {rendered:?}",
13689        );
13690        assert!(
13691            rendered.contains("bang"),
13692            "diagnostic must reference the bang-operator vocabulary: {rendered:?}",
13693        );
13694    }
13695
13696    #[test]
13697    fn validate_rejects_path_fonte_with_caminho_carrying_shell_history_substitution() {
13698        // The fail-before-pass-after pin for the canonical paste-from-
13699        // shell-history-quick-substitution footgun on `:caminho`. An
13700        // author copies a `git clone <bad-url>` line from their terminal,
13701        // corrects it via bash's `^bad^good` quick-substitution history
13702        // operator (bash reference §9.3, `set -o histexpand` mode's
13703        // default for interactive sessions), and pastes the trailing
13704        // `^bad^good` substitution fragment into a `:caminho` value
13705        // without trimming the leading `git clone` prefix — the byte
13706        // rides into the manifest verbatim. Until this arm landed the
13707        // `^` byte silently passed every prior `:caminho` cascade arm
13708        // (`^` isn't `\` / `<` / `>` / `|` / `;` / `&` / backtick / `*`
13709        // / `?` / `(` / `)` / `{` / `}` / `[` / `]` / `'` / `"` / `#` /
13710        // `%` / `$` / `!`); bash with the default `histexpand` mode
13711        // rewrites the prior command's `bad` string to `good` and re-
13712        // executes it, the paired-operator half of the `set -o
13713        // histexpand` feature the peer `!` arm already closes the prefix
13714        // half of. The peer `is_git_repo_url` axis rejects the byte at
13715        // 49e142f under the same shell-history-substitution / RFC-3986-
13716        // unwise banner.
13717        let d = dep_with_fonte(DepSource::Path {
13718            caminho: "../foo^bad^good".into(),
13719        });
13720        let err = d.validate().unwrap_err();
13721        let DepError::FonteCaminhoShellHistorySubstitution {
13722            nome,
13723            caminho,
13724            byte,
13725        } = err
13726        else {
13727            panic!("expected FonteCaminhoShellHistorySubstitution, got {err:?}");
13728        };
13729        assert_eq!(nome, "caixa-teia");
13730        assert_eq!(caminho, "../foo^bad^good");
13731        assert_eq!(byte, b'^');
13732    }
13733
13734    #[test]
13735    fn validate_rejects_path_fonte_with_caminho_carrying_regex_negation_anchor() {
13736        // The symmetric paste-from-doc-grep-pipeline footgun (peer with
13737        // `validate_rejects_git_fonte_with_repo_carrying_caret_regex_anchor`
13738        // on `is_git_repo_url`). An author copies a `grep '^archived'`
13739        // regex-anchor / negation idiom from a doc snippet and the byte
13740        // rides in verbatim. Pinned separately from the `^old^new^`
13741        // quick-substitution shape so a future diagnostic-surface change
13742        // that only checked the paired-caret history-substitution
13743        // position surfaces here — the per-byte arm fires anywhere `^`
13744        // appears in the value, including at a solitary leading-of-
13745        // segment position.
13746        let d = dep_with_fonte(DepSource::Path {
13747            caminho: "../foo/^archived".into(),
13748        });
13749        let err = d.validate().unwrap_err();
13750        assert!(
13751            matches!(
13752                err,
13753                DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
13754            ),
13755            "got {err:?}",
13756        );
13757    }
13758
13759    #[test]
13760    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_history_substitution_open() {
13761        // The trailing-`^` history-substitution-open shape — an author
13762        // starts typing a `^bad^good` quick-substitution but pastes only
13763        // the leading `^` sentinel before context-switching (a bash-
13764        // reference §9.3 valid histexpand prefix on its own — even a
13765        // solitary `^` on the prior command's whole re-execution shape).
13766        // Pinned separately from the `^old^new^` full-form and the leading-
13767        // of-segment `^archived` regex-anchor shape so the gate's
13768        // rationale extends to the paste-from-shell-history-with-only-
13769        // the-first-byte-selected surface. None of the prior shell-
13770        // metachar arms cover this shape.
13771        let d = dep_with_fonte(DepSource::Path {
13772            caminho: "../caixa-teia^".into(),
13773        });
13774        let err = d.validate().unwrap_err();
13775        assert!(
13776            matches!(
13777                err,
13778                DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
13779            ),
13780            "got {err:?}",
13781        );
13782    }
13783
13784    #[test]
13785    fn validate_accepts_path_fonte_with_caminho_carrying_no_caret() {
13786        // The positive-control pin (peer with
13787        // `validate_accepts_path_fonte_with_caminho_carrying_no_bang`
13788        // on the immediate-predecessor arm): the gate targets only
13789        // `^`, never adjacent printable ASCII or POSIX-valid bytes.
13790        // A relative POSIX path carrying dashes / dots / slashes /
13791        // digits / underscore (`"../caixa-teia/sub_v2.rc"`) must
13792        // continue to validate cleanly so the gate doesn't widen to
13793        // a "no printable punctuation anywhere" sweep that would
13794        // defeat the entire path-fonte author surface.
13795        let d = dep_with_fonte(DepSource::Path {
13796            caminho: "../caixa-teia/sub_v2.rc".into(),
13797        });
13798        d.validate().unwrap();
13799    }
13800
13801    #[test]
13802    fn fonte_caminho_shell_history_expansion_fires_before_shell_history_substitution() {
13803        // Cascade pin on the immediate-predecessor arm: a value carrying
13804        // both embedded `!` and `^` (`"../foo!sudo^bad^good"` — the
13805        // canonical "I pasted a `!sudo` history-reference next to a
13806        // `^bad^good` quick-substitution") routes through
13807        // `FonteCaminhoShellHistoryExpansion` not
13808        // `FonteCaminhoShellHistorySubstitution`. The `!` prefix form is
13809        // the more semantic-locating axis on probe-as-both values (an
13810        // author who removes the `!sudo` reference is likely to also
13811        // strip the paired `^` substitution fragment); same cascade
13812        // discipline every prior `:caminho` arm establishes.
13813        let d = dep_with_fonte(DepSource::Path {
13814            caminho: "../foo!sudo^bad^good".into(),
13815        });
13816        let err = d.validate().unwrap_err();
13817        assert!(
13818            matches!(
13819                err,
13820                DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
13821            ),
13822            "got {err:?}",
13823        );
13824    }
13825
13826    #[test]
13827    fn fonte_caminho_shell_history_substitution_fires_before_trailing_slash() {
13828        // Cascade pin on the immediate-successor arm: a value carrying
13829        // both embedded `^` and a trailing `/` (`"../foo^bad^good/"` —
13830        // the canonical "I tab-completed a `^bad^good`-carrying path")
13831        // routes through `FonteCaminhoShellHistorySubstitution` not
13832        // `FonteCaminhoTrailingSlash`. The embedded shell-history-
13833        // substitution byte is the more semantic-locating axis on probe-
13834        // as-both values (an author who removes the `^bad^good`
13835        // substitution fragment is likely to also tab-strip the trailing
13836        // separator).
13837        let d = dep_with_fonte(DepSource::Path {
13838            caminho: "../foo^bad^good/".into(),
13839        });
13840        let err = d.validate().unwrap_err();
13841        assert!(
13842            matches!(
13843                err,
13844                DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
13845            ),
13846            "got {err:?}",
13847        );
13848    }
13849
13850    #[test]
13851    fn fonte_caminho_shell_history_substitution_diagnostic_carries_offending_dep_caminho_and_byte()
13852    {
13853        // Diagnostic-shape pin (peer with
13854        // `fonte_caminho_shell_history_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
13855        // on the immediate-predecessor arm): the error's Display
13856        // surfaces the offending `:nome`, the offending `:caminho`
13857        // verbatim, the offending byte's hex form, and names the
13858        // shell-history-substitution / RFC-3986-'unwise' / regex-
13859        // negation footgun explicitly so a `feira lint` run can render
13860        // the diagnostic without re-parsing.
13861        let d = dep_with_fonte(DepSource::Path {
13862            caminho: "../foo^bad^good".into(),
13863        });
13864        let rendered = d.validate().unwrap_err().to_string();
13865        assert!(
13866            rendered.contains("caixa-teia"),
13867            "diagnostic must name the offending dep: {rendered}",
13868        );
13869        assert!(
13870            rendered.contains("../foo^bad^good"),
13871            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
13872        );
13873        assert!(
13874            rendered.contains("0x5e") || rendered.contains("0x5E"),
13875            "diagnostic must surface the offending byte hex: {rendered:?}",
13876        );
13877        assert!(
13878            rendered.contains("history-substitution") || rendered.contains("history substitution"),
13879            "diagnostic must name the shell-history-substitution footgun: {rendered:?}",
13880        );
13881        assert!(
13882            rendered.contains("unwise"),
13883            "diagnostic must reference the RFC-3986 'unwise' set vocabulary: {rendered:?}",
13884        );
13885    }
13886
13887    #[test]
13888    fn fonte_repo_empty_fires_before_pin_missing() {
13889        // Order pin: empty `:repo` is the more self-locating diagnostic
13890        // (every git source needs a repo; the pin discussion is
13891        // secondary), so it fires before the pin-missing arm even when
13892        // both are violated. Mirrors the
13893        // `nome_empty_takes_precedence_over_versao_invalid` ordering
13894        // discipline on the per-entry layer.
13895        let d = dep_with_fonte(DepSource::Git {
13896            repo: String::new(),
13897            tag: None,
13898            rev: None,
13899            branch: None,
13900        });
13901        let err = d.validate().unwrap_err();
13902        assert!(
13903            matches!(err, DepError::FonteRepoEmpty { .. }),
13904            "got {err:?}"
13905        );
13906    }
13907
13908    #[test]
13909    fn fonte_pin_missing_fires_before_pin_empty() {
13910        // Order pin: a fully-None pin set is structurally distinct from
13911        // a Some(empty) pin — the first surfaces as FontePinMissing
13912        // (no axis chosen), the second as FontePinEmpty (axis chosen
13913        // but value blank). Pin the disjoint relationship so a future
13914        // unification collapses to one variant only as a structural
13915        // decision.
13916        let d = dep_with_fonte(DepSource::Git {
13917            repo: "github:pleme-io/caixa-teia".into(),
13918            tag: None,
13919            rev: None,
13920            branch: None,
13921        });
13922        assert!(matches!(
13923            d.validate().unwrap_err(),
13924            DepError::FontePinMissing { .. }
13925        ));
13926    }
13927
13928    #[test]
13929    fn nome_empty_takes_precedence_over_fonte_invalid() {
13930        // Order pin: a per-entry diagnostic without a non-empty :nome
13931        // can't be self-locating, so :nome "" fires first even when
13932        // :fonte is also malformed. Mirrors
13933        // `nome_empty_takes_precedence_over_versao_invalid` on the
13934        // adjacent axis.
13935        let mut d = dep_with_fonte(DepSource::Git {
13936            repo: String::new(),
13937            tag: None,
13938            rev: None,
13939            branch: None,
13940        });
13941        d.nome = String::new();
13942        assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
13943    }
13944
13945    #[test]
13946    fn versao_invalid_takes_precedence_over_fonte_invalid() {
13947        // Order pin: the :versao parse-side diagnostic is narrower than
13948        // the :fonte shape diagnostic — a malformed :versao always names
13949        // the parser's reason, which is more actionable than the
13950        // :fonte gate's "the pins are wrong" wording. Pin the ordering
13951        // so a re-ordering surfaces here.
13952        let mut d = dep_with_fonte(DepSource::Git {
13953            repo: String::new(),
13954            tag: None,
13955            rev: None,
13956            branch: None,
13957        });
13958        d.versao = "v0.1".into();
13959        let err = d.validate().unwrap_err();
13960        assert!(
13961            matches!(err, DepError::VersaoInvalid { ref nome, .. } if nome == "caixa-teia"),
13962            "got {err:?}"
13963        );
13964    }
13965
13966    #[test]
13967    fn fonte_invalid_diagnostic_carries_offending_nome() {
13968        // The diagnostic-shape pin: every :fonte error variant names
13969        // the offending dep's :nome verbatim, so the author can grep
13970        // caixa.lisp for the `:nome "<n>"` block and fix it in one
13971        // edit. Cover all seven variants so a future variant addition
13972        // forces a parallel diagnostic-shape decision.
13973        for (case, fonte) in [
13974            (
13975                "repo-empty",
13976                DepSource::Git {
13977                    repo: String::new(),
13978                    tag: Some("v1".into()),
13979                    rev: None,
13980                    branch: None,
13981                },
13982            ),
13983            (
13984                "repo-shape",
13985                DepSource::Git {
13986                    repo: "github:p/x ".into(),
13987                    tag: Some("v1".into()),
13988                    rev: None,
13989                    branch: None,
13990                },
13991            ),
13992            (
13993                "pin-missing",
13994                DepSource::Git {
13995                    repo: "github:p/x".into(),
13996                    tag: None,
13997                    rev: None,
13998                    branch: None,
13999                },
14000            ),
14001            (
14002                "pin-ambiguous",
14003                DepSource::Git {
14004                    repo: "github:p/x".into(),
14005                    tag: Some("v1".into()),
14006                    rev: None,
14007                    branch: Some("main".into()),
14008                },
14009            ),
14010            (
14011                "pin-empty",
14012                DepSource::Git {
14013                    repo: "github:p/x".into(),
14014                    tag: Some(String::new()),
14015                    rev: None,
14016                    branch: None,
14017                },
14018            ),
14019            (
14020                "caminho-empty",
14021                DepSource::Path {
14022                    caminho: String::new(),
14023                },
14024            ),
14025            (
14026                "caminho-absolute",
14027                DepSource::Path {
14028                    caminho: "/home/me/work/caixa-teia".into(),
14029                },
14030            ),
14031        ] {
14032            let d = dep_with_fonte(fonte);
14033            let msg = d
14034                .validate()
14035                .expect_err(&format!("{case}: expected fonte error"))
14036                .to_string();
14037            assert!(
14038                msg.contains("\"caixa-teia\""),
14039                "{case}: diagnostic must quote the offending :nome verbatim, got {msg:?}"
14040            );
14041        }
14042    }
14043
14044    // -- :tag / :branch value-shape gate ----------------------------------
14045
14046    #[test]
14047    fn validate_rejects_git_fonte_with_tag_carrying_trailing_space() {
14048        // The canonical paste-from-doc footgun on `:tag` — author
14049        // copies `"v0.1.0 "` (trailing space) out of a release-notes
14050        // paragraph. Until this gate landed the empty-pin arm passed
14051        // (the string isn't empty), the resolver issued
14052        // `git fetch <remote> tag 'v0.1.0 '`, and the failure
14053        // surfaced at clone time with a quoting-confused git error
14054        // far from the source caixa.lisp. The new gate moves the
14055        // check to caixa-build time and names the offending dep +
14056        // pin + value verbatim.
14057        let d = dep_with_fonte(DepSource::Git {
14058            repo: "github:pleme-io/caixa-teia".into(),
14059            tag: Some("v0.1.0 ".into()),
14060            rev: None,
14061            branch: None,
14062        });
14063        let err = d.validate().unwrap_err();
14064        let DepError::FontePinShape {
14065            nome,
14066            pin,
14067            value,
14068            reason,
14069        } = err
14070        else {
14071            panic!("expected FontePinShape, got other variant");
14072        };
14073        assert_eq!(nome, "caixa-teia");
14074        assert_eq!(pin, ":tag");
14075        assert_eq!(value, "v0.1.0 ");
14076        assert!(
14077            reason.contains("whitespace"),
14078            "reason must surface the whitespace arm, got {reason:?}"
14079        );
14080    }
14081
14082    #[test]
14083    fn validate_rejects_git_fonte_with_tag_carrying_lock_suffix() {
14084        // The `.lock` suffix is git's atomic-rename guard for
14085        // in-flight ref updates — a refname ending in `.lock` is
14086        // unwritable on disk. Pinned separately from the whitespace
14087        // arm so a future relaxation that admits one but not the
14088        // other surfaces here.
14089        let d = dep_with_fonte(DepSource::Git {
14090            repo: "github:pleme-io/caixa-teia".into(),
14091            tag: Some("v0.1.0.lock".into()),
14092            rev: None,
14093            branch: None,
14094        });
14095        let err = d.validate().unwrap_err();
14096        let DepError::FontePinShape {
14097            pin, value, reason, ..
14098        } = err
14099        else {
14100            panic!("expected FontePinShape, got other variant");
14101        };
14102        assert_eq!(pin, ":tag");
14103        assert_eq!(value, "v0.1.0.lock");
14104        assert!(
14105            reason.contains(".lock"),
14106            "reason must surface the .lock arm, got {reason:?}"
14107        );
14108    }
14109
14110    #[test]
14111    fn validate_rejects_git_fonte_with_branch_carrying_embedded_space() {
14112        // The canonical "branch name with spaces" footgun (`feature
14113        // foo`, `release branch`) — git's refname parser rejects raw
14114        // whitespace, and the failure surfaces at `git checkout
14115        // 'feature foo'` time with a quoting-confused error far from
14116        // the source caixa.lisp. Pinned on the `:branch` axis so the
14117        // gate-applies-to-both-:tag-and-:branch contract is a build-
14118        // error to relax.
14119        let d = dep_with_fonte(DepSource::Git {
14120            repo: "github:pleme-io/caixa-teia".into(),
14121            tag: None,
14122            rev: None,
14123            branch: Some("feature/foo bar".into()),
14124        });
14125        let err = d.validate().unwrap_err();
14126        let DepError::FontePinShape {
14127            pin, value, reason, ..
14128        } = err
14129        else {
14130            panic!("expected FontePinShape, got other variant");
14131        };
14132        assert_eq!(pin, ":branch");
14133        assert_eq!(value, "feature/foo bar");
14134        assert!(
14135            reason.contains("whitespace"),
14136            "reason must surface the whitespace arm, got {reason:?}"
14137        );
14138    }
14139
14140    #[test]
14141    fn validate_rejects_git_fonte_with_branch_carrying_qualified_prefix() {
14142        // The `refs/heads/main` shape — the canonical "I copied the
14143        // fully-qualified ref out of `git show-ref` instead of the
14144        // leaf" footgun. The caixa-resolver prepends `refs/heads/`
14145        // at clone time, so this resolves to a literal ref named
14146        // `refs/heads/refs/heads/main` on disk; the silent double-
14147        // prefix is the load-bearing reason to gate at validate.
14148        // The diagnostic must enumerate the leaf the author probably
14149        // meant (`"main"`) so the fix is one edit.
14150        let d = dep_with_fonte(DepSource::Git {
14151            repo: "github:pleme-io/caixa-teia".into(),
14152            tag: None,
14153            rev: None,
14154            branch: Some("refs/heads/main".into()),
14155        });
14156        let err = d.validate().unwrap_err();
14157        let DepError::FontePinShape {
14158            pin, value, reason, ..
14159        } = err
14160        else {
14161            panic!("expected FontePinShape, got other variant");
14162        };
14163        assert_eq!(pin, ":branch");
14164        assert_eq!(value, "refs/heads/main");
14165        assert!(
14166            reason.contains("fully-qualified"),
14167            "reason must surface the qualified-prefix arm, got {reason:?}"
14168        );
14169        assert!(
14170            reason.contains("\"main\""),
14171            "reason must quote the leaf the author probably meant, got {reason:?}"
14172        );
14173    }
14174
14175    #[test]
14176    fn validate_rejects_git_fonte_with_tag_carrying_qualified_prefix() {
14177        // Sibling arm of the qualified-prefix gate on the `:tag`
14178        // axis (`refs/tags/v0.1.0` — same `git show-ref` output-leak
14179        // footgun). Pinned separately so a future relaxation that
14180        // only catches the `:branch` arm surfaces here.
14181        let d = dep_with_fonte(DepSource::Git {
14182            repo: "github:pleme-io/caixa-teia".into(),
14183            tag: Some("refs/tags/v0.1.0".into()),
14184            rev: None,
14185            branch: None,
14186        });
14187        let err = d.validate().unwrap_err();
14188        let DepError::FontePinShape {
14189            pin, value, reason, ..
14190        } = err
14191        else {
14192            panic!("expected FontePinShape, got other variant");
14193        };
14194        assert_eq!(pin, ":tag");
14195        assert_eq!(value, "refs/tags/v0.1.0");
14196        assert!(
14197            reason.contains("fully-qualified"),
14198            "reason must surface the qualified-prefix arm, got {reason:?}"
14199        );
14200        assert!(
14201            reason.contains("\"v0.1.0\""),
14202            "reason must quote the leaf the author probably meant, got {reason:?}"
14203        );
14204    }
14205
14206    #[test]
14207    fn validate_rejects_git_fonte_with_branch_named_at() {
14208        // The bare `@` is git's alias for `HEAD`; a `:branch "@"` is
14209        // unsourceable. Pinned so a future relaxation that admits
14210        // any single-character refname surfaces here.
14211        let d = dep_with_fonte(DepSource::Git {
14212            repo: "github:pleme-io/caixa-teia".into(),
14213            tag: None,
14214            rev: None,
14215            branch: Some("@".into()),
14216        });
14217        let err = d.validate().unwrap_err();
14218        let DepError::FontePinShape { pin, value, .. } = err else {
14219            panic!("expected FontePinShape, got other variant");
14220        };
14221        assert_eq!(pin, ":branch");
14222        assert_eq!(value, "@");
14223    }
14224
14225    #[test]
14226    fn validate_rejects_git_fonte_with_tag_carrying_double_dot() {
14227        // Git's `<rev1>..<rev2>` range grammar reserves `..` —
14228        // a `:tag "../escape"` (path-traversal-shaped slug) silently
14229        // passes parse and surfaces as a refname-parse error or, on
14230        // older git, a literal `../escape` checkout that escapes the
14231        // refs/ directory tree. Pinned separately from the
14232        // qualified-prefix arm so a future relaxation that catches
14233        // one but not the other surfaces here.
14234        let d = dep_with_fonte(DepSource::Git {
14235            repo: "github:pleme-io/caixa-teia".into(),
14236            tag: Some("../escape".into()),
14237            rev: None,
14238            branch: None,
14239        });
14240        let err = d.validate().unwrap_err();
14241        let DepError::FontePinShape { pin, value, .. } = err else {
14242            panic!("expected FontePinShape, got other variant");
14243        };
14244        assert_eq!(pin, ":tag");
14245        assert_eq!(value, "../escape");
14246    }
14247
14248    #[test]
14249    fn validate_accepts_git_fonte_with_hierarchical_branch() {
14250        // The positive-control pin: hierarchical refnames with one or
14251        // more `/` separators (the `feature/foo` / `user/jdoe/feat`
14252        // canonical idiom) round-trip through the gate. Pinned
14253        // separately from the leaf-`"main"` positive control so a
14254        // future tightening that rejects all multi-component refnames
14255        // surfaces here.
14256        let d = dep_with_fonte(DepSource::Git {
14257            repo: "github:pleme-io/caixa-teia".into(),
14258            tag: None,
14259            rev: None,
14260            branch: Some("feature/checkout-rewrite".into()),
14261        });
14262        d.validate().unwrap();
14263    }
14264
14265    #[test]
14266    fn validate_accepts_git_fonte_with_prerelease_tag() {
14267        // The positive-control pin: semver pre-release shape
14268        // (`v0.1.0-alpha.1`) — the in-component dot is allowed
14269        // (only consecutive `..` and trailing `.` are rejected), the
14270        // mid-component hyphen is allowed. Pinned separately from
14271        // the bare-`"v0.1.0"` positive control so a future tightening
14272        // that rejects pre-release tags surfaces here.
14273        let d = dep_with_fonte(DepSource::Git {
14274            repo: "github:pleme-io/caixa-teia".into(),
14275            tag: Some("v0.1.0-alpha.1".into()),
14276            rev: None,
14277            branch: None,
14278        });
14279        d.validate().unwrap();
14280    }
14281
14282    #[test]
14283    fn validate_rejects_git_fonte_with_rev_carrying_refname_unfriendly_value() {
14284        // The `:rev` axis is routed through `crate::render::is_git_oid`
14285        // (a SHA's character set is `[0-9a-f]`, not a refname's), so a
14286        // value with refname-shape punctuation (here, a `:` mid-string
14287        // — would be a refname violation under `is_git_ref_name` too)
14288        // is rejected at the OID-shape gate. The two predicates
14289        // partition the `:fonte` pin axes structurally: an `:rev` value
14290        // that's a valid refname (`:rev "main"`, `:rev "v0.1.0"`) is
14291        // *still* rejected here because every refname character outside
14292        // `[0-9a-f]` fails the OID gate. Same shape as
14293        // `fonte_pin_shape_diagnostic_carries_offending_nome_pin_value`
14294        // on the refname-shaped axes — the diagnostic names the
14295        // offending dep + pin + value verbatim. The flip-from-accept
14296        // case the prior `:tag`/`:branch` gate left as a "future axis"
14297        // (e70d213) — now landed.
14298        let d = dep_with_fonte(DepSource::Git {
14299            repo: "github:pleme-io/caixa-teia".into(),
14300            tag: None,
14301            rev: Some("c0ffee:notarefname".into()),
14302            branch: None,
14303        });
14304        let err = d.validate().unwrap_err();
14305        let DepError::FontePinShape {
14306            nome,
14307            pin,
14308            value,
14309            reason,
14310        } = err
14311        else {
14312            panic!("expected FontePinShape, got other variant");
14313        };
14314        assert_eq!(nome, "caixa-teia");
14315        assert_eq!(pin, ":rev");
14316        assert_eq!(value, "c0ffee:notarefname");
14317        assert!(
14318            !reason.is_empty(),
14319            "FontePinShape `reason` must carry the predicate's wording verbatim"
14320        );
14321    }
14322
14323    #[test]
14324    fn validate_accepts_git_fonte_with_rev_full_sha1() {
14325        // The positive-control pin on the SHA-1 OID width: exactly 40
14326        // lowercase hex characters — the canonical `git rev-parse HEAD`
14327        // emission on a SHA-1-hashed repository (the default on every
14328        // pre-2.42 git and the canonical pleme-io substrate hash).
14329        // Pinned separately from the SHA-256 positive control so a
14330        // future tightening that only admits one width surfaces here.
14331        let d = dep_with_fonte(DepSource::Git {
14332            repo: "github:pleme-io/caixa-teia".into(),
14333            tag: None,
14334            rev: Some("0123456789abcdef0123456789abcdef01234567".into()),
14335            branch: None,
14336        });
14337        d.validate().unwrap();
14338    }
14339
14340    #[test]
14341    fn validate_accepts_git_fonte_with_rev_full_sha256() {
14342        // The positive-control pin on the SHA-256 OID width: exactly
14343        // 64 lowercase hex characters — `git`'s
14344        // `extensions.objectFormat = sha256` emission (GA since Git
14345        // 2.42 / Oct 2023). The substrate admits either canonical
14346        // width so an `:rev` authored against a SHA-256-hashed
14347        // upstream round-trips through the gate without per-repo
14348        // configuration. Pinned separately from the SHA-1 positive
14349        // control so a future tightening that drops one width surfaces
14350        // here as a structural decision.
14351        let d = dep_with_fonte(DepSource::Git {
14352            repo: "github:pleme-io/caixa-teia".into(),
14353            tag: None,
14354            rev: Some("0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef".into()),
14355            branch: None,
14356        });
14357        d.validate().unwrap();
14358    }
14359
14360    #[test]
14361    fn validate_rejects_git_fonte_with_rev_abbreviated_prefix() {
14362        // The canonical `git log --short` / `git rev-parse --short HEAD`
14363        // paste-from-release-notes footgun: a 7-char prefix (git's
14364        // default `core.abbrev`) silently passes string emptiness
14365        // checks and resolves to one commit today, but becomes ambiguous
14366        // tomorrow as the repo grows. Until this gate landed the empty-
14367        // pin arm passed (the string isn't empty) and the resolver
14368        // accepted the prefix through git's separate prefix-lookup pass
14369        // — defeating the reproducibility contract `:rev` carries vs.
14370        // `:tag` / `:branch`. The new gate moves the check to caixa-
14371        // build time and names the offending dep + pin + value verbatim.
14372        let d = dep_with_fonte(DepSource::Git {
14373            repo: "github:pleme-io/caixa-teia".into(),
14374            tag: None,
14375            rev: Some("c0ffee0".into()),
14376            branch: None,
14377        });
14378        let err = d.validate().unwrap_err();
14379        let DepError::FontePinShape {
14380            pin, value, reason, ..
14381        } = err
14382        else {
14383            panic!("expected FontePinShape, got other variant");
14384        };
14385        assert_eq!(pin, ":rev");
14386        assert_eq!(value, "c0ffee0");
14387        assert!(
14388            reason.contains("abbreviated") || reason.contains("ambiguous"),
14389            "reason must surface the abbreviation arm, got {reason:?}"
14390        );
14391    }
14392
14393    #[test]
14394    fn validate_rejects_git_fonte_with_rev_uppercase_hex() {
14395        // The canonical "I pasted the SHA in uppercase" footgun: `git
14396        // porcelain` emits OIDs lowercase exclusively, so an uppercase-
14397        // bearing `:rev` round-trips inconsistently across the
14398        // resolver's `git fetch <remote> <:rev>` ↔ `git rev-parse HEAD`
14399        // equality-check pipeline and fails the lacre's content-
14400        // addressing probe with a confusing case-only diff. Pinned
14401        // separately from the non-hex arm so a future relaxation that
14402        // admits one but not the other surfaces here.
14403        let d = dep_with_fonte(DepSource::Git {
14404            repo: "github:pleme-io/caixa-teia".into(),
14405            tag: None,
14406            rev: Some("DEADBEEFCAFEBABE0123456789ABCDEF01234567".into()),
14407            branch: None,
14408        });
14409        let err = d.validate().unwrap_err();
14410        let DepError::FontePinShape {
14411            pin, value, reason, ..
14412        } = err
14413        else {
14414            panic!("expected FontePinShape, got other variant");
14415        };
14416        assert_eq!(pin, ":rev");
14417        assert_eq!(value, "DEADBEEFCAFEBABE0123456789ABCDEF01234567");
14418        assert!(
14419            reason.contains("uppercase"),
14420            "reason must surface the uppercase arm, got {reason:?}"
14421        );
14422    }
14423
14424    #[test]
14425    fn validate_rejects_git_fonte_with_rev_refname_value() {
14426        // The cross-axis mis-slot footgun: `:rev "main"` — the author
14427        // conflated `:rev` (hex commit ID, immutable) and `:branch`
14428        // (mutable ref pointing at whatever HEAD is today). Until this
14429        // gate landed the resolver silently dispatched on the value
14430        // shape ("`main` doesn't look like a SHA, fall back to
14431        // refname"), defeating the `:rev` reproducibility contract.
14432        // The new gate rejects every non-hex value on the `:rev` axis,
14433        // so the `:rev`/`:branch` boundary is structurally enforced —
14434        // a refname in the `:rev` slot is a build error, not a
14435        // resolver-time silent reinterpretation.
14436        let d = dep_with_fonte(DepSource::Git {
14437            repo: "github:pleme-io/caixa-teia".into(),
14438            tag: None,
14439            rev: Some("main".into()),
14440            branch: None,
14441        });
14442        let err = d.validate().unwrap_err();
14443        let DepError::FontePinShape {
14444            pin, value, reason, ..
14445        } = err
14446        else {
14447            panic!("expected FontePinShape, got other variant");
14448        };
14449        assert_eq!(pin, ":rev");
14450        assert_eq!(value, "main");
14451        // 4 chars `main` fails the length arm before the character arm,
14452        // so the diagnostic surfaces the abbreviation wording (same
14453        // path the `c0ffee0` 7-char fixture lands on); the structural
14454        // assertion is just that the `:rev "main"` value is rejected.
14455        assert!(
14456            !reason.is_empty(),
14457            "FontePinShape reason must be non-empty for refname-shaped :rev"
14458        );
14459    }
14460
14461    #[test]
14462    fn validate_rejects_git_fonte_with_rev_tag_shaped_value() {
14463        // Sibling cross-axis mis-slot: `:rev "v0.1.0"` — the author
14464        // conflated `:rev` and `:tag`. Pinned separately from the
14465        // `:rev "main"` (`:branch` mis-slot) arm so a future relaxation
14466        // that catches one but not the other surfaces here. The
14467        // length arm fires first (6 chars ≠ 40 ≠ 64); the structural
14468        // assertion is just that the cross-axis mis-slot is a build
14469        // error, regardless of which sub-arm surfaces the diagnostic
14470        // (`is_git_oid` rejects at the first violation; longer
14471        // tag-shape values would hit the non-hex arm instead).
14472        let d = dep_with_fonte(DepSource::Git {
14473            repo: "github:pleme-io/caixa-teia".into(),
14474            tag: None,
14475            rev: Some("v0.1.0".into()),
14476            branch: None,
14477        });
14478        let err = d.validate().unwrap_err();
14479        let DepError::FontePinShape {
14480            pin, value, reason, ..
14481        } = err
14482        else {
14483            panic!("expected FontePinShape, got other variant");
14484        };
14485        assert_eq!(pin, ":rev");
14486        assert_eq!(value, "v0.1.0");
14487        assert!(
14488            !reason.is_empty(),
14489            "FontePinShape reason must be non-empty for tag-shaped :rev"
14490        );
14491    }
14492
14493    #[test]
14494    fn validate_rejects_git_fonte_with_rev_too_long() {
14495        // Boundary case on the upper end: 41 hex chars — one past the
14496        // SHA-1 width, well below the SHA-256 width. Pin so a future
14497        // relaxation that admits "long enough to be a SHA" without
14498        // matching either canonical width surfaces here. The diagnostic
14499        // names the offending length verbatim so the author's grep
14500        // target is unambiguous (either trim one char or paste the
14501        // full SHA-256).
14502        let too_long: String = "0".repeat(41);
14503        let d = dep_with_fonte(DepSource::Git {
14504            repo: "github:pleme-io/caixa-teia".into(),
14505            tag: None,
14506            rev: Some(too_long.clone()),
14507            branch: None,
14508        });
14509        let err = d.validate().unwrap_err();
14510        let DepError::FontePinShape {
14511            pin, value, reason, ..
14512        } = err
14513        else {
14514            panic!("expected FontePinShape, got other variant");
14515        };
14516        assert_eq!(pin, ":rev");
14517        assert_eq!(value, too_long);
14518        assert!(
14519            reason.contains("41"),
14520            "reason must surface the offending length verbatim, got {reason:?}"
14521        );
14522    }
14523
14524    #[test]
14525    fn validate_rejects_git_fonte_with_rev_carrying_whitespace() {
14526        // The canonical paste-from-doc footgun on `:rev` — author
14527        // copies `"deadbeefcafe…0123 "` (trailing space) out of a
14528        // commit-message paragraph. Until this gate landed the empty-
14529        // pin arm passed (the string isn't empty), the resolver issued
14530        // `git fetch <remote> 'deadbeef… '` and the failure surfaced at
14531        // clone time with a quoting-confused git error far from the
14532        // source caixa.lisp. The new gate moves the check to caixa-
14533        // build time. Length is 41 (40 hex + space) so the length arm
14534        // fires first — pinned separately from the pure-length arm to
14535        // ensure the diagnostic surfaces *some* parser wording, not
14536        // silently pass through.
14537        let with_space = "0123456789abcdef0123456789abcdef01234567 ".to_string();
14538        let d = dep_with_fonte(DepSource::Git {
14539            repo: "github:pleme-io/caixa-teia".into(),
14540            tag: None,
14541            rev: Some(with_space.clone()),
14542            branch: None,
14543        });
14544        let err = d.validate().unwrap_err();
14545        let DepError::FontePinShape {
14546            pin, value, reason, ..
14547        } = err
14548        else {
14549            panic!("expected FontePinShape, got other variant");
14550        };
14551        assert_eq!(pin, ":rev");
14552        assert_eq!(value, with_space);
14553        assert!(
14554            !reason.is_empty(),
14555            "FontePinShape reason must be non-empty for whitespace-bearing :rev"
14556        );
14557    }
14558
14559    #[test]
14560    fn fonte_pin_shape_diagnostic_carries_offending_nome_pin_value_for_rev() {
14561        // Diagnostic-shape pin on the `:rev` axis: every FontePinShape
14562        // variant on this axis names the offending dep's `:nome` + the
14563        // `:rev` axis + the offending value verbatim, so the author's
14564        // grep target is the literal `:rev "<value>"` block in
14565        // caixa.lisp. Sibling of the `fonte_pin_shape_diagnostic_
14566        // carries_offending_nome_pin_value` test on the refname-shaped
14567        // (`:tag` / `:branch`) axes.
14568        let d = dep_with_fonte(DepSource::Git {
14569            repo: "github:p/x".into(),
14570            tag: None,
14571            rev: Some("not-a-sha".into()),
14572            branch: None,
14573        });
14574        let msg = d
14575            .validate()
14576            .expect_err(":rev: expected FontePinShape")
14577            .to_string();
14578        assert!(
14579            msg.contains("\"caixa-teia\""),
14580            ":rev: diagnostic must quote the offending :nome verbatim, got {msg:?}"
14581        );
14582        assert!(
14583            msg.contains(":rev"),
14584            ":rev: diagnostic must name the offending pin axis, got {msg:?}"
14585        );
14586        assert!(
14587            msg.contains("not-a-sha"),
14588            ":rev: diagnostic must quote the offending value verbatim, got {msg:?}"
14589        );
14590    }
14591
14592    #[test]
14593    fn fonte_pin_empty_fires_before_pin_shape() {
14594        // Order pin: a `Some("")` `:tag` is the more self-locating
14595        // diagnostic (the author chose an axis but left it blank;
14596        // grep is unambiguous), so it fires before the shape gate
14597        // even when both arms would match. Pinned so a future
14598        // reordering surfaces here. Mirrors the
14599        // `fonte_repo_empty_fires_before_pin_missing` ordering
14600        // discipline on the peer per-axis arms.
14601        let d = dep_with_fonte(DepSource::Git {
14602            repo: "github:pleme-io/caixa-teia".into(),
14603            tag: Some(String::new()),
14604            rev: None,
14605            branch: None,
14606        });
14607        assert!(matches!(
14608            d.validate().unwrap_err(),
14609            DepError::FontePinEmpty { ref pin, .. } if pin == ":tag"
14610        ));
14611    }
14612
14613    #[test]
14614    fn fonte_pin_shape_fires_after_repo_empty() {
14615        // Order pin: `:repo ""` is the more self-locating axis
14616        // (every git source needs a repo; the per-pin shape gate is
14617        // secondary), so the repo-empty arm fires before the
14618        // per-pin shape arm even when both are violated. Pinned so
14619        // a future reordering surfaces here. Mirrors
14620        // `fonte_repo_empty_fires_before_pin_missing` on the
14621        // adjacent axis pair.
14622        let d = dep_with_fonte(DepSource::Git {
14623            repo: String::new(),
14624            tag: Some("v0.1.0 ".into()),
14625            rev: None,
14626            branch: None,
14627        });
14628        assert!(matches!(
14629            d.validate().unwrap_err(),
14630            DepError::FonteRepoEmpty { .. }
14631        ));
14632    }
14633
14634    #[test]
14635    fn fonte_pin_shape_diagnostic_carries_offending_nome_pin_value() {
14636        // Diagnostic-shape pin across both refname-shaped axes
14637        // (`:tag` + `:branch`): every `FontePinShape` variant names
14638        // the offending dep's `:nome` + the offending pin axis + the
14639        // offending value verbatim, so the author's grep target is
14640        // unambiguous (the literal `:tag "<value>"` / `:branch
14641        // "<value>"` lands in caixa.lisp with quotes). Cover both
14642        // pin axes so a future variant addition forces a parallel
14643        // diagnostic-shape decision.
14644        for (pin_label, fonte) in [
14645            (
14646                ":tag",
14647                DepSource::Git {
14648                    repo: "github:p/x".into(),
14649                    tag: Some("v0.1.0~1".into()),
14650                    rev: None,
14651                    branch: None,
14652                },
14653            ),
14654            (
14655                ":branch",
14656                DepSource::Git {
14657                    repo: "github:p/x".into(),
14658                    tag: None,
14659                    rev: None,
14660                    branch: Some("feature/foo*".into()),
14661                },
14662            ),
14663        ] {
14664            let d = dep_with_fonte(fonte);
14665            let msg = d
14666                .validate()
14667                .expect_err(&format!("{pin_label}: expected FontePinShape"))
14668                .to_string();
14669            assert!(
14670                msg.contains("\"caixa-teia\""),
14671                "{pin_label}: diagnostic must quote the offending :nome verbatim, got {msg:?}"
14672            );
14673            assert!(
14674                msg.contains(pin_label),
14675                "{pin_label}: diagnostic must name the offending pin axis, got {msg:?}"
14676            );
14677        }
14678    }
14679
14680    #[test]
14681    fn git_source_json_round_trip() {
14682        let src = DepSource::Git {
14683            repo: "github:pleme-io/caixa-teia".into(),
14684            tag: Some("v0.1.0".into()),
14685            rev: None,
14686            branch: None,
14687        };
14688        let s = serde_json::to_string(&src).unwrap();
14689        assert!(s.contains(&format!(
14690            r#""{tipo}":"{git}""#,
14691            tipo = crate::render::DEP_SOURCE_KEY_TIPO,
14692            git = crate::render::DEP_SOURCE_TIPO_GIT,
14693        )));
14694        assert!(s.contains(r#""repo":"github:pleme-io/caixa-teia""#));
14695        assert!(s.contains(r#""tag":"v0.1.0""#));
14696        assert!(!s.contains("rev"));
14697        assert!(!s.contains("branch"));
14698        let round: DepSource = serde_json::from_str(&s).unwrap();
14699        assert_eq!(round, src);
14700    }
14701
14702    // ── DEP_SOURCE_{KEY_TIPO,TIPO_GIT,TIPO_PATH} drift-detection ────────
14703    //
14704    // The `#[serde(tag = "tipo", rename_all = "lowercase")]` derive
14705    // attribute on [`DepSource`] pins three load-bearing byte-sequences
14706    // that flow into every serialized `Dep.fonte` block: the outer
14707    // discriminator-key `"tipo"` the `tag = "tipo"` attribute names, and
14708    // the two admitted variant-tag values `"git"` / `"path"` the
14709    // `rename_all = "lowercase"` attribute pins as the discriminator's
14710    // closed-set arms. The three pin tests below round-trip a
14711    // fully-populated variant of each arm through
14712    // [`serde_json::to_value`] and assert each canonical byte-sequence
14713    // appears at its axis — pins a hypothetical future
14714    // `tag = "type"` / `tag = "source_type"` typo, a `rename_all`
14715    // rebrand (`"UPPERCASE"` / `"snake_case"` / `"kebab-case"`), or a
14716    // Rust-side variant rename (`Git` → `Repository`, `Path` → `Local`)
14717    // at build time rather than at fetch time when the resolver's
14718    // `Dep.fonte` dispatch silently fails to match on the drifted
14719    // discriminator. Same "serialize-and-check" discipline the peer
14720    // `M2_LIMITS_KEY_*`, `M2_BEHAVIOR_KEY_ON_*`, `SUPERVISOR_KEY_*`,
14721    // and `MEMBRO_KEY_*` drift-detection pins carry — extended here
14722    // to the last `#[serde(tag = ..., rename_all = ...)]` discriminator
14723    // family in caixa-core lacking a lifted peer.
14724
14725    #[test]
14726    fn dep_source_git_serde_keys_match_lifted_dep_source_key_consts() {
14727        // Fail-before-pass-after: a future `tag = "type"` at the derive
14728        // attribute would serialize under `"type":"git"`, and this test
14729        // would trip because `"tipo"` no longer appears at the emitted
14730        // discriminator key. A future `rename_all = "kebab-case"` /
14731        // `"snake_case"` (both no-ops on `Git` since it lacks internal
14732        // word boundaries) is caught by the sibling
14733        // `dep_source_path_serde_keys_match_lifted_dep_source_key_consts`
14734        // pin below (Path has no internal boundary either but the pair
14735        // catches any per-arm inconsistency). A future variant rename
14736        // `Git` → `Repository` would emit `"tipo":"repository"` and
14737        // trip this pin.
14738        let src = DepSource::Git {
14739            repo: "github:pleme-io/caixa-teia".into(),
14740            tag: Some("v0.1.0".into()),
14741            rev: None,
14742            branch: None,
14743        };
14744        let json = serde_json::to_value(&src).unwrap();
14745        let obj = json.as_object().expect("Git serializes as a JSON object");
14746        assert_eq!(
14747            obj.get(crate::render::DEP_SOURCE_KEY_TIPO)
14748                .and_then(serde_json::Value::as_str),
14749            Some(crate::render::DEP_SOURCE_TIPO_GIT),
14750            "DepSource::Git must serialize the tipo discriminator at DEP_SOURCE_KEY_TIPO \
14751             with value DEP_SOURCE_TIPO_GIT — attribute drift or variant rename \
14752             detected in {json}"
14753        );
14754    }
14755
14756    #[test]
14757    fn dep_source_path_serde_keys_match_lifted_dep_source_key_consts() {
14758        // Fail-before-pass-after: a future variant rename `Path` →
14759        // `Local` / `Filesystem` would emit `"tipo":"local"` and trip
14760        // this pin. A per-consumer disambiguation as the `defcaixa`
14761        // macro stabilizes ("caminho" → "path" for English-uniformity)
14762        // is scoped to the inner field key, not the discriminator; this
14763        // pin is orthogonal to that and catches only the outer
14764        // discriminator drift.
14765        let src = DepSource::Path {
14766            caminho: "../caixa-teia".into(),
14767        };
14768        let json = serde_json::to_value(&src).unwrap();
14769        let obj = json.as_object().expect("Path serializes as a JSON object");
14770        assert_eq!(
14771            obj.get(crate::render::DEP_SOURCE_KEY_TIPO)
14772                .and_then(serde_json::Value::as_str),
14773            Some(crate::render::DEP_SOURCE_TIPO_PATH),
14774            "DepSource::Path must serialize the tipo discriminator at DEP_SOURCE_KEY_TIPO \
14775             with value DEP_SOURCE_TIPO_PATH — attribute drift or variant rename \
14776             detected in {json}"
14777        );
14778    }
14779
14780    #[test]
14781    fn dep_source_key_consts_are_pairwise_distinct() {
14782        // Cross-axis collapse detector: a hypothetical future edit that
14783        // accidentally set two of the three consts to the same byte
14784        // (`DEP_SOURCE_TIPO_GIT = "path"` typo matching a peer arm) would
14785        // pass every per-arm serialize pin above but silently collapse
14786        // the discriminator's closed-set arms onto one another; this pin
14787        // catches the collapse at build time.
14788        assert_ne!(
14789            crate::render::DEP_SOURCE_KEY_TIPO,
14790            crate::render::DEP_SOURCE_TIPO_GIT,
14791        );
14792        assert_ne!(
14793            crate::render::DEP_SOURCE_KEY_TIPO,
14794            crate::render::DEP_SOURCE_TIPO_PATH,
14795        );
14796        assert_ne!(
14797            crate::render::DEP_SOURCE_TIPO_GIT,
14798            crate::render::DEP_SOURCE_TIPO_PATH,
14799        );
14800    }
14801
14802    #[test]
14803    fn dep_source_tipo_variant_consts_are_ascii_lowercase_shape() {
14804        // Shape pin against `rename_all` drift: the two variant-tag
14805        // consts must be ASCII-lowercase-only to match the
14806        // `rename_all = "lowercase"` attribute the derive uses; a future
14807        // rebrand to `"UPPERCASE"` / `"PascalCase"` at the attribute
14808        // would emit `"GIT"` / `"Git"` instead and trip this pin.
14809        for (label, s) in [
14810            ("DEP_SOURCE_TIPO_GIT", crate::render::DEP_SOURCE_TIPO_GIT),
14811            ("DEP_SOURCE_TIPO_PATH", crate::render::DEP_SOURCE_TIPO_PATH),
14812        ] {
14813            assert!(!s.is_empty(), "{label} must not be empty");
14814            assert!(
14815                s.bytes().all(|b| b.is_ascii_lowercase()),
14816                "{label} must be ASCII-lowercase-only (matching \
14817                 rename_all = \"lowercase\"), got {s:?}",
14818            );
14819        }
14820    }
14821
14822    // ── per-entry :caracteristicas set-not-multiset gate ────────────
14823    //
14824    // Every Vec-keyed-by-name authoring surface on the typed Caixa
14825    // surface that identifies its entries by a name field now uniformly
14826    // closes the set-not-multiset discipline at build time (cite
14827    // `validate_caracteristicas`'s peer-axis enumeration). The
14828    // `:caracteristicas` axis is per-`Dep`: the feature-toggle slot is
14829    // set-shaped (a feature is either enabled or not — there is no
14830    // `feature × 2` semantic), so two entries naming the same feature
14831    // are a redundant declaration the caixa-resolver's lacre pipeline
14832    // would silently dedup at resolve time. The empty-feature arm
14833    // closes the parallel "operationally-meaningless value" axis on
14834    // the same slot. Same linear-walk + `HashSet` + first-collision
14835    // shape every peer set gate uses; same empty-first cascade every
14836    // peer per-entry shape + duplicate gate uses (the empty-feature
14837    // axis is the more-actionable defect since two `""` entries would
14838    // both report `caracteristica: ""` under a duplicate-first
14839    // ordering, with no way to distinguish the offending site).
14840
14841    fn dep_with_features(features: &[&str]) -> Dep {
14842        Dep {
14843            nome: "caixa-teia".into(),
14844            versao: "^0.1".into(),
14845            fonte: None,
14846            opcional: false,
14847            caracteristicas: features.iter().map(|s| (*s).into()).collect(),
14848        }
14849    }
14850
14851    #[test]
14852    fn validate_rejects_empty_caracteristica() {
14853        // Fail-before-pass-after pin: every pre-gate codebase accepted
14854        // `(:caracteristicas (""))` cleanly (the `Vec<String>` field
14855        // imposed no per-entry shape contract), the dep validated, and
14856        // the empty feature would have reached the future caixa-resolver
14857        // lacre pipeline as a no-op feature enable — silently dropping
14858        // the author's intent far from the source `caixa.lisp`. The new
14859        // gate surfaces the structural defect at the typed-validate
14860        // surface with a self-locating diagnostic naming the offending
14861        // dep's `:nome`.
14862        let d = dep_with_features(&[""]);
14863        assert!(
14864            matches!(d.validate().unwrap_err(), DepError::CaracteristicaEmpty { ref nome } if nome == "caixa-teia"),
14865            "expected CaracteristicaEmpty, got {:?}",
14866            d.validate(),
14867        );
14868    }
14869
14870    #[test]
14871    fn validate_rejects_duplicate_caracteristica() {
14872        // Fail-before-pass-after pin on the set-not-multiset arm: the
14873        // feature-toggle slot is set-shaped, so `(:caracteristicas
14874        // ("http" "http"))` is a redundant declaration the lacre
14875        // pipeline dedupes silently at resolve time. The diagnostic
14876        // names the offending dep + the colliding feature verbatim so
14877        // the author can grep their caixa.lisp for `:caracteristicas`
14878        // and fix it in one edit. First-collision determinism is
14879        // pinned separately below.
14880        let d = dep_with_features(&["http", "http"]);
14881        assert!(
14882            matches!(
14883                d.validate().unwrap_err(),
14884                DepError::CaracteristicaDuplicate { ref nome, ref caracteristica }
14885                    if nome == "caixa-teia" && caracteristica == "http"
14886            ),
14887            "expected CaracteristicaDuplicate, got {:?}",
14888            d.validate(),
14889        );
14890    }
14891
14892    #[test]
14893    fn validate_accepts_distinct_caracteristicas() {
14894        // The canonical authoring shape — every feature distinct — must
14895        // remain a clean pass (positive control sweep). Covers the
14896        // canonical kebab-case feature names a target caixa typically
14897        // declares.
14898        dep_with_features(&["http", "json", "tls"])
14899            .validate()
14900            .unwrap();
14901    }
14902
14903    #[test]
14904    fn validate_accepts_single_caracteristica() {
14905        // Single-element list is the minimum non-empty shape; passes
14906        // the gate as the identity of the duplicate check (no second
14907        // entry to collide with).
14908        dep_with_features(&["http"]).validate().unwrap();
14909    }
14910
14911    #[test]
14912    fn validate_accepts_empty_caracteristicas_list() {
14913        // The bare-dep authoring shape (`Dep::simple` / `Dep::git`)
14914        // produces `caracteristicas: Vec::new()`; the empty list is
14915        // the gate's empty-set identity and passes vacuously. Pin
14916        // this so a future tightening that requires ≥1 feature
14917        // surfaces here as a test failure rather than a silent
14918        // contract narrowing.
14919        Dep::simple("caixa-teia", "^0.1").validate().unwrap();
14920        assert!(dep_with_features(&[]).validate().is_ok());
14921    }
14922
14923    #[test]
14924    fn validate_caracteristica_empty_fires_before_duplicate() {
14925        // Empty-first cascade: an entry with an empty feature *and*
14926        // duplicate entries surfaces the empty diagnostic first. The
14927        // empty-feature axis is the more-actionable defect since
14928        // `caracteristica: ""` is unambiguous; under duplicate-first
14929        // ordering the diagnostic could report the empty string from
14930        // either of two empty entries with no way to distinguish.
14931        // Mirrors the peer empty-before-duplicate ordering
14932        // discipline every per-entry shape + duplicate gate establishes
14933        // (`SupervisorSpec::validate`'s `EmptyChildName` arm before
14934        // `DuplicateChildCaixa`, `validate_membros`'s
14935        // `MembroCaixaEmpty` arm before `MembroDuplicate`).
14936        let d = dep_with_features(&["", "http", "http"]);
14937        assert!(matches!(
14938            d.validate().unwrap_err(),
14939            DepError::CaracteristicaEmpty { .. }
14940        ));
14941    }
14942
14943    #[test]
14944    fn validate_caracteristica_duplicate_first_collision_determinism() {
14945        // Three matching entries: the second occurrence surfaces the
14946        // diagnostic (the second is the first *collision* — the first
14947        // entry is the establishing one, not a duplicate). Mirrors
14948        // every peer first-collision posture
14949        // (`SupervisorError::DuplicateChildCaixa` reports the second
14950        // collision, `AplicacaoError::MembroDuplicate` reports the
14951        // second, `DepError::DuplicateNome` reports the second).
14952        // Pinning this so a future shortcut that flips to last-
14953        // collision (or non-deterministic) surfaces here.
14954        let d = dep_with_features(&["http", "http", "http"]);
14955        assert!(matches!(
14956            d.validate().unwrap_err(),
14957            DepError::CaracteristicaDuplicate { ref caracteristica, .. } if caracteristica == "http"
14958        ));
14959    }
14960
14961    #[test]
14962    fn validate_per_entry_shape_fires_before_caracteristicas() {
14963        // Per-entry shape precedence: a dep with a malformed `:nome`
14964        // (uppercase) AND duplicate `:caracteristicas` surfaces the
14965        // narrower `NomeInvalid` diagnostic first, not the set-gate
14966        // diagnostic. The `:nome` is the self-locating axis (every
14967        // diagnostic from the caracteristicas gate quotes the
14968        // offending dep's `:nome` to anchor the grep target —
14969        // surfacing the malformed name first keeps that anchor
14970        // valid). Same precedence shape every peer per-entry-shape
14971        // arm establishes against its peer set-gate
14972        // (`validate_deps_per_entry_validate_fires_before_duplicate_in_deps`
14973        // on the cross-entry `:nome` axis).
14974        let d = Dep {
14975            nome: "Caixa-Teia".into(), // uppercase — DNS-1123 violation
14976            versao: "^0.1".into(),
14977            fonte: None,
14978            opcional: false,
14979            caracteristicas: vec!["http".into(), "http".into()],
14980        };
14981        assert!(matches!(
14982            d.validate().unwrap_err(),
14983            DepError::NomeInvalid { .. }
14984        ));
14985    }
14986
14987    // ── per-entry :caracteristicas value-shape gate ──────────────────
14988    //
14989    // Until this gate landed `:caracteristicas` only refused the empty
14990    // string and cross-entry duplicates: a non-empty distinct but
14991    // structurally invalid feature name silently passed validate and the
14992    // failure surfaced at `cargo metadata` time as Cargo's
14993    // `restricted_names::validate_feature_name` parser rejection, far from
14994    // the source `caixa.lisp` with no field naming which `:deps` entry's
14995    // `:caracteristicas` carried the typo. The lifted predicate makes the
14996    // Cargo-feature-name-grammar intersection-floor a substrate-level
14997    // invariant at validate time. Same trajectory as the eight peer
14998    // value-shape predicates each typed surface downstream of a structured
14999    // grammar already follows.
15000
15001    #[test]
15002    fn validate_rejects_caracteristica_with_leading_plus() {
15003        // Fail-before-pass-after pin on the canonical Cargo
15004        // `+<feature>` activation-form-in-feature-name-slot footgun.
15005        // Cargo's `[dependencies.<dep>.features]` list grammar accepts
15006        // `+optional-feature` as an enablement of a previously-disabled
15007        // feature; pasting that activation form into `:caracteristicas`
15008        // (which names the feature itself) silently passed pre-gate and
15009        // failed at `cargo metadata` parse time.
15010        let d = dep_with_features(&["+http"]);
15011        let err = d.validate().unwrap_err();
15012        assert!(
15013            matches!(
15014                err,
15015                DepError::CaracteristicaInvalid { ref nome, ref caracteristica, .. }
15016                    if nome == "caixa-teia" && caracteristica == "+http"
15017            ),
15018            "expected CaracteristicaInvalid, got {err:?}"
15019        );
15020    }
15021
15022    #[test]
15023    fn validate_rejects_caracteristica_with_leading_hyphen() {
15024        // Fail-before-pass-after pin on the leading-hyphen footgun. `-`
15025        // is a legitimate continuation character (kebab-case feature
15026        // names like `runtime-tokio` pass) but Cargo rejects it at the
15027        // start; the structural defect — and its CLI-argument-injection
15028        // adjacency at any downstream Cargo subprocess invocation — is
15029        // closed at validate time, not at `cargo metadata` time.
15030        let d = dep_with_features(&["-json"]);
15031        let err = d.validate().unwrap_err();
15032        assert!(
15033            matches!(
15034                err,
15035                DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "-json"
15036            ),
15037            "expected CaracteristicaInvalid, got {err:?}"
15038        );
15039    }
15040
15041    #[test]
15042    fn validate_rejects_caracteristica_with_leading_dot() {
15043        // Fail-before-pass-after pin on the leading-dot footgun. `.` is
15044        // a legitimate continuation character (version-suffix shapes
15045        // like `feat.v2` pass) but the leading-dot form is the
15046        // canonical dotted-version-suffix-as-feature-name confusion.
15047        let d = dep_with_features(&[".feat"]);
15048        let err = d.validate().unwrap_err();
15049        assert!(matches!(
15050            err,
15051            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == ".feat"
15052        ));
15053    }
15054
15055    #[test]
15056    fn validate_rejects_caracteristica_with_whitespace() {
15057        // Fail-before-pass-after pin on the embedded-whitespace footgun:
15058        // a feature name with a space inside is structurally a multi-
15059        // token blob (the canonical paste-from-doc footgun, or an
15060        // accidental `"http server"` where the author meant
15061        // `"http-server"`).
15062        let d = dep_with_features(&["http feature"]);
15063        let err = d.validate().unwrap_err();
15064        assert!(matches!(
15065            err,
15066            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http feature"
15067        ));
15068    }
15069
15070    #[test]
15071    fn validate_rejects_caracteristica_with_comma() {
15072        // Fail-before-pass-after pin on the embedded-comma footgun:
15073        // the list-separator-belongs-to-the-list-grammar
15074        // miscomprehension where the author writes
15075        // `:caracteristicas ("http,json")` intending two features but
15076        // the `Vec<String>` field consumes the bare token as one entry.
15077        let d = dep_with_features(&["http,json"]);
15078        let err = d.validate().unwrap_err();
15079        assert!(matches!(
15080            err,
15081            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http,json"
15082        ));
15083    }
15084
15085    #[test]
15086    fn validate_rejects_caracteristica_with_slash() {
15087        // Fail-before-pass-after pin on the embedded-slash footgun:
15088        // Cargo's `dep/feat` namespaced-dep syntax applies inside
15089        // `[dependencies.<dep>.features]` list entries that already
15090        // name the parent dep (so the syntax says "enable feature
15091        // `feat` on a transitive dep `dep`"); `:caracteristicas` is
15092        // per-dep already (a sibling slot on the `Dep` itself), so the
15093        // segment separator within an entry must be `-`, `_`, `+`,
15094        // or `.`. The diagnostic remediation points at the canonical
15095        // Cargo namespaced-dep discipline.
15096        let d = dep_with_features(&["http/json"]);
15097        let err = d.validate().unwrap_err();
15098        assert!(matches!(
15099            err,
15100            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http/json"
15101        ));
15102    }
15103
15104    #[test]
15105    fn validate_rejects_caracteristica_with_non_ascii() {
15106        // Fail-before-pass-after pin on the un-percent-encoded non-ASCII
15107        // byte footgun: NFC-vs-NFD normalization across filesystems
15108        // silently rewrites the feature-key, breaking the lacre's
15109        // content-addressing invariant. Pinned at a canonical
15110        // smart-quote-paste shape (`café`) where the raw `é` byte is the
15111        // documented APFS round-trip break.
15112        let d = dep_with_features(&["caf\u{e9}"]);
15113        let err = d.validate().unwrap_err();
15114        assert!(matches!(
15115            err,
15116            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "caf\u{e9}"
15117        ));
15118    }
15119
15120    #[test]
15121    fn validate_rejects_caracteristica_with_control_character() {
15122        // Fail-before-pass-after pin on the embedded-control-character
15123        // footgun: a CR/LF or any 0x00..0x1F / 0x7F byte landing in a
15124        // feature name is the canonical paste-from-multiline-doc
15125        // footgun the predicate's reason wording specifically calls out.
15126        let d = dep_with_features(&["http\njson"]);
15127        let err = d.validate().unwrap_err();
15128        assert!(matches!(err, DepError::CaracteristicaInvalid { .. }));
15129    }
15130
15131    #[test]
15132    fn validate_accepts_canonical_caracteristicas_shapes() {
15133        // Positive control sweep: every canonical Cargo feature name
15134        // shape the pleme-io ecosystem uses must still pass. Mirrors
15135        // the substrate-side `cargo_feature_name_accepts_canonical_forms`
15136        // sweep — drift between either landing site and the predicate's
15137        // accepted set is a build error visible at this pair of tests,
15138        // not a per-renderer "this passed validate but failed at
15139        // cargo metadata time" surprise on the next acceptance.
15140        for s in [
15141            "http",
15142            "json",
15143            "derive",
15144            "serde_json",
15145            "runtime-tokio",
15146            "tokio.full",
15147            "v0.1",
15148            "http+json",
15149            "_internal",
15150            "__private",
15151            "default",
15152            "rt-multi-thread",
15153            "feat.v2",
15154        ] {
15155            let d = dep_with_features(&[s]);
15156            d.validate().unwrap_or_else(|e| {
15157                panic!("canonical Cargo feature name {s:?} must pass validate: {e:?}")
15158            });
15159        }
15160    }
15161
15162    #[test]
15163    fn validate_caracteristica_empty_fires_before_invalid() {
15164        // Cascade precedence pin: an entry list with both an empty
15165        // feature AND an invalid-shape feature surfaces the
15166        // `CaracteristicaEmpty` arm first (the empty value carries no
15167        // self-locating data — `caracteristica: ""` is the diagnostic
15168        // with no way to anchor a grep target — so closing the empty
15169        // axis first preserves the per-entry-shape diagnostic's
15170        // self-locating discipline). Same empty-first cascade every
15171        // peer per-entry shape gate establishes
15172        // (`SupervisorSpec::validate`'s `EmptyChildName` before
15173        // `ChildCaixaInvalid`, `validate_membros`'s `MembroCaixaEmpty`
15174        // before `MembroCaixaInvalid`).
15175        let d = dep_with_features(&["", "+http"]);
15176        assert!(matches!(
15177            d.validate().unwrap_err(),
15178            DepError::CaracteristicaEmpty { .. }
15179        ));
15180    }
15181
15182    #[test]
15183    fn validate_caracteristica_invalid_fires_before_duplicate() {
15184        // Per-entry-shape precedence pin: an entry list with the same
15185        // invalid feature shape declared twice surfaces the
15186        // `CaracteristicaInvalid` diagnostic on the first entry, not
15187        // the `CaracteristicaDuplicate` on the second collision. The
15188        // per-entry shape gate fires before the cross-entry set gate
15189        // — same precedence shape every peer two-arm-plus-set gate
15190        // establishes (`SupervisorSpec::validate`'s
15191        // `ChildCaixaInvalid` before `DuplicateChildCaixa`,
15192        // `validate_membros`'s `MembroCaixaInvalid` before
15193        // `MembroDuplicate`, `Dep::validate`'s `NomeInvalid` before
15194        // cross-list `DuplicateNome`).
15195        let d = dep_with_features(&["+http", "+http"]);
15196        assert!(matches!(
15197            d.validate().unwrap_err(),
15198            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "+http"
15199        ));
15200    }
15201
15202    #[test]
15203    fn validate_rejects_caracteristica_at_65_byte_boundary() {
15204        // Boundary pin on the 64-byte cap — both the boundary-accepting
15205        // case and the boundary-exceeding case in one place, so a
15206        // future cap shift surfaces both arms simultaneously, mirroring
15207        // the peer `cargo_feature_name_rejects_at_65_byte_boundary`
15208        // predicate-level pin at the dep-axis landing site.
15209        let max_ok = "a".repeat(64);
15210        dep_with_features(&[&max_ok])
15211            .validate()
15212            .unwrap_or_else(|e| panic!("64-byte feature name must pass: {e:?}"));
15213        let too_long = "a".repeat(65);
15214        let d = dep_with_features(&[&too_long]);
15215        assert!(matches!(
15216            d.validate().unwrap_err(),
15217            DepError::CaracteristicaInvalid { .. }
15218        ));
15219    }
15220
15221    // ── self-dep cross-slot gate ─────────────────────────────────────
15222
15223    #[test]
15224    fn validate_no_self_dep_rejects_self_in_deps() {
15225        // A caixa whose `:deps` lists its own `:nome` is a one-node
15226        // cycle in the lacre closure's dep-graph traversal — rejected,
15227        // naming the parent and the offending list tag.
15228        let deps = vec![
15229            Dep::simple("caixa-teia", "^0.1"),
15230            Dep::simple("orquestra", "^0.1"),
15231        ];
15232        let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
15233        assert!(
15234            matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS),
15235            "got {err:?}"
15236        );
15237    }
15238
15239    #[test]
15240    fn validate_no_self_dep_rejects_self_in_deps_dev() {
15241        // Same gate on the `:deps-dev` axis — neither dep list is a
15242        // second-class citizen on the self-edge invariant.
15243        let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
15244        let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
15245        assert!(
15246            matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
15247            "got {err:?}"
15248        );
15249    }
15250
15251    #[test]
15252    fn validate_no_self_dep_deps_fires_before_deps_dev() {
15253        // Walk order pin: a caixa that self-references on both lists
15254        // surfaces the `:deps` arm first — the load-bearing axis the
15255        // lacre closure resolves at every build. Mirrors the canonical
15256        // [`Caixa::validate_deps`] cascade (`:deps` → `:deps-dev`).
15257        let deps = vec![Dep::simple("orquestra", "^0.1")];
15258        let deps_dev = vec![Dep::simple("orquestra", "^0.2")];
15259        let err = validate_no_self_dep(&deps, &deps_dev, "orquestra").unwrap_err();
15260        assert!(
15261            matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS),
15262            "got {err:?}"
15263        );
15264    }
15265
15266    #[test]
15267    fn validate_no_self_dep_accepts_distinct_names() {
15268        // Positive control: every dep names a distinct caixa. The
15269        // canonical author surface — peer of
15270        // [`validate_no_self_supervision_accepts_distinct_children`].
15271        let deps = vec![
15272            Dep::simple("caixa-teia", "^0.1"),
15273            Dep::simple("caixa-arch", "^0.1"),
15274        ];
15275        let deps_dev = vec![Dep::simple("caixa-test", "^0.1")];
15276        validate_no_self_dep(&deps, &deps_dev, "orquestra").unwrap();
15277    }
15278
15279    #[test]
15280    fn validate_no_self_dep_empty_lists_pass() {
15281        // A caixa with no declared deps has nothing to self-reference —
15282        // the gate is vacuously satisfied. Peer of
15283        // [`validate_no_self_supervision_empty_children_is_ok`].
15284        validate_no_self_dep(&[], &[], "orquestra").unwrap();
15285    }
15286
15287    #[test]
15288    fn validate_no_self_dep_diagnostic_carries_offending_list_and_nome() {
15289        // Diagnostic-shape pin (peer with
15290        // [`validate_no_self_supervision`]'s diagnostic): the error's
15291        // Display surfaces both the offending list tag and the
15292        // parent's `:nome` verbatim, so the author can grep their
15293        // caixa.lisp for the offending block in one edit. Names
15294        // `:bibliotecas` / `:exe` / `:servicos` as the corrective
15295        // surface — every legitimate "I want to use code from this
15296        // caixa" intent routes through one of those three slots.
15297        let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
15298        let rendered = validate_no_self_dep(&[], &deps_dev, "orquestra")
15299            .unwrap_err()
15300            .to_string();
15301        assert!(
15302            rendered.contains(crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
15303            "diagnostic must name the offending list tag: {rendered}",
15304        );
15305        assert!(
15306            rendered.contains("orquestra"),
15307            "diagnostic must quote the parent caixa name: {rendered}",
15308        );
15309        assert!(
15310            rendered.contains(":bibliotecas"),
15311            "diagnostic must point at the corrective code-surface slot: {rendered}",
15312        );
15313    }
15314
15315    #[test]
15316    fn validate_no_self_dep_accepts_coincidental_substring_match() {
15317        // Identity is exact-string equality, not substring — a dep
15318        // named `"orquestra-helper"` is a distinct caixa even when the
15319        // parent is `"orquestra"`. Pin the exact-match discipline so a
15320        // future relaxation that uses `contains` surfaces here, peer
15321        // with the supervision-tree and Aplicacao-membership gates
15322        // which all use exact-string equality on the typed identity.
15323        let deps = vec![Dep::simple("orquestra-helper", "^0.1")];
15324        validate_no_self_dep(&deps, &[], "orquestra").unwrap();
15325    }
15326
15327    // ── drift-detection: DEP_AUTHOR_KEY_{DEPS,DEPS_DEV} pin ─────────────
15328
15329    #[test]
15330    fn dep_author_key_consts_pin_canonical_kebab_case_labels() {
15331        // Scalar-value pin: the two author-facing kebab-case labels the
15332        // `(defcaixa … :deps ((…)) :deps-dev ((…)))` surface admits on
15333        // the two-list dep-graph slot axis, one arm per typed slot.
15334        // Mirrors the peer scalar-value pin the sibling
15335        // [`crate::M2_AUTHOR_KEY_LIMITS`] /
15336        // [`crate::M2_AUTHOR_KEY_BEHAVIOR`] /
15337        // [`crate::M2_AUTHOR_KEY_UPGRADE_FROM`] (f49c8b0) M2 top-level
15338        // author-labels, [`crate::M3_AUTHOR_KEY_MEMBROS`] etc.
15339        // (882f498) M3 top-level author-labels, and
15340        // [`crate::SUPERVISOR_AUTHOR_KEY_ESTRATEGIA`] etc. (be40492)
15341        // Supervisor top-level author-labels carry, so every kind-scoped
15342        // typed-slot-family axis routes through one canonical per-arm
15343        // declaration.
15344        //
15345        // A future rebrand (`:deps` → `:dependencies` matching Cargo's
15346        // verbatim key, `:deps-dev` → `:dev-dependencies` matching the
15347        // same, `:deps` / `:deps-dev` → `:runtime-deps` / `:dev-deps`
15348        // for symmetry) lands as an edit to exactly one const, and
15349        // every consumer that reaches for the label picks it up at
15350        // build time rather than at runtime as a downstream mismatch on
15351        // a `DepError::DuplicateNome { list: … }` diagnostic far from
15352        // the rename's commit.
15353        assert_eq!(crate::render::DEP_AUTHOR_KEY_DEPS, ":deps");
15354        assert_eq!(crate::render::DEP_AUTHOR_KEY_DEPS_DEV, ":deps-dev");
15355    }
15356
15357    #[test]
15358    fn dep_author_key_consts_are_pairwise_distinct() {
15359        // Distinct-labels pin: the two `:deps` / `:deps-dev` labels
15360        // must not collapse onto one byte-string. A future copy-paste
15361        // slip that renamed both consts to the same value (or a rebrand
15362        // that dropped the `-dev` suffix from one but not the other)
15363        // would leave every `DepError::DuplicateNome { list: … }`
15364        // diagnostic naming an unattributable list — the linter would
15365        // route the author to the wrong caixa.lisp block, or the
15366        // cross-list precedence gate
15367        // (`validate_deps_duplicate_in_deps_fires_before_duplicate_in_deps_dev`)
15368        // would surface a `:deps`-tagged diagnostic on a `:deps-dev`
15369        // duplicate. Peer of the sibling
15370        // `m2_author_key_consts_are_pairwise_distinct`-shape gates the
15371        // other top-level kind-scoped slot-family axes carry
15372        // (implicitly held by their different byte-values today).
15373        assert_ne!(
15374            crate::render::DEP_AUTHOR_KEY_DEPS,
15375            crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
15376            "DEP_AUTHOR_KEY_{{DEPS,DEPS_DEV}} consts must be pairwise-distinct \
15377             so a `DepError::DuplicateNome {{ list: … }}` diagnostic \
15378             self-locates the offending block in the author's caixa.lisp",
15379        );
15380    }
15381
15382    #[test]
15383    fn validate_no_self_dep_routes_through_lifted_dep_author_key_consts() {
15384        // Production-through-const pin: the two per-arm list tags
15385        // [`validate_no_self_dep`] threads onto the `list:` field of a
15386        // returned [`DepError::DepIsSelf`] route through the lifted
15387        // [`crate::DEP_AUTHOR_KEY_DEPS`] /
15388        // [`crate::DEP_AUTHOR_KEY_DEPS_DEV`] consts. A future drift at
15389        // the walker (a rename that reaches one arm but not the const,
15390        // or vice versa) surfaces here at build time rather than at
15391        // runtime as a `feira lint` diagnostic naming the wrong list
15392        // tag. Mirror of the peer
15393        // [`crate::Caixa::declared_servico_slots`] production tagger
15394        // pin (f49c8b0) on the sibling M2 top-level slot axis, extended
15395        // onto the two-list dep-graph gate.
15396        let deps = vec![Dep::simple("orquestra", "^0.1")];
15397        let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
15398        let DepError::DepIsSelf { list, .. } = err else {
15399            panic!("expected DepIsSelf from :deps walk");
15400        };
15401        assert_eq!(list, crate::render::DEP_AUTHOR_KEY_DEPS);
15402
15403        let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
15404        let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
15405        let DepError::DepIsSelf { list, .. } = err else {
15406            panic!("expected DepIsSelf from :deps-dev walk");
15407        };
15408        assert_eq!(list, crate::render::DEP_AUTHOR_KEY_DEPS_DEV);
15409    }
15410
15411    // ── Dep::nome accessor pins ───────────────────────────────────────
15412    //
15413    // Three coherence pins on the lifted `Dep::nome` accessor: byte-equal
15414    // projection over the plain-shorthand / explicit-git / explicit-path
15415    // fixture triad the [`Dep`] docstring lists (so the accessor's
15416    // accept-set is exercised across every author-surface `:fonte`
15417    // shape); by-borrow pointer identity so the projection stays
15418    // zero-copy at every consumer site; and validate-composition through
15419    // the [`validate_no_self_dep`] cross-slot gate reading its
15420    // parent-name equality check through the lifted accessor rather than
15421    // the raw field.
15422
15423    #[test]
15424    fn dep_nome_returns_declared_nome_across_fonte_shapes() {
15425        // Plain-shorthand form (`:fonte None`).
15426        assert_eq!(Dep::simple("caixa-teia", "^0.1").nome(), "caixa-teia");
15427        // Explicit git-source form with a tag pin — same accessor path.
15428        assert_eq!(
15429            Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0").nome(),
15430            "caixa-teia",
15431        );
15432        // Explicit path-source form.
15433        assert_eq!(
15434            Dep {
15435                nome: "caixa-teia".to_string(),
15436                versao: "0.1.0".to_string(),
15437                fonte: Some(DepSource::Path {
15438                    caminho: "../caixa-teia".to_string(),
15439                }),
15440                opcional: false,
15441                caracteristicas: Vec::new(),
15442            }
15443            .nome(),
15444            "caixa-teia",
15445        );
15446        // The empty-string `:nome` sentinel (which [`Dep::validate`]
15447        // refuses through the [`DepError::NomeEmpty`] arm) still round-
15448        // trips as an empty `&str` through the accessor — the accessor is
15449        // a projection, not a gate; the gate is [`Dep::validate`].
15450        assert_eq!(Dep::simple("", "^0.1").nome(), "");
15451    }
15452
15453    #[test]
15454    fn dep_nome_is_by_borrow_pointer_identity() {
15455        // Zero-copy pin: the accessor must borrow into the field's own
15456        // storage, not clone. If a future rewrite regresses to
15457        // `self.nome.clone().leak()` or an owned-buffer shape, the two
15458        // pointers diverge and this pin fails at build time.
15459        let d = Dep::simple("caixa-teia", "^0.1");
15460        assert!(std::ptr::eq(d.nome().as_ptr(), d.nome.as_ptr()));
15461    }
15462
15463    // ── Dep::versao_requirement accessor pins ─────────────────────────
15464    //
15465    // Three coherence pins on the lifted `Dep::versao_requirement`
15466    // accessor: byte-equal projection over the plain-shorthand /
15467    // explicit-git / explicit-path fixture triad the [`Dep`] docstring
15468    // lists plus the empty-sentinel that round-trips as `""` (the accessor
15469    // is a projection, not a gate; the gate is [`Dep::validate`]); by-
15470    // borrow pointer identity so the projection stays zero-copy at every
15471    // consumer site; and validate-composition through the
15472    // [`crate::render::require_valid_versao_requirement`] cascade reading
15473    // its requirement-shape check through the lifted accessor rather than
15474    // the raw field.
15475    #[test]
15476    fn dep_versao_requirement_returns_declared_versao_across_fonte_shapes() {
15477        // Plain-shorthand form (`:fonte None`).
15478        assert_eq!(
15479            Dep::simple("caixa-teia", "^0.1").versao_requirement(),
15480            "^0.1",
15481        );
15482        // Explicit git-source form with a tag pin — same accessor path.
15483        assert_eq!(
15484            Dep::git(
15485                "caixa-teia",
15486                "~0.1.2",
15487                "github:pleme-io/caixa-teia",
15488                "v0.1.0"
15489            )
15490            .versao_requirement(),
15491            "~0.1.2",
15492        );
15493        // Explicit path-source form.
15494        assert_eq!(
15495            Dep {
15496                nome: "caixa-teia".to_string(),
15497                versao: "0.1.0".to_string(),
15498                fonte: Some(DepSource::Path {
15499                    caminho: "../caixa-teia".to_string(),
15500                }),
15501                opcional: false,
15502                caracteristicas: Vec::new(),
15503            }
15504            .versao_requirement(),
15505            "0.1.0",
15506        );
15507        // The wildcard requirement (`"*"`) — the shorthand
15508        // `parse_requirement` accepts as `VersionReq::STAR` — round-trips
15509        // verbatim through the accessor as `"*"`, same byte-shape the
15510        // author wrote.
15511        assert_eq!(Dep::simple("caixa-teia", "*").versao_requirement(), "*");
15512        // The empty-string `:versao` sentinel (which [`Dep::validate`]
15513        // refuses through the [`DepError::VersaoEmpty`] arm) still round-
15514        // trips as an empty `&str` through the accessor — the accessor is
15515        // a projection, not a gate; the gate is [`Dep::validate`]. Peer
15516        // of the sibling [`Dep::nome`] empty-sentinel round-trip pin.
15517        assert_eq!(Dep::simple("caixa-teia", "").versao_requirement(), "");
15518    }
15519
15520    #[test]
15521    fn dep_versao_requirement_is_by_borrow_pointer_identity() {
15522        // Zero-copy pin: the accessor must borrow into the field's own
15523        // storage, not clone. If a future rewrite regresses to
15524        // `self.versao.clone().leak()` or an owned-buffer shape, the two
15525        // pointers diverge and this pin fails at build time. Peer of the
15526        // sibling [`Dep::nome`] pointer-identity pin — same by-borrow
15527        // discipline extended onto the requirement-carrying axis.
15528        let d = Dep::simple("caixa-teia", "^0.1");
15529        assert!(std::ptr::eq(
15530            d.versao_requirement().as_ptr(),
15531            d.versao.as_ptr(),
15532        ));
15533    }
15534
15535    #[test]
15536    fn dep_validate_reads_requirement_through_accessor() {
15537        // Composition pin: the [`Dep::validate`]
15538        // [`crate::render::require_valid_versao_requirement`] cascade
15539        // consumes the requirement string through the lifted accessor —
15540        // both the requirement-gate input and the
15541        // [`DepError::VersaoInvalid`] error-body carrier route through
15542        // `self.versao_requirement()`. A valid requirement passes
15543        // (positive control); a malformed-but-non-empty requirement fails
15544        // and the diagnostic quotes the offending byte-string verbatim
15545        // (same shape the accessor projects), so a future regression that
15546        // detoured the requirement carrier through a different byte-
15547        // string (say the parsed `VersionReq`'s `Display`, or a
15548        // normalized rewrite) would surface here at build time. The
15549        // empty-`:versao` arm fires the [`DepError::VersaoEmpty`] variant
15550        // ahead of the parse arm, pinning the empty-first cascade the
15551        // accessor's `""` sentinel round-trip acknowledges.
15552        Dep::simple("caixa-teia", "^0.1").validate().unwrap();
15553        let err = Dep::simple("caixa-teia", "v0.1").validate().unwrap_err();
15554        assert!(
15555            matches!(
15556                &err,
15557                DepError::VersaoInvalid {
15558                    nome,
15559                    versao,
15560                    ..
15561                } if nome == "caixa-teia" && versao == "v0.1",
15562            ),
15563            "expected VersaoInvalid quoting the accessor-projected requirement, got {err:?}",
15564        );
15565        let err = Dep::simple("caixa-teia", "").validate().unwrap_err();
15566        assert!(
15567            matches!(
15568                &err,
15569                DepError::VersaoEmpty { nome } if nome == "caixa-teia",
15570            ),
15571            "expected VersaoEmpty from the empty-first arm, got {err:?}",
15572        );
15573    }
15574
15575    // ── Dep::fonte accessor pins ──────────────────────────────────────
15576    //
15577    // Three coherence pins on the lifted `Dep::fonte` accessor: byte-
15578    // equal projection over the plain-shorthand (`:fonte None`) /
15579    // explicit-git-tag / explicit-path fixture triad the [`Dep`]
15580    // docstring lists (so the accessor's accept-set is exercised across
15581    // every author-surface `:fonte` shape and both `DepSource` variants);
15582    // pointer identity so the borrowed reference points into the field's
15583    // own `Option<DepSource>` storage (not a cloned side-buffer); and
15584    // validate-composition through the [`Dep::validate`] gate reading
15585    // its per-`:fonte` [`DepSource::validate`] delegation through the
15586    // lifted accessor rather than the raw `if let Some(ref fonte) =
15587    // self.fonte` bracket.
15588
15589    #[test]
15590    fn dep_fonte_returns_declared_source_across_shapes() {
15591        // Plain-shorthand form — `:fonte` omitted, accessor projects
15592        // the `None` partition the resolver-side default-fill treats
15593        // as "resolve through `github:<default-org>/<nome>`".
15594        assert!(Dep::simple("caixa-teia", "^0.1").fonte().is_none());
15595        // Explicit git-source form with a tag pin — same accessor path.
15596        let git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
15597        match git.fonte() {
15598            Some(DepSource::Git {
15599                repo,
15600                tag,
15601                rev,
15602                branch,
15603            }) => {
15604                assert_eq!(repo, "github:pleme-io/caixa-teia");
15605                assert_eq!(tag.as_deref(), Some("v0.1.0"));
15606                assert!(rev.is_none());
15607                assert!(branch.is_none());
15608            }
15609            other => panic!("expected explicit git :fonte, got {other:?}"),
15610        }
15611        // Explicit path-source form — the dev-only local-filesystem
15612        // arm the [`Dep`] docstring's third fixture carries.
15613        let path = Dep {
15614            nome: "caixa-teia".to_string(),
15615            versao: "0.1.0".to_string(),
15616            fonte: Some(DepSource::Path {
15617                caminho: "../caixa-teia".to_string(),
15618            }),
15619            opcional: false,
15620            caracteristicas: Vec::new(),
15621        };
15622        match path.fonte() {
15623            Some(DepSource::Path { caminho }) => {
15624                assert_eq!(caminho, "../caixa-teia");
15625            }
15626            other => panic!("expected explicit path :fonte, got {other:?}"),
15627        }
15628    }
15629
15630    #[test]
15631    fn dep_fonte_is_by_borrow_pointer_identity() {
15632        // Zero-copy pin: the accessor must borrow into the field's own
15633        // `Option<DepSource>` storage, not clone into a side buffer. If
15634        // a future rewrite regresses to `self.fonte.clone()` or an
15635        // owned-buffer shape, the two pointers diverge and this pin
15636        // fails at build time. Peer of the sibling per-`Dep` [`Dep::nome`]
15637        // (eba2cde) / [`Dep::versao_requirement`] (05529b1) pointer-
15638        // identity pins — same by-borrow discipline extended onto the
15639        // outer-`Dep` `Option<&Composite>` composite-reference axis.
15640        let d = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
15641        let accessed = d.fonte().expect("git :fonte present") as *const DepSource;
15642        let raw = d.fonte.as_ref().expect("git :fonte present") as *const DepSource;
15643        assert!(std::ptr::eq(accessed, raw));
15644    }
15645
15646    #[test]
15647    fn dep_validate_reads_fonte_through_accessor() {
15648        // Composition pin: [`Dep::validate`]'s per-`:fonte`
15649        // [`DepSource::validate`] delegation consumes the typed slot
15650        // through the lifted accessor — an author-omitted `:fonte`
15651        // still passes the outer gate (positive control), an explicit
15652        // well-formed git source with exactly one pin passes, and a
15653        // malformed git source (empty `:repo`) surfaces the
15654        // [`DepError::FonteRepoEmpty`] variant quoting the offending
15655        // dep's `:nome` verbatim so a future regression that detoured
15656        // the `:fonte` delegation through a different path (say a
15657        // per-scope override projector) would surface here at build
15658        // time. Peer of the sibling
15659        // `dep_validate_reads_requirement_through_accessor` composition
15660        // pin on the `:versao` axis.
15661        // Positive control 1: no `:fonte` at all.
15662        Dep::simple("caixa-teia", "^0.1").validate().unwrap();
15663        // Positive control 2: well-formed git source.
15664        Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0")
15665            .validate()
15666            .unwrap();
15667        // Negative control: empty `:repo` — the accessor still returns
15668        // `Some(&DepSource::Git { repo: "", … })` and the delegated
15669        // `DepSource::validate` gate raises the typed carrier.
15670        let bad = Dep {
15671            nome: "caixa-teia".to_string(),
15672            versao: "^0.1".to_string(),
15673            fonte: Some(DepSource::Git {
15674                repo: String::new(),
15675                tag: Some("v0.1.0".to_string()),
15676                rev: None,
15677                branch: None,
15678            }),
15679            opcional: false,
15680            caracteristicas: Vec::new(),
15681        };
15682        let err = bad.validate().unwrap_err();
15683        assert!(
15684            matches!(
15685                &err,
15686                DepError::FonteRepoEmpty { nome } if nome == "caixa-teia",
15687            ),
15688            "expected FonteRepoEmpty from the accessor-routed :fonte gate, got {err:?}",
15689        );
15690    }
15691
15692    #[test]
15693    fn validate_no_self_dep_reads_parent_equality_through_accessor() {
15694        // Composition pin: the cross-slot [`validate_no_self_dep`] gate
15695        // rejects a `:deps` entry whose `:nome` equals the parent caixa's
15696        // own `:nome` through the lifted accessor rather than the raw
15697        // field. Fails-before-passes-after: with the accessor lifted the
15698        // gate reads its equality check through `dep.nome() ==
15699        // parent_nome` on both the `:deps` and `:deps-dev` traversals, so
15700        // the diagnostic still names the offending list tag as expected.
15701        let deps = vec![Dep::simple("orquestra", "^0.1")];
15702        let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
15703        assert!(matches!(
15704            err,
15705            DepError::DepIsSelf {
15706                ref nome,
15707                list,
15708            } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS,
15709        ));
15710        let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
15711        let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
15712        assert!(matches!(
15713            err,
15714            DepError::DepIsSelf {
15715                ref nome,
15716                list,
15717            } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
15718        ));
15719        // A non-matching `:nome` passes through the accessor gate.
15720        let deps = vec![Dep::simple("caixa-teia", "^0.1")];
15721        validate_no_self_dep(&deps, &[], "orquestra").unwrap();
15722    }
15723
15724    // ── Dep::caracteristicas accessor pins ────────────────────────────
15725    //
15726    // Three coherence pins on the lifted `Dep::caracteristicas` accessor:
15727    // byte-equal projection over the default-empty / single-entry /
15728    // multi-entry fixture triad (so the accessor's accept-set is
15729    // exercised across every author-surface `:caracteristicas` shape,
15730    // matching the peer sibling family's fixture-triad discipline); by-
15731    // borrow pointer identity so the projection stays zero-copy at every
15732    // consumer site; and validate-composition through the
15733    // [`Dep::validate_caracteristicas`] gate reading its per-entry
15734    // linear walk through the lifted accessor rather than the raw
15735    // `for c in &self.caracteristicas` bracket.
15736
15737    #[test]
15738    fn dep_caracteristicas_returns_declared_features_across_shapes() {
15739        // Default-empty form — the [`Dep::simple`] constructor's
15740        // `Vec::new()` fill; the accessor projects the empty slice
15741        // verbatim (no `None` collapse).
15742        assert!(
15743            Dep::simple("caixa-teia", "^0.1")
15744                .caracteristicas()
15745                .is_empty(),
15746        );
15747        // Single-entry form — the canonical Cargo-shaped one-feature
15748        // enable ([`crate::render::is_cargo_feature_name`] accepts the
15749        // `"http"` byte-string as a valid feature name).
15750        let one = Dep {
15751            nome: "caixa-teia".to_string(),
15752            versao: "^0.1".to_string(),
15753            fonte: None,
15754            opcional: false,
15755            caracteristicas: vec!["http".to_string()],
15756        };
15757        assert_eq!(one.caracteristicas(), &["http".to_string()]);
15758        // Multi-entry form — the substrate's set-shaped multi-feature
15759        // enable, exercising the accessor over a length-two slice with
15760        // no duplicate collapse.
15761        let two = Dep {
15762            nome: "caixa-teia".to_string(),
15763            versao: "^0.1".to_string(),
15764            fonte: None,
15765            opcional: false,
15766            caracteristicas: vec!["http".to_string(), "json".to_string()],
15767        };
15768        assert_eq!(
15769            two.caracteristicas(),
15770            &["http".to_string(), "json".to_string()],
15771        );
15772    }
15773
15774    #[test]
15775    fn dep_caracteristicas_is_by_borrow_pointer_identity() {
15776        // Zero-copy pin: the accessor must borrow into the field's own
15777        // `Vec<String>` storage, not clone into a side buffer. If a
15778        // future rewrite regresses to `self.caracteristicas.clone()` or
15779        // an owned-buffer shape, the two pointers diverge and this pin
15780        // fails at build time. Peer of the sibling per-`Dep`
15781        // [`Dep::nome`] (eba2cde) / [`Dep::versao_requirement`] (05529b1)
15782        // / [`Dep::fonte`] (d65d1bf) pointer-identity pins — same by-
15783        // borrow discipline extended onto the outer-`Dep` `&[String]`
15784        // slice-projection axis.
15785        let d = Dep {
15786            nome: "caixa-teia".to_string(),
15787            versao: "^0.1".to_string(),
15788            fonte: None,
15789            opcional: false,
15790            caracteristicas: vec!["http".to_string(), "json".to_string()],
15791        };
15792        assert!(std::ptr::eq(
15793            d.caracteristicas().as_ptr(),
15794            d.caracteristicas.as_ptr(),
15795        ));
15796    }
15797
15798    #[test]
15799    fn dep_validate_reads_caracteristicas_through_accessor() {
15800        // Composition pin: [`Dep::validate_caracteristicas`]'s per-entry
15801        // linear walk consumes the feature-toggle list through the
15802        // lifted accessor — a well-formed `:caracteristicas` set passes
15803        // (positive control), an empty-string entry surfaces the
15804        // [`DepError::CaracteristicaEmpty`] variant quoting the offending
15805        // `Dep::nome`, and a within-list duplicate surfaces the
15806        // [`DepError::CaracteristicaDuplicate`] variant so a future
15807        // regression that detoured the walk through a different byte-
15808        // string list (say a per-scope override projector) would surface
15809        // here at build time. Peer of the sibling
15810        // `dep_validate_reads_fonte_through_accessor` /
15811        // `dep_validate_reads_requirement_through_accessor` composition
15812        // pins on the `:fonte` / `:versao` axes.
15813        // Positive control: two distinct well-formed feature names pass.
15814        Dep {
15815            nome: "caixa-teia".to_string(),
15816            versao: "^0.1".to_string(),
15817            fonte: None,
15818            opcional: false,
15819            caracteristicas: vec!["http".to_string(), "json".to_string()],
15820        }
15821        .validate()
15822        .unwrap();
15823        // Negative control 1: empty-string feature-name entry — the
15824        // accessor still returns `&[""]` and the walk raises the typed
15825        // empty-first carrier.
15826        let err = Dep {
15827            nome: "caixa-teia".to_string(),
15828            versao: "^0.1".to_string(),
15829            fonte: None,
15830            opcional: false,
15831            caracteristicas: vec![String::new()],
15832        }
15833        .validate()
15834        .unwrap_err();
15835        assert!(
15836            matches!(
15837                &err,
15838                DepError::CaracteristicaEmpty { nome } if nome == "caixa-teia",
15839            ),
15840            "expected CaracteristicaEmpty from the accessor-routed walk, got {err:?}",
15841        );
15842        // Negative control 2: within-list duplicate — the accessor's
15843        // slice view carries both entries, and the walk's dedup arm
15844        // raises the typed duplicate carrier quoting the offending
15845        // feature name verbatim.
15846        let err = Dep {
15847            nome: "caixa-teia".to_string(),
15848            versao: "^0.1".to_string(),
15849            fonte: None,
15850            opcional: false,
15851            caracteristicas: vec!["http".to_string(), "http".to_string()],
15852        }
15853        .validate()
15854        .unwrap_err();
15855        assert!(
15856            matches!(
15857                &err,
15858                DepError::CaracteristicaDuplicate {
15859                    nome,
15860                    caracteristica,
15861                } if nome == "caixa-teia" && caracteristica == "http",
15862            ),
15863            "expected CaracteristicaDuplicate from the accessor-routed dedup, got {err:?}",
15864        );
15865    }
15866
15867    // ── Dep::opcional accessor pins ───────────────────────────────────
15868    //
15869    // Two coherence pins on the lifted `Dep::opcional` accessor: byte-
15870    // equal projection over the default-`false` / explicit-`true`
15871    // fixture pair across the plain-shorthand (`:fonte None`) / explicit-
15872    // git-tag / explicit-path fixture triad the [`Dep`] docstring lists,
15873    // exercising the accessor's accept-set over every author-surface
15874    // `:fonte` shape × every author-surface `:opcional` shape; and by-
15875    // `Copy` idempotency so the projection stays value-return (no
15876    // silent detour to a fresh `&bool` borrow that would introduce a
15877    // lifetime on the return type the plain-`Copy`-scalar axis's `bool`
15878    // shape elides). No composition pin — `:opcional` does not
15879    // participate in [`Dep::validate`] (an opcional dep with any bool
15880    // value is validate-accepted; the missing-source arm is a resolver-
15881    // side runtime dispatch, not a build-time refusal), so the axis
15882    // reduces to the value-shape + `Copy` pin pair the peer
15883    // [`crate::Caixa::max_restarts`] / [`crate::Caixa::estrategia`]
15884    // outer-`Option<Copy>` accessor pins already carry.
15885
15886    #[test]
15887    fn dep_opcional_returns_declared_opcional_across_fonte_shapes() {
15888        // Default-`false` form via the [`Dep::simple`] constructor —
15889        // the accessor projects the `false` bit the default-fill sets.
15890        assert!(!Dep::simple("caixa-teia", "^0.1").opcional());
15891        // Default-`false` form via the [`Dep::git`] constructor — same
15892        // default fill; the accessor projects `false` regardless of the
15893        // `:fonte` arm.
15894        assert!(!Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0").opcional(),);
15895        // Explicit-`true` form × plain-shorthand `:fonte` — the
15896        // canonical author-surface "this dep may be missing" shape.
15897        let plain_true = Dep {
15898            nome: "caixa-teia".to_string(),
15899            versao: "^0.1".to_string(),
15900            fonte: None,
15901            opcional: true,
15902            caracteristicas: Vec::new(),
15903        };
15904        assert!(plain_true.opcional());
15905        // Explicit-`true` form × explicit git-source — the accessor
15906        // projects the bit verbatim regardless of the `:fonte` arm.
15907        let git_true = Dep {
15908            nome: "caixa-teia".to_string(),
15909            versao: "^0.1".to_string(),
15910            fonte: Some(DepSource::Git {
15911                repo: "github:pleme-io/caixa-teia".to_string(),
15912                tag: Some("v0.1.0".to_string()),
15913                rev: None,
15914                branch: None,
15915            }),
15916            opcional: true,
15917            caracteristicas: Vec::new(),
15918        };
15919        assert!(git_true.opcional());
15920        // Explicit-`true` form × explicit path-source — the dev-only
15921        // local-filesystem arm the [`Dep`] docstring's third fixture
15922        // carries.
15923        let path_true = Dep {
15924            nome: "caixa-teia".to_string(),
15925            versao: "0.1.0".to_string(),
15926            fonte: Some(DepSource::Path {
15927                caminho: "../caixa-teia".to_string(),
15928            }),
15929            opcional: true,
15930            caracteristicas: Vec::new(),
15931        };
15932        assert!(path_true.opcional());
15933    }
15934
15935    #[test]
15936    fn dep_opcional_projects_bool_by_copy() {
15937        // The by-`Copy` pin: [`Dep::opcional`] returns `bool` by value
15938        // (`bool: Copy`) — the accessor does not borrow `&self` past
15939        // the call (no lifetime on the return type), and calling the
15940        // accessor twice on the same [`Dep`] must yield discriminant-
15941        // equal values (idempotent, no side effects on `&self`). Peer
15942        // of the sibling outer-`Caixa` `Option<Copy>` by-`Copy`
15943        // `max_restarts_projects_option_by_copy` (eba5211) /
15944        // `estrategia_projects_option_by_copy` (ed04d3c) pins on the
15945        // outer-`Caixa` altitude — extended here to the outer-`Dep`
15946        // altitude's plain-`Copy` `bool` axis. The `Copy` discipline
15947        // replaces the pointer-equality claim the sibling per-`Dep`
15948        // by-borrow pins (`dep_nome_is_by_borrow_pointer_identity`
15949        // eba2cde, `dep_versao_requirement_is_by_borrow_pointer_identity`
15950        // 05529b1, `dep_fonte_is_by_borrow_pointer_identity` d65d1bf,
15951        // `dep_caracteristicas_is_by_borrow_pointer_identity` 9197944)
15952        // carry (a fresh `Copy` of a `Copy` discriminant is definitionally
15953        // the same discriminant, so the axis reduces to discriminant
15954        // equality).
15955        //
15956        // Pins against a future silent detour that returned a fresh
15957        // `&bool` reference (which would type-check but silently
15958        // introduce a borrow of `&self` past the call, collapsing the
15959        // load-bearing "no lifetime on the return type" `Copy`
15960        // projection the plain-`Copy`-scalar axis's `bool` shape
15961        // carries) or a stale-read side effect that flipped the outer
15962        // discriminant on successive calls.
15963        for opcional in [false, true] {
15964            let d = Dep {
15965                nome: "caixa-teia".to_string(),
15966                versao: "^0.1".to_string(),
15967                fonte: None,
15968                opcional,
15969                caracteristicas: Vec::new(),
15970            };
15971            let first = d.opcional();
15972            let second = d.opcional();
15973            assert_eq!(
15974                first, second,
15975                "Dep::opcional must be idempotent — two successive calls \
15976                 on the same &self must return the same bool",
15977            );
15978            assert_eq!(
15979                first, opcional,
15980                "Dep::opcional must return :opcional verbatim by Copy — \
15981                 got {first}, expected {opcional}",
15982            );
15983            assert_eq!(
15984                d.opcional(),
15985                d.opcional,
15986                "Dep::opcional accessor and self.opcional field access \
15987                 must byte-equal — a bit-flip drift would silently split \
15988                 the paired resolver-side drop-vs-error dispatch from \
15989                 the storage-side default-fill the [`Dep::simple`] / \
15990                 [`Dep::git`] constructor pair carries",
15991            );
15992        }
15993    }
15994
15995    // ── DepSource::sole_pin — sole-set git-pin accessor ─────────────────
15996
15997    #[test]
15998    fn sole_pin_returns_none_for_path_source() {
15999        // A path source carries no git-ref, so `sole_pin()` returns
16000        // `None` structurally — the sibling arm every git-fetching
16001        // consumer partitions off before reaching for a git-ref. Pins
16002        // the Path-arm branch of the accessor against a future silent
16003        // detour that treats a `Self::Path` as an unpinned-git source
16004        // and returns the wrong "no pin" signal (e.g. the empty string,
16005        // or a hard-coded `Some("HEAD")` matching the caixa-crd
16006        // path-arm `git_ref` fill).
16007        let s = DepSource::Path {
16008            caminho: "../local-caixa".to_string(),
16009        };
16010        assert_eq!(s.sole_pin(), None);
16011    }
16012
16013    #[test]
16014    fn sole_pin_returns_none_for_unpinned_git_source() {
16015        // The [`DepSource::default_github`] shorthand shape carries no
16016        // pin — every `tag`/`rev`/`branch` is `None`, and `sole_pin()`
16017        // returns `None`. This is the shape caixa-resolver's `fetch_dep`
16018        // materializes when the author omits `:fonte` entirely, then
16019        // hands to `fetch_git` which raises `ResolveError::MissingPin`
16020        // on the `None` arm — the accessor's return matches the arm
16021        // the resolver's diagnostic keys off.
16022        let s = DepSource::default_github("pleme-io", "caixa-teia");
16023        assert_eq!(s.sole_pin(), None);
16024    }
16025
16026    #[test]
16027    fn sole_pin_returns_rev_when_only_rev_is_set() {
16028        let s = DepSource::Git {
16029            repo: "github:o/x".into(),
16030            tag: None,
16031            rev: Some("deadbeefcafebabe1234567890abcdef12345678".into()),
16032            branch: None,
16033        };
16034        assert_eq!(
16035            s.sole_pin(),
16036            Some("deadbeefcafebabe1234567890abcdef12345678")
16037        );
16038    }
16039
16040    #[test]
16041    fn sole_pin_returns_tag_when_only_tag_is_set() {
16042        let s = DepSource::Git {
16043            repo: "github:o/x".into(),
16044            tag: Some("v0.1.0".into()),
16045            rev: None,
16046            branch: None,
16047        };
16048        assert_eq!(s.sole_pin(), Some("v0.1.0"));
16049    }
16050
16051    #[test]
16052    fn sole_pin_returns_branch_when_only_branch_is_set() {
16053        let s = DepSource::Git {
16054            repo: "github:o/x".into(),
16055            tag: None,
16056            rev: None,
16057            branch: Some("main".into()),
16058        };
16059        assert_eq!(s.sole_pin(), Some("main"));
16060    }
16061
16062    #[test]
16063    fn sole_pin_precedence_rev_beats_tag_and_branch() {
16064        // Precedence: rev > tag > branch. Validate() rejects
16065        // multiple-pin shapes, but the accessor's precedence is defined
16066        // for pre-validate consumers (the resolver's `MissingPin`
16067        // diagnostic path, the caixa-crd round-trip's default `"main"`
16068        // fallback) and as defense-in-depth if the gate is ever
16069        // bypassed. Pins the same precedence caixa-resolver's
16070        // `fetch_git` and caixa-crd's `dep_into_ref` already apply
16071        // inline.
16072        let s = DepSource::Git {
16073            repo: "github:o/x".into(),
16074            tag: Some("v1".into()),
16075            rev: Some("deadbeefcafebabe1234567890abcdef12345678".into()),
16076            branch: Some("main".into()),
16077        };
16078        assert_eq!(
16079            s.sole_pin(),
16080            Some("deadbeefcafebabe1234567890abcdef12345678")
16081        );
16082    }
16083
16084    #[test]
16085    fn sole_pin_precedence_tag_beats_branch_when_no_rev() {
16086        let s = DepSource::Git {
16087            repo: "github:o/x".into(),
16088            tag: Some("v1".into()),
16089            rev: None,
16090            branch: Some("main".into()),
16091        };
16092        assert_eq!(s.sole_pin(), Some("v1"));
16093    }
16094
16095    #[test]
16096    fn sole_pin_byte_equals_inline_rev_or_tag_or_branch_cascade() {
16097        // Fail-before-pass-after byte-parity pin: the substrate accessor
16098        // must return byte-identical to the inline
16099        // `rev.as_deref().or(tag.as_deref()).or(branch.as_deref())`
16100        // cascade both caixa-resolver's `fetch_git` and caixa-crd's
16101        // `dep_into_ref` open-coded pre-lift. Trips at caixa-core build
16102        // time if the accessor's precedence silently drifts from the
16103        // consumer-side cascade — the exact drift this lift converges
16104        // to one substrate primitive to close structurally.
16105        //
16106        // Iterates through the 2^3 = 8 combinations of (tag, rev,
16107        // branch) each-either-`None`-or-`Some`, so every arm of the
16108        // precedence cascade lands under the pin. `validate()` refuses
16109        // the 4 multi-pin combinations, but the accessor's return is
16110        // defined on all 8.
16111        let vals = [Some("R".to_string()), None];
16112        for tag in &vals {
16113            for rev in &vals {
16114                for branch in &vals {
16115                    let s = DepSource::Git {
16116                        repo: "github:o/x".into(),
16117                        tag: tag.clone(),
16118                        rev: rev.clone(),
16119                        branch: branch.clone(),
16120                    };
16121                    // The exact inline cascade the two pre-lift
16122                    // consumer sites hand-rolled, byte-for-byte.
16123                    let expected = rev.as_deref().or(tag.as_deref()).or(branch.as_deref());
16124                    assert_eq!(
16125                        s.sole_pin(),
16126                        expected,
16127                        "sole_pin() must byte-equal \
16128                         rev.or(tag).or(branch) for \
16129                         (tag={tag:?}, rev={rev:?}, branch={branch:?}) — \
16130                         a drift would silently split caixa-resolver's \
16131                         fetch_git checkout target from caixa-crd's \
16132                         dep_into_ref git_ref fill",
16133                    );
16134                }
16135            }
16136        }
16137    }
16138
16139    // Fail-before-pass-after pins on the eleven
16140    // [`fonte_caminho_ctors!`]-generated `DepError::fonte_caminho_*`
16141    // constructors folded from the [`DepSource::validate_caminho`]
16142    // wire-up sites. Each pins the generated ctor's output to the
16143    // pre-lift struct-literal on the same `(&str, &str)` fixture, so
16144    // any wrapper-side lowercase / trim / re-order / silent-field-swap
16145    // regression on the two-field `{ nome: nome.to_string(), caminho:
16146    // caminho.to_string() }` construction surfaces here rather than at
16147    // a downstream diagnostic-shape mismatch. Peer of the sibling
16148    // `empty_child_version_ctor_matches_struct_literal_wrap` /
16149    // `contrato_endpoint_empty_ctor_matches_struct_literal_wrap` /
16150    // `entrada_host_invalid_ctor_matches_struct_literal_wrap` /
16151    // `nome_only_ctor_routes_caixa_through_nome_accessor` equivalence
16152    // pins on the peer `SupervisorError` / `AplicacaoError` /
16153    // `LayoutError` / `LimitsError` / `UpgradeError` envelopes.
16154
16155    #[test]
16156    fn fonte_caminho_absolute_ctor_matches_struct_literal_wrap() {
16157        assert_eq!(
16158            DepError::fonte_caminho_absolute("caixa-teia", "/home/me/work/caixa-teia"),
16159            DepError::FonteCaminhoAbsolute {
16160                nome: "caixa-teia".to_string(),
16161                caminho: "/home/me/work/caixa-teia".to_string(),
16162            },
16163            "generated fonte_caminho_absolute ctor must produce byte-equal \
16164             DepError to the open-coded struct-literal wrap on the same \
16165             (&str, &str) fixture",
16166        );
16167    }
16168
16169    #[test]
16170    fn fonte_caminho_tilde_expansion_ctor_matches_struct_literal_wrap() {
16171        assert_eq!(
16172            DepError::fonte_caminho_tilde_expansion("caixa-teia", "~/work/caixa-teia"),
16173            DepError::FonteCaminhoTildeExpansion {
16174                nome: "caixa-teia".to_string(),
16175                caminho: "~/work/caixa-teia".to_string(),
16176            },
16177        );
16178    }
16179
16180    #[test]
16181    fn fonte_caminho_var_expansion_ctor_matches_struct_literal_wrap() {
16182        assert_eq!(
16183            DepError::fonte_caminho_var_expansion("caixa-teia", "$HOME/work/caixa-teia"),
16184            DepError::FonteCaminhoVarExpansion {
16185                nome: "caixa-teia".to_string(),
16186                caminho: "$HOME/work/caixa-teia".to_string(),
16187            },
16188        );
16189    }
16190
16191    #[test]
16192    fn fonte_caminho_leading_whitespace_ctor_matches_struct_literal_wrap() {
16193        assert_eq!(
16194            DepError::fonte_caminho_leading_whitespace("caixa-teia", " ../caixa-teia"),
16195            DepError::FonteCaminhoLeadingWhitespace {
16196                nome: "caixa-teia".to_string(),
16197                caminho: " ../caixa-teia".to_string(),
16198            },
16199        );
16200    }
16201
16202    #[test]
16203    fn fonte_caminho_leading_hyphen_ctor_matches_struct_literal_wrap() {
16204        assert_eq!(
16205            DepError::fonte_caminho_leading_hyphen("caixa-teia", "-rf"),
16206            DepError::FonteCaminhoLeadingHyphen {
16207                nome: "caixa-teia".to_string(),
16208                caminho: "-rf".to_string(),
16209            },
16210        );
16211    }
16212
16213    #[test]
16214    fn fonte_caminho_backslash_ctor_matches_struct_literal_wrap() {
16215        assert_eq!(
16216            DepError::fonte_caminho_backslash("caixa-teia", "..\\caixa-teia"),
16217            DepError::FonteCaminhoBackslash {
16218                nome: "caixa-teia".to_string(),
16219                caminho: "..\\caixa-teia".to_string(),
16220            },
16221        );
16222    }
16223
16224    #[test]
16225    fn fonte_caminho_shell_pipe_ctor_matches_struct_literal_wrap() {
16226        assert_eq!(
16227            DepError::fonte_caminho_shell_pipe("caixa-teia", "../caixa-teia|evil"),
16228            DepError::FonteCaminhoShellPipe {
16229                nome: "caixa-teia".to_string(),
16230                caminho: "../caixa-teia|evil".to_string(),
16231            },
16232        );
16233    }
16234
16235    #[test]
16236    fn fonte_caminho_shell_semicolon_ctor_matches_struct_literal_wrap() {
16237        assert_eq!(
16238            DepError::fonte_caminho_shell_semicolon("caixa-teia", "../caixa-teia;evil"),
16239            DepError::FonteCaminhoShellSemicolon {
16240                nome: "caixa-teia".to_string(),
16241                caminho: "../caixa-teia;evil".to_string(),
16242            },
16243        );
16244    }
16245
16246    #[test]
16247    fn fonte_caminho_shell_background_ctor_matches_struct_literal_wrap() {
16248        assert_eq!(
16249            DepError::fonte_caminho_shell_background("caixa-teia", "../caixa-teia&"),
16250            DepError::FonteCaminhoShellBackground {
16251                nome: "caixa-teia".to_string(),
16252                caminho: "../caixa-teia&".to_string(),
16253            },
16254        );
16255    }
16256
16257    #[test]
16258    fn fonte_caminho_shell_command_substitution_ctor_matches_struct_literal_wrap() {
16259        assert_eq!(
16260            DepError::fonte_caminho_shell_command_substitution(
16261                "caixa-teia",
16262                "../caixa-teia`whoami`",
16263            ),
16264            DepError::FonteCaminhoShellCommandSubstitution {
16265                nome: "caixa-teia".to_string(),
16266                caminho: "../caixa-teia`whoami`".to_string(),
16267            },
16268        );
16269    }
16270
16271    #[test]
16272    fn fonte_caminho_trailing_slash_ctor_matches_struct_literal_wrap() {
16273        assert_eq!(
16274            DepError::fonte_caminho_trailing_slash("caixa-teia", "../caixa-teia/"),
16275            DepError::FonteCaminhoTrailingSlash {
16276                nome: "caixa-teia".to_string(),
16277                caminho: "../caixa-teia/".to_string(),
16278            },
16279        );
16280    }
16281
16282    #[test]
16283    fn fonte_caminho_ctors_route_nome_and_caminho_through_to_string() {
16284        // Cross-axis pin: sweep the two constructor input axes
16285        // (`nome: &str`, `caminho: &str`) through a non-default fixture
16286        // pair against every generated arm in the
16287        // [`fonte_caminho_ctors!`] macro, so any wrapper-side lowercase
16288        // / trim / truncate / re-order on the two-field
16289        // `{ nome, caminho }` construction — or a silent field swap
16290        // between the two axes at codegen time — surfaces here rather
16291        // than at a downstream diagnostic-shape mismatch. Peer of the
16292        // sibling `supervisor_caixa_only_ctors_route_caixa_through_
16293        // to_string` cross-axis routing pin on the peer
16294        // `SupervisorError` envelope, extended here onto the
16295        // `DepError` `{ nome: String, caminho: String }` envelope so
16296        // every substrate-primitive ctor family in caixa-core
16297        // guarantees each `&str`-field construction routes the
16298        // caller's `&str` verbatim through `.to_string()`.
16299        let nome = "sibling-teia";
16300        let caminho = "../workspace/sibling";
16301        let cases: [(DepError, DepError); 11] = [
16302            (
16303                DepError::fonte_caminho_absolute(nome, caminho),
16304                DepError::FonteCaminhoAbsolute {
16305                    nome: nome.to_string(),
16306                    caminho: caminho.to_string(),
16307                },
16308            ),
16309            (
16310                DepError::fonte_caminho_tilde_expansion(nome, caminho),
16311                DepError::FonteCaminhoTildeExpansion {
16312                    nome: nome.to_string(),
16313                    caminho: caminho.to_string(),
16314                },
16315            ),
16316            (
16317                DepError::fonte_caminho_var_expansion(nome, caminho),
16318                DepError::FonteCaminhoVarExpansion {
16319                    nome: nome.to_string(),
16320                    caminho: caminho.to_string(),
16321                },
16322            ),
16323            (
16324                DepError::fonte_caminho_leading_whitespace(nome, caminho),
16325                DepError::FonteCaminhoLeadingWhitespace {
16326                    nome: nome.to_string(),
16327                    caminho: caminho.to_string(),
16328                },
16329            ),
16330            (
16331                DepError::fonte_caminho_leading_hyphen(nome, caminho),
16332                DepError::FonteCaminhoLeadingHyphen {
16333                    nome: nome.to_string(),
16334                    caminho: caminho.to_string(),
16335                },
16336            ),
16337            (
16338                DepError::fonte_caminho_backslash(nome, caminho),
16339                DepError::FonteCaminhoBackslash {
16340                    nome: nome.to_string(),
16341                    caminho: caminho.to_string(),
16342                },
16343            ),
16344            (
16345                DepError::fonte_caminho_shell_pipe(nome, caminho),
16346                DepError::FonteCaminhoShellPipe {
16347                    nome: nome.to_string(),
16348                    caminho: caminho.to_string(),
16349                },
16350            ),
16351            (
16352                DepError::fonte_caminho_shell_semicolon(nome, caminho),
16353                DepError::FonteCaminhoShellSemicolon {
16354                    nome: nome.to_string(),
16355                    caminho: caminho.to_string(),
16356                },
16357            ),
16358            (
16359                DepError::fonte_caminho_shell_background(nome, caminho),
16360                DepError::FonteCaminhoShellBackground {
16361                    nome: nome.to_string(),
16362                    caminho: caminho.to_string(),
16363                },
16364            ),
16365            (
16366                DepError::fonte_caminho_shell_command_substitution(nome, caminho),
16367                DepError::FonteCaminhoShellCommandSubstitution {
16368                    nome: nome.to_string(),
16369                    caminho: caminho.to_string(),
16370                },
16371            ),
16372            (
16373                DepError::fonte_caminho_trailing_slash(nome, caminho),
16374                DepError::FonteCaminhoTrailingSlash {
16375                    nome: nome.to_string(),
16376                    caminho: caminho.to_string(),
16377                },
16378            ),
16379        ];
16380        for (via_ctor, via_struct_literal) in cases {
16381            assert_eq!(
16382                via_ctor, via_struct_literal,
16383                "fonte_caminho_ctors!-generated ctor must route (nome, caminho) \
16384                 through `.to_string()` in declared field order — a field-swap or \
16385                 silent-conversion regression surfaces here rather than at a \
16386                 downstream diagnostic-shape mismatch",
16387            );
16388        }
16389    }
16390
16391    // ── `dep_nome_only_ctors!` — the paired `{ nome: String }` single-slot
16392    //    envelope on `DepError`, sibling of the peer `fonte_caminho_ctors!`
16393    //    (f85f145) on the `{ nome, caminho }` two-slot envelope of the same
16394    //    enum, and of `supervisor_caixa_only_ctors!` (db09650) on the peer
16395    //    `SupervisorError` envelope's `{ caixa: String }` single-slot axis.
16396
16397    #[test]
16398    fn versao_empty_ctor_matches_struct_literal_wrap() {
16399        assert_eq!(
16400            DepError::versao_empty("caixa-teia"),
16401            DepError::VersaoEmpty {
16402                nome: "caixa-teia".to_string(),
16403            },
16404        );
16405    }
16406
16407    #[test]
16408    fn fonte_repo_empty_ctor_matches_struct_literal_wrap() {
16409        assert_eq!(
16410            DepError::fonte_repo_empty("caixa-teia"),
16411            DepError::FonteRepoEmpty {
16412                nome: "caixa-teia".to_string(),
16413            },
16414        );
16415    }
16416
16417    #[test]
16418    fn fonte_pin_missing_ctor_matches_struct_literal_wrap() {
16419        assert_eq!(
16420            DepError::fonte_pin_missing("caixa-teia"),
16421            DepError::FontePinMissing {
16422                nome: "caixa-teia".to_string(),
16423            },
16424        );
16425    }
16426
16427    #[test]
16428    fn fonte_caminho_empty_ctor_matches_struct_literal_wrap() {
16429        assert_eq!(
16430            DepError::fonte_caminho_empty("caixa-teia"),
16431            DepError::FonteCaminhoEmpty {
16432                nome: "caixa-teia".to_string(),
16433            },
16434        );
16435    }
16436
16437    #[test]
16438    fn caracteristica_empty_ctor_matches_struct_literal_wrap() {
16439        assert_eq!(
16440            DepError::caracteristica_empty("caixa-teia"),
16441            DepError::CaracteristicaEmpty {
16442                nome: "caixa-teia".to_string(),
16443            },
16444        );
16445    }
16446
16447    #[test]
16448    fn dep_nome_only_ctors_route_nome_through_to_string() {
16449        // Cross-axis routing pin: sweep the single constructor input
16450        // axis (`nome: &str`) through a non-default fixture against
16451        // every generated arm in the [`dep_nome_only_ctors!`] macro, so
16452        // any wrapper-side lowercase / trim / truncate at codegen time
16453        // — or a silent field re-name away from the canonical `nome`
16454        // axis on any one variant — surfaces here rather than at a
16455        // downstream diagnostic-shape mismatch. Peer of the sibling
16456        // `fonte_caminho_ctors_route_nome_and_caminho_through_
16457        // to_string` cross-axis routing pin on the same envelope's
16458        // two-slot family (f85f145) and of the peer
16459        // `supervisor_caixa_only_ctors_route_caixa_through_to_string`
16460        // pin on the `SupervisorError` single-slot family (db09650).
16461        let nome = "sibling-teia";
16462        let cases: [(DepError, DepError); 5] = [
16463            (
16464                DepError::versao_empty(nome),
16465                DepError::VersaoEmpty {
16466                    nome: nome.to_string(),
16467                },
16468            ),
16469            (
16470                DepError::fonte_repo_empty(nome),
16471                DepError::FonteRepoEmpty {
16472                    nome: nome.to_string(),
16473                },
16474            ),
16475            (
16476                DepError::fonte_pin_missing(nome),
16477                DepError::FontePinMissing {
16478                    nome: nome.to_string(),
16479                },
16480            ),
16481            (
16482                DepError::fonte_caminho_empty(nome),
16483                DepError::FonteCaminhoEmpty {
16484                    nome: nome.to_string(),
16485                },
16486            ),
16487            (
16488                DepError::caracteristica_empty(nome),
16489                DepError::CaracteristicaEmpty {
16490                    nome: nome.to_string(),
16491                },
16492            ),
16493        ];
16494        for (via_ctor, via_struct_literal) in cases {
16495            assert_eq!(
16496                via_ctor, via_struct_literal,
16497                "dep_nome_only_ctors!-generated ctor must route `nome` \
16498                 through `.to_string()` onto the canonical `nome` field \
16499                 — a field-rename or silent-conversion regression surfaces \
16500                 here rather than at a downstream diagnostic-shape mismatch",
16501            );
16502        }
16503    }
16504
16505    // ── `fonte_caminho_byte_ctors!` — the paired `{ nome: String,
16506    //    caminho: String, byte: u8 }` three-slot envelope on `DepError`,
16507    //    strict sibling of the peer `fonte_caminho_ctors!` (f85f145) on
16508    //    the same envelope's `{ nome: String, caminho: String }` two-slot
16509    //    shape, and of the peer `dep_nome_only_ctors!` (792aa92) on the
16510    //    same envelope's `{ nome: String }` one-slot shape.
16511
16512    #[test]
16513    fn fonte_caminho_control_char_ctor_matches_struct_literal_wrap() {
16514        assert_eq!(
16515            DepError::fonte_caminho_control_char("caixa-teia", "../caixa-teia\x00foo", 0x00),
16516            DepError::FonteCaminhoControlChar {
16517                nome: "caixa-teia".to_string(),
16518                caminho: "../caixa-teia\x00foo".to_string(),
16519                byte: 0x00,
16520            },
16521        );
16522    }
16523
16524    #[test]
16525    fn fonte_caminho_shell_redirection_ctor_matches_struct_literal_wrap() {
16526        assert_eq!(
16527            DepError::fonte_caminho_shell_redirection("caixa-teia", "../caixa-teia>log", b'>'),
16528            DepError::FonteCaminhoShellRedirection {
16529                nome: "caixa-teia".to_string(),
16530                caminho: "../caixa-teia>log".to_string(),
16531                byte: b'>',
16532            },
16533        );
16534    }
16535
16536    #[test]
16537    #[allow(
16538        clippy::too_many_lines,
16539        reason = "cross-axis routing pin sweeps twelve typed variants, one per \
16540                  byte-classification arm on the {nome,caminho,byte} envelope; \
16541                  the linear per-variant repetition is exactly what the sweep \
16542                  is pinning — a helper macro would hide the shape the fold is \
16543                  keying on"
16544    )]
16545    fn fonte_caminho_byte_ctors_route_nome_caminho_and_byte_through_to_string() {
16546        // Cross-axis routing pin: sweep the three constructor input axes
16547        // (`nome: &str`, `caminho: &str`, `byte: u8`) through a
16548        // non-default fixture triple against every generated arm in the
16549        // [`fonte_caminho_byte_ctors!`] macro, so any wrapper-side
16550        // lowercase / trim / truncate on the two `&str` axes — a silent
16551        // field swap between `nome` and `caminho`, or a silent
16552        // re-classification of the offending byte — surfaces here rather
16553        // than at a downstream diagnostic-shape mismatch. Peer of the
16554        // sibling `fonte_caminho_ctors_route_nome_and_caminho_through_
16555        // to_string` cross-axis routing pin on the same envelope's
16556        // two-slot family (f85f145) and of the sibling
16557        // `dep_nome_only_ctors_route_nome_through_to_string` pin on the
16558        // same envelope's one-slot family (792aa92), extended here onto
16559        // the `{ nome: String, caminho: String, byte: u8 }` three-slot
16560        // envelope so every substrate-primitive ctor family in
16561        // caixa-core's `DepError` envelope guarantees each field routes
16562        // the caller's value verbatim through `.to_string()` (or byte-
16563        // identity for `byte: u8`) in declared field order.
16564        let nome = "sibling-teia";
16565        let caminho = "../workspace/sibling";
16566        let byte = 0x2A_u8;
16567        let cases: [(DepError, DepError); 12] = [
16568            (
16569                DepError::fonte_caminho_control_char(nome, caminho, byte),
16570                DepError::FonteCaminhoControlChar {
16571                    nome: nome.to_string(),
16572                    caminho: caminho.to_string(),
16573                    byte,
16574                },
16575            ),
16576            (
16577                DepError::fonte_caminho_shell_redirection(nome, caminho, byte),
16578                DepError::FonteCaminhoShellRedirection {
16579                    nome: nome.to_string(),
16580                    caminho: caminho.to_string(),
16581                    byte,
16582                },
16583            ),
16584            (
16585                DepError::fonte_caminho_shell_glob(nome, caminho, byte),
16586                DepError::FonteCaminhoShellGlob {
16587                    nome: nome.to_string(),
16588                    caminho: caminho.to_string(),
16589                    byte,
16590                },
16591            ),
16592            (
16593                DepError::fonte_caminho_shell_subshell_grouping(nome, caminho, byte),
16594                DepError::FonteCaminhoShellSubshellGrouping {
16595                    nome: nome.to_string(),
16596                    caminho: caminho.to_string(),
16597                    byte,
16598                },
16599            ),
16600            (
16601                DepError::fonte_caminho_shell_brace_expansion(nome, caminho, byte),
16602                DepError::FonteCaminhoShellBraceExpansion {
16603                    nome: nome.to_string(),
16604                    caminho: caminho.to_string(),
16605                    byte,
16606                },
16607            ),
16608            (
16609                DepError::fonte_caminho_shell_bracket_expansion(nome, caminho, byte),
16610                DepError::FonteCaminhoShellBracketExpansion {
16611                    nome: nome.to_string(),
16612                    caminho: caminho.to_string(),
16613                    byte,
16614                },
16615            ),
16616            (
16617                DepError::fonte_caminho_shell_quote_grouping(nome, caminho, byte),
16618                DepError::FonteCaminhoShellQuoteGrouping {
16619                    nome: nome.to_string(),
16620                    caminho: caminho.to_string(),
16621                    byte,
16622                },
16623            ),
16624            (
16625                DepError::fonte_caminho_shell_comment(nome, caminho, byte),
16626                DepError::FonteCaminhoShellComment {
16627                    nome: nome.to_string(),
16628                    caminho: caminho.to_string(),
16629                    byte,
16630                },
16631            ),
16632            (
16633                DepError::fonte_caminho_url_percent_encoding(nome, caminho, byte),
16634                DepError::FonteCaminhoUrlPercentEncoding {
16635                    nome: nome.to_string(),
16636                    caminho: caminho.to_string(),
16637                    byte,
16638                },
16639            ),
16640            (
16641                DepError::fonte_caminho_shell_variable_expansion(nome, caminho, byte),
16642                DepError::FonteCaminhoShellVariableExpansion {
16643                    nome: nome.to_string(),
16644                    caminho: caminho.to_string(),
16645                    byte,
16646                },
16647            ),
16648            (
16649                DepError::fonte_caminho_shell_history_expansion(nome, caminho, byte),
16650                DepError::FonteCaminhoShellHistoryExpansion {
16651                    nome: nome.to_string(),
16652                    caminho: caminho.to_string(),
16653                    byte,
16654                },
16655            ),
16656            (
16657                DepError::fonte_caminho_shell_history_substitution(nome, caminho, byte),
16658                DepError::FonteCaminhoShellHistorySubstitution {
16659                    nome: nome.to_string(),
16660                    caminho: caminho.to_string(),
16661                    byte,
16662                },
16663            ),
16664        ];
16665        for (via_ctor, via_struct_literal) in cases {
16666            assert_eq!(
16667                via_ctor, via_struct_literal,
16668                "fonte_caminho_byte_ctors!-generated ctor must route \
16669                 (nome, caminho, byte) through `.to_string()` / byte-\
16670                 identity in declared field order — a field-swap or \
16671                 silent-conversion regression surfaces here rather than \
16672                 at a downstream diagnostic-shape mismatch",
16673            );
16674        }
16675    }
16676}
16677
16678#[cfg(test)]
16679mod dep_source_is_variant_tests {
16680    use super::*;
16681
16682    fn all_variants() -> Vec<(DepSource, &'static str)> {
16683        vec![
16684            (
16685                DepSource::Git {
16686                    repo: "github:pleme-io/caixa-teia".into(),
16687                    tag: Some("v0.1.0".into()),
16688                    rev: None,
16689                    branch: None,
16690                },
16691                "Git",
16692            ),
16693            (
16694                DepSource::Path {
16695                    caminho: "../caixa-teia".into(),
16696                },
16697                "Path",
16698            ),
16699        ]
16700    }
16701
16702    fn predicate_row(s: &DepSource) -> [bool; 2] {
16703        [s.is_git(), s.is_path()]
16704    }
16705
16706    // Fail-before-pass-after pin on the [`gen_platform::IsVariant`]
16707    // derive-generated per-arm predicate partition — for every variant
16708    // in `all_variants()`, the observed 2-slot predicate row must equal
16709    // a one-hot row with the `true` at exactly the same index as the
16710    // variant's declaration order. Expected rows are generated live
16711    // from the enumeration rather than transcribed by hand, so a
16712    // copy-paste flip that reroutes one arm through the wrong predicate
16713    // lane trips at the identity-diagonal assertion the way every peer
16714    // sibling [`DepList`] / [`crate::CaixaKind`] / [`crate::CaixaDialeto`]
16715    // / [`crate::supervisor::RestartStrategy`] / [`crate::supervisor::RestartPolicy`]
16716    // / [`crate::upgrade::UpgradeInstruction`] /
16717    // [`crate::aplicacao::PlacementStrategy`] /
16718    // [`crate::aplicacao::RateLimitUnit`] /
16719    // [`crate::aplicacao::WitTarget`] /
16720    // [`crate::render::PathShapeViolation`] partition pin already does.
16721    #[test]
16722    fn dep_source_is_variant_predicates_partition_the_arm_set() {
16723        let variants = all_variants();
16724        for (idx, (variant, name)) in variants.iter().enumerate() {
16725            let observed = predicate_row(variant);
16726            let mut expected = [false; 2];
16727            expected[idx] = true;
16728            assert_eq!(
16729                observed, expected,
16730                "DepSource::{name} at declaration-order slot {idx} must \
16731                 satisfy exactly one is_* predicate (its own); observed \
16732                 row must equal the one-hot expected row — a drift \
16733                 would silently reroute one `:fonte`-arm consumer \
16734                 through the wrong predicate lane"
16735            );
16736        }
16737    }
16738
16739    // Byte-parity pin on the two field-agnostic `matches!` shapes the
16740    // per-arm arm-discriminator predicates replace at any future
16741    // consumer site (a `:fonte`-shape-only lint rule that flags path
16742    // deps outside dev-caixas via `dep.fonte().is_some_and(DepSource::is_path)`,
16743    // a future admission-webhook that rejects `:fonte` shapes outside
16744    // the `is_git()` accept-set, a caixa-lacre indexing pass that
16745    // dispatches on `s.is_git()` without extracting `repo` / `caminho`).
16746    // Refuses a future accidental split between the derived predicate
16747    // and its `matches!` shape — a hand-rolled shadow impl that
16748    // overrides one path, an accidental rebrand that leaves one
16749    // consumer on the raw `matches!` form — on the two load-bearing
16750    // `:fonte`-arm-discriminator axes every downstream substrate
16751    // consumer of the dep-source axis keys off.
16752    #[test]
16753    fn dep_source_is_git_and_is_path_byte_equal_matches_shape() {
16754        for (variant, name) in all_variants() {
16755            let via_matches_git = matches!(variant, DepSource::Git { .. });
16756            let via_predicate_git = variant.is_git();
16757            assert_eq!(
16758                via_predicate_git, via_matches_git,
16759                "DepSource::{name}.is_git() must byte-equal \
16760                 matches!(_, DepSource::Git {{ .. }}) — otherwise a \
16761                 future converged consumer site would silently \
16762                 disagree with its pre-lift shape"
16763            );
16764            let via_matches_path = matches!(variant, DepSource::Path { .. });
16765            let via_predicate_path = variant.is_path();
16766            assert_eq!(
16767                via_predicate_path, via_matches_path,
16768                "DepSource::{name}.is_path() must byte-equal \
16769                 matches!(_, DepSource::Path {{ .. }}) — otherwise a \
16770                 future converged consumer site would silently \
16771                 disagree with its pre-lift shape"
16772            );
16773        }
16774    }
16775
16776    // Cross-pin against every constructor path that materializes a
16777    // [`DepSource`] shape today (the [`DepSource::default_github`]
16778    // resolver-side fallback that materializes an unpinned
16779    // `github:<org>/<nome>` git shorthand, the [`Dep::git`] author-
16780    // surface constructor that materializes a pinned `:tag`-carrying
16781    // `DepSource::Git`, a hand-rolled `DepSource::Path` the dev-mode
16782    // fixture family builds inline). Every constructor's return must
16783    // satisfy the arm-discriminator predicate the constructor's
16784    // variant name matches — a future constructor addition (an
16785    // in-tree registry-fetch pin, a `DepSource::Feira` variant the
16786    // enclosing docstring already names as a trajectory item) surfaces
16787    // as a build-time failure that names the offending drift when its
16788    // return arm doesn't route through the paired predicate.
16789    #[test]
16790    fn dep_source_constructors_route_through_paired_is_variant_predicate() {
16791        let via_default_github = DepSource::default_github("pleme-io", "caixa-teia");
16792        assert!(
16793            via_default_github.is_git(),
16794            "DepSource::default_github must materialize a Git-arm shape — \
16795             a future constructor that routed through a non-Git arm \
16796             (a registry-fetch pin, a `DepSource::Feira` promotion) \
16797             would silently split the resolver's unpinned-shorthand \
16798             materializer from the sole_pin() precedence cascade"
16799        );
16800        assert!(
16801            !via_default_github.is_path(),
16802            "DepSource::default_github must NOT materialize a Path-arm \
16803             shape — the paired negation pin"
16804        );
16805
16806        let via_dep_git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0")
16807            .fonte
16808            .expect("Dep::git materializes a Some(fonte)");
16809        assert!(
16810            via_dep_git.is_git(),
16811            "Dep::git's `:fonte` materialization must land on the Git \
16812             arm — the author-surface pinned-git constructor's return \
16813             must route through the paired predicate"
16814        );
16815        assert!(!via_dep_git.is_path(), "paired negation pin");
16816
16817        let via_path = DepSource::Path {
16818            caminho: "../caixa-teia".into(),
16819        };
16820        assert!(
16821            via_path.is_path(),
16822            "the dev-mode Path-arm materialization must satisfy is_path()"
16823        );
16824        assert!(!via_path.is_git(), "paired negation pin");
16825    }
16826}